Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions enigma-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ application {
jar.manifest.attributes 'Main-Class': mainClass
}

test.dependsOn(project(':enigma').tasks.named('obfuscateTestInputs'))

publishing {
publications {
"$project.name"(MavenPublication) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class DropInvalidMappingsTest extends CommandTest {
private static final Path LONE_JAR = TestUtil.obfJar("lone_class");
private static final Path INNER_JAR = TestUtil.obfJar("inner_classes");
private static final Path ENUMS_JAR = TestUtil.obfJar("enums");
private static final Path DROP_INVALID_MAPPINGS_JAR = TestUtil.obfJar("z_drop_invalid_mappings");
private static final Path DROP_INVALID_MAPPINGS_JAR = TestUtil.obfJar("drop_invalid_mappings");
private static final Path INPUT_DIR = getResource("/drop_invalid_mappings/input/");
private static final Path EXPECTED_DIR = getResource("/drop_invalid_mappings/expected/");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import static org.quiltmc.enigma.TestUtil.getResource;

public class SearchMappingsTest {
private static final Path JAR = TestUtil.obfJar("complete");
// private static final Path JAR = TestUtil.obfJar("complete");
private static final Path JAR = TestUtil.obfJar("search_mappings");
private static final Path MAPPINGS = getResource("/search_mappings");

// classes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CLASS Z OtherReturnInterface
CLASS f OtherReturnInterface
METHOD a abstractMethod (I)C
ARG 1 intParam
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CLASS aa OuterClass
CLASS g OuterClass
CLASS a InnerClass
METHOD a getOther ()LZ;
METHOD a getOther ()Lf;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CLASS t ParamType
CLASS h ParamType
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CLASS l SelfReturnEnum
METHOD a staticGetArray ()[Ll;
METHOD a staticGet (Ljava/lang/String;)Ll;
CLASS i SelfReturnEnum
METHOD a staticGetArray ()[Li;
METHOD a staticGet (Ljava/lang/String;)Li;
ARG 0 staticStringParam
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CLASS I
CLASS a
FIELD a privateStringField Ljava/lang/String;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CLASS ac
CLASS b
FIELD a floatField F
FIELD a intField I
FIELD a stringField Ljava/lang/String;
Expand Down
3 changes: 3 additions & 0 deletions enigma-cli/src/test/resources/search_mappings/c.mapping
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CLASS c
METHOD a staticVoidMethod (Lh;)V
ARG 0 staticTypedParam
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CLASS V
CLASS d
FIELD a recordInt I
FIELD a recordString Ljava/lang/String;
FIELD b PRIVATE_STATIC_FINAL_INT_FIELD I
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CLASS ak
CLASS e
CLASS b InnerFieldType
3 changes: 0 additions & 3 deletions enigma-cli/src/test/resources/search_mappings/r.mapping

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
CLASS Q some/packaged/PackagedClass
CLASS j some/packaged/PackagedClass
21 changes: 16 additions & 5 deletions enigma/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,17 @@ static String taskNameFrom(String name) {
return builder.toString()
}


final obfuscateTestInputs = tasks.register('obfuscateTestInputs') {
group = 'test-setup'
}

// Generate obfuscated JARs for tests
// If your test fails for class file version problem with proguard, run gradle with -Dorg.gradle.java.home="<older jdk>" flag
def registerTestJarTasks(String name, String... input) {
String taskName = taskNameFrom(name)
final testJar = tasks.register("${taskName}TestJar", Jar.class) {
group = "test-setup"
group = 'test-setup'
from(sourceSets.test.output) {
include input
}
Expand All @@ -127,21 +132,27 @@ def registerTestJarTasks(String name, String... input) {
: file('src/test/resources/proguard-test.conf')

final testObf = tasks.register("${taskName}TestObf", ProGuardTask) {
group = "test-setup"
group = 'test-setup'

configuration confFileArg

final outDir = project.layout.buildDirectory.map { it.dir('test-obf') }

printmapping(outDir.map { it.dir("${name}.map") })

libraryjars(
[jarfilter: '!**.jar', filter: '!module-info.class'],
"${System.getProperty('java.home')}/jmods/java.base.jmod"
)

injars testJar.map { it.archiveFile }

outjars file("build/test-obf/${name}.jar")
outjars outDir.map { it.dir("${name}.jar") }
}

test.dependsOn(testObf)
tasks.named('obfuscateTestInputs') {
dependsOn(testObf)
}
}

registerTestJarTasks("complete", "org/quiltmc/enigma/input/**/*.class")
Expand Down Expand Up @@ -365,7 +376,7 @@ final testRecommendedImplPluginAgainstBumpedEnigma = tasks
}
}

test.dependsOn(testPreHandlingPluginAgainstCurrentEnigma, testRecommendedImplPluginAgainstBumpedEnigma)
test.dependsOn(obfuscateTestInputs, testPreHandlingPluginAgainstCurrentEnigma, testRecommendedImplPluginAgainstBumpedEnigma)

publishing {
publications {
Expand Down
2 changes: 1 addition & 1 deletion enigma/src/main/java/org/quiltmc/enigma/api/Enigma.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public EnigmaProject openJar(Path path, ClassProvider libraryClassProvider, Prog
MappingsIndex mappingsIndex = MappingsIndex.empty();
mappingsIndex.indexMappings(proposedNames, progress);

return new EnigmaProject(this, path, mainProjectProvider, jarIndex, libIndex, comboIndex, mappingsIndex, proposedNames, Utils.zipSha1(path));
return EnigmaProject.of(this, path, mainProjectProvider, jarIndex, libIndex, comboIndex, mappingsIndex, proposedNames, Utils.zipSha1(path));
}

private Predicate<String> createMainReferencedPredicate(AbstractJarIndex mainIndex, ProjectClassProvider classProvider) {
Expand Down
Loading