From 81e6fca3e01905df08665d876f367ba2737a1a6c Mon Sep 17 00:00:00 2001 From: TexTrue <3140846162@qq.com> Date: Mon, 5 Aug 2024 20:11:59 +0800 Subject: [PATCH 1/2] rework gradle script part 1 --- base-common/build.gradle | 16 ++------ base-fabric/build.gradle | 48 +---------------------- base-neo/build.gradle | 51 +----------------------- command-common/build.gradle | 13 ++----- command-fabric/build.gradle | 49 +---------------------- command-neo/build.gradle | 52 +------------------------ event-base-common/build.gradle | 13 ++----- event-base-fabric/build.gradle | 48 +---------------------- event-base-neo/build.gradle | 51 +----------------------- fabric/build.gradle | 23 ++--------- gradle/scripts/kessokulib-common.gradle | 9 +++++ gradle/scripts/kessokulib-fabric.gradle | 44 +++++++++++++++++++++ gradle/scripts/kessokulib-neo.gradle | 47 ++++++++++++++++++++++ lifecycle-events-common/build.gradle | 13 ++----- lifecycle-events-fabric/build.gradle | 49 +---------------------- lifecycle-events-neo/build.gradle | 52 +------------------------ neo/build.gradle | 21 ++-------- platform-common/build.gradle | 13 ++----- platform-fabric/build.gradle | 48 +---------------------- platform-neo/build.gradle | 47 +--------------------- registry-common/build.gradle | 13 ++----- registry-fabric/build.gradle | 48 +---------------------- registry-neo/build.gradle | 52 +------------------------ 23 files changed, 148 insertions(+), 672 deletions(-) create mode 100644 gradle/scripts/kessokulib-common.gradle create mode 100644 gradle/scripts/kessokulib-fabric.gradle create mode 100644 gradle/scripts/kessokulib-neo.gradle diff --git a/base-common/build.gradle b/base-common/build.gradle index 98e6e7f2..63d4600f 100644 --- a/base-common/build.gradle +++ b/base-common/build.gradle @@ -1,14 +1,4 @@ -group = "band.kessoku.lib.base" -version = libs.versions.mod.get() + "+common." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-base" -} +apply from: rootProject.file("gradle/scripts/kessokulib-common.gradle") -architectury { - common(["fabric", "neoforge"]) -} - -dependencies { - modImplementation libs.fabric.loader -} \ No newline at end of file +group = "band.kessoku.lib.base" +base.archivesName = rootProject.name + "-base" diff --git a/base-fabric/build.gradle b/base-fabric/build.gradle index 2d020901..f11196ab 100644 --- a/base-fabric/build.gradle +++ b/base-fabric/build.gradle @@ -1,53 +1,9 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} +apply from: rootProject.file("gradle/scripts/kessokulib-fabric.gradle") group = "band.kessoku.lib.base" -version = libs.versions.mod.get() + "+fabric." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-base" -} - -architectury { - platformSetupLoomIde() - fabric() -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentFabric.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} +base.archivesName = rootProject.name + "-base" dependencies { - modImplementation libs.fabric.loader - modImplementation libs.fabric.api common(project(path: ':base-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':base-common', configuration: 'transformProductionFabric') } - -processResources { - inputs.property 'version', project.version - - filesMatching('fabric.mod.json') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - inputFile.set shadowJar.archiveFile -} \ No newline at end of file diff --git a/base-neo/build.gradle b/base-neo/build.gradle index 79923390..c05d9e6a 100644 --- a/base-neo/build.gradle +++ b/base-neo/build.gradle @@ -1,56 +1,9 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} - -base { - archivesName = rootProject.name + "-base" -} +apply from: rootProject.file("gradle/scripts/kessokulib-neo.gradle") group = "band.kessoku.lib.base" -version = libs.versions.mod.get() + "+neoforge." + libs.versions.minecraft.get() - -architectury { - platformSetupLoomIde() - neoForge() -} - -repositories { - maven { url "https://maven.neoforged.net/releases/" } -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentNeoForge.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} +base.archivesName = rootProject.name + "-base" dependencies { - neoForge libs.neo common(project(path: ':base-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':base-common', configuration: 'transformProductionNeoForge') } - -processResources { - inputs.property 'version', project.version - - filesMatching('META-INF/neoforge.mods.toml') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - inputFile.set shadowJar.archiveFile -} \ No newline at end of file diff --git a/command-common/build.gradle b/command-common/build.gradle index 6f266c32..685b1473 100644 --- a/command-common/build.gradle +++ b/command-common/build.gradle @@ -1,16 +1,9 @@ -group = "band.kessoku.lib.command" -version = libs.versions.mod.get() + "+common." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-command_api" -} +apply from: rootProject.file("gradle/scripts/kessokulib-common.gradle") -architectury { - common(["fabric", "neoforge"]) -} +group = "band.kessoku.lib.command" +base.archivesName = rootProject.name + "-command" dependencies { - modImplementation libs.fabric.loader implementation(project(":base-common")) implementation(project(":event-base-common")) } \ No newline at end of file diff --git a/command-fabric/build.gradle b/command-fabric/build.gradle index adfafa17..d8cf2ece 100644 --- a/command-fabric/build.gradle +++ b/command-fabric/build.gradle @@ -1,56 +1,11 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} +apply from: rootProject.file("gradle/scripts/kessokulib-fabric.gradle") group = "band.kessoku.lib.command" -version = libs.versions.mod.get() + "+fabric." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-command_api" -} - -architectury { - platformSetupLoomIde() - fabric() -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentFabric.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} +base.archivesName = rootProject.name + "-command" dependencies { - modImplementation libs.fabric.loader - modImplementation libs.fabric.api - implementation(project(":event-base-common")) common(project(path: ':command-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':command-common', configuration: 'transformProductionFabric') } - -processResources { - inputs.property 'version', project.version - - filesMatching('fabric.mod.json') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - input.set shadowJar.archiveFile -} \ No newline at end of file diff --git a/command-neo/build.gradle b/command-neo/build.gradle index 84906794..abcc0597 100644 --- a/command-neo/build.gradle +++ b/command-neo/build.gradle @@ -1,60 +1,12 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} +apply from: rootProject.file("gradle/scripts/kessokulib-neo.gradle") group = "band.kessoku.lib.command" -version = libs.versions.mod.get() + "+neoforge." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-command_api" -} - -architectury { - platformSetupLoomIde() - neoForge() -} - -repositories { - maven { url "https://maven.neoforged.net/releases/" } -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentNeoForge.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} +base.archivesName = rootProject.name + "-command" dependencies { - neoForge libs.neo - implementation(project(":event-base-common")) implementation(project(":event-base-neo")) common(project(path: ':command-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':command-common', configuration: 'transformProductionNeoForge') } - -processResources { - inputs.property 'version', project.version - - filesMatching('META-INF/neoforge.mods.toml') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - input.set shadowJar.archiveFile -} \ No newline at end of file diff --git a/event-base-common/build.gradle b/event-base-common/build.gradle index 71f49db3..3fd06de1 100644 --- a/event-base-common/build.gradle +++ b/event-base-common/build.gradle @@ -1,15 +1,8 @@ -group = "band.kessoku.lib.event" -version = libs.versions.mod.get() + "+common." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-event-base" -} +apply from: rootProject.file("gradle/scripts/kessokulib-common.gradle") -architectury { - common(["fabric", "neoforge"]) -} +group = "band.kessoku.lib.event" +base.archivesName = rootProject.name + "-event-base" dependencies { - modImplementation libs.fabric.loader implementation(project(":base-common")) } \ No newline at end of file diff --git a/event-base-fabric/build.gradle b/event-base-fabric/build.gradle index 7ffcd497..bd0cc5b8 100644 --- a/event-base-fabric/build.gradle +++ b/event-base-fabric/build.gradle @@ -1,53 +1,9 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} +apply from: rootProject.file("gradle/scripts/kessokulib-fabric.gradle") group = "band.kessoku.lib.event" -version = libs.versions.mod.get() + "+fabric." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-event-base" -} - -architectury { - platformSetupLoomIde() - fabric() -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentFabric.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} +base.archivesName = rootProject.name + "-event-base" dependencies { - modImplementation libs.fabric.loader - modImplementation libs.fabric.api common(project(path: ':event-base-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':event-base-common', configuration: 'transformProductionFabric') } - -processResources { - inputs.property 'version', project.version - - filesMatching('fabric.mod.json') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - inputFile.set shadowJar.archiveFile -} \ No newline at end of file diff --git a/event-base-neo/build.gradle b/event-base-neo/build.gradle index ad7b39dc..bff63401 100644 --- a/event-base-neo/build.gradle +++ b/event-base-neo/build.gradle @@ -1,56 +1,9 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} +apply from: rootProject.file("gradle/scripts/kessokulib-neo.gradle") group = "band.kessoku.lib.event" -version = libs.versions.mod.get() + "+neoforge." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-event-base" -} - -architectury { - platformSetupLoomIde() - neoForge() -} - -repositories { - maven { url "https://maven.neoforged.net/releases/" } -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentNeoForge.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} +base.archivesName = rootProject.name + "-event-base" dependencies { - neoForge libs.neo common(project(path: ':event-base-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':event-base-common', configuration: 'transformProductionNeoForge') } - -processResources { - inputs.property 'version', project.version - - filesMatching('META-INF/neoforge.mods.toml') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - inputFile.set shadowJar.archiveFile -} \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle index 7e9568a9..55657002 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,28 +1,11 @@ -group = "band.kessoku.lib" -version = libs.versions.mod.get() + "+fabric." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name -} +apply from: rootProject.file("gradle/scripts/kessokulib-fabric.gradle") -architectury { - platformSetupLoomIde() - fabric() -} +group = "band.kessoku.lib" +base.archivesName = rootProject.name dependencies { - modImplementation libs.fabric.loader - include(project(":base-fabric")) include(project(":event-base-fabric")) include(project(":platform-fabric")) include(project(":registry-fabric")) } - -processResources { - inputs.property 'version', project.version - - filesMatching('fabric.mod.json') { - expand version: project.version - } -} \ No newline at end of file diff --git a/gradle/scripts/kessokulib-common.gradle b/gradle/scripts/kessokulib-common.gradle new file mode 100644 index 00000000..b84dcc2c --- /dev/null +++ b/gradle/scripts/kessokulib-common.gradle @@ -0,0 +1,9 @@ +version = libs.versions.mod.get() + "+common." + libs.versions.minecraft.get() + +architectury { + common(["fabric", "neoforge"]) +} + +dependencies { + modImplementation libs.fabric.loader +} \ No newline at end of file diff --git a/gradle/scripts/kessokulib-fabric.gradle b/gradle/scripts/kessokulib-fabric.gradle new file mode 100644 index 00000000..13fcb319 --- /dev/null +++ b/gradle/scripts/kessokulib-fabric.gradle @@ -0,0 +1,44 @@ +apply plugin: "com.github.johnrengelman.shadow" + +version = libs.versions.mod.get() + "+fabric." + libs.versions.minecraft.get() + +architectury { + platformSetupLoomIde() + fabric() +} + +configurations { + common { + canBeResolved = true + canBeConsumed = false + } + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentFabric.extendsFrom common + shadowBundle { + canBeResolved = true + canBeConsumed = false + } +} + +dependencies { + modImplementation libs.fabric.loader + modImplementation libs.fabric.api +} + +processResources { + inputs.property 'version', project.version + + filesMatching('fabric.mod.json') { + expand version: project.version + } +} + +shadowJar { + configurations = [project.configurations.shadowBundle] + archiveClassifier = 'dev-shadow' +} + +remapJar { + inputFile.set shadowJar.archiveFile +} \ No newline at end of file diff --git a/gradle/scripts/kessokulib-neo.gradle b/gradle/scripts/kessokulib-neo.gradle new file mode 100644 index 00000000..72ade128 --- /dev/null +++ b/gradle/scripts/kessokulib-neo.gradle @@ -0,0 +1,47 @@ +apply plugin: "com.github.johnrengelman.shadow" + +version = libs.versions.mod.get() + "+neoforge." + libs.versions.minecraft.get() + +architectury { + platformSetupLoomIde() + neoForge() +} + +repositories { + maven { url "https://maven.neoforged.net/releases/" } +} + +configurations { + common { + canBeResolved = true + canBeConsumed = false + } + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentNeoForge.extendsFrom common + shadowBundle { + canBeResolved = true + canBeConsumed = false + } +} + +dependencies { + neoForge libs.neo +} + +processResources { + inputs.property 'version', project.version + + filesMatching('META-INF/neoforge.mods.toml') { + expand version: project.version + } +} + +shadowJar { + configurations = [project.configurations.shadowBundle] + archiveClassifier = 'dev-shadow' +} + +remapJar { + input.set shadowJar.archiveFile +} \ No newline at end of file diff --git a/lifecycle-events-common/build.gradle b/lifecycle-events-common/build.gradle index 33cadd39..6782a733 100644 --- a/lifecycle-events-common/build.gradle +++ b/lifecycle-events-common/build.gradle @@ -1,16 +1,9 @@ -group = "band.kessoku.lib.events.lifecycle" -version = libs.versions.mod.get() + "+common." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-lifecycle-events" -} +apply from: rootProject.file("gradle/scripts/kessokulib-common.gradle") -architectury { - common(["fabric", "neoforge"]) -} +group = "band.kessoku.lib.events.lifecycle" +base.archivesName = rootProject.name + "-lifecycle-events" dependencies { - modImplementation libs.fabric.loader implementation(project(":base-common")) implementation(project(":event-base-common")) } \ No newline at end of file diff --git a/lifecycle-events-fabric/build.gradle b/lifecycle-events-fabric/build.gradle index 07e3a804..36e4aa22 100644 --- a/lifecycle-events-fabric/build.gradle +++ b/lifecycle-events-fabric/build.gradle @@ -1,56 +1,11 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} +apply from: rootProject.file("gradle/scripts/kessokulib-fabric.gradle") group = "band.kessoku.lib.events.lifecycle" -version = libs.versions.mod.get() + "+fabric." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-lifecycle-events" -} - -architectury { - platformSetupLoomIde() - fabric() -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentFabric.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} +base.archivesName = rootProject.name + "-lifecycle-events" dependencies { - modImplementation libs.fabric.loader - modImplementation libs.fabric.api - implementation(project(":event-base-common")) common(project(path: ':lifecycle-events-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':lifecycle-events-common', configuration: 'transformProductionFabric') } - -processResources { - inputs.property 'version', project.version - - filesMatching('fabric.mod.json') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - input.set shadowJar.archiveFile -} \ No newline at end of file diff --git a/lifecycle-events-neo/build.gradle b/lifecycle-events-neo/build.gradle index 3279a33d..0051f405 100644 --- a/lifecycle-events-neo/build.gradle +++ b/lifecycle-events-neo/build.gradle @@ -1,18 +1,7 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} +apply from: rootProject.file("gradle/scripts/kessokulib-neo.gradle") group = "band.kessoku.lib.events.lifecycle" -version = libs.versions.mod.get() + "+neoforge." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-lifecycle-events" -} - -architectury { - platformSetupLoomIde() - neoForge() -} +base.archivesName = rootProject.name + "-lifecycle-events" loom { neoForge { @@ -20,47 +9,10 @@ loom { } } -repositories { - maven { url "https://maven.neoforged.net/releases/" } -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentNeoForge.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} - dependencies { - neoForge libs.neo - implementation(project(":event-base-common")) implementation(project(":event-base-neo")) common(project(path: ':lifecycle-events-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':lifecycle-events-common', configuration: 'transformProductionNeoForge') } - -processResources { - inputs.property 'version', project.version - - filesMatching('META-INF/neoforge.mods.toml') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - input.set shadowJar.archiveFile -} \ No newline at end of file diff --git a/neo/build.gradle b/neo/build.gradle index 747d4aed..f70c16fb 100644 --- a/neo/build.gradle +++ b/neo/build.gradle @@ -1,26 +1,11 @@ -group = "band.kessoku.lib" -version = libs.versions.mod.get() + "+neoforge." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name -} +apply from: rootProject.file("gradle/scripts/kessokulib-neo.gradle") -architectury { - platformSetupLoomIde() - neoForge() -} +group = "band.kessoku.lib" +base.archivesName = rootProject.name dependencies { - neoForge libs.neo include(project(":base-neo")) include(project(":event-base-neo")) include(project(":platform-neo")) include(project(":registry-neo")) } -processResources { - inputs.property 'version', project.version - - filesMatching('META-INF/neoforge.mods.toml') { - expand version: project.version - } -} \ No newline at end of file diff --git a/platform-common/build.gradle b/platform-common/build.gradle index d30f4cb7..5417392b 100644 --- a/platform-common/build.gradle +++ b/platform-common/build.gradle @@ -1,15 +1,8 @@ -group = "band.kessoku.lib.platform" -version = libs.versions.mod.get() + "+common." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-platform" -} +apply from: rootProject.file("gradle/scripts/kessokulib-common.gradle") -architectury { - common(["fabric", "neoforge"]) -} +group = "band.kessoku.lib.platform" +base.archivesName = rootProject.name + "-platform" dependencies { - modImplementation libs.fabric.loader implementation(project(":base-common")) } \ No newline at end of file diff --git a/platform-fabric/build.gradle b/platform-fabric/build.gradle index 68d58a63..eacc011f 100644 --- a/platform-fabric/build.gradle +++ b/platform-fabric/build.gradle @@ -1,53 +1,9 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} - -base { - archivesName = rootProject.name + "-platform" -} +apply from: rootProject.file("gradle/scripts/kessokulib-fabric.gradle") group = "band.kessoku.lib.platform" -version = libs.versions.mod.get() + "+fabric." + libs.versions.minecraft.get() - -architectury { - platformSetupLoomIde() - fabric() -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentFabric.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} +base.archivesName = rootProject.name + "-platform" dependencies { - modImplementation libs.fabric.loader - modImplementation libs.fabric.api common(project(path: ':platform-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':platform-common', configuration: 'transformProductionFabric') } - -processResources { - inputs.property 'version', project.version - - filesMatching('fabric.mod.json') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - inputFile.set shadowJar.archiveFile -} \ No newline at end of file diff --git a/platform-neo/build.gradle b/platform-neo/build.gradle index 63b1e927..85ef781f 100644 --- a/platform-neo/build.gradle +++ b/platform-neo/build.gradle @@ -1,52 +1,9 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} - -base { - archivesName = rootProject.name + "-platform" -} +apply from: rootProject.file("gradle/scripts/kessokulib-neo.gradle") group = "band.kessoku.lib.platform" -version = libs.versions.mod.get() + "+neoforge." + libs.versions.minecraft.get() - -architectury { - platformSetupLoomIde() - neoForge() -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentNeoForge.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} +base.archivesName = rootProject.name + "-platform" dependencies { - neoForge libs.neo common(project(path: ':platform-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':platform-common', configuration: 'transformProductionNeoForge') } - -processResources { - inputs.property 'version', project.version - - filesMatching('META-INF/neoforge.mods.toml') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - inputFile.set shadowJar.archiveFile -} \ No newline at end of file diff --git a/registry-common/build.gradle b/registry-common/build.gradle index 816c03e1..a9d11490 100644 --- a/registry-common/build.gradle +++ b/registry-common/build.gradle @@ -1,15 +1,8 @@ -group = "band.kessoku.lib.registry" -version = libs.versions.mod.get() + "+common." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-registry" -} +apply from: rootProject.file("gradle/scripts/kessokulib-common.gradle") -architectury { - common(["fabric", "neoforge"]) -} +group = "band.kessoku.lib.registry" +base.archivesName = rootProject.name + "-registry" dependencies { - modImplementation libs.fabric.loader implementation project(":base-common") } \ No newline at end of file diff --git a/registry-fabric/build.gradle b/registry-fabric/build.gradle index 7ef21480..0af45533 100644 --- a/registry-fabric/build.gradle +++ b/registry-fabric/build.gradle @@ -1,53 +1,9 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} +apply from: rootProject.file("gradle/scripts/kessokulib-fabric.gradle") group = "band.kessoku.lib.registry" -version = libs.versions.mod.get() + "+fabric." + libs.versions.minecraft.get() - -base { - archivesName = rootProject.name + "-registry" -} - -architectury { - platformSetupLoomIde() - fabric() -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentFabric.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} +base.archivesName = rootProject.name + "-registry" dependencies { - modImplementation libs.fabric.loader - modImplementation libs.fabric.api common(project(path: ':registry-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':registry-common', configuration: 'transformProductionFabric') } - -processResources { - inputs.property 'version', project.version - - filesMatching('fabric.mod.json') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - inputFile.set shadowJar.archiveFile -} \ No newline at end of file diff --git a/registry-neo/build.gradle b/registry-neo/build.gradle index 7ea5bbb3..514f5701 100644 --- a/registry-neo/build.gradle +++ b/registry-neo/build.gradle @@ -1,59 +1,11 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} - -base { - archivesName = rootProject.name + "-registry" -} +apply from: rootProject.file("gradle/scripts/kessokulib-neo.gradle") group = "band.kessoku.lib.registry" -version = libs.versions.mod.get() + "+neoforge." + libs.versions.minecraft.get() - -architectury { - platformSetupLoomIde() - neoForge() -} - -repositories { - maven { url "https://maven.neoforged.net/releases/" } -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentNeoForge.extendsFrom common - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} +base.archivesName = rootProject.name + "-registry" dependencies { - neoForge libs.neo - implementation(project(":event-base-neo")) common(project(path: ':registry-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':registry-common', configuration: 'transformProductionNeoForge') } - -processResources { - inputs.property 'version', project.version - - filesMatching('META-INF/neoforge.mods.toml') { - expand version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - inputFile.set shadowJar.archiveFile -} \ No newline at end of file From e41014038d646d47971551478eca1c97a77ed963 Mon Sep 17 00:00:00 2001 From: TexTrue <3140846162@qq.com> Date: Mon, 5 Aug 2024 22:29:05 +0800 Subject: [PATCH 2/2] rework gradle script part 2 --- build.gradle | 30 +++++++++++++++++++++------- command-common/build.gradle | 4 ++-- command-fabric/build.gradle | 2 +- command-neo/build.gradle | 4 ++-- event-base-common/build.gradle | 2 +- fabric/build.gradle | 9 +++++---- gradle/example/common/build.gradle | 9 +++++++++ gradle/example/fabric/build.gradle | 9 +++++++++ gradle/example/neo/build.gradle | 9 +++++++++ gradle/example/neo/gradle.properties | 1 + gradle/libs.versions.toml | 20 +++++++++++++------ lifecycle-events-common/build.gradle | 4 ++-- lifecycle-events-fabric/build.gradle | 2 +- lifecycle-events-neo/build.gradle | 4 ++-- neo/build.gradle | 9 +++++---- platform-common/build.gradle | 2 +- platform-fabric/build.gradle | 2 +- platform-neo/build.gradle | 2 +- registry-common/build.gradle | 2 +- registry-fabric/build.gradle | 2 +- registry-neo/build.gradle | 4 ++-- 21 files changed, 93 insertions(+), 39 deletions(-) create mode 100644 gradle/example/common/build.gradle create mode 100644 gradle/example/fabric/build.gradle create mode 100644 gradle/example/neo/build.gradle create mode 100644 gradle/example/neo/gradle.properties diff --git a/build.gradle b/build.gradle index d7b4a913..3c685041 100644 --- a/build.gradle +++ b/build.gradle @@ -19,17 +19,17 @@ subprojects { assemble.dependsOn spotlessApply repositories { - maven { url "https://maven.neoforged.net/releases/" } + } dependencies { - minecraft libs.minecraft - mappings loom.layered { + minecraft(libs.minecraft) + mappings(loom.layered { mappings(variantOf(libs.yarn) { classifier("v2") }) - mappings libs.yarn.patch - } - implementation 'com.google.auto.service:auto-service-annotations:1.1.1' - annotationProcessor 'com.google.auto.service:auto-service:1.1.1' + mappings(libs.yarn.patch) + }) + implementation("com.google.auto.service:auto-service-annotations:1.1.1") + annotationProcessor("com.google.auto.service:auto-service:1.1.1") } java { @@ -72,3 +72,19 @@ subprojects { } } } + +allprojects { + configurations { + moduleImplementation { + canBeResolved = true + canBeConsumed = false + } + compileClasspath.extendsFrom moduleImplementation + runtimeClasspath.extendsFrom moduleImplementation + moduleInclude { + canBeResolved = true + canBeConsumed = false + } + include.extendsFrom moduleInclude + } +} diff --git a/command-common/build.gradle b/command-common/build.gradle index 685b1473..b43f152d 100644 --- a/command-common/build.gradle +++ b/command-common/build.gradle @@ -4,6 +4,6 @@ group = "band.kessoku.lib.command" base.archivesName = rootProject.name + "-command" dependencies { - implementation(project(":base-common")) - implementation(project(":event-base-common")) + moduleImplementation(project(":base-common")) + moduleImplementation(project(":event-base-common")) } \ No newline at end of file diff --git a/command-fabric/build.gradle b/command-fabric/build.gradle index d8cf2ece..57277e56 100644 --- a/command-fabric/build.gradle +++ b/command-fabric/build.gradle @@ -4,7 +4,7 @@ group = "band.kessoku.lib.command" base.archivesName = rootProject.name + "-command" dependencies { - implementation(project(":event-base-common")) + moduleImplementation(project(":event-base-common")) common(project(path: ':command-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':command-common', configuration: 'transformProductionFabric') diff --git a/command-neo/build.gradle b/command-neo/build.gradle index abcc0597..f7eb179c 100644 --- a/command-neo/build.gradle +++ b/command-neo/build.gradle @@ -4,8 +4,8 @@ group = "band.kessoku.lib.command" base.archivesName = rootProject.name + "-command" dependencies { - implementation(project(":event-base-common")) - implementation(project(":event-base-neo")) + moduleImplementation(project(":event-base-common")) + moduleImplementation(project(":event-base-neo")) common(project(path: ':command-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':command-common', configuration: 'transformProductionNeoForge') diff --git a/event-base-common/build.gradle b/event-base-common/build.gradle index 3fd06de1..d8fb41dd 100644 --- a/event-base-common/build.gradle +++ b/event-base-common/build.gradle @@ -4,5 +4,5 @@ group = "band.kessoku.lib.event" base.archivesName = rootProject.name + "-event-base" dependencies { - implementation(project(":base-common")) + moduleImplementation(project(":base-common")) } \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle index 55657002..1ea9c09c 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -3,9 +3,10 @@ apply from: rootProject.file("gradle/scripts/kessokulib-fabric.gradle") group = "band.kessoku.lib" base.archivesName = rootProject.name +var modules = [":base-fabric", ":event-base-fabric", ":lifecycle-events-fabric", ":platform-fabric", ":registry-fabric"] + dependencies { - include(project(":base-fabric")) - include(project(":event-base-fabric")) - include(project(":platform-fabric")) - include(project(":registry-fabric")) + modules.each { + moduleInclude(project(it)) + } } diff --git a/gradle/example/common/build.gradle b/gradle/example/common/build.gradle new file mode 100644 index 00000000..91d13986 --- /dev/null +++ b/gradle/example/common/build.gradle @@ -0,0 +1,9 @@ +apply from: rootProject.file("gradle/scripts/kessokulib-common.gradle") + +group = "band.kessoku.lib.package" +base.archivesName = rootProject.name + "-package" + +// You can delete this section if you need to +dependencies { + +} diff --git a/gradle/example/fabric/build.gradle b/gradle/example/fabric/build.gradle new file mode 100644 index 00000000..0ada6be9 --- /dev/null +++ b/gradle/example/fabric/build.gradle @@ -0,0 +1,9 @@ +apply from: rootProject.file("gradle/scripts/kessokulib-fabric.gradle") + +group = "band.kessoku.lib.package" +base.archivesName = rootProject.name + "-package" + +dependencies { + common(project(path: ':package-common', configuration: 'namedElements')) { transitive false } + shadowBundle(project(path: ':package-common', configuration: 'transformProductionFabric')) +} diff --git a/gradle/example/neo/build.gradle b/gradle/example/neo/build.gradle new file mode 100644 index 00000000..21e732ee --- /dev/null +++ b/gradle/example/neo/build.gradle @@ -0,0 +1,9 @@ +apply from: rootProject.file("gradle/scripts/kessokulib-neo.gradle") + +group = "band.kessoku.lib.package" +base.archivesName = rootProject.name + "-package" + +dependencies { + common(project(path: ':package-common', configuration: 'namedElements')) { transitive false } + shadowBundle(project(path: ':package-common', configuration: 'transformProductionNeoForge')) +} diff --git a/gradle/example/neo/gradle.properties b/gradle/example/neo/gradle.properties new file mode 100644 index 00000000..2914393d --- /dev/null +++ b/gradle/example/neo/gradle.properties @@ -0,0 +1 @@ +loom.platform=neoforge \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dd6c6afa..17a0fd5b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ mod = "0.1.0" minecraft = "1.21" yarn = "1.21+build.9" -yarn-mappings-patch-neoforge = "1.21+build.4" +yarn-patch-neoforge = "1.21+build.4" # Loaders neo = "21.0.151" @@ -10,10 +10,17 @@ fabric-loader = "0.16.0" # Mods fabric-api = "0.100.8+1.21" + +# Plugin version +loom = "1.7-SNAPSHOT" +architectury = "3.4-SNAPSHOT" +shadow = "8.1.1" +spotless = "6.25.0" + [libraries] minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" } yarn = { group = "net.fabricmc", name = "yarn", version.ref = "yarn" } -yarn-patch = { group = "dev.architectury", name = "yarn-mappings-patch-neoforge", version.ref = "yarn-mappings-patch-neoforge" } +yarn-patch = { group = "dev.architectury", name = "yarn-mappings-patch-neoforge", version.ref = "yarn-patch-neoforge" } # Loaders neo = { group = "net.neoforged", name = "neoforge", version.ref = "neo" } @@ -21,8 +28,9 @@ fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = # Mods fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" } + [plugins] -loom = { id = "dev.architectury.loom", version = "1.7-SNAPSHOT" } -architectury = { id = "architectury-plugin", version = "3.4-SNAPSHOT" } -shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" } -spotless = { id = "com.diffplug.spotless", version = "6.25.0" } \ No newline at end of file +loom = { id = "dev.architectury.loom", version.ref = "loom" } +architectury = { id = "architectury-plugin", version.ref = "architectury" } +shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" } +spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } \ No newline at end of file diff --git a/lifecycle-events-common/build.gradle b/lifecycle-events-common/build.gradle index 6782a733..994ee90b 100644 --- a/lifecycle-events-common/build.gradle +++ b/lifecycle-events-common/build.gradle @@ -4,6 +4,6 @@ group = "band.kessoku.lib.events.lifecycle" base.archivesName = rootProject.name + "-lifecycle-events" dependencies { - implementation(project(":base-common")) - implementation(project(":event-base-common")) + moduleImplementation(project(":base-common")) + moduleImplementation(project(":event-base-common")) } \ No newline at end of file diff --git a/lifecycle-events-fabric/build.gradle b/lifecycle-events-fabric/build.gradle index 36e4aa22..afa73ea6 100644 --- a/lifecycle-events-fabric/build.gradle +++ b/lifecycle-events-fabric/build.gradle @@ -4,7 +4,7 @@ group = "band.kessoku.lib.events.lifecycle" base.archivesName = rootProject.name + "-lifecycle-events" dependencies { - implementation(project(":event-base-common")) + moduleImplementation(project(":event-base-common")) common(project(path: ':lifecycle-events-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':lifecycle-events-common', configuration: 'transformProductionFabric') diff --git a/lifecycle-events-neo/build.gradle b/lifecycle-events-neo/build.gradle index 0051f405..46539657 100644 --- a/lifecycle-events-neo/build.gradle +++ b/lifecycle-events-neo/build.gradle @@ -10,8 +10,8 @@ loom { } dependencies { - implementation(project(":event-base-common")) - implementation(project(":event-base-neo")) + moduleImplementation(project(":event-base-common")) + moduleImplementation(project(":event-base-neo")) common(project(path: ':lifecycle-events-common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':lifecycle-events-common', configuration: 'transformProductionNeoForge') diff --git a/neo/build.gradle b/neo/build.gradle index f70c16fb..b12d77c8 100644 --- a/neo/build.gradle +++ b/neo/build.gradle @@ -3,9 +3,10 @@ apply from: rootProject.file("gradle/scripts/kessokulib-neo.gradle") group = "band.kessoku.lib" base.archivesName = rootProject.name +var modules = [":base-neo", ":event-base-neo", ":lifecycle-events-neo", ":platform-neo", ":registry-neo"] + dependencies { - include(project(":base-neo")) - include(project(":event-base-neo")) - include(project(":platform-neo")) - include(project(":registry-neo")) + modules.each { + moduleInclude(project(it)) + } } diff --git a/platform-common/build.gradle b/platform-common/build.gradle index 5417392b..bc1382ff 100644 --- a/platform-common/build.gradle +++ b/platform-common/build.gradle @@ -4,5 +4,5 @@ group = "band.kessoku.lib.platform" base.archivesName = rootProject.name + "-platform" dependencies { - implementation(project(":base-common")) + moduleImplementation(project(":base-common")) } \ No newline at end of file diff --git a/platform-fabric/build.gradle b/platform-fabric/build.gradle index eacc011f..bc9b9663 100644 --- a/platform-fabric/build.gradle +++ b/platform-fabric/build.gradle @@ -5,5 +5,5 @@ base.archivesName = rootProject.name + "-platform" dependencies { common(project(path: ':platform-common', configuration: 'namedElements')) { transitive false } - shadowBundle project(path: ':platform-common', configuration: 'transformProductionFabric') + shadowBundle(project(path: ':platform-common', configuration: 'transformProductionFabric')) } diff --git a/platform-neo/build.gradle b/platform-neo/build.gradle index 85ef781f..bb815788 100644 --- a/platform-neo/build.gradle +++ b/platform-neo/build.gradle @@ -5,5 +5,5 @@ base.archivesName = rootProject.name + "-platform" dependencies { common(project(path: ':platform-common', configuration: 'namedElements')) { transitive false } - shadowBundle project(path: ':platform-common', configuration: 'transformProductionNeoForge') + shadowBundle(project(path: ':platform-common', configuration: 'transformProductionNeoForge')) } diff --git a/registry-common/build.gradle b/registry-common/build.gradle index a9d11490..50bb1128 100644 --- a/registry-common/build.gradle +++ b/registry-common/build.gradle @@ -4,5 +4,5 @@ group = "band.kessoku.lib.registry" base.archivesName = rootProject.name + "-registry" dependencies { - implementation project(":base-common") + moduleImplementation(project(":base-common")) } \ No newline at end of file diff --git a/registry-fabric/build.gradle b/registry-fabric/build.gradle index 0af45533..47ca80d1 100644 --- a/registry-fabric/build.gradle +++ b/registry-fabric/build.gradle @@ -5,5 +5,5 @@ base.archivesName = rootProject.name + "-registry" dependencies { common(project(path: ':registry-common', configuration: 'namedElements')) { transitive false } - shadowBundle project(path: ':registry-common', configuration: 'transformProductionFabric') + shadowBundle(project(path: ':registry-common', configuration: 'transformProductionFabric')) } diff --git a/registry-neo/build.gradle b/registry-neo/build.gradle index 514f5701..dd48c309 100644 --- a/registry-neo/build.gradle +++ b/registry-neo/build.gradle @@ -4,8 +4,8 @@ group = "band.kessoku.lib.registry" base.archivesName = rootProject.name + "-registry" dependencies { - implementation(project(":event-base-neo")) + moduleImplementation(project(":event-base-neo")) common(project(path: ':registry-common', configuration: 'namedElements')) { transitive false } - shadowBundle project(path: ':registry-common', configuration: 'transformProductionNeoForge') + shadowBundle(project(path: ':registry-common', configuration: 'transformProductionNeoForge')) }