From 73a1107683b1c4c7c6b07b32d39643b261688de3 Mon Sep 17 00:00:00 2001 From: TexBlock <3140846162@qq.com> Date: Sat, 7 Sep 2024 16:29:45 +0800 Subject: [PATCH] clean --- base/fabric/build.gradle | 2 + base/neo/build.gradle | 2 + .../gradle/plugin/KessokuGradlePlugin.java | 9 ---- .../gradle/plugin/KesssokuExtension.java | 48 +++++++++++++++++++ .../kessoku/lib/registry/api/Registry.java | 2 +- 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/base/fabric/build.gradle b/base/fabric/build.gradle index d0dc0350..fbff4c83 100644 --- a/base/fabric/build.gradle +++ b/base/fabric/build.gradle @@ -1,3 +1,5 @@ +import net.fabricmc.loom.util.ModPlatform + apply from: rootProject.file("gradle/scripts/klib-fabric.gradle") group = "band.kessoku.lib.base" diff --git a/base/neo/build.gradle b/base/neo/build.gradle index 092d8ae4..95468917 100644 --- a/base/neo/build.gradle +++ b/base/neo/build.gradle @@ -1,3 +1,5 @@ +import net.fabricmc.loom.util.ModPlatform + apply from: rootProject.file("gradle/scripts/klib-neo.gradle") group = "band.kessoku.lib.base" diff --git a/buildSrc/src/main/java/band/kessoku/gradle/plugin/KessokuGradlePlugin.java b/buildSrc/src/main/java/band/kessoku/gradle/plugin/KessokuGradlePlugin.java index a4f00aef..c2a9f33f 100644 --- a/buildSrc/src/main/java/band/kessoku/gradle/plugin/KessokuGradlePlugin.java +++ b/buildSrc/src/main/java/band/kessoku/gradle/plugin/KessokuGradlePlugin.java @@ -43,15 +43,6 @@ public void additionalRepositories(RepositoryHandler repositories) { repositories.maven(repo -> { repo.setName("NeoForge"); repo.setUrl("https://maven.neoforged.net/releases/"); - - repo.content(descriptor -> { - NEO_GROUPS.forEach(descriptor::includeGroupAndSubgroups); - }); - - repo.metadataSources(sources -> { - sources.mavenPom(); - sources.ignoreGradleMetadataRedirection(); - }); }); repositories.maven(repo -> { diff --git a/buildSrc/src/main/java/band/kessoku/gradle/plugin/KesssokuExtension.java b/buildSrc/src/main/java/band/kessoku/gradle/plugin/KesssokuExtension.java index bb7a1842..1807dc81 100644 --- a/buildSrc/src/main/java/band/kessoku/gradle/plugin/KesssokuExtension.java +++ b/buildSrc/src/main/java/band/kessoku/gradle/plugin/KesssokuExtension.java @@ -1,8 +1,10 @@ package band.kessoku.gradle.plugin; import net.fabricmc.loom.api.LoomGradleExtensionAPI; +import net.fabricmc.loom.util.ModPlatform; import org.gradle.api.Project; import org.gradle.api.artifacts.Dependency; +import org.gradle.api.artifacts.ModuleDependency; import org.gradle.api.artifacts.dsl.DependencyHandler; import org.gradle.api.tasks.SourceSetContainer; @@ -14,6 +16,10 @@ public abstract class KesssokuExtension { @Inject protected abstract Project getProject(); + public void testModuleImpls(List names, String plat) { + names.forEach(name -> testModuleImpl(name, plat)); + } + public void moduleImpls(List names, String plat) { names.forEach(name -> moduleImpl(name, plat)); } @@ -22,6 +28,24 @@ public void moduleIncludes(List names, String plat) { names.forEach(name -> moduleInclude(name, plat)); } + public void testModuleImpl(String name, String plat) { + Project project = this.getProject(); + DependencyHandler dependencies = project.getDependencies(); + + Dependency dependency = dependencies.project(Map.of( + "path", ":" + name + "-" + 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) { Project project = this.getProject(); DependencyHandler dependencies = project.getDependencies(); @@ -57,4 +81,28 @@ public void moduleInclude(String name, String plat) { settings.sourceSet(sourceSets.getByName("main"), depProject); })); } + + public void commonImpl(String name, ModPlatform platform) { + Project project = this.getProject(); + DependencyHandler dependencies = project.getDependencies(); + + ModuleDependency dependency = (ModuleDependency) dependencies.project(Map.of( + "path", ":" + name + "-common", + "configuration", "namedElements" + )); + dependency.setTransitive(false); + dependencies.add("api", dependency); + dependencies.add("development" + platform.displayName(), dependency); + } + + public void shade(String name, ModPlatform platform) { + Project project = this.getProject(); + DependencyHandler dependencies = project.getDependencies(); + + Dependency dependency = dependencies.project(Map.of( + "path", ":" + name + "-common", + "configuration", "transformProduction" + platform.displayName() + )); + dependencies.add("shadow", dependency); + } } diff --git a/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java b/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java index 62c35f72..542ce3ba 100644 --- a/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java +++ b/registry/common/src/main/java/band/kessoku/lib/registry/api/Registry.java @@ -16,6 +16,7 @@ package band.kessoku.lib.registry.api; import band.kessoku.lib.registry.impl.KessokuRegistryServices; +import org.jetbrains.annotations.ApiStatus; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; @@ -24,7 +25,6 @@ import net.minecraft.registry.Registries; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.Identifier; -import org.jetbrains.annotations.ApiStatus; @SuppressWarnings("unused") public interface Registry {