Skip to content

Commit

Permalink
Add module locator API
Browse files Browse the repository at this point in the history
  • Loading branch information
sormuras committed May 28, 2024
1 parent 72b9384 commit 8d67d33
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
7 changes: 7 additions & 0 deletions .bach/src/run.bach/run/Prepare.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package run;

class Prepare {
public static void main(String... args) {
Project.ofCurrentWorkingDirectory().prepare();
}
}
13 changes: 6 additions & 7 deletions .bach/src/run.bach/run/Project.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package run;

import java.lang.module.ModuleFinder;
import java.util.Optional;
import run.bach.ModuleFinders;

import run.bach.ModuleLocator;
import run.bach.ToolCall;
import run.bach.ToolRunner;
import run.bach.workflow.Builder;
Expand Down Expand Up @@ -34,10 +34,10 @@ static Project ofCurrentWorkingDirectory() {
.withModule("src/test.bach", "src/test.bach/test/java/module-info.java")
.withModule("src/test.junit", "src/test.junit/test/java/module-info.java");
var libraries =
ModuleFinder.compose(
ModuleFinders.ofProperties(JUnit.MODULES),
ModuleFinders.ofProperties(
"org.junitpioneer=https://repo.maven.apache.org/maven2/org/junit-pioneer/junit-pioneer/2.2.0/junit-pioneer-2.2.0.jar#SIZE=191032"));
ModuleLocator.compose(
JUnit.modules(),
ModuleLocator.of("org.junitpioneer","pkg:maven/org.junit-pioneer/junit-pioneer@2.2.0")
);
var structure = new Structure(basics, new Spaces(main, test), libraries);
var runner = ToolRunner.ofSystem();
return new Project(verbose, new Workflow(folders, structure, runner));
Expand All @@ -52,7 +52,6 @@ public void printStatus() {
System.out.println(structure.toNameAndVersion());
System.out.println(structure.basics());
structure.spaces().forEach(System.out::println);
structure.libraries().findAll().stream().sorted().forEach(System.out::println);
System.out.println(workflow.folders());
System.out.println(workflow.runner());
}
Expand Down
7 changes: 0 additions & 7 deletions .bach/src/run.bach/run/Restore.java

This file was deleted.

12 changes: 6 additions & 6 deletions .bach/src/run.bach/run/demo/ModuleResolverDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
import java.nio.file.Path;

import jdk.jfr.consumer.RecordingStream;
import run.bach.ModuleFinders;
import run.bach.ModuleLocator;
import run.bach.ModuleResolver;
import run.bach.ToolFinder;
import run.info.bach.JavaFX;
import run.info.org.junit.JUnit;

public class ModuleResolverDemo {
public static void main(String... args) throws Exception {
var libraries = ModuleFinder.compose(ModuleFinders.ofProperties(JUnit.MODULES));

try (var reader = libraries.find("org.junit.jupiter").orElseThrow().open()) {
reader.list().forEach(System.out::println);
}
var libraries = ModuleLocator.compose(
JUnit.modules(),
JavaFX.version("22.0.1")
);

var lib = Path.of("lib");
try (var recording = new RecordingStream()) {
Expand Down

0 comments on commit 8d67d33

Please sign in to comment.