[Git][java-team/mojo-executor][upstream] New upstream version 2.3.2

Andrius Merkys (@merkys) gitlab at salsa.debian.org
Tue Oct 5 07:21:00 BST 2021



Andrius Merkys pushed to branch upstream at Debian Java Maintainers / mojo-executor


Commits:
fd3e6545 by Andrius Merkys at 2021-10-05T01:39:35-04:00
New upstream version 2.3.2
- - - - -


13 changed files:

- .travis.yml
- README.md
- mojo-executor-maven-plugin/pom.xml
- + mojo-executor-maven-plugin/src/it/mojo-executor-test-project-blocking/pom.xml
- + mojo-executor-maven-plugin/src/it/mojo-executor-test-project-blocking/postbuild.groovy
- mojo-executor-maven-plugin/src/it/mojo-executor-test-project-no-plugin-version/postbuild.groovy
- mojo-executor-maven-plugin/src/it/mojo-executor-test-project-null-maven-project/postbuild.groovy
- mojo-executor-maven-plugin/src/it/mojo-executor-test-project-quiet/postbuild.groovy
- mojo-executor-maven-plugin/src/it/mojo-executor-test-project/postbuild.groovy
- mojo-executor-maven-plugin/src/main/java/org/twdata/maven/mojoexecutor/plugin/MojoExecutorMojo.java
- mojo-executor/pom.xml
- mojo-executor/src/main/java/org/twdata/maven/mojoexecutor/MavenCompatibilityHelper.java
- pom.xml


Changes:

=====================================
.travis.yml
=====================================
@@ -2,9 +2,6 @@
 sudo: false
 
 language: java
-#maven:
-#  - '3.0.5'
-#  - '3.5.0'
 
 jdk:
   - openjdk8
@@ -15,14 +12,14 @@ cache:
      - '$HOME/.m2/repository'
 
 before_install:
-  - wget https://archive.apache.org/dist/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.zip
-  - unzip -q apache-maven-3.0.5-bin.zip
+  - wget https://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.zip
+  - unzip -q apache-maven-3.2.5-bin.zip
   - wget https://archive.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.zip
   - unzip -q apache-maven-3.5.0-bin.zip
 
 env:
   matrix:
-    - MAVEN=$PWD/apache-maven-3.0.5
+    - MAVEN=$PWD/apache-maven-3.2.5
     - MAVEN=$PWD/apache-maven-3.5.0
 
 install: /bin/true


=====================================
README.md
=====================================
@@ -1,4 +1,5 @@
 [![Build Status](https://travis-ci.org/TimMoore/mojo-executor.svg?branch=master)](https://travis-ci.org/TimMoore/mojo-executor)
+[![Maven Central](https://img.shields.io/maven-central/v/org.twdata.maven/mojo-executor)](https://search.maven.org/artifact/org.twdata.maven/mojo-executor)
 
 The Mojo Executor provides a way to to execute other Mojos (plugins) within a Maven plugin, allowing you to easily create Maven plugins that are composed of other plugins.
 
@@ -24,7 +25,7 @@ Cheers,
 Nick Cross
 ----------
 
-While I am no longer actively using this plugin I am happy to review, assist with contributions, merge PRs and release new versions. I have released the last two versions (2.3.0/2.3.1) rolling up all the various fixes and improvements.
+While I am no longer actively using this plugin I am happy to review, assist with contributions, merge PRs and release new versions. I have released the last few versions rolling up all the various fixes and improvements.
 
 Cheers,
 — Nick
@@ -34,6 +35,8 @@ Cheers,
 News
 ====
 
+*  1 Sep 2021 — Mojo Executor 2.3.2 released (by Nick Cross) with various bug fixes and minor improvements
+* 21 Nov 2019 — Mojo Executor 2.3.1 released (by Nick Cross) with various bug fixes and minor improvements
 -  4 May 2017 — Mojo Executor 2.3.0 released (by Nick Cross) with various bug fixes and minor improvements.
 - 27 Mar 2014 — Mojo Executor 1.5.2 released with support for Maven 2 through 3.1.
 - 12 Feb 2014 — I'm looking for a new maintainer for this project. If you're interested, please get in touch!
@@ -43,9 +46,9 @@ News
 Downloads
 =========
 
-You can download the jars, source, and javadocs from Maven central:
+You can download the JARs, source, and Javadocs from Maven central:
 
-http://repo2.maven.org/maven2/org/twdata/maven/mojo-executor/
+https://search.maven.org/search?q=g:org.twdata.maven
 
 Example Usage
 =============
@@ -141,7 +144,7 @@ Contributors
 
 Mojo Executor was originally created by [Don Brown][mrdon] (mrdon at twdata.org).
 
-It is currently maintained by [Tim Moore][TimMoore] (tmoore at incrementalism.net).
+It is currently maintained by [Tim Moore][TimMoore] (tmoore at incrementalism.net) and [Nick Cross][rnc] (ncross at redhat.com)
 
 Thanks to the following contributors, who have provided patches and other assistance:
 
@@ -153,6 +156,7 @@ Thanks to the following contributors, who have provided patches and other assist
 -   [msavelyev][msavelyev] & [Ivan Dyachenko][ivan-dyachenko] — support for attributes in Mojo configuration
 -   [Christof Schoell][cschoell] — Maven 3.1 support in the 1.5.x branch
 
+[rnc]: https://github.com/rnc
 [mrdon]: https://github.com/mrdon
 [TimMoore]: https://github.com/TimMoore/
 [matthewmccullough]: https://github.com/matthewmccullough


=====================================
mojo-executor-maven-plugin/pom.xml
=====================================
@@ -20,7 +20,7 @@
     <parent>
         <groupId>org.twdata.maven</groupId>
         <artifactId>mojo-executor-parent</artifactId>
-        <version>2.3.1</version>
+        <version>2.3.2</version>
     </parent>
 
     <artifactId>mojo-executor-maven-plugin</artifactId>
@@ -94,7 +94,7 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-invoker-plugin</artifactId>
                 <configuration>
-                    <!-- <debug>true</debug> -->
+<!--                     <debug>true</debug>-->
                     <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                     <localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
                     <settingsFile>src/it/settings.xml</settingsFile>


=====================================
mojo-executor-maven-plugin/src/it/mojo-executor-test-project-blocking/pom.xml
=====================================
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 2008-2013 Don Brown
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.twdata.maven</groupId>
+    <artifactId>mojo-executor-test-project-blocking</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <name>Mojo Executor - Test Project</name>
+    <description>
+        Used by the tests for the Mojo Executor Maven Plugin.
+    </description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.4</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-nop</artifactId>
+            <version>1.7.4</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit-dep</artifactId>
+            <version>4.11</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.twdata.maven</groupId>
+                <artifactId>mojo-executor-maven-plugin</artifactId>
+                <version>@project.version@</version>
+                <executions>
+                    <execution>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>execute-mojo</goal>
+                        </goals>
+                        <configuration>
+                            <quiet>false</quiet>
+                            <blocking>true</blocking>
+                            <plugin>
+                                <groupId>org.apache.maven.plugins</groupId>
+                                <artifactId>maven-dependency-plugin</artifactId>
+                                <version>2.0</version>
+                            </plugin>
+                            <goal>list</goal>
+                            <configuration>
+                            </configuration>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>


=====================================
mojo-executor-maven-plugin/src/it/mojo-executor-test-project-blocking/postbuild.groovy
=====================================
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2008-2013 Don Brown
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+File buildLog = new File((String) basedir, "build.log")
+def text = buildLog.getText()
+text = text.replaceAll("\r\n", "\n")
+def v1 = text.contains("[INFO] Executing 'org.apache.maven.plugins:maven-dependency-plugin' in blocking mode.")
+def v2 = text.contains("""[INFO] The following files have been resolved:
+[INFO]    junit:junit:jar:4.11:test
+[INFO]    org.hamcrest:hamcrest-core:jar:1.3:test
+[INFO]    org.slf4j:slf4j-api:jar:1.7.4:provided
+[INFO]    org.slf4j:slf4j-nop:jar:1.7.4:runtime""");
+return v1 && v2;


=====================================
mojo-executor-maven-plugin/src/it/mojo-executor-test-project-no-plugin-version/postbuild.groovy
=====================================
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 File buildLog = new File((String) basedir, "build.log")
-return buildLog.getText().contains("""
+def text = buildLog.getText()
+text = text.replaceAll("\r\n", "\n")
+return text.contains("""
 [INFO] The following files have been resolved:
 [INFO]    junit:junit:jar:4.11:test
 [INFO]    org.hamcrest:hamcrest-core:jar:1.3:test


=====================================
mojo-executor-maven-plugin/src/it/mojo-executor-test-project-null-maven-project/postbuild.groovy
=====================================
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 File buildLog = new File((String) basedir, "build.log")
-return buildLog.getText().contains("""
+def text = buildLog.getText()
+text = text.replaceAll("\r\n", "\n")
+return text.contains("""
 [INFO] The following files have been resolved:
 [INFO]    junit:junit:jar:4.11:test
 [INFO]    org.hamcrest:hamcrest-core:jar:1.3:test


=====================================
mojo-executor-maven-plugin/src/it/mojo-executor-test-project-quiet/postbuild.groovy
=====================================
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 File buildLog = new File((String) basedir, "build.log")
-return ! buildLog.getText().contains("""
+def text = buildLog.getText()
+text = text.replaceAll("\r\n", "\n")
+return ! text.contains("""
 [INFO] The following files have been resolved:
 [INFO]    junit:junit:jar:4.11:test
 [INFO]    org.hamcrest:hamcrest-core:jar:1.3:test


=====================================
mojo-executor-maven-plugin/src/it/mojo-executor-test-project/postbuild.groovy
=====================================
@@ -14,7 +14,9 @@
  * limitations under the License.
  */
 File buildLog = new File((String) basedir, "build.log")
-return buildLog.getText().contains("""
+def text = buildLog.getText()
+text = text.replaceAll("\r\n", "\n")
+return text.contains("""
 [INFO] The following files have been resolved:
 [INFO]    junit:junit:jar:4.11:test
 [INFO]    org.hamcrest:hamcrest-core:jar:1.3:test


=====================================
mojo-executor-maven-plugin/src/main/java/org/twdata/maven/mojoexecutor/plugin/MojoExecutorMojo.java
=====================================
@@ -23,17 +23,17 @@ import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.BuildPluginManager;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.annotations.*;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
 import org.codehaus.plexus.logging.Logger;
 import org.slf4j.ILoggerFactory;
 import org.slf4j.LoggerFactory;
 
+import java.util.HashSet;
+import java.util.Set;
+
+import static java.lang.String.format;
 import static org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo;
 import static org.twdata.maven.mojoexecutor.MojoExecutor.executionEnvironment;
 import static org.twdata.maven.mojoexecutor.PlexusConfigurationUtils.toXpp3Dom;
@@ -42,18 +42,20 @@ import static org.twdata.maven.mojoexecutor.PlexusConfigurationUtils.toXpp3Dom;
  * Execute a Mojo using the MojoExecutor.
  */
 @SuppressWarnings("unused")
- at Mojo( name = "execute-mojo", defaultPhase = LifecyclePhase.TEST, requiresDependencyResolution = ResolutionScope.TEST)
+ at Mojo(name = "execute-mojo", defaultPhase = LifecyclePhase.TEST, requiresDependencyResolution = ResolutionScope.TEST)
 public class MojoExecutorMojo extends AbstractMojo {
+    private static final Set<String> lockedKeys = new HashSet<>();
+
     /**
      * Plugin to execute.
      */
-    @Parameter (required = true)
+    @Parameter(required = true)
     private Plugin plugin;
 
     /**
      * Plugin goal to execute.
      */
-    @Parameter (required = true)
+    @Parameter(required = true)
     private String goal;
 
     /**
@@ -65,13 +67,13 @@ public class MojoExecutorMojo extends AbstractMojo {
     /**
      * The project currently being build.
      */
-    @Parameter( defaultValue = "${project}", readonly = true )
+    @Parameter(defaultValue = "${project}", readonly = true)
     private MavenProject mavenProject;
 
     /**
      * The current Maven session.
      */
-    @Parameter( defaultValue = "${session}", readonly = true )
+    @Parameter(defaultValue = "${session}", readonly = true)
     private MavenSession mavenSession;
 
     /**
@@ -83,27 +85,63 @@ public class MojoExecutorMojo extends AbstractMojo {
     /**
      * Disable logging on executed mojos
      */
-    @Parameter ( defaultValue = "false")
+    @Parameter(defaultValue = "false")
     private boolean quiet;
 
+    /**
+     * Enable thread blocking per plugin GA (groupId & artifactId)
+     */
+    @Parameter(defaultValue = "false")
+    private boolean blocking;
+
     /**
      * Ignore injected maven projetc
      */
-    @Parameter ( defaultValue = "false")
+    @Parameter(defaultValue = "false")
     private boolean ignoreMavenProject;
 
     public void execute() throws MojoExecutionException {
 
         getLog().info("Executing with maven project " + mavenProject + " for session " + mavenSession);
 
-        if ( quiet )
-        {
+        if (quiet) {
             disableLogging();
         }
+
+        // Blocking case.
+        if (blocking) {
+            final String key = format("%s:%s", plugin.getGroupId(), plugin.getArtifactId());
+
+            try {
+                lock(key);
+
+                getLog().info(String.format("Executing '%s' in blocking mode.", key));
+
+                //Put your code here.
+                //For different keys it is executed in parallel.
+                //For equal keys it is executed synchronously.
+                executeMojoImpl();
+
+            } catch (InterruptedException e) {
+                final String failed = "Failed to execute mojo";
+                getLog().error(failed, e);
+                throw new MojoExecutionException(failed, e);
+            } finally {
+                unlock(key);
+
+                getLog().info(String.format("Released '%s' block.", key));
+            }
+        } else {
+            // Non blocking case.
+            executeMojoImpl();
+        }
+    }
+
+    private void executeMojoImpl() throws MojoExecutionException {
         executeMojo(plugin, goal, toXpp3Dom(configuration),
-            (ignoreMavenProject ?
-                executionEnvironment( mavenSession, pluginManager) :
-                executionEnvironment( mavenProject, mavenSession, pluginManager)));
+                (ignoreMavenProject ?
+                        executionEnvironment(mavenSession, pluginManager) :
+                        executionEnvironment(mavenProject, mavenSession, pluginManager)));
     }
 
     private void disableLogging() throws MojoExecutionException {
@@ -122,4 +160,19 @@ public class MojoExecutorMojo extends AbstractMojo {
         slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.ERROR);
         slf4jConfiguration.activate();
     }
+
+    private void lock(String key) throws InterruptedException {
+        synchronized (lockedKeys) {
+            while (!lockedKeys.add(key)) {
+                lockedKeys.wait();
+            }
+        }
+    }
+
+    private void unlock(String key) {
+        synchronized (lockedKeys) {
+            lockedKeys.remove(key);
+            lockedKeys.notifyAll();
+        }
+    }
 }


=====================================
mojo-executor/pom.xml
=====================================
@@ -20,7 +20,7 @@
     <parent>
         <groupId>org.twdata.maven</groupId>
         <artifactId>mojo-executor-parent</artifactId>
-        <version>2.3.1</version>
+        <version>2.3.2</version>
     </parent>
 
     <artifactId>mojo-executor</artifactId>


=====================================
mojo-executor/src/main/java/org/twdata/maven/mojoexecutor/MavenCompatibilityHelper.java
=====================================
@@ -34,7 +34,7 @@ import java.lang.reflect.Method;
 import java.util.List;
 
 /**
- * The <tt>MavenCompatibilityHelper</tt> hides incompatibilities between Maven versions
+ * The {@code MavenCompatibilityHelper} hides incompatibilities between Maven versions
  *
  */
 public class MavenCompatibilityHelper {


=====================================
pom.xml
=====================================
@@ -25,7 +25,7 @@
 
   <groupId>org.twdata.maven</groupId>
   <artifactId>mojo-executor-parent</artifactId>
-  <version>2.3.1</version>
+  <version>2.3.2</version>
   <packaging>pom</packaging>
 
   <name>Mojo Executor Parent</name>
@@ -96,7 +96,7 @@
     <connection>scm:git:git://github.com/TimMoore/mojo-executor.git</connection>
     <developerConnection>scm:git:ssh://git@github.com/TimMoore/mojo-executor.git</developerConnection>
     <url>https://github.com/TimMoore/mojo-executor</url>
-    <tag>mojo-executor-parent-2.3.1</tag>
+    <tag>mojo-executor-parent-2.3.2</tag>
   </scm>
   <issueManagement>
     <system>GitHub</system>
@@ -146,7 +146,7 @@
       <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
-        <version>4.12</version>
+        <version>4.13.1</version>
         <scope>test</scope>
       </dependency>
       <dependency>



View it on GitLab: https://salsa.debian.org/java-team/mojo-executor/-/commit/fd3e654571862d63858d4ac1a69c13d503a3511a

-- 
View it on GitLab: https://salsa.debian.org/java-team/mojo-executor/-/commit/fd3e654571862d63858d4ac1a69c13d503a3511a
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20211005/297939e7/attachment.htm>


More information about the pkg-java-commits mailing list