1818import java .util .Map ;
1919import java .util .stream .Collectors ;
2020
21+ import org .apache .commons .io .FilenameUtils ;
2122import org .apache .commons .lang3 .StringUtils ;
2223import org .apache .commons .lang3 .SystemUtils ;
2324import org .apache .maven .execution .MavenSession ;
@@ -628,24 +629,6 @@ private void createCustomizedJre(File jreFolder, File libsFolder) throws MojoExe
628629
629630 String modules = getRequiredModules (libsFolder );
630631
631- // warn and generate a non optimized JRE
632- // if (JavaUtils.getJavaMajorVersion() < 12 && !forceJreOptimization) {
633- //
634- // getLog().warn("We need JDK 12+ for correctly determining the dependencies. You run " + System.getProperty("java.home"));
635- // getLog().warn("All modules will be included in the generated JRE.");
636- //
637- // modules = "ALL-MODULE-PATH";
638- //
639- // } else { // generate an optimized JRE, including only required modules
640- //
641- // if (forceJreOptimization) {
642- // getLog().warn("JRE optimization has been forced. It can cause issues with some JDKs.");
643- // }
644- //
645- // modules = getRequiredModules(libsFolder);
646- //
647- // }
648-
649632 File modulesDir = new File (System .getProperty ("java.home" ), "jmods" );
650633
651634 File jlink = new File (System .getProperty ("java.home" ), "/bin/jlink" );
@@ -660,6 +643,19 @@ private void createCustomizedJre(File jreFolder, File libsFolder) throws MojoExe
660643 Arrays .asList (binFolder .listFiles ()).forEach (f -> f .setExecutable (true , false ));
661644
662645 }
646+
647+ // rename all folders into jre/legal (needed to codesign command not to fail on macos), replacing "." (dots) with "_" (underscores)
648+ File legalFolder = new File (jreFolder , "legal" );
649+ if (legalFolder .exists ()) {
650+ Arrays .asList (legalFolder .listFiles ())
651+ .stream ()
652+ .forEach (d -> {
653+ File newname = new File (d .getParentFile (), d .getName ().replaceAll ("\\ ." , "_" ));
654+ System .out .println ("renombrando " + d .getName () + " por " + newname .getName ());
655+ d .renameTo (newname );
656+ }
657+ );
658+ }
663659
664660 }
665661
0 commit comments