Skip to content

Commit

Permalink
Add source to deobf build
Browse files Browse the repository at this point in the history
Gradle tweaks
  • Loading branch information
OreCruncher committed Nov 18, 2018
1 parent 73c5159 commit c431a3e
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -20,3 +20,4 @@ build
# other
eclipse
run
/secrets.properties
133 changes: 78 additions & 55 deletions build.gradle
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions configuration.gradle
Expand Up @@ -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}"
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/orecruncher/LibInfo.java
Expand Up @@ -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() {

Expand Down

0 comments on commit c431a3e

Please sign in to comment.