From dd7d34930a31c4b72a4f397a9bcb6a3468af6c52 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Tue, 21 Mar 2023 10:55:48 +0100 Subject: [PATCH] Environment variable to disable inclusion of SDK legal files. --- src/org/argeo/build/Make.java | 47 +++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/org/argeo/build/Make.java b/src/org/argeo/build/Make.java index 324cae8..5a5fd64 100644 --- a/src/org/argeo/build/Make.java +++ b/src/org/argeo/build/Make.java @@ -62,6 +62,14 @@ public class Make { */ private final static String ENV_SOURCE_BUNDLES = "SOURCE_BUNDLES"; + /** + * Environment variable on whether legal files at the root of the sources should + * be included in the generated bundles. Should be set to true when building + * third-party software in order no to include the build harness license into + * the generated bundles. + */ + private final static String ENV_NO_SDK_LEGAL = "NO_SDK_LEGAL"; + /** * Environment variable to override the default location for the Argeo Build * configuration files. Typically used if Argeo Build has been compiled and @@ -79,7 +87,7 @@ public class Make { /** Base of the source code, typically the cloned git repository. */ final Path sdkSrcBase; /** - * The base of the builder, typically a submodule pointing to the public + * The base of the builder, typically a submodule pointing to the INCLUDEpublic * argeo-build directory. */ final Path argeoBuildBase; @@ -92,14 +100,19 @@ public class Make { /** The base of the a2 sources when packages separately. */ final Path a2srcOutput; - /** Whether sources should be packaged separately */ + /** Whether sources should be packaged separately. */ final boolean sourceBundles; + /** Whether common legal files should be included. */ + final boolean noSdkLegal; /** Constructor initialises the base directories. */ public Make() throws IOException { sourceBundles = Boolean.parseBoolean(System.getenv(ENV_SOURCE_BUNDLES)); if (sourceBundles) logger.log(Level.INFO, "Sources will be packaged separately"); + noSdkLegal = Boolean.parseBoolean(System.getenv(ENV_NO_SDK_LEGAL)); + if (noSdkLegal) + logger.log(Level.INFO, "SDK legal files will NOT be included"); execDirectory = Paths.get(System.getProperty("user.dir")); Path sdkMkP = findSdkMk(execDirectory); @@ -447,20 +460,22 @@ 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); + if (!noSdkLegal) { + 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) { -- 2.30.2