diff --git a/.gitignore b/.gitignore index 2c770e0..976eac4 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ build # other eclipse run +/secrets.properties diff --git a/build.gradle b/build.gradle index 7e88459..966f0c9 100644 --- a/build.gradle +++ b/build.gradle @@ -8,68 +8,91 @@ buildscript { } } -apply plugin: 'net.minecraftforge.gradle.forge' -apply from: 'configuration.gradle' - -sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly. -compileJava { - sourceCompatibility = targetCompatibility = "1.8" -} - -minecraft { - runDir = "run" - replace '@VERSION@', project.ext.modVersion - mappings = project.ext.snapshot +if (file('secrets.properties').exists()) { + println "Loading parameters from secrets.properties" + ext.secrets = new Properties() + file('secrets.properties').withReader {secrets.load(it)} } -processResources -{ - // 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 version and mcversion - expand 'version':project.version, 'mcversion':project.minecraft.version - } - - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' - } -} +allprojects { -task sourcesJar(type: Jar) { - description = 'Creates a JAR containing the source code.' - dependsOn reobfJar - from sourceSets.main.allSource - classifier = 'sources' -} + apply plugin: 'net.minecraftforge.gradle.forge' + apply from: 'configuration.gradle' + + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 + compileJava { + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 + } + + minecraft { + runDir = "run" + replace '@VERSION@', project.ext.modVersion + replace '@FINGERPRINT@', project.ext.fingerprint + replace '@UPDATEURL@', project.ext.updateurl + mappings = project.ext.snapshot + } + + jar { + manifest { + attributes 'Maven-Artifact': "${project.group}:${project.archivesBaseName}:${project.version}" + } + } + + processResources { + // 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 version and mcversion + expand 'version':project.version, 'mcversion':project.minecraft.version + } + + // copy everything else, thats not the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } + } + + task sourcesJar(type: Jar) { + description = 'Creates a JAR containing the source code.' + dependsOn reobfJar + from sourceSets.main.allSource + classifier = 'sources' + } + + task deobfJar(type: Jar) { + description = 'Creates a JAR containing the non-obfuscated compiled code.' + from sourceSets.main.output + from sourceSets.main.allSource + manifest { + attributes 'Maven-Artifact': "${project.group}:${project.archivesBaseName}:${project.version}" + } + classifier = "deobf" + } + + // https://gist.github.com/matthewprenger/9b2da059b89433a01c1c + task signJar(type: SignJar, dependsOn: reobfJar) { + onlyIf { // Skip the task if our secret data isn't available + project.hasProperty('keyStore') + } + keyStore = project.keyStore // This needs to be a path to the keystore file + alias = project.keyStoreAlias + storePass = project.keyStorePass + keyPass = project.keyStoreKeyPass + inputFile = jar.archivePath + outputFile = jar.archivePath + } -task deobfJar(type: Jar) { - description = 'Creates a JAR containing the non-obfuscated compiled code.' - from sourceSets.main.output - classifier = "deobf" } -// https://gist.github.com/matthewprenger/9b2da059b89433a01c1c -task signJar(type: SignJar) { - - onlyIf { // Skip the task if our secret data isn't available - project.hasProperty('keyStore') +minecraft { + if (project.ext.has('secrets')) { + clientRunArgs = ["--uuid ${secrets.uuid}", "--username ${secrets.username}"] } - - dependsOn reobfJar - - keyStore = project.keyStore // This needs to be a path to the keystore file - alias = project.keyStoreAlias - storePass = project.keyStorePass - keyPass = project.keyStoreKeyPass - inputFile = jar.archivePath - outputFile = jar.archivePath } //Adds the artifact types added by this script to the actual artifacts list. diff --git a/configuration.gradle b/configuration.gradle index 1674f99..1c5ba77 100644 --- a/configuration.gradle +++ b/configuration.gradle @@ -10,6 +10,8 @@ project.ext.modVersion = modVersion project.group = "org.orecruncher" project.archivesBaseName = "OreLib" project.version = "${mcVersion}-${modVersion}" +project.ext.fingerprint = "7a2128d395ad96ceb9d9030fbd41d035b435753a" +project.ext.updateurl = "https://raw.githubusercontent.com/OreCruncher/OreLib/master/version.json" // JAR tagging project.minecraft.version = "${mcVersion}-${forgeVersion}" diff --git a/src/main/java/org/orecruncher/LibInfo.java b/src/main/java/org/orecruncher/LibInfo.java index 37ed4f2..e16aac4 100644 --- a/src/main/java/org/orecruncher/LibInfo.java +++ b/src/main/java/org/orecruncher/LibInfo.java @@ -31,8 +31,8 @@ public final class LibInfo { public static final String VERSION = "@VERSION@"; public static final String MINECRAFT_VERSIONS = "[1.12.2,)"; public static final String DEPENDENCIES = "required-after:forge@[14.23.5.2768,);"; - public static final String UPDATE_URL = "https://raw.githubusercontent.com/OreCruncher/OreLib/master/version.json"; - public static final String FINGERPRINT = "7a2128d395ad96ceb9d9030fbd41d035b435753a"; + public static final String UPDATE_URL = "@UPDATEURL@"; + public static final String FINGERPRINT = "@FINGERPRINT@"; private LibInfo() {