From aad12650ea7394e315ebe170ceebb345c739577d Mon Sep 17 00:00:00 2001 From: Runemoro Date: Sat, 18 Apr 2020 09:02:12 -0400 Subject: Fix a few bugs (#219) * Update Gradle and replace deprecated Gradle features * Allow naming class in default package (fixes #215) * Fix CFR crash (fixes #207) * Update README.md Co-Authored-By: liach <7806504+liach@users.noreply.github.com> Co-authored-by: liach <7806504+liach@users.noreply.github.com>--- README.md | 1 + build.gradle | 103 ++++++++++----------- gradle/wrapper/gradle-wrapper.properties | 2 +- .../cuchaz/enigma/source/cfr/EnigmaDumper.java | 8 +- .../enigma/translation/mapping/NameValidator.java | 7 +- .../representation/entry/ClassEntry.java | 2 +- 6 files changed, 59 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 3888b457..24fc9c5f 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Enigma is distributed under the [LGPL-3.0](LICENSE). Enigma includes the following open-source libraries: - A [modified version](https://github.com/FabricMC/procyon) of [Procyon](https://bitbucket.org/mstrobel/procyon) (Apache-2.0) + - A [modified version](https://github.com/FabricMC/cfr) of [CFR](https://github.com/leibnitz27/cfr) (MIT) - [Guava](https://github.com/google/guava) (Apache-2.0) - [SyntaxPane](https://github.com/Sciss/SyntaxPane) (Apache-2.0) - [Darcula](https://github.com/bulenkov/Darcula) (Apache-2.0) diff --git a/build.gradle b/build.gradle index 34573cf0..e5889c4c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,30 +1,16 @@ -// Do it this way so people with older Gradle can hopefully still build. -buildscript { - repositories { - jcenter() - maven { - url "https://plugins.gradle.org/m2/" - } - } - - dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.2' - } +plugins { + id 'java' + id 'com.github.johnrengelman.shadow' version '5.2.0' + id 'maven-publish' } -apply plugin: 'java' -apply plugin: 'eclipse' -apply plugin: 'idea' -apply plugin: 'com.github.johnrengelman.shadow' -apply plugin: 'maven' - group = 'cuchaz' version = '0.15.1' def generatedSourcesDir = "$buildDir/generated-src" -def ENV = System.getenv() -version = version + "+" + (ENV.BUILD_NUMBER ? ("build." + ENV.BUILD_NUMBER) : "local") +def buildNumber = System.getenv("BUILD_NUMBER") +version = version + "+" + (buildNumber ? "build.$buildNumber" : "local") sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -45,14 +31,9 @@ repositories { mavenLocal() mavenCentral() - maven { - name "Cuchaz Custom Repository" - url 'http://maven.cuchazinteractive.com' - } - maven { name "Modmuss Repository" - url 'http://maven.modmuss50.me/' + url 'https://maven.modmuss50.me/' } ivy { @@ -65,30 +46,29 @@ repositories { } configurations { - proGuard // used to download ProGuard - application // used for JSyntaxPane so it's not in the library POM - - compile.extendsFrom application + proGuard } dependencies { - compile 'com.google.guava:guava:28.0-jre' - compile 'com.google.code.gson:gson:2.8.5' - compile 'org.ow2.asm:asm:8.0' - compile 'org.ow2.asm:asm-commons:8.0' - compile 'org.ow2.asm:asm-tree:8.0' - compile 'org.ow2.asm:asm-util:8.0' - compile 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3' - - compile 'net.fabricmc:procyon-fabric-compilertools:0.5.35.+' - compile 'net.fabricmc:cfr:0.0.1' - - application name: "darcula", version: "1.0.0" - application 'de.sciss:syntaxpane:1.2.+' - application 'me.xdrop:fuzzywuzzy:1.2.0' - - testCompile 'junit:junit:4.+' - testCompile 'org.hamcrest:hamcrest-all:1.+' + implementation 'com.google.guava:guava:28.0-jre' + implementation 'com.google.code.gson:gson:2.8.5' + implementation 'org.ow2.asm:asm:8.0' + implementation 'org.ow2.asm:asm-commons:8.0' + implementation 'org.ow2.asm:asm-tree:8.0' + implementation 'org.ow2.asm:asm-util:8.0' + implementation 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3' + implementation 'net.fabricmc:procyon-fabric-compilertools:0.5.35.+' + implementation 'net.fabricmc:cfr:0.0.1' + implementation name: "darcula", version: "1.0.0" + implementation 'de.sciss:syntaxpane:1.2.+' + implementation 'me.xdrop:fuzzywuzzy:1.2.0' + implementation name: "darcula", version: "1.0.0" + implementation 'de.sciss:syntaxpane:1.2.+' + implementation 'me.xdrop:fuzzywuzzy:1.2.0' + + testImplementation 'junit:junit:4.+' + testImplementation 'org.hamcrest:hamcrest-all:1.+' + proGuard 'net.sf.proguard:proguard-base:6.+' } @@ -103,8 +83,8 @@ file('src/test/java/cuchaz/enigma/inputs').listFiles().each { theFile -> include 'cuchaz/enigma/inputs/Keep.class' } - archiveName = theFile.name + '.jar' - destinationDir = file('build/test-inputs') + archiveFileName = theFile.name + '.jar' + destinationDirectory = file('build/test-inputs') } task("${theFile.name}TestObf", type: JavaExec, @@ -184,12 +164,23 @@ artifacts { archives sourcesJar } -// And finally, make the build generate / install the jars. -build.dependsOn install - -apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/maven.gradle' +publishing { + publications { + mavenJava(MavenPublication) { + artifact jar + } + } -uploadArchives.repositories.mavenDeployer.pom.withXml { - asNode().dependencies.'*'.findAll() { it.artifactId.text() == 'darcula' } - .each() { it.parent().remove(it) } + // select the repositories you want to publish to + repositories { + if (project.hasProperty('mavenPass')) { + maven { + url = "http://mavenupload.modmuss50.me/" + credentials { + username = "buildslave" + password = project.getProperty('mavenPass') + } + } + } + } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f4d7b2bf..6623300b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java b/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java index e265d9d1..09e0a9b2 100644 --- a/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java +++ b/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java @@ -43,7 +43,13 @@ public class EnigmaDumper implements Dumper { } private String getDesc(JavaTypeInstance type) { - type = type.getDeGenerifiedType(); + if (!type.isUsableType() && type != RawJavaType.VOID) { + throw new IllegalArgumentException(type.toString()); + } + + if (type instanceof JavaGenericBaseInstance) { + return getDesc(type.getDeGenerifiedType()); + } if (type instanceof JavaRefTypeInstance) { return "L" + type.getRawName().replace('.', '/') + ";"; diff --git a/src/main/java/cuchaz/enigma/translation/mapping/NameValidator.java b/src/main/java/cuchaz/enigma/translation/mapping/NameValidator.java index 19473ead..5bc2f67a 100644 --- a/src/main/java/cuchaz/enigma/translation/mapping/NameValidator.java +++ b/src/main/java/cuchaz/enigma/translation/mapping/NameValidator.java @@ -26,7 +26,7 @@ public class NameValidator { "boolean", "do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte", "else", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", "void", "class", "finally", - "long", "strictfp", "volatile", "const", "float", "native", "super", "while" + "long", "strictfp", "volatile", "const", "float", "native", "super", "while", "_" ); static { @@ -35,13 +35,10 @@ public class NameValidator { CLASS_PATTERN = Pattern.compile(String.format("^(%s(\\.|/))*(%s)$", identifierRegex, identifierRegex)); } - public static void validateClassName(String name, boolean packageRequired) { + public static void validateClassName(String name) { if (!CLASS_PATTERN.matcher(name).matches() || ILLEGAL_IDENTIFIERS.contains(name)) { throw new IllegalNameException(name, "This doesn't look like a legal class name"); } - if (packageRequired && ClassEntry.getPackageName(name) == null) { - throw new IllegalNameException(name, "Class must be in a package"); - } } public static void validateIdentifier(String name) { diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java index 74298e43..d6171f11 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java @@ -98,7 +98,7 @@ public class ClassEntry extends ParentedEntry implements Comparable< @Override public void validateName(String name) throws IllegalNameException { - NameValidator.validateClassName(name, !isInnerClass()); + NameValidator.validateClassName(name); } @Override -- cgit v1.2.3