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:38 UTC

[karaf] branch karaf-4.2.x 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 karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
     new 09ab3f0  [KARAF-7186] Optionally avoid to fail the verify goal on bundle uninstall/update
09ab3f0 is described below

commit 09ab3f0729021973015de3c44b627629b7e91b3a
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
    
    (cherry picked from commit cc21884616bd1b9c3c296d107601f3bbffc3dc36)
---
 .../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 fecdd27..1ca7107 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
@@ -127,6 +127,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;
 
@@ -451,7 +457,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);
 
 
@@ -792,7 +798,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<>();