This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
198 lines (164 loc) · 5.47 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
plugins {
id 'ru.vyarus.github-info' version '1.5.0' apply false
id 'ru.vyarus.quality' version '4.9.0' apply false
id 'org.cyclonedx.bom' version '1.7.4' apply false
id 'jacoco'
id 'java-platform'
id 'ru.vyarus.java-lib' version '2.4.0'
id 'net.researchgate.release' version '3.0.2'
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
id 'com.github.ben-manes.versions' version '0.46.0'
}
wrapper {
gradleVersion = '7.4'
}
description = 'Dropwizard-guicey extensions'
ext {
guicey = '6.0.0-beta.1'
guiceExtAnn = '1.4.0'
}
// root project is a BOM (like maven)
dependencies {
// inherited BOMs declaration
api platform("ru.vyarus.guicey:guicey-bom:$guicey")
constraints {
api "ru.vyarus:guice-ext-annotations:$guiceExtAnn"
api 'ru.vyarus:guice-validator:2.0.1'
// 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 extensions BOM'
}
}
pom {
delegate.properties {
'guicey.version' guicey
'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.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
group = 'ru.vyarus.guicey'
github {
user = 'xvik'
license = 'MIT'
}
// delay required because java plugin is activated only in subprojects and without it
// pom closure would reference root project only
afterEvaluate {
pom {
developers {
developer {
id 'xvik'
name 'Vyacheslav Rusakov'
email '[email protected]'
}
}
}
}
// don't publish gradle metadata artifact
javaLib.withoutGradleMetadata()
// skip signing for jitpack (snapshots)
tasks.withType(Sign) {onlyIf { !System.getenv('JITPACK') }}
}
// 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'
sourceCompatibility = 11
// common dependencies for all modules
dependencies {
implementation platform(project(':'))
compileOnly 'com.github.spotbugs:spotbugs-annotations:4.7.3'
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'ru.vyarus: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
pom.removeDependencyManagement()
}
test {
// useJUnitPlatform()
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:1.2.0'
testImplementation 'org.spockframework:spock-core:2.3-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"
}
}