-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
234 lines (199 loc) · 7.33 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
import java.time.Duration
plugins {
id 'java-library'
id 'checkstyle'
id 'jacoco'
id 'com.github.spotbugs' version '6.0.26'
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 = 'This framework allows edits to be defined in Groovy and to be executed on various data types.'
println "Starting build using JDK ${Runtime.version().feature()}"
repositories {
mavenCentral()
}
dependencies {
api 'com.imsweb:staging-client-java:11.3.1'
api 'org.apache.groovy:groovy:4.0.24'
api 'com.thoughtworks.xstream:xstream:1.4.21'
implementation 'commons-codec:commons-codec:1.17.1'
implementation 'org.apache.commons:commons-lang3:3.17.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'commons-io:commons-io:2.17.0'
testImplementation 'com.imsweb:layout:6.0'
testImplementation 'com.imsweb:staging-client-java-cs:11.3.1'
testImplementation 'com.imsweb:staging-client-java-eod-public:11.3.1'
testImplementation 'com.imsweb:staging-client-java-tnm:11.3.1'
testImplementation('com.imsweb:validation-edits-seer:024-13') { exclude module: 'validation' }
testImplementation('com.imsweb:validation-edits-naaccr-translated:019-01') { exclude module: 'validation' }
}
// 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_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}
// customize the manifest
jar {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': 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.validation'
)
}
}
// checkstyle plugin settings
checkstyle {
ignoreFailures = false
configFile = file('config/checkstyle/checkstyle.xml')
configProperties = ['suppressionFile': file('config/checkstyle/checkstyle-exclude.xml')]
}
// jacoco plugin settings
jacocoTestReport {
reports {
xml.required = true
}
}
test.finalizedBy jacocoTestReport
// spotbugs plugin settings
spotbugs {
ignoreFailures = false
excludeFilter.set(file('config/spotbugs/spotbugs-exclude.xml'))
}
sonarqube {
properties {
property "sonar.projectKey", "imsweb_validation"
property "sonar.organization", "imsweb"
property "sonar.host.url", "https://sonarcloud.io"
property 'sonar.exclusions', '**/lab/*'
property 'sonar.coverage.exclusions', '**/lab/*'
}
}
// use this task to generate the regex parser
tasks.register('generateJavaContextParser') {
doLast {
javaexec {
main = '-jar'
args = ['config/jflex-1.4.2/lib/JFlex.jar',
'--nobak',
'-d',
'src/main/java/com/imsweb/validation/internal/context/',
'config/java-context.flex']
}
}
}
// 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'
]
}
if (project.hasProperty('branch_name') && (project.ext.get('branch_name') == 'master' || project.ext.get('branch_name') == 'main'))
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 = 'validation'
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'Validation Framework'
description = 'This framework allows edits to be defined in Groovy and to be executed on various data types.'
url = 'https://github.com/imsweb/validation'
inceptionYear = '2015'
licenses {
license {
name = 'A modified BSD License (BSD)'
url = 'https://github.com/imsweb/validation/blob/master/LICENSE'
distribution = 'repo'
}
}
developers {
developer {
id = 'depryf'
name = 'Fabian Depry'
email = '[email protected]'
}
}
scm {
url = 'https://github.com/imsweb/validation'
connection = 'scm:https://github.com/imsweb/validation.git'
developerConnection = 'scm:[email protected]:imsweb/validation.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.13'
distributionType = Wrapper.DistributionType.ALL
}