-
Notifications
You must be signed in to change notification settings - Fork 50
/
build.gradle
284 lines (237 loc) · 10.1 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
plugins {
id 'com.gradle.build-scan' version '3.6.2'
}
description = "Butterfly - Application transformation tool"
allprojects {
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: "jacoco"
group = 'com.paypal.butterfly'
version = '3.2.8-SNAPSHOT'
repositories {
mavenLocal()
mavenCentral()
maven{
url "https://repo.spring.io/plugins-release/"
}
}
}
Set testModules = [
"integration-tests",
"tests"
]
subprojects {
apply plugin: 'java'
def javaVersion = JavaVersion.VERSION_1_8
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
test {
testLogging {
events "failed"
// events "started", "passed", "skipped", "failed", "standardError"
// outputs.upToDateWhen {false}
// showStandardStreams = true
}
}
// compileJava {
// options.compilerArgs += ["-Xlint:deprecation", "-Xlint:unchecked"]
// }
ext {
ossrhUsername = System.getenv('SONATYPE_USER')
ossrhPassword = System.getenv('SONATYPE_PASSWORD')
}
jar {
manifest {
attributes 'Implementation-Version': version,
'Implementation-Name': name,
'Implementation-Vendor': 'PayPal'
}
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
if (version.endsWith("SNAPSHOT")) {
if (!name.equals("butterfly-cli-package")) {
artifacts {
archives sourcesJar
}
}
} else if (System.getenv("SECRING_FILE") != null) {
if (!name.equals("butterfly-cli-package")) {
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
artifacts {
archives javadocJar, sourcesJar
}
}
project.ext['signing.keyId'] = "$System.env.GPG_KEYNAME"
project.ext['signing.password'] = "$System.env.GPG_PASSPHRASE"
project.ext['signing.secretKeyRingFile'] = "$System.env.SECRING_FILE"
signing {
sign configurations.archives
}
}
// Publishing non test modules
if (!testModules.contains(name)) {
uploadArchives {
repositories {
mavenDeployer {
if (!version.endsWith("SNAPSHOT") && System.getenv("SECRING_FILE") != null) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name project.name
description project.description
packaging 'jar'
url 'https://github.com/paypal/butterfly'
scm {
connection 'scm:git:git@github.com:paypal/butterfly.git'
developerConnection 'scm:git:git@github.com:paypal/butterfly.git'
url 'git@github.com:paypal/butterfly.git'
}
licenses {
license {
name 'MIT'
url 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id 'fabiocarvalho777'
name 'Fabio Carvalho'
email 'fabiocarvalho777@gmail.com'
organization 'PayPal'
organizationUrl 'http://www.paypal.com'
}
}
}
}
}
}
}
jacocoTestCoverageVerification {
violationRules {
rule { element = 'PACKAGE'; limit { minimum = 0.28 }; includes = ['com.paypal.butterfly.cli'] }
rule { element = 'PACKAGE'; limit { minimum = 0.71 }; includes = ['com.paypal.butterfly.cli.logging'] }
rule { element = 'PACKAGE'; limit { minimum = 0.41 }; includes = ['com.paypal.butterfly.core*'] }
rule { element = 'PACKAGE'; limit { minimum = 0.54 }; includes = ['com.paypal.butterfly.extensions.api'] }
rule { element = 'PACKAGE'; limit { minimum = 0.00 }; includes = ['com.paypal.butterfly.extensions.api*'] }
rule { element = 'PACKAGE'; limit { minimum = 1.00 }; includes = ['com.paypal.butterfly.extensions.springboot*'] }
rule { element = 'PACKAGE'; limit { minimum = 0.00 }; includes = ['com.paypal.butterfly.persist*'] }
rule { element = 'PACKAGE'; limit { minimum = 0.63 }; includes = ['com.paypal.butterfly.test*'] }
rule { element = 'PACKAGE'; limit { minimum = 0.82 }; includes = ['com.paypal.butterfly.utilities*'] }
}
}
}
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
def coverageProjects = subprojects.stream().filter({sb -> !(sb.name in [
// Projects without Java code
'butterfly-bom',
'butterfly-cli-package',
'extensions-catalog',
// API projects without concrete classes, or relevant classes, to be tested
'butterfly-api',
'butterfly-rest-api',
// Test projects
'tests',
'integration-tests'
])}).collect()
additionalSourceDirs = files(coverageProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(coverageProjects.sourceSets.main.allSource.srcDirs)
classDirectories = files(coverageProjects.sourceSets.main.output)
executionData = files(coverageProjects.jacocoTestReport.executionData)
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
html.destination file("${buildDir}/reports/jacoco/html")
xml.destination file("${buildDir}/reports/jacoco/coverage.xml")
}
}
// Returns the hash number of the latest commit
ext.getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '-1', '--pretty=%H'
standardOutput = stdout
}
return stdout.toString().trim()
}
// Returns a String made of project version and commit hash number as a suffix,
// used to tag SNAPSHOT Docker images
ext.getCommitProjectVersion = { version ->
if (version.endsWith('SNAPSHOT')) {
return version + "-" + getGitHash()
} else {
return version
}
}
// Docker repository
// Leaving it empty intentionally, so it defaults to Docker public DTR
ext.docker_repo = ''
// Dependencies version management
ext.lib = [
// Java specs
annotation_api: "javax.annotation:javax.annotation-api:1.3.2",
jaxrs: "javax.ws.rs:javax.ws.rs-api:2.1.1",
bean_validation: "javax.validation:validation-api:2.0.1.Final",
// Spring
spring_context: "org.springframework:spring-context:5.3.30",
spring_boot_starter: "org.springframework.boot:spring-boot-starter:2.7.17",
spring_boot_autoconfigure: "org.springframework.boot:spring-boot-autoconfigure:2.7.17",
spring_boot_loader: "org.springframework.boot:spring-boot-loader:2.7.17",
spring_test: "org.springframework:spring-test:5.3.30",
// Maven
maven_model: "org.apache.maven:maven-model:3.8.1",
maven_invoker: "org.apache.maven.shared:maven-invoker:3.1.0",
// Parsers
gson: "com.google.code.gson:gson:2.10.1",
woodstox_core: "com.fasterxml.woodstox:woodstox-core:6.2.6",
xmlunit: "xmlunit:xmlunit:1.5",
yamlbeans: "com.esotericsoftware.yamlbeans:yamlbeans:1.15",
javaparser_core: "com.github.javaparser:javaparser-core:3.25.6",
jackson: "com.fasterxml.jackson.core:jackson-annotations:2.13.5",
jackson_databind: "com.fasterxml.jackson.core:jackson-databind:2.13.5",
// Drivers
lightcouch: "org.lightcouch:lightcouch:0.1.8",
// Utilities
annotations: "com.google.code.findbugs:annotations:3.0.0",
classgraph: "io.github.classgraph:classgraph:4.8.107",
commons_io: "commons-io:commons-io:2.9.0",
commons_lang3: "org.apache.commons:commons-lang3:3.12.0",
commons_collections4: "org.apache.commons:commons-collections4:4.4",
guava: "com.google.guava:guava:32.1.3-jre",
jopt_simple: "net.sf.jopt-simple:jopt-simple:5.0.4",
plexus_utils: "org.codehaus.plexus:plexus-utils:3.2.1",
reflections: "org.reflections:reflections:0.10.2",
slf4j_api: "org.slf4j:slf4j-api:1.7.30",
log4j_api: "org.apache.logging.log4j:log4j-api:2.17.1",
log4j_core:"org.apache.logging.log4j:log4j-core:2.17.1",
log4j_slf4j_impl: "org.apache.logging.log4j:log4j-slf4j-impl:2.17.1",
//for async log4j2 logging
disruptor: "com.lmax:disruptor:3.4.4",
zip4j: "net.lingala.zip4j:zip4j:2.11.5",
version_compare :"io.github.g00fy2:versioncompare:1.4.1",
// Swagger
swagger_annotations: "io.swagger.core.v3:swagger-annotations:2.0.8",
// Tests
hamcrest: "org.hamcrest:hamcrest-core:1.3",
javassist: "org.javassist:javassist:3.28.0-GA",
objenesis: "org.objenesis:objenesis:2.2",
testng: "org.testng:testng:6.14.2",
mockito_all: "org.mockito:mockito-all:1.10.19",
powermock_module_testng: "org.powermock:powermock-module-testng:1.6.5",
powermock_api_mockito: "org.powermock:powermock-api-mockito:1.6.5",
// Jersey
jersey_core: "org.glassfish.jersey.core:jersey-client:2.26",
jersey_inject: "org.glassfish.jersey.inject:jersey-hk2:2.26",
]