-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.gradle
155 lines (138 loc) · 4.51 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
plugins {
id 'java'
id 'io.freefair.lombok' version '8.10.2'
id 'org.springframework.boot' version '2.7.18'
id 'io.spring.dependency-management' version '1.1.6'
id 'jacoco'
id 'org.sonarqube' version '5.1.0.4882'
id 'maven-publish'
}
ext {
openFeignVersion = '11.10'
testContainersVersion = '1.20.4'
}
if (!project.hasProperty('gitBranch')) {
ext.gitBranch = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
}
allprojects {
group = 'com.iexec.blockchain'
if (gitBranch != 'main' && gitBranch != 'master' && !(gitBranch ==~ '(release|hotfix|support)/.*')) {
version += '-NEXT-SNAPSHOT'
}
repositories {
mavenLocal()
mavenCentral()
// iExec
maven {
url "https://docker-regis-adm.iex.ec/repository/maven-public/"
credentials {
username nexusUser
password nexusPassword
}
}
maven {
url "https://jitpack.io"
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
sourceCompatibility = '11'
targetCompatibility = '11'
}
}
dependencies {
// Spring framework
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
// Spring Doc
implementation 'org.springdoc:springdoc-openapi-ui:1.7.0'
// iexec
implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion"
implementation "com.iexec.common:iexec-common:$iexecCommonVersion"
// feign
implementation "io.github.openfeign:feign-jackson:$openFeignVersion"
implementation "io.github.openfeign:feign-slf4j:$openFeignVersion"
// observability
runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
// integration tests
implementation project(':iexec-blockchain-adapter-api-library')
}
springBoot {
buildInfo()
}
tasks.named("bootJar") {
manifest {
attributes("Implementation-Title": "iExec Blockchain Adapter API",
"Implementation-Version": project.version)
}
}
testing {
suites {
configureEach {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.awaitility:awaitility'
}
}
test {
useJUnitJupiter()
}
itest(JvmTestSuite) {
sources {
java {
srcDirs = ['src/itest/java']
}
}
dependencies {
implementation project()
implementation project(':iexec-blockchain-adapter-api-library')
implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion"
implementation "com.iexec.common:iexec-common:$iexecCommonVersion"
implementation 'org.apache.commons:commons-lang3'
implementation 'org.hibernate.validator:hibernate-validator'
implementation "org.testcontainers:junit-jupiter:$testContainersVersion"
}
}
}
}
publishing {
publications {
maven(MavenPublication) {
artifact tasks.named("bootJar")
from components.java
}
}
repositories {
maven {
credentials {
username nexusUser
password nexusPassword
}
url = project.hasProperty("nexusUrl") ? project.nexusUrl : ''
}
}
}
tasks.withType(Test).configureEach {
finalizedBy jacocoTestReport
}
// sonarqube code coverage requires jacoco XML report
jacocoTestReport {
reports {
xml.required = true
}
}
tasks.sonarqube.dependsOn tasks.jacocoTestReport
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', '.'
}