Skip to content

Commit

Permalink
fix copy resources in transform
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jul 14, 2024
1 parent 769e646 commit 36278da
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
19 changes: 19 additions & 0 deletions expect-platform-test/src/main/java/xyz/wagyourtail/ept/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import xyz.wagyourtail.unimined.expect.annotation.PlatformOnly;
import xyz.wagyourtail.unimined.expect.Target;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Main.TestAnnotation(Main.TestEnum.MAIN)
public class Main {

public static void main(String[] args) {
Expand All @@ -24,6 +29,10 @@ public static void main(String[] args) {
} catch (NoSuchMethodException e) {
System.out.println("platformOnlyTest does not exist");
}

// get annotation from class
TestAnnotation annotation = Main.class.getAnnotation(TestAnnotation.class);
System.out.println(annotation.value());
}

@ExpectPlatform(
Expand Down Expand Up @@ -54,4 +63,14 @@ public static void clientTest() {
public static void environmentCheck(Environment env) {
throw new AssertionError();
}

public enum TestEnum {
MAIN
}

@Retention(RetentionPolicy.RUNTIME)
@java.lang.annotation.Target(ElementType.TYPE)
public @interface TestAnnotation {
TestEnum value();
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kotlin.code.style=official

version = 1.0.4
version = 1.0.5

asmVersion=9.7
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ public void transform(Path inputRoot, Path outputRoot) throws IOException {
if (parent != null) {
Files.createDirectories(outputRoot.resolve(inputRoot.relativize(parent).toString()));
}
Path output = outputRoot.resolve(inputRoot.relativize(path).toString());

if (!path.toString().endsWith(".class")) {
Files.copy(path, output, StandardCopyOption.REPLACE_EXISTING);
return;
}
ClassReader reader = new ClassReader(Files.newInputStream(path));
ClassNode classNode = new ClassNode();
reader.accept(classNode, 0);

classNode = transform(classNode);

Path output = outputRoot.resolve(inputRoot.relativize(path).toString());
ClassWriter writer = new ClassWriter(reader, 0);
classNode.accept(writer);

Expand Down

0 comments on commit 36278da

Please sign in to comment.