Skip to content

Commit

Permalink
Merge pull request #2 from LostLuma/feature/build-script-improvements
Browse files Browse the repository at this point in the history
Improve build logic
  • Loading branch information
Pixaurora authored Jul 12, 2024
2 parents f7cb12a + 833af08 commit ba32887
Show file tree
Hide file tree
Showing 35 changed files with 283 additions and 276 deletions.
20 changes: 0 additions & 20 deletions build-logic/build.gradle

This file was deleted.

24 changes: 24 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
plugins {
`kotlin-dsl`
}

repositories {
maven {
name = "Quilt"
url = uri("https://maven.quiltmc.org/repository/release")
}
// Currently needed for Intermediary and other temporary dependencies
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
gradlePluginPortal()
}

dependencies {
implementation(libs.quilt.loom)
}

kotlin {
jvmToolchain(21)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pluginManagement {
}
}

dependencyResolutionManagement{
dependencyResolutionManagement {
versionCatalogs {
libs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
Expand Down
29 changes: 0 additions & 29 deletions build-logic/src/main/groovy/kit_tunes.base_mod_conventions.gradle

This file was deleted.

16 changes: 0 additions & 16 deletions build-logic/src/main/groovy/kit_tunes.game_mod_conventions.gradle

This file was deleted.

19 changes: 0 additions & 19 deletions build-logic/src/main/groovy/kit_tunes.java.17.gradle

This file was deleted.

19 changes: 0 additions & 19 deletions build-logic/src/main/groovy/kit_tunes.java.21.gradle

This file was deleted.

19 changes: 0 additions & 19 deletions build-logic/src/main/groovy/kit_tunes.java.8.gradle

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import org.gradle.api.Project;

public class ProjectMetadata {
private final Project project;
private final ProjectProperties properties;

public ProjectMetadata(Project project) {
this.project = project;
this.properties = new ProjectProperties(project);
}

public String mod_id() {
public String modId() {
String modId = String.valueOf(properties.requireString(Property.BASE_MOD_ID));

Optional<String> subModId = properties.optionalString(Property.SUB_MOD_ID);
Expand All @@ -23,14 +25,25 @@ public String mod_id() {
return modId;
}

public String base_file_name() {
String modId = this.mod_id().replace("_", "-");
public String version() {
return this.properties.requireString(Property.MOD_VERSION);
}

return modId + "-" + this.properties.requireString(Property.UPDATE_TITLE) + "-"
+ this.properties.requireString(Property.MOD_VERSION);
public String archiveName() {
String base = this.modId().replace("_", "-");

if (this.isRootProject()) {
base += "-" + this.properties.requireString(Property.UPDATE_TITLE);
}

if (!this.project.hasProperty(Property.MINECRAFT_VERSION_MIN.key())) {
return base;
} else {
return base + "-minecraft-" + this.properties.requireString(Property.MINECRAFT_VERSION_MIN);
}
}

public String game_mod_file_name() {
return this.base_file_name() + "+minecraft-" + this.properties.requireString(Property.MINECRAFT_VERSION);
private boolean isRootProject() {
return this.project.getRootProject().equals(this.project);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package net.pixaurora.kit_tunes.build_logic;

public enum Property {
BASE_MOD_ID("archives_base_name"), SUB_MOD_ID("sub_mod_name"), MOD_VERSION("mod_version"),
UPDATE_TITLE("update_title"), MINECRAFT_VERSION("minecraft_version");
BASE_MOD_ID("archives_base_name"),
SUB_MOD_ID("sub_mod_name"),
MOD_VERSION("mod_version"),
UPDATE_TITLE("update_title"),
MINECRAFT_VERSION_MIN("minecraft_version_min");

private final String key;

Expand Down
30 changes: 30 additions & 0 deletions build-logic/src/main/kotlin/kit_tunes.base.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import net.pixaurora.kit_tunes.build_logic.ProjectMetadata

plugins {
id("base")
}

val metadata = ProjectMetadata(project)
extra.set("metadata", metadata)

version = metadata.version()

base {
archivesName = metadata.archiveName()
}

repositories {
mavenCentral()
maven {
name = "Quilt"
url = uri("https://maven.quiltmc.org/repository/release")
}
}

tasks.withType<ProcessResources> {
inputs.property("version", metadata.version())

filesMatching("quilt.mod.json") {
expand(inputs.properties)
}
}
19 changes: 19 additions & 0 deletions build-logic/src/main/kotlin/kit_tunes.java.08.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id("java")
}

java {
withSourcesJar()

toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"

javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(8)
}
}
19 changes: 19 additions & 0 deletions build-logic/src/main/kotlin/kit_tunes.java.17.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id("java")
}

java {
withSourcesJar()

toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"

javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
19 changes: 19 additions & 0 deletions build-logic/src/main/kotlin/kit_tunes.java.21.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id("java")
}

java {
withSourcesJar()

toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"

javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(21)
}
}
21 changes: 21 additions & 0 deletions build-logic/src/main/kotlin/kit_tunes.module.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import net.pixaurora.kit_tunes.build_logic.ProjectMetadata

plugins {
id("kit_tunes.base")
id("org.quiltmc.loom")
}

val metadata = extra.get("metadata") as ProjectMetadata

loom {
mods.create(metadata.modId()) {
sourceSet(sourceSets.main.get())
}
}

dependencies {
modImplementation("org.quiltmc:quilt-loader:0.26.0")

mappings(loom.officialMojangMappings())
minecraft("com.mojang:minecraft:${project.property("minecraft_version")}")
}
36 changes: 0 additions & 36 deletions build.gradle

This file was deleted.

Loading

0 comments on commit ba32887

Please sign in to comment.