forked from ehcache/ehcache3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
285 lines (246 loc) · 8.05 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/*
* Copyright Terracotta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import scripts.*
import org.gradle.internal.jvm.Jvm
plugins {
// This adds tasks to auto close or release nexus staging repos
// see https://github.com/Codearte/gradle-nexus-staging-plugin/
id 'io.codearte.nexus-staging'
//OWASP Security Vulnerability Detection
id 'org.owasp.dependencycheck'
// Declare spotbugs at the top
id 'com.github.spotbugs' apply false
// Declare bnd at the top
id 'biz.aQute.bnd.builder' apply false
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
if (deployUrl.contains('nexus')) {
//internal terracotta config, shorten url for this plugin to end at local/
project.nexusStaging {
serverUrl = deployUrl.replaceAll(~/local\/.*$/, "local/")
packageGroup = 'Ehcache OS' //internal staging repository name
}
ext {
deployUser = tcDeployUser
deployPwd = tcDeployPassword
}
} else {
project.nexusStaging {
packageGroup = 'org.ehcache' //Sonatype staging repository name
}
ext {
deployUser = sonatypeUser
deployPwd = sonatypePwd
}
}
project.nexusStaging {
username = project.ext.deployUser
password = project.ext.deployPwd
logger.debug("Nexus Staging: Using login ${username} and url ${serverUrl}")
}
// Disable automatic promotion for added safety
closeAndReleaseRepository.enabled = false
ext {
baseVersion = findProperty('overrideVersion') ?: ehcacheVersion
utils = new Utils(baseVersion, logger)
isReleaseVersion = !baseVersion.endsWith('SNAPSHOT')
isCloudbees = System.getenv('JENKINS_URL')?.contains('cloudbees')
}
assert (JavaVersion.current().isJava8Compatible()) : 'The Ehcache 3 build requires Java 8+ to run'
ext {
testJava = Jvm.current()
}
if (hasProperty('testVM')) {
testJava = Utils.jvmForHome(new File(testVM))
println "Using Test JVM $testJava [Version: $testJava.javaVersion.majorVersion]"
}
dependencyCheck {
failBuildOnCVSS = 0
suppressionFile = 'config/owasp-supressions.xml'
skipConfigurations += ['checkstyle', 'spotbugs']
skipProjects += [':docs', ':demos:00-NoCache', ':demos:01-CacheAside']
}
tasks.register('check') {
dependsOn dependencyCheckAggregate
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'checkstyle'
apply plugin: 'com.github.spotbugs'
apply plugin: 'jacoco'
group = 'org.ehcache.modules'
version = baseVersion
archivesBaseName = "ehcache-${project.name}"
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
if (project.hasProperty('mvnlocal')) {
mavenLocal()
}
mavenCentral()
maven { url "https://repo.terracotta.org/maven2" }
}
sourceSets {
slowTest {
java.srcDir 'src/slow-test/java'
resources.srcDir 'src/slow-test/resources'
compileClasspath += sourceSets.test.compileClasspath
runtimeClasspath += sourceSets.test.runtimeClasspath
}
}
dependencies {
implementation "org.slf4j:slf4j-api:$parent.slf4jVersion"
compileOnly "com.github.spotbugs:spotbugs-annotations:${project.spotbugs.toolVersion}"
testCompileOnly "com.github.spotbugs:spotbugs-annotations:${project.spotbugs.toolVersion}"
testImplementation "junit:junit:$junitVersion"
testImplementation "org.assertj:assertj-core:$assertjVersion"
testImplementation "org.hamcrest:hamcrest-library:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testRuntimeOnly "org.slf4j:slf4j-simple:$parent.slf4jVersion"
}
jar {
utils.fillManifest(manifest,"ehcache-${project.name}")
from "$rootDir/LICENSE"
}
test {
maxHeapSize = "1408m"
systemProperty 'java.awt.headless', 'true'
if (parent.isCloudbees) {
systemProperty 'disable.concurrent.tests', 'true'
}
}
task slowTest(type: Test) {
testClassesDirs = sourceSets.slowTest.output.classesDirs
classpath += sourceSets.slowTest.runtimeClasspath
binResultsDir file("$buildDir/slow-tests-results/binary/$name")
reports.junitXml.destination = file("$buildDir/slow-tests-results")
reports.html.destination = file("$buildDir/reports/slow-tests")
}
task sourceJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
javadoc {
title "$project.archivesBaseName $project.version API"
exclude '**/internal/**'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
archiveClassifier = 'javadoc'
}
artifacts {
archives javadocJar
archives sourceJar
}
checkstyle {
configFile = file("$rootDir/config/checkstyle.xml")
configProperties = ['projectDir':projectDir, 'rootDir':rootDir]
}
spotbugs {
ignoreFailures = false
sourceSets = [sourceSets.main]
}
// Spotbugs itself has a divergence in it's slf4j dependencies.
// This version is independent of the version we use.
configurations.spotbugs.resolutionStrategy {
force 'org.slf4j:slf4j-api:1.8.0-beta4'
}
spotbugsMain {
reports {
// Switch from xml to html by changing these flags
xml.enabled = true
html.enabled = false
}
}
jacoco {
toolVersion = jacocoVersion
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
}
}
tasks.withType(AbstractCompile) {
options.with {
fork = true
}
}
tasks.withType(Test) {
executable = testJava.javaExecutable
maxParallelForks 64
}
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
configurations.all {
resolutionStrategy {
failOnVersionConflict()
// If you want to override a dependency, instead of changing gradle.properties, use something like below
// force 'org.terracotta:statistics:2.0-SNAPSHOT'
}
}
plugins.withId('biz.aQute.bnd.builder') {
/*
* The bnd gradle plugin does not handle our 2-digit snapshot versioning scheme very well. It maps `x.y-SNAPSHOT`
* to `x.y.0.SNAPSHOT`. This is bad since `x.y.0.SNAPSHOT` is considered to be less than *all* `x.y.z`. This means
* the baseline version range expression `(,x.y.0.SNAPSHOT[` will always pick the last release from the previous
* minor line. To fix this we manually map to a 3-digit snapshot version where the 3rd digit is a number chosen
* to be higher than we would ever release ('All the worlds a VAX').
*/
def fixedVersion = project.version.asType(String).replaceAll(/^(\d+.\d+)-SNAPSHOT$/, "\$1.999-SNAPSHOT")
jar {
bnd(
'Bundle-Name': project.properties.subPomName,
'Bundle-Description': project.properties.subPomDesc,
'Bundle-SymbolicName': "org.ehcache.modules.$project.archivesBaseName",
'Bundle-DocURL': 'http://ehcache.org',
'Bundle-License': 'LICENSE',
'Bundle-Vendor': 'Terracotta Inc., a wholly-owned subsidiary of Software AG USA, Inc.',
'Bundle-Version': fixedVersion,
'Service-Component': 'OSGI-INF/*.xml'
)
}
dependencies {
baseline(group: group, name: jar.archiveBaseName.get(), version: "(,${fixedVersion}[") {
force = true
transitive = false
}
}
configurations.baseline {
resolutionStrategy {
componentSelection {
all { selection ->
if (!selection.candidate.version.matches(/\d+(?:\.\d+)*/)) {
selection.reject("Only full releases can be used as OSGi baselines")
}
}
}
}
}
}
}
allprojects {
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs += ['-Werror', '-Xlint:all']
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
}
}