You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/07/23 14:32:43 UTC
[maven-plugin-tools] branch master updated: [MPLUGIN-393] Upgrade to JUnit 5 and @Inject annotations
This is an automated email from the ASF dual-hosted git repository.
sjaranowski 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 f2859283 [MPLUGIN-393] Upgrade to JUnit 5 and @Inject annotations
f2859283 is described below
commit f28592835422eeb212421c2dd7e475ab09f9e73e
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon Feb 7 18:11:26 2022 +0100
[MPLUGIN-393] Upgrade to JUnit 5 and @Inject annotations
---
maven-plugin-plugin/pom.xml | 9 +++--
.../annotation-with-inheritance-from-deps/pom.xml | 6 ++--
.../it/annotation-with-inheritance-reactor/pom.xml | 6 ++--
.../pom.xml | 6 ++--
.../plugin/plugin/AbstractGeneratorMojoTest.java | 5 +--
maven-plugin-tools-annotations/pom.xml | 24 ++++++-------
.../JavaAnnotationsMojoDescriptorExtractor.java | 14 +++++---
.../scanner/DefaultMojoAnnotationsScanner.java | 6 +++-
.../annotations/TestAnnotationsReader.java | 34 +++++++++++-------
.../scanner/DefaultMojoAnnotationsScannerTest.java | 19 +++++-----
maven-plugin-tools-api/pom.xml | 4 +--
.../tools/plugin/scanner/DefaultMojoScanner.java | 5 +++
.../main/resources/META-INF/plexus/components.xml | 42 ----------------------
.../plugin/scanner/DefaultMojoScannerTest.java | 39 ++++++++++----------
.../maven/tools/plugin/util/PluginUtilsTest.java | 12 +++----
.../apache/maven/tools/plugin/util/TestUtils.java | 6 ++--
maven-plugin-tools-generators/pom.xml | 9 +++--
.../generator/AbstractGeneratorTestCase.java | 14 ++------
.../tools/plugin/generator/GeneratorUtilsTest.java | 23 ++++++------
.../generator/PluginDescriptorGeneratorTest.java | 6 ++++
.../plugin/generator/PluginHelpGeneratorTest.java | 12 +++++--
maven-plugin-tools-java/pom.xml | 18 +++-------
.../JavaJavadocMojoDescriptorExtractor.java | 7 ++--
.../javadoc/JavaMojoDescriptorExtractorTest.java | 38 ++++++++++----------
maven-script/maven-plugin-tools-ant/pom.xml | 24 +++----------
.../extractor/ant/AntMojoDescriptorExtractor.java | 9 ++---
.../ant/AntMojoDescriptorExtractorTest.java | 27 +++++++-------
maven-script/maven-plugin-tools-beanshell/pom.xml | 20 ++---------
.../BeanshellMojoDescriptorExtractor.java | 11 +++---
maven-script/maven-plugin-tools-model/pom.xml | 4 +--
.../extractor/model/PluginMetadataParserTest.java | 18 +++++-----
maven-script/maven-script-ant/pom.xml | 9 +++--
.../maven/script/ant/AntMojoWrapperTest.java | 29 ++++++---------
pom.xml | 36 ++++++++-----------
34 files changed, 249 insertions(+), 302 deletions(-)
diff --git a/maven-plugin-plugin/pom.xml b/maven-plugin-plugin/pom.xml
index 60f762c4..f1250ff9 100644
--- a/maven-plugin-plugin/pom.xml
+++ b/maven-plugin-plugin/pom.xml
@@ -181,8 +181,13 @@
<!-- tests -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml
index 3cfdfdd2..8a977b8e 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/pom.xml
@@ -58,9 +58,9 @@ under the License.
</dependency>
<dependency>
<!-- dependency of org.apache.maven.plugin-tools:maven-plugin-tools-annotations:@project.version@:jar:tests -->
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.2</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>5.8.2</version>
</dependency>
<dependency>
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml
index deb3b6c6..713ce85f 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/pom.xml
@@ -56,9 +56,9 @@ under the License.
</dependency>
<dependency>
<!-- dependency of org.apache.maven.plugin-tools:maven-plugin-tools-annotations:@project.version@:jar:tests -->
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.2</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>5.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
diff --git a/maven-plugin-plugin/src/it/mplugin-372-annotation-with-inheritance-from-provided-deps/pom.xml b/maven-plugin-plugin/src/it/mplugin-372-annotation-with-inheritance-from-provided-deps/pom.xml
index a00cb1b0..0f6949cd 100644
--- a/maven-plugin-plugin/src/it/mplugin-372-annotation-with-inheritance-from-provided-deps/pom.xml
+++ b/maven-plugin-plugin/src/it/mplugin-372-annotation-with-inheritance-from-provided-deps/pom.xml
@@ -59,9 +59,9 @@ under the License.
</dependency>
<dependency>
<!-- dependency of org.apache.maven.plugin-tools:maven-plugin-tools-annotations:@project.version@:jar:tests -->
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.2</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>5.8.2</version>
</dependency>
<dependency>
diff --git a/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojoTest.java b/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojoTest.java
index d1e8c3be..5c363304 100644
--- a/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojoTest.java
+++ b/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojoTest.java
@@ -23,12 +23,13 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.is;
import org.apache.maven.project.MavenProject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+// at least one test class must be public for test-javadoc report
public class AbstractGeneratorMojoTest
{
@Test
- public void defaultGoalPrefix()
+ void defaultGoalPrefix()
{
assertThat( AbstractGeneratorMojo.getDefaultGoalPrefix( newProject( null, "maven-plugin-plugin" ) ),
is( "plugin" ) );
diff --git a/maven-plugin-tools-annotations/pom.xml b/maven-plugin-tools-annotations/pom.xml
index b53e0938..8cd6da1d 100644
--- a/maven-plugin-tools-annotations/pom.xml
+++ b/maven-plugin-tools-annotations/pom.xml
@@ -62,14 +62,9 @@
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-annotations</artifactId>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.plexus</artifactId>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@@ -92,8 +87,13 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -116,10 +116,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
index ca68e321..a4b5f6d4 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java
@@ -19,6 +19,10 @@ package org.apache.maven.tools.plugin.extractor.annotations;
* under the License.
*/
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
@@ -63,7 +67,6 @@ import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
-import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.StringUtils;
@@ -80,19 +83,20 @@ import com.thoughtworks.qdox.model.JavaField;
* @author Olivier Lamy
* @since 3.0
*/
-@Component( role = MojoDescriptorExtractor.class, hint = "java-annotations" )
+@Named( "java-annotations" )
+@Singleton
public class JavaAnnotationsMojoDescriptorExtractor
extends AbstractLogEnabled
implements MojoDescriptorExtractor
{
- @org.codehaus.plexus.component.annotations.Requirement
+ @Inject
private MojoAnnotationsScanner mojoAnnotationsScanner;
- @org.codehaus.plexus.component.annotations.Requirement
+ @Inject
private RepositorySystem repositorySystem;
- @org.codehaus.plexus.component.annotations.Requirement
+ @Inject
private ArchiverManager archiverManager;
@Override
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java
index 8e664d94..0407b8ea 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java
@@ -19,6 +19,9 @@ package org.apache.maven.tools.plugin.extractor.annotations.scanner;
* under the License.
*/
+import javax.inject.Named;
+import javax.inject.Singleton;
+
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Execute;
@@ -56,7 +59,8 @@ import java.util.zip.ZipInputStream;
* @author Olivier Lamy
* @since 3.0
*/
-@org.codehaus.plexus.component.annotations.Component( role = MojoAnnotationsScanner.class )
+@Named
+@Singleton
public class DefaultMojoAnnotationsScanner
extends AbstractLogEnabled
implements MojoAnnotationsScanner
diff --git a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java
index 47b2c7ed..41fd2474 100644
--- a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java
+++ b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/TestAnnotationsReader.java
@@ -19,6 +19,14 @@ package org.apache.maven.tools.plugin.extractor.annotations;
* under the License.
*/
+import javax.inject.Inject;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
@@ -28,27 +36,29 @@ import org.apache.maven.tools.plugin.extractor.annotations.datamodel.ParameterAn
import org.apache.maven.tools.plugin.extractor.annotations.scanner.MojoAnnotatedClass;
import org.apache.maven.tools.plugin.extractor.annotations.scanner.MojoAnnotationsScanner;
import org.apache.maven.tools.plugin.extractor.annotations.scanner.MojoAnnotationsScannerRequest;
-import org.codehaus.plexus.PlexusTestCase;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
+import org.codehaus.plexus.testing.PlexusTest;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Olivier Lamy
*/
-public class TestAnnotationsReader
- extends PlexusTestCase
+@PlexusTest
+class TestAnnotationsReader
{
- public void testReadMojoClass()
+
+ @Inject
+ MojoAnnotationsScanner mojoAnnotationsScanner;
+
+ @Test
+ void testReadMojoClass()
throws Exception
{
- MojoAnnotationsScanner mojoAnnotationsScanner = (MojoAnnotationsScanner) lookup( MojoAnnotationsScanner.ROLE );
-
MojoAnnotationsScannerRequest request = new MojoAnnotationsScannerRequest();
request.setClassesDirectories( Collections.singletonList( new File( getBasedir(), "target/test-classes" ) ) );
request.setIncludePatterns( Arrays.asList( "**/FooMojo.class" ) );
diff --git a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScannerTest.java b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScannerTest.java
index 401f4e20..87dfc4e5 100644
--- a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScannerTest.java
+++ b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScannerTest.java
@@ -19,41 +19,38 @@ package org.apache.maven.tools.plugin.extractor.annotations.scanner;
* under the License.
*/
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-
import java.io.File;
import java.io.IOException;
-import java.net.URL;
import java.util.Collections;
import java.util.Map;
import org.apache.maven.tools.plugin.extractor.ExtractionException;
-import org.apache.maven.tools.plugin.extractor.annotations.AbstractFooMojo;
import org.apache.maven.tools.plugin.extractor.annotations.DeprecatedMojo;
-import org.apache.maven.tools.plugin.extractor.annotations.FooMojo;
import org.codehaus.plexus.logging.Logger;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
-public class DefaultMojoAnnotationsScannerTest
+class DefaultMojoAnnotationsScannerTest
{
private DefaultMojoAnnotationsScanner scanner = new DefaultMojoAnnotationsScanner();
@Test
- public void testSkipModuleInfoClassInArchive() throws Exception
+ void testSkipModuleInfoClassInArchive() throws Exception
{
scanner.scanArchive( new File( "target/test-classes/java9-module.jar" ), null, false );
}
@Test
- public void testJava8Annotations() throws Exception
+ void testJava8Annotations() throws Exception
{
scanner.enableLogging( mock( Logger.class ) );
scanner.scanArchive( new File( "target/test-classes/java8-annotations.jar" ), null, false );
}
@Test
- public void scanDeprecatedMojoAnnotatins() throws ExtractionException, IOException
+ void scanDeprecatedMojoAnnotatins() throws ExtractionException, IOException
{
File directoryToScan = new File( DeprecatedMojo.class.getResource( "" ).getFile() );
diff --git a/maven-plugin-tools-api/pom.xml b/maven-plugin-tools-api/pom.xml
index 75ab3779..dbc279aa 100644
--- a/maven-plugin-tools-api/pom.xml
+++ b/maven-plugin-tools-api/pom.xml
@@ -69,8 +69,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java
index 67dc5dcd..f53484da 100644
--- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java
+++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScanner.java
@@ -19,6 +19,9 @@ package org.apache.maven.tools.plugin.scanner;
* under the License.
*/
+import javax.inject.Inject;
+import javax.inject.Named;
+
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.tools.plugin.PluginToolsRequest;
@@ -37,6 +40,7 @@ import java.util.Set;
/**
* @author jdcasey
*/
+@Named
public class DefaultMojoScanner
extends AbstractLogEnabled
implements MojoScanner
@@ -54,6 +58,7 @@ public class DefaultMojoScanner
*
* @param extractors not null
*/
+ @Inject
public DefaultMojoScanner( Map<String, MojoDescriptorExtractor> extractors )
{
this.mojoDescriptorExtractors = extractors;
diff --git a/maven-plugin-tools-api/src/main/resources/META-INF/plexus/components.xml b/maven-plugin-tools-api/src/main/resources/META-INF/plexus/components.xml
deleted file mode 100644
index bea45db2..00000000
--- a/maven-plugin-tools-api/src/main/resources/META-INF/plexus/components.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<!--
- ~ 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>
-
- <!--
- |
- | MojoScanner, used to scan all types of mojo sources to extract descriptor
- | information using various MojoDescriptorExtractor's
- |
- -->
- <component>
- <role>org.apache.maven.tools.plugin.scanner.MojoScanner</role>
- <implementation>org.apache.maven.tools.plugin.scanner.DefaultMojoScanner</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- <requirements>
- <requirement>
- <role>org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor</role>
- <field-name>mojoDescriptorExtractors</field-name>
- </requirement>
- </requirements>
- </component>
-
- </components>
-</component-set>
\ No newline at end of file
diff --git a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScannerTest.java b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScannerTest.java
index 2c365e6c..746ebc16 100644
--- a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScannerTest.java
+++ b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/scanner/DefaultMojoScannerTest.java
@@ -28,8 +28,8 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
import org.apache.maven.tools.plugin.extractor.ExtractionException;
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.Arrays;
@@ -41,14 +41,14 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author jdcasey
*/
-public class DefaultMojoScannerTest
+class DefaultMojoScannerTest
{
private Map<String, MojoDescriptorExtractor> extractors;
@@ -60,8 +60,8 @@ public class DefaultMojoScannerTest
private MavenProject project;
- @Before
- public void setUp()
+ @BeforeEach
+ void setUp()
{
extractors = new HashMap<>();
extractors.put( "one", new ScannerTestExtractor( "one" ) );
@@ -81,7 +81,7 @@ public class DefaultMojoScannerTest
}
@Test
- public void testUnspecifiedExtractors()
+ void testUnspecifiedExtractors()
throws Exception
{
PluginDescriptor pluginDescriptor = createPluginDescriptor();
@@ -92,7 +92,7 @@ public class DefaultMojoScannerTest
}
@Test
- public void testSpecifiedExtractors()
+ void testSpecifiedExtractors()
throws Exception
{
Set<String> activeExtractors = new HashSet<>();
@@ -110,7 +110,7 @@ public class DefaultMojoScannerTest
}
@Test
- public void testAllExtractorsThroughNull()
+ void testAllExtractorsThroughNull()
throws Exception
{
PluginDescriptor pluginDescriptor = createPluginDescriptor();
@@ -122,12 +122,12 @@ public class DefaultMojoScannerTest
}
@Test
- public void testNoExtractorsThroughEmptySet()
+ void testNoExtractorsThroughEmptySet()
throws Exception
{
PluginDescriptor pluginDescriptor = createPluginDescriptor();
- scanner.setActiveExtractors( Collections.<String>emptySet() );
+ scanner.setActiveExtractors( Collections.emptySet() );
try
{
scanner.populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
@@ -138,11 +138,11 @@ public class DefaultMojoScannerTest
// Ok
}
- checkResult( pluginDescriptor, Collections.<String>emptySet() );
+ checkResult( pluginDescriptor, Collections.emptySet() );
}
@Test
- public void testUnknownExtractor()
+ void testUnknownExtractor()
throws Exception
{
Set<String> activeExtractors = new HashSet<>();
@@ -162,7 +162,7 @@ public class DefaultMojoScannerTest
// Ok
}
- checkResult( pluginDescriptor, Collections.<String>emptySet() );
+ checkResult( pluginDescriptor, Collections.emptySet() );
}
private PluginDescriptor createPluginDescriptor()
@@ -196,11 +196,10 @@ public class DefaultMojoScannerTest
for ( MojoDescriptor desc : descriptors )
{
assertEquals( pluginDescriptor, desc.getPluginDescriptor() );
- assertTrue( "Unexpected goal in PluginDescriptor: " + desc.getGoal(),
- remainingGoals.remove( desc.getGoal() ) );
+ assertTrue( remainingGoals.remove( desc.getGoal() ), "Unexpected goal in PluginDescriptor: " + desc.getGoal() );
}
- assertEquals( "Expected goals missing from PluginDescriptor: " + remainingGoals, 0, remainingGoals.size() );
+ assertEquals( 0, remainingGoals.size(), "Expected goals missing from PluginDescriptor: " + remainingGoals );
}
-}
\ No newline at end of file
+}
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 f4d46b17..3ec5253a 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,17 +20,17 @@ package org.apache.maven.tools.plugin.util;
*/
import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author jdcasey
*/
-public class PluginUtilsTest
+class PluginUtilsTest
{
@Test
- public void testShouldTrimArtifactIdToFindPluginId()
+ void testShouldTrimArtifactIdToFindPluginId()
{
assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-artifactId-plugin" ) );
assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-plugin-artifactId" ) );
@@ -41,7 +41,7 @@ public class PluginUtilsTest
}
@Test
- public void testShouldFindTwoScriptsWhenNoExcludesAreGiven()
+ void testShouldFindTwoScriptsWhenNoExcludesAreGiven()
{
String testScript = "test.txt";
@@ -54,7 +54,7 @@ public class PluginUtilsTest
}
@Test
- public void testShouldFindOneScriptsWhenAnExcludeIsGiven()
+ void testShouldFindOneScriptsWhenAnExcludeIsGiven()
{
String testScript = "test.txt";
diff --git a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/TestUtils.java b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/TestUtils.java
index b96d871a..a94dac2d 100644
--- a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/TestUtils.java
+++ b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/TestUtils.java
@@ -19,13 +19,13 @@ package org.apache.maven.tools.plugin.util;
* under the License.
*/
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author jdcasey
@@ -34,7 +34,7 @@ public class TestUtils
{
@Test
- public void testDirnameFunction_METATEST() throws UnsupportedEncodingException
+ void testDirnameFunction_METATEST() throws UnsupportedEncodingException
{
String classname = getClass().getName().replace( '.', '/' ) + ".class";
String basedir = TestUtils.dirname( classname );
diff --git a/maven-plugin-tools-generators/pom.xml b/maven-plugin-tools-generators/pom.xml
index bab7ca7f..88ef51eb 100644
--- a/maven-plugin-tools-generators/pom.xml
+++ b/maven-plugin-tools-generators/pom.xml
@@ -88,8 +88,13 @@
<!-- test -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
index b138f4c9..c3a43c35 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
+++ b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/AbstractGeneratorTestCase.java
@@ -27,9 +27,9 @@ import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
-import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.component.repository.ComponentDependency;
import org.codehaus.plexus.util.FileUtils;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.lang.reflect.Constructor;
@@ -42,20 +42,12 @@ import java.util.List;
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
*/
public abstract class AbstractGeneratorTestCase
- extends PlexusTestCase
{
protected Generator generator;
- protected String basedir;
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
- basedir = System.getProperty( "basedir" );
- }
+ protected String basedir = System.getProperty( "basedir" );
+ @Test
public void testGenerator()
throws Exception
{
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 bb5a30d0..a35ebdf7 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
@@ -31,19 +31,19 @@ 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 org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author jdcasey
*/
-public class GeneratorUtilsTest
+class GeneratorUtilsTest
{
@Test
- public void testShouldWriteDependencies()
+ void testShouldWriteDependencies()
throws Exception
{
ComponentDependency dependency = new ComponentDependency();
@@ -71,7 +71,7 @@ public class GeneratorUtilsTest
}
@Test
- public void testMakeHtmlValid()
+ void testMakeHtmlValid()
{
String javadoc = null;
assertEquals( "", GeneratorUtils.makeHtmlValid( javadoc ) );
@@ -104,7 +104,7 @@ public class GeneratorUtilsTest
}
@Test
- public void testDecodeJavadocTags()
+ void testDecodeJavadocTags()
{
String javadoc = null;
assertEquals( "", GeneratorUtils.decodeJavadocTags( javadoc ) );
@@ -159,7 +159,7 @@ public class GeneratorUtilsTest
}
@Test
- public void testToText()
+ void testToText()
throws Exception
{
String javadoc = null;
@@ -191,7 +191,7 @@ public class GeneratorUtilsTest
}
@Test
- public void testIsMavenReport()
+ void testIsMavenReport()
throws Exception
{
try
@@ -215,7 +215,7 @@ public class GeneratorUtilsTest
}
@Test
- public void testExcludeProvidedScopeFormComponentDependencies()
+ void testExcludeProvidedScopeFormComponentDependencies()
{
Artifact a1 = new DefaultArtifact( "g", "a1", "1.0", Artifact.SCOPE_COMPILE, "jar", "", null );
@@ -239,5 +239,4 @@ public class GeneratorUtilsTest
assertEquals( a3.getVersion(), componentDependency2.getVersion() );
assertEquals( a3.getType(), componentDependency2.getType() );
}
-
}
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java
index 870466dc..1b73f4af 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java
+++ b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java
@@ -24,6 +24,7 @@ import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
import org.codehaus.plexus.component.repository.ComponentDependency;
+import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.util.ReaderFactory;
import java.io.BufferedReader;
@@ -34,9 +35,14 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
*/
+@PlexusTest
public class PluginDescriptorGeneratorTest
extends AbstractGeneratorTestCase
{
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
index ce4f9195..e82453d0 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
+++ b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
@@ -19,22 +19,28 @@ package org.apache.maven.tools.plugin.generator;
* under the License.
*/
+import javax.inject.Inject;
+
+import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.velocity.VelocityComponent;
/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
+@PlexusTest
public class PluginHelpGeneratorTest
extends AbstractGeneratorTestCase
{
+
+ @Inject
+ VelocityComponent velocityComponent;
+
// inherits tests from base class
@Override
protected void setupGenerator()
throws Exception
{
-
- generator =
- new PluginHelpGenerator().setVelocityComponent( (VelocityComponent) lookup( VelocityComponent.ROLE ) );
+ generator = new PluginHelpGenerator().setVelocityComponent( velocityComponent );
}
}
diff --git a/maven-plugin-tools-java/pom.xml b/maven-plugin-tools-java/pom.xml
index b3c4469d..2c4db575 100644
--- a/maven-plugin-tools-java/pom.xml
+++ b/maven-plugin-tools-java/pom.xml
@@ -56,8 +56,9 @@
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-annotations</artifactId>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.plexus</artifactId>
+ <scope>compile</scope>
</dependency>
<!-- misc -->
@@ -68,8 +69,8 @@
<!-- test -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -80,13 +81,4 @@
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- </plugin>
- </plugins>
- </build>
-
</project>
diff --git a/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java b/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java
index a4418884..6602011b 100644
--- a/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java
+++ b/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/javadoc/JavaJavadocMojoDescriptorExtractor.java
@@ -19,6 +19,9 @@ package org.apache.maven.tools.plugin.extractor.javadoc;
* under the License.
*/
+import javax.inject.Named;
+import javax.inject.Singleton;
+
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
@@ -41,7 +44,6 @@ import org.apache.maven.tools.plugin.PluginToolsRequest;
import org.apache.maven.tools.plugin.extractor.ExtractionException;
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
import org.apache.maven.tools.plugin.util.PluginUtils;
-import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.StringUtils;
@@ -62,7 +64,8 @@ import com.thoughtworks.qdox.model.JavaType;
*
* @see org.apache.maven.plugin.descriptor.MojoDescriptor
*/
-@Component( role = MojoDescriptorExtractor.class, hint = "java-javadoc" )
+@Named( "java-javadoc" )
+@Singleton
public class JavaJavadocMojoDescriptorExtractor
extends AbstractLogEnabled
implements MojoDescriptorExtractor, JavadocMojoAnnotation
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 73dfaaaf..b804d2f8 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
@@ -44,21 +44,23 @@ import org.codehaus.plexus.util.FileUtils;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author jdcasey
*/
+// at least one test class must be public for test-javadoc report
public class JavaMojoDescriptorExtractorTest
{
private File root;
- @Before
- public void setUp()
+ @BeforeEach
+ void setUp()
{
File sourceFile = fileOf( "dir-flag.txt" );
root = sourceFile.getParentFile();
@@ -151,10 +153,7 @@ public class JavaMojoDescriptorExtractorTest
Diff diff = XMLUnit.compareXML( expected, actual );
- if ( !diff.identical() )
- {
- fail( "generated plugin.xml is not identical as plugin-expected.xml for " + directory + ": " + diff );
- }
+ assertTrue( diff.identical(), "generated plugin.xml is not identical as plugin-expected.xml for " + directory + ": " + diff );
}
/**
@@ -171,16 +170,16 @@ public class JavaMojoDescriptorExtractorTest
}
@Test
- public void testShouldFindTwoMojoDescriptorsInTestSourceDirectory()
+ void testShouldFindTwoMojoDescriptorsInTestSourceDirectory()
throws Exception
{
List<MojoDescriptor> results = extract( "source" );
- assertEquals( "Extracted mojos", 2, results.size() );
+ assertEquals( 2, results.size(), "Extracted mojos" );
}
@Test
- public void testShouldPropagateImplementationParameter()
+ void testShouldPropagateImplementationParameter()
throws Exception
{
List<MojoDescriptor> results = extract( "source2" );
@@ -195,11 +194,11 @@ public class JavaMojoDescriptorExtractorTest
Parameter parameter = parameters.get( 0 );
- assertEquals( "Implementation parameter", "source2.sub.MyBla", parameter.getImplementation() );
+ assertEquals( "source2.sub.MyBla", parameter.getImplementation(), "Implementation parameter" );
}
@Test
- public void testMaven30Parameters()
+ void testMaven30Parameters()
throws Exception
{
List<MojoDescriptor> results = extract( "source2" );
@@ -217,7 +216,7 @@ public class JavaMojoDescriptorExtractorTest
* @throws Exception
*/
@Test
- public void testAnnotationInPlugin()
+ void testAnnotationInPlugin()
throws Exception
{
List<MojoDescriptor> results = extract( "source3" );
@@ -230,7 +229,7 @@ public class JavaMojoDescriptorExtractorTest
* generics.
*/
@Test
- public void testJava15SyntaxParsing()
+ void testJava15SyntaxParsing()
throws Exception
{
List<MojoDescriptor> results = extract( "java-1.5" );
@@ -239,7 +238,7 @@ public class JavaMojoDescriptorExtractorTest
}
@Test
- public void testSingleTypeImportWithFullyQualifiedClassName()
+ void testSingleTypeImportWithFullyQualifiedClassName()
throws Exception
{
List<MojoDescriptor> results = extract( "MPLUGIN-314" );
@@ -248,7 +247,7 @@ public class JavaMojoDescriptorExtractorTest
}
@Test
- public void testMethodReferenceInEnumConstructor()
+ void testMethodReferenceInEnumConstructor()
throws Exception
{
List<MojoDescriptor> results = extract( "MPLUGIN-320" );
@@ -257,12 +256,11 @@ public class JavaMojoDescriptorExtractorTest
}
@Test
- public void testEnumWithRegexPattern()
+ void testEnumWithRegexPattern()
throws Exception
{
List<MojoDescriptor> results = extract( "MPLUGIN-290" );
assertTrue( results.isEmpty() );
}
-
}
diff --git a/maven-script/maven-plugin-tools-ant/pom.xml b/maven-script/maven-plugin-tools-ant/pom.xml
index 6faa83bc..77d19ad6 100644
--- a/maven-script/maven-plugin-tools-ant/pom.xml
+++ b/maven-script/maven-plugin-tools-ant/pom.xml
@@ -44,8 +44,8 @@
<artifactId>maven-plugin-tools-model</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
@@ -55,24 +55,10 @@
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-annotations</artifactId>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.plexus</artifactId>
+ <scope>compile</scope>
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- </plugin>
- </plugins>
- </build>
-
</project>
diff --git a/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java b/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java
index 062369b2..bee647ec 100644
--- a/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java
+++ b/maven-script/maven-plugin-tools-ant/src/main/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractor.java
@@ -19,6 +19,9 @@ package org.apache.maven.tools.plugin.extractor.ant;
* under the License.
*/
+import javax.inject.Named;
+import javax.inject.Singleton;
+
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
@@ -34,10 +37,8 @@ import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.tools.plugin.PluginToolsRequest;
import org.apache.maven.tools.plugin.extractor.AbstractScriptedMojoDescriptorExtractor;
import org.apache.maven.tools.plugin.extractor.ExtractionException;
-import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
import org.apache.maven.tools.plugin.extractor.model.PluginMetadataParseException;
import org.apache.maven.tools.plugin.extractor.model.PluginMetadataParser;
-import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.repository.ComponentRequirement;
import org.codehaus.plexus.util.StringUtils;
@@ -46,11 +47,11 @@ import org.codehaus.plexus.util.StringUtils;
*
* @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
*/
-@Component( role = MojoDescriptorExtractor.class, hint = "ant" )
@Deprecated
+@Named( "ant" )
+@Singleton
public class AntMojoDescriptorExtractor
extends AbstractScriptedMojoDescriptorExtractor
- implements MojoDescriptorExtractor
{
/** Default metadata file extension */
private static final String METADATA_FILE_EXTENSION = ".mojos.xml";
diff --git a/maven-script/maven-plugin-tools-ant/src/test/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractorTest.java b/maven-script/maven-plugin-tools-ant/src/test/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractorTest.java
index c11f23a7..66346079 100644
--- a/maven-script/maven-plugin-tools-ant/src/test/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractorTest.java
+++ b/maven-script/maven-plugin-tools-ant/src/test/java/org/apache/maven/tools/plugin/extractor/ant/AntMojoDescriptorExtractorTest.java
@@ -38,15 +38,19 @@ import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
import org.apache.maven.tools.plugin.PluginToolsRequest;
import org.apache.maven.tools.plugin.extractor.ExtractionException;
import org.codehaus.plexus.component.repository.ComponentRequirement;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+// at least one test class must be public for test-javadoc report
public class AntMojoDescriptorExtractorTest
{
@Test
- public void testBasicMojoExtraction_CheckInjectedParametersAndRequirements()
+ void testBasicMojoExtraction_CheckInjectedParametersAndRequirements()
throws InvalidPluginDescriptorException, ExtractionException
{
Map<String, Set<File>> scriptMap = buildTestMap( "basic" );
@@ -82,11 +86,11 @@ public class AntMojoDescriptorExtractorTest
paramMap.put( param.getName(), param );
}
- assertNotNull( "Mojo descriptor: " + desc.getGoal() + " is missing 'basedir' parameter.", paramMap.get( "basedir" ) );
- assertNotNull( "Mojo descriptor: " + desc.getGoal() + " is missing 'messageLevel' parameter.", paramMap.get( "messageLevel" ) );
- assertNotNull( "Mojo descriptor: " + desc.getGoal() + " is missing 'project' parameter.", paramMap.get( "project" ) );
- assertNotNull( "Mojo descriptor: " + desc.getGoal() + " is missing 'session' parameter.", paramMap.get( "session" ) );
- assertNotNull( "Mojo descriptor: " + desc.getGoal() + " is missing 'mojoExecution' parameter.", paramMap.get( "mojoExecution" ) );
+ assertNotNull( paramMap.get( "basedir" ), "Mojo descriptor: " + desc.getGoal() + " is missing 'basedir' parameter." );
+ assertNotNull( paramMap.get( "messageLevel" ), "Mojo descriptor: " + desc.getGoal() + " is missing 'messageLevel' parameter." );
+ assertNotNull( paramMap.get( "project" ), "Mojo descriptor: " + desc.getGoal() + " is missing 'project' parameter." );
+ assertNotNull( paramMap.get( "session" ), "Mojo descriptor: " + desc.getGoal() + " is missing 'session' parameter." );
+ assertNotNull( paramMap.get( "mojoExecution" ), "Mojo descriptor: " + desc.getGoal() + " is missing 'mojoExecution' parameter." );
List<ComponentRequirement> components = desc.getRequirements();
@@ -94,7 +98,7 @@ public class AntMojoDescriptorExtractorTest
assertEquals( 1, components.size() );
ComponentRequirement req = components.get( 0 );
- assertEquals( "Mojo descriptor: " + desc.getGoal() + " is missing 'PathTranslator' component requirement.", PathTranslator.class.getName(), req.getRole() );
+ assertEquals( PathTranslator.class.getName(), req.getRole(), "Mojo descriptor: " + desc.getGoal() + " is missing 'PathTranslator' component requirement." );
}
}
@@ -106,10 +110,7 @@ public class AntMojoDescriptorExtractorTest
ClassLoader cloader = Thread.currentThread().getContextClassLoader();
URL mojosXmlUrl = cloader.getResource( resourceDirName + "/test.mojos.xml" );
- if ( mojosXmlUrl == null )
- {
- fail( "No classpath resource named: '" + resourceDirName + "/test.mojos.xml' could be found." );
- }
+ assertNotNull( mojosXmlUrl, "No classpath resource named: '" + resourceDirName + "/test.mojos.xml' could be found." );
File mojosXml = Paths.get( mojosXmlUrl.toURI() ).toFile();
File dir = mojosXml.getParentFile();
diff --git a/maven-script/maven-plugin-tools-beanshell/pom.xml b/maven-script/maven-plugin-tools-beanshell/pom.xml
index 0d0b5c01..c1d69cec 100644
--- a/maven-script/maven-plugin-tools-beanshell/pom.xml
+++ b/maven-script/maven-plugin-tools-beanshell/pom.xml
@@ -44,14 +44,9 @@
<artifactId>maven-plugin-api</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-annotations</artifactId>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>org.eclipse.sisu.plexus</artifactId>
+ <scope>compile</scope>
</dependency>
<!-- misc -->
@@ -62,13 +57,4 @@
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- </plugin>
- </plugins>
- </build>
-
</project>
diff --git a/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java b/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
index a688fdcd..bce940dd 100644
--- a/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
+++ b/maven-script/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
@@ -19,6 +19,9 @@ package org.apache.maven.tools.plugin.extractor.beanshell;
* under the License.
*/
+import javax.inject.Named;
+import javax.inject.Singleton;
+
import static java.nio.charset.StandardCharsets.UTF_8;
import bsh.EvalError;
@@ -28,8 +31,6 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.tools.plugin.PluginToolsRequest;
import org.apache.maven.tools.plugin.extractor.AbstractScriptedMojoDescriptorExtractor;
import org.apache.maven.tools.plugin.extractor.ExtractionException;
-import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
-import org.codehaus.plexus.component.annotations.Component;
import java.io.File;
import java.io.InputStreamReader;
@@ -44,10 +45,10 @@ import java.util.Set;
* @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
*/
@Deprecated
-@Component( role = MojoDescriptorExtractor.class, hint = "bsh" )
+@Named( "bsh" )
+@Singleton
public class BeanshellMojoDescriptorExtractor
extends AbstractScriptedMojoDescriptorExtractor
- implements MojoDescriptorExtractor
{
/**
* {@inheritDoc}
@@ -132,4 +133,4 @@ public class BeanshellMojoDescriptorExtractor
return mojoDescriptor;
}
-}
\ No newline at end of file
+}
diff --git a/maven-script/maven-plugin-tools-model/pom.xml b/maven-script/maven-plugin-tools-model/pom.xml
index d57e8230..6a2479a6 100644
--- a/maven-script/maven-plugin-tools-model/pom.xml
+++ b/maven-script/maven-plugin-tools-model/pom.xml
@@ -45,8 +45,8 @@
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/maven-script/maven-plugin-tools-model/src/test/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParserTest.java b/maven-script/maven-plugin-tools-model/src/test/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParserTest.java
index 76322552..1fcb7dac 100644
--- a/maven-script/maven-plugin-tools-model/src/test/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParserTest.java
+++ b/maven-script/maven-plugin-tools-model/src/test/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParserTest.java
@@ -25,15 +25,19 @@ import java.net.URL;
import java.nio.file.Paths;
import java.util.Set;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+// at least one test class must be public for test-javadoc report
public class PluginMetadataParserTest
{
@Test
- public void testBasicDeclarationWithoutCall()
+ void testBasicDeclarationWithoutCall()
throws PluginMetadataParseException
{
File metadataFile = getMetadataFile( "test.mojos.xml" );
@@ -47,7 +51,7 @@ public class PluginMetadataParserTest
}
@Test
- public void testBasicDeclarationWithCall()
+ void testBasicDeclarationWithCall()
throws PluginMetadataParseException
{
File metadataFile = getMetadataFile( "test2.mojos.xml" );
@@ -65,10 +69,7 @@ public class PluginMetadataParserTest
try
{
URL resource = Thread.currentThread().getContextClassLoader().getResource( name );
- if ( resource == null )
- {
- fail( "Cannot find classpath resource: '" + name + "'." );
- }
+ assertNotNull( resource, "Cannot find classpath resource: '" + name + "'." );
return Paths.get( resource.toURI() ).toFile();
}
catch ( final URISyntaxException e )
@@ -76,5 +77,4 @@ public class PluginMetadataParserTest
throw new AssertionError( e );
}
}
-
}
diff --git a/maven-script/maven-script-ant/pom.xml b/maven-script/maven-script-ant/pom.xml
index 3d49f076..aaa640d1 100644
--- a/maven-script/maven-script-ant/pom.xml
+++ b/maven-script/maven-script-ant/pom.xml
@@ -66,8 +66,13 @@ under the License.
<artifactId>maven-core</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java b/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java
index 791c87f0..c63be026 100644
--- a/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java
+++ b/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.java
@@ -19,8 +19,9 @@ package org.apache.maven.script.ant;
* under the License.
*/
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -65,23 +66,24 @@ import org.codehaus.plexus.component.repository.ComponentRequirement;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
+// at least one test class must be public for test-javadoc report
public class AntMojoWrapperTest
{
private BuildListener buildListener;
- @Before
+ @BeforeEach
public void setUp()
{
buildListener = mock( BuildListener.class );
}
@Test
- public void test2xStylePlugin()
+ void test2xStylePlugin()
throws PlexusConfigurationException, IOException, ComponentInstantiationException, MojoExecutionException,
ComponentConfigurationException, ArchiverException, URISyntaxException
{
@@ -106,14 +108,8 @@ public class AntMojoWrapperTest
private void assertPresence( List<String> messages, String test )
{
- for ( String message : messages )
- {
- if ( message.contains( test ) )
- {
- fail( "Test string: '" + test + "' was found in output, but SHOULD NOT BE THERE." );
- return;
- }
- }
+ assertTrue( messages.stream().noneMatch( s -> s.contains( test ) ),
+ "Test string: '" + test + "' was found in output, but SHOULD NOT BE THERE." );
}
private List<String> run( String pluginXml )
@@ -125,10 +121,7 @@ public class AntMojoWrapperTest
URL resource = Thread.currentThread().getContextClassLoader().getResource( pluginXml );
- if ( resource == null )
- {
- fail( "plugin descriptor not found: '" + pluginXml + "'." );
- }
+ assertNotNull( resource, "plugin descriptor not found: '" + pluginXml + "'." );
PluginDescriptor pd;
try ( Reader reader = new InputStreamReader( resource.openStream() ) )
diff --git a/pom.xml b/pom.xml
index 04abbee9..d73ea0ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -176,11 +176,6 @@
<artifactId>plexus-utils</artifactId>
<version>${plexusUtilsVersion}</version>
</dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-annotations</artifactId>
- <version>2.1.1</version>
- </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
@@ -239,6 +234,12 @@
<version>3.23.1</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
@@ -246,9 +247,15 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.2</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>5.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <version>1.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -265,19 +272,6 @@
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- <version>2.1.1</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-metadata</goal>
- <goal>generate-test-metadata</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</pluginManagement>
</build>