-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
292 lines (251 loc) · 10.1 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
286
287
288
289
290
291
292
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.github.jk1:gradle-license-report:2.4'
}
}
plugins {
id "io.github.gradle-nexus.publish-plugin" version "1.3.0" apply true
}
def appAndSourceUrl = 'https://github.com/TNG/value-provider'
ext {
app = [
description: 'A library that facilitates writing realistic test data and in turn better tests for your Java application.',
name : 'value-provider',
urls : [
entry : appAndSourceUrl,
doc : appAndSourceUrl,
issues: "${appAndSourceUrl}/issues",
source: appAndSourceUrl
],
gitRepo : '[email protected]:TNG/value-provider.git',
license : [
name: 'The Apache Software License, Version 2.0',
url : 'http://www.apache.org/licenses/LICENSE-2.0.txt'
]
]
company = [
name: 'TNG Technology Consulting GmbH',
url : 'https://www.tngtech.com/'
]
dependency = [
apache_commons : [group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'],
guava : [group: 'com.google.guava', name: 'guava', version: '33.0.0-jre'],
slf4j : [group: 'org.slf4j', name: 'slf4j-api', version: '2.0.12'],
lombok : [group: 'org.projectlombok', name: 'lombok', version: '1.18.30'],
junit4 : [group: 'junit', name: 'junit', version: '4.13.2'],
junit4_dataprovider : [group: 'com.tngtech.junit.dataprovider', name: 'junit4-dataprovider', version: '2.10'],
junit5_dataprovider : [group: 'com.tngtech.junit.dataprovider', name: 'junit-jupiter-dataprovider', version: '2.10'],
assertj_core : [group: 'org.assertj', name: 'assertj-core', version: '3.25.3'],
mockito : [group: 'org.mockito', name: 'mockito-core', version: '5.10.0'],
log4j_api : [group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.23.0'],
log4j_core : [group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.23.0'],
log4j_slf4j : [group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.23.0'],
junit4_engine : [group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.10.2'],
junit_jupiter_api : [group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.10.2'],
junit_jupiter_engine : [group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.2'],
junit_jupiter_params : [group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.10.2'],
junit_platform_runner: [group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.10.2'],
junit_jupiter_testkit: [group: 'org.junit.platform', name: 'junit-platform-testkit', version: '1.10.2']
]
postfixedJar = { File jarFile, String postfix ->
new File(jarFile.parentFile, jarFile.name.replaceAll(/\.jar$/, "-${postfix}.jar"))
}
tempJar = { File jarFile -> postfixedJar(jarFile, 'tmp') }
productionProjects = [
project(':core'),
project(':example'),
project(':junit4'),
project(':junit5')]
releaseProjects = [
project(':core'),
project(':junit4'),
project(':junit5')]
createModuleDescription = { description, proj -> "${description} - Module '${proj.name}'" }
currentScriptRootOf = { it.buildscript.sourceFile.parentFile }
}
allprojects {
group = 'com.tngtech.valueprovider'
version = '1.2.4-SNAPSHOT'
repositories {
mavenCentral()
}
}
task showJdkVersion {
println "Configured JDK: ${JavaVersion.current()}"
}
task clean {
doLast {
project.buildDir.deleteDir()
}
}
subprojects {
apply plugin: 'java-library'
compileJava { options.encoding = "UTF-8" }
compileTestJava { options.encoding = "UTF-8" }
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
dependencies {
implementation dependency.apache_commons
implementation dependency.guava
implementation dependency.slf4j
testImplementation dependency.assertj_core
testImplementation dependency.junit4
testImplementation dependency.junit_jupiter_api
testRuntimeOnly dependency.log4j_slf4j
testRuntimeOnly dependency.log4j_api
testRuntimeOnly dependency.log4j_core
}
repositories {
mavenCentral()
}
test {
useJUnitPlatform()
}
}
ext.isReleaseVersion = !project.version.endsWith("-SNAPSHOT")
// respective username and password can be configured in ~/.gradle/gradle.properties
nexusPublishing {
packageGroup = 'com.tngtech'
repositories {
sonatype {
username = findProperty("sonatypeUsername")
password = findProperty("sonatypePassword")
}
}
}
releaseProjects*.with {
apply plugin: "maven-publish"
apply plugin: "signing"
tasks.withType(GenerateModuleMetadata) {
enabled = false // the meta-data does not match the way the Maven artifacts are composed and thus is broken
}
java {
withJavadocJar()
withSourcesJar()
}
// fix for broken java doc generation when using html tags in javadoc
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
if (JavaVersion.current().isJava9Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addBooleanOption('html5', true)
}
}
}
project(":core") {
archivesBaseName = 'value-provider-core'
description = app.description
}
project(":junit4") {
archivesBaseName = 'value-provider-junit4'
description = 'JUnit 4 test infrastructure to reproduce random test data in case of test failures.'
}
project(":junit5") {
archivesBaseName = 'value-provider-junit5'
description = 'JUnit 5 test infrastructure to reproduce random test data in case of test failures.'
}
project(":example") {
archivesBaseName = 'value-provider-example'
description = 'Examples for test data factories using the value-provider library.'
}
tasks.withType(Jar) {
from(rootProject.rootDir) {
include("LICENSE", "NOTICE")
into("META-INF")
}
manifest {
def title = project.archivesBaseName
def now = java.time.LocalDate.now()
def today = now.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd"))
def companyName = company.name
def copyright = "${now.year} ${companyName}"
attributes(
'Built-By': "Gradle ${gradle.gradleVersion}",
'Built-Date': today,
'Specification-Title': project.archivesBaseName,
'Specification-Version': archiveVersion,
'Specification-Vendor': companyName,
'Implementation-Title': title,
'Implementation-Version': archiveVersion,
'Implementation-Vendor': company.name,
'Issue-Tracker': "https://github.com/TNG/value-provider/issues",
'Documentation-URL': "https://github.com/TNG/value-provider",
'Copyright': copyright,
'License': app.license.name,
)
}
}
tasks.withType(AbstractPublishToMaven) {
it.dependsOn(build)
}
tasks.withType(PublishToMavenRepository) {
it.doFirst {
assert !gradle.startParameter.isParallelProjectExecutionEnabled():
'uploading archives with parallel execution seems to lead to broken uploads in Sonatype Nexus'
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = project.archivesBaseName
from components.java
pom {
name = project.archivesBaseName
packaging = "jar"
description = project.description
url = app.urls.entry
developers {
developer {
id = 'stefanhechtltng'
name = 'Stefan Hechtl'
email = '[email protected]'
}
developer {
id = 'jonashoef'
name = 'Jonas Höf'
email = '[email protected]'
}
}
licenses {
license {
name = app.license.name
url = app.license.url
distribution = 'repo'
}
}
organization {
name = company.name
url = company.url
}
scm {
url = app.urls.source
connection = "scm:${app.gitRepo}"
developerConnection = "scm:${app.gitRepo}"
}
}
}
}
}
signing {
// requires gradle.properties, see http://www.gradle.org/docs/current/userguide/signing_plugin.html
required {
isReleaseVersion && gradle.taskGraph.hasTask('publish')
}
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
}
apply plugin: 'com.github.jk1.dependency-license-report'