Improve overriding A2 modules
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 17 Dec 2023 14:09:55 +0000 (15:09 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 17 Dec 2023 14:09:55 +0000 (15:09 +0100)
org.argeo.init/src/org/argeo/init/a2/FsA2Source.java
org.argeo.init/src/org/argeo/init/a2/ProvisioningManager.java

index 151b0023f56a2fc9d052dee6c31f1924e0609f52..921992da3371f0e12af8175b1d2f8911c5d46075 100644 (file)
@@ -61,9 +61,9 @@ public class FsA2Source extends AbstractProvisioningSource implements A2Source {
                                        if (variantPath == null)
                                                continue contributions;
 
-                                       if (Files.exists(variantPath)) {
-                                               // a variant was found, let's collect its contributions (also common ones in its
-                                               // parent)
+                                       // a variant was found, let's collect its contributions (also common ones in its
+                                       // parent)
+                                       if (Files.exists(variantPath.getParent())) {
                                                for (Path variantContributionPath : Files.newDirectoryStream(variantPath.getParent())) {
                                                        String variantContributionId = variantContributionPath.getFileName().toString();
                                                        if (variantContributionId.contains(".")) {
@@ -71,6 +71,8 @@ public class FsA2Source extends AbstractProvisioningSource implements A2Source {
                                                                contributions.put(variantContributionPath, contribution);
                                                        }
                                                }
+                                       }
+                                       if (Files.exists(variantPath)) {
                                                for (Path variantContributionPath : Files.newDirectoryStream(variantPath)) {
                                                        String variantContributionId = variantContributionPath.getFileName().toString();
                                                        if (variantContributionId.contains(".")) {
index 92df47ea8f744e6d587a21c7baf91db2ea067377..289870abc3ef945b7a2bb5f9b122027beb1af6cd 100644 (file)
@@ -158,8 +158,10 @@ public class ProvisioningManager {
                        } else {
                                A2Module lastOsgiModule = osgiBranch.last();
                                int compare = moduleVersion.compareTo(lastOsgiModule.getVersion());
-                               if (compare > 0) {// update
+                               if (compare >= 0) {// update (also if same version)
                                        Bundle bundle = (Bundle) lastOsgiModule.getLocator();
+                                       if (bundle.getBundleId() == 0)// ignore framework bundle
+                                               return null;
                                        moduleSource.update(bundle, module);
                                        // TODO make it more dynamic, based on OSGi APIs
                                        // TODO remove old module? Or keep update history?