diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/GTNHGradlePlugin.java b/src/main/java/com/gtnewhorizons/gtnhgradle/GTNHGradlePlugin.java index 05edeaf7..290b44b0 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/GTNHGradlePlugin.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/GTNHGradlePlugin.java @@ -94,6 +94,9 @@ public static abstract class GTNHExtension implements ExtensionAware { /** Logging service used by the plugin */ public final @NotNull Logger logger; + /** The MinecraftVersion enum associated with this project */ + public final @NotNull MinecraftVersion minecraftVersion; + /** Parsed properties associated with this project */ public @NotNull PropertiesConfiguration configuration; @@ -142,6 +145,7 @@ public static abstract class GTNHExtension implements ExtensionAware { public GTNHExtension(final Project project) { logger = Logging.getLogger(GTNHGradlePlugin.class); configuration = PropertiesConfiguration.GradleUtils.makePropertiesFrom(project); + minecraftVersion = MinecraftVersion.getByVersionString(configuration.minecraftVersion); } /** @@ -194,4 +198,86 @@ public void applyAllModules(final Project project) { @Inject public abstract @NotNull ExecOperations getExecOperations(); } + + /** + * The enum stored in the GTNHExtension object representing the selected MC version + */ + public enum MinecraftVersion { + + /** Minecraft 1.7.10 */ + V1_7_10("1.7.10", "10.13.4.1614", "stable", "12", UpdateableConstants.NEWEST_UNIMIXINS, + UpdateableConstants.NEWEST_LWJGL3IFY, "unimixins", "unimixins"), + + /** Minecraft 1.12.2 */ + V1_12_2("1.12.2", "14.23.5.2847", "stable", "39", UpdateableConstants.NEWEST_MIXINBOOTER, + UpdateableConstants.NEWEST_LWJGL3IFY_1122, "mixinbooter", "mixin-booter"); + + /** + * Minecraft Version + */ + public final String version; + + /** + * Forge Version + */ + public final String forgeVersion; + + /** + * Obfuscation Mappings Channel + */ + public final String mappingsChannel; + + /** + * Obfuscation Mappings Versions + */ + public final String mappingsVersion; + + /** + * The full dependency spec for the version's Mixin provider(e.g. unimixins or mixinbooter) + */ + public final String mixinProviderSpec; + + /** + * The full dependency spec for the version's lwjgl3ify + */ + public final String lwjgl3ifySpec; + + /** + * The modrinth project slug for the version's mixin provider. Used to create relation on Modrinth publishing + */ + public final String modrinthMixinSlug; + + /** + * The curseforge project slug for the version's mixin provider. Used to create relation on Curseforge + * publishing + */ + public final String curseMixinSlug; + + MinecraftVersion(String version, String forgeVersion, String mappingsChannel, String mappingsVersion, + String mixinProviderSpec, String lwjgl3ifySpec, String modrinthMixinSlug, String curseMixinSlug) { + this.version = version; + this.forgeVersion = forgeVersion; + this.mappingsChannel = mappingsChannel; + this.mappingsVersion = mappingsVersion; + this.mixinProviderSpec = mixinProviderSpec; + this.lwjgl3ifySpec = lwjgl3ifySpec; + this.modrinthMixinSlug = modrinthMixinSlug; + this.curseMixinSlug = curseMixinSlug; + } + + /** + * Find a MinecraftVersion based on the MC version string, e.g. "1.7.10" or "1.12.2" + * + * @param version The minecraft version string + * @return The matching MinecraftVersion enum + */ + public static MinecraftVersion getByVersionString(String version) { + for (MinecraftVersion v : MinecraftVersion.values()) { + if (v.version.equals(version)) { + return v; + } + } + throw new IllegalArgumentException("Invalid Minecraft Version" + version); + } + } } diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/PropertiesConfiguration.java b/src/main/java/com/gtnewhorizons/gtnhgradle/PropertiesConfiguration.java index 0c6ef3da..d91d91ed 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/PropertiesConfiguration.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/PropertiesConfiguration.java @@ -281,30 +281,6 @@ ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empt """) public @NotNull String minecraftVersion = "1.7.10"; - /** See annotation */ - @Prop(name = "forgeVersion", isSettings = false, preferPopulated = true, required = false, docComment = """ - Version of Minecraft Forge to target - """) - public @NotNull String forgeVersion = "10.13.4.1614"; - - /** See annotation */ - @Prop(name = "channel", isSettings = false, preferPopulated = true, required = false, docComment = """ - Specify an MCP channel for dependency deobfuscation and the deobfParams task. - """) - public @NotNull String channel = "stable"; - - /** See annotation */ - @Prop(name = "mappingsVersion", isSettings = false, preferPopulated = true, required = false, docComment = """ - Specify an MCP mappings version for dependency deobfuscation and the deobfParams task. - """) - public @NotNull String mappingsVersion = "12"; - - /** See annotation */ - @Prop(name = "remoteMappings", isSettings = false, preferPopulated = true, required = false, docComment = """ - Defines other MCP mappings for dependency deobfuscation. - """) - public @NotNull String remoteMappings = "https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/"; - /** See annotation */ @Prop( name = "developmentEnvironmentUserName", @@ -341,6 +317,21 @@ Enables using modern Java syntax (up to version 17) via Jabel, while still targe """) public boolean enableGenericInjection = false; + /** See annotation */ + @Prop( + name = "stripForgeRequirements", + isSettings = false, + preferPopulated = true, + required = false, + docComment = """ + 1.12.2 ONLY + Some mods require a specific forge version to launch in. When you need to use one of those mods as a dependency, + and cannot launch with the forge version required, enable this to strip the forge version requirements from that mod. + This will add 'strip-latest-forge-requirements' as 'runtimeOnlyNonPublishable'. + Requires useMixins or forceEnableMixins to be true, as the mod uses mixins to function. + """) + public boolean stripForgeRequirements = false; + /** See annotation */ @Prop( name = "generateGradleTokenClass", @@ -430,9 +421,11 @@ Enables using modern Java syntax (up to version 17) via Jabel, while still targe preferPopulated = true, required = false, docComment = """ - Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/ - There can be multiple files in a space-separated list. + Specify the configuration file for Forge's access transformers here. + It can be placed into /src/main/resources/META-INF/ or /src/main/resources + There can be multiple files in a space-separated or comma-separated list. Example value: mymodid_at.cfg nei_at.cfg + Example value: mymodid_at.cfg,nei_at.cfg """) public @NotNull String accessTransformersFile = ""; @@ -478,6 +471,17 @@ Enables using modern Java syntax (up to version 17) via Jabel, while still targe """) public @NotNull String mixinsPackage = ""; + /** See annotation */ + @Prop( + name = "mixinConfigRefmap", + isSettings = false, + preferPopulated = true, + required = false, + docComment = """ + Location of the mixin config refmap. If left, blank, defaults to "mixins.${modId}.refmap.json". Target file must have the "json" extension. + """) + public @NotNull String mixinConfigRefmap = ""; + /** See annotation */ @Prop( name = "coreModClass", @@ -549,7 +553,10 @@ Enables using modern Java syntax (up to version 17) via Jabel, while still targe preferPopulated = true, required = false, docComment = """ - Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories. + Adds the following well-known repositories: + CurseMaven + Modrinth + BlameJared(1.12.2 only) """) public boolean includeWellKnownRepositories = true; @@ -564,6 +571,7 @@ Enables using modern Java syntax (up to version 17) via Jabel, while still targe list of strings, with the acceptable keys being(case does not matter): cursemaven modrinth + blamejared """) public @NotNull String excludeWellKnownRepositories = ""; @@ -575,6 +583,7 @@ list of strings, with the acceptable keys being(case does not matter): required = false, hidden = true, docComment = """ + [1.7.10 only] Adds a dependency override rule to use RFG-deobfuscated https://www.curseforge.com/minecraft/mc-mods/industrial-craft/files/2353971 instead of net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev """) public boolean useIC2FromCurseforge = true; @@ -620,7 +629,8 @@ list of strings, with the acceptable keys being(case does not matter): type can be one of [project, version], and the name is the Modrinth project or version slug/id of the other mod. Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech - Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true + Note: on 1.7.10, UniMixins is automatically set as a required dependency if usesMixins = true + On 1.12.2, MixinBooter is automatically set as a required dependency """) public @NotNull String modrinthRelations = ""; @@ -645,7 +655,8 @@ list of strings, with the acceptable keys being(case does not matter): Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible], and the name is the CurseForge project slug of the other mod. Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft - Note: UniMixins is automatically set as a required dependency if usesMixins = true. + Note: On 1.7.10, UniMixins is automatically set as a required dependency if usesMixins = true. + On 1.12.2, MixinBooter is automatically set as a required dependency """) public @NotNull String curseForgeRelations = ""; @@ -736,6 +747,32 @@ Uncomment this to disable Checkstyle checks (currently wildcard import check). This is meant to be set in $HOME/.gradle/gradle.properties. """) public boolean ideaCheckSpotlessOnBuild = true; + + @Prop( + name = "releaseType", + isSettings = false, + preferPopulated = false, + required = false, + defaultInComment = "release", + docComment = """ + This project's release type on CurseForge and/or Modrinth. + Alternatively this can be set with the 'RELEASE_TYPE' environment variable. + Allowed types: release, beta, alpha + Leave blank to use the old release type, with -pre designations + """) + public String releaseType = "release"; + + @Prop( + name = "separateRunDirs", + isSettings = false, + preferPopulated = false, + required = false, + defaultInComment = "false", + docComment = """ + Separate run directories into "run/client" for runClient task, and "run/server" for runServer task. + Useful for debugging a server and client simultaneously. If not enabled, it will be in the standard location "run/" + """) + public boolean separateRunDirs = false; // // diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/UpdateableConstants.java b/src/main/java/com/gtnewhorizons/gtnhgradle/UpdateableConstants.java index 8228e8b1..6bbd0386 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/UpdateableConstants.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/UpdateableConstants.java @@ -16,18 +16,23 @@ public class UpdateableConstants { // https://github.com/GTNewHorizons/ExampleMod1.7.10/releases public static final @NotNull String NEWEST_BLOWDRYER_TAG = "0.2.2"; - /** Latest version of UniMixins */ + /** Latest version of UniMixins for 1.7.10 */ public static final String NEWEST_UNIMIXINS = "io.github.legacymoddingmc:unimixins:0.1.18"; + /** Latest version of MixinBooter for 1.12.2 */ + public static final String NEWEST_MIXINBOOTER = "zone.rong:mixinbooter:10.2"; + /** Latest version of Jabel for modern Java support */ public static final @NotNull String NEWEST_JABEL = "com.github.bsideup.jabel:jabel-javac-plugin:1.0.1"; /** Latest version of GTNHLib for modern Java support */ // https://github.com/GTNewHorizons/GTNHLib/releases public static final @NotNull String NEWEST_GTNH_LIB = "com.github.GTNewHorizons:GTNHLib:0.5.18"; - /** Latest version of GTNHLib for modern Java support */ + /** Latest version of lwjgl3ify for modern Java support */ // https://github.com/GTNewHorizons/lwjgl3ify/releases public static final @NotNull String NEWEST_LWJGL3IFY = "com.github.GTNewHorizons:lwjgl3ify:2.1.4"; - /** Latest version of GTNHLib for modern Java support */ + /** Latest version of lwjgl3ify for modern Java support on 1.12.2 */ + public static final @NotNull String NEWEST_LWJGL3IFY_1122 = "io.github.twilightflower:lwjgl3ify:1.0.1"; + /** Latest version of Hodgepodge for modern Java support */ // https://github.com/GTNewHorizons/Hodgepodge/releases public static final @NotNull String NEWEST_HODGEPODGE = "com.github.GTNewHorizons:Hodgepodge:2.5.74"; /** Latest version of LWJGL3 for modern Java support */ @@ -50,4 +55,7 @@ public class UpdateableConstants { /** Latest Industrial Craft 2 version */ public static final @NotNull String NEWEST_IC2_SPEC = "curse.maven:ic2-242638:2353971"; + + /** Latest strip-latest-forge-requirements for 1.12.2 */ + public static final @NotNull String NEWEST_STRIP_FORGE_REQUIREMENTS = "com.cleanroommc:strip-latest-forge-requirements:1.0"; } diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/AccessTransformerModule.java b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/AccessTransformerModule.java index febaf593..bbdf5ec5 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/AccessTransformerModule.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/AccessTransformerModule.java @@ -33,6 +33,9 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project .resolve("main") .resolve("resources") .resolve("META-INF"); + final Path resources = projectRoot.resolve("src") + .resolve("main") + .resolve("resources"); final SourceSetContainer sourceSets = project.getExtensions() .getByType(JavaPluginExtension.class) @@ -40,11 +43,18 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project final ConfigurableFileCollection atList = mcpTasks.getDeobfuscationATs(); if (!gtnh.configuration.accessTransformersFile.isEmpty()) { - for (String atFile : gtnh.configuration.accessTransformersFile.split(" ")) { - final Path targetFile = metaInf.resolve(atFile.trim()); - if (!Files.exists(metaInf.resolve(targetFile))) { - throw new GradleException( - "Could not resolve \"accessTransformersFile\"! Could not find " + targetFile); + String commaSeparated = gtnh.configuration.accessTransformersFile.replaceAll("\\s+(\\s*)", ",$1"); + for (String atFile : commaSeparated.split(",")) { + atFile = atFile.trim(); + final Path targetFile; + final Path targetFileResources = resources.resolve(atFile); + final Path targetFileMetaInf = metaInf.resolve(atFile); + if (Files.exists(resources.resolve(targetFileResources))) { + targetFile = targetFileResources; + } else if (Files.exists(metaInf.resolve(targetFileMetaInf))) { + targetFile = targetFileMetaInf; + } else { + throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + atFile); } atList.from(projectRoot.relativize(targetFile)); } diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/IdeIntegrationModule.java b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/IdeIntegrationModule.java index f4612bb1..6b189d2d 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/IdeIntegrationModule.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/IdeIntegrationModule.java @@ -177,9 +177,8 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project final RunMinecraftTask runClient = tasks.named("runClient", RunMinecraftTask.class) .get(); final var run = ijClientRun.get(); - run.setWorkingDirectory( - runClient.getWorkingDir() - .getAbsolutePath()); + File clientFile = new File(runClient.getWorkingDir(), gtnh.configuration.separateRunDirs ? "client" : ""); + run.setWorkingDirectory(clientFile.getAbsolutePath()); run.setProgramParameters(quotedJoin(runClient.calculateArgs())); run.setJvmArgs( quotedJoin(runClient.calculateJvmArgs()) + ' ' + quotedPropJoin(runClient.getSystemProperties())); @@ -192,9 +191,8 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project final RunMinecraftTask runServer = tasks.named("runServer", RunMinecraftTask.class) .get(); final var run = ijServerRun.get(); - run.setWorkingDirectory( - runServer.getWorkingDir() - .getAbsolutePath()); + File serverFile = new File(runServer.getWorkingDir(), gtnh.configuration.separateRunDirs ? "server" : ""); + run.setWorkingDirectory(serverFile.getAbsolutePath()); run.setProgramParameters(quotedJoin(runServer.calculateArgs())); run.setJvmArgs( quotedJoin(runServer.calculateJvmArgs()) + ' ' + quotedPropJoin(runServer.getSystemProperties())); diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/MixinModule.java b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/MixinModule.java index 91c272a6..e31ab7ab 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/MixinModule.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/MixinModule.java @@ -47,13 +47,22 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project } } - final String mixinProviderSpecNoClassifer = UpdateableConstants.NEWEST_UNIMIXINS; - final String mixinProviderSpec = mixinProviderSpecNoClassifer + ":dev"; + final String mixinProviderSpecNoClassifer = gtnh.minecraftVersion.mixinProviderSpec; + String mixinProviderSpec; + + if (gtnh.minecraftVersion == GTNHGradlePlugin.MinecraftVersion.V1_7_10) { + mixinProviderSpec = mixinProviderSpecNoClassifer + ":dev"; + } else { + mixinProviderSpec = mixinProviderSpecNoClassifer; + } + project.getExtensions() .getExtraProperties() .set("mixinProviderSpec", mixinProviderSpec); - final String mixingConfigRefMap = "mixins." + gtnh.configuration.modId + ".refmap.json"; + final String mixingConfigRefMap = gtnh.configuration.mixinConfigRefmap.isEmpty() + ? "mixins." + gtnh.configuration.modId + ".refmap.json" + : gtnh.configuration.mixinConfigRefmap; final String mixinSourceSetName = gtnh.configuration.separateMixinSourceSet.trim(); final SourceSetContainer sourceSets = project.getExtensions() .getByType(JavaPluginExtension.class) @@ -128,6 +137,13 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project deps.add("runtimeOnlyNonPublishable", mixinProviderSpec); } + if (gtnh.minecraftVersion == GTNHGradlePlugin.MinecraftVersion.V1_12_2) { + if ((gtnh.configuration.usesMixins || gtnh.configuration.forceEnableMixins) + && gtnh.configuration.stripForgeRequirements) { + deps.add("runtimeOnlyNonPublishable", UpdateableConstants.NEWEST_STRIP_FORGE_REQUIREMENTS); + } + } + // Replace old mixin mods with unimixins // https://docs.gradle.org/8.0.2/userguide/resolution_rules.html#sec:substitution_with_classifier project.getConfigurations() diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/ModernJavaModule.java b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/ModernJavaModule.java index 5dcc63ac..07635208 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/ModernJavaModule.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/ModernJavaModule.java @@ -100,22 +100,27 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project }); ext.set("java17PatchDependenciesCfg", java17PatchDependenciesCfg); + final String mixinSpec = gtnh.minecraftVersion.mixinProviderSpec; + final String lwjgl3ifySpec = gtnh.minecraftVersion.lwjgl3ifySpec; + if (!gtnh.configuration.modId.equals("lwjgl3ify")) { - deps.add(java17DependenciesCfg.getName(), UpdateableConstants.NEWEST_LWJGL3IFY); - ((ModuleDependency) deps - .add(java17PatchDependenciesCfg.getName(), UpdateableConstants.NEWEST_LWJGL3IFY + ":forgePatches")) - .setTransitive(false); + deps.add(java17DependenciesCfg.getName(), lwjgl3ifySpec); + ((ModuleDependency) deps.add(java17PatchDependenciesCfg.getName(), lwjgl3ifySpec + ":forgePatches")) + .setTransitive(false); } - if (!gtnh.configuration.modId.equals("hodgepodge")) { + + if (!gtnh.configuration.modId.equals("hodgepodge") + && gtnh.minecraftVersion == GTNHGradlePlugin.MinecraftVersion.V1_7_10) { final ModuleDependency hodgepodge = (ModuleDependency) deps .add(java17DependenciesCfg.getName(), UpdateableConstants.NEWEST_HODGEPODGE); if (gtnh.configuration.modId.equals("gtnhlib")) { hodgepodge.exclude(ImmutableMap.of("module", "GTNHLib")); } } + deps.getConstraints() - .add(java17DependenciesCfg.getName(), UpdateableConstants.NEWEST_UNIMIXINS) - .because("Use latest UniMixins known to GTNHGradle."); + .add(java17DependenciesCfg.getName(), mixinSpec) + .because("Use latest UniMixins or MixinBooter known to GTNHGradle."); final List java17JvmArgs = new ArrayList<>(Arrays.asList(JAVA_17_ARGS)); final List hotswapJvmArgs = new ArrayList<>(Arrays.asList(HOTSWAP_JVM_ARGS)); diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/PublishingModule.java b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/PublishingModule.java index a899f664..db4ea2fa 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/PublishingModule.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/PublishingModule.java @@ -102,8 +102,19 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project .set(gtnh.configuration.modrinthProjectId); mr.getVersionNumber() .set(modVersion); - mr.getVersionType() - .set(modVersion.map(v -> v.endsWith("-pre") ? "beta" : "release")); + String versionType = System.getenv("RELEASE_TYPE"); + if (versionType != null) { + mr.getVersionType() + .set(versionType); + } else { + if (!gtnh.configuration.releaseType.isEmpty()) { + mr.getVersionType() + .set(gtnh.configuration.releaseType); + } else { + mr.getVersionType() + .set(modVersion.map(v -> v.endsWith("-pre") ? "beta" : "release")); + } + } if (changelogFile.exists()) { final String contents = new String(Files.readAllBytes(changelogFile.toPath()), StandardCharsets.UTF_8); mr.getChangelog() @@ -114,7 +125,7 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project mr.getAdditionalFiles() .set(project.provider(() -> getSecondaryArtifacts(project, gtnh))); mr.getGameVersions() - .add(gtnh.configuration.minecraftVersion); + .add(gtnh.minecraftVersion.version); mr.getLoaders() .add("forge"); mr.getDebugMode() @@ -133,7 +144,7 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project } } if (gtnh.configuration.usesMixins) { - addModrinthDep(project, "required", "project", "unimixins"); + addModrinthDep(project, "required", "project", gtnh.minecraftVersion.modrinthMixinSlug); } project.getTasks() .named("modrinth") @@ -168,8 +179,17 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project artifact.changelogType = "markdown"; artifact.changelog = changelogFile; } - artifact.releaseType = modVersion.map(v -> v.endsWith("-pre") ? "beta" : "release"); - artifact.addGameVersion(gtnh.configuration.minecraftVersion, "Forge"); + String versionType = System.getenv("RELEASE_TYPE"); + if (versionType != null) { + artifact.releaseType = versionType; + } else { + if (!gtnh.configuration.releaseType.isEmpty()) { + artifact.releaseType = gtnh.configuration.releaseType; + } else { + artifact.releaseType = modVersion.map(v -> v.endsWith("-pre") ? "beta" : "release"); + } + } + artifact.addGameVersion(gtnh.minecraftVersion.version, "Forge"); artifact.addModLoader("Forge"); if (!gtnh.configuration.curseForgeRelations.isEmpty()) { @@ -184,7 +204,7 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project } } if (gtnh.configuration.usesMixins) { - artifact.addRelation("unimixins", "requiredDependency"); + artifact.addRelation(gtnh.minecraftVersion.curseMixinSlug, "requiredDependency"); } for (final Object secondary : getSecondaryArtifacts(project, gtnh)) { diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/ToolchainModule.java b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/ToolchainModule.java index 0eb52a53..59f39411 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/ToolchainModule.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/ToolchainModule.java @@ -98,6 +98,17 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project }); }); + if (gtnh.minecraftVersion == GTNHGradlePlugin.MinecraftVersion.V1_12_2) { + repos.maven(mvn -> { + mvn.setName("Cleanroom Maven"); + mvn.setUrl("https://maven.cleanroommc.com"); + }); + repos.maven(mvn -> { + mvn.setName("GTCEu Maven"); + mvn.setUrl("https://maven.gtceu.com"); + }); + } + // Provide a runtimeOnlyNonPublishable configuration final ConfigurationContainer cfg = project.getConfigurations(); final Configuration runtimeOnlyNonPublishable = cfg.create("runtimeOnlyNonPublishable", c -> { @@ -224,6 +235,9 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project final ModUtils modUtils = project.getExtensions() .getByType(ModUtils.class); + minecraft.getMcVersion() + .set(gtnh.configuration.minecraftVersion); + // Tag injection if (!gtnh.configuration.replaceGradleTokenInFile.isEmpty()) { for (final String f : gtnh.configuration.replaceGradleTokenInFile.split(",")) { @@ -351,10 +365,14 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project .provider( () -> Objects.requireNonNull(project.getVersion()) .toString()); - props.put("minecraftVersion", minecraft.getMcVersion()); + props.put( + gtnh.minecraftVersion == GTNHGradlePlugin.MinecraftVersion.V1_7_10 ? "minecraftVersion" : "mcversion", + minecraft.getMcVersion()); props.put("modId", gtnh.configuration.modId); props.put("modName", gtnh.configuration.modName); - props.put("modVersion", modVersion); + props.put( + gtnh.minecraftVersion == GTNHGradlePlugin.MinecraftVersion.V1_7_10 ? "modVersion" : "version", + modVersion); } tasks.named("processResources", ProcessResources.class) @@ -385,14 +403,15 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project manifest.attributes(ImmutableMap.of("FMLCorePlugin", props.modGroup + "." + props.coreModClass)); } if (props.usesMixins) { - manifest.attributes( - ImmutableMap.of( - "TweakClass", - "org.spongepowered.asm.launch.MixinTweaker", - "MixinConfigs", - "mixins." + props.modId + ".json", - "ForceLoadAsMod", - !props.containsMixinsAndOrCoreModOnly)); + if (gtnh.minecraftVersion == GTNHGradlePlugin.MinecraftVersion.V1_7_10) { + manifest.attributes( + ImmutableMap.of( + "TweakClass", + "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs", + "mixins." + props.modId + ".json")); + } + manifest.attributes(ImmutableMap.of("ForceLoadAsMod", !props.containsMixinsAndOrCoreModOnly)); } }); project.getExtensions() diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/UtilityModule.java b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/UtilityModule.java index bce2b8eb..b2b4a59b 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/UtilityModule.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/UtilityModule.java @@ -74,15 +74,15 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project final PropertiesConfiguration props = gtnh.configuration; final String mcpDir = project.getGradle() .getGradleUserHomeDir() + "/caches/minecraft/de/oceanlabs/mcp/mcp_" - + props.channel + + gtnh.minecraftVersion.mappingsChannel + "/" - + props.mappingsVersion; + + gtnh.minecraftVersion.mappingsVersion; final String mcpZIP = mcpDir + "/mcp_" - + props.channel + + gtnh.minecraftVersion.mappingsChannel + "-" - + props.mappingsVersion + + gtnh.minecraftVersion.mappingsVersion + "-" - + props.minecraftVersion + + gtnh.minecraftVersion.version + ".zip"; final String paramsCSV = mcpDir + "/params.csv"; @@ -91,17 +91,18 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project download.run(ds -> { try { ds.src( - "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_" + props.channel + "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_" + + gtnh.minecraftVersion.mappingsChannel + "/" - + props.mappingsVersion + + gtnh.minecraftVersion.mappingsVersion + "-" - + props.minecraftVersion + + gtnh.minecraftVersion.version + "/mcp_" - + props.channel + + gtnh.minecraftVersion.mappingsChannel + "-" - + props.mappingsVersion + + gtnh.minecraftVersion.mappingsVersion + "-" - + props.minecraftVersion + + gtnh.minecraftVersion.version + ".zip"); } catch (MalformedURLException e) { throw new RuntimeException(e); diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/WellKnownRepositoriesModule.java b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/WellKnownRepositoriesModule.java index 34ae2f6c..aef68e18 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/modules/WellKnownRepositoriesModule.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/modules/WellKnownRepositoriesModule.java @@ -48,5 +48,12 @@ public void apply(GTNHGradlePlugin.@NotNull GTNHExtension gtnh, @NotNull Project ec.filter(f -> { f.includeGroup("maven.modrinth"); }); }); } + + if (!excludes.contains("BLAMEJARED") && gtnh.minecraftVersion == GTNHGradlePlugin.MinecraftVersion.V1_12_2) { + repos.maven(mvn -> { + mvn.setName("BlameJared Maven"); + mvn.setUrl("https://maven.blamejared.com"); + }); + } } } diff --git a/src/main/java/com/gtnewhorizons/gtnhgradle/tasks/RunHotswappableMinecraftTask.java b/src/main/java/com/gtnewhorizons/gtnhgradle/tasks/RunHotswappableMinecraftTask.java index aeab1d2f..7e695e6d 100644 --- a/src/main/java/com/gtnewhorizons/gtnhgradle/tasks/RunHotswappableMinecraftTask.java +++ b/src/main/java/com/gtnewhorizons/gtnhgradle/tasks/RunHotswappableMinecraftTask.java @@ -1,7 +1,6 @@ package com.gtnewhorizons.gtnhgradle.tasks; import com.gtnewhorizons.gtnhgradle.GTNHGradlePlugin; -import com.gtnewhorizons.gtnhgradle.UpdateableConstants; import com.gtnewhorizons.retrofuturagradle.MinecraftExtension; import com.gtnewhorizons.retrofuturagradle.mcp.MCPTasks; import com.gtnewhorizons.retrofuturagradle.minecraft.MinecraftTasks; @@ -97,6 +96,7 @@ public void setup(Project project, GTNHGradlePlugin.GTNHExtension gtnh) { mcpTasks.getTaskPackagePatchedMc(), "jar"); getMainClass().set((side == Distribution.CLIENT) ? "GradleStart" : "GradleStartServer"); + getMcVersion().set(gtnh.configuration.minecraftVersion); getUsername().set(minecraft.getUsername()); getUserUUID().set(minecraft.getUserUUID()); if (side == Distribution.DEDICATED_SERVER) { @@ -108,12 +108,13 @@ public void setup(Project project, GTNHGradlePlugin.GTNHExtension gtnh) { systemProperty("gradlestart.bouncerServer", "com.gtnewhorizons.retrofuturabootstrap.Main"); if (gtnh.configuration.usesMixins) { + final String mixinSpec = gtnh.minecraftVersion.mixinProviderSpec; this.getExtraJvmArgs() .addAll(project.provider(() -> { final Configuration mixinCfg = project.getConfigurations() .detachedConfiguration( project.getDependencies() - .create(UpdateableConstants.NEWEST_UNIMIXINS)); + .create(mixinSpec)); mixinCfg.setCanBeConsumed(false); mixinCfg.setCanBeResolved(true); mixinCfg.setTransitive(false);