-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle.kts
144 lines (124 loc) · 4.14 KB
/
build.gradle.kts
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
group = "dev.thriving.oss"
object Meta {
const val release = "https://s01.oss.sonatype.org/service/local/"
const val snapshot = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
const val desc = "OSS GitHub Java Library Template Repository"
const val license = "Apache-2.0"
const val licenseUrl = "https://opensource.org/licenses/Apache-2.0"
const val githubRepo = "thriving-dev/java-library-template"
const val developerId = "hartmut-co-uk"
const val developerName = "Hartmut Armbruster"
const val developerOrganization = "thriving.dev"
const val developerOrganizationUrl = "https://thriving.dev"
}
java {
sourceCompatibility = JavaVersion.VERSION_21
}
plugins {
// Apply the java-library plugin for API and implementation separation.
`java-library`
`maven-publish`
signing
}
repositories {
mavenCentral()
}
sourceSets {
create("intTest") {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}
}
val intTestImplementation by configurations.getting {
extendsFrom(configurations.implementation.get())
}
configurations["intTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get())
dependencies {
testImplementation(libs.junit)
intTestImplementation(libs.junit)
intTestImplementation(libs.bundles.testcontainers.junit)
intTestImplementation(libs.assertj)
}
val intTest = task<Test>("intTest") {
description = "Runs integration tests."
group = "verification"
testClassesDirs = sourceSets["intTest"].output.classesDirs
classpath = sourceSets["intTest"].runtimeClasspath
shouldRunAfter("test")
useJUnitPlatform()
testLogging {
events("passed")
}
}
tasks.check { dependsOn(intTest) }
tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
signing {
val signingKey = providers.environmentVariable("GPG_SIGNING_KEY")
val signingPassphrase = providers.environmentVariable("GPG_SIGNING_PASSPHRASE")
if (signingKey.isPresent && signingPassphrase.isPresent) {
useInMemoryPgpKeys(signingKey.get(), signingPassphrase.get())
val extension = extensions.getByName("publishing") as PublishingExtension
sign(extension.publications)
}
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
from(components["java"])
pom {
name.set(project.name)
description.set(Meta.desc)
url.set("https://github.com/${Meta.githubRepo}")
licenses {
license {
name.set(Meta.license)
url.set(Meta.licenseUrl)
}
}
developers {
developer {
id.set(Meta.developerId)
name.set(Meta.developerName)
organization.set(Meta.developerOrganization)
organizationUrl.set(Meta.developerOrganizationUrl)
}
}
scm {
url.set("https://github.com/${Meta.githubRepo}.git")
connection.set("scm:git:git://github.com/${Meta.githubRepo}.git")
developerConnection.set("scm:git:git://github.com/${Meta.githubRepo}.git")
}
issueManagement {
url.set("https://github.com/${Meta.githubRepo}/issues")
}
}
}
}
}
tasks.jar {
manifest {
attributes(
mapOf(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
),
)
}
}
java {
withSourcesJar()
withJavadocJar()
}
// gradle locking of dependency versions
// *required+used for trivy scan
dependencyLocking {
lockAllConfigurations()
}
// always run subproject task with parent
rootProject.tasks.dependencies { dependsOn(tasks.dependencies) }