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 14:24:53 UTC

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

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-dependency-plugin.git

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

    [MDEP-769] tests for verifying changing mojo default parameters
    
    Closes #167
---
 .../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;