-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.gradle
129 lines (110 loc) · 3.75 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
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id "java"
id "org.sonarqube" version "4.4.1.3373"
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'application'
id 'com.palantir.docker' version '0.35.0'
}
ext {
javaMainClass = "org.molgenis.emx2.RunMolgenisEmx2"
javaVersion = JavaVersion.VERSION_17
}
allprojects {
if(rootProject.nyxState.releaseScope.previousVersion == rootProject.version) {
version = rootProject.nyxState.releaseScope.previousVersion + "-SNAPSHOT"
}
else {
version = rootProject.version.replace("SNAPSHOT.1","SNAPSHOT")
}
}
println "Corrected version checking for optional snapshot: " + rootProject.version
nyxPublish.dependsOn assemble
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"
}
}
tasks.withType(Test) {
maxParallelForks = Runtime.runtime.availableProcessors() / 2;
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation project(':backend:molgenis-emx2-run')
}
mainClassName = 'org.molgenis.emx2.RunMolgenisEmx2'
shadowJar {
zip64 = true
archiveBaseName = 'molgenis-emx2'
mergeServiceFiles()
archiveVersion = project.version.replace("v","")
}
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
def imageName = 'docker.io/molgenis/molgenis-emx2'
def tagName = project.version.toString().replace("v","")
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().replace("v","")}-${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 'TAG_NAME', tagName
property 'FILE_NAME', shadowJar.archiveFile.get().asFile.name
}
docker {
name imageName
tags tagName, 'latest'
files shadowJar.archiveFile.get()
buildArgs(['JAR_FILE': shadowJar.archiveFile.get().asFile.name])
}
tasks.dockerPrepare.dependsOn(shadowJar)
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
}
application {
mainClass.set(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']}"
)
}
}
//task to install pre-commit hook that applies formatting
task installPreCommitGitFormatApplyHook(type: Copy) {
from new File(rootProject.rootDir, 'pre-commit-format-apply')
rename 'pre-commit-format-apply', 'pre-commit'
into { new File(rootProject.rootDir, '.git/hooks') }
fileMode 0775
}