[GitHub] [karaf] jbonofre commented on a change in pull request #1201: add support of clean arg in main
jbonofre commented on a change in pull request #1201: URL: https://github.com/apache/karaf/pull/1201#discussion_r494776488 ## File path: main/src/main/java/org/apache/karaf/main/Main.java ## @@ -232,6 +239,29 @@ public void updateInstancePidAfterShutdown() throws Exception { } public void launch() throws Exception { +if (Arrays.asList(args).contains("clean")) { Review comment: It does already exist. You can start `bin/karaf` with `clean` option. That's in the `sh|bat` script. So your proposal is to remove from script to have it in `Main`, right ? In that case, we should also upgrade the scripts. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [karaf] rmannibucau opened a new pull request #1201: add support of clean arg in main
rmannibucau opened a new pull request #1201: URL: https://github.com/apache/karaf/pull/1201 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[BUILD-FAILURE]: Job 'Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [31]'
BUILD-FAILURE: Job 'Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [31]': Check console output at "https://ci-builds.apache.org/job/Karaf/job/karaf-runtime-jdk11/job/karaf-4.2.x/31/";>Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [31]"
[BUILD-FAILURE]: Job 'Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [30]'
BUILD-FAILURE: Job 'Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [30]': Check console output at "https://ci-builds.apache.org/job/Karaf/job/karaf-runtime-jdk11/job/karaf-4.2.x/30/";>Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [30]"
[BUILD-FAILURE]: Job 'Karaf/karaf-runtime-jdk11/master [master] [36]'
BUILD-FAILURE: Job 'Karaf/karaf-runtime-jdk11/master [master] [36]': Check console output at "https://ci-builds.apache.org/job/Karaf/job/karaf-runtime-jdk11/job/master/36/";>Karaf/karaf-runtime-jdk11/master [master] [36]"
[BUILD-FAILURE]: Job 'Karaf/karaf-runtime-jdk11/master [master] [35]'
BUILD-FAILURE: Job 'Karaf/karaf-runtime-jdk11/master [master] [35]': Check console output at "https://ci-builds.apache.org/job/Karaf/job/karaf-runtime-jdk11/job/master/35/";>Karaf/karaf-runtime-jdk11/master [master] [35]"
[karaf] branch karaf-4.2.x updated: [KARAF-6860] Upgrade to Pax Exam 4.13.4
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 85df465 [KARAF-6860] Upgrade to Pax Exam 4.13.4 85df465 is described below commit 85df465b7662b1f9617aa986fef16de05eed2971 Author: jbonofre AuthorDate: Wed Sep 23 20:40:04 2020 +0200 [KARAF-6860] Upgrade to Pax Exam 4.13.4 (cherry picked from commit dbf08d53fcb6df650d95b2b48004bc84eedb0363) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e1fff07..b81969e 100644 --- a/pom.xml +++ b/pom.xml @@ -279,7 +279,7 @@ 6.0.0 1.1.3 -4.13.3 +4.13.4 1.11.7 1.5.1 1.8.3
[karaf] branch master updated: [KARAF-6860] Upgrade to Pax Exam 4.13.4
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 dbf08d5 [KARAF-6860] Upgrade to Pax Exam 4.13.4 new d4fe632 Merge pull request #1200 from jbonofre/KARAF-6860 dbf08d5 is described below commit dbf08d53fcb6df650d95b2b48004bc84eedb0363 Author: jbonofre AuthorDate: Wed Sep 23 20:40:04 2020 +0200 [KARAF-6860] Upgrade to Pax Exam 4.13.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2a77a88..9271b5d 100644 --- a/pom.xml +++ b/pom.xml @@ -278,7 +278,7 @@ 7.0.0 1.1.3 -4.13.3 +4.13.4 2.0.5 1.5.1 1.8.3
[GitHub] [karaf] jbonofre merged pull request #1200: [KARAF-6860] Upgrade to Pax Exam 4.13.4
jbonofre merged pull request #1200: URL: https://github.com/apache/karaf/pull/1200 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[karaf] branch karaf-4.2.x updated: Fix main
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 fbec94d Fix main fbec94d is described below commit fbec94d6b8af4ad4bf6188f98256525889083873 Author: jbonofre AuthorDate: Thu Sep 24 14:28:30 2020 +0200 Fix main --- main/src/main/java/org/apache/karaf/main/Main.java | 76 -- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/main/src/main/java/org/apache/karaf/main/Main.java b/main/src/main/java/org/apache/karaf/main/Main.java index 00cba42..18986d5 100644 --- a/main/src/main/java/org/apache/karaf/main/Main.java +++ b/main/src/main/java/org/apache/karaf/main/Main.java @@ -29,6 +29,7 @@ import java.lang.reflect.Proxy; import java.net.URI; import java.net.URL; import java.net.URLClassLoader; +import java.nio.charset.StandardCharsets; import java.security.Provider; import java.security.Security; import java.util.ArrayList; @@ -90,7 +91,8 @@ public class Main { private volatile boolean exiting; private AutoCloseable shutdownThread; private Thread monitorThread; - +private URLClassLoader classLoader; + /** * * This method performs the main task of constructing an framework instance @@ -221,7 +223,7 @@ public class Main { public void setShutdownCallback(ShutdownCallback shutdownCallback) { this.shutdownCallback = shutdownCallback; } - + public void updateInstancePidAfterShutdown() throws Exception { if (config == null) { config = new ConfigProperties(); @@ -246,12 +248,12 @@ public class Main { for (String provider : config.securityProviders) { addSecurityProvider(provider); } - + List bundleDirs = getBundleRepos(); ArtifactResolver resolver = new SimpleMavenResolver(bundleDirs); // Start up the OSGI framework -ClassLoader classLoader = createClassLoader(resolver); +classLoader = createClassLoader(resolver); FrameworkFactory factory = loadFrameworkFactory(classLoader); framework = factory.newFramework(config.props); @@ -269,7 +271,7 @@ public class Main { LOG.info("Installing and starting initial bundles"); File startupPropsFile = new File(config.karafEtc, STARTUP_PROPERTIES_FILE_NAME); -List bundles = readBundlesFromStartupProperties(startupPropsFile); +List bundles = readBundlesFromStartupProperties(startupPropsFile); installAndStartBundles(resolver, framework.getBundleContext(), bundles); LOG.info("All initial bundles installed and set to start"); } @@ -279,7 +281,7 @@ public class Main { activatorManager = new KarafActivatorManager(classLoader, framework); activatorManager.startKarafActivators(); - + setStartLevel(config.lockStartLevel); // Progress bar if (config.delayConsoleStart) { @@ -342,29 +344,26 @@ public class Main { final Class signalHandlerClass = Class.forName("sun.misc.SignalHandler"); Object signalHandler = Proxy.newProxyInstance(getClass().getClassLoader(), -new Class[] { -signalHandlerClass -}, +new Class[] { +signalHandlerClass +}, (proxy, method, args) -> { -new Thread() { -@Override -public void run() { -try { -exiting = true; -framework.stop(); -} catch (BundleException e) { -e.printStackTrace(); -} +new Thread(() -> { +try { +exiting = true; +framework.stop(); +} catch (BundleException e) { +e.printStackTrace(); } -}.start(); +}).start(); return null; } ); signalClass.getMethod("handle", signalClass, signalHandlerClass).invoke( -null, -signalClass.getConstructor(String.class).newInstance("TERM"), -signalHandler +null, + signalClass.getConstructor(String.class).newInstance("TERM"), +signalHandler ); } catch (Exception e) { } @@ -482,7 +481,7 @@ public class Main { } } -
[BUILD-FAILURE]: Job 'Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [29]'
BUILD-FAILURE: Job 'Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [29]': Check console output at "https://ci-builds.apache.org/job/Karaf/job/karaf-runtime-jdk11/job/karaf-4.2.x/29/";>Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [29]"
[karaf] branch karaf-4.2.x updated: rewrite the CicularBuffer to reduce logservice overhead
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 c4a8214 rewrite the CicularBuffer to reduce logservice overhead c4a8214 is described below commit c4a8214db373581ddeae011d285e05edd718f9b6 Author: Romain Manni-Bucau AuthorDate: Mon Sep 21 12:44:22 2020 +0200 rewrite the CicularBuffer to reduce logservice overhead (cherry picked from commit 7021e024bc22ba32379cc667ab839422e9d58766) --- .../karaf/log/core/internal/CircularBuffer.java| 112 + .../karaf/log/core/internal/LogServiceImpl.java| 13 +-- .../log/core/internal/CircularBufferTest.java | 55 ++ 3 files changed, 109 insertions(+), 71 deletions(-) diff --git a/log/src/main/java/org/apache/karaf/log/core/internal/CircularBuffer.java b/log/src/main/java/org/apache/karaf/log/core/internal/CircularBuffer.java index c953b31..4b9da9f 100644 --- a/log/src/main/java/org/apache/karaf/log/core/internal/CircularBuffer.java +++ b/log/src/main/java/org/apache/karaf/log/core/internal/CircularBuffer.java @@ -18,92 +18,74 @@ */ package org.apache.karaf.log.core.internal; -import java.lang.reflect.Array; -import java.util.ArrayList; +import org.ops4j.pax.logging.spi.PaxLoggingEvent; + import java.util.List; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReferenceArray; +import java.util.function.IntFunction; +import java.util.stream.IntStream; + +import static java.util.Comparator.comparing; +import static java.util.stream.Collectors.toList; /** - * An array that only keeps the last N elements added + * An array that only keeps the last N elements added. + * + * It is likely that it writes way more than it reads (add vs getElements) since logs should be continuous appended + * but their query should be quite rare so we want to optimize the append path. + * + * Important: it can happen a small inconsistency between add() and getElements() but the fact getElements() + * sorts the data makes it hurtless and it avoids to have a lock in this buffer which must keep a "0-overhead" + * on the runtime. */ -public class CircularBuffer { +public class CircularBuffer { -private T[] elements; -private transient int start; -private transient int end; -private transient boolean full; -private final int maxElements; -private Class type; +private final AtomicInteger currentIdx = new AtomicInteger(0); +private final AtomicReferenceArray buffer; -public CircularBuffer(int size, Class type) { +public CircularBuffer(int size) { if (size <= 0) { throw new IllegalArgumentException("The size must be greater than 0"); } -this.type = type; -maxElements = size; -clear(); +this.buffer = new AtomicReferenceArray<>(size); } -private int size() { -if (end == start) { -return full ? maxElements : 0; -} else if (end < start) { -return maxElements - start + end; -} else { -return end - start; -} +public int maxSize() { +return buffer.length(); } -@SuppressWarnings("unchecked") -public synchronized void clear() { -start = 0; -end = 0; -full = false; -elements = (T[])Array.newInstance(type, maxElements); -} - -public synchronized void add(T element) { +public void add(final PaxLoggingEvent element) { if (null == element) { - throw new NullPointerException("Attempted to add null object to buffer"); -} -if (full) { -increaseStart(); -} -elements[end] = element; -increaseEnd(); - -} - -private void increaseStart() { -start++; -if (start >= maxElements) { -start = 0; +throw new NullPointerException("Attempted to add null object to buffer"); } +doAdd(element); } -private void increaseEnd() { -end++; -if (end >= maxElements) { -end = 0; -} -if (end == start) { -full = true; -} +public List getElements(final int requestedCount) { +final int max = Math.min(buffer.length(), requestedCount); +final int current = currentIdx.get() % buffer.length(); +return collectEvents(max, idx -> buffer.get((current + idx) % buffer.length())); } -public synchronized Iterable getElements() { -return getElements(size()); +private List collectEvents(final int max, final IntFunction mapper) { +return IntStream.range(0, max) +.mapToObj(mapper) +.filter(Objects::nonNull) // not initialized yet +.so
[karaf] branch master updated: rewrite the CicularBuffer to reduce logservice overhead
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 7021e02 rewrite the CicularBuffer to reduce logservice overhead new ae7650a Merge pull request #1198 from rmannibucau/rmannibucau/reduce-logservice-overhead 7021e02 is described below commit 7021e024bc22ba32379cc667ab839422e9d58766 Author: Romain Manni-Bucau AuthorDate: Mon Sep 21 12:44:22 2020 +0200 rewrite the CicularBuffer to reduce logservice overhead --- .../karaf/log/core/internal/CircularBuffer.java| 112 + .../karaf/log/core/internal/LogServiceImpl.java| 13 +-- .../log/core/internal/CircularBufferTest.java | 55 ++ 3 files changed, 109 insertions(+), 71 deletions(-) diff --git a/log/src/main/java/org/apache/karaf/log/core/internal/CircularBuffer.java b/log/src/main/java/org/apache/karaf/log/core/internal/CircularBuffer.java index a8482b0..4b9da9f 100644 --- a/log/src/main/java/org/apache/karaf/log/core/internal/CircularBuffer.java +++ b/log/src/main/java/org/apache/karaf/log/core/internal/CircularBuffer.java @@ -18,92 +18,74 @@ */ package org.apache.karaf.log.core.internal; -import java.lang.reflect.Array; -import java.util.ArrayList; +import org.ops4j.pax.logging.spi.PaxLoggingEvent; + import java.util.List; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReferenceArray; +import java.util.function.IntFunction; +import java.util.stream.IntStream; + +import static java.util.Comparator.comparing; +import static java.util.stream.Collectors.toList; /** - * An array that only keeps the last N elements added + * An array that only keeps the last N elements added. + * + * It is likely that it writes way more than it reads (add vs getElements) since logs should be continuous appended + * but their query should be quite rare so we want to optimize the append path. + * + * Important: it can happen a small inconsistency between add() and getElements() but the fact getElements() + * sorts the data makes it hurtless and it avoids to have a lock in this buffer which must keep a "0-overhead" + * on the runtime. */ -public class CircularBuffer { +public class CircularBuffer { -private T[] elements; -private transient int start; -private transient int end; -private transient boolean full; -private final int maxElements; -private Class type; +private final AtomicInteger currentIdx = new AtomicInteger(0); +private final AtomicReferenceArray buffer; -public CircularBuffer(int size, Class type) { +public CircularBuffer(int size) { if (size <= 0) { throw new IllegalArgumentException("The size must be greater than 0"); } -this.type = type; -maxElements = size; -clear(); +this.buffer = new AtomicReferenceArray<>(size); } -private int size() { -if (end == start) { -return full ? maxElements : 0; -} else if (end < start) { -return maxElements - start + end; -} else { -return end - start; -} +public int maxSize() { +return buffer.length(); } -@SuppressWarnings("unchecked") -public synchronized void clear() { -start = 0; -end = 0; -full = false; -elements = (T[])Array.newInstance(type, maxElements); -} - -public synchronized void add(T element) { +public void add(final PaxLoggingEvent element) { if (null == element) { - throw new NullPointerException("Attempted to add null object to buffer"); -} -if (full) { -increaseStart(); -} -elements[end] = element; -increaseEnd(); - -} - -private void increaseStart() { -start++; -if (start >= maxElements) { -start = 0; +throw new NullPointerException("Attempted to add null object to buffer"); } +doAdd(element); } -private void increaseEnd() { -end++; -if (end >= maxElements) { -end = 0; -} -if (end == start) { -full = true; -} +public List getElements(final int requestedCount) { +final int max = Math.min(buffer.length(), requestedCount); +final int current = currentIdx.get() % buffer.length(); +return collectEvents(max, idx -> buffer.get((current + idx) % buffer.length())); } -public synchronized Iterable getElements() { -return getElements(size()); +private List collectEvents(final int max, final IntFunction mapper) { +return IntStream.range(0, max) +.mapToObj(mapper) +.filter(Objects::nonNull) // not initialized yet +
[GitHub] [karaf] jbonofre merged pull request #1198: rewrite the CicularBuffer to reduce logservice overhead
jbonofre merged pull request #1198: URL: https://github.com/apache/karaf/pull/1198 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[BUILD-FAILURE]: Job 'Karaf/karaf-runtime-jdk11/master [master] [34]'
BUILD-FAILURE: Job 'Karaf/karaf-runtime-jdk11/master [master] [34]': Check console output at "https://ci-builds.apache.org/job/Karaf/job/karaf-runtime-jdk11/job/master/34/";>Karaf/karaf-runtime-jdk11/master [master] [34]"
[BUILD-FAILURE]: Job 'Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [28]'
BUILD-FAILURE: Job 'Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [28]': Check console output at "https://ci-builds.apache.org/job/Karaf/job/karaf-runtime-jdk11/job/karaf-4.2.x/28/";>Karaf/karaf-runtime-jdk11/karaf-4.2.x [karaf-4.2.x] [28]"
[karaf] branch karaf-4.2.x 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 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 e20ee72 ensure maven plugin brings back an up to date javax.annotation dep + fixing tests e20ee72 is described below commit e20ee7234ccc7756e4cbca91c343cb921ad5d055 Author: Romain Manni-Bucau AuthorDate: Wed Sep 23 11:08:32 2020 +0200 ensure maven plugin brings back an up to date javax.annotation dep + fixing tests (cherry picked from commit 75eca9f6d6ebd379cc1a758d5fc053d9a2df986b) --- tooling/karaf-maven-plugin/pom.xml | 12 +- .../java/org/apache/karaf/tooling/RunMojo.java | 222 ++--- .../java/org/apache/karaf/tooling/RunMojoTest.java | 10 +- 3 files changed, 216 insertions(+), 28 deletions(-) diff --git a/tooling/karaf-maven-plugin/pom.xml b/tooling/karaf-maven-plugin/pom.xml index 03617df..2cec18b 100644 --- a/tooling/karaf-maven-plugin/pom.xml +++ b/tooling/karaf-maven-plugin/pom.xml @@ -44,10 +44,20 @@ - + +javax.annotation +javax.annotation-api +${javax.annotation.version} + org.apache.maven maven-plugin-api + + +javax.annotation +jsr250-api + + org.apache.maven.resolver 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 20b6aad..57f5a1a 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 @@ -48,8 +48,12 @@ import java.lang.reflect.Method; import java.net.URI; import java.nio.file.Files; import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Stream; /** * Run a Karaf instance @@ -76,6 +80,22 @@ public class RunMojo extends MojoSupport { private boolean deployProjectArtifact = true; /** + * If set and the artifact is not attached to the project, this location will be used. + * It enables to launch karaf:run without building/attaching the artifact. + * A typical good value is + * {@code ${project.build.directory}/${project.build.finalName}.jar}. + */ +@Parameter +private File fallbackLocalProjectArtifact; + +/** + * If true project and deployProjectArtifact is true, + * artifact is deployed after the feature installation, otherwise before. + */ +@Parameter(defaultValue = "false") +private boolean deployAfterFeatures = false; + +/** * A list of URLs referencing feature repositories that will be added * to the karaf instance started by this goal. */ @@ -83,6 +103,22 @@ public class RunMojo extends MojoSupport { private String[] featureRepositories = null; /** + * Karaf main args. + */ +@Parameter +private String[] mainArgs; + +/** + * Karaf console log level + * (karaf.log.console value used in default karaf logging configuration). + */ +@Parameter +private String consoleLogLevel; + +@Parameter +private Map systemProperties; + +/** * Comma-separated list of features to install. */ @Parameter(defaultValue = "") @@ -100,9 +136,25 @@ public class RunMojo extends MojoSupport { @Parameter(defaultValue = "false") private String startSsh = "false"; +/** + * Maximum duration startup can take in milliseconds, negative or zero values mean no maximum. + */ +@Parameter(defaultValue = "18") +private long maximumStartupDuration; + +@Parameter +private List forbiddenDelegationPackages; + private static final Pattern mvnPattern = Pattern.compile("mvn:([^/ ]+)/([^/ ]+)/([^/ ]*)(/([^/ ]+)(/([^/ ]+))?)?"); public void execute() throws MojoExecutionException, MojoFailureException { +// reset system properties after the execution to ensure not not pollute the maven build +final Properties originalProperties = new Properties(); +originalProperties.putAll(System.getProperties()); + +// before any mkdir or so since "clean" is handled +final String[] args = handleArgs(karafDirectory, mainArgs == null ? new String[0] : mainArgs); + if (karafDirectory.exists()) { getLog().info("Using Karaf container located " + karafDirectory.getAbsolutePath()); } else { @@ -122,29 +174,94 @@ public class RunMojo extends MojoSupport { System.setProperty("karaf.etc", karafDirectory.getAb
[GitHub] [karaf] jbonofre merged pull request #1199: ensure maven plugin brings back an up to date javax.annotation dep + …
jbonofre merged pull request #1199: URL: https://github.com/apache/karaf/pull/1199 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[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 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 @@ - + +javax.annotation +javax.annotation-api +${javax.annotation.version} + org.apache.maven maven-plugin-api + + +javax.annotation +jsr250-api + + org.apache.maven.resolver 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 = "18") private long maximumStartupDuration; +@Parameter +private List 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 conta