Skip to content

Commit

Permalink
Move common build logic to convention plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
LostLuma committed Jul 23, 2024
1 parent 13c2d1a commit 2cb375d
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 193 deletions.
28 changes: 28 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
`kotlin-dsl`
}

repositories {
maven {
name = "Architectury"
url = uri("https://maven.architectury.dev")
}
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net")
}
maven {
name = "NeoForge"
url = uri("https://maven.neoforged.net/releases")
}
gradlePluginPortal()
}

dependencies {
implementation(libs.architectury.loom)
implementation(libs.architectury.plugin)

// Enable using version catalog in local plugins
// https://github.com/gradle/gradle/issues/15383
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
13 changes: 13 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pluginManagement {
repositories {
gradlePluginPortal()
}
}

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
30 changes: 30 additions & 0 deletions build-logic/src/main/kotlin/dynamic_fps.base.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
id("base")
}

val baseName = project.property("archives_name").toString()

val mavenGroup = project.property("maven_group").toString()
val modVersion = project.property("mod_version").toString()

base {
archivesName = baseName
}

group = mavenGroup
version = modVersion

if (project.hasProperty("loom.platform")) {
val platform = project.property("loom.platform")
val minecraft = project.property("minecraft_version_min")

version = "${modVersion}+minecraft-${minecraft}-${platform}"
}

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

filesMatching(listOf("fabric.mod.json", "mods.toml", "neoforge.mods.toml", "quilt.mod.json")) {
expand(inputs.properties)
}
}
19 changes: 19 additions & 0 deletions build-logic/src/main/kotlin/dynamic_fps.java.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)
}
}
36 changes: 36 additions & 0 deletions build-logic/src/main/kotlin/dynamic_fps.module.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import org.gradle.accessors.dm.LibrariesForLibs

plugins {
id("dynamic_fps.base")
id("dynamic_fps.java")
id("architectury-plugin")
id("dev.architectury.loom")
}

val libs = the<LibrariesForLibs>()

architectury {
minecraft = libs.versions.minecraft.get()
}

loom {
silentMojangMappingsLicense()

mods.create("dynamic_fps") {
sourceSet(sourceSets.main.get())
}
}

repositories {
maven {
name = "LostLuma"
url = uri("https://maven.lostluma.net/releases")
}
}

dependencies {
minecraft(libs.minecraft)
mappings(loom.officialMojangMappings())

implementation(libs.battery)
}
68 changes: 0 additions & 68 deletions build.gradle

This file was deleted.

3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
alias(libs.plugins.architectury.loom).apply(false)
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ org.gradle.jvmargs = -Xmx3G
mod_version = 3.6.0

maven_group = juliand665
archives_base_name = dynamic-fps
archives_name = dynamic-fps

# Game Properties
minecraft_version_min = 1.21.0
Expand Down
10 changes: 6 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ cloth_config = "15.0.127"

mixinextras = "0.3.5"

architectury = "3.4.155"
architectury_loom = "1.6.397"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }

Expand Down Expand Up @@ -51,10 +54,9 @@ cloth_config = { module = "me.shedaniel.cloth:cloth-config", version.ref = "clot
mixinextras_common = { module = "io.github.llamalad7:mixinextras-common", version.ref = "mixinextras" }
mixinextras_forge = { module = "io.github.llamalad7:mixinextras-forge", version.ref = "mixinextras" }

[bundles]
architectury_plugin = { module = "architectury-plugin:architectury-plugin.gradle.plugin", version.ref = "architectury" }
architectury_loom = { module = "dev.architectury.loom:dev.architectury.loom.gradle.plugin", version.ref = "architectury_loom" }

[plugins]
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }

architectury = { id = "architectury-plugin", version = "3.4.155" }
architectury_loom = { id = "dev.architectury.loom", version = "1.6.397" }
architectury_loom = { id = "dev.architectury.loom", version.ref = "architectury_loom" }
28 changes: 0 additions & 28 deletions platforms/common/build.gradle

This file was deleted.

19 changes: 19 additions & 0 deletions platforms/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id("dynamic_fps.module")
}

val platforms = project.property("enabled_platforms").toString()

architectury {
common(platforms.split(","))
}

loom {
accessWidenerPath = file("src/main/resources/dynamic_fps.accesswidener")
}

dependencies {
modImplementation(libs.cloth.config)
// Note: This is only here for the @Environment annotation, do not use!
modImplementation(libs.fabric.loader)
}
23 changes: 1 addition & 22 deletions platforms/fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id("dynamic_fps.module")
alias libs.plugins.shadow
}

Expand Down Expand Up @@ -41,14 +42,6 @@ dependencies {
shadowCommon(project(path: ":platforms:common", configuration: "transformProductionFabric")) { transitive false }
}

processResources {
inputs.property "version", rootProject.mod_version

filesMatching("fabric.mod.json") {
expand "version": rootProject.mod_version
}
}

shadowJar {
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
Expand All @@ -71,17 +64,3 @@ components.java {
skip()
}
}

publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}
23 changes: 1 addition & 22 deletions platforms/forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id("dynamic_fps.module")
alias libs.plugins.shadow
}

Expand Down Expand Up @@ -40,14 +41,6 @@ dependencies {
shadowCommon(project(path: ":platforms:common", configuration: "transformProductionForge")) { transitive = false }
}

processResources {
inputs.property "version", rootProject.mod_version

filesMatching("META-INF/mods.toml") {
expand "version": rootProject.mod_version
}
}

shadowJar {
exclude "fabric.mod.json"
exclude "architectury.common.json"
Expand All @@ -71,17 +64,3 @@ components.java {
skip()
}
}

publishing {
publications {
mavenForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}
Loading

0 comments on commit 2cb375d

Please sign in to comment.