Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Sep 7, 2024
1 parent 73a1107 commit 8dd4551
Show file tree
Hide file tree
Showing 32 changed files with 187 additions and 129 deletions.
6 changes: 3 additions & 3 deletions base/fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply from: rootProject.file("gradle/scripts/klib-fabric.gradle")
group = "band.kessoku.lib.base"
base.archivesName = rootProject.name + "-base"

dependencies {
common(project(path: ':base-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':base-common', configuration: 'transformProductionFabric')
kessoku {
common("base", ModPlatform.FABRIC)
shadowBundle("base", ModPlatform.FABRIC)
}
6 changes: 3 additions & 3 deletions base/neo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply from: rootProject.file("gradle/scripts/klib-neo.gradle")
group = "band.kessoku.lib.base"
base.archivesName = rootProject.name + "-base"

dependencies {
common(project(path: ':base-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':base-common', configuration: 'transformProductionNeoForge')
kessoku {
common("base", ModPlatform.NEOFORGE)
shadowBundle("base", ModPlatform.NEOFORGE)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package band.kessoku.gradle.plugin;

import net.fabricmc.loom.api.LoomGradleExtensionAPI;
import net.fabricmc.loom.api.NeoForgeExtensionAPI;
import net.fabricmc.loom.configuration.FabricApiExtension;
import net.fabricmc.loom.util.ModPlatform;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.ModuleDependency;
Expand All @@ -16,19 +19,30 @@ public abstract class KesssokuExtension {
@Inject
protected abstract Project getProject();

public void testModuleImpls(List<String> names, String plat) {
names.forEach(name -> testModuleImpl(name, plat));
public void library(String lib) {
Project project = this.getProject();
DependencyHandler dependencies = project.getDependencies();

Dependency dependency = dependencies.project(Map.of(
"path", lib,
"configuration", "namedElements"
));
dependencies.add("implementation", dependency);
}

public void testModules(List<String> names, String plat) {
names.forEach(name -> testModule(name, plat));
}

public void moduleImpls(List<String> names, String plat) {
names.forEach(name -> moduleImpl(name, plat));
public void modules(List<String> names, String plat) {
names.forEach(name -> module(name, plat));
}

public void moduleIncludes(List<String> names, String plat) {
names.forEach(name -> moduleInclude(name, plat));
}

public void testModuleImpl(String name, String plat) {
public void testModule(String name, String plat) {
Project project = this.getProject();
DependencyHandler dependencies = project.getDependencies();

Expand All @@ -37,16 +51,9 @@ public void testModuleImpl(String name, String plat) {
"configuration", "namedElements"
));
dependencies.add("testImplementation", dependency);

// LoomGradleExtensionAPI loom = project.getExtensions().getByType(LoomGradleExtensionAPI.class);
// loom.mods(mods -> mods.register("kessoku-" + name + "-" + plat, settings -> {
// Project depProject = project.project(":" + name + "-" + plat);
// SourceSetContainer sourceSets = depProject.getExtensions().getByType(SourceSetContainer.class);
// settings.sourceSet(sourceSets.getByName("main"), depProject);
// }));
}

public void moduleImpl(String name, String plat) {
public void module(String name, String plat) {
Project project = this.getProject();
DependencyHandler dependencies = project.getDependencies();

Expand Down Expand Up @@ -82,7 +89,7 @@ public void moduleInclude(String name, String plat) {
}));
}

public void commonImpl(String name, ModPlatform platform) {
public void common(String name, ModPlatform platform) {
Project project = this.getProject();
DependencyHandler dependencies = project.getDependencies();

Expand All @@ -95,7 +102,7 @@ public void commonImpl(String name, ModPlatform platform) {
dependencies.add("development" + platform.displayName(), dependency);
}

public void shade(String name, ModPlatform platform) {
public void shadowBundle(String name, ModPlatform platform) {
Project project = this.getProject();
DependencyHandler dependencies = project.getDependencies();

Expand Down
11 changes: 3 additions & 8 deletions command/common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import com.google.common.collect.Lists

apply from: rootProject.file("gradle/scripts/klib-common.gradle")

group = "band.kessoku.lib.command"
base.archivesName = rootProject.name + "-command"

kessoku {
modules(["base", "event-base"], "common")


dependencies {
kessoku.moduleImpls(["base", "event-base"], "common")

testImplementation(project(":base-common"))
testImplementation(project(":event-base-common"))
testModules(["base", "event-base"], "common")
}
10 changes: 6 additions & 4 deletions command/fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-fabric.gradle")

group = "band.kessoku.lib.command"
base.archivesName = rootProject.name + "-command"

dependencies {
kessoku.moduleImpls(["base", "event-base"], "common")
kessoku {
modules(["base", "event-base"], "common")

common(project(path: ':command-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':command-common', configuration: 'transformProductionFabric')
common("command", ModPlatform.FABRIC)
shadowBundle("command", ModPlatform.FABRIC)
}
12 changes: 7 additions & 5 deletions command/neo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-neo.gradle")

group = "band.kessoku.lib.command"
base.archivesName = rootProject.name + "-command"

dependencies {
kessoku.moduleImpls(["base", "event-base"], "common")
kessoku.moduleImpl("event-base", "neo")
kessoku {
modules(["base", "event-base"], "common")
module("event-base", "neo")

common(project(path: ':command-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':command-common', configuration: 'transformProductionNeoForge')
common("command", ModPlatform.NEOFORGE)
shadowBundle("command", ModPlatform.NEOFORGE)
}
6 changes: 4 additions & 2 deletions config/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ apply from: rootProject.file("gradle/scripts/klib-common.gradle")
group = "band.kessoku.lib.config"
base.archivesName = rootProject.name + "-config"

dependencies {
kessoku.moduleImpls(["base", "platform"], "common")
kessoku {
modules(["base", "platform"], "common")
}

dependencies {
implementation(libs.bundles.night.config)
implementation(libs.aj4j)
}
15 changes: 9 additions & 6 deletions config/fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-fabric.gradle")
apply plugin: "com.gradleup.shadow"

group = "band.kessoku.lib.config"
base.archivesName = rootProject.name + "-config"

dependencies {
shadowBundle(libs.aj4j)
kessoku {
modules(["base", "platform"], "common")

kessoku.moduleImpls(["base", "platform"], "common")
common("config", ModPlatform.FABRIC)
shadowBundle("config", ModPlatform.FABRIC)
}

common(project(path: ':config-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':config-common', configuration: 'transformProductionFabric')
dependencies {
shadowBundle(libs.aj4j)
}

shadowJar {
Expand Down
14 changes: 9 additions & 5 deletions config/neo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-neo.gradle")

group = "band.kessoku.lib.config"
base.archivesName = rootProject.name + "-config"

dependencies {
shadowBundle(libs.aj4j)
kessoku {
modules(["base", "platform"], "common")

kessoku.moduleImpls(["base", "platform"], "common")
common("config", ModPlatform.NEOFORGE)
shadowBundle("config", ModPlatform.NEOFORGE)
}

common(project(path: ':config-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':config-common', configuration: 'transformProductionNeoForge')
dependencies {
shadowBundle(libs.aj4j)
}

shadowJar {
Expand Down
6 changes: 5 additions & 1 deletion entity-events/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ apply from: rootProject.file("gradle/scripts/klib-common.gradle")
group = "band.kessoku.lib.events.entity"
base.archivesName = rootProject.name + "-entity-events"

kessoku {
modules(["base", "event-base"], "common")
}

dependencies {
kessoku.moduleImpls(["base", "event-base"], "common")

}
12 changes: 9 additions & 3 deletions entity-events/fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-fabric.gradle")

group = "band.kessoku.lib.events.entity"
base.archivesName = rootProject.name + "-entity-events"

kessoku {
modules(["base", "event-base"], "common")

common("entity-events", ModPlatform.FABRIC)
shadowBundle("entity-events", ModPlatform.FABRIC)
}

dependencies {
kessoku.moduleImpls(["base", "event-base"], "common")

common(project(path: ':entity-events-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':entity-events-common', configuration: 'transformProductionFabric')
}
12 changes: 7 additions & 5 deletions entity-events/neo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-neo.gradle")

group = "band.kessoku.lib.events.entity"
Expand All @@ -7,12 +9,12 @@ loom {
//accessWidenerPath = file("src/main/resources/kessoku-entity-events.accesswidener")
}

dependencies {
kessoku.moduleImpls(["base", "event-base"], "common")
kessoku.moduleImpl("event-base", "neo")
kessoku {
modules(["base", "event-base"], "common")
module("event-base", "neo")

common(project(path: ':entity-events-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':entity-events-common', configuration: 'transformProductionNeoForge')
common("entity-events", ModPlatform.NEOFORGE)
shadowBundle("entity-events", ModPlatform.NEOFORGE)
}

remapJar {
Expand Down
5 changes: 4 additions & 1 deletion entrypoint/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ apply from: rootProject.file("gradle/scripts/klib-common.gradle")
group = "band.kessoku.lib.entrypoint"
base.archivesName = rootProject.name + "-entrypoint"

kessoku {
module("base", "common")
}

dependencies {
kessoku.moduleImpl("base", "common")
implementation libs.aj4j
}
13 changes: 9 additions & 4 deletions entrypoint/fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-fabric.gradle")

group = "band.kessoku.lib.entrypoint"
base.archivesName = rootProject.name + "-entrypoint"

kessoku {
module("base", "common")

common("entrypoint", ModPlatform.FABRIC)
shadowBundle("entrypoint", ModPlatform.FABRIC)
}

dependencies {
kessoku.moduleImpl("base", "common")
implementation libs.aj4j

common(project(path: ':entrypoint-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':entrypoint-common', configuration: 'transformProductionFabric')
}
10 changes: 6 additions & 4 deletions entrypoint/neo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-neo.gradle")

group = "band.kessoku.lib.entrypoint"
base.archivesName = rootProject.name + "-entrypoint"

dependencies {
kessoku.moduleImpl("base", "common")
kessoku {
module("base", "common")

common(project(path: ':entrypoint-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':entrypoint-common', configuration: 'transformProductionNeoForge')
common("entrypoint", ModPlatform.NEOFORGE)
shadowBundle("entrypoint", ModPlatform.NEOFORGE)
}
4 changes: 2 additions & 2 deletions event-base/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ apply from: rootProject.file("gradle/scripts/klib-common.gradle")
group = "band.kessoku.lib.event"
base.archivesName = rootProject.name + "-event-base"

dependencies {
kessoku.moduleImpl("base", "common")
kessoku {
module("base", "common")
}
10 changes: 6 additions & 4 deletions event-base/fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-fabric.gradle")

group = "band.kessoku.lib.event"
base.archivesName = rootProject.name + "-event-base"

dependencies {
kessoku.moduleImpl("base", "common")
kessoku {
module("base", "common")

common(project(path: ':event-base-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':event-base-common', configuration: 'transformProductionFabric')
common("event-base", ModPlatform.FABRIC)
shadowBundle("event-base", ModPlatform.FABRIC)
}
10 changes: 6 additions & 4 deletions event-base/neo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import net.fabricmc.loom.util.ModPlatform

apply from: rootProject.file("gradle/scripts/klib-neo.gradle")

group = "band.kessoku.lib.event"
base.archivesName = rootProject.name + "-event-base"

dependencies {
kessoku.moduleImpl("base", "common")
kessoku {
module("base", "common")

common(project(path: ':event-base-common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':event-base-common', configuration: 'transformProductionNeoForge')
common("event-base", ModPlatform.NEOFORGE)
shadowBundle("event-base", ModPlatform.NEOFORGE)
}
4 changes: 2 additions & 2 deletions keybind/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ apply from: rootProject.file("gradle/scripts/klib-common.gradle")
group = "band.kessoku.lib.keybind"
base.archivesName = rootProject.name + "-keybind"

dependencies {
kessoku.moduleImpl("base", "common")
kessoku {
module("base", "common")
}
Loading

0 comments on commit 8dd4551

Please sign in to comment.