Skip to content

Commit ec11c0b

Browse files
authored
Allow folders as classpath entries (#3)
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.
1 parent 7e59ed6 commit ec11c0b

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

cli/src/main/java/net/neoforged/jst/cli/intellij/ClasspathSetup.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public static void addLibrary(Logger logger, Path libraryPath, IntelliJEnvironme
104104
if (!Files.exists(libraryPath)) {
105105
throw new UncheckedIOException(new NoSuchFileException(libraryPath.toString()));
106106
}
107-
ijEnv.addJarToClassPath(libraryPath);
107+
if (Files.isDirectory(libraryPath)) ijEnv.addFolderToClasspath(libraryPath);
108+
else ijEnv.addJarToClassPath(libraryPath);
108109
logger.debug("Added %s", libraryPath);
109110
}
110111
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public C1 get()La/b/c/Reference;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package a.b.c;
2+
3+
public record Reference(int a) {
4+
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import a.b.c.Reference;
2+
3+
public class C1 {
4+
public Reference get() {
5+
return new Reference(1);
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import a.b.c.Reference;
2+
3+
public class C1 {
4+
private Reference get() {
5+
return new Reference(1);
6+
}
7+
}

tests/src/test/java/net/neoforged/jst/tests/EmbeddedTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ void testMethodsInheritance() throws Exception {
302302
void testHiddenPrefixes() throws Exception {
303303
runATTest("hidden_prefix", "--hidden-prefix=other");
304304
}
305+
306+
@Test
307+
void testFolderClasspathEntries() throws Exception {
308+
runATTest("folder_classpath_entry", "--classpath=" + testDataRoot.resolve("accesstransformer/folder_classpath_entry/deps"));
309+
}
305310
}
306311

307312
@Nested

0 commit comments

Comments
 (0)