@@ -19,17 +19,34 @@ public class JavaCompiler implements Service<JavaCompiler.Input, Boolean> {
1919 // dev.enola.be.jvm module that uses this JavaCompiler class. Note that they have different
2020 // lifecycles - this is a Singleton service, while Task is per-invocation.
2121
22- // TODO Merge Input & Options into single joint record & class Builder?
23-
2422 public record Input (
25- StdIO stdIO , Sourcepath sourcepath /*, Classpath classpath*/ , Options options ) {}
26-
27- public static record Options (Path outputDirectory ) {
28- // TODO Support in-memory; see https://www.baeldung.com/java-string-compile-execute-code
23+ StdIO stdIO , Sourcepath sourcepath /*, Classpath classpath*/ , Options options ) {
2924
3025 public static class Builder {
26+ private StdIO stdIO = StdIO .system ();
27+ private Sourcepath sourcepath = new Sourcepath ();
3128 private Path outputDirectory ;
3229
30+ public Builder stdIO (StdIO stdIO ) {
31+ this .stdIO = stdIO ;
32+ return this ;
33+ }
34+
35+ // TODO Glob
36+ public Builder sourceAdd (Path path ) {
37+ this .sourcepath .addPath (path );
38+ return this ;
39+ }
40+
41+ public Sourcepath sourcepath () {
42+ return sourcepath ;
43+ }
44+
45+ public Builder sourcepath (Sourcepath sourcepath ) {
46+ this .sourcepath = sourcepath ;
47+ return this ;
48+ }
49+
3350 public Builder outputDirectory (Path outputDirectory ) {
3451 this .outputDirectory = outputDirectory ;
3552 return this ;
@@ -39,12 +56,16 @@ public Builder outputDirectory(String outputDirectory) {
3956 return outputDirectory (Path .of (outputDirectory ));
4057 }
4158
42- public Options build () {
43- return new Options (outputDirectory );
59+ public Input build () {
60+ var options = new Options (outputDirectory );
61+ return new Input (stdIO , sourcepath , options );
4462 }
4563 }
4664 }
4765
66+ // TODO Support in-memory output; see https://www.baeldung.com/java-string-compile-execute-code
67+ public static record Options (Path outputDirectory ) {}
68+
4869 @ Override
4970 public Boolean invoke (Input input ) throws Exception {
5071 var err = input .stdIO ().errWriter ();
0 commit comments