-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
218 lines (188 loc) · 7.22 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
plugins {
id 'io.codearte.nexus-staging' version '0.30.0' // logs into Sonotype OSS and does a "Close" and "Release"
id 'com.github.spotbugs' version '6.0.15'
id 'com.adarshr.test-logger' version '4.0.0'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'org.sonatype.gradle.plugins.scan' version '2.8.2'
id 'org.sonarqube' version '5.0.0.4638'
}
sonarqube {
properties {
property "sonar.projectKey", "imsweb_staging-client-java"
property "sonar.organization", "imsweb"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.cpd.exclusions", "**/com/imsweb/staging/entities/impl/**"
property "sonar.coverage.exclusions", "**/UpdaterUtils.java"
property "sonar.gradle.skipCompile", "true"
}
}
// configure nexus staging plugin
nexusStaging {
numberOfRetries = 50
delayBetweenRetriesInMillis = 5000
packageGroup = 'com.imsweb'
}
// don't try to release a snapshot to a non-snapshot repository, that won't work anyway
if (version.endsWith('-SNAPSHOT')) {
gradle.startParameter.excludedTaskNames += 'closeAndReleaseRepository'
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'checkstyle'
apply plugin: "com.github.spotbugs"
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'com.adarshr.test-logger'
apply plugin: "com.github.ben-manes.versions"
apply plugin: 'org.sonatype.gradle.plugins.scan'
apply plugin: "org.sonarqube"
group = 'com.imsweb'
version = '11.3.1'
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
testImplementation 'org.assertj:assertj-core:3.26.0'
testImplementation 'com.google.code.bean-matchers:bean-matchers:0.14'
testImplementation 'org.slf4j:slf4j-simple:2.0.13'
}
// fail the build if there are compiler warnings
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
//options.compilerArgs << "-Xlint:all" << "-Xlint:-serial" << "-Xlint:-options" << "-Werror"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
repositories {
mavenCentral()
}
checkstyle {
toolVersion = '8.29'
configFile = file("../config/checkstyle/checkstyle.xml")
}
spotbugs {
excludeFilter = file("../config/spotbugs/spotbugs-exclude.xml")
}
jar {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': archiveVersion,
'Implementation-Vendor': group,
'Created-By': System.properties['java.vm.version'] + ' (' + System.properties['java.vm.vendor'] + ')',
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Built-JDK': System.getProperty('java.version'),
'Automatic-Module-Name': 'com.imsweb.algorithms.staging'
)
}
}
test {
useJUnitPlatform()
}
jacocoTestReport {
reports {
xml.required = true
}
}
test.finalizedBy jacocoTestReport
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { qualifier -> version.toUpperCase().contains(qualifier) }
def regex = /^[0-9,.v-]+$/
return !stableKeyword && !(version ==~ regex)
}
dependencyUpdates {
// ignore alpha, beta, etc. versions
rejectVersionIf { selection ->
isNonStable(selection.candidate.version)
}
}
// Nexus vulnerability scan (see https://github.com/sonatype-nexus-community/scan-gradle-plugin)
ossIndexAudit {
outputFormat = 'DEPENDENCY_GRAPH'
printBanner = false
excludeCoordinates = ['com.fasterxml.jackson.core:jackson-core:2.14.2']
}
check.dependsOn 'ossIndexAudit'
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
options.addStringOption('Xdoclint:none', '-quiet')
}
}
// zip up all algorithms
tasks.register('zipAlgorithms', JavaExec) {
mainClass.set('com.imsweb.staging.zip.ZipAlgorithm')
classpath = sourceSets.test.runtimeClasspath
}
// don't try to sign a snapshot; its not needed
if (version.endsWith('-SNAPSHOT')) {
gradle.startParameter.excludedTaskNames += 'signMavenJavaPublication'
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = project.name
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'Staging Java Client'
description = 'A cancer staging client library'
url = 'https://github.com/imsweb/staging-client-java'
inceptionYear = '2015'
licenses {
license {
name = 'A modified BSD License (BSD)'
url = 'https://github.com/imsweb/staging-client-java/blob/master/LICENSE'
distribution = 'repo'
}
}
developers {
developer {
id = 'ctmay4'
name = 'Chuck May'
email = 'mayc@imsweb.com'
}
}
scm {
url = 'https://github.com/imsweb/staging-client-java'
connection = 'scm:https://github.com/imsweb/staging-client-java.git'
developerConnection = 'scm:git@github.com:imsweb/staging-client-java.git'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = project.findProperty('nexusUsername') ?: ''
password = project.findProperty('nexusPassword') ?: ''
}
}
}
}
signing {
def signingKey = project.findProperty('signingKey') ?: ''
def signingPassword = project.findProperty('signingPassword') ?: ''
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
}
wrapper {
gradleVersion = '8.8'
distributionType = Wrapper.DistributionType.ALL
}