You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2021/06/30 04:19:06 UTC

[karaf] branch main updated: [KARAF-7186] Optionally avoid to fail the verify goal on bundle uninstall/update

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/main by this push:
     new cc21884  [KARAF-7186] Optionally avoid to fail the verify goal on bundle uninstall/update
     new 13d139a  Merge pull request #1394 from mrulli/KARAF-7186
cc21884 is described below

commit cc21884616bd1b9c3c296d107601f3bbffc3dc36
Author: Matteo Rulli <ma...@flairbit.io>
AuthorDate: Wed Jun 23 14:46:22 2021 +0200

    [KARAF-7186] Optionally avoid to fail the verify goal on bundle uninstall/update
---
 .../features/internal/service/StaticInstallSupport.java    | 11 +++++++++--
 .../src/main/java/org/apache/karaf/tooling/VerifyMojo.java | 14 ++++++++++++--
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/StaticInstallSupport.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/StaticInstallSupport.java
index a87e029..54607d26 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/StaticInstallSupport.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/StaticInstallSupport.java
@@ -32,6 +32,9 @@ import org.osgi.resource.Wire;
 
 public abstract class StaticInstallSupport implements BundleInstallSupport {
 
+    protected boolean failOnUninstall = true;
+    protected boolean failOnUpdate = true;
+
     @Override
     public void print(String message, boolean verbose) {
     }
@@ -43,13 +46,17 @@ public abstract class StaticInstallSupport implements BundleInstallSupport {
     @Override
     public void updateBundle(Bundle bundle, String uri, InputStream is) throws BundleException {
         System.err.println("Update bundle is not supported in the static installer");
-        throw new UnsupportedOperationException();
+        if (failOnUpdate) {
+            throw new UnsupportedOperationException();
+        }
     }
 
     @Override
     public void uninstall(Bundle bundle) throws BundleException {
         System.err.println("Uninstall bundle is not supported in the static installer");
-        throw new UnsupportedOperationException();
+        if (failOnUninstall) {
+            throw new UnsupportedOperationException();
+        }
     }
 
     @Override
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
index 8c3d3d8..93ea068 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
@@ -122,6 +122,12 @@ public class VerifyMojo extends MojoSupport {
     @Parameter(property = "featureProcessingInstructions")
     protected File featureProcessingInstructions;
 
+    @Parameter(property = "failOnUninstall")
+    protected boolean failOnUninstall = true;
+
+    @Parameter(property = "failOnUpdate")
+    protected boolean failOnUpdate = true;
+
     @Parameter(property = "features")
     protected List<String> features;
 
@@ -446,7 +452,7 @@ public class VerifyMojo extends MojoSupport {
     private void verifyResolution(DownloadManager manager, final Map<String, Features> repositories, Set<String> features, Hashtable<String, String> properties) throws MojoExecutionException {
         try {
             Bundle systemBundle = getSystemBundle(getMetadata(properties, "metadata#"));
-            DummyDeployCallback callback = new DummyDeployCallback(systemBundle, repositories.values());
+            DummyDeployCallback callback = new DummyDeployCallback(systemBundle, repositories.values(), failOnUpdate, failOnUninstall);
             Deployer deployer = new Deployer(manager, new ResolverImpl(new MavenResolverLog()), callback);
 
 
@@ -790,7 +796,11 @@ public class VerifyMojo extends MojoSupport {
         private final Deployer.DeploymentState dstate;
         private final AtomicLong nextBundleId = new AtomicLong(0);
 
-        public DummyDeployCallback(Bundle sysBundle, Collection<Features> repositories) {
+        public DummyDeployCallback(Bundle sysBundle, Collection<Features> repositories, boolean failOnUpdate, boolean failOnUninstall) {
+
+            super.failOnUpdate = failOnUpdate;
+            super.failOnUninstall = failOnUninstall;
+
             systemBundle = sysBundle;
             dstate = new Deployer.DeploymentState();
             dstate.bundles = new HashMap<>();