forked from iExecBlockchainComputing/iexec-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
178 lines (149 loc) · 5.26 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
plugins {
id 'java'
id 'io.freefair.lombok' version '8.2.2'
id 'org.springframework.boot' version '2.7.14'
id 'io.spring.dependency-management' version '1.1.3'
id 'jacoco'
id 'org.sonarqube' version '4.2.1.3168'
id 'maven-publish'
}
group = 'com.iexec.worker'
ext {
springCloudVersion = '2021.0.8'
dockerJavaVersion = '3.2.12'
lombokVersion = '1.18.2'
}
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.blockchain:iexec-blockchain-adapter-api-library:$iexecBlockchainAdapterVersion"
implementation "com.iexec.result-proxy:iexec-result-proxy-library:$iexecResultVersion"
implementation "com.iexec.sms:iexec-sms-library:$iexecSmsVersion"
// 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'
// 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'
// docker
implementation "com.github.docker-java:docker-java:${dockerJavaVersion}"
// expiring map
implementation 'net.jodah:expiringmap:0.5.10'
// tests
testImplementation "org.springframework.boot:spring-boot-starter-test"
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation "org.mockito:mockito-inline" // activates mocking final classes/methods
// awaitility
testImplementation "org.awaitility:awaitility"
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
springBoot {
buildInfo()
}
tasks.named("bootJar") {
manifest {
attributes("Implementation-Title": "iExec Worker",
"Implementation-Version": project.version)
}
}
test {
useJUnitPlatform()
}
tasks.register('itest') {
group 'Verification'
description 'Runs the integration tests.'
}
// sonarqube code coverage requires jacoco XML report
jacocoTestReport {
reports {
xml.required = true
}
}
tasks.test.finalizedBy tasks.jacocoTestReport
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 ("sh", "-c", "docker build --build-arg jar=$jarPathForOCI -t $ociImageName:$gitShortCommit ."
+ " && docker tag $ociImageName:$gitShortCommit $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()
}