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 2020/09/24 08:45:24 UTC

[karaf] branch master updated: ensure maven plugin brings back an up to date javax.annotation dep + fixing tests

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 75eca9f  ensure maven plugin brings back an up to date javax.annotation dep + fixing tests
     new d6c3e62  Merge pull request #1199 from rmannibucau/rmannibucau/fixing-maven-plugin-tests-and-fixing-javaxannotation-dep
75eca9f is described below

commit 75eca9f6d6ebd379cc1a758d5fc053d9a2df986b
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Wed Sep 23 11:08:32 2020 +0200

    ensure maven plugin brings back an up to date javax.annotation dep + fixing tests
---
 tooling/karaf-maven-plugin/pom.xml                           | 12 +++++++++++-
 .../src/main/java/org/apache/karaf/tooling/RunMojo.java      |  6 ++++++
 .../src/test/java/org/apache/karaf/tooling/RunMojoTest.java  |  8 +++++---
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/tooling/karaf-maven-plugin/pom.xml b/tooling/karaf-maven-plugin/pom.xml
index 4b07966..bbc3865 100644
--- a/tooling/karaf-maven-plugin/pom.xml
+++ b/tooling/karaf-maven-plugin/pom.xml
@@ -43,10 +43,20 @@
     </properties>
 
     <dependencies>
-
+        <dependency>
+            <groupId>javax.annotation</groupId>
+            <artifactId>javax.annotation-api</artifactId>
+            <version>${javax.annotation.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.apache.maven</groupId>
             <artifactId>maven-plugin-api</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.annotation</groupId>
+                    <artifactId>jsr250-api</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.maven.resolver</groupId>
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java
index 8aa6ba0..60714b5 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java
@@ -142,6 +142,9 @@ public class RunMojo extends MojoSupport {
     @Parameter(defaultValue = "180000")
     private long maximumStartupDuration;
 
+    @Parameter
+    private List<String> forbiddenDelegationPackages;
+
     private static final Pattern mvnPattern = Pattern.compile("mvn:([^/ ]+)/([^/ ]+)/([^/ ]*)(/([^/ ]+)(/([^/ ]+))?)?");
 
     public void execute() throws MojoExecutionException, MojoFailureException {
@@ -194,6 +197,9 @@ public class RunMojo extends MojoSupport {
                     throw new ClassNotFoundException(
                             "avoid to use the classrealm loader which will prevent felix to match its reference");
                 }
+                if (name != null && forbiddenDelegationPackages != null && forbiddenDelegationPackages.stream().anyMatch(name::startsWith)) {
+                    throw new ClassNotFoundException(name);
+                }
                 return super.loadClass(name, resolve);
             }
         };
diff --git a/tooling/karaf-maven-plugin/src/test/java/org/apache/karaf/tooling/RunMojoTest.java b/tooling/karaf-maven-plugin/src/test/java/org/apache/karaf/tooling/RunMojoTest.java
index 6b8b9c2..aff1a4c 100644
--- a/tooling/karaf-maven-plugin/src/test/java/org/apache/karaf/tooling/RunMojoTest.java
+++ b/tooling/karaf-maven-plugin/src/test/java/org/apache/karaf/tooling/RunMojoTest.java
@@ -167,7 +167,7 @@ public class RunMojoTest extends EasyMockSupport {
             mojo.deploy(context, null);
             fail("Expected MojoExecutionException");
         } catch (MojoExecutionException e) {
-            assertEquals("Project artifact doesn't exist", e.getMessage());
+            assertEquals("No artifact to deploy", e.getMessage());
         }
     }
 
@@ -188,7 +188,7 @@ public class RunMojoTest extends EasyMockSupport {
             mojo.deploy(context, null);
             fail("Expected MojoExecutionException");
         } catch (MojoExecutionException e) {
-            assertEquals("Project artifact doesn't exist", e.getMessage());
+            assertEquals("No artifact to deploy", e.getMessage());
         }
     }
 
@@ -198,6 +198,8 @@ public class RunMojoTest extends EasyMockSupport {
         Artifact artifact = mock(Artifact.class);
         File artifactFile = mock(File.class);
         expect(artifactFile.exists()).andReturn(true).times(2);
+        expect(artifactFile.getAbsolutePath()).andReturn("foo.jar").times(1);
+        expect(artifactFile.toURI()).andReturn(URI.create("file:///foo.jar")).times(1);
         replay(artifactFile);
         expect(artifact.getFile()).andReturn(artifactFile);
         replay(artifact);
@@ -209,7 +211,7 @@ public class RunMojoTest extends EasyMockSupport {
             mojo.deploy(context, null);
             fail("Expected MojoExecutionException");
         } catch (MojoExecutionException e) {
-            assertEquals("Packaging jar is not supported", e.getMessage());
+            assertEquals("Can't deploy project artifact in container", e.getMessage());
         }
     }