-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
build.gradle
232 lines (196 loc) · 6.86 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
plugins {
id 'ru.vyarus.github-info' version '2.0.0' apply false
id 'ru.vyarus.quality' version '5.0.0' apply false
id 'org.cyclonedx.bom' version '1.10.0' apply false
id 'ru.vyarus.mkdocs' version '4.0.1' apply false
id 'jacoco'
id 'java-platform'
id 'ru.vyarus.java-lib' version '3.0.0'
id 'net.researchgate.release' version '3.0.2'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
id 'com.github.ben-manes.versions' version '0.51.0'
}
wrapper {
gradleVersion = '8.10.1'
}
description = 'Dropwizard guice integration'
ext {
dropwizard = '5.0.0-alpha.5'
guice = '7.0.0'
hk2 = '3.0.6'
spockJunit5 = '1.2.0'
guiceExtAnn = '2.0.1'
guiceValidator = '3.0.2'
}
// root project is a BOM
dependencies {
// dropwizard BOM must go first to let maven select correct guava
api platform("io.dropwizard:dropwizard-dependencies:$dropwizard")
api platform("com.google.inject:guice-bom:$guice")
constraints {
api "com.google.inject:guice:$guice"
api "org.glassfish.hk2:guice-bridge:$hk2"
api "ru.vyarus:spock-junit5:$spockJunit5"
api "ru.vyarus:guice-ext-annotations:$guiceExtAnn"
api "ru.vyarus:guice-validator:$guiceValidator"
// add subprojects to BOM
project.subprojects.each { api it }
}
}
javaLib {
// aggregated test and coverage reports
aggregateReports()
// publish root BOM as custom artifact
bom {
artifactId = 'guicey-bom'
description = 'Guicey BOM'
}
}
maven.pom {
properties = [
'guice.version' : guice,
'dropwizard.version' : dropwizard,
'hk2.version' : hk2,
'guice-ext-annotations.version': guiceExtAnn
]
}
// maven publication related configuration applied to all projects
allprojects {
apply plugin: 'project-report'
apply plugin: 'ru.vyarus.github-info'
apply plugin: 'ru.vyarus.java-lib'
apply plugin: 'signing'
repositories { mavenLocal(); mavenCentral(); maven { url 'https://jitpack.io' } }
configurations.configureEach {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
group = 'ru.vyarus.guicey'
github {
user = 'xvik'
license = 'MIT'
repository = 'dropwizard-guicey'
}
// delay required because java plugin is activated only in subprojects and without it
// pom closure would reference root project only
pluginManager.withPlugin("ru.vyarus.pom") {
maven.pom {
developers {
developer {
id = 'xvik'
name = 'Vyacheslav Rusakov'
email = '[email protected]'
}
}
}
if (System.getenv("SNAPSHOT")) {
// https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-java-packages-with-gradle#publishing-packages-to-github-packages
publishing {
repositories {
maven {
name = "GitHub"
url = "https://maven.pkg.github.com/xvik/dropwizard-guicey"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
}
}
// don't publish gradle metadata artifact
javaLib.withoutGradleMetadata()
// skip signing for jitpack (snapshots)
tasks.withType(Sign) { onlyIf { !(System.getenv('JITPACK') || System.getenv('SNAPSHOT')) } }
}
// all sub-modules are normal java modules, using root BOM (like maven)
subprojects {
apply plugin: 'groovy'
apply plugin: 'jacoco'
apply plugin: 'ru.vyarus.quality'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'org.cyclonedx.bom'
java {
sourceCompatibility = JavaVersion.VERSION_17
}
dependencies {
implementation platform(project(':'))
}
if (project.name != 'dropwizard-guicey') {
// extra modules use different group
group = 'ru.vyarus.guicey'
// common dependencies for all modules except core
dependencies {
implementation project(':dropwizard-guicey')
testImplementation 'io.dropwizard:dropwizard-testing'
}
javaLib {
// java 9 auto module name
autoModuleName = "$group.${project.name.replace('guicey', 'ru.vyarus.dropwizard.guicey').replace('-', '.')}"
}
// use only direct dependencies in the generated pom, removing BOM mentions
maven.removeDependencyManagement()
}
test {
testLogging {
events 'skipped', 'failed'
exceptionFormat 'full'
}
maxHeapSize = '512m'
}
dependencyUpdates.revision = 'release'
if (!project.name.startsWith('guicey-test-')) {
test {
useJUnitPlatform()
}
dependencies {
testImplementation 'ru.vyarus:spock-junit5'
testImplementation 'org.spockframework:spock-core:2.4-M4-groovy-4.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
}
} else {
// don't compile and run tests for legacy junit4 and spock1 modules
tasks.withType(GroovyCompile)
.configureEach { it.onlyIf { JavaVersion.current() <= JavaVersion.VERSION_11 } }
test.onlyIf { JavaVersion.current() <= JavaVersion.VERSION_11 }
}
// SBOM
cyclonedxBom {
includeConfigs = ["runtimeClasspath"]
destination = file("build/reports")
outputName = "bom"
outputFormat = "all"
}
publishing.publications.maven {
artifact(file('build/reports/bom.json')) {
classifier = 'cyclonedx'
builtBy cyclonedxBom
}
artifact(file('build/reports/bom.xml')) {
classifier = 'cyclonedx'
builtBy cyclonedxBom
}
}
}
// dependency on all subprojects required for release validation
check.dependsOn subprojects.check
nexusPublishing {
repositories {
sonatype {
username = findProperty('sonatypeUser')
password = findProperty('sonatypePassword')
}
}
}
// Required signing properties for release: signing.keyId, signing.password and signing.secretKeyRingFile
// (https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials)
release.git.requireBranch.set('master')
// release manages only root project (subprojects will be checked and released implicitly)
afterReleaseBuild {
dependsOn 'publishToSonatype'
dependsOn subprojects.collect { ":$it.name:publishToSonatype" }
dependsOn 'closeAndReleaseSonatypeStagingRepository'
doLast {
logger.warn "RELEASED $project.group:$project.name:$project.version"
}
}