-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
132 lines (116 loc) · 4.47 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
// Workaround for IntelliJ issue where `libs` is errored: https://youtrack.jetbrains.com/issue/KTIJ-19369
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
`java-library`
`maven-publish`
signing
alias(libs.plugins.nexuspublish)
alias(libs.plugins.gitversion)
alias(libs.plugins.versions)
alias(libs.plugins.dependencycheck)
}
val gitVersion: groovy.lang.Closure<String> by extra
version = gitVersion()
group = "com.virtlink.commons"
description = "Adds support for FasterXML's Jackson to Apache Commons Configuration 2."
extra["isSnapshotVersion"] = version.toString().endsWith("-SNAPSHOT")
extra["isDirtyVersion"] = version.toString().endsWith(".dirty")
extra["isCI"] = !System.getenv("CI").isNullOrEmpty()
repositories {
mavenCentral()
}
dependencies {
api (libs.commons.configuration2)
api (libs.jackson.databind)
api (libs.commons.text) // Dependency override of commons.configuration2
compileOnly (libs.jsr305)
testImplementation (libs.junit)
testImplementation (libs.jackson.dataformat.yaml)
testImplementation (libs.guava)
testImplementation (libs.commons.beanutils)
}
configure<JavaPluginExtension> {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
withSourcesJar()
withJavadocJar()
}
allprojects {
tasks {
withType<JavaCompile> {
options.compilerArgs.add("-Xlint:unchecked")
options.compilerArgs.add("-Xlint:deprecation")
}
}
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
pom {
name.set("Jackson for Commons Configuration 2")
description.set(project.description)
url.set("https://github.com/Virtlink/commons-configuration2-jackson")
inceptionYear.set("2015")
licenses {
// From: https://spdx.org/licenses/
license {
name.set("Apache-2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("virtlink")
name.set("Daniel A. A. Pelsmaeker")
email.set("[email protected]")
}
}
scm {
connection.set("scm:[email protected]:Virtlink/commons-configuration2-jackson.git")
developerConnection.set("scm:[email protected]:Virtlink/commons-configuration2-jackson.git")
url.set("scm:[email protected]:Virtlink/commons-configuration2-jackson.git")
}
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/Virtlink/commons-configuration2-jackson")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/"))
username.set(project.findProperty("ossrh.user") as String? ?: System.getenv("OSSRH_USERNAME"))
password.set(project.findProperty("ossrh.token") as String? ?: System.getenv("OSSRH_TOKEN"))
}
}
}
signing {
sign(publishing.publications["mavenJava"])
if (!project.hasProperty("signing.secretKeyRingFile")) {
// If no secretKeyRingFile was set, we assume an in-memory key in the SIGNING_KEY environment variable (used in CI)
useInMemoryPgpKeys(
project.findProperty("signing.keyId") as String? ?: System.getenv("SIGNING_KEY_ID"),
System.getenv("SIGNING_KEY"),
project.findProperty("signing.password") as String? ?: System.getenv("SIGNING_KEY_PASSWORD"),
)
}
}
val checkNotDirty by tasks.registering {
doLast {
if (project.extra["isDirtyVersion"] as Boolean) {
throw GradleException("Cannot publish a dirty version: ${project.version}")
}
}
}
tasks.publish { dependsOn(checkNotDirty) }