-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
225 lines (189 loc) · 6.98 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
import java.time.Duration
plugins {
id 'java-library'
id 'checkstyle'
id 'jacoco'
id 'com.github.spotbugs' version '6.1.5'
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.52.0' // check for out-of-date dependencies (run 'dependencyUpdates' manually)
id 'org.sonatype.gradle.plugins.scan' version '3.0.0' // scan for vulnerabilities
id 'org.sonarqube' version '6.0.1.5171' // sonarQube analysis
}
group = 'com.imsweb'
version = file('VERSION').text.trim()
description = 'Framework that allows defining file formats (layouts) and use them to read and write data files.'
println "Starting build using JDK ${Runtime.version().feature()}"
repositories {
mavenCentral()
maven {
url = 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
api 'com.imsweb:naaccr-xml:11.2'
implementation 'com.thoughtworks.xstream:xstream:1.4.21'
implementation 'de.siegmar:fastcsv:3.4.0'
implementation 'commons-io:commons-io:2.18.0'
implementation 'org.apache.commons:commons-lang3:3.17.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.imsweb:seerutils:5.6'
testImplementation 'com.imsweb:seerutils-gui:1.20'
testImplementation 'com.imsweb:naaccr-api-client:1.1' // access NAACCR documentation API
testImplementation 'org.commonmark:commonmark:0.24.0' // convert markdown to HTML for NAACCR documentation
testImplementation 'org.freemarker:freemarker:2.3.34' // fill it template for NAACCR documentation
testImplementation('org.xhtmlrenderer:core-renderer:R8') { // Java Swing HTML renderer for NAACCR documentation lab
exclude module: 'itext'
}
}
// enforce UTF-8, display the compilation warnings
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' << '-Xlint:rawtypes' << '-Werror'
}
// 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_11
targetCompatibility = JavaVersion.VERSION_11
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.layout'
)
}
}
// Nexus vulnerability scan (https://github.com/sonatype-nexus-community/scan-gradle-plugin)
ossIndexAudit {
outputFormat = 'DEPENDENCY_GRAPH'
printBanner = false
excludeVulnerabilityIds = [
'CVE-2022-42003',
'CVE-2022-42004',
'sonatype-2022-6438'
]
}
check.dependsOn 'ossIndexAudit'
// checkstyle plugin settings
checkstyle {
ignoreFailures = true
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 = true
excludeFilter.set(project(':').file("config/spotbugs/spotbugs-exclude.xml"))
}
sonarqube {
properties {
property "sonar.projectKey", "imsweb_layout"
property "sonar.organization", "imsweb"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.exclusions", "**/lab/**"
property "sonar.coverage.exclusions", "**/lab/**"
}
}
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 = 'layout'
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'Layout Framework'
description = 'Framework that allows defining file formats (layouts) and use them to read and write data files.'
url = 'https://github.com/imsweb/layout'
inceptionYear = '2015'
licenses {
license {
name = 'A modified BSD License (BSD)'
url = 'https://github.com/imsweb/layout/blob/master/LICENSE'
distribution = 'repo'
}
}
developers {
developer {
id = 'depryf'
name = 'Fabian Depry'
email = '[email protected]'
}
}
scm {
url = 'https://github.com/imsweb/layout'
connection = 'scm:https://github.com/imsweb/layout.git'
developerConnection = 'scm:[email protected]:imsweb/layout.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.12.1'
distributionType = Wrapper.DistributionType.ALL
}