diff options
| author | 2020-04-18 09:02:12 -0400 | |
|---|---|---|
| committer | 2020-04-18 14:02:12 +0100 | |
| commit | aad12650ea7394e315ebe170ceebb345c739577d (patch) | |
| tree | 130e544e082ec16be80fb17a3855dcead43af957 | |
| parent | Added zoom for PanelEditor (#209) (diff) | |
| download | enigma-fork-aad12650ea7394e315ebe170ceebb345c739577d.tar.gz enigma-fork-aad12650ea7394e315ebe170ceebb345c739577d.tar.xz enigma-fork-aad12650ea7394e315ebe170ceebb345c739577d.zip | |
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>
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | build.gradle | 103 | ||||
| -rw-r--r-- | gradle/wrapper/gradle-wrapper.properties | 2 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java | 8 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/translation/mapping/NameValidator.java | 7 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java | 2 |
6 files changed, 59 insertions, 64 deletions
| @@ -8,6 +8,7 @@ Enigma is distributed under the [LGPL-3.0](LICENSE). | |||
| 8 | 8 | ||
| 9 | Enigma includes the following open-source libraries: | 9 | Enigma includes the following open-source libraries: |
| 10 | - A [modified version](https://github.com/FabricMC/procyon) of [Procyon](https://bitbucket.org/mstrobel/procyon) (Apache-2.0) | 10 | - A [modified version](https://github.com/FabricMC/procyon) of [Procyon](https://bitbucket.org/mstrobel/procyon) (Apache-2.0) |
| 11 | - A [modified version](https://github.com/FabricMC/cfr) of [CFR](https://github.com/leibnitz27/cfr) (MIT) | ||
| 11 | - [Guava](https://github.com/google/guava) (Apache-2.0) | 12 | - [Guava](https://github.com/google/guava) (Apache-2.0) |
| 12 | - [SyntaxPane](https://github.com/Sciss/SyntaxPane) (Apache-2.0) | 13 | - [SyntaxPane](https://github.com/Sciss/SyntaxPane) (Apache-2.0) |
| 13 | - [Darcula](https://github.com/bulenkov/Darcula) (Apache-2.0) | 14 | - [Darcula](https://github.com/bulenkov/Darcula) (Apache-2.0) |
diff --git a/build.gradle b/build.gradle index 34573cf..e5889c4 100644 --- a/build.gradle +++ b/build.gradle | |||
| @@ -1,30 +1,16 @@ | |||
| 1 | // Do it this way so people with older Gradle can hopefully still build. | 1 | plugins { |
| 2 | buildscript { | 2 | id 'java' |
| 3 | repositories { | 3 | id 'com.github.johnrengelman.shadow' version '5.2.0' |
| 4 | jcenter() | 4 | id 'maven-publish' |
| 5 | maven { | ||
| 6 | url "https://plugins.gradle.org/m2/" | ||
| 7 | } | ||
| 8 | } | ||
| 9 | |||
| 10 | dependencies { | ||
| 11 | classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.2' | ||
| 12 | } | ||
| 13 | } | 5 | } |
| 14 | 6 | ||
| 15 | apply plugin: 'java' | ||
| 16 | apply plugin: 'eclipse' | ||
| 17 | apply plugin: 'idea' | ||
| 18 | apply plugin: 'com.github.johnrengelman.shadow' | ||
| 19 | apply plugin: 'maven' | ||
| 20 | |||
| 21 | group = 'cuchaz' | 7 | group = 'cuchaz' |
| 22 | version = '0.15.1' | 8 | version = '0.15.1' |
| 23 | 9 | ||
| 24 | def generatedSourcesDir = "$buildDir/generated-src" | 10 | def generatedSourcesDir = "$buildDir/generated-src" |
| 25 | 11 | ||
| 26 | def ENV = System.getenv() | 12 | def buildNumber = System.getenv("BUILD_NUMBER") |
| 27 | version = version + "+" + (ENV.BUILD_NUMBER ? ("build." + ENV.BUILD_NUMBER) : "local") | 13 | version = version + "+" + (buildNumber ? "build.$buildNumber" : "local") |
| 28 | 14 | ||
| 29 | sourceCompatibility = 1.8 | 15 | sourceCompatibility = 1.8 |
| 30 | targetCompatibility = 1.8 | 16 | targetCompatibility = 1.8 |
| @@ -46,13 +32,8 @@ repositories { | |||
| 46 | mavenCentral() | 32 | mavenCentral() |
| 47 | 33 | ||
| 48 | maven { | 34 | maven { |
| 49 | name "Cuchaz Custom Repository" | ||
| 50 | url 'http://maven.cuchazinteractive.com' | ||
| 51 | } | ||
| 52 | |||
| 53 | maven { | ||
| 54 | name "Modmuss Repository" | 35 | name "Modmuss Repository" |
| 55 | url 'http://maven.modmuss50.me/' | 36 | url 'https://maven.modmuss50.me/' |
| 56 | } | 37 | } |
| 57 | 38 | ||
| 58 | ivy { | 39 | ivy { |
| @@ -65,30 +46,29 @@ repositories { | |||
| 65 | } | 46 | } |
| 66 | 47 | ||
| 67 | configurations { | 48 | configurations { |
| 68 | proGuard // used to download ProGuard | 49 | proGuard |
| 69 | application // used for JSyntaxPane so it's not in the library POM | ||
| 70 | |||
| 71 | compile.extendsFrom application | ||
| 72 | } | 50 | } |
| 73 | 51 | ||
| 74 | dependencies { | 52 | dependencies { |
| 75 | compile 'com.google.guava:guava:28.0-jre' | 53 | implementation 'com.google.guava:guava:28.0-jre' |
| 76 | compile 'com.google.code.gson:gson:2.8.5' | 54 | implementation 'com.google.code.gson:gson:2.8.5' |
| 77 | compile 'org.ow2.asm:asm:8.0' | 55 | implementation 'org.ow2.asm:asm:8.0' |
| 78 | compile 'org.ow2.asm:asm-commons:8.0' | 56 | implementation 'org.ow2.asm:asm-commons:8.0' |
| 79 | compile 'org.ow2.asm:asm-tree:8.0' | 57 | implementation 'org.ow2.asm:asm-tree:8.0' |
| 80 | compile 'org.ow2.asm:asm-util:8.0' | 58 | implementation 'org.ow2.asm:asm-util:8.0' |
| 81 | compile 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3' | 59 | implementation 'net.sf.jopt-simple:jopt-simple:6.0-alpha-3' |
| 82 | 60 | implementation 'net.fabricmc:procyon-fabric-compilertools:0.5.35.+' | |
| 83 | compile 'net.fabricmc:procyon-fabric-compilertools:0.5.35.+' | 61 | implementation 'net.fabricmc:cfr:0.0.1' |
| 84 | compile 'net.fabricmc:cfr:0.0.1' | 62 | implementation name: "darcula", version: "1.0.0" |
| 85 | 63 | implementation 'de.sciss:syntaxpane:1.2.+' | |
| 86 | application name: "darcula", version: "1.0.0" | 64 | implementation 'me.xdrop:fuzzywuzzy:1.2.0' |
| 87 | application 'de.sciss:syntaxpane:1.2.+' | 65 | implementation name: "darcula", version: "1.0.0" |
| 88 | application 'me.xdrop:fuzzywuzzy:1.2.0' | 66 | implementation 'de.sciss:syntaxpane:1.2.+' |
| 89 | 67 | implementation 'me.xdrop:fuzzywuzzy:1.2.0' | |
| 90 | testCompile 'junit:junit:4.+' | 68 | |
| 91 | testCompile 'org.hamcrest:hamcrest-all:1.+' | 69 | testImplementation 'junit:junit:4.+' |
| 70 | testImplementation 'org.hamcrest:hamcrest-all:1.+' | ||
| 71 | |||
| 92 | proGuard 'net.sf.proguard:proguard-base:6.+' | 72 | proGuard 'net.sf.proguard:proguard-base:6.+' |
| 93 | } | 73 | } |
| 94 | 74 | ||
| @@ -103,8 +83,8 @@ file('src/test/java/cuchaz/enigma/inputs').listFiles().each { theFile -> | |||
| 103 | include 'cuchaz/enigma/inputs/Keep.class' | 83 | include 'cuchaz/enigma/inputs/Keep.class' |
| 104 | } | 84 | } |
| 105 | 85 | ||
| 106 | archiveName = theFile.name + '.jar' | 86 | archiveFileName = theFile.name + '.jar' |
| 107 | destinationDir = file('build/test-inputs') | 87 | destinationDirectory = file('build/test-inputs') |
| 108 | } | 88 | } |
| 109 | 89 | ||
| 110 | task("${theFile.name}TestObf", type: JavaExec, | 90 | task("${theFile.name}TestObf", type: JavaExec, |
| @@ -184,12 +164,23 @@ artifacts { | |||
| 184 | archives sourcesJar | 164 | archives sourcesJar |
| 185 | } | 165 | } |
| 186 | 166 | ||
| 187 | // And finally, make the build generate / install the jars. | 167 | publishing { |
| 188 | build.dependsOn install | 168 | publications { |
| 189 | 169 | mavenJava(MavenPublication) { | |
| 190 | apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/maven.gradle' | 170 | artifact jar |
| 171 | } | ||
| 172 | } | ||
| 191 | 173 | ||
| 192 | uploadArchives.repositories.mavenDeployer.pom.withXml { | 174 | // select the repositories you want to publish to |
| 193 | asNode().dependencies.'*'.findAll() { it.artifactId.text() == 'darcula' } | 175 | repositories { |
| 194 | .each() { it.parent().remove(it) } | 176 | if (project.hasProperty('mavenPass')) { |
| 177 | maven { | ||
| 178 | url = "http://mavenupload.modmuss50.me/" | ||
| 179 | credentials { | ||
| 180 | username = "buildslave" | ||
| 181 | password = project.getProperty('mavenPass') | ||
| 182 | } | ||
| 183 | } | ||
| 184 | } | ||
| 185 | } | ||
| 195 | } | 186 | } |
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f4d7b2b..6623300 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | distributionBase=GRADLE_USER_HOME | 1 | distributionBase=GRADLE_USER_HOME |
| 2 | distributionPath=wrapper/dists | 2 | distributionPath=wrapper/dists |
| 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip | 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip |
| 4 | zipStoreBase=GRADLE_USER_HOME | 4 | zipStoreBase=GRADLE_USER_HOME |
| 5 | zipStorePath=wrapper/dists | 5 | 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 e265d9d..09e0a9b 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 { | |||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | private String getDesc(JavaTypeInstance type) { | 45 | private String getDesc(JavaTypeInstance type) { |
| 46 | type = type.getDeGenerifiedType(); | 46 | if (!type.isUsableType() && type != RawJavaType.VOID) { |
| 47 | throw new IllegalArgumentException(type.toString()); | ||
| 48 | } | ||
| 49 | |||
| 50 | if (type instanceof JavaGenericBaseInstance) { | ||
| 51 | return getDesc(type.getDeGenerifiedType()); | ||
| 52 | } | ||
| 47 | 53 | ||
| 48 | if (type instanceof JavaRefTypeInstance) { | 54 | if (type instanceof JavaRefTypeInstance) { |
| 49 | return "L" + type.getRawName().replace('.', '/') + ";"; | 55 | 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 19473ea..5bc2f67 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 { | |||
| 26 | "boolean", "do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte", | 26 | "boolean", "do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte", |
| 27 | "else", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", | 27 | "else", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", |
| 28 | "extends", "int", "short", "try", "char", "final", "interface", "static", "void", "class", "finally", | 28 | "extends", "int", "short", "try", "char", "final", "interface", "static", "void", "class", "finally", |
| 29 | "long", "strictfp", "volatile", "const", "float", "native", "super", "while" | 29 | "long", "strictfp", "volatile", "const", "float", "native", "super", "while", "_" |
| 30 | ); | 30 | ); |
| 31 | 31 | ||
| 32 | static { | 32 | static { |
| @@ -35,13 +35,10 @@ public class NameValidator { | |||
| 35 | CLASS_PATTERN = Pattern.compile(String.format("^(%s(\\.|/))*(%s)$", identifierRegex, identifierRegex)); | 35 | CLASS_PATTERN = Pattern.compile(String.format("^(%s(\\.|/))*(%s)$", identifierRegex, identifierRegex)); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | public static void validateClassName(String name, boolean packageRequired) { | 38 | public static void validateClassName(String name) { |
| 39 | if (!CLASS_PATTERN.matcher(name).matches() || ILLEGAL_IDENTIFIERS.contains(name)) { | 39 | if (!CLASS_PATTERN.matcher(name).matches() || ILLEGAL_IDENTIFIERS.contains(name)) { |
| 40 | throw new IllegalNameException(name, "This doesn't look like a legal class name"); | 40 | throw new IllegalNameException(name, "This doesn't look like a legal class name"); |
| 41 | } | 41 | } |
| 42 | if (packageRequired && ClassEntry.getPackageName(name) == null) { | ||
| 43 | throw new IllegalNameException(name, "Class must be in a package"); | ||
| 44 | } | ||
| 45 | } | 42 | } |
| 46 | 43 | ||
| 47 | public static void validateIdentifier(String name) { | 44 | 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 74298e4..d6171f1 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<ClassEntry> implements Comparable< | |||
| 98 | 98 | ||
| 99 | @Override | 99 | @Override |
| 100 | public void validateName(String name) throws IllegalNameException { | 100 | public void validateName(String name) throws IllegalNameException { |
| 101 | NameValidator.validateClassName(name, !isInnerClass()); | 101 | NameValidator.validateClassName(name); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | @Override | 104 | @Override |