-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
215 lines (183 loc) · 6.67 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
import java.time.Duration
plugins {
id 'java-library'
id 'checkstyle'
id 'jacoco'
id 'com.github.spotbugs' version '6.0.20'
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.trim()
description = 'Cancer-related synthetic data generator.'
println "Starting build using JDK ${Runtime.version().feature()}"
repositories {
mavenCentral()
}
dependencies {
api 'com.imsweb:layout:5.7'
api 'com.imsweb:naaccr-xml:11.1'
implementation 'com.imsweb:seerutils:5.6'
implementation 'org.apache.commons:commons-lang3:3.16.0'
implementation 'commons-io:commons-io:2.16.1'
testImplementation 'com.imsweb:validation:3.2'
testImplementation 'com.imsweb:staging-client-java:11.3.0'
testImplementation 'com.imsweb:staging-client-java-cs:11.3.0'
testImplementation 'com.imsweb:staging-client-java-eod-public:11.3.0'
testImplementation 'com.imsweb:staging-client-java-tnm:11.3.0'
testImplementation 'junit:junit:4.13.2'
}
// 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.datagenerator',
'Main-Class': 'com.imsweb.datagenerator.gui.StandaloneNaaccrDataGenerator')
}
from('VERSION') {
rename 'VERSION', 'DATA-GENERATOR-VERSION'
}
from('LICENSE') {
rename 'LICENSE', 'DATA-GENERATOR-LICENSE'
}
}
sonarqube {
properties {
property "sonar.projectKey", "imsweb_data-generator"
property "sonar.organization", "imsweb"
property "sonar.host.url", "https://sonarcloud.io"
property 'sonar.exclusions', '**/lab/*'
property 'sonar.coverage.exclusions', '**/lab/*'
}
}
// Nexus vulnerability scan (see https://github.com/sonatype-nexus-community/scan-gradle-plugin)
ossIndexAudit {
outputFormat = 'DEPENDENCY_GRAPH'
printBanner = false
}
check.dependsOn 'ossIndexAudit'
// checkstyle plugin settings
checkstyle {
ignoreFailures = true
configFile = project(':').file('config/checkstyle/checkstyle.xml')
configProperties = ['suppressionFile': project(':').file('config/checkstyle/suppressions.xml')]
}
// spotbugs plugin settings
spotbugs {
ignoreFailures = true
excludeFilter.set(project(':').file("config/spotbugs/spotbugs-exclude.xml"))
}
jacocoTestReport {
reports {
xml.required = true
}
}
test.finalizedBy jacocoTestReport
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)) || version == '021-11'
}
// 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 = 'data-generator'
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'Synthetic Data Generator'
description = 'This Java library can be used to create synthetic data files.'
url = 'https://github.com/imsweb/data-generator'
inceptionYear = '2016'
licenses {
license {
name = 'A modified BSD License (BSD)'
url = 'https://github.com/imsweb/data-generator/blob/master/LICENSE'
distribution = 'repo'
}
}
developers {
developer {
id = 'depryf'
name = 'Fabian Depry'
email = '[email protected]'
}
}
scm {
url = 'https://github.com/imsweb/data-generator'
connection = 'scm:https://github.com/imsweb/data-generator.git'
developerConnection = 'scm:[email protected]:imsweb/data-generator.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))
}
}
// Gradle wrapper, this allows to build the project without having to install Gradle...
wrapper {
gradleVersion = '8.9'
distributionType = Wrapper.DistributionType.ALL
}