You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2021/10/21 17:18:46 UTC

[maven-plugin-tools] branch master updated: [MPLUGIN-376] Drop legacy dependencies (#42)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new d57eaff  [MPLUGIN-376] Drop legacy dependencies (#42)
d57eaff is described below

commit d57eaff72823b0ee9b043d369b565f98c07ba4e5
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Thu Oct 21 19:18:39 2021 +0200

    [MPLUGIN-376] Drop legacy dependencies (#42)
    
    Plugin used a lot of legacy code, misused Mojo test case
    and used old Junit 3.x TestCase, and missed some
    dependencies (junit mostly).
    
    Changes:
    * drop use of Junit 3 TestCase, use Junit4 everywhere
    * fix misuses of AbstractMojoTestCase when it is NOT mojo being tested
    * add missing junit test dep where missing
    * drop legacy p-c-d, sisu using exclusions/replacements
    * align JavaMojoDescriptorExtractorTest.java for semantic difference: current Shim returns empty list instead of null when no components (for null safety). Assers updated but semantic is same: "there are no components discovered".
---
 maven-plugin-plugin/pom.xml                        | 32 +++++++++++++++-------
 maven-plugin-tools-annotations/pom.xml             |  5 ----
 maven-plugin-tools-api/pom.xml                     |  5 ----
 .../maven/tools/plugin/util/PluginUtilsTest.java   |  8 ++++--
 maven-plugin-tools-generators/pom.xml              | 19 ++++++++-----
 .../tools/plugin/generator/GeneratorUtilsTest.java | 14 ++++++++--
 maven-plugin-tools-java/pom.xml                    | 12 ++++----
 .../javadoc/JavaMojoDescriptorExtractorTest.java   |  6 ++--
 maven-script/maven-plugin-tools-model/pom.xml      |  5 ----
 maven-script/maven-script-ant/pom.xml              |  6 ++++
 maven-script/maven-script-beanshell/pom.xml        |  6 ++++
 pom.xml                                            | 22 +++++++++++++--
 12 files changed, 91 insertions(+), 49 deletions(-)

diff --git a/maven-plugin-plugin/pom.xml b/maven-plugin-plugin/pom.xml
index 807d368..22f988b 100644
--- a/maven-plugin-plugin/pom.xml
+++ b/maven-plugin-plugin/pom.xml
@@ -99,6 +99,12 @@
       <groupId>org.apache.maven.doxia</groupId>
       <artifactId>doxia-sink-api</artifactId>
       <version>${doxiaVersion}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-container-default</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.doxia</groupId>
@@ -120,19 +126,24 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
+      <!-- TODO: make this provided once 3.6.2+ maven-plugin-plugin is in use -->
+      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-model</artifactId>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-repository-metadata</artifactId>
       <version>${mavenVersion}</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-artifact</artifactId>
+      <scope>provided</scope>
     </dependency>
 
     <!-- shared -->
@@ -148,19 +159,13 @@
       <artifactId>plexus-utils</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.sonatype.sisu</groupId>
-      <artifactId>sisu-inject-plexus</artifactId>
-      <version>1.4.2</version>
+      <groupId>org.eclipse.sisu</groupId>
+      <artifactId>org.eclipse.sisu.plexus</artifactId>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-velocity</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>velocity</groupId>
-          <artifactId>velocity</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
 
     <!-- for m2e support: https://www.eclipse.org/m2e/documentation/m2e-making-maven-plugins-compat.html -->
@@ -169,7 +174,14 @@
       <artifactId>plexus-build-api</artifactId>
       <version>0.0.7</version>
     </dependency>
- 
+
+    <!-- tests -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
     <!-- needed for it tests -->
     <dependency>
       <groupId>org.apache.maven.plugin-tools</groupId>
diff --git a/maven-plugin-tools-annotations/pom.xml b/maven-plugin-tools-annotations/pom.xml
index aeb7cb2..733eb97 100644
--- a/maven-plugin-tools-annotations/pom.xml
+++ b/maven-plugin-tools-annotations/pom.xml
@@ -72,11 +72,6 @@
       </exclusions>
     </dependency>
     <dependency>
-      <groupId>org.sonatype.sisu</groupId>
-      <artifactId>sisu-inject-plexus</artifactId>
-      <version>1.4.2</version>
-    </dependency>
-    <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-archiver</artifactId>
     </dependency>
diff --git a/maven-plugin-tools-api/pom.xml b/maven-plugin-tools-api/pom.xml
index 36eac5e..78cffce 100644
--- a/maven-plugin-tools-api/pom.xml
+++ b/maven-plugin-tools-api/pom.xml
@@ -61,11 +61,6 @@
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.sonatype.sisu</groupId>
-      <artifactId>sisu-inject-plexus</artifactId>
-      <version>1.4.2</version>
-    </dependency>
 
     <!-- test -->
     <dependency>
diff --git a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java
index a5c740b..f4d46b1 100644
--- a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java
+++ b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java
@@ -20,14 +20,16 @@ package org.apache.maven.tools.plugin.util;
  */
 
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
 
 /**
  * @author jdcasey
  */
 public class PluginUtilsTest
-    extends AbstractMojoTestCase
 {
+    @Test
     public void testShouldTrimArtifactIdToFindPluginId()
     {
         assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-artifactId-plugin" ) );
@@ -38,6 +40,7 @@ public class PluginUtilsTest
         assertEquals( "plugin", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-plugin-plugin" ) );
     }
 
+    @Test
     public void testShouldFindTwoScriptsWhenNoExcludesAreGiven()
     {
         String testScript = "test.txt";
@@ -50,6 +53,7 @@ public class PluginUtilsTest
         assertEquals( 2, files.length );
     }
 
+    @Test
     public void testShouldFindOneScriptsWhenAnExcludeIsGiven()
     {
         String testScript = "test.txt";
diff --git a/maven-plugin-tools-generators/pom.xml b/maven-plugin-tools-generators/pom.xml
index b854127..e784974 100644
--- a/maven-plugin-tools-generators/pom.xml
+++ b/maven-plugin-tools-generators/pom.xml
@@ -62,12 +62,6 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-velocity</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>velocity</groupId>
-          <artifactId>velocity</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
 
     <!-- other -->
@@ -94,10 +88,21 @@
 
     <!-- test -->
     <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.apache.maven.reporting</groupId>
       <artifactId>maven-reporting-impl</artifactId>
-      <version>2.1</version>
+      <version>3.0.0</version>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-container-default</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.plugin-testing</groupId>
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/GeneratorUtilsTest.java b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/GeneratorUtilsTest.java
index d8d469e..6662aa4 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/GeneratorUtilsTest.java
+++ b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/GeneratorUtilsTest.java
@@ -20,21 +20,25 @@ package org.apache.maven.tools.plugin.generator;
  */
 
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.codehaus.plexus.component.repository.ComponentDependency;
 import org.codehaus.plexus.util.xml.CompactXMLWriter;
 import org.codehaus.plexus.util.xml.XMLWriter;
+import org.junit.Test;
 
 import java.io.StringWriter;
 import java.util.Collections;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 /**
  * @author jdcasey
  */
 public class GeneratorUtilsTest
-    extends AbstractMojoTestCase
 {
+    @Test
     public void testShouldWriteDependencies()
         throws Exception
     {
@@ -62,6 +66,7 @@ public class GeneratorUtilsTest
         assertEquals( pattern, output );
     }
 
+    @Test
     public void testMakeHtmlValid()
     {
         String javadoc = null;
@@ -94,6 +99,7 @@ public class GeneratorUtilsTest
         assertEquals( javadoc, GeneratorUtils.makeHtmlValid( javadoc ) );
     }
 
+    @Test
     public void testDecodeJavadocTags()
     {
         String javadoc = null;
@@ -148,6 +154,7 @@ public class GeneratorUtilsTest
         assertEquals( "label", GeneratorUtils.decodeJavadocTags( javadoc ) );
     }
 
+    @Test
     public void testToText()
         throws Exception
     {
@@ -179,6 +186,7 @@ public class GeneratorUtilsTest
         assertEquals( "Generates something for the project.", GeneratorUtils.toText( javadoc ) );
     }
 
+    @Test
     public void testIsMavenReport()
         throws Exception
     {
@@ -194,7 +202,7 @@ public class GeneratorUtilsTest
         String impl = "org.apache.maven.tools.plugin.generator.stubs.MavenReportStub";
 
         MavenProjectStub stub = new MavenProjectStub();
-        stub.setCompileSourceRoots( Collections.singletonList( getBasedir() + "/target/classes" ) );
+        stub.setCompileSourceRoots( Collections.singletonList( System.getProperty( "basedir" ) + "/target/classes" ) );
 
         assertTrue( GeneratorUtils.isMavenReport( impl, stub ) );
 
diff --git a/maven-plugin-tools-java/pom.xml b/maven-plugin-tools-java/pom.xml
index 77b546d..442a13b 100644
--- a/maven-plugin-tools-java/pom.xml
+++ b/maven-plugin-tools-java/pom.xml
@@ -58,12 +58,6 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-component-annotations</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>junit</groupId>
-          <artifactId>junit</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
 
     <!-- misc -->
@@ -72,6 +66,12 @@
       <artifactId>qdox</artifactId>
     </dependency>
 
+    <!-- test -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>xmlunit</groupId>
       <artifactId>xmlunit</artifactId>
diff --git a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java
index 3f3001f..73dfaaa 100644
--- a/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java
+++ b/maven-plugin-tools-java/src/test/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaMojoDescriptorExtractorTest.java
@@ -222,7 +222,7 @@ public class JavaMojoDescriptorExtractorTest
     {
         List<MojoDescriptor> results = extract( "source3" );
 
-        assertNull( results );
+        assertTrue( results.isEmpty() );
     }
 
     /**
@@ -253,7 +253,7 @@ public class JavaMojoDescriptorExtractorTest
     {
         List<MojoDescriptor> results = extract( "MPLUGIN-320" );
 
-        assertNull( results );
+        assertTrue( results.isEmpty() );
     }
 
     @Test
@@ -262,7 +262,7 @@ public class JavaMojoDescriptorExtractorTest
     {
         List<MojoDescriptor> results = extract( "MPLUGIN-290" );
 
-        assertNull( results );
+        assertTrue( results.isEmpty() );
     }
 
 }
diff --git a/maven-script/maven-plugin-tools-model/pom.xml b/maven-script/maven-plugin-tools-model/pom.xml
index 024f899..42fde0f 100644
--- a/maven-script/maven-plugin-tools-model/pom.xml
+++ b/maven-script/maven-plugin-tools-model/pom.xml
@@ -45,11 +45,6 @@
       <artifactId>plexus-utils</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.sonatype.sisu</groupId>
-      <artifactId>sisu-inject-plexus</artifactId>
-      <version>1.4.2</version>
-    </dependency>
-    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>
diff --git a/maven-script/maven-script-ant/pom.xml b/maven-script/maven-script-ant/pom.xml
index eaaebd5..4d7a842 100644
--- a/maven-script/maven-script-ant/pom.xml
+++ b/maven-script/maven-script-ant/pom.xml
@@ -50,6 +50,12 @@ under the License.
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-ant-factory</artifactId>
       <version>1.0-alpha-2.1</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-container-default</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
diff --git a/maven-script/maven-script-beanshell/pom.xml b/maven-script/maven-script-beanshell/pom.xml
index 366d27c..1e9bce0 100644
--- a/maven-script/maven-script-beanshell/pom.xml
+++ b/maven-script/maven-script-beanshell/pom.xml
@@ -40,6 +40,12 @@ under the License.
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-bsh-factory</artifactId>
       <version>1.0-alpha-7</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-container-default</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>bsh</groupId>
diff --git a/pom.xml b/pom.xml
index cb56dd8..186c11c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,9 +92,10 @@
   <properties>
     <surefire.version>2.22.2</surefire.version>
     <javaVersion>7</javaVersion>
-    <pluginTestingHarnessVersion>1.3</pluginTestingHarnessVersion>
-    <mavenVersion>3.2.2</mavenVersion>
+    <pluginTestingHarnessVersion>3.3.0</pluginTestingHarnessVersion>
+    <mavenVersion>3.2.5</mavenVersion>
     <antVersion>1.7.1</antVersion>
+    <sisuVersion>0.3.5</sisuVersion>
     <mavenInvokerPluginVersion>3.2.2</mavenInvokerPluginVersion>
     <maven.site.path>plugin-tools-archives/plugin-tools-LATEST</maven.site.path>
     <asmVersion>9.1</asmVersion>
@@ -172,6 +173,11 @@
       
       <!-- plexus -->
       <dependency>
+        <groupId>org.eclipse.sisu</groupId>
+        <artifactId>org.eclipse.sisu.plexus</artifactId>
+        <version>${sisuVersion}</version>
+      </dependency>
+      <dependency>
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-utils</artifactId>
         <version>3.3.0</version>
@@ -196,6 +202,16 @@
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-velocity</artifactId>
         <version>1.2</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>velocity</groupId>
+            <artifactId>velocity</artifactId>
+          </exclusion>
+        </exclusions>
       </dependency>
 
       <!-- other -->
@@ -237,7 +253,7 @@
       <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
-        <version>4.13.1</version>
+        <version>4.13.2</version>
         <scope>test</scope>
       </dependency>
     </dependencies>