You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/10/03 19:37:18 UTC

(maven-acr-plugin) branch master updated (3db423d -> 2a98c18)

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

slachiewicz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/maven-acr-plugin.git


    from 3db423d  Simplify GH PR template boilerplate
     new 251e802  Replace Plexus components.xml with JSR-330 components
     new 2a98c18  Pin the acr goal binding to the plugin's own version

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                            |  10 +-
 src/it/{it-01 => it-05}/pom.xml                    |  15 ++-
 .../maven/plugin/acr/it/it05}/SampleApp.java       |   2 +-
 .../main/resources/META-INF/application-client.xml |   0
 .../it/it01/SampleApp.java => it-05/verify.groovy} |  18 ++--
 .../META-INF/plexus/components.xml                 |  84 ---------------
 .../acr/internal/AppClientArtifactHandler.java}    |  23 +++--
 .../AppClientLifecycleMappingProvider.java         | 113 +++++++++++++++++++++
 8 files changed, 147 insertions(+), 118 deletions(-)
 copy src/it/{it-01 => it-05}/pom.xml (81%)
 copy src/it/{it-01/src/main/java/org/apache/maven/plugin/acr/it/it01 => it-05/src/main/java/org/apache/maven/plugin/acr/it/it05}/SampleApp.java (95%)
 copy src/it/{it-01 => it-05}/src/main/resources/META-INF/application-client.xml (100%)
 copy src/it/{it-01/src/main/java/org/apache/maven/plugin/acr/it/it01/SampleApp.java => it-05/verify.groovy} (58%)
 delete mode 100644 src/main/filtered-resources/META-INF/plexus/components.xml
 copy src/{it/it-01/src/main/java/org/apache/maven/plugin/acr/it/it01/SampleApp.java => main/java/org/apache/maven/plugins/acr/internal/AppClientArtifactHandler.java} (65%)
 create mode 100644 src/main/java/org/apache/maven/plugins/acr/internal/AppClientLifecycleMappingProvider.java


(maven-acr-plugin) 01/02: Replace Plexus components.xml with JSR-330 components

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-acr-plugin.git

commit 251e8026949fc36c1da626a1681db1fa3e57d706
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Oct 3 21:09:20 2026 +0200

    Replace Plexus components.xml with JSR-330 components
---
 pom.xml                                            | 10 +--
 .../META-INF/plexus/components.xml                 | 84 --------------------
 .../acr/internal/AppClientArtifactHandler.java     | 35 +++++++++
 .../AppClientLifecycleMappingProvider.java         | 90 ++++++++++++++++++++++
 4 files changed, 129 insertions(+), 90 deletions(-)

diff --git a/pom.xml b/pom.xml
index 458efd2..4ccd4dd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -119,13 +119,11 @@ under the License.
   </dependencies>
 
   <build>
-    <resources>
-      <resource>
-        <filtering>true</filtering>
-        <directory>src/main/filtered-resources</directory>
-      </resource>
-    </resources>
     <plugins>
+      <plugin>
+        <groupId>org.eclipse.sisu</groupId>
+        <artifactId>sisu-maven-plugin</artifactId>
+      </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
diff --git a/src/main/filtered-resources/META-INF/plexus/components.xml b/src/main/filtered-resources/META-INF/plexus/components.xml
deleted file mode 100644
index 60f08a0..0000000
--- a/src/main/filtered-resources/META-INF/plexus/components.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */-->
-<component-set>
-  <components>
-    <!--
-     | ACR
-     |-->
-    <component>
-      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
-      <role-hint>app-client</role-hint>
-      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
-      <configuration>
-        <type>app-client</type>
-        <extension>jar</extension>
-        <language>java</language>
-        <addedToClasspath>true</addedToClasspath>
-      </configuration>
-    </component>
-    <!--
-      | Defining the phases with their appropriate plugins
-      ! and versions which will be executed during the 'default'
-      ! life cycle.
-    -->
-    <!--
-     | ACR
-     |-->
-    <component>
-      <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
-      <role-hint>app-client</role-hint>
-      <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
-      <configuration>
-        <lifecycles>
-          <lifecycle>
-            <id>default</id>
-            <phases>
-              <process-resources>
-                org.apache.maven.plugins:maven-resources-plugin:2.7:resources
-              </process-resources>
-              <compile>
-                org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile
-              </compile>
-              <process-test-resources>
-                org.apache.maven.plugins:maven-resources-plugin:2.7:testResources
-              </process-test-resources>
-              <test-compile>
-                org.apache.maven.plugins:maven-compiler-plugin:3.5.1:testCompile
-              </test-compile>
-              <test>
-                org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test
-              </test>
-              <package>
-                org.apache.maven.plugins:maven-acr-plugin:${project.version}:acr
-              </package>
-              <install>
-                org.apache.maven.plugins:maven-install-plugin:2.5.2:install
-              </install>
-              <deploy>
-                org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy
-              </deploy>
-            </phases>
-          </lifecycle>
-        </lifecycles>
-      </configuration>
-    </component>
-  </components>
-</component-set>
\ No newline at end of file
diff --git a/src/main/java/org/apache/maven/plugins/acr/internal/AppClientArtifactHandler.java b/src/main/java/org/apache/maven/plugins/acr/internal/AppClientArtifactHandler.java
new file mode 100644
index 0000000..a596098
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/acr/internal/AppClientArtifactHandler.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.plugins.acr.internal;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+@Singleton
+@Named("app-client")
+public class AppClientArtifactHandler extends DefaultArtifactHandler {
+    public AppClientArtifactHandler() {
+        super("app-client");
+        setExtension("jar");
+        setLanguage("java");
+        setAddedToClasspath(true);
+    }
+}
diff --git a/src/main/java/org/apache/maven/plugins/acr/internal/AppClientLifecycleMappingProvider.java b/src/main/java/org/apache/maven/plugins/acr/internal/AppClientLifecycleMappingProvider.java
new file mode 100644
index 0000000..2bd7861
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/acr/internal/AppClientLifecycleMappingProvider.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.plugins.acr.internal;
+
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.lifecycle.mapping.Lifecycle;
+import org.apache.maven.lifecycle.mapping.LifecycleMapping;
+import org.apache.maven.lifecycle.mapping.LifecyclePhase;
+
+@Singleton
+@Named("app-client")
+public final class AppClientLifecycleMappingProvider implements Provider<LifecycleMapping> {
+    // The maven-acr-plugin binding carries no version: this mapping is only loaded when the project
+    // declares the plugin, so the version always comes from the project's effective POM.
+    private static final String[] BINDINGS = {
+        "process-resources", "org.apache.maven.plugins:maven-resources-plugin:2.7:resources",
+        "compile", "org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile",
+        "process-test-resources", "org.apache.maven.plugins:maven-resources-plugin:2.7:testResources",
+        "test-compile", "org.apache.maven.plugins:maven-compiler-plugin:3.5.1:testCompile",
+        "test", "org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test",
+        "package", "org.apache.maven.plugins:maven-acr-plugin:acr",
+        "install", "org.apache.maven.plugins:maven-install-plugin:2.5.2:install",
+        "deploy", "org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy"
+    };
+
+    private final LifecycleMapping lifecycleMapping;
+
+    public AppClientLifecycleMappingProvider() {
+        Map<String, LifecyclePhase> lifecyclePhases = new LinkedHashMap<>();
+        for (int i = 0; i < BINDINGS.length; i += 2) {
+            lifecyclePhases.put(BINDINGS[i], new LifecyclePhase(BINDINGS[i + 1]));
+        }
+        Lifecycle defaultLifecycle = new Lifecycle();
+        defaultLifecycle.setId("default");
+        defaultLifecycle.setLifecyclePhases(lifecyclePhases);
+
+        this.lifecycleMapping = new LifecycleMapping() {
+            @Override
+            public Map<String, Lifecycle> getLifecycles() {
+                return Collections.singletonMap("default", defaultLifecycle);
+            }
+
+            @Override
+            public List<String> getOptionalMojos(String lifecycle) {
+                return null;
+            }
+
+            @Override
+            public Map<String, String> getPhases(String lifecycle) {
+                if (!"default".equals(lifecycle)) {
+                    return null;
+                }
+                Map<String, String> phases = new LinkedHashMap<>();
+                for (Map.Entry<String, LifecyclePhase> entry : lifecyclePhases.entrySet()) {
+                    phases.put(entry.getKey(), entry.getValue().toString());
+                }
+                return phases;
+            }
+        };
+    }
+
+    @Override
+    public LifecycleMapping get() {
+        return lifecycleMapping;
+    }
+}


(maven-acr-plugin) 02/02: Pin the acr goal binding to the plugin's own version

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-acr-plugin.git

commit 2a98c18468952ba7d56604fcf5b491f0c6fb2ddb
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Oct 3 21:16:48 2026 +0200

    Pin the acr goal binding to the plugin's own version
    
    A version-less binding makes <build><extensions> users run whatever
    version repository metadata resolves; it-05 covers that path.
---
 src/it/it-05/pom.xml                               | 47 ++++++++++++++++++++++
 .../apache/maven/plugin/acr/it/it05/SampleApp.java | 30 ++++++++++++++
 .../main/resources/META-INF/application-client.xml | 33 +++++++++++++++
 src/it/it-05/verify.groovy                         | 28 +++++++++++++
 .../AppClientLifecycleMappingProvider.java         | 29 +++++++++++--
 5 files changed, 164 insertions(+), 3 deletions(-)

diff --git a/src/it/it-05/pom.xml b/src/it/it-05/pom.xml
new file mode 100644
index 0000000..a265463
--- /dev/null
+++ b/src/it/it-05/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugin</groupId>
+  <artifactId>maven-acr-plugin-it05</artifactId>
+  <version>1.0</version>
+  <packaging>app-client</packaging>
+
+  <name>Maven ACR Plugin :: Integration test 05</name>
+  <description>Load the plugin as a build extension and check that the package phase runs the same plugin version</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.build.outputTimestamp>2020-05-01T12:12:12Z</project.build.outputTimestamp>
+  </properties>
+
+  <build>
+    <extensions>
+      <extension>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-acr-plugin</artifactId>
+        <version>@project.version@</version>
+      </extension>
+    </extensions>
+  </build>
+</project>
diff --git a/src/it/it-05/src/main/java/org/apache/maven/plugin/acr/it/it05/SampleApp.java b/src/it/it-05/src/main/java/org/apache/maven/plugin/acr/it/it05/SampleApp.java
new file mode 100644
index 0000000..2426de0
--- /dev/null
+++ b/src/it/it-05/src/main/java/org/apache/maven/plugin/acr/it/it05/SampleApp.java
@@ -0,0 +1,30 @@
+package org.apache.maven.plugin.acr.it.it05;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+public class SampleApp
+{
+
+    public String sayHello( String t )
+    {
+        return "Hello " + t;
+    }
+
+}
\ No newline at end of file
diff --git a/src/it/it-05/src/main/resources/META-INF/application-client.xml b/src/it/it-05/src/main/resources/META-INF/application-client.xml
new file mode 100644
index 0000000..5bc5e95
--- /dev/null
+++ b/src/it/it-05/src/main/resources/META-INF/application-client.xml
@@ -0,0 +1,33 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+<application-client xmlns="http://java.sun.com/xml/ns/j2ee"
+                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+                    http://java.sun.com/xml/ns/j2ee/application-client_1_4.xsd"
+                    version="1.4">
+
+  <display-name>A sample app client</display-name>
+
+  <env-entry>
+    <env-entry-name>myKey</env-entry-name>
+    <env-entry-type>java.lang.String</env-entry-type>
+    <env-entry-value>myValue</env-entry-value>
+  </env-entry>
+
+</application-client>
\ No newline at end of file
diff --git a/src/it/it-05/verify.groovy b/src/it/it-05/verify.groovy
new file mode 100644
index 0000000..4cf017b
--- /dev/null
+++ b/src/it/it-05/verify.groovy
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+def version = (new File(basedir, "pom.xml").text =~ /<artifactId>maven-acr-plugin<\/artifactId>\s*<version>([^<]+)<\/version>/)[0][1]
+def log = new File(basedir, "build.log").text
+
+// The lifecycle mapping must bind the acr goal to the loaded extension's version,
+// not to whatever version repository metadata resolves for a version-less binding.
+if (!log.contains(":" + version + ":acr (default-acr)")) {
+    throw new AssertionError("acr goal did not run at extension version " + version)
+}
+assert new File(basedir, "target/maven-acr-plugin-it05-1.0.jar").isFile()
diff --git a/src/main/java/org/apache/maven/plugins/acr/internal/AppClientLifecycleMappingProvider.java b/src/main/java/org/apache/maven/plugins/acr/internal/AppClientLifecycleMappingProvider.java
index 2bd7861..aec1b1b 100644
--- a/src/main/java/org/apache/maven/plugins/acr/internal/AppClientLifecycleMappingProvider.java
+++ b/src/main/java/org/apache/maven/plugins/acr/internal/AppClientLifecycleMappingProvider.java
@@ -22,10 +22,13 @@ import javax.inject.Named;
 import javax.inject.Provider;
 import javax.inject.Singleton;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 import org.apache.maven.lifecycle.mapping.Lifecycle;
 import org.apache.maven.lifecycle.mapping.LifecycleMapping;
@@ -34,15 +37,18 @@ import org.apache.maven.lifecycle.mapping.LifecyclePhase;
 @Singleton
 @Named("app-client")
 public final class AppClientLifecycleMappingProvider implements Provider<LifecycleMapping> {
-    // The maven-acr-plugin binding carries no version: this mapping is only loaded when the project
-    // declares the plugin, so the version always comes from the project's effective POM.
+    // The acr binding is pinned to this plugin's own version. Left version-less, a project that loads
+    // the plugin through <build><extensions> would run whatever version repository metadata resolves.
+    // The version-less form remains only as a fallback for running from unpackaged classes.
+    private static final String ACR_GOAL = acrGoal();
+
     private static final String[] BINDINGS = {
         "process-resources", "org.apache.maven.plugins:maven-resources-plugin:2.7:resources",
         "compile", "org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile",
         "process-test-resources", "org.apache.maven.plugins:maven-resources-plugin:2.7:testResources",
         "test-compile", "org.apache.maven.plugins:maven-compiler-plugin:3.5.1:testCompile",
         "test", "org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test",
-        "package", "org.apache.maven.plugins:maven-acr-plugin:acr",
+        "package", ACR_GOAL,
         "install", "org.apache.maven.plugins:maven-install-plugin:2.5.2:install",
         "deploy", "org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy"
     };
@@ -83,6 +89,23 @@ public final class AppClientLifecycleMappingProvider implements Provider<Lifecyc
         };
     }
 
+    private static String acrGoal() {
+        String resource = "/META-INF/maven/org.apache.maven.plugins/maven-acr-plugin/pom.properties";
+        try (InputStream in = AppClientLifecycleMappingProvider.class.getResourceAsStream(resource)) {
+            if (in != null) {
+                Properties properties = new Properties();
+                properties.load(in);
+                String version = properties.getProperty("version");
+                if (version != null) {
+                    return "org.apache.maven.plugins:maven-acr-plugin:" + version + ":acr";
+                }
+            }
+        } catch (IOException e) {
+            // fall through to the version-less binding
+        }
+        return "org.apache.maven.plugins:maven-acr-plugin:acr";
+    }
+
     @Override
     public LifecycleMapping get() {
         return lifecycleMapping;