Skip to content

Commit

Permalink
Allow folders as classpath entries (#3)
Browse files Browse the repository at this point in the history
The IJ parser allows for folders to be part of the classpath.
This behaviour is useful for supplying folders of compiled .class or
source files.
  • Loading branch information
lynxplay authored Dec 18, 2024
1 parent 7e59ed6 commit ec11c0b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public static void addLibrary(Logger logger, Path libraryPath, IntelliJEnvironme
if (!Files.exists(libraryPath)) {
throw new UncheckedIOException(new NoSuchFileException(libraryPath.toString()));
}
ijEnv.addJarToClassPath(libraryPath);
if (Files.isDirectory(libraryPath)) ijEnv.addFolderToClasspath(libraryPath);
else ijEnv.addJarToClassPath(libraryPath);
logger.debug("Added %s", libraryPath);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public C1 get()La/b/c/Reference;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package a.b.c;

public record Reference(int a) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import a.b.c.Reference;

public class C1 {
public Reference get() {
return new Reference(1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import a.b.c.Reference;

public class C1 {
private Reference get() {
return new Reference(1);
}
}
5 changes: 5 additions & 0 deletions tests/src/test/java/net/neoforged/jst/tests/EmbeddedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ void testMethodsInheritance() throws Exception {
void testHiddenPrefixes() throws Exception {
runATTest("hidden_prefix", "--hidden-prefix=other");
}

@Test
void testFolderClasspathEntries() throws Exception {
runATTest("folder_classpath_entry", "--classpath=" + testDataRoot.resolve("accesstransformer/folder_classpath_entry/deps"));
}
}

@Nested
Expand Down

0 comments on commit ec11c0b

Please sign in to comment.