Simplify build configuration and support branches
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 15 Oct 2022 10:07:03 +0000 (12:07 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 15 Oct 2022 10:07:03 +0000 (12:07 +0200)
argeo.bnd
configure
osgi.mk
src/org/argeo/build/Make.java

index 871c5886adc4fb16d46b6974f6f345f17abc42bf..9ab4015cd38bab02a243b3a5e1de50e227e49c39 100644 (file)
--- a/argeo.bnd
+++ b/argeo.bnd
@@ -1,16 +1,8 @@
-# Common
-Bundle-Version: ${MAJOR}.${MINOR}.${MICRO}${qualifier}
-Private-Package: *.internal.*, config.*
-Export-Package: !*.internal.*, !config.*, *
+Bundle-Version: ${major}.${minor}.${micro}${qualifier}
+Export-Package: !*.internal.*, !config.*, !icons.*, !css.*, !swt.*, !rap.*, *
 Bundle-RequiredExecutionEnvironment=JavaSE-17
 
 #-consumer-policy : ${range;[==,=+)}
 -contract: !JavaServlet,*
--savemanifest : META-INF/MANIFEST.MF
--includeresource.default : bin,OSGI-INF/=-OSGI-INF/,e4xmi/=-e4xmi/,icons/=-icons/,img/=-img/
--compression STORE
--source true
 -removeheaders = Bnd-LastModified,Build-Jdk,Built-By,Tool,Created-By
-Automatic-Module-Name: ${bsn}
-SLC-Category=${category}
--groupid=${category}
+Automatic-Module-Name: ${bsn}
\ No newline at end of file
index c9af7a5b8d3035c237a67aa8885e737fbf320157..4adf1c0cb842d5e3049bef17f6d7e07cea75b58a 100755 (executable)
--- a/configure
+++ b/configure
@@ -36,6 +36,7 @@ SDK_BUILD_BASE := $SDK_BUILD_BASE
 JAVA_HOME := $JAVA_HOME
 
 include \$(SDK_SRC_BASE)/branch.mk
+include $(SDK_SRC_BASE)/sdk/branches/$(BRANCH).bnd
 EOF
 
 
diff --git a/osgi.mk b/osgi.mk
index 733f20e3e9a0743c0d75f74da931806c5fdd9813..bbd54693c2c7fa9b9797b8200151eaa4ae01f0d9 100644 (file)
--- a/osgi.mk
+++ b/osgi.mk
@@ -31,7 +31,7 @@ JAVADOC_SRCS = $(foreach bundle, $(BUNDLES), $(bundle)/src)
 
 BUILD_BASE = $(SDK_BUILD_BASE)/$(shell basename $(SDK_SRC_BASE))
 
-TARGET_BUNDLES =  $(abspath $(foreach bundle, $(BUNDLES),$(A2_OUTPUT)/$(shell dirname $(bundle))/$(A2_CATEGORY)/$(shell basename $(bundle)).$(MAJOR).$(MINOR).jar))
+TARGET_BUNDLES =  $(abspath $(foreach bundle, $(BUNDLES),$(A2_OUTPUT)/$(shell dirname $(bundle))/$(A2_CATEGORY)/$(shell basename $(bundle)).$(major).$(minor).jar))
 TODOS = $(foreach bundle, $(BUNDLES),$(BUILD_BASE)/$(bundle)/to-build) 
 
 ## Needed in order to be able to expand $$ variables
@@ -46,11 +46,11 @@ javadoc: $(BUILD_BASE)/built
 # Actual build (compilation + bundle packaging)
 $(BUILD_BASE)/built : BUNDLES_TO_BUILD = $(subst $(abspath $(BUILD_BASE))/,, $(subst to-build,, $?))
 $(BUILD_BASE)/built : $(TODOS)
-       $(ARGEO_MAKE) all --a2-bases $(A2_BASE) --dep-categories $(DEP_CATEGORIES) --category $(A2_CATEGORY) --bundles $(BUNDLES_TO_BUILD)
+       $(ARGEO_MAKE) all --branch $(BRANCH) --a2-bases $(A2_BASE) --dep-categories $(DEP_CATEGORIES) --category $(A2_CATEGORY) --bundles $(BUNDLES_TO_BUILD)
        touch $(BUILD_BASE)/built 
 
-$(A2_OUTPUT)/%.$(MAJOR).$(MINOR).jar : $(BUILD_BASE)/$$(subst $(A2_CATEGORY)/,,$$*)/to-build
-       $(ARGEO_MAKE) all --a2-bases $(A2_BASE) --dep-categories $(DEP_CATEGORIES) --category $(A2_CATEGORY) --bundles $(subst $(A2_CATEGORY)/,,$*)
+$(A2_OUTPUT)/%.$(major).$(minor).jar : $(BUILD_BASE)/$$(subst $(A2_CATEGORY)/,,$$*)/to-build
+       $(ARGEO_MAKE) all --branch $(BRANCH) --a2-bases $(A2_BASE) --dep-categories $(DEP_CATEGORIES) --category $(A2_CATEGORY) --bundles $(subst $(A2_CATEGORY)/,,$*)
 
 $(BUILD_BASE)/%/to-build : $$(shell find $(SDK_SRC_BASE)/% -type f -not -path 'bin/*' -not -path '*/MANIFEST.MF')
        @rm -rf $(dir $@)
index 115a91b7d349b849a69a8d7fa1b2dc573a6d3a4d..90e97961bf848e3d98065bbd3ebfeb329604febb 100644 (file)
@@ -176,18 +176,23 @@ public class Make {
                        return;
 
                List<String> categories = options.get("--category");
-               Objects.requireNonNull(bundles, "--bundles argument must be set");
+               Objects.requireNonNull(bundles, "--category argument must be set");
                if (categories.size() != 1)
-                       throw new IllegalArgumentException("One and only one category must be specified");
+                       throw new IllegalArgumentException("One and only one --category must be specified");
                String category = categories.get(0);
 
+               List<String> branches = options.get("--branch");
+               if (branches.size() != 1)
+                       throw new IllegalArgumentException("One and only one --branch must be specified");
+               String branch = branches.get(0);
+
                long begin = System.currentTimeMillis();
                // create jars in parallel
                List<CompletableFuture<Void>> toDos = new ArrayList<>();
                for (String bundle : bundles) {
                        toDos.add(CompletableFuture.runAsync(() -> {
                                try {
-                                       createBundle(bundle, category);
+                                       createBundle(branch, bundle, category);
                                } catch (IOException e) {
                                        throw new RuntimeException("Packaging of " + bundle + " failed", e);
                                }
@@ -202,7 +207,7 @@ public class Make {
         * UTILITIES
         */
        /** Package a single bundle. */
-       void createBundle(String bundle, String category) throws IOException {
+       void createBundle(String branch, String bundle, String category) throws IOException {
                Path source = execDirectory.resolve(bundle);
                Path compiled = buildBase.resolve(bundle);
                String bundleSymbolicName = source.getFileName().toString();
@@ -213,8 +218,8 @@ public class Make {
                try (InputStream in = Files.newInputStream(argeoBnd)) {
                        properties.load(in);
                }
-               // FIXME make it configurable
-               Path branchBnd = sdkSrcBase.resolve("cnf/unstable.bnd");
+
+               Path branchBnd = sdkSrcBase.resolve("sdk/branches/" + branch + ".bnd");
                try (InputStream in = Files.newInputStream(branchBnd)) {
                        properties.load(in);
                }
@@ -241,10 +246,10 @@ public class Make {
                        throw new RuntimeException("Bnd analysis of " + compiled + " failed", e);
                }
 
-               String major = properties.getProperty("MAJOR");
-               Objects.requireNonNull(major, "MAJOR must be set");
-               String minor = properties.getProperty("MINOR");
-               Objects.requireNonNull(minor, "MINOR must be set");
+               String major = properties.getProperty("major");
+               Objects.requireNonNull(major, "'major' must be set");
+               String minor = properties.getProperty("minor");
+               Objects.requireNonNull(minor, "'minor' must be set");
 
                // Write manifest
                Path manifestP = compiled.resolve("META-INF/MANIFEST.MF");
@@ -370,9 +375,8 @@ public class Make {
                                        + (jvmUptime % 1000) + " s");
                } catch (Exception e) {
                        long jvmUptime = ManagementFactory.getRuntimeMXBean().getUptime();
-                       logger.log(ERROR,
-                                       "Make.java action '" + action + "' failed after " + (jvmUptime / 1000) + "." + (jvmUptime % 1000) + " s",
-                                       e);
+                       logger.log(ERROR, "Make.java action '" + action + "' failed after " + (jvmUptime / 1000) + "."
+                                       + (jvmUptime % 1000) + " s", e);
                        System.exit(1);
                }
        }