-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.gradle.kts
158 lines (139 loc) · 4.01 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
import com.diffplug.gradle.spotless.FormatExtension
import org.jetbrains.gradle.ext.settings
import org.jetbrains.gradle.ext.taskTriggers
plugins {
`java-gradle-plugin`
alias(libs.plugins.indra)
alias(libs.plugins.indra.gradlePluginPublish)
alias(libs.plugins.indra.licenserSpotless)
alias(libs.plugins.indra.checkstyle)
alias(libs.plugins.pluginPublish)
alias(libs.plugins.spotless)
alias(libs.plugins.ideaExt)
eclipse
}
repositories {
mavenCentral()
gradlePluginPortal()
}
// Worker hijinks
// workerShared available at compile time in workerClasspath and main
// workerClasspath is isolated for worker-only deps
val workerShared by sourceSets.registering
val workerClasspath by sourceSets.registering {
compileClasspath += sourceSets.main.get().compileClasspath
}
val privateRuntime by configurations.registering
configurations.runtimeClasspath {
extendsFrom(privateRuntime.get())
}
// Register worker bits to the unpacked variant
listOf(configurations.apiElements, configurations.runtimeElements).forEach {
it.configure {
outgoing.variants.named("classes") {
artifact(workerClasspath.flatMap { it.java.destinationDirectory}) {
type = ArtifactTypeDefinition.JVM_CLASS_DIRECTORY
}
artifact(workerShared.flatMap { it.java.destinationDirectory}) {
type = ArtifactTypeDefinition.JVM_CLASS_DIRECTORY
}
}
}
}
// Then add them to the jar
tasks.jar {
from(workerShared.map { it.output })
from(workerClasspath.map { it.output })
}
dependencies {
implementation(libs.mammoth)
"workerClasspathCompileOnly"(libs.pebble)
"workerClasspathCompileOnly"(libs.snakeyamlEngine)
"workerClasspathCompileOnly"(workerShared.map { it.output })
compileOnly(workerShared.map { it.output })
privateRuntime.name(workerClasspath.map { it.output })
privateRuntime.name(workerShared.map { it.output })
compileOnly(libs.ideaExtPlugin)
testImplementation(libs.mammoth.test)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.api)
testRuntimeOnly(libs.junit.engine)
testRuntimeOnly(libs.junit.launcher)
checkstyle(libs.stylecheck)
}
// generated sources (blossom jr)
val templatesRoot = layout.projectDirectory.dir("src/main/java-templates")
val templateDest = layout.buildDirectory.dir("generated/sources/java-templates/")
val processTemplates = tasks.register("generateJavaTemplates", Sync::class) {
val templateProperties = mapOf(
"pebbleVersion" to libs.versions.pebble.get(),
"snakeyamlVersion" to libs.versions.snakeyaml.get()
)
inputs.properties(templateProperties)
from(templatesRoot)
into(templateDest)
expand(templateProperties.toMutableMap())
}
sourceSets.main {
java.srcDir(processTemplates.map { it.outputs })
}
eclipse.synchronizationTasks(processTemplates)
if (idea.project != null) {
setOf(idea.project.settings.taskTriggers.afterSync(processTemplates))
}
if (idea.module != null) {
idea.module.generatedSourceDirs.add(templateDest.get().asFile)
}
indra {
github("KyoriPowered", "blossom") {
ci(true)
}
javaVersions {
target(11)
minimumToolchain(17)
testWith(11, 17, 21)
}
checkstyle(libs.versions.checkstyle.get())
signWithKeyFromPrefixedProperties("kyori")
configurePublications {
pom {
url = "https://blossom.kyori.net"
organization {
name = "KyoriPowered"
url = "https://kyori.net"
}
developers {
developer {
id = "zml"
email = "zml at kyori [.] net"
timezone = "America/Vancouver"
}
}
}
}
}
indraPluginPublishing {
plugin(
"blossom",
"net.kyori.blossom.Blossom",
"blossom",
project.description,
listOf("templating", "replacement")
)
website("https://blossom.kyori.net/")
}
spotless {
fun FormatExtension.applyCommon() {
endWithNewline()
indentWithSpaces(2)
trimTrailingWhitespace()
}
java {
targetExclude("build/generated/**")
applyCommon()
importOrderFile(rootProject.file(".spotless/kyori.importorder"))
}
kotlinGradle {
applyCommon()
}
}