-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle.kts
160 lines (136 loc) · 4.75 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import org.cadixdev.gradle.licenser.Licenser
import org.cadixdev.gradle.licenser.LicenseExtension
plugins {
`java-library`
jacoco
id("org.cadixdev.licenser") version "0.5.0" apply false
}
val projectName: String by project
val projectUrl: String by project
val projectInceptionYear: String by project
val bombeVersion: String by project
val groovyVersion: String by project
val spockVersion: String by project
val isSnapshot = version.toString().endsWith("-SNAPSHOT")
allprojects {
group = "org.cadixdev"
version = "0.6.0-SNAPSHOT"
}
subprojects {
apply<JavaLibraryPlugin>()
apply<GroovyPlugin>()
apply<JacocoPlugin>()
apply<MavenPublishPlugin>()
apply<Licenser>()
repositories {
mavenCentral()
if (bombeVersion.endsWith("-SNAPSHOT")) {
maven("https://oss.sonatype.org/content/groups/public/")
}
}
dependencies {
// Standard JUnit
testImplementation(platform("org.junit:junit-bom:5.7.0"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-engine")
// Spock
testImplementation("org.codehaus.groovy:groovy-all:$groovyVersion")
testImplementation("org.spockframework:spock-core:$spockVersion")
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
withSourcesJar()
withJavadocJar()
}
tasks.javadoc {
options.optionFiles(rootProject.file("gradle/javadoc.options"))
}
configure<LicenseExtension> {
header = rootProject.file("HEADER.txt")
}
tasks.withType<JavaCompile>().configureEach {
options.release.set(8)
}
tasks.test {
useJUnitPlatform()
}
tasks.jacocoTestReport {
reports {
xml.isEnabled = false
csv.isEnabled = false
html.destination = file("${buildDir}/jacocoHtml")
}
}
tasks.processResources {
from(rootProject.file("LICENSE.txt"))
}
configure<PublishingExtension> {
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
from(components["java"])
withoutBuildIdentifier()
pom {
name.set(projectName)
description.set(project.description)
packaging = "jar"
url.set(projectUrl)
inceptionYear.set(projectInceptionYear)
scm {
connection.set("scm:git:https://github.com/CadixDev/Lorenz.git")
developerConnection.set("scm:git:[email protected]:CadixDev/Lorenz.git")
url.set("https://github.com/CadixDev/Lorenz")
}
issueManagement {
system.set("GitHub")
url.set("https://github.com/CadixDev/Lorenz/issues")
}
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/MIT")
distribution.set("repo")
}
}
developers {
developer {
id.set("jamierocks")
name.set("Jamie Mansfield")
email.set("[email protected]")
url.set("https://www.jamiemansfield.me")
timezone.set("Europe/London")
}
}
}
}
}
repositories {
val url = if (isSnapshot) {
"https://oss.sonatype.org/content/repositories/snapshots/"
} else {
"https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
maven(url) {
credentials(PasswordCredentials::class)
name = "ossrh"
}
}
}
if (project.hasProperty("ossrhUsername") && project.hasProperty("ossrhPassword")) {
apply<SigningPlugin>()
configure<SigningExtension> {
useGpgCmd()
setRequired {
!isSnapshot && (
gradle.taskGraph.hasTask("publishAllPublicationsToOssrhRepository")
|| gradle.taskGraph.hasTask("publishMavenPublicationToOssrhRepository")
)
}
sign(project.extensions.getByType<PublishingExtension>().publications["maven"])
}
}
}