forked from ben-manes/caffeine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
166 lines (146 loc) · 5.01 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
import com.github.benmanes.gradle.versions.reporter.PlainTextReporter
apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply plugin: 'io.snyk.gradle.plugin.snykplugin'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'org.owasp.dependencycheck'
apply from: "${rootDir}/gradle/coverage.gradle"
buildscript {
apply from: "${rootDir}/gradle/dependencies.gradle"
repositories {
mavenCentral()
gradlePluginPortal {
metadataSources {
ignoreGradleMetadataRedirection()
mavenPom()
artifact()
}
}
}
dependencies {
classpath gradlePlugins.values()
classpath platforms.collect { platform(it) }
configurations.configureEach { configuration ->
restrictions.each { module, version ->
constraints.add(configuration.name, module).version { require version }
}
}
}
}
allprojects {
apply plugin: 'com.github.ethankhall.semantic-versioning'
apply from: "${rootDir}/gradle/eclipse.gradle"
group = 'com.github.ben-manes.caffeine'
version.with {
major = 3 // incompatible API changes
minor = 1 // backwards-compatible additions
patch = 4 // backwards-compatible bug fixes
releaseBuild = rootProject.hasProperty('release')
}
dependencies {
def ignored = [
'api', 'apiElements', 'archives', 'compileClasspath', 'compileOnlyApi', 'default',
'implementation', 'javadocElements', 'runtimeClasspath', 'runtimeElements', 'runtimeOnly',
'sourcesElements', 'testCompileClasspath', 'testRuntimeClasspath']
configurations.configureEach { configuration ->
if (name !in ignored) {
restrictions.each { module, version ->
constraints.add(configuration.name, module).version { require version }
}
}
}
}
}
subprojects {
apply plugin: 'biz.aQute.bnd.builder'
apply plugin: 'java-library'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply from: "${rootDir}/gradle/publish.gradle"
apply from: "${rootDir}/gradle/codeQuality.gradle"
apply from: "${rootDir}/gradle/dependencies.gradle"
apply from: "${rootDir}/gradle/objectLayout.gradle"
configurations.configureEach {
resolutionStrategy.dependencySubstitution {
substitute module('org.hamcrest:hamcrest-core') using module(testLibraries.hamcrest)
}
}
dependencies {
annotationProcessor platforms.collect { platform(it) }
testImplementation libraries.guava
testImplementation testLibraries.junit
testImplementation testLibraries.truth
testImplementation testLibraries.testng
testImplementation testLibraries.mockito
testImplementation testLibraries.hamcrest
testImplementation testLibraries.awaitility
testImplementation testLibraries.osgiCompile
testImplementation platforms.collect { platform(it) }
testImplementation testPlatforms.collect { platform(it) }
testRuntimeOnly testLibraries.osgiRuntime
testRuntimeOnly testLibraries.junitEngines
}
if (project != project(':caffeine')) {
javadoc.options.linksOffline(
"https://static.javadoc.io/${group}/caffeine/${version}/",
relativePath(project(':caffeine').javadoc.destinationDir))
javadoc.dependsOn(project(':caffeine').javadoc)
}
}
nexusPublishing {
repositories {
sonatype {
username = project.properties['nexusUsername'] ?: System.env.NEXUS_USERNAME
password = project.properties['nexusPassword'] ?: System.env.NEXUS_PASSWORD
}
}
}
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA', 'JRE'].any { version.toUpperCase().contains(it) }
def unstableKeyword = ['PREVIEW'].any { version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return (!stableKeyword || unstableKeyword) && !(version ==~ regex)
}
tasks.named('dependencyUpdates').configure {
resolutionStrategy {
componentSelection {
all {
def stable = ['javax.json.bind', 'org.jetbrains.kotlin', 'org.osgi']
if (isNonStable(it.candidate.version) && it.candidate.group in stable) {
reject('release candidate')
}
}
force libraries.coherence
}
}
outputFormatter { result ->
def reporter = new PlainTextReporter(project, revision, gradleReleaseChannel)
result.exceeded.dependencies.removeIf { dependency ->
if (dependency.group.startsWith('org.ops4j')) {
result.current.dependencies.add(dependency)
return true
}
return false
}
reporter.write(System.out, result)
}
}
dependencyCheck {
formats = ['html', 'sarif']*.toUpperCase()
scanBuildEnv = true
failOnError = false
}
dependencyCheckAggregate.dependsOn(subprojects*.tasks.jar)
snyk {
arguments = "--all-sub-projects ${findProperty('snykArgs') ?: ''}"
api = System.env.SNYK_TOKEN
autoDownload = true
autoUpdate = true
}
tasks.named('snyk-test').configure {
notCompatibleWithConfigurationCache(
"The ${name} task is not compatible with the configuration cache")
}
tasks.named('snyk-monitor').configure {
notCompatibleWithConfigurationCache(
"The ${name} task is not compatible with the configuration cache")
}