-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
208 lines (176 loc) · 6.2 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
import java.time.Duration
plugins {
id 'java-library'
id 'checkstyle'
id 'jacoco'
id 'com.github.spotbugs' version '6.0.23'
id 'maven-publish'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0' // publish to Maven Central
id 'com.github.ben-manes.versions' version '0.51.0' // check for out-of-date dependencies (run 'dependencyUpdates' manually)
id 'org.sonatype.gradle.plugins.scan' version '2.8.3' // scan for vulnerabilities
id 'org.sonarqube' version '5.1.0.4882' // sonarQube analysis
}
group = 'com.imsweb'
version = file('VERSION').text
description = 'Java implementation of the Multiple Primary and Histology Coding Rules.'
println "Starting build using JDK ${Runtime.version().feature()}"
repositories {
mavenCentral()
}
dependencies {
implementation 'org.apache.commons:commons-lang3:3.17.0'
implementation 'com.opencsv:opencsv:5.9'
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.imsweb:seerapi-client-java:5.6'
testImplementation 'com.imsweb:data-generator:1.33'
}
// enforce UTF-8, display the compilation warnings
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
}
// the Javadoc was made way too strict in Java 8 and it's not worth the time fixing everything!
tasks.withType(Javadoc).configureEach {
options.addStringOption('Xdoclint:none', '-quiet')
}
// generate javadoc and sources (required by Nexus)
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
// customize the manifest
jar {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'Information Management Services Inc.',
'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.mph'
)
}
}
// checkstyle plugin settings
checkstyle {
ignoreFailures = false
configFile = project(':').file('config/checkstyle/checkstyle.xml')
configProperties = ['suppressionFile': project(':').file('config/checkstyle/suppressions.xml')]
}
// jacoco plugin settings
jacocoTestReport {
reports {
xml.required = true
}
}
test.finalizedBy jacocoTestReport
// spotbugs plugin settings
spotbugs {
ignoreFailures = false
excludeFilter.set(project(':').file("config/spotbugs/spotbugs-exclude.xml"))
}
sonarqube {
properties {
property "sonar.projectKey", "imsweb_mph"
property "sonar.organization", "imsweb"
property "sonar.host.url", "https://sonarcloud.io"
property 'sonar.exclusions', '**/lab/*'
property 'sonar.coverage.exclusions', '**/lab/*'
}
}
// Nexus vulnerability scan (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'
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
// https://github.com/ben-manes/gradle-versions-plugin
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(it.candidate.version)
}
}
// needed to deploy to Maven Central
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'mph'
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'MPH'
description = 'Java implementation of the Multiple Primary and Histology Coding Rules.'
url = 'https://github.com/imsweb/mph'
inceptionYear = '2016'
licenses {
license {
name = 'A modified BSD License (BSD)'
url = 'https://github.com/imsweb/mph/blob/master/LICENSE'
distribution = 'repo'
}
}
developers {
developer {
id = 'depryf'
name = 'Fabian Depry'
email = '[email protected]'
}
}
scm {
url = 'https://github.com/imsweb/mph'
connection = 'scm:https://github.com/imsweb/mph.git'
developerConnection = 'scm:[email protected]:imsweb/mph.git'
}
}
}
}
}
// setup JAR signing
signing {
required { !project.version.endsWith('-SNAPSHOT') }
String signingKey = project.findProperty('signingKey') ?: ''
String signingPassword = project.findProperty('signingPassword') ?: ''
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
// needed to release on maven central
nexusPublishing {
repositories {
sonatype {
stagingProfileId = '63e5ddd3ab0d16'
username = project.findProperty("nexusUsername")
password = project.findProperty("nexusPassword")
}
}
clientTimeout = Duration.ofSeconds(300)
connectTimeout = Duration.ofSeconds(60)
transitionCheckOptions {
maxRetries.set(50)
delayBetween.set(Duration.ofMillis(5000))
}
}
tasks.register('hematoDataTest', Test) {
include '**/HematoDataTest.class'
}
// Gradle wrapper, this allows to build the project without having to install Gradle!
wrapper {
gradleVersion = '8.10.2'
distributionType = Wrapper.DistributionType.ALL
}