Skip to content

Commit 33dfcf5

Browse files
committed
build: use Indra and proper(-ish) build logic
Signed-off-by: Mariell Hoversholm <[email protected]>
1 parent 389d44d commit 33dfcf5

16 files changed

+216
-178
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/.idea/
2-
/.gradle/
3-
**/build/
2+
.gradle/
3+
**/build/

bom/build.gradle.kts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
plugins {
2+
id("moonshine.publishing")
3+
`java-platform`
4+
}
5+
6+
indra {
7+
configurePublications {
8+
from(components["javaPlatform"])
9+
}
10+
}
11+
12+
dependencies {
13+
constraints {
14+
sequenceOf(
15+
"core",
16+
"standard",
17+
).forEach {
18+
api(project(":moonshine-$it"))
19+
}
20+
}
21+
}

build-logic/build.gradle.kts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
}
8+
9+
dependencies {
10+
implementation(libs.gradle.plugin.indra)
11+
implementation(libs.gradle.plugin.indra.publishing)
12+
implementation(libs.gradle.plugin.testlog)
13+
14+
implementation(files(libs.javaClass.protectionDomain.codeSource.location))
15+
}

build-logic/settings.gradle.kts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
create("libs") {
4+
from(files("../gradle/libs.versions.toml"))
5+
}
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import com.adarshr.gradle.testlogger.theme.ThemeType
2+
import org.gradle.accessors.dm.LibrariesForLibs
3+
4+
plugins {
5+
id("moonshine.publishing")
6+
id("net.kyori.indra")
7+
id("net.kyori.indra.checkstyle")
8+
id("net.kyori.indra.license-header")
9+
id("com.adarshr.test-logger")
10+
java
11+
`java-library`
12+
jacoco
13+
}
14+
15+
testlogger {
16+
theme = ThemeType.MOCHA_PARALLEL
17+
showPassed = true
18+
}
19+
20+
configurations {
21+
testCompileClasspath {
22+
exclude(group = "junit")
23+
}
24+
}
25+
26+
repositories {
27+
mavenCentral()
28+
}
29+
30+
dependencies {
31+
val libs = (project as ExtensionAware).extensions.getByName("libs") as LibrariesForLibs
32+
api(libs.checkerframework)
33+
34+
testImplementation(libs.bundles.testing.api)
35+
testRuntimeOnly(libs.bundles.testing.runtime)
36+
}
37+
38+
java {
39+
disableAutoTargetJvm()
40+
}
41+
42+
tasks {
43+
withType<JavaCompile> {
44+
options.compilerArgs.add("-parameters")
45+
}
46+
47+
compileTestJava {
48+
options.release.set(11)
49+
sourceCompatibility = "11"
50+
targetCompatibility = sourceCompatibility
51+
}
52+
53+
javadoc {
54+
val opt = options as StandardJavadocDocletOptions
55+
opt.addStringOption("Xdoclint:none", "-quiet")
56+
57+
opt.encoding("UTF-8")
58+
opt.charSet("UTF-8")
59+
opt.source("8")
60+
doFirst {
61+
opt.links(
62+
"https://docs.oracle.com/javase/8/docs/api/"
63+
)
64+
}
65+
}
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
plugins {
2+
id("net.kyori.indra.publishing")
3+
}
4+
5+
indra {
6+
javaVersions {
7+
target(8)
8+
}
9+
10+
github("KyoriPowered", "moonshine") {
11+
ci(true)
12+
}
13+
14+
license {
15+
name("Lesser GNU General Public Licence 3.0")
16+
url("https://www.gnu.org/licenses/lgpl-3.0.en.html")
17+
spdx("LGPL-3.0-only")
18+
}
19+
20+
configurePublications {
21+
pom {
22+
developers {
23+
developer {
24+
id.set("Proximyst")
25+
name.set("Mariell Hoversholm")
26+
timezone.set("Europe/Stockholm")
27+
}
28+
}
29+
}
30+
}
31+
}

build.gradle.kts

+3-169
Original file line numberDiff line numberDiff line change
@@ -1,172 +1,6 @@
1-
import nl.javadude.gradle.plugins.license.LicensePlugin
2-
import org.checkerframework.gradle.plugin.CheckerFrameworkPlugin
3-
import java.util.*
4-
51
plugins {
6-
java
7-
`java-library`
8-
`maven-publish`
9-
checkstyle
10-
jacoco
11-
id("com.github.hierynomus.license") version "0.16.1"
12-
id("org.checkerframework") version "0.5.22"
13-
}
14-
15-
allprojects {
16-
group = "net.kyori.moonshine"
17-
version = "2.0.0-SNAPSHOT"
18-
}
19-
20-
subprojects {
21-
apply {
22-
plugin<JavaPlugin>()
23-
plugin<JavaLibraryPlugin>()
24-
plugin<MavenPublishPlugin>()
25-
plugin<CheckstylePlugin>()
26-
plugin<JacocoPlugin>()
27-
plugin<LicensePlugin>()
28-
plugin<CheckerFrameworkPlugin>()
29-
}
30-
31-
dependencies {
32-
api("io.leangen.geantyref:geantyref:1.3.11")
33-
34-
testImplementation("org.junit.jupiter:junit-jupiter:5.+")
35-
testImplementation("org.assertj:assertj-core:3.+")
36-
testImplementation("org.mockito:mockito-junit-jupiter:3.+")
37-
}
38-
39-
tasks {
40-
test {
41-
useJUnitPlatform()
42-
dependsOn(checkstyleMain, checkstyleTest)
43-
if (!System.getenv("CI").toBoolean()) {
44-
dependsOn(licenseFormat)
45-
}
46-
dependsOn(licenseMain, licenseTest)
47-
finalizedBy(jacocoTestReport)
48-
}
49-
50-
jacocoTestReport {
51-
dependsOn(test)
52-
reports {
53-
xml.required.set(true)
54-
html.required.set(true)
55-
csv.required.set(false)
56-
}
57-
}
58-
59-
javadoc {
60-
val opt = options as StandardJavadocDocletOptions
61-
opt.addStringOption("Xdoclint:none", "-quiet")
62-
63-
opt.encoding("UTF-8")
64-
opt.charSet("UTF-8")
65-
opt.source("8")
66-
doFirst {
67-
opt.links(
68-
"https://docs.oracle.com/javase/8/docs/api/"
69-
)
70-
}
71-
}
72-
}
2+
id("moonshine.publishing")
733
}
744

75-
// These are some options that either won't apply to rootProject, or
76-
// will be nice to have to disable potential warnings and errors.
77-
allprojects {
78-
repositories {
79-
mavenCentral()
80-
}
81-
82-
extensions.configure(JavaPluginExtension::class) {
83-
sourceCompatibility = JavaVersion.VERSION_1_8
84-
targetCompatibility = sourceCompatibility
85-
disableAutoTargetJvm()
86-
}
87-
88-
license {
89-
header = rootProject.file("LICENCE-HEADER")
90-
ext["year"] = Calendar.getInstance().get(Calendar.YEAR)
91-
include("**/*.java")
92-
93-
mapping("java", "DOUBLESLASH_STYLE")
94-
}
95-
96-
checkstyle {
97-
toolVersion = "8.44"
98-
val configRoot = rootProject.projectDir.resolve(".checkstyle")
99-
configDirectory.set(configRoot)
100-
configProperties["basedir"] = configRoot.absolutePath
101-
}
102-
103-
jacoco {
104-
reportsDirectory.set(rootProject.buildDir.resolve("reports").resolve("jacoco"))
105-
}
106-
107-
java {
108-
withSourcesJar()
109-
withJavadocJar()
110-
}
111-
112-
tasks {
113-
compileJava {
114-
options.compilerArgs.add("-parameters")
115-
}
116-
117-
compileTestJava {
118-
options.compilerArgs.add("-parameters")
119-
sourceCompatibility = "11"
120-
targetCompatibility = sourceCompatibility
121-
}
122-
}
123-
124-
publishing {
125-
publications {
126-
create<MavenPublication>("maven") {
127-
from(components["java"])
128-
}
129-
}
130-
131-
repositories {
132-
maven {
133-
name = "proxi-nexus"
134-
val repo = if (project.version.toString().endsWith("-SNAPSHOT")) {
135-
"snapshots"
136-
} else {
137-
"releases"
138-
}
139-
url = uri("https://nexus.mardroemmar.dev/repository/maven-$repo/")
140-
credentials {
141-
val proxiUser: String? by project
142-
val proxiPassword: String? by project
143-
username = proxiUser
144-
password = proxiPassword
145-
}
146-
}
147-
}
148-
}
149-
}
150-
151-
tasks {
152-
test {
153-
finalizedBy(jacocoTestReport)
154-
}
155-
156-
jacocoTestReport {
157-
dependsOn(allprojects.map { it.tasks.test })
158-
159-
additionalSourceDirs(files(subprojects.map { it.sourceSets.main.get().allSource.srcDirs }))
160-
additionalClassDirs(files(subprojects.map { it.sourceSets.main.get().output }))
161-
executionData.setFrom(files(
162-
subprojects.flatMap { it.tasks.jacocoTestReport.map { it.executionData }.get() }
163-
.filter { it.exists() }
164-
))
165-
166-
reports {
167-
xml.required.set(true)
168-
html.required.set(true)
169-
csv.required.set(false)
170-
}
171-
}
172-
}
5+
group = "net.kyori.moonshine"
6+
version = "2.0.0-SNAPSHOT"

core/build.gradle.kts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
plugins {
2+
id("moonshine.api")
3+
}
4+
15
dependencies {
6+
api("io.leangen.geantyref:geantyref:1.3.11")
27
implementation(project(":moonshine-internal-common"))
38
implementation(project(":moonshine-internal-jre8"))
49
implementation(project(":moonshine-internal-jre9"))
510
testImplementation(project(":moonshine-standard"))
611
testImplementation("net.kyori:examination-api:1.+")
712
testImplementation("net.kyori:examination-string:1.+")
8-
}
13+
}

gradle/libs.versions.toml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[versions]
2+
gradle-plugin-indra = "2.0.6"
3+
gradle-plugin-testlog = "3.0.0"
4+
5+
checkerframework = "3.18.0"
6+
junit-jupiter = "5.7.2"
7+
assertj = "3.20.2"
8+
mockito = "3.12.4"
9+
10+
[libraries]
11+
gradle-plugin-indra = { module = "net.kyori:indra-common", version.ref = "gradle-plugin-indra" }
12+
gradle-plugin-indra-publishing = { module = "net.kyori:indra-publishing-sonatype", version.ref = "gradle-plugin-indra" }
13+
gradle-plugin-testlog = { module = "com.adarshr:gradle-test-logger-plugin", version.ref = "gradle-plugin-testlog" }
14+
15+
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit-jupiter" }
16+
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit-jupiter" }
17+
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit-jupiter" }
18+
assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" }
19+
mockito = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" }
20+
checkerframework = { module = "org.checkerframework:checker-qual", version.ref = "checkerframework" }
21+
22+
[bundles]
23+
testing-api = [
24+
"junit-jupiter-api",
25+
"junit-jupiter-params",
26+
"assertj-core",
27+
"mockito",
28+
]
29+
testing-runtime = [
30+
"junit-jupiter-engine",
31+
]

internal-common/build.gradle.kts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
id("moonshine.api")
3+
}
4+
5+
dependencies {
6+
api("io.leangen.geantyref:geantyref:1.3.11")
7+
}

internal-jre8/build.gradle.kts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
plugins {
2+
id("moonshine.api")
3+
}
4+
15
dependencies {
26
api(project(":moonshine-internal-common"))
3-
}
7+
}

0 commit comments

Comments
 (0)