Skip to content

Commit

Permalink
Cleanup (Implements #116) (#130)
Browse files Browse the repository at this point in the history
PRs #127 #126 and #120 should merge with master to fix jenkins build failing
  • Loading branch information
fr1kin authored Sep 4, 2019
1 parent da004df commit 1a4f98d
Show file tree
Hide file tree
Showing 506 changed files with 17,354 additions and 20,592 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

[{*.java,*.gradle,*.properties}]
indent_style = space
indent_size = 2

[*.info]
indent_style = tab
184 changes: 88 additions & 96 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import org.apache.tools.ant.filters.ReplaceTokens

apply plugin: 'java'

buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.15.0"
}
repositories {
jcenter()
maven { url "http://files.minecraftforge.net/maven" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}

repositories {
mavenCentral()

maven { url 'https://oss.sonatype.org/content/groups/public/' }
mavenCentral()
maven { url "https://oss.sonatype.org/content/groups/public/" }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'net.minecraftforge.gradle.forge'

sourceCompatibility = targetCompatibility = '1.8'
Expand All @@ -30,111 +28,105 @@ version project.property('forgehax.version')
archivesBaseName = "forgehax-" + project.property('forgehax.mc.version')

configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

minecraft {
version = project.property('forgehax.forge.version')
runDir = "run"
version = project.property('forgehax.forge.version')
runDir = "run"

// channel_mapping
mappings = project.property('forgehax.mcp.channel') + '_' + project.property('forgehax.mcp.mapping')
// channel_mapping
mappings = "${project.property('forgehax.mcp.channel')}_${project.property('forgehax.mcp.mapping')}"
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.15.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.15.0'
}


jar {
manifest {
attributes (
'FMLCorePlugin': 'com.matt.forgehax.asm.ForgeHaxCoreMod',
'FMLCorePluginContainsFMLMod': 'true'
)
}
exclude ('assets/minecraft/textures/forgehax/*')
manifest {
attributes(
'FMLCorePlugin': 'com.matt.forgehax.asm.ForgeHaxCoreMod',
'FMLCorePluginContainsFMLMod': 'true'
)
}
}

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'
}


// TODO: Filter images out properly
//filesNotMatching("**/*.png") {
it.filter ReplaceTokens, tokens: [
"forgehax.version" : project.property("forgehax.version"),
"forgehax.mc.version" : project.property("forgehax.mc.version"),
"forgehax.forge.version": project.property("forgehax.forge.version"),
"forgehax.mcp.version" : project.property("forgehax.mcp.version"),
"forgehax.mcp.channel" : project.property("forgehax.mcp.channel"),
"forgehax.mcp.mapping" : project.property("forgehax.mcp.mapping")
]
//}
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'
}

filesMatching('**/*.properties') {
it.filter ReplaceTokens, tokens: [
"forgehax.version" : project.property("forgehax.version"),
"forgehax.mc.version" : project.property("forgehax.mc.version"),
"forgehax.forge.version": project.property("forgehax.forge.version"),
"forgehax.mcp.version" : project.property("forgehax.mcp.version"),
"forgehax.mcp.channel" : project.property("forgehax.mcp.channel"),
"forgehax.mcp.mapping" : project.property("forgehax.mcp.mapping")
]
}
}


task setGameDir() {
// Check if custom gamedir has been passed, if not use default ones per platform
if(!project.hasProperty("gameDir")) {
if(org.gradle.internal.os.OperatingSystem.current().isWindows()) {
project.ext.gameDir = System.getenv("APPDATA") + "/.minecraft"
} else if(org.gradle.internal.os.OperatingSystem.current().isMacOsX()) {
project.ext.gameDir = System.properties["user.home"] + "/Library/Application Support/minecraft"
} else {
project.ext.gameDir = System.properties["user.home"] + "/.minecraft"
}
// Check if custom gamedir has been passed, if not use default ones per platform
if (!project.hasProperty("gameDir")) {
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
project.ext.gameDir = System.getenv("APPDATA") + "/.minecraft"
} else if (org.gradle.internal.os.OperatingSystem.current().isMacOsX()) {
project.ext.gameDir = System.properties["user.home"] + "/Library/Application Support/minecraft"
} else {
project.ext.gameDir = System.properties["user.home"] + "/.minecraft"
}
}
}

task copyJar(type: Copy, dependsOn: [setGameDir]) {
def gameDirectory = "$gameDir/mods/" + minecraft.version

// find previous jar (if it exists)
def previousJars = fileTree(dir: gameDirectory).matching {
include archivesBaseName + '*'
}.files

// change file name
if(previousJars) {
// create .backups folder
def backupDir = gameDirectory + '/.backups/'
file(backupDir).mkdirs()

for(File previousJar : previousJars) {
def n = gameDirectory + '/.backups/' + previousJar.getName() + '.bk'
def f = file(n)
def i = 1
while(f.exists()) {
f = file(n + '_' + i)
i++
}
previousJar.renameTo(f)
}
def gameDirectory = "$gameDir/mods/" + minecraft.version

// find previous jar (if it exists)
def previousJars = fileTree(dir: gameDirectory).matching {
include archivesBaseName + '*'
}.files

// change file name
if (previousJars) {
// create .backups folder
def backupDir = gameDirectory + '/.backups/'
file(backupDir).mkdirs()

for (File previousJar : previousJars) {
def n = gameDirectory + '/.backups/' + previousJar.getName() + '.bk'
def f = file(n)
def i = 1
while (f.exists()) {
f = file(n + '_' + i)
i++
}
previousJar.renameTo(f)
}
}

// copy forgehax jar from libs to forge mod folder
from jar
into "$gameDir/mods/" + minecraft.version
// copy forgehax jar from libs to forge mod folder
from jar
into "$gameDir/mods/" + minecraft.version
}

task publishToMavenLocal() {} // dummy

build.finalizedBy copyJar
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
forgehax.version=2.9.0
forgehax.mc.version=1.12.2
forgehax.forge.version=1.12.2-14.23.5.2775
forgehax.forge.version=1.12.2-14.23.5.2846
forgehax.mcp.version=1.12
forgehax.mcp.channel=snapshot
forgehax.mcp.mapping=20171003
forgehax.mcp.mapping=20171003
2 changes: 1 addition & 1 deletion scripts/update
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
docker-compose \
-f docker-compose.ci.yml \
run --rm \
forgehax setupDecompWorkspace --stacktrace
forgehax setupDecompWorkspace --stacktrace --refresh-dependencies
fi
fi
45 changes: 27 additions & 18 deletions src/main/java/bspkrs/mmv/ClassSrgData.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,61 +27,70 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
*/

public class ClassSrgData implements Comparable<ClassSrgData> {

public static enum SortType {
PKG,
OBF
}

private final String obfName;
private final String srgName;
private String srgPkgName;
private final boolean isClientOnly;

public static SortType sortType = SortType.PKG;

public ClassSrgData(String obfName, String srgName, String srgPkgName, boolean isClientOnly) {
this.obfName = obfName;
this.srgName = srgName;
this.srgPkgName = srgPkgName;
this.isClientOnly = isClientOnly;
}

public String getObfName() {
return this.obfName;
}

public String getSrgName() {
return this.srgName;
}

public String getSrgPkgName() {
return this.srgPkgName;
}

public ClassSrgData setSrgPkgName(String pkg) {
this.srgPkgName = pkg;
return this;
}

public boolean isClientOnly() {
return isClientOnly;
}

public String getFullyQualifiedSrgName() {
return srgPkgName + "/" + srgName;
}

@Override
public int compareTo(ClassSrgData o) {
if (sortType == SortType.PKG)
if (o != null) return getFullyQualifiedSrgName().compareTo(o.getFullyQualifiedSrgName());
else return 1;
else if (o != null)
if (obfName.length() != o.obfName.length()) return obfName.length() - o.obfName.length();
else return obfName.compareTo(o.obfName);
else return 1;
if (sortType == SortType.PKG) {
if (o != null) {
return getFullyQualifiedSrgName().compareTo(o.getFullyQualifiedSrgName());
} else {
return 1;
}
} else if (o != null) {
if (obfName.length() != o.obfName.length()) {
return obfName.length() - o.obfName.length();
} else {
return obfName.compareTo(o.obfName);
}
} else {
return 1;
}
}

public boolean contains(String s) {
return srgName.contains(s) || obfName.contains(s) || this.srgPkgName.contains(s);
}
Expand Down
Loading

0 comments on commit 1a4f98d

Please sign in to comment.