Skip to content

Commit

Permalink
Update module resolver demo
Browse files Browse the repository at this point in the history
  • Loading branch information
sormuras committed May 28, 2024
1 parent 942ac78 commit 442af66
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .bach/src/run.bach/run/bach
Submodule bach updated 1 files
+6 −0 ModuleLocator.java
10 changes: 8 additions & 2 deletions .bach/src/run.bach/run/demo/ModuleResolverDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ public static void main(String... args) throws Exception {
var resolver = ModuleResolver.ofSingleDirectory(lib, libraries);
resolver.resolveModule("org.junit.jupiter"); // to write and discover tests
resolver.resolveModule("org.junit.platform.console"); // to run tests
resolver.resolveModule("javafx.controls");
resolver.resolveMissingModules();
recording.stop();
}

ModuleFinder.of(lib).findAll().stream()
.map(ref -> ref.descriptor().toNameAndVersion() + " -> " + ref.location().orElseThrow())
.sorted()
.forEach(System.out::println);

// "jreleaser" via the tool provider SPI
var jreleaserHome = Folders.ofCurrentWorkingDirectory().tool("jreleaser@" + JReleaser.VERSION);
var jreleaserResolver = ModuleResolver.ofSingleDirectory(jreleaserHome, JReleaser.MODULES);
Expand All @@ -38,13 +44,13 @@ public static void main(String... args) throws Exception {
ToolFinder.of("java"), // provides "java" tool
ToolFinder.of(ModuleFinder.of(lib)), // provides "junit" tool
ToolFinder.of(ModuleFinder.of(jreleaserHome)), // provides "jreleaser" tool
ToolFinder.ofInstaller().withJavaApplication("demo/release@uri", JReleaser.URI));
ToolFinder.ofInstaller().withJavaApplication("jrelease@uri", JReleaser.URI));

var junit = tools.get("junit");
junit.run("--version");
junit.run("engines");

tools.get("jreleaser").run("--version");
tools.get("release@uri").run("--version");
tools.get("jrelease@uri").run("--version");
}
}
2 changes: 1 addition & 1 deletion .bach/src/run.bach/run/info/bach
Submodule bach updated 1 files
+22 −4 JavaFX.java

0 comments on commit 442af66

Please sign in to comment.