X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=src%2Forg%2Fargeo%2Fbuild%2FMake.java;h=324cae8ab89725ef22d86d545b67a40a70e2dcf2;hb=06c0c3c415124e6219b1c0192fc79f9692103e22;hp=78310597c15a4982f03dccbaa2b2ecf35965adb2;hpb=1d38b1c8155f35271cf20217167eb6901df25272;p=cc0%2Fargeo-build.git diff --git a/src/org/argeo/build/Make.java b/src/org/argeo/build/Make.java index 7831059..324cae8 100644 --- a/src/org/argeo/build/Make.java +++ b/src/org/argeo/build/Make.java @@ -13,6 +13,7 @@ import java.io.PrintWriter; import java.lang.System.Logger; import java.lang.System.Logger.Level; import java.lang.management.ManagementFactory; +import java.nio.file.DirectoryStream; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; @@ -140,7 +141,6 @@ public class Make { } /** Compile all the bundles which have been passed via the --bundle argument. */ - @SuppressWarnings("restriction") void compile(Map> options) throws IOException { List bundles = options.get("--bundles"); Objects.requireNonNull(bundles, "--bundles argument must be set"); @@ -407,6 +407,12 @@ public class Make { } }); + // add legal notices and licenses + for (Path p : listLegalFilesToInclude(source).values()) { + jarOut.putNextEntry(new JarEntry(p.getFileName().toString())); + Files.copy(p, jarOut); + } + // add sources // TODO add effective BND, Eclipse project file, etc., in order to be able to // repackage @@ -426,6 +432,11 @@ public class Make { try (JarOutputStream srcJarOut = new JarOutputStream(Files.newOutputStream(srcJarP), srcManifest)) { copySourcesToJar(srcP, srcJarOut, ""); + // add legal notices and licenses + for (Path p : listLegalFilesToInclude(source).values()) { + jarOut.putNextEntry(new JarEntry(p.getFileName().toString())); + Files.copy(p, jarOut); + } } } else { copySourcesToJar(srcP, jarOut, "OSGI-OPT/src/"); @@ -433,6 +444,41 @@ public class Make { } } + /** List the relevant legal files to include, from the SDK source base. */ + Map listLegalFilesToInclude(Path bundleBase) throws IOException { + Map toInclude = new HashMap<>(); + DirectoryStream sdkSrcLegal = Files.newDirectoryStream(sdkSrcBase, (p) -> { + String fileName = p.getFileName().toString(); + return switch (fileName) { + case "NOTICE": + case "LICENSE": + case "COPYING": + case "COPYING.LESSER": + yield true; + default: + yield false; + }; + }); + for (Path p : sdkSrcLegal) + toInclude.put(p.getFileName().toString(), p); + DirectoryStream bundleLegal = Files.newDirectoryStream(bundleBase, (p) -> { + String fileName = p.getFileName().toString(); + return switch (fileName) { + case "NOTICE": + case "LICENSE": + case "COPYING": + case "COPYING.LESSER": + yield true; + default: + yield false; + }; + }); + // bundle can override + for (Path p : bundleLegal) + toInclude.put(p.getFileName().toString(), p); + return toInclude; + } + /* * UTILITIES */