Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysdh540 committed Oct 13, 2023
1 parent 05b4738 commit f0b272e
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 122 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ plugins {
id 'architectury-plugin' version "${arch_plugin_version}" apply false
id 'dev.architectury.loom' version "${loom_version}" apply false
id 'io.github.juuxel.loom-vineflower' version "${vineflower_version}" apply false
id 'com.github.johnrengelman.shadow' version "${shadow_version}" apply false

id 'io.github.pacifistmc.forgix' version "${forgix_version}"
}
setup()

def modVersion = mod_version + (build_number != null ? "-build.${build_number}" : "")
def modVersion = mod_version + (build_number != null ? "-build.${build_number}" : '')

forgix {
group = maven_group
Expand Down
3 changes: 2 additions & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
architectury {
common rootProject.enabled_platforms.split(", ")
//noinspection GroovyAssignabilityCheck
common rootProject.enabled_platforms.split(', ')
}

dependencies {
Expand Down
20 changes: 1 addition & 19 deletions common/src/main/java/dev/rdh/createunlimited/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import net.minecraftforge.fml.config.IConfigSpec;
import net.minecraftforge.fml.config.ModConfig;

import java.nio.file.Path;
import java.util.UUID;
import java.util.function.Supplier;

Expand All @@ -48,11 +47,6 @@ public static String platformName() {
throw new AssertionError();
}

@ExpectPlatform
public static Path getConfigDirectory() {
throw new AssertionError();
}

@ExpectPlatform
public static void registerCommand(LiteralArgumentBuilder<CommandSourceStack> command) {
throw new AssertionError();
Expand All @@ -65,7 +59,7 @@ public static void registerConfig(ModConfig.Type type, IConfigSpec<?> spec) {

@ExpectPlatform
public static <A extends ArgumentType<?>, T extends ArgumentTypeInfo.Template<A>, I extends ArgumentTypeInfo<A, T>>
void registerArgument(String name, Class<A> clazz, I info, ResourceLocation id) {
void registerArgument(Class<A> clazz, I info, ResourceLocation id) {
throw new AssertionError();
}

Expand All @@ -74,18 +68,6 @@ public static Attribute getReachAttribute() {
throw new AssertionError();
}

public static boolean isFabric() {
return platformName().equals("Fabric") || isQuilt();
}

public static boolean isForge() {
return platformName().equals("Forge");
}

public static boolean isQuilt() {
return platformName().equals("Quilt");
}

public static Supplier<Multimap<Attribute, AttributeModifier>> singleRange() {
AttributeModifier am = new AttributeModifier(UUID.fromString("7f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier",
CUConfigs.server().singleExtendoGripRange.get(), AttributeModifier.Operation.ADDITION);
Expand Down
47 changes: 5 additions & 42 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,62 +1,25 @@
plugins {
id "com.github.johnrengelman.shadow" version "${shadow_version}"
}
apply from: rootProject.file('gradle/platform.gradle')

architectury {
platformSetupLoomIde()
fabric()
}
architectury.fabric()

configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentFabric.extendsFrom common
}

dependencies {
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric}"
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api}+${rootProject.minecraft_version}"

modImplementation "com.terraformersmc:modmenu:${rootProject.modmenu}"

modImplementation("com.simibubi.create:create-fabric-${rootProject.minecraft_version}:${rootProject.create_fabric}+mc${rootProject.minecraft_version}")

if(rootProject.hasProperty("snr")) {
if(rootProject.hasProperty('snr')) {
modImplementation("com.railwayteam.railways:Steam_Rails-fabric-${minecraft_version}:${snr}+fabric-mc${minecraft_version}-build.${snr_build}") { transitive = false }
}
}

shadowJar {
exclude "architectury.common.json"

configurations = [project.configurations.shadowCommon, project.configurations.shade]
archiveClassifier.set "dev-shadow"
}

remapJar {
injectAccessWidener = true
input.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set null
}

jar {
archiveClassifier.set "dev"
}

sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}

components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,9 @@
import net.minecraftforge.fml.config.IConfigSpec;
import net.minecraftforge.fml.config.ModConfig;

import java.nio.file.Path;

@NoBootstrap
public class UtilImpl {

public static Path getConfigDirectory() {
return FabricLoader.getInstance().getConfigDir();
}

public static void registerCommand(LiteralArgumentBuilder<CommandSourceStack> command) {
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated, selection) -> dispatcher.register(command));
}
Expand All @@ -51,7 +45,7 @@ public static void registerConfig(ModConfig.Type type, IConfigSpec<?> spec) {
}

public static <A extends ArgumentType<?>, T extends ArgumentTypeInfo.Template<A>, I extends ArgumentTypeInfo<A, T>>
void registerArgument(String name, Class<A> clazz, I info, ResourceLocation id) {
void registerArgument(Class<A> clazz, I info, ResourceLocation id) {
ArgumentTypeRegistry.registerArgumentType(id, clazz, info);
}

Expand Down
52 changes: 7 additions & 45 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,46 +1,33 @@
plugins {
id "com.github.johnrengelman.shadow" version "${shadow_version}"
}
apply from: rootProject.file('gradle/platform.gradle')

architectury {
platformSetupLoomIde()
forge()
}
architectury.forge()

configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentForge.extendsFrom common

forgeRuntimeLibrary.extendsFrom addJar
}

dependencies {
forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge}"

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }

modImplementation("com.simibubi.create:create-${minecraft_version}:${create_forge}:slim") { transitive = false }
modImplementation "com.tterrag.registrate:Registrate:${registrate}"
modImplementation "com.jozufozu.flywheel:flywheel-forge-${flywheel_mc}:${flywheel}"

include "com.github.LlamaLad7:MixinExtras:${rootProject.mixin_extras}"

if(rootProject.hasProperty("snr")) {
if(rootProject.hasProperty('snr')) {
modImplementation("com.railwayteam.railways:Steam_Rails-forge-${minecraft_version}:${snr}+forge-mc${minecraft_version}-build.${snr_build}")
}
}

loom {
def awFile = project(":common").file("src/main/resources/createunlimited.accesswidener")
def awFile = project(':common').file('src/main/resources/createunlimited.accesswidener')

forge {
mixinConfig(
"createunlimited.mixins.json",
"createunlimited-common.mixins.json",
'createunlimited.mixins.json',
'createunlimited-common.mixins.json',
)

if(awFile.exists()) {
Expand All @@ -51,30 +38,5 @@ loom {
}

shadowJar {
exclude "fabric.mod.json"
exclude "architectury.common.json"

configurations = [project.configurations.shadowCommon, project.configurations.shade]

archiveClassifier.set "dev-shadow"
}

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set null
}

jar.archiveClassifier.set "dev"

sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}

components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
exclude 'fabric.mod.json'
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
import net.minecraftforge.fml.config.IConfigSpec;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.forgespi.language.IModInfo;

import org.jetbrains.annotations.ApiStatus;

import java.nio.file.Path;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand All @@ -42,10 +40,6 @@ public class UtilImpl {
@ApiStatus.Internal
public static Set<LiteralArgumentBuilder<CommandSourceStack>> commands = new HashSet<>();

public static Path getConfigDirectory() {
return FMLPaths.CONFIGDIR.get();
}

public static void registerCommand(LiteralArgumentBuilder<CommandSourceStack> command) {
commands.add(command);
}
Expand All @@ -55,7 +49,7 @@ public static void registerConfig(ModConfig.Type type, IConfigSpec<?> spec) {
}

public static <A extends ArgumentType<?>, T extends ArgumentTypeInfo.Template<A>, I extends ArgumentTypeInfo<A, T>>
void registerArgument(String name, Class<A> clazz, I info, ResourceLocation id) {
void registerArgument(Class<A> clazz, I info, ResourceLocation id) {
ArgumentTypeInfos.registerByClass(clazz, info);
}

Expand Down
46 changes: 46 additions & 0 deletions gradle/platform.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apply plugin: 'com.github.johnrengelman.shadow'

String platform = project.name.substring(1).capitalize()

architectury {
platformSetupLoomIde()
}

configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
}

dependencies {
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
shadowCommon(project(path: ':common', configuration: "transformProduction${platform}")) { transitive = false }
}

shadowJar {
exclude 'architectury.common.json'

configurations = [project.configurations.shadowCommon, project.configurations.shade]
archiveClassifier = 'shadow'
}

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier = null
}

jar.archiveClassifier = 'dev'

sourcesJar {
def commonSources = project(':common').sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}

components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}

0 comments on commit f0b272e

Please sign in to comment.