Skip to content

Commit 7fe9fa0

Browse files
committed
fix: Bootstrap with FileSet
1 parent 550e356 commit 7fe9fa0

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/ch/vorburger/jvmtools/Bootstrap.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import static ch.vorburger.test.Assert.assertTrue;
44

5-
import java.nio.file.Path;
5+
import dev.enola.be.io.FileSet;
66

77
public class Bootstrap {
88

@@ -12,9 +12,7 @@ public static void main(String[] args) throws Exception {
1212

1313
var input =
1414
new JavaCompiler.Input.Builder()
15-
// TODO FileSet Glob
16-
.source(Path.of("src/ch/vorburger/jvmtools/JavaCompiler.java"))
17-
.source(Path.of("src/ch/vorburger/jvmtools/JavaCompilerTest.java"))
15+
.sources(new FileSet.Builder().addRoot("src").includeGlob("**/*.java"))
1816
.outputDirectory(".build/bootstrap-classes")
1917
.build();
2018
assertTrue(new JavaCompiler().invoke(input));

src/ch/vorburger/jvmtools/JavaCompiler.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import ch.vorburger.main.StdIO;
44
import ch.vorburger.stereotype.Service;
55

6+
import dev.enola.be.io.FileSet;
7+
68
import java.io.PrintStream;
79
import java.nio.file.Path;
810
import java.util.ArrayList;
@@ -33,7 +35,12 @@ public Builder stdIO(StdIO stdIO) {
3335
return this;
3436
}
3537

36-
public Builder source(Stream<Path> paths) {
38+
public Builder sources(FileSet.Builder fileSetBuilder) {
39+
sources(fileSetBuilder.build().stream());
40+
return this;
41+
}
42+
43+
public Builder sources(Stream<Path> paths) {
3744
// TODO Optimization: Keep Stream, and start compiling right away from it...
3845
paths.forEach(this.sourcepath::addPath);
3946
return this;

src/dev/enola/be/io/FileSet.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public Builder addRoot(Path root) {
4949
return this;
5050
}
5151

52+
public Builder addRoot(String root) {
53+
this.roots.add(Path.of(root));
54+
return this;
55+
}
56+
5257
public Builder includeGlob(String pattern) {
5358
this.includes.add(FileSystems.getDefault().getPathMatcher("glob:" + pattern));
5459
return this;

0 commit comments

Comments
 (0)