From 0b23dcdb392fd2cd8ebd54e48771bc3dd079ebeb Mon Sep 17 00:00:00 2001 From: bombcar Date: Thu, 23 Dec 2021 12:43:30 -0600 Subject: [PATCH] add version --- build.gradle | 109 ++++++++++++++---- gradle.properties | 14 +-- src/main/java/binnie/botany/Botany.java | 1 + src/main/java/binnie/core/BinnieCore.java | 17 +-- src/main/java/binnie/extrabees/ExtraBees.java | 1 + .../java/binnie/extratrees/ExtraTrees.java | 1 + src/main/java/binnie/genetics/Genetics.java | 1 + 7 files changed, 105 insertions(+), 39 deletions(-) diff --git a/build.gradle b/build.gradle index 18fedd35..43dfa377 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 928ecf7feb33a1149538b0e2cd17e3bc5f281428 +//version: 8fa7883b6196c1765266f4e6ddf3118d5043aafb /* DO NOT CHANGE THIS FILE! @@ -42,6 +42,7 @@ plugins { id("org.ajoberstar.grgit") version("3.1.1") id("com.github.johnrengelman.shadow") version("4.0.4") id("com.palantir.git-version") version("0.12.3") + id("maven-publish") } apply plugin: 'forge' @@ -194,7 +195,9 @@ if(file("addon.gradle").exists()) { apply from: 'repositories.gradle' configurations { - implementation.extendsFrom(shadowImplementation) + implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored + implementation.extendsFrom(shadowCompile) + implementation.extendsFrom(shadeCompile) } repositories { @@ -260,16 +263,28 @@ task relocateShadowJar(type: ConfigureShadowRelocation) { } shadowJar { + project.configurations.shadeCompile.each { dep -> + from(project.zipTree(dep)) { + exclude 'META-INF', 'META-INF/**' + } + } + manifest { attributes(getManifestAttributes()) } minimize() // This will only allow shading for actually used classes - configurations = [project.configurations.shadowImplementation] + configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile] dependsOn(relocateShadowJar) } jar { + project.configurations.shadeCompile.each { dep -> + from(project.zipTree(dep)) { + exclude 'META-INF', 'META-INF/**' + } + } + manifest { attributes(getManifestAttributes()) } @@ -343,31 +358,31 @@ tasks.withType(JavaExec).configureEach { } processResources - { - // this will ensure that this task is redone when the versions change. - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft.version +{ + // this will ensure that this task is redone when the versions change. + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' + // replace stuff in mcmod.info, nothing else + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' - // replace version and mcversion - expand "minecraftVersion": project.minecraft.version, - "modVersion": versionDetails().lastTag, - "modId": modId, - "modName": modName - } + // replace version and mcversion + expand "minecraftVersion": project.minecraft.version, + "modVersion": versionDetails().lastTag, + "modId": modId, + "modName": modName + } - if(usesMixins.toBoolean()) { - from refMap - } + if(usesMixins.toBoolean()) { + from refMap + } - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' - } - } + // copy everything else, thats not the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } +} def getManifestAttributes() { def manifestAttributes = [:] @@ -400,6 +415,12 @@ task sourcesJar(type: Jar) { } task shadowDevJar(type: ShadowJar) { + project.configurations.shadeCompile.each { dep -> + from(project.zipTree(dep)) { + exclude 'META-INF', 'META-INF/**' + } + } + from sourceSets.main.output getArchiveClassifier().set("dev") @@ -408,7 +429,7 @@ task shadowDevJar(type: ShadowJar) { } minimize() // This will only allow shading for actually used classes - configurations = [project.configurations.shadowImplementation] + configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile] } task relocateShadowDevJar(type: ConfigureShadowRelocation) { @@ -423,6 +444,12 @@ task circularResolverJar(type: Jar) { } task devJar(type: Jar) { + project.configurations.shadeCompile.each { dep -> + from(project.zipTree(dep)) { + exclude 'META-INF', 'META-INF/**' + } + } + from sourceSets.main.output getArchiveClassifier().set("dev") @@ -460,6 +487,38 @@ artifacts { } } +// publishing +publishing { + publications { + maven(MavenPublication) { + artifact source: jar + artifact source: sourcesJar, classifier: "src" + artifact source: devJar, classifier: "dev" + if (apiPackage) { + artifact source: apiJar, classifier: "api" + } + + groupId = System.getenv("ARTIFACT_GROUP_ID") ?: group + artifactId = System.getenv("ARTIFACT_ID") ?: project.name + version = System.getenv("ARTIFACT_VERSION") ?: project.version + } + } + + repositories { + maven { + String owner = System.getenv("REPOSITORY_OWNER") ?: "Unknown" + String repositoryName = System.getenv("REPOSITORY_NAME") ?: "Unknown" + String githubRepositoryUrl = "https://maven.pkg.github.com/$owner/$repositoryName" + name = "GitHubPackages" + url = githubRepositoryUrl + credentials { + username = System.getenv("GITHUB_ACTOR") ?: "NONE" + password = System.getenv("GITHUB_TOKEN") ?: "NONE" + } + } + } +} + // Updating task updateBuildScript { doLast { diff --git a/gradle.properties b/gradle.properties index 6fd836b6..c94b8185 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,24 +15,24 @@ autoUpdateBuildScript = false minecraftVersion = 1.7.10 forgeVersion = 10.13.4.1614 -# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you +# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you # restart Minecraft in development. Choose this dependent on your mod: # Do you need consistent player progressing (for example Thaumcraft)? -> Select a name # Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty -developmentEnvironmentUserName = "Developer" +developmentEnvironmentUserName = Developer # Define a source file of your project with: # public static final String VERSION = "GRADLETOKEN_VERSION"; -# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's +# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's # version in @Mod([...], version = VERSION, [...]) # Leave these properties empty to skip individual token replacements -replaceGradleTokenInFile = +replaceGradleTokenInFile = BinnieCore.java gradleTokenModId = gradleTokenModName = -gradleTokenVersion = +gradleTokenVersion = GRADLETOKEN_VERSION gradleTokenGroupName = -# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can +# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can # leave this property empty. # Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api apiPackage = @@ -48,7 +48,7 @@ mixinPlugin = # Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! mixinsPackage = # Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! -# This parameter is for legacy compatability only +# This parameter is for legacy compatibility only # Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin coreModClass = # If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class diff --git a/src/main/java/binnie/botany/Botany.java b/src/main/java/binnie/botany/Botany.java index b0a119a7..54a1deb4 100644 --- a/src/main/java/binnie/botany/Botany.java +++ b/src/main/java/binnie/botany/Botany.java @@ -55,6 +55,7 @@ import net.minecraftforge.event.world.BlockEvent; @Mod( modid = "Botany", name = "Botany", + version = BinnieCore.VERSION, useMetadata = true, dependencies = "after:BinnieCore" ) diff --git a/src/main/java/binnie/core/BinnieCore.java b/src/main/java/binnie/core/BinnieCore.java index d168b7f7..90e36a2d 100644 --- a/src/main/java/binnie/core/BinnieCore.java +++ b/src/main/java/binnie/core/BinnieCore.java @@ -47,11 +47,14 @@ import net.minecraftforge.client.event.TextureStitchEvent; import java.util.ArrayList; import java.util.List; -@Mod(modid = "BinnieCore", name = "Binnie Core", useMetadata = true, dependencies = "after:Forestry@[4.2,)") +import static binnie.core.BinnieCore.*; + +@Mod(modid = "BinnieCore", name = "Binnie Core", version = VERSION, useMetadata = true, dependencies = "after:Forestry@[4.2,)") public class BinnieCore extends AbstractMod { @Mod.Instance("BinnieCore") public static BinnieCore instance; @SidedProxy(clientSide = "binnie.core.proxy.BinnieProxyClient", serverSide = "binnie.core.proxy.BinnieProxyServer") + public static final String VERSION = "GRADLETOKEN_VERSION"; public static BinnieProxy proxy; public static int multipassRenderID; private static List modList = new ArrayList<>(); @@ -92,7 +95,7 @@ public class BinnieCore extends AbstractMod { @Override public void preInit() { - BinnieCore.instance = this; + instance = this; for (FluidContainer container : FluidContainer.values()) { Item item = new ItemFluidContainer(container); GameRegistry.registerItem(item, item.getUnlocalizedName().substring(5)); @@ -108,7 +111,7 @@ public class BinnieCore extends AbstractMod { NetworkRegistry.INSTANCE.registerGuiHandler(mod, new BinnieGUIHandler(mod)); } - BinnieCore.multipassRenderID = RenderingRegistry.getNextAvailableRenderId(); + multipassRenderID = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new MultipassBlockRenderer()); GameRegistry.registerTileEntity(TileEntityMetadata.class, "binnie.tile.metadata"); } @@ -147,12 +150,12 @@ public class BinnieCore extends AbstractMod { } static void registerMod(AbstractMod mod) { - BinnieCore.modList.add(mod); + modList.add(mod); } private static List getActiveMods() { List list = new ArrayList<>(); - for (AbstractMod mod : BinnieCore.modList) { + for (AbstractMod mod : modList) { if (mod.isActive()) { list.add(mod); } @@ -183,7 +186,7 @@ public class BinnieCore extends AbstractMod { @Override public IBinnieProxy getProxy() { - return BinnieCore.proxy; + return proxy; } @Override @@ -222,7 +225,7 @@ public class BinnieCore extends AbstractMod { public static class PacketHandler extends BinniePacketHandler { public PacketHandler() { - super(BinnieCore.instance); + super(instance); } } } diff --git a/src/main/java/binnie/extrabees/ExtraBees.java b/src/main/java/binnie/extrabees/ExtraBees.java index 1ec92508..b999a5e9 100644 --- a/src/main/java/binnie/extrabees/ExtraBees.java +++ b/src/main/java/binnie/extrabees/ExtraBees.java @@ -27,6 +27,7 @@ import net.minecraft.item.Item; @Mod( modid = "ExtraBees", name = "Extra Bees", + version = BinnieCore.VERSION, useMetadata = true, dependencies = "after:BinnieCore" ) diff --git a/src/main/java/binnie/extratrees/ExtraTrees.java b/src/main/java/binnie/extratrees/ExtraTrees.java index 38e4ce06..fbdeee7b 100644 --- a/src/main/java/binnie/extratrees/ExtraTrees.java +++ b/src/main/java/binnie/extratrees/ExtraTrees.java @@ -30,6 +30,7 @@ import net.minecraft.item.Item; @Mod( modid = "ExtraTrees", name = "Extra Trees", + version = BinnieCore.VERSION, useMetadata = true, dependencies = "after:BinnieCore" ) diff --git a/src/main/java/binnie/genetics/Genetics.java b/src/main/java/binnie/genetics/Genetics.java index f6317368..c824c4fc 100644 --- a/src/main/java/binnie/genetics/Genetics.java +++ b/src/main/java/binnie/genetics/Genetics.java @@ -25,6 +25,7 @@ import net.minecraft.item.Item; @Mod( modid = "Genetics", name = "Genetics", + version = BinnieCore.VERSION, useMetadata = true, dependencies = "after:BinnieCore" )