From 6cc5b8599410be968a9b5abe94d65bbe78e5d91f Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Fri, 17 Mar 2023 05:25:35 +0100 Subject: [PATCH] Change SOURCE_BUNDLE environment property --- osgi.mk | 11 +++++++---- src/org/argeo/build/Make.java | 4 ++-- src/org/argeo/build/Repackage.java | 27 +++++++++++++++++++++------ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/osgi.mk b/osgi.mk index 12e34aa..44338e8 100644 --- a/osgi.mk +++ b/osgi.mk @@ -15,6 +15,10 @@ JAVADOC ?= $(JAVA_HOME)/bin/javadoc # BUNDLES the space-separated list of bundles to build # A2_CATEGORY the (single) a2 category the bundles will belong to +# The following environment variables can change the behaviour of the build +# SOURCE_BUNDLES sources will be packaged separately in Eclipse-compatible source bundles +# NO_MANIFEST_COPY generated MANIFESTs won't be copied to the source tree + # The following variables have default values which can be overriden # DEP_CATEGORIES the a2 categories the compilation depends on # JAVADOC_PACKAGES the space-separated list of packages for which javadoc will be generated @@ -41,9 +45,6 @@ TODOS = $(foreach bundle, $(BUNDLES),$(BUILD_BASE)/$(bundle)/to-build) .PHONY: osgi manifests javadoc osgi: $(BUILD_BASE)/built $(MANIFESTS) -# copy MANIFESTs to sources -# @mkdir -p $(foreach bundle, $(BUNDLES), $(bundle)/META-INF/); -# @$(foreach bundle, $(BUNDLES), cp -v $(BUILD_BASE)/$(bundle)/META-INF/MANIFEST.MF $(bundle)/META-INF/MANIFEST.MF;) # Actual build (compilation + bundle packaging) $(BUILD_BASE)/built : BUNDLES_TO_BUILD = $(subst $(abspath $(BUILD_BASE))/,, $(subst to-build,, $?)) @@ -65,8 +66,10 @@ $(BUILD_BASE)/%/to-build : $$(shell find % -type f -not -path 'bin/*' -not -path # Local manifests %/META-INF/MANIFEST.MF : $(BUILD_BASE)/%/META-INF/MANIFEST.MF - @mkdir -p $* +ifneq($(NO_MANIFEST_COPY),"true") + @mkdir -p $*/META-INF @cp $< $@ +endif clean-manifests : @rm -rf $(foreach bundle, $(BUNDLES), $(bundle)/META-INF/MANIFEST.MF); diff --git a/src/org/argeo/build/Make.java b/src/org/argeo/build/Make.java index 7ad6e31..fa903c3 100644 --- a/src/org/argeo/build/Make.java +++ b/src/org/argeo/build/Make.java @@ -55,7 +55,7 @@ public class Make { * Environment properties on whether sources should be packaged separately or * integrated in the bundles. */ - private final static String ENV_BUILD_SOURCE_BUNDLES = "BUILD_SOURCE_BUNDLES"; + private final static String ENV_SOURCE_BUNDLES = "SOURCE_BUNDLES"; /** Name of the local-specific Makefile (sdk.mk). */ final static String SDK_MK = "sdk.mk"; @@ -85,7 +85,7 @@ public class Make { /** Constructor initialises the base directories. */ public Make() throws IOException { - sourceBundles = Boolean.parseBoolean(System.getenv(ENV_BUILD_SOURCE_BUNDLES)); + sourceBundles = Boolean.parseBoolean(System.getenv(ENV_SOURCE_BUNDLES)); if (sourceBundles) logger.log(Level.INFO, "Sources will be packaged separately"); diff --git a/src/org/argeo/build/Repackage.java b/src/org/argeo/build/Repackage.java index 54863af..1d280e6 100644 --- a/src/org/argeo/build/Repackage.java +++ b/src/org/argeo/build/Repackage.java @@ -51,12 +51,20 @@ import java.util.zip.Deflater; import aQute.bnd.osgi.Analyzer; import aQute.bnd.osgi.Jar; -/** The central class for A2 packaging. */ +/** + * Simple tool repackaging existing jar files into OSGi bundles in an A2 + * repository. + */ public class Repackage { private final static Logger logger = System.getLogger(Repackage.class.getName()); - private final static String ENV_BUILD_SOURCE_BUNDLES = "BUILD_SOURCE_BUNDLES"; + /** + * Environment properties on whether sources should be packaged separately or + * integrated in the bundles. + */ + private final static String ENV_SOURCE_BUNDLES = "SOURCE_BUNDLES"; + /** Whethere repackaging should run in parallel or sequentially. */ private final static boolean parallel = true; /** Main entry point. */ @@ -83,23 +91,30 @@ public class Repackage { private final static String COMMON_BND = "common.bnd"; private final static String MERGE_BND = "merge.bnd"; + /** Directory where to download archives */ private Path originBase; + /** Directory where to download Maven artifacts */ private Path mavenBase; + /** A2 repository base for binary bundles */ private Path a2Base; + /** A2 repository base for source bundles */ private Path a2SrcBase; + /** A2 base for native components */ private Path a2LibBase; + /** Location of the descriptors driving the packaging */ private Path descriptorsBase; - + /** URIs of archives to download */ private Properties uris = new Properties(); - - /** key is URI prefix, value list of base URLs */ + /** Mirrors for archive download. Key is URI prefix, value list of base URLs */ private Map> mirrors = new HashMap>(); + /** Whether sources should be packaged separately */ private final boolean sourceBundles; + /** Constructor initialises the various variables */ public Repackage(Path a2Base, Path descriptorsBase) { - sourceBundles = Boolean.parseBoolean(System.getenv(ENV_BUILD_SOURCE_BUNDLES)); + sourceBundles = Boolean.parseBoolean(System.getenv(ENV_SOURCE_BUNDLES)); if (sourceBundles) logger.log(INFO, "Sources will be packaged separately"); -- 2.30.2