diff --git a/.classpath b/.classpath
index 85ecd15..87e3b11 100644
--- a/.classpath
+++ b/.classpath
@@ -14,11 +14,8 @@
-
-
-
diff --git a/src/main/java/com.github.forax.pro.bootstrap/com/github/forax/pro/bootstrap/Bootstrap.java b/src/main/java/com.github.forax.pro.bootstrap/com/github/forax/pro/bootstrap/Bootstrap.java
index f5e1bed..408bc85 100644
--- a/src/main/java/com.github.forax.pro.bootstrap/com/github/forax/pro/bootstrap/Bootstrap.java
+++ b/src/main/java/com.github.forax.pro.bootstrap/com/github/forax/pro/bootstrap/Bootstrap.java
@@ -61,11 +61,8 @@ public static void main(String[] args) throws IOException {
"com.github.forax.pro.plugin.runner@" + version,
"com.github.forax.pro.plugin.tester@" + version,
"com.github.forax.pro.plugin.jmher@" + version,
- "com.github.forax.pro.plugin.uberpackager@" + version,
"com.github.forax.pro.plugin.bootstrap@" + version + "/com.github.forax.pro.bootstrap.Bootstrap",
"com.github.forax.pro.bootstrap.genbuilder@" + version + "/com.github.forax.pro.bootstrap.genbuilder.GenBuilder",
- "com.github.forax.pro.ubermain@" + version,
- "com.github.forax.pro.uberbooter@" + version,
"com.github.forax.pro.daemon@" + version,
"com.github.forax.pro.daemon.imp@" + version
));
@@ -101,8 +98,6 @@ public static void main(String[] args) throws IOException {
"com.github.forax.pro.plugin.docer",
"com.github.forax.pro.plugin.packager",
"com.github.forax.pro.plugin.linker",
- "com.github.forax.pro.plugin.uberpackager",
- "com.github.forax.pro.uberbooter", // needed by ubermain
"com.github.forax.pro.daemon.imp"
) // then add all system modules
.appendAll(ModuleHelper.systemModulesFinder().findAll().stream()
diff --git a/src/main/java/com.github.forax.pro.plugin.uberpackager/com/github/forax/pro/plugin/uberpackager/ConventionFacade.java b/src/main/java/com.github.forax.pro.plugin.uberpackager/com/github/forax/pro/plugin/uberpackager/ConventionFacade.java
deleted file mode 100644
index 54fc645..0000000
--- a/src/main/java/com.github.forax.pro.plugin.uberpackager/com/github/forax/pro/plugin/uberpackager/ConventionFacade.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.github.forax.pro.plugin.uberpackager;
-
-import java.nio.file.Path;
-import java.util.List;
-
-import com.github.forax.pro.api.TypeCheckedConfig;
-
-@TypeCheckedConfig
-public interface ConventionFacade {
- Path javaModuleArtifactSourcePath();
- List javaModuleDependencyPath();
-
- Path javaModuleUberPath();
- Path javaModuleUberExplodedPath();
-}
diff --git a/src/main/java/com.github.forax.pro.plugin.uberpackager/com/github/forax/pro/plugin/uberpackager/UberPackagerConf.java b/src/main/java/com.github.forax.pro.plugin.uberpackager/com/github/forax/pro/plugin/uberpackager/UberPackagerConf.java
deleted file mode 100644
index 4c5d887..0000000
--- a/src/main/java/com.github.forax.pro.plugin.uberpackager/com/github/forax/pro/plugin/uberpackager/UberPackagerConf.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.github.forax.pro.plugin.uberpackager;
-
-import java.nio.file.Path;
-import java.util.List;
-
-import com.github.forax.pro.api.TypeCheckedConfig;
-
-@TypeCheckedConfig
-public interface UberPackagerConf {
- Path moduleArtifactSourcePath();
- void moduleArtifactSourcePath(Path destination);
-
- void moduleDependencyPath(List moduleDependencyPath);
- List moduleDependencyPath();
-
- Path moduleUberPath();
- void moduleUberPath(Path moduleUberPath);
-
- Path moduleUberExplodedPath();
- void moduleUberExplodedPath(Path moduleUberExplodedPath);
-}
diff --git a/src/main/java/com.github.forax.pro.plugin.uberpackager/com/github/forax/pro/plugin/uberpackager/UberPackagerPlugin.java b/src/main/java/com.github.forax.pro.plugin.uberpackager/com/github/forax/pro/plugin/uberpackager/UberPackagerPlugin.java
deleted file mode 100644
index b486d76..0000000
--- a/src/main/java/com.github.forax.pro.plugin.uberpackager/com/github/forax/pro/plugin/uberpackager/UberPackagerPlugin.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package com.github.forax.pro.plugin.uberpackager;
-
-import static com.github.forax.pro.api.MutableConfig.derive;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.spi.ToolProvider;
-
-import com.github.forax.pro.api.Config;
-import com.github.forax.pro.api.MutableConfig;
-import com.github.forax.pro.api.Plugin;
-import com.github.forax.pro.api.WatcherRegistry;
-import com.github.forax.pro.api.helper.CmdLine;
-import com.github.forax.pro.api.helper.ProConf;
-import com.github.forax.pro.helper.FileHelper;
-import com.github.forax.pro.helper.Log;
-import com.github.forax.pro.helper.util.StableList;
-
-public class UberPackagerPlugin implements Plugin {
- @Override
- public String name() {
- return "uberpackager";
- }
-
- @Override
- public void init(MutableConfig config) {
- config.getOrUpdate(name(), UberPackagerConf.class);
- }
-
- @Override
- public void configure(MutableConfig config) {
- var uberPackagerConf = config.getOrUpdate(name(), UberPackagerConf.class);
- var convention = config.getOrThrow("convention", ConventionFacade.class);
-
- // inputs
- derive(uberPackagerConf, UberPackagerConf::moduleArtifactSourcePath, convention, ConventionFacade::javaModuleArtifactSourcePath);
- derive(uberPackagerConf, UberPackagerConf::moduleDependencyPath, convention, ConventionFacade::javaModuleDependencyPath);
-
- // outputs
- derive(uberPackagerConf, UberPackagerConf::moduleUberPath, convention, ConventionFacade::javaModuleUberPath);
- derive(uberPackagerConf, UberPackagerConf::moduleUberExplodedPath, convention, ConventionFacade::javaModuleUberExplodedPath);
- }
-
- @Override
- public void watch(Config config, WatcherRegistry registry) {
- var uberPackagerConf = config.getOrThrow(name(), UberPackagerConf.class);
- uberPackagerConf.moduleArtifactSourcePath().forEach(registry::watch);
- uberPackagerConf.moduleDependencyPath().forEach(registry::watch);
- }
-
- @Override
- public int execute(Config config) throws IOException {
- var log = Log.create(name(), config.getOrThrow("pro", ProConf.class).loglevel());
- log.debug(config, conf -> "config " + config);
-
- log.info(null, __ -> "WARNING: this feature is highly experimental !");
-
- var jarTool = ToolProvider.findFirst("jar").orElseThrow(() -> new IllegalStateException("can not find the command jar"));
- var uberPackagerConf = config.getOrThrow(name(), UberPackagerConf.class);
-
- var uberExplodedPath = uberPackagerConf.moduleUberExplodedPath();
- FileHelper.deleteAllFiles(uberExplodedPath, false);
- Files.createDirectories(uberExplodedPath);
-
- var mainClass = com.github.forax.pro.ubermain.Main.class;
- var uberjarModule = mainClass.getModule();
- var uberJarRef = uberjarModule.getLayer().configuration().findModule(uberjarModule.getName()).get().reference();
- try(var moduleReader = uberJarRef.open()) {
- var mainClassName = mainClass.getName().replace('.', '/');
- for(var filename: List.of(mainClassName + ".class", mainClassName + "$1.class", mainClassName + "$1$1.class")) {
- var path = uberExplodedPath.resolve(filename);
- Files.createDirectories(path.getParent());
- Files.copy(moduleReader.open(filename).get(), path);
- }
- }
-
- //FIXME add the class of module uberbooter
-
- var modulePaths = StableList.of(uberPackagerConf.moduleArtifactSourcePath())
- .appendAll(uberPackagerConf.moduleDependencyPath());
-
- try(var writer = Files.newBufferedWriter(uberExplodedPath.resolve("modules.txt"))) {
- writer.write("com.github.forax.pro.main/com.github.forax.pro.main.Main");
- writer.newLine();
- //writer.write(uberbooterModule);
- //writer.newLine();
- for(var modulePath: modulePaths) {
- try(var modularJars = Files.list(modulePath)) {
- for(var modularJar: (Iterable)modularJars::iterator){
- //System.out.println("modularJar " + modularJar);
- writer.write(modularJar.getFileName().toString());
- writer.newLine();
- }
- }
- }
- }
-
- var uberjar = uberPackagerConf.moduleUberPath().resolve("uber.jar");
- var cmdLine = new CmdLine().addAll(
- "--create",
- "--file", uberjar.toString(),
- "--main-class", mainClass.getName(),
- "-C", uberExplodedPath.toString(),
- "."
- );
- var arguments = cmdLine.toArguments();
- log.verbose(arguments, args -> "jar " + String.join(" ", args));
- jarTool.run(System.out, System.err, arguments);
-
- for(var modulePath: modulePaths) {
- cmdLine = new CmdLine().addAll(
- "--update",
- "--file", uberjar.toString(),
- "-C", modulePath.toString(),
- "."
- );
- arguments = cmdLine.toArguments();
- log.verbose(arguments, args -> "jar " + String.join(" ", args));
- jarTool.run(System.out, System.err, arguments);
- }
-
- return 0;
- }
-}
diff --git a/src/main/java/com.github.forax.pro.plugin.uberpackager/module-info.java b/src/main/java/com.github.forax.pro.plugin.uberpackager/module-info.java
deleted file mode 100644
index 92a9299..0000000
--- a/src/main/java/com.github.forax.pro.plugin.uberpackager/module-info.java
+++ /dev/null
@@ -1,11 +0,0 @@
-module com.github.forax.pro.plugin.uberpackager {
- requires com.github.forax.pro.api;
- requires com.github.forax.pro.helper;
-
- requires com.github.forax.pro.ubermain;
-
- opens com.github.forax.pro.plugin.uberpackager;
-
- provides com.github.forax.pro.api.Plugin
- with com.github.forax.pro.plugin.uberpackager.UberPackagerPlugin;
-}
\ No newline at end of file
diff --git a/src/main/java/com.github.forax.pro.uberbooter/com/github/forax/pro/uberbooter/Booter.java b/src/main/java/com.github.forax.pro.uberbooter/com/github/forax/pro/uberbooter/Booter.java
deleted file mode 100644
index 1632c1d..0000000
--- a/src/main/java/com.github.forax.pro.uberbooter/com/github/forax/pro/uberbooter/Booter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.github.forax.pro.uberbooter;
-
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.Set;
-
-public class Booter {
- private static final StackWalker STACK_WALKER = StackWalker.getInstance(Set.of(StackWalker.Option.RETAIN_CLASS_REFERENCE));
-
- public static void main(Class> mainClass, String[] args) throws NoSuchMethodException, IllegalAccessException {
- if (!STACK_WALKER.getCallerClass().getName().equals("com.github.forax.pro.ubermain.Main")) {
- throw new SecurityException("caller is not permitted to call this method");
- }
-
- var lookup = MethodHandles.lookup();
- try {
- Booter.class.getModule().addReads(mainClass.getModule());
- var mh = lookup.findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class));
- mh.invokeExact(args);
- } catch(NoSuchMethodException | IllegalAccessException e) {
- throw e;
- } catch(RuntimeException | Error e) {
- throw e;
- } catch (Throwable e) {
- throw new UndeclaredThrowableException(e);
- }
- }
-}
diff --git a/src/main/java/com.github.forax.pro.uberbooter/module-info.java b/src/main/java/com.github.forax.pro.uberbooter/module-info.java
deleted file mode 100644
index 45fbee1..0000000
--- a/src/main/java/com.github.forax.pro.uberbooter/module-info.java
+++ /dev/null
@@ -1,3 +0,0 @@
-module com.github.forax.pro.uberbooter {
- exports com.github.forax.pro.uberbooter;
-}
\ No newline at end of file
diff --git a/src/main/java/com.github.forax.pro.ubermain/com/github/forax/pro/ubermain/Main.java b/src/main/java/com.github.forax.pro.ubermain/com/github/forax/pro/ubermain/Main.java
deleted file mode 100644
index 480c936..0000000
--- a/src/main/java/com.github.forax.pro.ubermain/com/github/forax/pro/ubermain/Main.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package com.github.forax.pro.ubermain;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleDescriptor.Exports;
-import java.lang.module.ModuleDescriptor.Modifier;
-import java.lang.module.ModuleDescriptor.Opens;
-import java.lang.module.ModuleFinder;
-import java.lang.module.ModuleReader;
-import java.lang.module.ModuleReference;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-public class Main {
- private static URI baseURI(URI uri) {
- var uriName = uri.toString();
- var index = uriName.indexOf('!');
- return URI.create(uriName.substring(0, index));
- }
-
- static String packageOf(String className) {
- var index = className.lastIndexOf('.');
- return className.substring(0, index);
- }
-
- public static void main(String[] args) throws IOException, URISyntaxException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException {
- List lines;
- try(var input = Main.class.getResourceAsStream("/modules.txt");
- var reader = new InputStreamReader(input);
- var bufferedReader = new BufferedReader(reader);
- var stream = bufferedReader.lines()) {
- lines = stream.collect(Collectors.toList());
- }
-
- var tokens = lines.get(0).split("/");
- var mainModule = tokens[0];
- var mainClassName = tokens[1];
- var moduleFileNames = lines.subList(1, lines.size());
-
- //System.out.println(moduleFileNames);
- var firstFileName = moduleFileNames.get(0);
- var baseURI = baseURI(Main.class.getResource("/" + firstFileName).toURI());
-
- System.out.println(baseURI);
-
- // uncompress into a temporary directory
- var tmp = Files.createTempDirectory("uberjar");
- try(var zipfs = FileSystems.newFileSystem(baseURI, Map.of())) {
- for(var moduleFileName: moduleFileNames) {
- var modulePath = zipfs.getPath("/" + moduleFileName);
- Files.copy(modulePath, tmp.resolve(modulePath.getFileName().toString()));
- }
- }
-
- var finder = ModuleFinder.of(tmp);
- //System.out.println(finder.findAll().stream().map(ref -> ref.descriptor().name()).collect(Collectors.toList()));
-
- var patchedFinder = new ModuleFinder() {
- private ModuleReference main;
-
- @Override
- public Set findAll() {
- return finder.findAll().stream().map(ref -> find(ref.descriptor().name()).get()).collect(Collectors.toSet());
- }
-
- @Override
- public Optional find(String name) {
- var moduleOpt = finder.find(name);
- if (!moduleOpt.isPresent() || !name.equals(mainModule)) {
- return moduleOpt;
- }
- if (main == null) {
- var ref = moduleOpt.get();
- var descriptor = ref.descriptor();
-
- var modifiers = descriptor.isOpen()? Set.of(Modifier.OPEN):
- descriptor.isAutomatic()? Set.of(Modifier.AUTOMATIC): Set.of();
- var builder = ModuleDescriptor.newModule(name, modifiers);
- descriptor.version().ifPresent(builder::version);
-
- descriptor.requires().forEach(builder::requires);
- descriptor.exports().forEach(builder::exports);
- builder.exports(packageOf(mainClassName), Set.of("com.github.forax.pro.uberbooter")); // patch !
- descriptor.opens().forEach(builder::opens);
-
- descriptor.uses().forEach(builder::uses);
- descriptor.provides().forEach(builder::provides);
-
- var packages = new HashSet<>(descriptor.packages());
- packages.removeAll(descriptor.exports().stream().map(Exports::source).collect(Collectors.toSet()));
- packages.removeAll(descriptor.opens().stream().map(Opens::source).collect(Collectors.toSet()));
- packages.remove(packageOf(mainClassName));
- builder.packages(packages);
-
- main = new ModuleReference(builder.build(), ref.location().get()) {
- @Override
- public ModuleReader open() throws IOException {
- return ref.open();
- }
- };
- }
- return Optional.of(main);
- }
- };
-
- var parent = ModuleLayer.boot();
- var configuration = parent.configuration().resolveAndBind(patchedFinder, ModuleFinder.of(), List.of("com.github.forax.pro.uberbooter", mainModule));
- var layer = ModuleLayer.defineModulesWithOneLoader(configuration, List.of(parent), ClassLoader.getSystemClassLoader()).layer();
-
- var loader = layer.findLoader("com.github.forax.pro.uberbooter");
- var booterClass = loader.loadClass("com.github.forax.pro.uberbooter.Booter");
-
- var mainLoader = layer.findLoader(mainModule);
- var mainClass = mainLoader.loadClass(mainClassName);
-
- var lookup = MethodHandles.lookup();
- try {
- var mh = lookup.findStatic(booterClass, "main", MethodType.methodType(void.class, Class.class, String[].class));
- mh.invokeExact(mainClass, args);
- } catch (NoSuchMethodException | IllegalAccessException e) {
- throw e;
- } catch (RuntimeException | Error e) {
- throw e;
- } catch (Throwable e) {
- throw new UndeclaredThrowableException(e);
- }
- }
-}
diff --git a/src/main/java/com.github.forax.pro.ubermain/module-info.java b/src/main/java/com.github.forax.pro.ubermain/module-info.java
deleted file mode 100644
index 7d10ee0..0000000
--- a/src/main/java/com.github.forax.pro.ubermain/module-info.java
+++ /dev/null
@@ -1,3 +0,0 @@
-module com.github.forax.pro.ubermain {
- exports com.github.forax.pro.ubermain to com.github.forax.pro.plugin.uberpackager;
-}
\ No newline at end of file