From e16b741b09e5817e38c517978f0c071e9a4c95d9 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 14 Oct 2021 14:08:52 +0200 Subject: [PATCH 1/5] Drop legacy Plugin used a lot of legacy code, misused Mojo test case and used old Junit 3.x TestCase, and missed some dependencies (junit mostly). --- maven-plugin-plugin/pom.xml | 32 +++++++++++++------ maven-plugin-tools-annotations/pom.xml | 5 --- maven-plugin-tools-api/pom.xml | 5 --- .../tools/plugin/util/PluginUtilsTest.java | 4 +-- maven-plugin-tools-generators/pom.xml | 19 +++++++---- .../plugin/generator/GeneratorUtilsTest.java | 14 ++++++-- maven-plugin-tools-java/pom.xml | 12 +++---- .../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, 87 insertions(+), 49 deletions(-) diff --git a/maven-plugin-plugin/pom.xml b/maven-plugin-plugin/pom.xml index 8b37b7942..d78200af6 100644 --- a/maven-plugin-plugin/pom.xml +++ b/maven-plugin-plugin/pom.xml @@ -102,6 +102,12 @@ org.apache.maven.doxia doxia-sink-api ${doxiaVersion} + + + org.codehaus.plexus + plexus-container-default + + org.apache.maven.doxia @@ -123,19 +129,24 @@ org.apache.maven maven-plugin-api + + compile org.apache.maven maven-model + provided org.apache.maven maven-repository-metadata ${mavenVersion} + provided org.apache.maven maven-artifact + provided @@ -151,19 +162,13 @@ plexus-utils - org.sonatype.sisu - sisu-inject-plexus - 1.4.2 + org.eclipse.sisu + org.eclipse.sisu.plexus + provided org.codehaus.plexus plexus-velocity - - - velocity - velocity - - @@ -172,7 +177,14 @@ plexus-build-api 0.0.7 - + + + + junit + junit + test + + org.apache.maven.plugin-tools diff --git a/maven-plugin-tools-annotations/pom.xml b/maven-plugin-tools-annotations/pom.xml index 92c9de85c..1a9e3ec55 100644 --- a/maven-plugin-tools-annotations/pom.xml +++ b/maven-plugin-tools-annotations/pom.xml @@ -75,11 +75,6 @@ - - org.sonatype.sisu - sisu-inject-plexus - 1.4.2 - org.codehaus.plexus plexus-archiver diff --git a/maven-plugin-tools-api/pom.xml b/maven-plugin-tools-api/pom.xml index 36eac5e90..78cffcea6 100644 --- a/maven-plugin-tools-api/pom.xml +++ b/maven-plugin-tools-api/pom.xml @@ -61,11 +61,6 @@ org.codehaus.plexus plexus-utils - - org.sonatype.sisu - sisu-inject-plexus - 1.4.2 - 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 a5c740b89..5b94fd1d6 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 @@ -19,14 +19,14 @@ * under the License. */ +import junit.framework.TestCase; import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; /** * @author jdcasey */ public class PluginUtilsTest - extends AbstractMojoTestCase + extends TestCase { public void testShouldTrimArtifactIdToFindPluginId() { diff --git a/maven-plugin-tools-generators/pom.xml b/maven-plugin-tools-generators/pom.xml index b85412719..e784974a9 100644 --- a/maven-plugin-tools-generators/pom.xml +++ b/maven-plugin-tools-generators/pom.xml @@ -62,12 +62,6 @@ org.codehaus.plexus plexus-velocity - - - velocity - velocity - - @@ -93,11 +87,22 @@ + + junit + junit + test + org.apache.maven.reporting maven-reporting-impl - 2.1 + 3.0.0 test + + + org.codehaus.plexus + plexus-container-default + + org.apache.maven.plugin-testing 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 d8d469ec3..6662aa497 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 @@ */ 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 void testShouldWriteDependencies() assertEquals( pattern, output ); } + @Test public void testMakeHtmlValid() { String javadoc = null; @@ -94,6 +99,7 @@ public void testMakeHtmlValid() assertEquals( javadoc, GeneratorUtils.makeHtmlValid( javadoc ) ); } + @Test public void testDecodeJavadocTags() { String javadoc = null; @@ -148,6 +154,7 @@ public void testDecodeJavadocTags() assertEquals( "label", GeneratorUtils.decodeJavadocTags( javadoc ) ); } + @Test public void testToText() throws Exception { @@ -179,6 +186,7 @@ public void testToText() assertEquals( "Generates something for the project.", GeneratorUtils.toText( javadoc ) ); } + @Test public void testIsMavenReport() throws Exception { @@ -194,7 +202,7 @@ public void testIsMavenReport() 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 77b546d7c..442a13b2a 100644 --- a/maven-plugin-tools-java/pom.xml +++ b/maven-plugin-tools-java/pom.xml @@ -58,12 +58,6 @@ org.codehaus.plexus plexus-component-annotations - - - junit - junit - - @@ -72,6 +66,12 @@ qdox + + + junit + junit + test + xmlunit xmlunit 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 3f3001fcc..73dfaaaf9 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 void testAnnotationInPlugin() { List results = extract( "source3" ); - assertNull( results ); + assertTrue( results.isEmpty() ); } /** @@ -253,7 +253,7 @@ public void testMethodReferenceInEnumConstructor() { List results = extract( "MPLUGIN-320" ); - assertNull( results ); + assertTrue( results.isEmpty() ); } @Test @@ -262,7 +262,7 @@ public void testEnumWithRegexPattern() { List 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 024f89900..42fde0ffb 100644 --- a/maven-script/maven-plugin-tools-model/pom.xml +++ b/maven-script/maven-plugin-tools-model/pom.xml @@ -44,11 +44,6 @@ org.codehaus.plexus plexus-utils - - org.sonatype.sisu - sisu-inject-plexus - 1.4.2 - junit junit diff --git a/maven-script/maven-script-ant/pom.xml b/maven-script/maven-script-ant/pom.xml index eaaebd534..4d7a8421d 100644 --- a/maven-script/maven-script-ant/pom.xml +++ b/maven-script/maven-script-ant/pom.xml @@ -50,6 +50,12 @@ under the License. org.codehaus.plexus plexus-ant-factory 1.0-alpha-2.1 + + + org.codehaus.plexus + plexus-container-default + + org.codehaus.plexus diff --git a/maven-script/maven-script-beanshell/pom.xml b/maven-script/maven-script-beanshell/pom.xml index 366d27c71..1e9bce017 100644 --- a/maven-script/maven-script-beanshell/pom.xml +++ b/maven-script/maven-script-beanshell/pom.xml @@ -40,6 +40,12 @@ under the License. org.codehaus.plexus plexus-bsh-factory 1.0-alpha-7 + + + org.codehaus.plexus + plexus-container-default + + bsh diff --git a/pom.xml b/pom.xml index 522502883..0425c535b 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ maven-parent org.apache.maven - 34 + 35-SNAPSHOT ../pom/maven/pom.xml @@ -92,9 +92,10 @@ 2.22.2 7 - 1.3 - 3.0 + 3.3.0 + 3.2.5 1.7.1 + 0.3.5 3.2.2 plugin-tools-archives/plugin-tools-LATEST 9.1 @@ -176,6 +177,11 @@ + + org.eclipse.sisu + org.eclipse.sisu.plexus + ${sisuVersion} + org.codehaus.plexus plexus-utils @@ -201,6 +207,16 @@ org.codehaus.plexus plexus-velocity 1.2 + + + org.codehaus.plexus + plexus-container-default + + + velocity + velocity + + From c4463955406dffae3b347c32fea53b14613cb4d9 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 14 Oct 2021 14:12:01 +0200 Subject: [PATCH 2/5] Rollback parent change --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0425c535b..037cb7386 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ maven-parent org.apache.maven - 35-SNAPSHOT + 34 ../pom/maven/pom.xml From 5176f01a8a42268ea684072c05929b95a4a390a2 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 14 Oct 2021 14:22:55 +0200 Subject: [PATCH 3/5] Make it junit4 --- .../apache/maven/tools/plugin/util/PluginUtilsTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 5b94fd1d6..f4d46b17e 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 @@ -19,15 +19,17 @@ * under the License. */ -import junit.framework.TestCase; import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; /** * @author jdcasey */ public class PluginUtilsTest - extends TestCase { + @Test public void testShouldTrimArtifactIdToFindPluginId() { assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-artifactId-plugin" ) ); @@ -38,6 +40,7 @@ public void testShouldTrimArtifactIdToFindPluginId() assertEquals( "plugin", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-plugin-plugin" ) ); } + @Test public void testShouldFindTwoScriptsWhenNoExcludesAreGiven() { String testScript = "test.txt"; @@ -50,6 +53,7 @@ public void testShouldFindTwoScriptsWhenNoExcludesAreGiven() assertEquals( 2, files.length ); } + @Test public void testShouldFindOneScriptsWhenAnExcludeIsGiven() { String testScript = "test.txt"; From b6d8a128b49acdaa5d4ca1e3ef91042147e7d772 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 14 Oct 2021 14:30:05 +0200 Subject: [PATCH 4/5] Add TODO --- maven-plugin-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-plugin-plugin/pom.xml b/maven-plugin-plugin/pom.xml index d78200af6..4fbdcdfef 100644 --- a/maven-plugin-plugin/pom.xml +++ b/maven-plugin-plugin/pom.xml @@ -129,7 +129,7 @@ org.apache.maven maven-plugin-api - + compile From 63e3ff7c8544f5d9d8e16b07559a7af6028c2a35 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 14 Oct 2021 14:32:57 +0200 Subject: [PATCH 5/5] Up junit as well --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 037cb7386..a6a843bca 100644 --- a/pom.xml +++ b/pom.xml @@ -258,7 +258,7 @@ junit junit - 4.13.1 + 4.13.2 test