Skip to content

Commit c66bf15

Browse files
committed
build: Split up build into more conventional plugins / build-src
1 parent e594eec commit c66bf15

20 files changed

+304
-288
lines changed

build-src/build.gradle.kts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
plugins {
2+
`kotlin-dsl`
3+
kotlin("jvm") version "2.1.20"
4+
}
5+
repositories {
6+
mavenCentral()
7+
gradlePluginPortal()
8+
maven("https://oss.sonatype.org/content/repositories/snapshots")
9+
maven("https://maven.architectury.dev/")
10+
maven("https://maven.fabricmc.net")
11+
maven("https://maven.wagyourtail.xyz/releases")
12+
maven("https://maven.wagyourtail.xyz/snapshots")
13+
maven("https://maven.neoforged.net/releases")
14+
maven("https://maven.minecraftforge.net/")
15+
maven("https://repo.spongepowered.org/maven/")
16+
maven("https://repo.sk1er.club/repository/maven-releases/")
17+
}
18+
19+
dependencies {
20+
api("xyz.wagyourtail.unimined:unimined:1.3.14")
21+
api("commons-io:commons-io:2.16.1")
22+
api("org.ow2.asm:asm-util:9.7")
23+
api("org.ow2.asm:asm-tree:9.7")
24+
api("org.ow2.asm:asm:9.7")
25+
api("org.ow2.asm:asm-commons:9.7")
26+
api("org.ow2.asm:asm-analysis:9.7")
27+
api("com.gradleup.shadow:shadow-gradle-plugin:9.0.0-beta12")
28+
api("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20")
29+
api("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:2.1.20")
30+
}

build-src/settings.gradle.kts

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Dependencies {
2+
val LIB_NINE_PATCH = "io.github.juuxel:libninepatch:1.2.0"
3+
val JB_ANNOTATIONS = "org.jetbrains:annotations:24.0.1"
4+
5+
/**
6+
* Intentionally old version of GSON to properly compile on 1.8.9
7+
*/
8+
val LEGACY_GSON = "com.google.code.gson:gson:2.1"
9+
10+
val LOMBOK = "org.projectlombok:lombok:1.18.32"
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
fun cmd(vararg args: String): String? {
3+
val process = ProcessBuilder()
4+
.redirectOutput(ProcessBuilder.Redirect.PIPE)
5+
.command(*args)
6+
.start()
7+
val p = process.waitFor()
8+
if (p != 0) {
9+
println("${args.toList()} encountered error")
10+
return null
11+
}
12+
return process.inputStream.readAllBytes().decodeToString()
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import org.gradle.api.publish.PublicationContainer
2+
import org.gradle.api.publish.maven.MavenPublication
3+
4+
fun PublicationContainer.defaultMaven(configure: MavenPublication.() -> Unit) {
5+
val publication = maybeCreate(SharedNames.MAVEN_PUBLICATION_NAME, MavenPublication::class.java)
6+
configure(publication)
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object SharedNames {
2+
const val MAVEN_PUBLICATION_NAME = "maven"
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Version {
2+
val tag = cmd("git", "describe", "--tags", "HEAD")
3+
val hash = cmd("git", "rev-parse", "--short", "HEAD")!!
4+
val isSnapshot = tag == null || hash in tag
5+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
import java.nio.charset.StandardCharsets
3+
4+
repositories {
5+
mavenLocal()
6+
mavenCentral()
7+
maven("https://repo.nea.moe/releases")
8+
maven("https://repo.spongepowered.org/maven/")
9+
maven("https://maven.neoforged.net/releases")
10+
}
11+
12+
13+
group = "org.notenoughupdates.moulconfig"
14+
version = if (Version.isSnapshot) "9999.9999.9999" else Version.tag!!
15+
16+
tasks.withType(JavaCompile::class) {
17+
options.encoding = StandardCharsets.UTF_8.name()
18+
}
19+
20+
tasks.withType(ShadowJar::class).configureEach {
21+
relocate("juuxel.libninepatch", "io.github.notenoughupdates.moulconfig.deps.libninepatch")
22+
}
23+
afterEvaluate {
24+
extensions.findByType<PublishingExtension>()?.apply {
25+
repositories {
26+
if (project.hasProperty("moulconfigPassword") && !Version.isSnapshot) {
27+
maven {
28+
url = uri("https://maven.notenoughupdates.org/releases")
29+
name = "moulconfig"
30+
credentials(PasswordCredentials::class)
31+
authentication {
32+
create<BasicAuthentication>("basic")
33+
}
34+
}
35+
}
36+
}
37+
publications.filterIsInstance<MavenPublication>().forEach {
38+
it.pom {
39+
licenses {
40+
license {
41+
name.set("LGPL-3.0 or later")
42+
url.set("https://github.com/NotEnoughUpdates/NotEnoughUpdates/blob/HEAD/COPYING.LESSER")
43+
}
44+
}
45+
developers {
46+
developer {
47+
name.set("NotEnoughUpdates contributors")
48+
}
49+
developer {
50+
name.set("Linnea Gräf")
51+
}
52+
}
53+
scm {
54+
url.set("https://github.com/NotEnoughUpdates/MoulConfig")
55+
}
56+
}
57+
}
58+
}
59+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import xyz.wagyourtail.unimined.api.UniminedExtension
2+
import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask
3+
4+
plugins {
5+
id("xyz.wagyourtail.unimined")
6+
id("org.jetbrains.dokka")
7+
id("moulconfig.kotlin")
8+
id("moulconfig.leaf")
9+
}
10+
11+
the<UniminedExtension>().minecraft {
12+
version("1.21.4")
13+
mappings {
14+
intermediary()
15+
yarn("1")
16+
}
17+
18+
fabric {
19+
loader("0.16.9")
20+
val aF = project.file("src/main/resources/moulconfig.accesswidener")
21+
if (aF.exists())
22+
accessWidener(aF)
23+
}
24+
runs {
25+
config("client") {
26+
jvmArgs("-Dmoulconfig.testmod=true")
27+
jvmArgs("-Dmoulconfig.warn.crash=false")
28+
// env.putAll(parseEnvFile(file(".env")))
29+
}
30+
}
31+
}
32+
33+
34+
val remapJar by tasks.named("remapJar", RemapJarTask::class) {
35+
asJar {
36+
archiveClassifier.set("")
37+
}
38+
39+
dependsOn(tasks.shadowJar)
40+
inputFile.set(tasks.shadowJar.flatMap { it.archiveFile })
41+
}
42+
43+
tasks.named("jar", Jar::class) {
44+
archiveClassifier.set("small")
45+
dependsOn(tasks.processResources)
46+
}
47+
48+
49+
tasks.withType(Jar::class) {
50+
this.filesMatching(listOf("fabric.mod.json")) {
51+
filter {
52+
if (it.contains("FabricMain")) ""
53+
else it
54+
}
55+
}
56+
exclude("io/github/notenoughupdates/moulconfig/test/**")
57+
}
58+
59+
configure<PublishingExtension> {
60+
publications {
61+
defaultMaven {
62+
artifact(remapJar) {
63+
classifier = ""
64+
}
65+
}
66+
}
67+
}
68+
69+

0 commit comments

Comments
 (0)