forked from molgenis/molgenis-emx2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
134 lines (113 loc) · 3.44 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id "java"
id "org.sonarqube" version "3.3"
id "de.gliderpilot.semantic-release" version "1.4.2"
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'application'
id 'com.google.cloud.tools.jib' version '3.1.1'
}
targetCompatibility = '16'
sourceCompatibility = '16'
sonarqube {
properties {
property 'sonar.projectName', 'molgenis-emx2'
property 'sonar.projectKey', 'molgenis_molgenis-emx2'
property 'sonar.coverage.jacoco.xmlReportPaths', "${projectDir}/backend/build/reports/jacoco/jacocoMergedReport/jacocoMergedReport.xml"
}
}
allprojects {
group = 'org.molgenis'
}
tasks.withType(Test) {
maxParallelForks = Runtime.runtime.availableProcessors();
}
repositories {
mavenLocal()
maven {
url = 'https://repo.maven.apache.org/maven2'
}
}
dependencies {
implementation project(':backend:molgenis-emx2-run')
}
mainClassName = 'org.molgenis.emx2.RunMolgenisEmx2'
shadowJar {
archiveBaseName = 'molgenis-emx2'
}
publishing {
repositories {
maven {
// change to point to repo later
url = "$buildDir/repo"
}
}
}
project.ext.ghToken = project.hasProperty('ghToken') ? project.getProperty('ghToken') : System.getenv('GITHUB_TOKEN') ?: null
semanticRelease {
repo {
releaseAsset shadowJar
ghToken = project.ghToken
}
}
def imageName = 'docker.io/molgenis/molgenis-emx2'
def tagName = project.version.toString()
if (version.toString().endsWith('-SNAPSHOT')) {
ext.hash = 'git rev-parse --short HEAD'.execute().text.trim()
imageName = "docker.io/molgenis/molgenis-emx2-snapshot"
tagName = "${project.version.toString()}-${ext.hash}"
}
// write a file to pickup in deployment to use specific tags in upgrade
task ci(type: WriteProperties) {
outputFile file('build/ci.properties')
property 'tagName', tagName
}
jib {
from {
image = 'adoptopenjdk:16-jdk-hotspot-focal'
}
to {
image = imageName
tags = [tagName.toString()]
}
container {
mainClass = mainClassName
ports = ['8080']
}
}
String getGitHash() {
// git hash
def command = Runtime.getRuntime().exec("git rev-parse --short HEAD")
def result = command.waitFor()
if (result != 0) {
throw new IOException("Command 'getGitHash()' exited with " + result)
}
String gitCommitHash = command.inputStream.text.trim()
return gitCommitHash
}
//gradle cleanTest test --no-build-cache
task createHelm(type: Exec) {
commandLine 'helm', 'package', 'deploy/helm-chart/', '-d', 'docs/helm-charts/'
commandLine 'helm', 'repo', 'index', 'docs/helm-charts', '--url', 'http://mswertz.github.io/molgenis-emx2/helm-charts'
}
ext {
javaMainClass = "org.molgenis.emx2.RunMolgenisEmx2"
}
application {
mainClassName = javaMainClass
}
jar {
reproducibleFileOrder = true
manifest {
attributes(
'Specification-Version': project.version.toString(),
'Implementation-Version': getGitHash(),
'Created-By': "Gradle ${gradle.gradleVersion}",
'Build-Jdk': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-OS': "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}"
)
}
}