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 2021/09/29 12:10:07 UTC

[maven-dependency-plugin] branch MDEP-769-tests created (now ffe11e9)

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

slachiewicz pushed a change to branch MDEP-769-tests
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git.


      at ffe11e9  [MDEP-769] tests for verifying changing mojo default parameters

This branch includes the following new commits:

     new 7c0c440  [MDEP-769] remove final modifier from mojo parameter
     new ffe11e9  [MDEP-769] tests for verifying changing mojo default parameters

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.


[maven-dependency-plugin] 01/02: [MDEP-769] remove final modifier from mojo parameter

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

slachiewicz pushed a commit to branch MDEP-769-tests
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git

commit 7c0c440bd3601a2e026e87e18edbae713232a8f9
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Mon Sep 13 23:44:50 2021 +0200

    [MDEP-769] remove final modifier from mojo parameter
---
 .../maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java       | 6 +++---
 .../apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java | 2 +-
 .../plugins/dependency/fromDependencies/BuildClasspathMojo.java     | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java
index a347041..d5e36ac 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java
@@ -182,7 +182,7 @@ public abstract class AbstractAnalyzeMojo
      * @since 2.10
      */
     @Parameter
-    private final String[] ignoredDependencies = new String[0];
+    private String[] ignoredDependencies = new String[0];
 
     /**
      * List of dependencies that will be ignored if they are used but undeclared. The filter syntax is:
@@ -201,7 +201,7 @@ public abstract class AbstractAnalyzeMojo
      * @since 2.10
      */
     @Parameter
-    private final String[] ignoredUsedUndeclaredDependencies = new String[0];
+    private String[] ignoredUsedUndeclaredDependencies = new String[0];
 
     /**
      * List of dependencies that will be ignored if they are declared but unused. The filter syntax is:
@@ -220,7 +220,7 @@ public abstract class AbstractAnalyzeMojo
      * @since 2.10
      */
     @Parameter
-    private final String[] ignoredUnusedDeclaredDependencies = new String[0];
+    private String[] ignoredUnusedDeclaredDependencies = new String[0];
 
     /**
      * List of project packaging that will be ignored.
diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java
index bebe5f4..e95d350 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/CopyMojo.java
@@ -59,7 +59,7 @@ public class CopyMojo
      * @since 2.7
      */
     @Parameter( property = "mdep.prependGroupId", defaultValue = "false" )
-    private final boolean prependGroupId = false;
+    private boolean prependGroupId = false;
 
     /**
      * Use artifact baseVersion during copy
diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java
index bcb6dac..4a4176a 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java
@@ -78,7 +78,7 @@ public class BuildClasspathMojo
      * Strip artifact classifier during copy (only works if prefix is set)
      */
     @Parameter( property = "mdep.stripClassifier", defaultValue = "false" )
-    private final boolean stripClassifier = false;
+    private boolean stripClassifier = false;
 
     /**
      * The prefix to prepend on each dependent artifact. If undefined, the paths refer to the actual files store in the
@@ -158,7 +158,7 @@ public class BuildClasspathMojo
      * @since 2.6
      */
     @Parameter( property = "mdep.useBaseVersion", defaultValue = "true" )
-    private final boolean useBaseVersion = true;
+    private boolean useBaseVersion = true;
 
     /**
      * Maven ProjectHelper

[maven-dependency-plugin] 02/02: [MDEP-769] tests for verifying changing mojo default parameters

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

slachiewicz pushed a commit to branch MDEP-769-tests
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git

commit ffe11e995f844b6ae211000ffb4b6a2229724fda
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Tue Sep 14 09:15:56 2021 +0200

    [MDEP-769] tests for verifying changing mojo default parameters
---
 .../invoker.properties                             | 18 +++++++++
 .../pom.xml                                        | 18 ++++++++-
 .../build-classpath-changeparams/test.properties   | 26 +++++++++++++
 .../verify.bsh                                     | 12 +++---
 src/it/projects/build-classpath/pom.xml            | 16 +++++++-
 src/it/projects/build-classpath/verify.bsh         |  2 +
 .../copy-with-prependGroupId/invoker.properties    | 18 +++++++++
 .../pom.xml                                        | 45 ++++++++++++++--------
 .../verify.bsh                                     | 31 ++++++---------
 9 files changed, 141 insertions(+), 45 deletions(-)

diff --git a/src/it/projects/build-classpath-changeparams/invoker.properties b/src/it/projects/build-classpath-changeparams/invoker.properties
new file mode 100644
index 0000000..68eb44c
--- /dev/null
+++ b/src/it/projects/build-classpath-changeparams/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:build-classpath
diff --git a/src/it/projects/build-classpath/pom.xml b/src/it/projects/build-classpath-changeparams/pom.xml
similarity index 78%
copy from src/it/projects/build-classpath/pom.xml
copy to src/it/projects/build-classpath-changeparams/pom.xml
index 5047df0..74963ba 100644
--- a/src/it/projects/build-classpath/pom.xml
+++ b/src/it/projects/build-classpath-changeparams/pom.xml
@@ -24,12 +24,12 @@
   <modelVersion>4.0.0</modelVersion>
 
   <groupId>org.apache.maven.its.dependency</groupId>
-  <artifactId>test</artifactId>
+  <artifactId>build-classpath-changeparams</artifactId>
   <version>1.0-SNAPSHOT</version>
 
   <name>Test</name>
   <description>
-    Test dependency:build-classpath
+    Test dependency:build-classpath with changed default parameters
   </description>
 
   <properties>
@@ -49,6 +49,20 @@
         </exclusion>
       </exclusions>
     </dependency>
+
+    <!-- one dependency with classifier -->
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0.6</version>
+      <classifier>sources</classifier>
+      <exclusions>
+        <exclusion>
+          <groupId>*</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
   </dependencies>
 
 </project>
diff --git a/src/it/projects/build-classpath-changeparams/test.properties b/src/it/projects/build-classpath-changeparams/test.properties
new file mode 100644
index 0000000..a4f45b9
--- /dev/null
+++ b/src/it/projects/build-classpath-changeparams/test.properties
@@ -0,0 +1,26 @@
+# 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.
+
+mdep.outputFile = target/classpath.txt
+mdep.fileSeparator = /
+mdep.pathSeparator = :
+
+# for test we change default parameters
+mdep.prependGroupId = true
+mdep.stripClassifier = true
+mdep.prefix = PREFIX
+
diff --git a/src/it/projects/build-classpath/verify.bsh b/src/it/projects/build-classpath-changeparams/verify.bsh
similarity index 77%
copy from src/it/projects/build-classpath/verify.bsh
copy to src/it/projects/build-classpath-changeparams/verify.bsh
index 7b3b234..57574e0 100644
--- a/src/it/projects/build-classpath/verify.bsh
+++ b/src/it/projects/build-classpath-changeparams/verify.bsh
@@ -29,11 +29,13 @@ classpath = StringUtils.replace( classpath, "PREFIX/", "" );
 List actual = Arrays.asList( classpath.split( ":" ) );
 
 List expected = new ArrayList();
-expected.add( "maven-profile-2.0.6.jar" );
-expected.add( "maven-model-2.0.6.jar" );
-expected.add( "plexus-utils-1.4.1.jar" );
-expected.add( "plexus-container-default-1.0-alpha-9-stable-1.jar" );
-expected.add( "junit-3.8.1.jar" );
+expected.add( "org.apache.maven.maven-profile-2.0.6.jar" );
+expected.add( "org.apache.maven.maven-model-2.0.6.jar" );
+expected.add( "org.codehaus.plexus.plexus-utils-1.4.1.jar" );
+expected.add( "org.codehaus.plexus.plexus-container-default-1.0-alpha-9-stable-1.jar" );
+expected.add( "junit.junit-3.8.1.jar" );
+// dependency with classifier in pom
+expected.add( "org.apache.maven.maven-project-2.0.6.jar" );
 
 System.out.println( "Checking classpath... " );
 System.out.println( "Actual  : " + actual );
diff --git a/src/it/projects/build-classpath/pom.xml b/src/it/projects/build-classpath/pom.xml
index 5047df0..b89b55d 100644
--- a/src/it/projects/build-classpath/pom.xml
+++ b/src/it/projects/build-classpath/pom.xml
@@ -24,7 +24,7 @@
   <modelVersion>4.0.0</modelVersion>
 
   <groupId>org.apache.maven.its.dependency</groupId>
-  <artifactId>test</artifactId>
+  <artifactId>build-classpath</artifactId>
   <version>1.0-SNAPSHOT</version>
 
   <name>Test</name>
@@ -49,6 +49,20 @@
         </exclusion>
       </exclusions>
     </dependency>
+
+    <!-- one dependency with classifier -->
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0.6</version>
+      <classifier>sources</classifier>
+      <exclusions>
+        <exclusion>
+          <groupId>*</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
   </dependencies>
 
 </project>
diff --git a/src/it/projects/build-classpath/verify.bsh b/src/it/projects/build-classpath/verify.bsh
index 7b3b234..63990b9 100644
--- a/src/it/projects/build-classpath/verify.bsh
+++ b/src/it/projects/build-classpath/verify.bsh
@@ -34,6 +34,8 @@ expected.add( "maven-model-2.0.6.jar" );
 expected.add( "plexus-utils-1.4.1.jar" );
 expected.add( "plexus-container-default-1.0-alpha-9-stable-1.jar" );
 expected.add( "junit-3.8.1.jar" );
+// dependency with classifier in pom
+expected.add( "maven-project-2.0.6-sources.jar" );
 
 System.out.println( "Checking classpath... " );
 System.out.println( "Actual  : " + actual );
diff --git a/src/it/projects/copy-with-prependGroupId/invoker.properties b/src/it/projects/copy-with-prependGroupId/invoker.properties
new file mode 100644
index 0000000..f50e476
--- /dev/null
+++ b/src/it/projects/copy-with-prependGroupId/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals = clean process-sources
diff --git a/src/it/projects/build-classpath/pom.xml b/src/it/projects/copy-with-prependGroupId/pom.xml
similarity index 61%
copy from src/it/projects/build-classpath/pom.xml
copy to src/it/projects/copy-with-prependGroupId/pom.xml
index 5047df0..f0303aa 100644
--- a/src/it/projects/build-classpath/pom.xml
+++ b/src/it/projects/copy-with-prependGroupId/pom.xml
@@ -24,31 +24,42 @@
   <modelVersion>4.0.0</modelVersion>
 
   <groupId>org.apache.maven.its.dependency</groupId>
-  <artifactId>test</artifactId>
+  <artifactId>copy-with-prependGroupId</artifactId>
   <version>1.0-SNAPSHOT</version>
 
   <name>Test</name>
   <description>
-    Test dependency:build-classpath
+    Test dependency:copy with changed default value of prependGroupId
   </description>
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
 
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-profile</artifactId>
-      <version>2.0.6</version>
-      <exclusions>
-        <exclusion>
-          <!-- NOTE: Excluded because of questionable handling of dependencyManagement in maven-profile:pom:2.0.6 -->
-          <groupId>classworlds</groupId>
-          <artifactId>classworlds</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-  </dependencies>
-
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>test</id>
+            <goals>
+              <goal>copy</goal>
+            </goals>
+            <configuration>
+              <prependGroupId>true</prependGroupId>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.apache.maven</groupId>
+                  <artifactId>maven-model</artifactId>
+                  <version>2.0.6</version>
+                </artifactItem>
+              </artifactItems>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
 </project>
diff --git a/src/it/projects/build-classpath/verify.bsh b/src/it/projects/copy-with-prependGroupId/verify.bsh
similarity index 53%
copy from src/it/projects/build-classpath/verify.bsh
copy to src/it/projects/copy-with-prependGroupId/verify.bsh
index 7b3b234..8018ef2 100644
--- a/src/it/projects/build-classpath/verify.bsh
+++ b/src/it/projects/copy-with-prependGroupId/verify.bsh
@@ -18,30 +18,21 @@
  */
 
 import java.io.*;
-import java.util.*;
 
-import org.codehaus.plexus.util.*;
+File libDir = new File( basedir, "target/dependency" );
 
-String classpath = FileUtils.fileRead( new File( basedir, "target/classpath.txt" ) );
+String[] expectedFiles = {
+    "org.apache.maven.maven-model-2.0.6.jar",
+};
 
-classpath = StringUtils.replace( classpath, "PREFIX/", "" );
-
-List actual = Arrays.asList( classpath.split( ":" ) );
-
-List expected = new ArrayList();
-expected.add( "maven-profile-2.0.6.jar" );
-expected.add( "maven-model-2.0.6.jar" );
-expected.add( "plexus-utils-1.4.1.jar" );
-expected.add( "plexus-container-default-1.0-alpha-9-stable-1.jar" );
-expected.add( "junit-3.8.1.jar" );
-
-System.out.println( "Checking classpath... " );
-System.out.println( "Actual  : " + actual );
-System.out.println( "Expected: " + expected );
-
-if ( !actual.equals( expected ) )
+for ( String expectedFile : expectedFiles )
 {
-    throw new Exception( "Unexpected classpath" );
+    File file = new File( libDir, expectedFile );
+    System.out.println( "Checking for existence of " + file );
+    if ( !file.isFile() )
+    {
+        throw new Exception( "Missing file " + file );
+    }
 }
 
 return true;