-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle
188 lines (158 loc) · 5.41 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
plugins {
id 'java'
id 'io.freefair.lombok' version '8.6'
id 'org.springframework.boot' version '2.7.18'
id 'io.spring.dependency-management' version '1.1.4'
id 'jacoco'
id 'org.sonarqube' version '5.0.0.4638'
id 'maven-publish'
}
group = 'com.iexec.worker'
ext {
springCloudVersion = '2021.0.8'
commonsMathsVersion = '3.6.1'
testContainersVersion = '1.19.3'
}
if (!project.hasProperty('gitBranch')) {
ext.gitBranch = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
}
if (gitBranch != 'main' && gitBranch != 'master' && !(gitBranch ==~ '(release|hotfix|support)/.*')) {
version += '-NEXT-SNAPSHOT'
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://docker-regis-adm.iex.ec/repository/maven-public/"
credentials {
username nexusUser
password nexusPassword
}
}
maven {
url "https://jitpack.io"
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
dependencies {
// iexec
implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion"
implementation "com.iexec.common:iexec-common:$iexecCommonVersion"
implementation "com.iexec.commons:iexec-commons-containers:$iexecCommonsContainersVersion"
implementation "com.iexec.result-proxy:iexec-result-proxy-library:$iexecResultVersion"
implementation "com.iexec.sms:iexec-sms-library:$iexecSmsVersion"
implementation "com.iexec.core:iexec-core-library:$iexecCoreVersion"
// spring
implementation "org.springframework.boot:spring-boot-starter"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springframework.boot:spring-boot-starter-websocket"
implementation "org.springframework.cloud:spring-cloud-starter"
implementation "org.springframework.cloud:spring-cloud-starter-openfeign"
implementation "org.springframework.retry:spring-retry"
// apache commons-lang3
implementation 'org.apache.commons:commons-lang3'
// Apache commons-math3
implementation "org.apache.commons:commons-math3:${commonsMathsVersion}"
// Required for com.iexec.worker.feign.config.RestTemplateConfig
implementation 'org.apache.httpcomponents:httpclient'
implementation 'org.glassfish.jersey.inject:jersey-hk2'
implementation 'org.glassfish.jersey.bundles.repackaged:jersey-guava:2.25.1'
implementation 'javax.activation:activation:1.1.1'
// Removes 'warning: unknown enum constant When.MAYBE'
implementation 'com.google.code.findbugs:annotations:3.0.1'
// observability
runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
// expiring map
implementation 'net.jodah:expiringmap:0.5.10'
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
sourceCompatibility = "11"
targetCompatibility = "11"
}
springBoot {
buildInfo()
}
tasks.named("bootJar") {
manifest {
attributes("Implementation-Title": "iExec Worker",
"Implementation-Version": project.version)
}
}
testing {
suites {
test {
useJUnitJupiter()
dependencies {
implementation "org.springframework.boot:spring-boot-starter-test"
implementation "org.mockito:mockito-inline" // activates mocking final classes/methods
// awaitility
implementation "org.awaitility:awaitility"
// testcontainers
implementation "org.testcontainers:junit-jupiter:$testContainersVersion"
}
}
}
}
tasks.withType(Test).configureEach {
finalizedBy jacocoTestReport
}
tasks.register('itest') {
group 'Verification'
description 'Runs the integration tests.'
}
// sonarqube code coverage requires jacoco XML report
jacocoTestReport {
reports {
xml.required = true
}
}
tasks.sonarqube.dependsOn tasks.jacocoTestReport
publishing {
publications {
maven(MavenPublication) {
artifact tasks.named("bootJar")
from components.java
}
}
repositories {
maven {
credentials {
username nexusUser
password nexusPassword
}
url project.hasProperty('nexusUrl') ? nexusUrl : ''
}
}
}
ext.jarPathForOCI = relativePath(tasks.bootJar.outputs.files.singleFile)
ext.gitShortCommit = 'git rev-parse --short=8 HEAD'.execute().text.trim()
ext.ociImageName = 'local/' + ['bash', '-c', 'basename $(git config --get remote.origin.url) .git'].execute().text.trim()
tasks.register('buildImage', Exec) {
group 'Build'
description 'Builds an OCI image from a Dockerfile.'
dependsOn bootJar
commandLine 'docker', 'build', '--build-arg', 'jar=' + jarPathForOCI, '-t', ociImageName + ':dev', '.'
}
// ##################
// # proxy #
// ##################
//gradle bootRun -PproxyHost=192.168.XX.XXX -PproxyPort=3128
project.ext.getJvmArgs = {
if (project.hasProperty("proxyHost") && project.hasProperty("proxyPort")) {
return ["-Dhttp.proxyHost=" + project.proxyHost, "-Dhttp.proxyPort=" + project.proxyPort]
} else {
return []
}
}
bootRun {
jvmArgs = project.ext.getJvmArgs()
}