Merge remote-tracking branch 'origin/master' into dependency-convergence
# Conflicts:
# maven-plugin-plugin/pom.xml
# maven-plugin-tools-generators/pom.xml
# pom.xml
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven-verify.yml
similarity index 92%
rename from .github/workflows/maven.yml
rename to .github/workflows/maven-verify.yml
index c136c4a..4d67fdc 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven-verify.yml
@@ -15,15 +15,13 @@
# specific language governing permissions and limitations
# under the License.
-name: Java CI
+name: Verify
on:
push:
- branches-ignore:
- - dependabot/**
pull_request:
jobs:
build:
name: Verify
- uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v1
+ uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3
diff --git a/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java b/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java
index d6be4f9..0e643d6 100644
--- a/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java
+++ b/maven-plugin-annotations/src/main/java/org/apache/maven/plugins/annotations/Parameter.java
@@ -73,6 +73,13 @@
String defaultValue() default "";
/**
+ * Defines the implementation in the case the parameter type is an interface.
+ *
+ * @return the implementation class name
+ */
+ Class<?> implementation() default Object.class;
+
+ /**
* is the parameter required?
* @return <code>true</code> if the Mojo should fail when the parameter cannot be injected
*/
diff --git a/maven-plugin-plugin/pom.xml b/maven-plugin-plugin/pom.xml
index 50fe7c8..d36e8c7 100644
--- a/maven-plugin-plugin/pom.xml
+++ b/maven-plugin-plugin/pom.xml
@@ -71,9 +71,7 @@
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
- <!-- from stricter view, should use ${mavenPluginToolsVersion} but this is causing problems with release plugin -->
- <!--version>${mavenPluginToolsVersion}</version-->
- <!--
+ <!--
Do not use 'provided' scope here. The annotations are a transitive dependency of
'maven-plugin-tools-annotations' which fails to load at runtime when not available.
-->
@@ -161,8 +159,13 @@
<!-- tests -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
@@ -208,23 +211,6 @@
</pluginManagement>
<plugins>
<plugin>
- <groupId>org.codehaus.modello</groupId>
- <artifactId>modello-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>java</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <version>1.0.0</version>
- <models>
- <model>src/main/mdo/pluginRequirements.mdo</model>
- </models>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
@@ -253,17 +239,10 @@
<version>3.6.4</version>
<executions>
<execution>
- <id>default-descriptor</id>
- <phase>process-classes</phase>
- </execution>
- <execution>
<id>generated-helpmojo</id>
<goals>
<goal>helpmojo</goal>
</goals>
- <configuration>
- <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
- </configuration>
</execution>
</executions>
</plugin>
@@ -294,19 +273,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
- <version>${mavenInvokerPluginVersion}</version>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>l10n-maven-plugin</artifactId>
- <version>1.0-alpha-2</version>
- <configuration>
- <locales>
- <locale>de</locale>
- <locale>fr</locale>
- <locale>sv</locale>
- </locales>
- </configuration>
</plugin>
</plugins>
</reporting>
@@ -318,7 +284,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
- <version>${mavenInvokerPluginVersion}</version>
<configuration>
<projectsDirectory>src/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
@@ -328,7 +293,8 @@
<settingsFile>src/it/settings.xml</settingsFile>
<streamLogsOnFailures>true</streamLogsOnFailures>
<filterProperties>
- <sitePluginVersion>3.3</sitePluginVersion>
+ <sitePluginVersion>3.12.1</sitePluginVersion>
+ <projectInfoReportsPlugin>3.4.1</projectInfoReportsPlugin>
<antVersion>${antVersion}</antVersion>
</filterProperties>
<properties>
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 56840d6..e5836c0 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
@@ -36,7 +36,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <plexusCompilerVersion>1.8.6</plexusCompilerVersion>
</properties>
<dependencies>
@@ -44,53 +43,35 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>@project.version@</version>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools-annotations</artifactId>
<version>@project.version@</version>
<classifier>tests</classifier>
- </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>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-manager</artifactId>
- <version>${plexusCompilerVersion}</version>
+ <!-- we only need one class FooMojo -->
+ <!-- in order to don't manage all transitive dependencies simply exclude its -->
<exclusions>
<exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-api</artifactId>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-javac</artifactId>
- <version>${plexusCompilerVersion}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
- </dependency>
+
</dependencies>
<build>
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
index 3acb9b1..21bb3e8 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
@@ -65,11 +65,6 @@
{
throw new MojoExecutionException( "projectHelper == null" );
}
- if ( compilerManager == null )
- {
- throw new MojoExecutionException( "compilerManager == null" );
- }
-
}
}
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy
index b46c828..b941b80 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-from-deps/verify.groovy
@@ -20,11 +20,8 @@
File descriptorFile = new File( basedir, "target/classes/META-INF/maven/plugin.xml" );
assert descriptorFile.isFile()
-File oldHelpClass = new File( basedir, "target/classes/HelpMojo.class" );
-assert !oldHelpClass.exists()
-
-File newHelpClass = new File( basedir, "target/classes/org/apache/maven/plugin/coreit/HelpMojo.class" );
-assert newHelpClass.exists()
+File helpClass = new File( basedir, "target/classes/org/apache/maven/its/annotation_with_inheritance_from_deps/annotation_with_inheritance_from_deps/HelpMojo.class" );
+assert helpClass.exists()
def pluginDescriptor = new XmlParser().parse( descriptorFile );
@@ -54,23 +51,24 @@
assert mojo.configuration.beer[0].'@implementation' == 'java.lang.String'
assert mojo.configuration.beer[0].'@default-value' == 'coolbeer'
-assert mojo.requirements.requirement.size() == 3
+assert mojo.requirements.requirement.size() == 2
-assert mojo.requirements.requirement[1].role.text() == 'org.codehaus.plexus.compiler.manager.CompilerManager'
+assert mojo.requirements.requirement[0].role.text() == 'org.apache.maven.artifact.metadata.ArtifactMetadataSource'
+assert mojo.requirements.requirement[0].'role-hint'.text() == 'maven'
+assert mojo.requirements.requirement[0].'field-name'.text() == 'artifactMetadataSource'
+
+assert mojo.requirements.requirement[1].role.text() == 'org.apache.maven.project.MavenProjectHelper'
assert mojo.requirements.requirement[1].'role-hint'.text() == ''
-assert mojo.requirements.requirement[1].'field-name'.text() == 'compilerManager'
+assert mojo.requirements.requirement[1].'field-name'.text() == 'projectHelper'
-assert mojo.requirements.requirement[2].role.text() == 'org.apache.maven.project.MavenProjectHelper'
-//assert mojo.requirements.requirement[2].'role-hint'.text() == 'default'
-assert mojo.requirements.requirement[2].'field-name'.text() == 'projectHelper'
-
-assert mojo.parameters.parameter.size() == 3
+assert mojo.parameters.parameter.size() == 4
def parameter = mojo.parameters.parameter.findAll{ it.name.text() == "aliasedParam"}[0]
assert parameter.name.text() == 'aliasedParam'
assert parameter.alias.text() == 'alias'
assert parameter.type.text() == 'java.lang.String'
+assert parameter.implementation.isEmpty()
assert parameter.deprecated.text() == 'As of 0.2'
assert parameter.required.text() == 'false'
assert parameter.editable.text() == 'true'
@@ -81,6 +79,7 @@
assert parameter.name.text() == 'beer'
assert parameter.alias.isEmpty()
assert parameter.type.text() == 'java.lang.String'
+assert parameter.implementation.isEmpty()
assert parameter.deprecated.text() == "wine is better"
assert parameter.required.text() == 'false'
assert parameter.editable.text() == 'true'
@@ -91,9 +90,21 @@
assert parameter.name.text() == 'bar'
assert parameter.alias.isEmpty()
assert parameter.type.text() == 'java.lang.String'
+assert parameter.implementation.isEmpty()
assert parameter.deprecated.isEmpty()
assert parameter.required.text() == 'true'
assert parameter.editable.text() == 'true'
assert parameter.description.text() == 'the cool bar to go'
+parameter = mojo.parameters.parameter.findAll{ it.name.text() == "fooInterface"}[0]
+
+assert parameter.name.text() == 'fooInterface'
+assert parameter.alias.isEmpty()
+assert parameter.type.text() == 'org.apache.maven.tools.plugin.extractor.annotations.FooInterface'
+assert parameter.implementation.text() == 'org.apache.maven.tools.plugin.extractor.annotations.FooInterfaceImpl'
+assert parameter.deprecated.isEmpty()
+assert parameter.required.text() == 'false'
+assert parameter.editable.text() == 'true'
+assert parameter.description.text() == 'Interface type as parameter.'
+
return true;
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/invoker.properties b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/invoker.properties
index 260443c..24189f7 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/invoker.properties
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/invoker.properties
@@ -15,6 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals.1 = clean install -DskipTests
+invoker.goals.1 = clean install
invoker.goals.2 = org.apache.maven.its.annotation-with-inheritance-reactor:module-mojo:1.0-SNAPSHOT:it0014
invoker.goals.3 = org.apache.maven.its.annotation-with-inheritance-reactor:module-mojo:1.0-SNAPSHOT:first
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java
index 9858058..505152b 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-abstract-mojo/src/main/java/org/apache/maven/plugins/AbstractFirstMojo.java
@@ -20,13 +20,8 @@
*/
import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.Execute;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
-import org.codehaus.plexus.compiler.manager.CompilerManager;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import java.io.File;
@@ -50,12 +45,6 @@
protected File touchFile;
/**
- * Plexus compiler manager.
- */
- @Component
- protected CompilerManager compilerManager;
-
- /**
*
*/
@Component( role = ArtifactMetadataSource.class, hint = "maven" )
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
index b0b40fe..cb150a2 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/module-mojo/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
@@ -66,10 +66,6 @@
{
throw new MojoExecutionException( "projectHelper == null" );
}
- if ( compilerManager == null )
- {
- throw new MojoExecutionException( "compilerManager == null" );
- }
if (! ( projectHelper instanceof MavenProjectHelper ))
{
throw new MojoExecutionException( "! projectHelper instanceof MavenProjectHelper" );
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 558a545..d2f6b8b 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
@@ -35,7 +35,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <plexusCompilerVersion>1.8.6</plexusCompilerVersion>
</properties>
<dependencies>
@@ -43,51 +42,39 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools-annotations</artifactId>
<version>@project.version@</version>
<classifier>tests</classifier>
+ <!-- we only need one class FooMojo -->
+ <!-- in order to don't manage all transitive dependencies simply exclude its -->
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
</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>
<artifactId>maven-plugin-annotations</artifactId>
<version>@project.version@</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-manager</artifactId>
- <version>${plexusCompilerVersion}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-javac</artifactId>
- <version>${plexusCompilerVersion}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-api</artifactId>
- </exclusion>
- </exclusions>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy
index d5aa091..6b0b412 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance-reactor/verify.groovy
@@ -53,11 +53,11 @@
assert mojo.configuration.touchFile[0].'@implementation' == 'java.io.File'
assert mojo.configuration.touchFile[0].'@default-value' == '${project.build.directory}/touch.txt'
-assert mojo.requirements.requirement.size() == 3
+assert mojo.requirements.requirement.size() == 2
-assert mojo.requirements.requirement[2].role.text() == 'org.apache.maven.project.MavenProjectHelper'
-//assert mojo.requirements.requirement[2].'role-hint'.text() == 'default'
-assert mojo.requirements.requirement[2].'field-name'.text() == 'projectHelper'
+assert mojo.requirements.requirement[1].role.text() == 'org.apache.maven.project.MavenProjectHelper'
+assert mojo.requirements.requirement[1].'role-hint'.text() == ''
+assert mojo.requirements.requirement[1].'field-name'.text() == 'projectHelper'
assert mojo.parameters.parameter.size() == 3
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties b/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties
index 17e8ee4..0ad4137 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/invoker.properties
@@ -15,8 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals.1 = clean install -DskipTests
+invoker.goals.1 = clean install
invoker.goals.2 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:it0014
invoker.goals.3 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:first
invoker.goals.4 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:help
-invoker.goals.5 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:third
\ No newline at end of file
+invoker.goals.5 = org.apache.maven.its.annotation-with-inheritance:annotation-with-inheritance:1.0-SNAPSHOT:third
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml b/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml
index e9c9113..b00ab7d 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/pom.xml
@@ -36,7 +36,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <plexusCompilerVersion>1.8.6</plexusCompilerVersion>
</properties>
<dependencies>
@@ -44,11 +43,13 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
@@ -58,30 +59,8 @@
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-manager</artifactId>
- <version>${plexusCompilerVersion}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-javac</artifactId>
- <version>${plexusCompilerVersion}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
+ <version>@plexusUtilsVersion@</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java
index c0eee7c..65837c0 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFirstMojo.java
@@ -20,13 +20,8 @@
*/
import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.Execute;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
-import org.codehaus.plexus.compiler.manager.CompilerManager;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import java.io.File;
@@ -49,12 +44,6 @@
protected File touchFile;
/**
- * Plexus compiler manager.
- */
- @Component
- protected CompilerManager compilerManager;
-
- /**
*
*/
@Component( role = ArtifactMetadataSource.class, hint = "maven" )
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFooMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFooMojo.java
index 8f7c8e3..0b13bc2 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFooMojo.java
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/AbstractFooMojo.java
@@ -19,18 +19,6 @@
* under the License.
*/
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.Execute;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.codehaus.plexus.compiler.manager.CompilerManager;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-
-import java.io.File;
-
/**
*
*/
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
index e88906e..b22ff96 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
@@ -72,10 +72,6 @@
{
throw new MojoExecutionException( "projectHelper == null" );
}
- if ( compilerManager == null )
- {
- throw new MojoExecutionException( "compilerManager == null" );
- }
if ( dependencies.isEmpty() )
{
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/ThirdMojo.java b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/ThirdMojo.java
index 4334f73..4a35262 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/ThirdMojo.java
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/src/main/java/org/apache/maven/plugin/coreit/ThirdMojo.java
@@ -72,11 +72,6 @@
{
throw new MojoExecutionException( "projectHelper == null" );
}
- if ( compilerManager == null )
- {
- throw new MojoExecutionException( "compilerManager == null" );
- }
-
if ( dependencies.isEmpty() )
{
throw new MojoExecutionException( "dependencies.isEmpty()" );
diff --git a/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy b/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy
index f4e1ba5..689e000 100644
--- a/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy
+++ b/maven-plugin-plugin/src/it/annotation-with-inheritance/verify.groovy
@@ -23,11 +23,8 @@
File descriptorFile = new File( basedir, "target/classes/META-INF/maven/plugin.xml" );
assert descriptorFile.isFile()
-File oldHelpClass = new File( basedir, "target/classes/HelpMojo.class" );
-assert !oldHelpClass.exists()
-
-File newHelpClass = new File( basedir, "target/classes/org/apache/maven/plugin/coreit/HelpMojo.class" );
-assert newHelpClass.exists()
+File helpClass = new File( basedir, "target/classes/org/apache/maven/its/annotation_with_inheritance/annotation_with_inheritance/HelpMojo.class" );
+assert helpClass.exists()
def pluginDescriptor = new XmlParser().parse( descriptorFile );
@@ -57,11 +54,11 @@
assert mojo.configuration.touchFile[0].'@implementation' == 'java.io.File'
assert mojo.configuration.touchFile[0].'@default-value' == '${project.build.directory}/touch.txt'
-assert mojo.requirements.requirement.size() == 3
+assert mojo.requirements.requirement.size() == 2
-assert mojo.requirements.requirement[2].role.text() == 'org.apache.maven.project.MavenProjectHelper'
+assert mojo.requirements.requirement[1].role.text() == 'org.apache.maven.project.MavenProjectHelper'
//assert mojo.requirements.requirement[2].'role-hint'.text() == 'default'
-assert mojo.requirements.requirement[2].'field-name'.text() == 'projectHelper'
+assert mojo.requirements.requirement[1].'field-name'.text() == 'projectHelper'
assert mojo.parameters.parameter.size() == 4
diff --git a/maven-plugin-plugin/src/it/ant-basic/invoker.properties b/maven-plugin-plugin/src/it/ant-basic/invoker.properties
index 0d94ede..55875b6 100644
--- a/maven-plugin-plugin/src/it/ant-basic/invoker.properties
+++ b/maven-plugin-plugin/src/it/ant-basic/invoker.properties
@@ -15,6 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals.1 = clean install -DskipTests
+invoker.goals.1 = clean install
invoker.goals.2 = org.apache.maven.ant.it:maven-ant-it-basic:1.0-SNAPSHOT:touch -Dname=touch.txt
diff --git a/maven-plugin-plugin/src/it/ant-reference-parameter/invoker.properties b/maven-plugin-plugin/src/it/ant-reference-parameter/invoker.properties
index adcfaf5..96636d0 100644
--- a/maven-plugin-plugin/src/it/ant-reference-parameter/invoker.properties
+++ b/maven-plugin-plugin/src/it/ant-reference-parameter/invoker.properties
@@ -15,6 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals.1 = clean install -DskipTests
+invoker.goals.1 = clean install
invoker.goals.2 = org.apache.maven.ant.it:maven-ant-it-referenceParameter:1.0-SNAPSHOT:test
diff --git a/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/java/org/apache/maven/plugins/antWithRefs/ArtifactsTask.java b/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/java/org/apache/maven/plugins/antWithRefs/ArtifactsTask.java
index 8c8e20e..c41989d 100644
--- a/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/java/org/apache/maven/plugins/antWithRefs/ArtifactsTask.java
+++ b/maven-plugin-plugin/src/it/ant-reference-parameter/src/main/java/org/apache/maven/plugins/antWithRefs/ArtifactsTask.java
@@ -29,7 +29,7 @@
public void execute()
throws BuildException
{
- log( String.valueOf( getProject().getReference( "artifacts" ) ) );
+ log( String.valueOf( ( Object ) getProject().getReference( "artifacts" ) ) );
}
}
diff --git a/maven-plugin-plugin/src/it/ant-simple-usage/invoker.properties b/maven-plugin-plugin/src/it/ant-simple-usage/invoker.properties
index 853271b..3df4a4d 100644
--- a/maven-plugin-plugin/src/it/ant-simple-usage/invoker.properties
+++ b/maven-plugin-plugin/src/it/ant-simple-usage/invoker.properties
@@ -15,6 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals.1 = clean install -DskipTests
+invoker.goals.1 = clean install
#invoker.goals.2 = org.apache.maven.ant.it:maven-ant-it-referenceParameter:1.0-SNAPSHOT:test
diff --git a/maven-plugin-plugin/src/it/asm-failure/pom.xml b/maven-plugin-plugin/src/it/asm-failure/pom.xml
index a45177a..9da9f6d 100644
--- a/maven-plugin-plugin/src/it/asm-failure/pom.xml
+++ b/maven-plugin-plugin/src/it/asm-failure/pom.xml
@@ -50,13 +50,14 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
- <version>3.0</version>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>@project.version@</version>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
diff --git a/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties b/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties
index 8ec6452..88773cf 100644
--- a/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties
+++ b/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties
@@ -15,6 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals.1 = clean install -DskipTests
+invoker.goals.1 = clean install
invoker.goals.2 = org.apache.maven.beanshell.it:maven-beanshell-it-basic:1.0-SNAPSHOT:touch -Dname=touch.txt
diff --git a/maven-plugin-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/pom.xml b/maven-plugin-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/pom.xml
index 7b846ea..37dbbb6 100644
--- a/maven-plugin-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/pom.xml
+++ b/maven-plugin-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/pom.xml
@@ -43,7 +43,8 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
- <version>2.0</version>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/maven-plugin-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/site/site.xml b/maven-plugin-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/site/site.xml
index fc47fd7..e4ac0af 100644
--- a/maven-plugin-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/site/site.xml
+++ b/maven-plugin-plugin/src/it/fix-maven-since-3.x/antsample-maven-plugin/src/site/site.xml
@@ -20,6 +20,11 @@
<project name="${artifactId}">
<publishDate position="right" format="dd/MM/yyyy, HH:mm" />
<version position="right"/>
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.11.1</version>
+ </skin>
<poweredBy>
<logo name="Maven" href="http://maven.apache.org/"
img="${project.url}/images/maven-feather.png" />
@@ -31,6 +36,6 @@
<item name="Usage" href="usage.html"/>
<item name="FAQ" href="faq.html"/>
</menu>
- ${reports}
+ <menu ref="reports" />
</body>
</project>
diff --git a/maven-plugin-plugin/src/it/fix-maven-since-3.x/javasample-maven-plugin/pom.xml b/maven-plugin-plugin/src/it/fix-maven-since-3.x/javasample-maven-plugin/pom.xml
index 027f542..bb3e177 100644
--- a/maven-plugin-plugin/src/it/fix-maven-since-3.x/javasample-maven-plugin/pom.xml
+++ b/maven-plugin-plugin/src/it/fix-maven-since-3.x/javasample-maven-plugin/pom.xml
@@ -43,7 +43,8 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
- <version>2.0</version>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
</project>
diff --git a/maven-plugin-plugin/src/it/fix-maven-since-3.x/javasample-maven-plugin/src/site/site.xml b/maven-plugin-plugin/src/it/fix-maven-since-3.x/javasample-maven-plugin/src/site/site.xml
index 4520314..8f28766 100644
--- a/maven-plugin-plugin/src/it/fix-maven-since-3.x/javasample-maven-plugin/src/site/site.xml
+++ b/maven-plugin-plugin/src/it/fix-maven-since-3.x/javasample-maven-plugin/src/site/site.xml
@@ -20,6 +20,11 @@
<project name="${artifactId}">
<publishDate position="right" format="dd/MM/yyyy, HH:mm" />
<version position="right"/>
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.11.1</version>
+ </skin>
<poweredBy>
<logo name="Maven" href="http://maven.apache.org/"
img="${project.url}/images/maven-feather.png" />
@@ -31,7 +36,7 @@
<item name="Usage" href="usage.html"/>
<item name="FAQ" href="faq.html"/>
</menu>
- ${reports}
+ <menu ref="reports" />
</body>
</project>
diff --git a/maven-plugin-plugin/src/it/fix-maven-since-3.x/pom.xml b/maven-plugin-plugin/src/it/fix-maven-since-3.x/pom.xml
index eec11c3..dd3624a 100644
--- a/maven-plugin-plugin/src/it/fix-maven-since-3.x/pom.xml
+++ b/maven-plugin-plugin/src/it/fix-maven-since-3.x/pom.xml
@@ -38,7 +38,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
- <version>3.0.2</version>
+ <version>@plexusUtilsVersion@</version>
</dependency>
</dependencies>
@@ -71,7 +71,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.4</version>
+ <version>@projectInfoReportsPlugin@</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/expected-help.txt b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/expected-help.txt
new file mode 100644
index 0000000..ff876eb
--- /dev/null
+++ b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/expected-help.txt
@@ -0,0 +1,25 @@
+[INFO] help 1.0-SNAPSHOT
+ Tests generation and compilation of the help mojo.
+
+help:test
+ Deprecated. No reason given
+
+ MOJO-DESCRIPTION. Some 'quotation' marks and backslashes '\\', some important
+ javadoc
+ and an inline link to AnotherMojo.
+
+ Available parameters:
+
+ defaultParam (Default: escape\backslash)
+ This parameter uses 'quotation' marks and backslashes '\\' in its
+ description. Those characters must be escaped in Java string literals.
+
+ deprecatedParam
+ Deprecated. No reason given
+
+ Parameter description in javadoc.
+
+ undocumentedParam
+
+ Required: Yes
+ User property: test.undocumented
diff --git a/.github/workflows/maven.yml b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/invoker.properties
similarity index 73%
copy from .github/workflows/maven.yml
copy to maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/invoker.properties
index c136c4a..e7b0b4d 100644
--- a/.github/workflows/maven.yml
+++ b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/invoker.properties
@@ -5,9 +5,9 @@
# 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
-#
+#
+# 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
@@ -15,15 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-name: Java CI
-
-on:
- push:
- branches-ignore:
- - dependabot/**
- pull_request:
-
-jobs:
- build:
- name: Verify
- uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v1
+invoker.goals.1 = clean install
+invoker.goals.2 = --log-file help.log org.apache.maven.its.plugin:help:1.0-SNAPSHOT:help
diff --git a/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/pom.xml b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/pom.xml
new file mode 100644
index 0000000..97ae706
--- /dev/null
+++ b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.plugin</groupId>
+ <artifactId>help</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <description>
+ Tests generation and compilation of the help mojo.
+ </description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>@project.version@</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.10.1</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>help-goal</id>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/src/main/java/test/MyMojo.java b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/src/main/java/test/MyMojo.java
new file mode 100644
index 0000000..d4c8147
--- /dev/null
+++ b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/src/main/java/test/MyMojo.java
@@ -0,0 +1,67 @@
+package test;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ * MOJO-DESCRIPTION. Some "quotation" marks and backslashes '\\', some <strong>important</strong> javadoc<br> and an
+ * inline link to {@link test.AnotherMojo}.
+ *
+ * @since 2.1
+ */
+@Deprecated
+@Mojo( name= "test" )
+public class MyMojo
+ extends AbstractMojo
+{
+
+ /**
+ * This parameter uses "quotation" marks and backslashes '\\' in its description. Those characters <em>must</em> be
+ * escaped in Java string literals.
+ *
+ * @since 2.0
+ */
+ @Parameter( defaultValue = "escape\\backslash" )
+ private String defaultParam;
+
+ /**
+ * Parameter description in javadoc.
+ */
+ @Deprecated
+ @Parameter
+ private String deprecatedParam;
+
+ @Parameter( property = "test.undocumented", required = true )
+ private String undocumentedParam;
+
+ /**
+ * Readonly parameter: should not be proposed for configuration.
+ */
+ @Parameter( defaultValue = "not for configuration", readonly = true )
+ private String readonly;
+
+ public void execute()
+ {
+ }
+
+}
diff --git a/.github/workflows/maven.yml b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/test.properties
similarity index 73%
copy from .github/workflows/maven.yml
copy to maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/test.properties
index c136c4a..16e4de3 100644
--- a/.github/workflows/maven.yml
+++ b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/test.properties
@@ -5,9 +5,9 @@
# 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
-#
+#
+# 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
@@ -15,15 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-name: Java CI
-
-on:
- push:
- branches-ignore:
- - dependabot/**
- pull_request:
-
-jobs:
- build:
- name: Verify
- uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v1
+detail = true
+goal = test
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/verify.groovy
similarity index 60%
copy from maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
copy to maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/verify.groovy
index ce4f919..219231b 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
+++ b/maven-plugin-plugin/src/it/help-basic-deprecated-annotation-only/verify.groovy
@@ -1,5 +1,3 @@
-package org.apache.maven.tools.plugin.generator;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,22 +17,12 @@
* under the License.
*/
-import org.codehaus.plexus.velocity.VelocityComponent;
+expected = new File( basedir, "expected-help.txt" ).text.trim().replace( "\r", "" )
-/**
- * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
- */
-public class PluginHelpGeneratorTest
- extends AbstractGeneratorTestCase
-{
- // inherits tests from base class
- @Override
- protected void setupGenerator()
- throws Exception
- {
+log = new File( basedir, "help.log" ).text.replace( "\r", "" )
+log = log.substring( log.indexOf( "[INFO] help 1.0-SNAPSHOT" ) )
+log = log.substring( 0, log.indexOf( "[INFO]", 5 ) ).trim()
- generator =
- new PluginHelpGenerator().setVelocityComponent( (VelocityComponent) lookup( VelocityComponent.ROLE ) );
+assert log == expected
- }
-}
+return true
diff --git a/maven-plugin-plugin/src/it/help-basic-jdk11/invoker.properties b/maven-plugin-plugin/src/it/help-basic-jdk11/invoker.properties
index e1086cb..9cdacab 100644
--- a/maven-plugin-plugin/src/it/help-basic-jdk11/invoker.properties
+++ b/maven-plugin-plugin/src/it/help-basic-jdk11/invoker.properties
@@ -16,8 +16,5 @@
# under the License.
invoker.java.version = 11+
-invoker.maven.version = 3.0+
-invoker.goals.1 = clean install -DskipTests
-invoker.goals.2 = org.apache.maven.its.plugin:help-jdk11:1.0-SNAPSHOT:help
-invoker.goals.3 = --log-file help.log org.apache.maven.its.plugin:help-jdk11:1.0-SNAPSHOT:help
-# --log-file option is only supported by Maven 3
+invoker.goals.1 = clean install
+invoker.goals.2 = --log-file help.log org.apache.maven.its.plugin:help-jdk11:1.0-SNAPSHOT:help
diff --git a/maven-plugin-plugin/src/it/help-basic-jdk11/pom.xml b/maven-plugin-plugin/src/it/help-basic-jdk11/pom.xml
index 2bbbc31..65c2096 100644
--- a/maven-plugin-plugin/src/it/help-basic-jdk11/pom.xml
+++ b/maven-plugin-plugin/src/it/help-basic-jdk11/pom.xml
@@ -40,11 +40,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
diff --git a/maven-plugin-plugin/src/it/help-basic/invoker.properties b/maven-plugin-plugin/src/it/help-basic/invoker.properties
index 544361b..e7b0b4d 100644
--- a/maven-plugin-plugin/src/it/help-basic/invoker.properties
+++ b/maven-plugin-plugin/src/it/help-basic/invoker.properties
@@ -15,9 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-invoker.maven.version = 3.0+
-invoker.goals.1 = clean install -DskipTests
-invoker.goals.2 = org.apache.maven.its.plugin:help:1.0-SNAPSHOT:help
-invoker.goals.3 = --log-file help.log org.apache.maven.its.plugin:help:1.0-SNAPSHOT:help
-# --log-file option is only supported by Maven 3
-invoker.maven.version = 3.0+
+invoker.goals.1 = clean install
+invoker.goals.2 = --log-file help.log org.apache.maven.its.plugin:help:1.0-SNAPSHOT:help
diff --git a/maven-plugin-plugin/src/it/help-basic/pom.xml b/maven-plugin-plugin/src/it/help-basic/pom.xml
index 2675d8e..73e4ce4 100644
--- a/maven-plugin-plugin/src/it/help-basic/pom.xml
+++ b/maven-plugin-plugin/src/it/help-basic/pom.xml
@@ -40,11 +40,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
diff --git a/maven-plugin-plugin/src/it/help-package/pom.xml b/maven-plugin-plugin/src/it/help-package/pom.xml
index f289a1f..81f0376 100644
--- a/maven-plugin-plugin/src/it/help-package/pom.xml
+++ b/maven-plugin-plugin/src/it/help-package/pom.xml
@@ -40,11 +40,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/maven-plugin-plugin/src/it/ignore-plugin-class-realm/invoker.properties b/maven-plugin-plugin/src/it/ignore-plugin-class-realm/invoker.properties
index 5493444..9c6bf14 100644
--- a/maven-plugin-plugin/src/it/ignore-plugin-class-realm/invoker.properties
+++ b/maven-plugin-plugin/src/it/ignore-plugin-class-realm/invoker.properties
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals.1 = clean install -DskipTests
+invoker.goals.1 = clean install
invoker.profiles.1 = setup
invoker.goals.2 = clean process-classes
diff --git a/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/invoker.properties b/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/invoker.properties
index a67d07c..6760204 100644
--- a/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/invoker.properties
+++ b/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/invoker.properties
@@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-invoker.java.version = 1.8+
-invoker.goals.1 = clean install -DskipTests
-invoker.goals.2 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0-SNAPSHOT:it0014
-invoker.goals.3 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0-SNAPSHOT:help
\ No newline at end of file
+invoker.goals.1 = clean install
+invoker.goals.2 = org.apache.maven.its.basic-java-annotations:123-maven-it-basic-java-annotations:1.0-SNAPSHOT:it0014
+invoker.goals.3 = org.apache.maven.its.basic-java-annotations:123-maven-it-basic-java-annotations:1.0-SNAPSHOT:help
diff --git a/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/pom.xml b/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/pom.xml
index 63d0e04..dda14a8 100644
--- a/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/pom.xml
+++ b/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/pom.xml
@@ -23,7 +23,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.basic-java-annotations</groupId>
- <artifactId>maven-it-basic-java-annotations</artifactId>
+ <artifactId>123-maven-it-basic-java-annotations</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
@@ -47,22 +47,19 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>@mavenVersion@</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>@project.version@</version>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/verify.groovy b/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/verify.groovy
index 294f538..b130e2c 100644
--- a/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/verify.groovy
+++ b/maven-plugin-plugin/src/it/java-basic-annotations-jdk8/verify.groovy
@@ -224,8 +224,7 @@
assert requirement.role.text() == 'org.apache.maven.project.MavenProjectHelper'
// check help mojo source and class
-assert new File( basedir, "target/classes/org/apache/maven/plugin/coreit/HelpMojo.class" ).isFile()
-assert new File( basedir, "target/generated-sources/plugin/org/apache/maven/plugin/coreit/HelpMojo.java" ).isFile()
-assert !new File( basedir, "target/generated-sources/plugin/HelpMojo.java" ).isFile()
+assert new File( basedir, "target/classes/org/apache/maven/its/basic_java_annotations/_123_maven_it_basic_java_annotations/HelpMojo.class" ).isFile()
+assert new File( basedir, "target/generated-sources/plugin/org/apache/maven/its/basic_java_annotations/_123_maven_it_basic_java_annotations/HelpMojo.java" ).isFile()
return true;
diff --git a/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/invoker.properties b/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/invoker.properties
index 64ad810..c955e5b 100644
--- a/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/invoker.properties
+++ b/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/invoker.properties
@@ -16,6 +16,6 @@
# under the License.
invoker.java.version = 9+
-invoker.goals.1 = clean install -DskipTests
+invoker.goals.1 = clean install
invoker.goals.2 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0-SNAPSHOT:it0014
-invoker.goals.3 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0-SNAPSHOT:help
\ No newline at end of file
+invoker.goals.3 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0-SNAPSHOT:help
diff --git a/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/pom.xml b/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/pom.xml
index d7c0660..ad2b972 100644
--- a/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/pom.xml
+++ b/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/pom.xml
@@ -43,22 +43,19 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>@mavenVersion@</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>@project.version@</version>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/verify.groovy b/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/verify.groovy
index 294f538..c498a22 100644
--- a/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/verify.groovy
+++ b/maven-plugin-plugin/src/it/java-basic-annotations-jdkcurrent/verify.groovy
@@ -224,8 +224,7 @@
assert requirement.role.text() == 'org.apache.maven.project.MavenProjectHelper'
// check help mojo source and class
-assert new File( basedir, "target/classes/org/apache/maven/plugin/coreit/HelpMojo.class" ).isFile()
-assert new File( basedir, "target/generated-sources/plugin/org/apache/maven/plugin/coreit/HelpMojo.java" ).isFile()
-assert !new File( basedir, "target/generated-sources/plugin/HelpMojo.java" ).isFile()
+assert new File( basedir, "target/classes/org/apache/maven/its/basic_java_annotations/maven_it_basic_java_annotations/HelpMojo.class" ).isFile()
+assert new File( basedir, "target/generated-sources/plugin/org/apache/maven/its/basic_java_annotations/maven_it_basic_java_annotations/HelpMojo.java" ).isFile()
return true;
diff --git a/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties b/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties
index f3a9963..d0a9e14 100644
--- a/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties
+++ b/maven-plugin-plugin/src/it/java-basic-annotations/invoker.properties
@@ -15,6 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals.1 = clean install -DskipTests
+invoker.goals.1 = clean install
invoker.goals.2 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0-SNAPSHOT:it0014
-invoker.goals.3 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0-SNAPSHOT:help
\ No newline at end of file
+invoker.goals.3 = org.apache.maven.its.basic-java-annotations:maven-it-basic-java-annotations:1.0-SNAPSHOT:help
diff --git a/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml b/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml
index 653a7c9..19ee2b1 100644
--- a/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml
+++ b/maven-plugin-plugin/src/it/java-basic-annotations/pom.xml
@@ -43,22 +43,24 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
+ <version>@plexusUtilsVersion@</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>@project.version@</version>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
index 62247a0..f2848eb 100644
--- a/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
+++ b/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
@@ -44,6 +44,7 @@
*/
@Mojo( name = "first", requiresDependencyResolution = ResolutionScope.TEST, defaultPhase = LifecyclePhase.INTEGRATION_TEST )
@Execute( phase = LifecyclePhase.GENERATE_SOURCES, lifecycle = "cobertura" )
+@Deprecated
public class FirstMojo
extends AbstractMojo
{
@@ -62,6 +63,7 @@
* @since 0.1
* @deprecated As of 0.2
*/
+ @Deprecated
@Parameter( name = "namedParam", alias = "alias" )
private String aliasedParam;
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java b/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/MPlugin396Mojo.java
similarity index 60%
rename from maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
rename to maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/MPlugin396Mojo.java
index ce4f919..57c45d8 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
+++ b/maven-plugin-plugin/src/it/java-basic-annotations/src/main/java/org/apache/maven/plugin/coreit/MPlugin396Mojo.java
@@ -1,4 +1,4 @@
-package org.apache.maven.tools.plugin.generator;
+package org.apache.maven.plugin.coreit;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,22 +19,25 @@
* under the License.
*/
-import org.codehaus.plexus.velocity.VelocityComponent;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProjectHelper;
-/**
- * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
- */
-public class PluginHelpGeneratorTest
- extends AbstractGeneratorTestCase
+@Deprecated
+@Mojo( name = "mplugin-396" )
+public class MPlugin396Mojo
+ extends AbstractMojo
{
- // inherits tests from base class
- @Override
- protected void setupGenerator()
- throws Exception
+ @Deprecated
+ @Parameter
+ private String param;
+
+ @Component
+ private MavenProjectHelper projectHelper;
+
+ public void execute()
{
-
- generator =
- new PluginHelpGenerator().setVelocityComponent( (VelocityComponent) lookup( VelocityComponent.ROLE ) );
-
}
}
diff --git a/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy b/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
index 294f538..4315bef 100644
--- a/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
+++ b/maven-plugin-plugin/src/it/java-basic-annotations/verify.groovy
@@ -224,8 +224,19 @@
assert requirement.role.text() == 'org.apache.maven.project.MavenProjectHelper'
// check help mojo source and class
-assert new File( basedir, "target/classes/org/apache/maven/plugin/coreit/HelpMojo.class" ).isFile()
-assert new File( basedir, "target/generated-sources/plugin/org/apache/maven/plugin/coreit/HelpMojo.java" ).isFile()
-assert !new File( basedir, "target/generated-sources/plugin/HelpMojo.java" ).isFile()
+assert new File( basedir, "target/classes/org/apache/maven/its/basic_java_annotations/maven_it_basic_java_annotations/HelpMojo.class" ).isFile()
+assert new File( basedir, "target/generated-sources/plugin/org/apache/maven/its/basic_java_annotations/maven_it_basic_java_annotations/HelpMojo.java" ).isFile()
+
+mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "help"}[0]
+assert mojo.goal.text() == 'help'
+assert mojo.implementation.text() == 'org.apache.maven.its.basic_java_annotations.maven_it_basic_java_annotations.HelpMojo'
+assert mojo.language.text() == 'java'
+
+// check values set by deprecated annotation only
+mojo = pluginDescriptor.mojos.mojo.findAll{ it.goal.text() == "mplugin-396"}[0]
+assert mojo.deprecated.text() == 'No reason given'
+
+parameter = mojo.parameters.parameter.findAll{ it.name.text() == "param" }[0]
+assert parameter.deprecated.text() == 'No reason given'
return true;
diff --git a/maven-plugin-plugin/src/it/java-basic/invoker.properties b/maven-plugin-plugin/src/it/java-basic/invoker.properties
index 6672f02..da4a708 100644
--- a/maven-plugin-plugin/src/it/java-basic/invoker.properties
+++ b/maven-plugin-plugin/src/it/java-basic/invoker.properties
@@ -15,6 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals.1 = clean install -DskipTests
+invoker.goals.1 = clean install
invoker.goals.2 = org.apache.maven.its.it0013:maven-it-it0013:1.0-SNAPSHOT:it0013
diff --git a/maven-plugin-plugin/src/it/java-basic/pom.xml b/maven-plugin-plugin/src/it/java-basic/pom.xml
index c570e41..847e4a9 100644
--- a/maven-plugin-plugin/src/it/java-basic/pom.xml
+++ b/maven-plugin-plugin/src/it/java-basic/pom.xml
@@ -43,11 +43,13 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/maven-plugin-plugin/src/it/mplugin-187/invoker.properties b/maven-plugin-plugin/src/it/mplugin-187/invoker.properties
index 5659577..a16bae8 100644
--- a/maven-plugin-plugin/src/it/mplugin-187/invoker.properties
+++ b/maven-plugin-plugin/src/it/mplugin-187/invoker.properties
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals = clean plugin:report -DskipTests
+invoker.goals = clean plugin:report
diff --git a/maven-plugin-plugin/src/it/mplugin-191/pom.xml b/maven-plugin-plugin/src/it/mplugin-191/pom.xml
index 29aa38e..adc71d3 100644
--- a/maven-plugin-plugin/src/it/mplugin-191/pom.xml
+++ b/maven-plugin-plugin/src/it/mplugin-191/pom.xml
@@ -56,12 +56,14 @@
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>@project.version@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/maven-plugin-plugin/src/it/mplugin-223/invoker.properties b/maven-plugin-plugin/src/it/mplugin-223/invoker.properties
index adce2cd..bbd66b8 100644
--- a/maven-plugin-plugin/src/it/mplugin-223/invoker.properties
+++ b/maven-plugin-plugin/src/it/mplugin-223/invoker.properties
@@ -12,4 +12,4 @@
# 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.1 = clean verify -DskipTests
+invoker.goals.1 = clean verify
diff --git a/maven-plugin-plugin/src/it/mplugin-223/pom.xml b/maven-plugin-plugin/src/it/mplugin-223/pom.xml
index 7615391..64e71c9 100644
--- a/maven-plugin-plugin/src/it/mplugin-223/pom.xml
+++ b/maven-plugin-plugin/src/it/mplugin-223/pom.xml
@@ -38,6 +38,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
diff --git a/maven-plugin-plugin/src/it/mplugin-272_java8/pom.xml b/maven-plugin-plugin/src/it/mplugin-272_java8/pom.xml
index c10c6e4..94414e3 100644
--- a/maven-plugin-plugin/src/it/mplugin-272_java8/pom.xml
+++ b/maven-plugin-plugin/src/it/mplugin-272_java8/pom.xml
@@ -20,64 +20,66 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <groupId>test-plugin</groupId>
- <artifactId>test-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>maven-plugin</packaging>
+ <groupId>test-plugin</groupId>
+ <artifactId>test-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>@mavenVersion@</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-annotations</artifactId>
- <version>@project.version@</version>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>@project.version@</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
- <version>@project.version@</version>
- <configuration>
- <goalPrefix>FOO</goalPrefix>
- </configuration>
- <executions>
- <execution>
- <id>default-descriptor</id>
- <goals>
- <goal>descriptor</goal>
- </goals>
- <configuration>
- </configuration>
- <phase>process-classes</phase>
- </execution>
- <execution>
- <id>help-descriptor</id>
- <goals>
- <goal>helpmojo</goal>
- </goals>
- <phase>process-classes</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
\ No newline at end of file
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <goalPrefix>FOO</goalPrefix>
+ </configuration>
+ <executions>
+ <execution>
+ <id>default-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ <configuration>
+ </configuration>
+ <phase>process-classes</phase>
+ </execution>
+ <execution>
+ <id>help-descriptor</id>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/maven-plugin-plugin/src/it/mplugin-299_no-configuration/invoker.properties b/maven-plugin-plugin/src/it/mplugin-299_no-configuration/invoker.properties
index a9041f9..e7b0b4d 100644
--- a/maven-plugin-plugin/src/it/mplugin-299_no-configuration/invoker.properties
+++ b/maven-plugin-plugin/src/it/mplugin-299_no-configuration/invoker.properties
@@ -1,20 +1,19 @@
-# 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.maven.version = 3.0+
-invoker.goals.1 = clean install -DskipTests
-invoker.goals.2 = --log-file help.log org.apache.maven.its.plugin:help:1.0-SNAPSHOT:help
+# 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.1 = clean install
+invoker.goals.2 = --log-file help.log org.apache.maven.its.plugin:help:1.0-SNAPSHOT:help
diff --git a/maven-plugin-plugin/src/it/mplugin-299_no-configuration/pom.xml b/maven-plugin-plugin/src/it/mplugin-299_no-configuration/pom.xml
index dbb98d7..671a83f 100644
--- a/maven-plugin-plugin/src/it/mplugin-299_no-configuration/pom.xml
+++ b/maven-plugin-plugin/src/it/mplugin-299_no-configuration/pom.xml
@@ -40,11 +40,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
diff --git a/maven-plugin-plugin/src/it/mplugin-305_defaultMojoDependencies/pom.xml b/maven-plugin-plugin/src/it/mplugin-305_defaultMojoDependencies/pom.xml
index 720fac5..770a784 100644
--- a/maven-plugin-plugin/src/it/mplugin-305_defaultMojoDependencies/pom.xml
+++ b/maven-plugin-plugin/src/it/mplugin-305_defaultMojoDependencies/pom.xml
@@ -37,6 +37,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
diff --git a/maven-plugin-plugin/src/it/mplugin-305_emptyMojoDependencies/pom.xml b/maven-plugin-plugin/src/it/mplugin-305_emptyMojoDependencies/pom.xml
index 79d6885..03a3a3d 100644
--- a/maven-plugin-plugin/src/it/mplugin-305_emptyMojoDependencies/pom.xml
+++ b/maven-plugin-plugin/src/it/mplugin-305_emptyMojoDependencies/pom.xml
@@ -37,6 +37,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
diff --git a/maven-plugin-plugin/src/it/mplugin-305_singleMojoDependencies/pom.xml b/maven-plugin-plugin/src/it/mplugin-305_singleMojoDependencies/pom.xml
index e142cc6..456e475 100644
--- a/maven-plugin-plugin/src/it/mplugin-305_singleMojoDependencies/pom.xml
+++ b/maven-plugin-plugin/src/it/mplugin-305_singleMojoDependencies/pom.xml
@@ -37,6 +37,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
diff --git a/maven-plugin-plugin/src/it/mplugin-319_report-since/pom.xml b/maven-plugin-plugin/src/it/mplugin-319_report-since/pom.xml
index f7ad90a..618a3d8 100644
--- a/maven-plugin-plugin/src/it/mplugin-319_report-since/pom.xml
+++ b/maven-plugin-plugin/src/it/mplugin-319_report-since/pom.xml
@@ -37,6 +37,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
@@ -67,7 +68,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.4</version>
+ <version>@projectInfoReportsPlugin@</version>
<reportSets>
<reportSet>
<reports>
diff --git a/maven-plugin-plugin/src/it/mplugin-324_javadoc/pom.xml b/maven-plugin-plugin/src/it/mplugin-324_javadoc/pom.xml
index b63f51c..1b283ed 100644
--- a/maven-plugin-plugin/src/it/mplugin-324_javadoc/pom.xml
+++ b/maven-plugin-plugin/src/it/mplugin-324_javadoc/pom.xml
@@ -40,11 +40,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
@@ -65,7 +61,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>3.0.1</version>
+ <version>3.4.1</version>
<configuration>
<level>private</level>
</configuration>
diff --git a/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/pom.xml b/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/pom.xml
index b72ecc0..699119c 100644
--- a/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/pom.xml
+++ b/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/pom.xml
@@ -40,11 +40,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
diff --git a/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/verify.groovy b/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/verify.groovy
index b64de43..b47f8a9 100644
--- a/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/verify.groovy
+++ b/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/verify.groovy
@@ -17,7 +17,7 @@
* under the License.
*/
-firstRun = new File( basedir, "target/generated-sources-run1/plugin/test/HelpMojo.java" ).text;
-secondRun = new File( basedir, "target/generated-sources/plugin/test/HelpMojo.java" ).text;
+firstRun = new File( basedir, "target/generated-sources-run1/plugin/org/apache/maven/its/plugin/help/HelpMojo.java" ).text;
+secondRun = new File( basedir, "target/generated-sources/plugin/org/apache/maven/its/plugin/help/HelpMojo.java" ).text;
assert firstRun == secondRun;
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 36b0aa3..456b6f1 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
@@ -36,7 +36,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <plexusCompilerVersion>1.8.6</plexusCompilerVersion>
</properties>
<dependencies>
@@ -47,51 +46,31 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>@project.version@</version>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools-annotations</artifactId>
<version>@project.version@</version>
<classifier>tests</classifier>
- </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>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-manager</artifactId>
- <version>${plexusCompilerVersion}</version>
+ <!-- we only need one class FooMojo -->
+ <!-- in order to don't manage all transitive dependencies simply exclude its -->
<exclusions>
<exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-api</artifactId>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-javac</artifactId>
- <version>${plexusCompilerVersion}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
- </dependency>
</dependencies>
<build>
diff --git a/maven-plugin-plugin/src/it/mplugin-372-annotation-with-inheritance-from-provided-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/mplugin-372-annotation-with-inheritance-from-provided-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
index a2a1ba2..6615b6a 100644
--- a/maven-plugin-plugin/src/it/mplugin-372-annotation-with-inheritance-from-provided-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
+++ b/maven-plugin-plugin/src/it/mplugin-372-annotation-with-inheritance-from-provided-deps/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
@@ -64,11 +64,6 @@
{
throw new MojoExecutionException( "projectHelper == null" );
}
- if ( compilerManager == null )
- {
- throw new MojoExecutionException( "compilerManager == null" );
- }
-
}
}
diff --git a/.github/workflows/maven.yml b/maven-plugin-plugin/src/it/mplugin-390/invoker.properties
similarity index 73%
copy from .github/workflows/maven.yml
copy to maven-plugin-plugin/src/it/mplugin-390/invoker.properties
index c136c4a..f8ed77e 100644
--- a/.github/workflows/maven.yml
+++ b/maven-plugin-plugin/src/it/mplugin-390/invoker.properties
@@ -5,9 +5,9 @@
# 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
-#
+#
+# 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
@@ -15,15 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-name: Java CI
-
-on:
- push:
- branches-ignore:
- - dependabot/**
- pull_request:
-
-jobs:
- build:
- name: Verify
- uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v1
+invoker.goals.1 = process-classes
+invoker.goals.2 = process-classes
diff --git a/maven-plugin-plugin/src/it/mplugin-390/pom.xml b/maven-plugin-plugin/src/it/mplugin-390/pom.xml
new file mode 100644
index 0000000..75ed424
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-390/pom.xml
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mplugin-390</groupId>
+ <artifactId>mplugin-390</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>Maven Integration Test :: mplugin-390</name>
+ <description>
+ Test plugin-plugin, plugin.xml descriptor - shouldn't contain dependencies in provided scope
+ </description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>@project.version@</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- dependency in compile scope -->
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-math3</artifactId>
+ <version>3.6.1</version>
+ </dependency>
+
+ <!-- dependency in runtime scope -->
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-rng-client-api</artifactId>
+ <version>1.4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <id>touch</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target>
+ <touch file="${project.build.directory}/touch.txt"/>
+ <sleep milliseconds="100"/>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>@project.version@</version>
+ </plugin>
+ </plugins>
+
+ </build>
+</project>
diff --git a/maven-plugin-plugin/src/it/mplugin-390/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java b/maven-plugin-plugin/src/it/mplugin-390/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
new file mode 100644
index 0000000..b8f7f62
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-390/src/main/java/org/apache/maven/plugin/coreit/FirstMojo.java
@@ -0,0 +1,53 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ * Touches a test file.
+ *
+ * @since 1.2
+ */
+@Mojo( name = "first", requiresDependencyResolution = ResolutionScope.TEST, defaultPhase = LifecyclePhase.INTEGRATION_TEST )
+public class FirstMojo
+ extends AbstractMojo
+{
+
+ /**
+ * @since 0.1
+ * @deprecated As of 0.2
+ */
+ @Parameter( alias = "alias" )
+ private String aliasedParam;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ // nothing
+ }
+}
diff --git a/maven-plugin-plugin/src/it/mplugin-390/verify.groovy b/maven-plugin-plugin/src/it/mplugin-390/verify.groovy
new file mode 100644
index 0000000..000ea82
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-390/verify.groovy
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+File descriptorFile = new File( basedir, "target/classes/META-INF/maven/plugin.xml" );
+assert descriptorFile.isFile()
+
+File touchFile = new File( basedir, "target/touch.txt" );
+assert touchFile.isFile()
+
+// the touch file should be newer than the descriptor
+assert touchFile.lastModified() > descriptorFile.lastModified()
+
+return true;
diff --git a/.github/workflows/maven.yml b/maven-plugin-plugin/src/it/mplugin-394_report-encoding/invoker.properties
similarity index 73%
copy from .github/workflows/maven.yml
copy to maven-plugin-plugin/src/it/mplugin-394_report-encoding/invoker.properties
index c136c4a..9397c3b 100644
--- a/.github/workflows/maven.yml
+++ b/maven-plugin-plugin/src/it/mplugin-394_report-encoding/invoker.properties
@@ -5,9 +5,9 @@
# 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
-#
+#
+# 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
@@ -15,15 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-name: Java CI
-
-on:
- push:
- branches-ignore:
- - dependabot/**
- pull_request:
-
-jobs:
- build:
- name: Verify
- uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v1
+invoker.goals = -Dfile.encoding=CP1252 plugin:report
diff --git a/maven-plugin-plugin/src/it/mplugin-394_report-encoding/pom.xml b/maven-plugin-plugin/src/it/mplugin-394_report-encoding/pom.xml
new file mode 100644
index 0000000..e83b6e7
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-394_report-encoding/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.plugin</groupId>
+ <artifactId>report-encoding</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>Maven Integration Test :: Report Encoding</name>
+ <description>
+ Tests correct usage of configured encoding for reports
+ </description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.report.outputEncoding>UTF-8</project.report.outputEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>@project.version@</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.0</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>@project.version@</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/maven-plugin-plugin/src/it/mplugin-394_report-encoding/src/main/java/test/MyMojo.java b/maven-plugin-plugin/src/it/mplugin-394_report-encoding/src/main/java/test/MyMojo.java
new file mode 100644
index 0000000..9041f19
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-394_report-encoding/src/main/java/test/MyMojo.java
@@ -0,0 +1,50 @@
+package test;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ * Mojo-Description with some non-ASCII characters: €àáâãäåæòóôõöø
+ * <p>
+ * This file is encoded with UTF-8 and Maven is configured with UTF-8 for source
+ * files and UTF-8 as output encoding for the site. Therefore we expect the
+ * generated site to contain all characters from above, even if the system
+ * encoding is not UTF-8.
+ */
+@Mojo( name= "test" )
+public class MyMojo
+ extends AbstractMojo
+{
+
+ /**
+ * Parameter-Description with some non-ASCII characters: ÈÉÊË€
+ */
+ @Parameter
+ private String testParam;
+
+
+ public void execute()
+ {
+ }
+
+}
diff --git a/maven-plugin-plugin/src/it/mplugin-394_report-encoding/verify.groovy b/maven-plugin-plugin/src/it/mplugin-394_report-encoding/verify.groovy
new file mode 100644
index 0000000..f769922
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-394_report-encoding/verify.groovy
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+generated = new File( basedir, "target/generated-site/xdoc/test-mojo.xml").getText("UTF-8")
+
+assert generated.contains("Mojo-Description with some non-ASCII characters: €àáâãäåæòóôõöø")
+assert generated.contains("Parameter-Description with some non-ASCII characters: ÈÉÊË€")
+
+return true;
diff --git a/maven-plugin-plugin/src/it/packaging-jar/pom.xml b/maven-plugin-plugin/src/it/packaging-jar/pom.xml
index ec5702c..268956e 100644
--- a/maven-plugin-plugin/src/it/packaging-jar/pom.xml
+++ b/maven-plugin-plugin/src/it/packaging-jar/pom.xml
@@ -42,22 +42,13 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>@mavenVersion@</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.1</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>@project.version@</version>
- <scope>compile</scope>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/pom.xml b/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/pom.xml
index 8efba42..49df8ba 100644
--- a/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/pom.xml
+++ b/maven-plugin-plugin/src/it/plugin-info-jdk-default-version/pom.xml
@@ -37,6 +37,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
@@ -47,12 +48,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
- <!--
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -73,7 +68,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.4</version>
+ <version>@projectInfoReportsPlugin@</version>
<reportSets>
<reportSet>
<reports>
diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk/pom.xml b/maven-plugin-plugin/src/it/plugin-info-jdk/pom.xml
index d0a198e..051dfd9 100644
--- a/maven-plugin-plugin/src/it/plugin-info-jdk/pom.xml
+++ b/maven-plugin-plugin/src/it/plugin-info-jdk/pom.xml
@@ -42,6 +42,7 @@
<modules>
<module>property</module>
+ <module>propertyRelease</module>
<module>pluginManagement</module>
<module>plugin</module>
<module>requirement</module>
@@ -77,7 +78,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.4</version>
+ <version>@projectInfoReportsPlugin@</version>
<reportSets>
<reportSet>
<reports>
diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/pom.xml b/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/pom.xml
new file mode 100644
index 0000000..948ecda
--- /dev/null
+++ b/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.its.plugin-info-jdk</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>propertyRelease</artifactId>
+ <name>target bytecode defined by maven.compiler.release property</name>
+ <packaging>maven-plugin</packaging>
+
+ <properties>
+ <maven.compiler.release>8</maven.compiler.release><!-- this should take precedence over maven.compiler.target -->
+ <maven.compiler.source>1.3</maven.compiler.source>
+ <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
+ </properties>
+</project>
diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/src/main/resources/META-INF/maven/plugin.xml b/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/src/main/resources/META-INF/maven/plugin.xml
new file mode 100644
index 0000000..df636a1
--- /dev/null
+++ b/maven-plugin-plugin/src/it/plugin-info-jdk/propertyRelease/src/main/resources/META-INF/maven/plugin.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<plugin>
+ <name>target bytecode defined by maven.compiler.release property</name>
+ <description></description>
+ <groupId>org.apache.maven.its.plugin-info-jdk</groupId>
+ <artifactId>propertyRelease</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <goalPrefix>property</goalPrefix>
+ <isolatedRealm>false</isolatedRealm>
+ <inheritedByDefault>true</inheritedByDefault>
+ <mojos>
+ <mojo>
+ <goal>touch</goal>
+ <description>Goal which touches a timestamp file.</description>
+ <requiresDirectInvocation>false</requiresDirectInvocation>
+ <requiresProject>true</requiresProject>
+ <requiresReports>false</requiresReports>
+ <aggregator>false</aggregator>
+ <requiresOnline>false</requiresOnline>
+ <inheritedByDefault>true</inheritedByDefault>
+ <phase>process-sources</phase>
+ <implementation>org.apache.maven.plugins.issues.plugin.MyMojo</implementation>
+ <language>java</language>
+ <instantiationStrategy>per-lookup</instantiationStrategy>
+ <executionStrategy>once-per-session</executionStrategy>
+ <threadSafe>false</threadSafe>
+ <parameters>
+ <parameter>
+ <name>outputDirectory</name>
+ <type>java.io.File</type>
+ <required>true</required>
+ <editable>true</editable>
+ <description>Location of the file.</description>
+ </parameter>
+ </parameters>
+ <configuration>
+ <outputDirectory implementation="java.io.File">${project.build.directory}</outputDirectory>
+ </configuration>
+ </mojo>
+ </mojos>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <type>jar</type>
+ <version>2.0</version>
+ </dependency>
+ </dependencies>
+</plugin>
\ No newline at end of file
diff --git a/maven-plugin-plugin/src/it/plugin-info-jdk/verify.groovy b/maven-plugin-plugin/src/it/plugin-info-jdk/verify.groovy
index 2b43714..947dded 100644
--- a/maven-plugin-plugin/src/it/plugin-info-jdk/verify.groovy
+++ b/maven-plugin-plugin/src/it/plugin-info-jdk/verify.groovy
@@ -18,6 +18,7 @@
*/
assert new File( basedir, 'property/target/site/plugin-info.html' ).text.contains( '<td>1.3</td>' )
+assert new File( basedir, 'propertyRelease/target/site/plugin-info.html' ).text.contains( '<td>8</td>' )
assert new File( basedir, 'pluginManagement/target/site/plugin-info.html' ).text.contains( '<td>1.4</td>' )
assert new File( basedir, 'plugin/target/site/plugin-info.html' ).text.contains( '<td>1.5</td>' )
assert new File( basedir, 'requirement/target/site/plugin-info.html' ).text.contains( '<td>1.8</td>' )
diff --git a/maven-plugin-plugin/src/it/plugin-report-annotations/invoker.properties b/maven-plugin-plugin/src/it/plugin-report-annotations/invoker.properties
index abdde0d..5cc536a 100644
--- a/maven-plugin-plugin/src/it/plugin-report-annotations/invoker.properties
+++ b/maven-plugin-plugin/src/it/plugin-report-annotations/invoker.properties
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals = clean site -DskipTests
+invoker.goals = clean site
diff --git a/maven-plugin-plugin/src/it/plugin-report-annotations/pom.xml b/maven-plugin-plugin/src/it/plugin-report-annotations/pom.xml
index 327bc10..293af03 100644
--- a/maven-plugin-plugin/src/it/plugin-report-annotations/pom.xml
+++ b/maven-plugin-plugin/src/it/plugin-report-annotations/pom.xml
@@ -41,22 +41,35 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>@project.version@</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.reporting</groupId>
- <artifactId>maven-reporting-impl</artifactId>
- <version>3.0.0</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
- <version>3.0</version>
+ <version>@reportingApiVersion@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-impl</artifactId>
+ <version>@reportingImplVersion@</version>
</dependency>
</dependencies>
@@ -100,7 +113,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.4</version>
+ <version>@projectInfoReportsPlugin@</version>
<reportSets>
<reportSet>
<reports>
diff --git a/.github/workflows/maven.yml b/maven-plugin-plugin/src/it/plugin-report-requirements-history/invoker.properties
similarity index 73%
copy from .github/workflows/maven.yml
copy to maven-plugin-plugin/src/it/plugin-report-requirements-history/invoker.properties
index c136c4a..a3d335e 100644
--- a/.github/workflows/maven.yml
+++ b/maven-plugin-plugin/src/it/plugin-report-requirements-history/invoker.properties
@@ -5,9 +5,9 @@
# 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
-#
+#
+# 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
@@ -15,15 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-name: Java CI
-
-on:
- push:
- branches-ignore:
- - dependabot/**
- pull_request:
-
-jobs:
- build:
- name: Verify
- uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v1
+invoker.goals = site
diff --git a/maven-plugin-plugin/src/it/plugin-report-requirements-history/pom.xml b/maven-plugin-plugin/src/it/plugin-report-requirements-history/pom.xml
new file mode 100644
index 0000000..5fa57ea
--- /dev/null
+++ b/maven-plugin-plugin/src/it/plugin-report-requirements-history/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its</groupId>
+ <artifactId>plugin-report</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>MPLUGIN-400</name>
+ <description>
+ Test basic site generation to guard against regression.
+ </description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>@project.version@</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.10.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>@sitePluginVersion@</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>@project.version@</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <reporting>
+ <excludeDefaults>true</excludeDefaults>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <requirementsHistories>
+ <requirementsHistory>
+ <version>1.1.99</version>
+ <maven>3.2.5</maven>
+ <jdk>1.7</jdk>
+ </requirementsHistory>
+ <requirementsHistory>
+ <version>2.0.99</version>
+ <maven>3.8.6</maven>
+ <jdk>1.8</jdk>
+ </requirementsHistory>
+ </requirementsHistories>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
diff --git a/maven-plugin-plugin/src/it/plugin-report-requirements-history/src/main/java/org/MyMojo.java b/maven-plugin-plugin/src/it/plugin-report-requirements-history/src/main/java/org/MyMojo.java
new file mode 100644
index 0000000..82a95ab
--- /dev/null
+++ b/maven-plugin-plugin/src/it/plugin-report-requirements-history/src/main/java/org/MyMojo.java
@@ -0,0 +1,65 @@
+package org;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ * Does nothing.
+ *
+ * @since 1.0
+ * @deprecated You don't use test goals, do you?
+ */
+@Mojo( name = "noop", defaultPhase = LifecyclePhase.PROCESS_SOURCES,
+ requiresDependencyResolution = ResolutionScope.TEST,
+ requiresDirectInvocation = true, requiresOnline = true, inheritByDefault = false, aggregator = true )
+@Execute( phase = LifecyclePhase.COMPILE )
+public class MyMojo
+ extends AbstractMojo
+{
+
+ /**
+ * This is a test.
+ */
+ @SuppressWarnings( "unused" )
+ @Parameter( required = true )
+ private String required;
+
+ /**
+ * This is a test.
+ *
+ * @since 1.1
+ * @deprecated Just testing.
+ */
+ @SuppressWarnings( "unused" )
+ @Parameter( property = "string", defaultValue = "${project.version}/</markup-must-be-escaped>" )
+ private String string;
+
+ public void execute()
+ {
+ // intentional do nothing
+ }
+
+}
diff --git a/maven-plugin-plugin/src/it/plugin-report-requirements-history/verify.groovy b/maven-plugin-plugin/src/it/plugin-report-requirements-history/verify.groovy
new file mode 100644
index 0000000..d573e5e
--- /dev/null
+++ b/maven-plugin-plugin/src/it/plugin-report-requirements-history/verify.groovy
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+assert new File( basedir, 'target/site/noop-mojo.html' ).isFile()
+
+def pluginInfo = new File( basedir, 'target/site/plugin-info.html' )
+assert pluginInfo.isFile()
+
+assert pluginInfo.text.contains('1.1.99')
+assert pluginInfo.text.contains('2.0.99')
+assert pluginInfo.text.contains('3.2.5')
+assert pluginInfo.text.contains('3.8.6')
+assert pluginInfo.text.contains('1.7')
+assert pluginInfo.text.contains('1.8')
diff --git a/maven-plugin-plugin/src/it/plugin-report/invoker.properties b/maven-plugin-plugin/src/it/plugin-report/invoker.properties
index abdde0d..5cc536a 100644
--- a/maven-plugin-plugin/src/it/plugin-report/invoker.properties
+++ b/maven-plugin-plugin/src/it/plugin-report/invoker.properties
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals = clean site -DskipTests
+invoker.goals = clean site
diff --git a/maven-plugin-plugin/src/it/plugin-report/pom.xml b/maven-plugin-plugin/src/it/plugin-report/pom.xml
index e55b56e..290559c 100644
--- a/maven-plugin-plugin/src/it/plugin-report/pom.xml
+++ b/maven-plugin-plugin/src/it/plugin-report/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven-parent</artifactId>
- <version>21</version>
+ <version>34</version>
</parent>
<groupId>org.apache.maven.its</groupId>
@@ -47,16 +47,29 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.maven.reporting</groupId>
- <artifactId>maven-reporting-impl</artifactId>
- <version>3.0.0</version>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
- <version>3.0</version>
+ <version>@reportingApiVersion@</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-impl</artifactId>
+ <version>@reportingImplVersion@</version>
</dependency>
</dependencies>
@@ -81,6 +94,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>@sitePluginVersion@</version>
+ <configuration>
+ <locales>en</locales>
+ </configuration>
</plugin>
</plugins>
</build>
@@ -90,7 +106,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.4</version>
+ <version>@projectInfoReportsPlugin@</version>
<reportSets>
<reportSet>
<reports>
diff --git a/maven-plugin-plugin/src/it/plugin-report/verify.bsh b/maven-plugin-plugin/src/it/plugin-report/verify.bsh
deleted file mode 100644
index 091a10a..0000000
--- a/maven-plugin-plugin/src/it/plugin-report/verify.bsh
+++ /dev/null
@@ -1,56 +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.
- */
-
-import java.io.*;
-import java.util.*;
-import java.util.regex.*;
-
-try
-{
- File siteDir = new File( basedir, "target/site" );
- System.out.println( "Checking for existence of site directory: " + siteDir );
- if ( !siteDir.isDirectory() )
- {
- System.out.println( "FAILED!" );
- return false;
- }
-
- String[] expectedFiles = {
- "noop-mojo.html",
- "noop-mojo.html",
- "report-mojo.html",
- };
- for ( String path : expectedFiles )
- {
- File file = new File( siteDir, path );
- System.out.println( "Checking for existence of doc file: " + file );
- if ( !file.isFile() || file.length() <= 0 )
- {
- System.out.println( "FAILED!" );
- return false;
- }
- }
-}
-catch( Throwable t )
-{
- t.printStackTrace();
- return false;
-}
-
-return true;
diff --git a/maven-plugin-plugin/src/it/plugin-report/verify.groovy b/maven-plugin-plugin/src/it/plugin-report/verify.groovy
new file mode 100644
index 0000000..0da48db
--- /dev/null
+++ b/maven-plugin-plugin/src/it/plugin-report/verify.groovy
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+assert new File( basedir, 'target/site/noop-mojo.html' ).isFile()
+assert new File( basedir, 'target/site/report-mojo.html' ).isFile()
+
+def pluginInfo = new File( basedir, 'target/site/plugin-info.html' )
+assert pluginInfo.isFile()
+
+assert !pluginInfo.text.contains('Memory')
+assert !pluginInfo.text.contains('Disk Space')
+assert !pluginInfo.text.contains('No minimum requirement.')
diff --git a/maven-plugin-plugin/src/it/skip/invoker.properties b/maven-plugin-plugin/src/it/skip/invoker.properties
index 8e51f71..b192273 100644
--- a/maven-plugin-plugin/src/it/skip/invoker.properties
+++ b/maven-plugin-plugin/src/it/skip/invoker.properties
@@ -15,5 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-invoker.goals = install -DskipTests
-invoker.mavenOpts = -Dmaven.plugin.skip=true
\ No newline at end of file
+invoker.goals = install
+invoker.mavenOpts = -Dmaven.plugin.skip=true
diff --git a/maven-plugin-plugin/src/it/source-encoding/latin-1/pom.xml b/maven-plugin-plugin/src/it/source-encoding/latin-1/pom.xml
index e21d6ca..5c2ce92 100644
--- a/maven-plugin-plugin/src/it/source-encoding/latin-1/pom.xml
+++ b/maven-plugin-plugin/src/it/source-encoding/latin-1/pom.xml
@@ -40,7 +40,8 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
- <version>2.0</version>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/maven-plugin-plugin/src/it/source-encoding/utf-8/pom.xml b/maven-plugin-plugin/src/it/source-encoding/utf-8/pom.xml
index a8ddf7f..a68864f 100644
--- a/maven-plugin-plugin/src/it/source-encoding/utf-8/pom.xml
+++ b/maven-plugin-plugin/src/it/source-encoding/utf-8/pom.xml
@@ -40,7 +40,8 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
- <version>2.0</version>
+ <version>@mavenVersion@</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
index bd1354d..a62d923 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
@@ -19,34 +19,14 @@
* under the License.
*/
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.IncludesArtifactFilter;
+import java.util.Collections;
+import java.util.List;
+
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
-import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
-import org.apache.maven.tools.plugin.PluginToolsRequest;
-import org.apache.maven.tools.plugin.extractor.ExtractionException;
-import org.apache.maven.tools.plugin.generator.Generator;
-import org.apache.maven.tools.plugin.generator.GeneratorException;
-import org.apache.maven.tools.plugin.generator.GeneratorUtils;
-import org.apache.maven.tools.plugin.scanner.MojoScanner;
-import org.codehaus.plexus.component.repository.ComponentDependency;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.sonatype.plexus.build.incremental.BuildContext;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
/**
* Abstract class for this Plugin.
@@ -64,99 +44,18 @@
protected MavenProject project;
/**
- * The component used for scanning the source tree for mojos.
- */
- @Component
- protected MojoScanner mojoScanner;
-
- @Component
- protected BuildContext buildContext;
-
- /**
- * The file encoding of the source files.
- *
- * @since 2.5
- */
- @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
- protected String encoding;
-
- /**
* The goal prefix that will appear before the ":".
*/
@Parameter
protected String goalPrefix;
/**
- * By default an exception is throw if no mojo descriptor is found. As the maven-plugin is defined in core, the
- * descriptor generator mojo is bound to generate-resources phase.
- * But for annotations, the compiled classes are needed, so skip error
- *
- * @since 3.0
- */
- @Parameter( property = "maven.plugin.skipErrorNoDescriptorsFound", defaultValue = "false" )
- protected boolean skipErrorNoDescriptorsFound;
-
- /**
- * <p>
- * The role names of mojo extractors to use.
- * </p>
- * <p>
- * If not set, all mojo extractors will be used. If set to an empty extractor name, no mojo extractors
- * will be used.
- * </p>
- * Example:
- * <pre>
- * <!-- Use all mojo extractors -->
- * <extractors/>
- *
- * <!-- Use no mojo extractors -->
- * <extractors>
- * <extractor/>
- * </extractors>
- *
- * <!-- Use only bsh mojo extractor -->
- * <extractors>
- * <extractor>bsh</extractor>
- * </extractors>
- * </pre>
- */
- @Parameter
- protected Set<String> extractors;
-
- /**
* Set this to "true" to skip invoking any goals or reports of the plugin.
*
* @since 2.8
*/
@Parameter( defaultValue = "false", property = "maven.plugin.skip" )
- protected boolean skip;
-
- /**
- * Specify the dependencies as {@code groupId:artifactId} containing (abstract) Mojos, to filter
- * dependencies scanned at runtime and focus on dependencies that are really useful to Mojo analysis.
- * By default, the value is {@code null} and all dependencies are scanned (as before this parameter was added).
- * If specified in the configuration with no children, no dependencies are scanned.
- *
- * @since 3.5
- */
- @Parameter
- private List<String> mojoDependencies = null;
-
- /**
- * List of Remote Repositories used by the resolver
- *
- * @since 3.0
- */
- @Parameter( defaultValue = "${project.remoteArtifactRepositories}", required = true, readonly = true )
- protected List<ArtifactRepository> remoteRepos;
-
- /**
- * Location of the local repository.
- *
- * @since 3.0
- */
- @Parameter( defaultValue = "${localRepository}", required = true, readonly = true )
- protected ArtifactRepository local;
+ private boolean skip;
/**
* Maven plugin packaging types. Default is single "maven-plugin".
@@ -164,55 +63,15 @@
* @since 3.3
*/
@Parameter
- protected List<String> packagingTypes = Collections.singletonList( "maven-plugin" );
-
- /**
- * Flag controlling is "expected dependencies in provided scope" check to be performed or not. Default value:
- * {@code true}.
- *
- * @since 3.6.3
- */
- @Parameter( defaultValue = "true", property = "maven.plugin.checkExpectedProvidedScope" )
- private boolean checkExpectedProvidedScope = true;
-
- /**
- * List of {@code groupId} strings of artifact coordinates that are expected to be in "provided" scope. Default
- * value: {@code ["org.apache.maven"]}.
- *
- * @since 3.6.3
- */
- @Parameter
- private List<String> expectedProvidedScopeGroupIds = Collections.singletonList( "org.apache.maven" );
-
- /**
- * List of {@code groupId:artifactId} strings of artifact coordinates that are to be excluded from "expected
- * provided scope" check. Default value: {@code ["org.apache.maven:maven-archiver", "org.apache.maven:maven-jxr"]}.
- *
- * @since 3.6.3
- */
- @Parameter
- private List<String> expectedProvidedScopeExclusions = Arrays.asList(
- "org.apache.maven:maven-archiver",
- "org.apache.maven:maven-jxr" );
-
- /**
- * @return the output directory where files will be generated.
- */
- protected abstract File getOutputDirectory();
-
- /**
- * @return the wanted <code>Generator</code> implementation.
- */
- protected abstract Generator createGenerator();
+ private List<String> packagingTypes = Collections.singletonList( "maven-plugin" );
/**
* System/OS line separator: used to format console messages.
*/
- private static final String LS = System.lineSeparator();
+ protected static final String LS = System.lineSeparator();
- /**
- * {@inheritDoc}
- */
+ protected abstract void generate() throws MojoExecutionException;
+
@Override
public void execute()
throws MojoExecutionException
@@ -222,6 +81,7 @@
getLog().info( "Unsupported packaging type " + project.getPackaging() + ", execution skipped" );
return;
}
+
if ( skip )
{
getLog().warn( "Execution skipped" );
@@ -230,7 +90,7 @@
if ( !"maven-plugin".equalsIgnoreCase( project.getArtifactId() )
&& project.getArtifactId().toLowerCase().startsWith( "maven-" )
- && project.getArtifactId().toLowerCase().endsWith( "-plugin" )
+ && project.getArtifactId().toLowerCase().endsWith( "-plugin" )
&& !"org.apache.maven.plugins".equals( project.getGroupId() ) )
{
getLog().error( LS + LS + "Artifact Ids of the format maven-___-plugin are reserved for" + LS
@@ -239,29 +99,8 @@
+ "In the future this error will break the build." + LS + LS );
}
- if ( checkExpectedProvidedScope )
- {
- Set<Artifact> wrongScopedArtifacts = dependenciesNotInProvidedScope();
- if ( !wrongScopedArtifacts.isEmpty() )
- {
- StringBuilder errorMessage = new StringBuilder(
- LS + LS + "Some dependencies of Maven Plugins are expected to be in provided scope." + LS
- + "Please make sure that dependencies listed below declared in POM" + LS
- + "have set '<scope>provided</scope>' as well." + LS + LS
- + "The following dependencies are in wrong scope:" + LS
- );
- for ( Artifact artifact : wrongScopedArtifacts )
- {
- errorMessage.append( " * " ).append( artifact ).append( LS );
- }
- errorMessage.append( LS ).append( LS );
-
- getLog().error( errorMessage.toString() );
- }
- }
-
String defaultGoalPrefix = getDefaultGoalPrefix( project );
-
+
if ( goalPrefix == null )
{
goalPrefix = defaultGoalPrefix;
@@ -273,67 +112,7 @@
+ defaultGoalPrefix + "'." + LS );
}
- mojoScanner.setActiveExtractors( extractors );
-
- // TODO: could use this more, eg in the writing of the plugin descriptor!
- PluginDescriptor pluginDescriptor = new PluginDescriptor();
-
- pluginDescriptor.setGroupId( project.getGroupId() );
-
- pluginDescriptor.setArtifactId( project.getArtifactId() );
-
- pluginDescriptor.setVersion( project.getVersion() );
-
- pluginDescriptor.setGoalPrefix( goalPrefix );
-
- pluginDescriptor.setName( project.getName() );
-
- pluginDescriptor.setDescription( project.getDescription() );
-
- if ( encoding == null || encoding.length() < 1 )
- {
- getLog().warn( "Using platform encoding (" + ReaderFactory.FILE_ENCODING
- + " actually) to read mojo source files, i.e. build is platform dependent!" );
- }
- else
- {
- getLog().info( "Using '" + encoding + "' encoding to read mojo source files." );
- }
-
- try
- {
- List<ComponentDependency> deps = GeneratorUtils.toComponentDependencies( project.getArtifacts() );
- pluginDescriptor.setDependencies( deps );
-
- PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
- request.setEncoding( encoding );
- request.setSkipErrorNoDescriptorsFound( skipErrorNoDescriptorsFound );
- request.setDependencies( filterMojoDependencies() );
- request.setLocal( this.local );
- request.setRemoteRepos( this.remoteRepos );
-
- mojoScanner.populatePluginDescriptor( request );
-
- File outputDirectory = getOutputDirectory();
- outputDirectory.mkdirs();
-
- createGenerator().execute( outputDirectory, request );
- buildContext.refresh( outputDirectory );
- }
- catch ( GeneratorException e )
- {
- throw new MojoExecutionException( "Error writing plugin descriptor", e );
- }
- catch ( InvalidPluginDescriptorException | ExtractionException e )
- {
- throw new MojoExecutionException( "Error extracting plugin descriptor: '" + e.getLocalizedMessage() + "'",
- e );
- }
- catch ( LinkageError e )
- {
- throw new MojoExecutionException( "The API of the mojo scanner is not compatible with this plugin version."
- + " Please check the plugin dependencies configured in the POM and ensure the versions match.", e );
- }
+ generate();
}
static String getDefaultGoalPrefix( MavenProject project )
@@ -349,61 +128,4 @@
}
return defaultGoalPrefix;
}
-
- /**
- * Collects all dependencies expected to be in "provided" scope but are NOT in "provided" scope.
- */
- private Set<Artifact> dependenciesNotInProvidedScope()
- {
- LinkedHashSet<Artifact> wrongScopedDependencies = new LinkedHashSet<>();
-
- for ( Artifact dependency : project.getArtifacts() )
- {
- String ga = dependency.getGroupId() + ":" + dependency.getArtifactId();
- if ( expectedProvidedScopeGroupIds.contains( dependency.getGroupId() )
- && !expectedProvidedScopeExclusions.contains( ga )
- && !Artifact.SCOPE_PROVIDED.equals( dependency.getScope() ) )
- {
- wrongScopedDependencies.add( dependency );
- }
- }
-
- return wrongScopedDependencies;
- }
-
- /**
- * Get dependencies filtered with mojoDependencies configuration.
- *
- * @return eventually filtered dependencies, or even <code>null</code> if configured with empty mojoDependencies
- * list
- * @see #mojoDependencies
- */
- private Set<Artifact> filterMojoDependencies()
- {
- Set<Artifact> filteredArtifacts;
- if ( mojoDependencies == null )
- {
- filteredArtifacts = new LinkedHashSet<>( project.getArtifacts() );
- }
- else if ( mojoDependencies.size() == 0 )
- {
- filteredArtifacts = null;
- }
- else
- {
- filteredArtifacts = new LinkedHashSet<>();
-
- ArtifactFilter filter = new IncludesArtifactFilter( mojoDependencies );
-
- for ( Artifact artifact : project.getArtifacts() )
- {
- if ( filter.include( artifact ) )
- {
- filteredArtifacts.add( artifact );
- }
- }
- }
-
- return filteredArtifacts;
- }
}
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
index 9827a77..1a6f329 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java
@@ -20,13 +20,34 @@
*/
import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.IncludesArtifactFilter;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.tools.plugin.generator.Generator;
+import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
+import org.apache.maven.tools.plugin.PluginToolsRequest;
+import org.apache.maven.tools.plugin.extractor.ExtractionException;
+import org.apache.maven.tools.plugin.generator.GeneratorException;
+import org.apache.maven.tools.plugin.generator.GeneratorUtils;
import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
+import org.apache.maven.tools.plugin.scanner.MojoScanner;
+import org.codehaus.plexus.component.repository.ComponentDependency;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.sonatype.plexus.build.incremental.BuildContext;
/**
* <p>
@@ -51,7 +72,15 @@
* The directory where the generated <code>plugin.xml</code> file will be put.
*/
@Parameter( defaultValue = "${project.build.outputDirectory}/META-INF/maven", readonly = true )
- protected File outputDirectory;
+ private File outputDirectory;
+
+ /**
+ * The file encoding of the source files.
+ *
+ * @since 2.5
+ */
+ @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
+ private String encoding;
/**
* A flag to disable generation of the <code>plugin.xml</code> in favor of a hand authored plugin descriptor.
@@ -62,36 +91,259 @@
private boolean skipDescriptor;
/**
- * {@inheritDoc}
+ * <p>
+ * The role names of mojo extractors to use.
+ * </p>
+ * <p>
+ * If not set, all mojo extractors will be used. If set to an empty extractor name, no mojo extractors
+ * will be used.
+ * </p>
+ * Example:
+ * <pre>
+ * <!-- Use all mojo extractors -->
+ * <extractors/>
+ *
+ * <!-- Use no mojo extractors -->
+ * <extractors>
+ * <extractor/>
+ * </extractors>
+ *
+ * <!-- Use only bsh mojo extractor -->
+ * <extractors>
+ * <extractor>bsh</extractor>
+ * </extractors>
+ * </pre>
*/
- @Override
- protected File getOutputDirectory()
- {
- return outputDirectory;
- }
+ @Parameter
+ private Set<String> extractors;
+
/**
- * {@inheritDoc}
+ * By default, an exception is throw if no mojo descriptor is found. As the maven-plugin is defined in core, the
+ * descriptor generator mojo is bound to generate-resources phase.
+ * But for annotations, the compiled classes are needed, so skip error
+ *
+ * @since 3.0
*/
- @Override
- protected Generator createGenerator()
- {
- return new PluginDescriptorGenerator( getLog() );
- }
+ @Parameter( property = "maven.plugin.skipErrorNoDescriptorsFound", defaultValue = "false" )
+ private boolean skipErrorNoDescriptorsFound;
/**
- * {@inheritDoc}
+ * Flag controlling is "expected dependencies in provided scope" check to be performed or not. Default value:
+ * {@code true}.
+ *
+ * @since 3.6.3
*/
- @Override
- public void execute()
+ @Parameter( defaultValue = "true", property = "maven.plugin.checkExpectedProvidedScope" )
+ private boolean checkExpectedProvidedScope = true;
+
+ /**
+ * List of {@code groupId} strings of artifact coordinates that are expected to be in "provided" scope. Default
+ * value: {@code ["org.apache.maven"]}.
+ *
+ * @since 3.6.3
+ */
+ @Parameter
+ private List<String> expectedProvidedScopeGroupIds = Collections.singletonList( "org.apache.maven" );
+
+ /**
+ * List of {@code groupId:artifactId} strings of artifact coordinates that are to be excluded from "expected
+ * provided scope" check. Default value: {@code ["org.apache.maven:maven-archiver", "org.apache.maven:maven-jxr"]}.
+ *
+ * @since 3.6.3
+ */
+ @Parameter
+ private List<String> expectedProvidedScopeExclusions = Arrays.asList(
+ "org.apache.maven:maven-archiver",
+ "org.apache.maven:maven-jxr" );
+
+ /**
+ * Specify the dependencies as {@code groupId:artifactId} containing (abstract) Mojos, to filter
+ * dependencies scanned at runtime and focus on dependencies that are really useful to Mojo analysis.
+ * By default, the value is {@code null} and all dependencies are scanned (as before this parameter was added).
+ * If specified in the configuration with no children, no dependencies are scanned.
+ *
+ * @since 3.5
+ */
+ @Parameter
+ private List<String> mojoDependencies = null;
+
+ /**
+ * List of Remote Repositories used by the resolver
+ *
+ * @since 3.0
+ */
+ @Parameter( defaultValue = "${project.remoteArtifactRepositories}", required = true, readonly = true )
+ private List<ArtifactRepository> remoteRepos;
+
+ /**
+ * Location of the local repository.
+ *
+ * @since 3.0
+ */
+ @Parameter( defaultValue = "${localRepository}", required = true, readonly = true )
+ private ArtifactRepository local;
+
+ /**
+ * The component used for scanning the source tree for mojos.
+ */
+ @Component
+ private MojoScanner mojoScanner;
+
+ @Component
+ protected BuildContext buildContext;
+
+ public void generate()
throws MojoExecutionException
{
+
if ( skipDescriptor )
{
+ getLog().warn( "Execution skipped" );
return;
}
- super.execute();
+ if ( checkExpectedProvidedScope )
+ {
+ Set<Artifact> wrongScopedArtifacts = dependenciesNotInProvidedScope();
+ if ( !wrongScopedArtifacts.isEmpty() )
+ {
+ StringBuilder errorMessage = new StringBuilder(
+ LS + LS + "Some dependencies of Maven Plugins are expected to be in provided scope." + LS
+ + "Please make sure that dependencies listed below declared in POM" + LS
+ + "have set '<scope>provided</scope>' as well." + LS + LS
+ + "The following dependencies are in wrong scope:" + LS
+ );
+ for ( Artifact artifact : wrongScopedArtifacts )
+ {
+ errorMessage.append( " * " ).append( artifact ).append( LS );
+ }
+ errorMessage.append( LS ).append( LS );
+
+ getLog().error( errorMessage.toString() );
+ }
+ }
+
+ mojoScanner.setActiveExtractors( extractors );
+
+ // TODO: could use this more, eg in the writing of the plugin descriptor!
+ PluginDescriptor pluginDescriptor = new PluginDescriptor();
+
+ pluginDescriptor.setGroupId( project.getGroupId() );
+
+ pluginDescriptor.setArtifactId( project.getArtifactId() );
+
+ pluginDescriptor.setVersion( project.getVersion() );
+
+ pluginDescriptor.setGoalPrefix( goalPrefix );
+
+ pluginDescriptor.setName( project.getName() );
+
+ pluginDescriptor.setDescription( project.getDescription() );
+
+ if ( encoding == null || encoding.length() < 1 )
+ {
+ getLog().warn( "Using platform encoding (" + ReaderFactory.FILE_ENCODING
+ + " actually) to read mojo source files, i.e. build is platform dependent!" );
+ }
+ else
+ {
+ getLog().info( "Using '" + encoding + "' encoding to read mojo source files." );
+ }
+
+ try
+ {
+ List<ComponentDependency> deps = GeneratorUtils.toComponentDependencies( project.getArtifacts() );
+ pluginDescriptor.setDependencies( deps );
+
+ PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
+ request.setEncoding( encoding );
+ request.setSkipErrorNoDescriptorsFound( skipErrorNoDescriptorsFound );
+ request.setDependencies( filterMojoDependencies() );
+ request.setLocal( this.local );
+ request.setRemoteRepos( this.remoteRepos );
+
+ mojoScanner.populatePluginDescriptor( request );
+
+ outputDirectory.mkdirs();
+
+ PluginDescriptorGenerator pluginDescriptorGenerator = new PluginDescriptorGenerator();
+ pluginDescriptorGenerator.execute( outputDirectory, request );
+
+ buildContext.refresh( outputDirectory );
+ }
+ catch ( GeneratorException e )
+ {
+ throw new MojoExecutionException( "Error writing plugin descriptor", e );
+ }
+ catch ( InvalidPluginDescriptorException | ExtractionException e )
+ {
+ throw new MojoExecutionException( "Error extracting plugin descriptor: '" + e.getLocalizedMessage() + "'",
+ e );
+ }
+ catch ( LinkageError e )
+ {
+ throw new MojoExecutionException( "The API of the mojo scanner is not compatible with this plugin version."
+ + " Please check the plugin dependencies configured"
+ + " in the POM and ensure the versions match.",
+ e );
+ }
}
+ /**
+ * Collects all dependencies expected to be in "provided" scope but are NOT in "provided" scope.
+ */
+ private Set<Artifact> dependenciesNotInProvidedScope()
+ {
+ LinkedHashSet<Artifact> wrongScopedDependencies = new LinkedHashSet<>();
+
+ for ( Artifact dependency : project.getArtifacts() )
+ {
+ String ga = dependency.getGroupId() + ":" + dependency.getArtifactId();
+ if ( expectedProvidedScopeGroupIds.contains( dependency.getGroupId() )
+ && !expectedProvidedScopeExclusions.contains( ga )
+ && !Artifact.SCOPE_PROVIDED.equals( dependency.getScope() ) )
+ {
+ wrongScopedDependencies.add( dependency );
+ }
+ }
+
+ return wrongScopedDependencies;
+ }
+
+ /**
+ * Get dependencies filtered with mojoDependencies configuration.
+ *
+ * @return eventually filtered dependencies, or even <code>null</code> if configured with empty mojoDependencies
+ * list
+ * @see #mojoDependencies
+ */
+ private Set<Artifact> filterMojoDependencies()
+ {
+ Set<Artifact> filteredArtifacts;
+ if ( mojoDependencies == null )
+ {
+ filteredArtifacts = new LinkedHashSet<>( project.getArtifacts() );
+ }
+ else if ( mojoDependencies.isEmpty() )
+ {
+ filteredArtifacts = null;
+ }
+ else
+ {
+ filteredArtifacts = new LinkedHashSet<>();
+
+ ArtifactFilter filter = new IncludesArtifactFilter( mojoDependencies );
+
+ for ( Artifact artifact : project.getArtifacts() )
+ {
+ if ( filter.include( artifact ) )
+ {
+ filteredArtifacts.add( artifact );
+ }
+ }
+ }
+
+ return filteredArtifacts;
+ }
}
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
index 7cc472e..2d8a291 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java
@@ -19,7 +19,11 @@
* under the License.
*/
+import javax.lang.model.SourceVersion;
+
import java.io.File;
+import java.util.Arrays;
+import java.util.stream.Collectors;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
@@ -27,19 +31,19 @@
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.tools.plugin.generator.Generator;
+import org.apache.maven.tools.plugin.generator.GeneratorException;
import org.apache.maven.tools.plugin.generator.PluginHelpGenerator;
+import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.velocity.VelocityComponent;
/**
* Generates a <code>HelpMojo</code> class.
- *
- * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @since 2.4
*/
@Mojo( name = "helpmojo", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true,
- requiresDependencyResolution = ResolutionScope.COMPILE )
+ requiresDependencyResolution = ResolutionScope.COMPILE )
public class HelpGeneratorMojo
extends AbstractGeneratorMojo
{
@@ -50,9 +54,14 @@
protected File outputDirectory;
/**
- * The name of the package for the generated <code>HelpMojo</code>. By default, the package will be calculated based
- * on the packages of the other plugin goals.
- *
+ * The name of the package for the generated <code>HelpMojo</code>.
+ * <p>
+ * By default, the package name will be calculated as <code>groupId + "." + artifactId</code> with additional
+ * <ul>
+ * <li><code>-</code> (dashes) will be replaced by <code>_</code> (underscores)</li>
+ * <li><code>_</code> (underscore) will be added before each number or Java keyword at the beginning of name</li>
+ * </ul>
+ *
* @since 2.6
*/
@Parameter
@@ -64,41 +73,59 @@
@Component
private VelocityComponent velocity;
- /**
- * {@inheritDoc}
- */
- @Override
- protected File getOutputDirectory()
+ String getHelpPackageName()
{
- return outputDirectory;
+ String packageName = null;
+ if ( StringUtils.isNotBlank( helpPackageName ) )
+ {
+ packageName = helpPackageName;
+ }
+
+ if ( packageName == null )
+ {
+ packageName = project.getGroupId() + "." + project.getArtifactId();
+ packageName = packageName.replace( "-", "_" );
+
+ String[] packageItems = packageName.split( "\\." );
+ packageName = Arrays.stream( packageItems )
+ .map( this::prefixSpecialCase )
+ .collect( Collectors.joining( "." ) );
+ }
+
+ return packageName;
}
- /**
- * {@inheritDoc}
- */
- @Override
- protected Generator createGenerator()
+ private String prefixSpecialCase( String name )
{
- return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setVelocityComponent( this.velocity );
+ if ( SourceVersion.isKeyword( name ) || !Character.isJavaIdentifierStart( name.charAt( 0 ) ) )
+ {
+ name = "_" + name;
+ }
+ return name;
}
- /**
- * {@inheritDoc}
- */
@Override
- public void execute()
- throws MojoExecutionException
+ protected void generate() throws MojoExecutionException
{
- // force value for this plugin
- skipErrorNoDescriptorsFound = true;
+ PluginHelpGenerator pluginHelpGenerator = new PluginHelpGenerator()
+ .setMavenProject( project )
+ .setHelpPackageName( getHelpPackageName() )
+ .setGoalPrefix( goalPrefix )
+ .setVelocityComponent( velocity );
- super.execute();
+ try
+ {
+ pluginHelpGenerator.execute( outputDirectory );
+ }
+ catch ( GeneratorException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
- if ( !project.getCompileSourceRoots().contains( outputDirectory.getAbsolutePath() ) && !skip )
+ if ( !project.getCompileSourceRoots().contains( outputDirectory.getAbsolutePath() ) )
{
project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
}
-
}
}
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginReport.java
similarity index 80%
rename from maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
rename to maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginReport.java
index cb2eee9..2cd448a 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/report/PluginReport.java
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.plugin;
+package org.apache.maven.plugin.plugin.report;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -20,21 +20,18 @@
*/
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
-import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.model.Plugin;
-import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
@@ -51,15 +48,13 @@
import org.apache.maven.rtinfo.RuntimeInformation;
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
import org.apache.maven.tools.plugin.PluginToolsRequest;
-import org.apache.maven.tools.plugin.extractor.ExtractionException;
import org.apache.maven.tools.plugin.generator.GeneratorException;
import org.apache.maven.tools.plugin.generator.GeneratorUtils;
import org.apache.maven.tools.plugin.generator.PluginXdocGenerator;
-import org.apache.maven.tools.plugin.scanner.MojoScanner;
import org.apache.maven.tools.plugin.util.PluginUtils;
-import org.codehaus.plexus.component.repository.ComponentDependency;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.XmlStreamReader;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
@@ -82,28 +77,13 @@
private File outputDirectory;
/**
- * Doxia Site Renderer.
- */
- @Component
- private Renderer siteRenderer;
-
- /**
- * The Maven Project.
- */
- @Parameter( defaultValue = "${project}", readonly = true )
- private MavenProject project;
-
- /**
- * Mojo scanner tools.
- */
- @Component
- protected MojoScanner mojoScanner;
-
- /**
* The file encoding of the source files.
*
+ * @deprecated not used in report, will be removed in the next major version
+ *
* @since 2.7
*/
+ @Deprecated
@Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" )
private String encoding;
@@ -124,11 +104,14 @@
* </others>
* </requirements>
* </pre>
- *
+ * <p>
* If not is specified, Maven requirement is extracted from
* <code><project><prerequisites><maven></code>
* and JDK requirement is extracted from maven-compiler-plugin configuration.
+ *
+ * @deprecated will be removed in the next major version, please don't use
*/
+ @Deprecated
@Parameter
private Requirements requirements;
@@ -149,8 +132,11 @@
* (There is a special case for maven-plugin-plugin: it is mapped to 'plugin')
* </p>
*
+ * @deprecated not used in report, will be removed in the next major version
+ *
* @since 2.4
*/
+ @Deprecated
@Parameter( property = "goalPrefix" )
protected String goalPrefix;
@@ -171,21 +157,34 @@
private boolean skipReport;
/**
- * List of Remote Repositories used by the resolver
+ * Set this to "true" to generate the usage section for "plugin-info.html" with
+ * {@code <extensions>true</extensions>}.
*
- * @since 3.0
+ * @since 3.7.0
*/
- @Parameter( defaultValue = "${project.remoteArtifactRepositories}", required = true, readonly = true )
- protected List<ArtifactRepository> remoteRepos;
+ @Parameter( defaultValue = "false", property = "maven.plugin.report.hasExtensionsToLoad" )
+ private boolean hasExtensionsToLoad;
/**
- * Location of the local repository.
+ * The Plugin requirements history list.
+ * <p>
+ * Can be specified as list of <code>requirementsHistory</code>:
*
- * @since 3.0
+ * <pre>
+ * <requirementsHistories>
+ * <requirementsHistory>
+ * <version>plugin version</version>
+ * <maven>maven version</maven>
+ * <jdk>jdk version</jdk>
+ * </requirementsHistory>
+ * </requirementsHistories>
+ * </pre>
+ *
+ * @since 3.7.0
*/
- @Parameter( defaultValue = "${localRepository}", required = true, readonly = true )
- protected ArtifactRepository local;
-
+ @Parameter
+ private List<RequirementsHistory> requirementsHistories = new ArrayList<>();
+
/**
* @since 3.5.1
*/
@@ -198,22 +197,13 @@
* @since 3.5.1
*/
@Parameter( defaultValue = "${project.build.outputDirectory}/META-INF/maven/plugin.xml", required = true,
- readonly = true )
+ readonly = true )
private File pluginXmlFile;
/**
* {@inheritDoc}
*/
@Override
- protected Renderer getSiteRenderer()
- {
- return siteRenderer;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
protected String getOutputDirectory()
{
// PLUGIN-191: output directory of plugin.html, not *-mojo.xml
@@ -224,15 +214,6 @@
* {@inheritDoc}
*/
@Override
- protected MavenProject getProject()
- {
- return project;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
public boolean canGenerateReport()
{
return pluginXmlFile != null && pluginXmlFile.isFile() && pluginXmlFile.canRead();
@@ -245,10 +226,6 @@
protected void executeReport( Locale locale )
throws MavenReportException
{
- if ( !canGenerateReport() )
- {
- return;
- }
if ( skip || skipReport )
{
getLog().info( "Maven Plugin Plugin Report generation skipped." );
@@ -262,7 +239,8 @@
// Write the overview
PluginOverviewRenderer r =
- new PluginOverviewRenderer( project, requirements, getSink(), pluginDescriptor, locale );
+ new PluginOverviewRenderer( getProject(), requirements, requirementsHistories, getSink(),
+ pluginDescriptor, locale, hasExtensionsToLoad );
r.render();
}
@@ -270,74 +248,23 @@
throws MavenReportException
{
PluginDescriptorBuilder builder = getPluginDescriptorBuilder();
-
- try
+
+ try ( Reader input = new XmlStreamReader( Files.newInputStream( pluginXmlFile.toPath() ) ) )
{
- return builder.build( new FileReader( pluginXmlFile ) );
+ return builder.build( input );
}
- catch ( FileNotFoundException | PlexusConfigurationException e )
+ catch ( IOException | PlexusConfigurationException e )
{
- getLog().debug( "Failed to read " + pluginXmlFile + ", fall back to mojoScanner" );
+ throw new MavenReportException( "Error extracting plugin descriptor from " + pluginXmlFile, e );
}
- // Copy from AbstractGeneratorMojo#execute()
- String defaultGoalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() );
- if ( goalPrefix == null )
- {
- goalPrefix = defaultGoalPrefix;
- }
- else
- {
- getLog().warn( "\n\nGoal prefix is specified as: '" + goalPrefix + "'. Maven currently expects it to be '"
- + defaultGoalPrefix + "'.\n" );
- }
-
- // TODO: could use this more, eg in the writing of the plugin descriptor!
- PluginDescriptor pluginDescriptor = new PluginDescriptor();
-
- pluginDescriptor.setGroupId( project.getGroupId() );
-
- pluginDescriptor.setArtifactId( project.getArtifactId() );
-
- pluginDescriptor.setVersion( project.getVersion() );
-
- pluginDescriptor.setGoalPrefix( goalPrefix );
-
- try
- {
- List<ComponentDependency> deps = GeneratorUtils.toComponentDependencies( project.getArtifacts() );
- pluginDescriptor.setDependencies( deps );
-
- PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
- request.setEncoding( encoding );
- request.setSkipErrorNoDescriptorsFound( true );
- request.setDependencies( new LinkedHashSet<>( project.getArtifacts() ) );
- request.setLocal( this.local );
- request.setRemoteRepos( this.remoteRepos );
-
- try
- {
- mojoScanner.populatePluginDescriptor( request );
- }
- catch ( InvalidPluginDescriptorException e )
- {
- // this is OK, it happens to lifecycle plugins. Allow generation to proceed.
- getLog().debug( "Plugin without mojos.", e );
- }
- }
- catch ( ExtractionException e )
- {
- throw new MavenReportException( "Error extracting plugin descriptor: \'" + e.getLocalizedMessage() + "\'",
- e );
- }
- return pluginDescriptor;
}
/**
- * Return the pluginDescriptorBuilder to use based on the Maven version: either use the original from the
- * maven-plugin-api or a patched version for Maven versions before the MNG-6109 fix
+ * Return the pluginDescriptorBuilder to use based on the Maven version: either use the original from the
+ * maven-plugin-api or a patched version for Maven versions before the MNG-6109 fix
* (because of Maven MNG-6109 bug that won't give accurate 'since' info when reading plugin.xml).
- *
+ *
* @return the proper pluginDescriptorBuilder
* @see <a href="https://issues.apache.org/jira/browse/MNG-6109">MNG-6109</a>
* @see <a href="https://issues.apache.org/jira/browse/MPLUGIN-319">MPLUGIN-319</a>
@@ -400,8 +327,8 @@
File outputDir = outputDirectory;
outputDir.mkdirs();
- PluginXdocGenerator generator = new PluginXdocGenerator( project, locale );
- PluginToolsRequest pluginToolsRequest = new DefaultPluginToolsRequest( project, pluginDescriptor );
+ PluginXdocGenerator generator = new PluginXdocGenerator( getProject(), locale );
+ PluginToolsRequest pluginToolsRequest = new DefaultPluginToolsRequest( getProject(), pluginDescriptor );
generator.execute( outputDir, pluginToolsRequest );
}
catch ( GeneratorException e )
@@ -431,19 +358,25 @@
private final Requirements requirements;
+ private final List<RequirementsHistory> requirementsHistories;
+
private final PluginDescriptor pluginDescriptor;
private final Locale locale;
+ private final boolean hasExtensionsToLoad;
+
/**
- * @param project not null
- * @param requirements not null
- * @param sink not null
- * @param pluginDescriptor not null
- * @param locale not null
+ * @param project not null
+ * @param requirements not null
+ * @param requirementsHistories not null
+ * @param sink not null
+ * @param pluginDescriptor not null
+ * @param locale not null
*/
- PluginOverviewRenderer( MavenProject project, Requirements requirements, Sink sink,
- PluginDescriptor pluginDescriptor, Locale locale )
+ PluginOverviewRenderer( MavenProject project, Requirements requirements,
+ List<RequirementsHistory> requirementsHistories, Sink sink,
+ PluginDescriptor pluginDescriptor, Locale locale, boolean hasExtensionsToLoad )
{
super( sink );
@@ -451,9 +384,13 @@
this.requirements = ( requirements == null ? new Requirements() : requirements );
+ this.requirementsHistories = requirementsHistories;
+
this.pluginDescriptor = pluginDescriptor;
this.locale = locale;
+
+ this.hasExtensionsToLoad = hasExtensionsToLoad;
}
/**
@@ -469,7 +406,6 @@
* {@inheritDoc}
*/
@Override
- @SuppressWarnings( { "unchecked", "rawtypes" } )
public void renderBody()
{
startSection( getTitle() );
@@ -501,11 +437,11 @@
String descriptionColumnName = getBundle( locale ).getString( "report.plugin.goals.column.description" );
if ( hasMavenReport )
{
- tableHeader( new String[]{ goalColumnName, isMavenReport, descriptionColumnName } );
+ tableHeader( new String[] {goalColumnName, isMavenReport, descriptionColumnName} );
}
else
{
- tableHeader( new String[]{ goalColumnName, descriptionColumnName } );
+ tableHeader( new String[] {goalColumnName, descriptionColumnName} );
}
List<MojoDescriptor> mojos = new ArrayList<>();
@@ -581,19 +517,23 @@
( jdk != null ? jdk : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
sink.tableRow_();
- sink.tableRow();
- tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.memory" ) );
- tableCell( ( StringUtils.isNotEmpty( requirements.getMemory() )
- ? requirements.getMemory()
- : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
- sink.tableRow_();
+ String memory = requirements.getMemory();
+ if ( StringUtils.isNotEmpty( memory ) )
+ {
+ sink.tableRow();
+ tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.memory" ) );
+ tableCell( memory );
+ sink.tableRow_();
+ }
- sink.tableRow();
- tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.diskspace" ) );
- tableCell( ( StringUtils.isNotEmpty( requirements.getDiskSpace() )
- ? requirements.getDiskSpace()
- : getBundle( locale ).getString( "report.plugin.systemrequirements.nominimum" ) ) );
- sink.tableRow_();
+ String diskSpace = requirements.getDiskSpace();
+ if ( StringUtils.isNotEmpty( diskSpace ) )
+ {
+ sink.tableRow();
+ tableCell( getBundle( locale ).getString( "report.plugin.systemrequirements.diskspace" ) );
+ tableCell( diskSpace );
+ sink.tableRow_();
+ }
if ( requirements.getOthers() != null && requirements.getOthers().size() > 0 )
{
@@ -613,11 +553,44 @@
endSection();
+ renderRequirementsHistories();
+
renderUsageSection( hasMavenReport );
endSection();
}
+ private void renderRequirementsHistories()
+ {
+ if ( requirementsHistories.isEmpty() )
+ {
+ return;
+ }
+
+ startSection( getBundle( locale ).getString( "report.plugin.systemrequirements.history" ) );
+ paragraph( getBundle( locale ).getString( "report.plugin.systemrequirements.history.intro" ) );
+
+ startTable();
+ tableHeader( new String[] {
+ getBundle( locale ).getString( "report.plugin.systemrequirements.history.version" ),
+ getBundle( locale ).getString( "report.plugin.systemrequirements.history.maven" ),
+ getBundle( locale ).getString( "report.plugin.systemrequirements.history.jdk" )
+ } );
+
+ requirementsHistories.forEach(
+ requirementsHistory ->
+ {
+ sink.tableRow();
+ tableCell( requirementsHistory.getVersion() );
+ tableCell( requirementsHistory.getMaven() );
+ tableCell( requirementsHistory.getJdk() );
+ sink.tableRow_();
+ } );
+ endTable();
+
+ endSection();
+ }
+
/**
* Render the section about the usage of the plugin.
*
@@ -648,6 +621,11 @@
"</artifactId>" ).append( '\n' );
sb.append( " <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" ).append(
'\n' );
+ if ( hasExtensionsToLoad )
+ {
+ sb.append( " <extensions>true</extensions>" ).append(
+ '\n' );
+ }
sb.append( " </plugin>" ).append( '\n' );
sb.append( " ..." ).append( '\n' );
sb.append( " </plugins>" ).append( '\n' );
@@ -660,8 +638,6 @@
'\n' );
sb.append( " <artifactId>" ).append( pluginDescriptor.getArtifactId() ).append(
"</artifactId>" ).append( '\n' );
- sb.append( " <version>" ).append( pluginDescriptor.getVersion() ).append( "</version>" ).append(
- '\n' );
sb.append( " </plugin>" ).append( '\n' );
sb.append( " ..." ).append( '\n' );
sb.append( " </plugins>" ).append( '\n' );
@@ -751,13 +727,19 @@
compiler = getCompilerPlugin( project.getPluginManagement().getPluginsAsMap() );
}
- jdk = getPluginParameter( compiler, "target" );
+ jdk = getPluginParameter( compiler, "release" );
if ( jdk != null )
{
return jdk;
}
- jdk = getPluginParameter( compiler, "release" );
+ jdk = project.getProperties().getProperty( "maven.compiler.release" );
+ if ( jdk != null )
+ {
+ return jdk;
+ }
+
+ jdk = getPluginParameter( compiler, "target" );
if ( jdk != null )
{
return jdk;
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/report/Requirements.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/report/Requirements.java
new file mode 100644
index 0000000..1cc68b7
--- /dev/null
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/report/Requirements.java
@@ -0,0 +1,94 @@
+package org.apache.maven.plugin.plugin.report;
+
+/*
+ * 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.
+ */
+
+import java.util.Properties;
+
+/**
+ * Plugin requirements.
+ *
+ * @deprecated will be removed in the next major version
+ */
+@Deprecated
+public class Requirements
+{
+ /**
+ * The minimum version of Maven to run this plugin.
+ */
+ private String maven;
+
+ /**
+ * The minimum version of the JDK to run this plugin.
+ */
+ private String jdk;
+
+ /**
+ * The minimum memory needed to run this plugin.
+ */
+ private String memory;
+
+ /**
+ * The minimum diskSpace needed to run this plugin.
+ */
+ private String diskSpace;
+
+ /**
+ * Field others.
+ */
+ private java.util.Properties others;
+
+ public String getMaven()
+ {
+ return maven;
+ }
+
+ public String getJdk()
+ {
+ return jdk;
+ }
+
+ public String getMemory()
+ {
+ return memory;
+ }
+
+ public String getDiskSpace()
+ {
+ return diskSpace;
+ }
+
+ public Properties getOthers()
+ {
+ return others;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder( "Requirements{" );
+ sb.append( "maven='" ).append( maven ).append( '\'' );
+ sb.append( ", jdk='" ).append( jdk ).append( '\'' );
+ sb.append( ", memory='" ).append( memory ).append( '\'' );
+ sb.append( ", diskSpace='" ).append( diskSpace ).append( '\'' );
+ sb.append( ", others=" ).append( others );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/report/RequirementsHistory.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/report/RequirementsHistory.java
new file mode 100644
index 0000000..ec3955a
--- /dev/null
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/report/RequirementsHistory.java
@@ -0,0 +1,69 @@
+package org.apache.maven.plugin.plugin.report;
+
+/*
+ * 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.
+ */
+
+/**
+ * Plugin requirements history.
+ *
+ * @author Slawomir Jaranowski
+ */
+public class RequirementsHistory
+{
+ /**
+ * The plugin version.
+ */
+ private String version;
+
+ /**
+ * The minimum version of Maven to run this plugin.
+ */
+ private String maven;
+
+ /**
+ * The minimum version of the JDK to run this plugin.
+ */
+ private String jdk;
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public String getMaven()
+ {
+ return maven;
+ }
+
+ public String getJdk()
+ {
+ return jdk;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder( "RequirementsHistory{" );
+ sb.append( "version='" ).append( version ).append( '\'' );
+ sb.append( ", maven='" ).append( maven ).append( '\'' );
+ sb.append( ", jdk='" ).append( jdk ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
diff --git a/maven-plugin-plugin/src/main/mdo/pluginRequirements.mdo b/maven-plugin-plugin/src/main/mdo/pluginRequirements.mdo
deleted file mode 100644
index 9516b81..0000000
--- a/maven-plugin-plugin/src/main/mdo/pluginRequirements.mdo
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.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.
--->
-
-<model xmlns="https://codehaus-plexus.github.io/MODELLO/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="https://codehaus-plexus.github.io/MODELLO/1.0.0 https://codehaus-plexus.github.io/modello/xsd/modello-1.0.0.xsd">
- <id>pluginRequirements</id>
- <name>PluginRequirements</name>
- <description><![CDATA[Model to specify plugin requirements.]]></description>
- <defaults>
- <default>
- <key>package</key>
- <value>org.apache.maven.plugin.plugin</value>
- </default>
- </defaults>
- <classes>
- <class>
- <name>Requirements</name>
- <description>Plugin requirements.</description>
- <version>1.0.0</version>
- <fields>
- <field>
- <name>maven</name>
- <description>The minimum version of Maven to run this plugin.</description>
- <version>1.0.0</version>
- <type>String</type>
- <identifier>true</identifier>
- </field>
- <field>
- <name>jdk</name>
- <description>The minimum version of the JDK to run this plugin.</description>
- <version>1.0.0</version>
- <type>String</type>
- <identifier>true</identifier>
- </field>
- <field>
- <name>memory</name>
- <description>The minimum memory needed to run this plugin.</description>
- <version>1.0.0</version>
- <type>String</type>
- </field>
- <field>
- <name>diskSpace</name>
- <description>The minimum diskSpace needed to run this plugin.</description>
- <version>1.0.0</version>
- <type>String</type>
- </field>
- <field>
- <name>others</name>
- <description>Others requirements properties.</description>
- <version>1.0.0</version>
- <type>Properties</type>
- <association xml.mapStyle="inline">
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- </field>
- </fields>
- </class>
- </classes>
-</model>
diff --git a/maven-plugin-plugin/src/main/resources/plugin-report.properties b/maven-plugin-plugin/src/main/resources/plugin-report.properties
index 01ee9b3..7d9c45b 100644
--- a/maven-plugin-plugin/src/main/resources/plugin-report.properties
+++ b/maven-plugin-plugin/src/main/resources/plugin-report.properties
@@ -37,12 +37,18 @@
report.plugin.systemrequirements.memory=Memory
report.plugin.systemrequirements.diskspace=Disk Space
+report.plugin.systemrequirements.history=System Requirements History
+report.plugin.systemrequirements.history.intro=The following specifies the minimum requirements to run this Maven plugin for historical versions:
+report.plugin.systemrequirements.history.version=Plugin Version
+report.plugin.systemrequirements.history.maven=Maven
+report.plugin.systemrequirements.history.jdk=JDK
+
report.plugin.usage=Usage
report.plugin.usage.intro=You should specify the version in your project's plugin configuration:
report.plugin.usage.pluginManagement=To define the plugin version in your parent POM
report.plugin.usage.plugins=To use the plugin goals in your POM or parent POM
report.plugin.usage.reporting=To use the report goals in your POM or parent POM
-report.plugin.configuration.end=For more information, see {"Guide to Configuring Plug-ins", http://maven.apache.org/guides/mini/guide-configuring-plugins.html}
+report.plugin.configuration.end=For more information, see {"Guide to Configuring Plug-ins", https://maven.apache.org/guides/mini/guide-configuring-plugins.html}
report.plugin.isReport=Yes
report.plugin.isNotReport=No
diff --git a/maven-plugin-plugin/src/main/resources/plugin-report_de.properties b/maven-plugin-plugin/src/main/resources/plugin-report_de.properties
index 01736e1..e87e5c0 100644
--- a/maven-plugin-plugin/src/main/resources/plugin-report_de.properties
+++ b/maven-plugin-plugin/src/main/resources/plugin-report_de.properties
@@ -21,8 +21,8 @@
report.plugin.description=Dieser Bericht dokumentiert die Goals des Plugins und deren Parameter.
report.plugin.title=Plugin-Dokumentation
-report.plugin.goals.nogoal=Keine Goals verf\u00fcgbar.
-report.plugin.goals.intro=Verf\u00fcgbare Goals dieses Plugins:
+report.plugin.goals.nogoal=Keine Goals verf\u00FCgbar.
+report.plugin.goals.intro=Verf\u00FCgbare Goals dieses Plugins:
report.plugin.goals.column.goal=Goal
report.plugin.goals.column.isMavenReport=Bericht?
report.plugin.goals.column.description=Beschreibung
@@ -30,19 +30,25 @@
report.plugin.goal.deprecated=Missbilligt.
report.plugin.systemrequirements=Systemvoraussetzungen
-report.plugin.systemrequirements.intro=Die folgende Tabelle listet die Mindestanforderungen zum Ausf\u00fchren dieses Plugins auf:
+report.plugin.systemrequirements.intro=Die folgende Tabelle listet die Mindestanforderungen zum Ausf\u00FChren dieses Plugins auf:
report.plugin.systemrequirements.nominimum=Keine Mindestanforderung.
report.plugin.systemrequirements.maven=Maven
report.plugin.systemrequirements.jdk=JDK
report.plugin.systemrequirements.memory=Arbeitsspeicher
report.plugin.systemrequirements.diskspace=Festplatte
+report.plugin.systemrequirements.history=Historie der Systemvoraussetzungen
+report.plugin.systemrequirements.history.intro=In der folgenden Tabelle sind die Mindestanforderungen zum Ausf\u00FChren dieses Plug-ins f\u00FCr historische Versionen aufgef\u00FChrt:
+report.plugin.systemrequirements.history.version=Plugin Version
+report.plugin.systemrequirements.history.maven=Maven
+report.plugin.systemrequirements.history.jdk=JDK
+
report.plugin.usage=Gebrauch
-report.plugin.usage.intro=Geben Sie die gew\u00fcnschte Version einfach in der Plugin-Konfiguration Ihres Projekts an:
+report.plugin.usage.intro=Geben Sie die gew\u00FCnschte Version einfach in der Plugin-Konfiguration Ihres Projekts an:
report.plugin.usage.pluginManagement=Zum Definieren der Plugin-Version in der Eltern-POM
-report.plugin.usage.plugins=Zum Verwenden der Plugin-Goals w\u00e4hrend des Build-Vorgangs eines Projekts
-report.plugin.usage.reporting=Zum Erzeugen der Berichte f\u00fcr die Projektdokumentation
-report.plugin.configuration.end=F\u00fcr weitergehende Informationen lesen Sie bitte den Artikel {"Guide to Configuring Plug-ins", http://maven.apache.org/guides/mini/guide-configuring-plugins.html}.
+report.plugin.usage.plugins=Zum Verwenden der Plugin-Goals w\u00E4hrend des Build-Vorgangs eines Projekts
+report.plugin.usage.reporting=Zum Erzeugen der Berichte f\u00FCr die Projektdokumentation
+report.plugin.configuration.end=F\u00FCr weitergehende Informationen lesen Sie bitte den Artikel {"Guide to Configuring Plug-ins", https://maven.apache.org/guides/mini/guide-configuring-plugins.html}.
report.plugin.isReport=Ja
report.plugin.isNotReport=Nein
diff --git a/maven-plugin-plugin/src/main/resources/plugin-report_fr.properties b/maven-plugin-plugin/src/main/resources/plugin-report_fr.properties
index d71d840..2ac7b3f 100644
--- a/maven-plugin-plugin/src/main/resources/plugin-report_fr.properties
+++ b/maven-plugin-plugin/src/main/resources/plugin-report_fr.properties
@@ -18,7 +18,7 @@
#
report.plugin.name=Documentation du plugin
-report.plugin.description=Ce rapport fournit de la documentation sur les goals et les param\u00eatres d'un plugin.
+report.plugin.description=Ce rapport fournit de la documentation sur les goals et les param\u00EAtres d'un plugin.
report.plugin.title=Documentation du plugin
report.plugin.goals.nogoal=Aucun goal disponible.
@@ -27,22 +27,28 @@
report.plugin.goals.column.isMavenReport=Rapport?
report.plugin.goals.column.description=Description
report.plugin.goal.nodescription=Pas de description.
-report.plugin.goal.deprecated=Obsol\u00e8te.
+report.plugin.goal.deprecated=Obsol\u00E8te.
-report.plugin.systemrequirements=Exigences Syst\u00e8mes
-report.plugin.systemrequirements.intro=Ce qui suit sp\u00e9cifie les exigences minimales pour ex\u00e9cuter ce plugin Maven :
+report.plugin.systemrequirements=Exigences Syst\u00E8mes
+report.plugin.systemrequirements.intro=Ce qui suit sp\u00E9cifie les exigences minimales pour ex\u00E9cuter ce plugin Maven :
report.plugin.systemrequirements.nominimum= Aucune exigence minimale.
report.plugin.systemrequirements.maven=Maven
report.plugin.systemrequirements.jdk=JDK
-report.plugin.systemrequirements.memory=M\u00e9moire
+report.plugin.systemrequirements.memory=M\u00E9moire
report.plugin.systemrequirements.diskspace=Espace Disque
+report.plugin.systemrequirements.history=Historique des Exigences Syst\u00E8mes
+report.plugin.systemrequirements.history.intro=Ce qui suit sp\u00E9cifie les exigences minimales pour ex\u00E9cuter ce plugin Maven pour les versions historiques:
+report.plugin.systemrequirements.history.version=Version du Plugin
+report.plugin.systemrequirements.history.maven=Maven
+report.plugin.systemrequirements.history.jdk=JDK
+
report.plugin.usage=Utilisation
-report.plugin.usage.intro=Vous devez sp\u00e9cifier la version dans la configuration de votre projet :
-report.plugin.usage.pluginManagement=Pour d\u00e9finir la version du plugin dans le POM parent
+report.plugin.usage.intro=Vous devez sp\u00E9cifier la version dans la configuration de votre projet :
+report.plugin.usage.pluginManagement=Pour d\u00E9finir la version du plugin dans le POM parent
report.plugin.usage.plugins=Pour utiliser les goals du plugin dans votre POM ou POM parent
report.plugin.usage.reporting=Pour utiliser les goals de rapports dans votre POM ou POM parent
-report.plugin.configuration.end=Pour plus d'informations, consultez {"Guide to Configuring Plug-ins", http://maven.apache.org/guides/mini/guide-configuring-plugins.html}
+report.plugin.configuration.end=Pour plus d'informations, consultez {"Guide to Configuring Plug-ins", https://maven.apache.org/guides/mini/guide-configuring-plugins.html}
report.plugin.isReport=Oui
report.plugin.isNotReport=Non
diff --git a/maven-plugin-plugin/src/main/resources/plugin-report_sv.properties b/maven-plugin-plugin/src/main/resources/plugin-report_sv.properties
index cf04795..0e806e4 100644
--- a/maven-plugin-plugin/src/main/resources/plugin-report_sv.properties
+++ b/maven-plugin-plugin/src/main/resources/plugin-report_sv.properties
@@ -18,31 +18,37 @@
#
report.plugin.name=Plugindokumentation
-report.plugin.description=Denna rapport tillhandahåller mål- och parameterdokumentation för en plugin.
+report.plugin.description=Denna rapport tillhandah\u00E5ller m\u00E5l- och parameterdokumentation f\u00F6r en plugin.
report.plugin.title=Plugindokumentation
-report.plugin.goals.nogoal=Inga mål tillgängliga ännu.
-report.plugin.goals.intro=Tillgängliga mål för denna plugin:
-report.plugin.goals.column.goal=Mål
+report.plugin.goals.nogoal=Inga m\u00E5l tillg\u00E4ngliga \u00E4nnu.
+report.plugin.goals.intro=Tillg\u00E4ngliga m\u00E5l f\u00F6r denna plugin:
+report.plugin.goals.column.goal=M\u00E5l
report.plugin.goals.column.isMavenReport=Rapport?
report.plugin.goals.column.description=Beskrivning
report.plugin.goal.nodescription=Ingen beskrivning.
-report.plugin.goal.deprecated=Föråldrat.
+report.plugin.goal.deprecated=F\u00F6r\u00E5ldrat.
report.plugin.systemrequirements=Systemkrav
-report.plugin.systemrequirements.intro=Följande minimikrav ställs för att köra denna Maven plugin:
+report.plugin.systemrequirements.intro=F\u00F6ljande minimikrav st\u00E4lls f\u00F6r att k\u00F6ra denna Maven plugin:
report.plugin.systemrequirements.nominimum= Inga minimikrav.
report.plugin.systemrequirements.maven=Maven
report.plugin.systemrequirements.jdk=JDK
report.plugin.systemrequirements.memory=Minne
report.plugin.systemrequirements.diskspace=Diskutrymme
-report.plugin.usage=Användning
-report.plugin.usage.intro=Du bör specificera versionen i ditt projekts pluginkonfiguration:
-report.plugin.usage.pluginManagement=För att definiera pluginversion i din föräldra-POM
-report.plugin.usage.plugins=För att använda plugin-målen i din POM eller föräldra-POM
-report.plugin.usage.reporting=För att använda rapport-målen i din POM eller föräldra-POM
-report.plugin.configuration.end=För mer information, läs {"Guide to Configuring Plug-ins", http://maven.apache.org/guides/mini/guide-configuring-plugins.html} (på engelska).
+report.plugin.systemrequirements.history=Systemkravshistorik
+report.plugin.systemrequirements.history.intro=F\u00F6ljande anger minimikraven f\u00F6r att k\u00F6ra detta Maven-plugin f\u00F6r historiska versioner:
+report.plugin.systemrequirements.history.version=Plugin Version
+report.plugin.systemrequirements.history.maven=Maven
+report.plugin.systemrequirements.history.jdk=JDK
+
+report.plugin.usage=Anv\u00E4ndning
+report.plugin.usage.intro=Du b\u00F6r specificera versionen i ditt projekts pluginkonfiguration:
+report.plugin.usage.pluginManagement=F\u00F6r att definiera pluginversion i din f\u00F6r\u00E4ldra-POM
+report.plugin.usage.plugins=F\u00F6r att anv\u00E4nda plugin-m\u00E5len i din POM eller f\u00F6r\u00E4ldra-POM
+report.plugin.usage.reporting=F\u00F6r att anv\u00E4nda rapport-m\u00E5len i din POM eller f\u00F6r\u00E4ldra-POM
+report.plugin.configuration.end=F\u00F6r mer information, l\u00E4s {"Guide to Configuring Plug-ins", https://maven.apache.org/guides/mini/guide-configuring-plugins.html} (p\u00E5 engelska).
report.plugin.isReport=Ja
report.plugin.isNotReport=Nej
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 d1e8c3b..5c36330 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.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-plugin/src/test/java/org/apache/maven/plugin/plugin/HelpGeneratorMojoTest.java b/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/HelpGeneratorMojoTest.java
new file mode 100644
index 0000000..5d65709
--- /dev/null
+++ b/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/HelpGeneratorMojoTest.java
@@ -0,0 +1,63 @@
+package org.apache.maven.plugin.plugin;
+
+/*
+ * 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.
+ */
+
+import java.util.stream.Stream;
+
+import org.apache.maven.project.MavenProject;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class HelpGeneratorMojoTest
+{
+
+ public static Stream<Arguments> packageNameShouldBeCorrect()
+ {
+ return Stream.of(
+ Arguments.of( aProject( "groupId", "artifactId" ), "groupId.artifactId" ),
+ Arguments.of( aProject( "groupId", "123-artifactId" ), "groupId._123_artifactId" ),
+ Arguments.of( aProject( "group-Id", "artifact-Id" ), "group_Id.artifact_Id" ),
+ Arguments.of( aProject( "group-Id", "int" ), "group_Id._int" )
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource
+ void packageNameShouldBeCorrect( MavenProject project, String expectedPackageName )
+ {
+ HelpGeneratorMojo mojo = new HelpGeneratorMojo();
+ mojo.project = project;
+
+ String packageName = mojo.getHelpPackageName();
+ assertEquals( expectedPackageName, packageName );
+ }
+
+ private static MavenProject aProject( String groupId, String artifactId )
+ {
+
+ MavenProject mavenProject = new MavenProject();
+ mavenProject.setGroupId( groupId );
+ mavenProject.setArtifactId( artifactId );
+ return mavenProject;
+ }
+}
diff --git a/maven-plugin-tools-annotations/pom.xml b/maven-plugin-tools-annotations/pom.xml
index c929034..d20cf64 100644
--- a/maven-plugin-tools-annotations/pom.xml
+++ b/maven-plugin-tools-annotations/pom.xml
@@ -62,19 +62,13 @@
<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>
<artifactId>plexus-archiver</artifactId>
- <version>4.2.5</version><!-- Java 7 -->
</dependency>
<dependency>
@@ -88,25 +82,23 @@
</dependency>
<dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-compiler-manager</artifactId>
- <version>2.8.8</version><!-- Java 7 -->
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<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>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
- <version>2.9.1</version><!-- Java 7 -->
<scope>test</scope>
</dependency>
</dependencies>
@@ -114,6 +106,10 @@
<build>
<plugins>
<plugin>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>sisu-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
@@ -125,10 +121,6 @@
</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>
<executions>
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 ca68e32..973d2e0 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 @@
* 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.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 @@
* @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
@@ -563,6 +567,7 @@
parameter.setName( name );
parameter.setAlias( parameterAnnotationContent.alias() );
parameter.setDefaultValue( parameterAnnotationContent.defaultValue() );
+ parameter.setImplementation( parameterAnnotationContent.getImplementationClassName() );
parameter.setDeprecated( parameterAnnotationContent.getDeprecated() );
parameter.setDescription( parameterAnnotationContent.getDescription() );
parameter.setEditable( !parameterAnnotationContent.readonly() );
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java
index 1db117a..3d9f892 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/datamodel/ParameterAnnotationContent.java
@@ -20,8 +20,10 @@
*/
import org.apache.maven.plugins.annotations.Parameter;
+import org.objectweb.asm.Type;
import java.lang.annotation.Annotation;
+import java.util.Objects;
/**
* @author Olivier Lamy
@@ -40,6 +42,8 @@
private String defaultValue;
+ private String implementationClassName;
+
private boolean required = false;
private boolean readonly = false;
@@ -53,12 +57,13 @@
}
public ParameterAnnotationContent( String fieldName, String alias, String property, String defaultValue,
- boolean required, boolean readonly, String className )
+ Class<?> implementation, boolean required, boolean readonly, String className )
{
this( fieldName, className );
this.alias = alias;
this.property = property;
this.defaultValue = defaultValue;
+ this.implementationClassName = implementation != null ? implementation.getName() : null;
this.required = required;
this.readonly = readonly;
}
@@ -107,6 +112,33 @@
this.defaultValue = defaultValue;
}
+ public void implementation( Type implementation )
+ {
+
+ implementationClassName = implementation.getClassName();
+ if ( implementationClassName.equals( Object.class.getName() ) )
+ {
+ // Object is default value for implementation attribute
+ this.implementationClassName = null;
+ }
+ }
+
+ public String getImplementationClassName()
+ {
+ return implementationClassName;
+ }
+
+ @Override
+ public Class<?> implementation()
+ {
+ // needed for implementing @Parameter
+ // we don't have access to project class path,
+ // so loading class is not possible without build additional classLoader
+ // we only operate on classes names
+ throw new UnsupportedOperationException(
+ "please use getImplementationClassName instead of implementation method" );
+ }
+
@Override
public boolean required()
{
@@ -151,10 +183,14 @@
final StringBuilder sb = new StringBuilder();
sb.append( super.toString() );
sb.append( "ParameterAnnotationContent" );
- sb.append( "{name='" ).append( name ).append( '\'' );
+ sb.append( "{fieldName='" ).append( getFieldName() ).append( '\'' );
+ sb.append( ", className='" ).append( getClassName() ).append( '\'' );
+ sb.append( ", name='" ).append( name ).append( '\'' );
+ sb.append( ", alias='" ).append( alias ).append( '\'' );
sb.append( ", alias='" ).append( alias ).append( '\'' );
sb.append( ", property='" ).append( property ).append( '\'' );
sb.append( ", defaultValue='" ).append( defaultValue ).append( '\'' );
+ sb.append( ", implementation='" ).append( implementationClassName ).append( '\'' );
sb.append( ", required=" ).append( required );
sb.append( ", readonly=" ).append( readonly );
sb.append( '}' );
@@ -189,15 +225,24 @@
return false;
}
- if ( alias != null ? !alias.equals( that.alias ) : that.alias != null )
+ if ( getClassName() != null ? !getClassName().equals( that.getClassName() ) : that.getClassName() != null )
{
return false;
}
- if ( defaultValue != null ? !defaultValue.equals( that.defaultValue ) : that.defaultValue != null )
+
+ if ( !Objects.equals( alias, that.alias ) )
{
return false;
}
- if ( property != null ? !property.equals( that.property ) : that.property != null )
+ if ( !Objects.equals( defaultValue, that.defaultValue ) )
+ {
+ return false;
+ }
+ if ( !Objects.equals( property, that.property ) )
+ {
+ return false;
+ }
+ if ( !Objects.equals( implementationClassName, that.implementationClassName ) )
{
return false;
}
@@ -208,12 +253,7 @@
@Override
public int hashCode()
{
- int result = alias != null ? alias.hashCode() : 0;
- result = 31 * result + ( getFieldName() != null ? getFieldName().hashCode() : 0 );
- result = 31 * result + ( property != null ? property.hashCode() : 0 );
- result = 31 * result + ( defaultValue != null ? defaultValue.hashCode() : 0 );
- result = 31 * result + ( required ? 1 : 0 );
- result = 31 * result + ( readonly ? 1 : 0 );
- return result;
+ return Objects.hash( alias, getFieldName(), property, defaultValue, required, readonly,
+ implementationClassName );
}
}
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 d53848f..0407b8e 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 @@
* 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,14 +59,16 @@
* @author Olivier Lamy
* @since 3.0
*/
-@org.codehaus.plexus.component.annotations.Component( role = MojoAnnotationsScanner.class )
+@Named
+@Singleton
public class DefaultMojoAnnotationsScanner
extends AbstractLogEnabled
implements MojoAnnotationsScanner
{
// classes with a dash must be ignored
private static final Pattern SCANNABLE_CLASS = Pattern.compile( "[^-]+\\.class" );
-
+ private static final String EMPTY = "";
+
private Reflector reflector = new Reflector();
@Override
@@ -271,6 +276,12 @@
{
MojoAnnotationContent mojoAnnotationContent = new MojoAnnotationContent();
populateAnnotationContent( mojoAnnotationContent, mojoAnnotationVisitor );
+
+ if ( mojoClassVisitor.getAnnotationVisitor( Deprecated.class ) != null )
+ {
+ mojoAnnotationContent.setDeprecated( EMPTY );
+ }
+
mojoAnnotatedClass.setMojo( mojoAnnotationContent );
}
@@ -289,10 +300,15 @@
{
ParameterAnnotationContent parameterAnnotationContent =
new ParameterAnnotationContent( mojoFieldVisitor.getFieldName(), mojoFieldVisitor.getClassName() );
- if ( mojoFieldVisitor.getMojoAnnotationVisitor() != null )
+
+ Map<String, MojoAnnotationVisitor> annotationVisitorMap = mojoFieldVisitor.getAnnotationVisitorMap();
+ MojoAnnotationVisitor fieldAnnotationVisitor = annotationVisitorMap.get( Parameter.class.getName() );
+
+ populateAnnotationContent( parameterAnnotationContent, fieldAnnotationVisitor );
+
+ if ( annotationVisitorMap.containsKey( Deprecated.class.getName() ) )
{
- populateAnnotationContent( parameterAnnotationContent,
- mojoFieldVisitor.getMojoAnnotationVisitor() );
+ parameterAnnotationContent.setDeprecated( EMPTY );
}
mojoAnnotatedClass.getParameters().put( parameterAnnotationContent.getFieldName(),
@@ -306,7 +322,9 @@
ComponentAnnotationContent componentAnnotationContent =
new ComponentAnnotationContent( mojoFieldVisitor.getFieldName() );
- MojoAnnotationVisitor annotationVisitor = mojoFieldVisitor.getMojoAnnotationVisitor();
+ Map<String, MojoAnnotationVisitor> annotationVisitorMap = mojoFieldVisitor.getAnnotationVisitorMap();
+ MojoAnnotationVisitor annotationVisitor = annotationVisitorMap.get( Component.class.getName() );
+
if ( annotationVisitor != null )
{
for ( Map.Entry<String, Object> entry : annotationVisitor.getAnnotationValues().entrySet() )
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScanner.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScanner.java
index a5add2f..a4e7619 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScanner.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScanner.java
@@ -37,9 +37,13 @@
{
String ROLE = MojoAnnotationsScanner.class.getName();
- List<String> CLASS_LEVEL_ANNOTATIONS = Arrays.asList( Mojo.class.getName(), Execute.class.getName() );
+ List<String> CLASS_LEVEL_ANNOTATIONS = Arrays.asList( Mojo.class.getName(),
+ Execute.class.getName(),
+ Deprecated.class.getName() );
- List<String> FIELD_LEVEL_ANNOTATIONS = Arrays.asList( Parameter.class.getName(), Component.class.getName() );
+ List<String> FIELD_LEVEL_ANNOTATIONS = Arrays.asList( Parameter.class.getName(),
+ Component.class.getName(),
+ Deprecated.class.getName() );
/**
* Scan classes for mojo annotations.
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java
index 6ebf4c6..4012034 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoClassVisitor.java
@@ -34,7 +34,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
/**
* @author Olivier Lamy
@@ -96,13 +95,13 @@
{
String annotationClassName = annotation.getName();
- List<MojoFieldVisitor> mojoFieldVisitors = new ArrayList<MojoFieldVisitor>();
+ List<MojoFieldVisitor> mojoFieldVisitors = new ArrayList<>();
for ( MojoFieldVisitor mojoFieldVisitor : this.fieldVisitors )
{
- MojoAnnotationVisitor mojoAnnotationVisitor = mojoFieldVisitor.getMojoAnnotationVisitor();
- if ( mojoAnnotationVisitor != null && Objects.equals( annotationClassName,
- mojoAnnotationVisitor.getAnnotationClassName() ) )
+ Map<String, MojoAnnotationVisitor> filedVisitorMap = mojoFieldVisitor.getAnnotationVisitorMap();
+
+ if ( filedVisitorMap.containsKey( annotationClassName ) )
{
mojoFieldVisitors.add( mojoFieldVisitor );
}
diff --git a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoFieldVisitor.java b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoFieldVisitor.java
index b3d0353..f69ae06 100644
--- a/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoFieldVisitor.java
+++ b/maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/visitors/MojoFieldVisitor.java
@@ -19,6 +19,9 @@
* under the License.
*/
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.maven.tools.plugin.extractor.annotations.scanner.MojoAnnotationsScanner;
import org.codehaus.plexus.logging.Logger;
import org.objectweb.asm.AnnotationVisitor;
@@ -38,7 +41,7 @@
private String fieldName;
- private MojoAnnotationVisitor mojoAnnotationVisitor;
+ private Map<String, MojoAnnotationVisitor> annotationVisitorMap = new HashMap<>();
private String className;
@@ -50,9 +53,9 @@
this.className = className;
}
- public MojoAnnotationVisitor getMojoAnnotationVisitor()
+ public Map<String, MojoAnnotationVisitor> getAnnotationVisitorMap()
{
- return mojoAnnotationVisitor;
+ return annotationVisitorMap;
}
public String getFieldName()
@@ -68,7 +71,8 @@
{
return null;
}
- mojoAnnotationVisitor = new MojoAnnotationVisitor( logger, annotationClassName );
+ MojoAnnotationVisitor mojoAnnotationVisitor = new MojoAnnotationVisitor( logger, annotationClassName );
+ annotationVisitorMap.put( annotationClassName, mojoAnnotationVisitor );
return mojoAnnotationVisitor;
}
diff --git a/maven-plugin-tools-annotations/src/site/apt/index.apt b/maven-plugin-tools-annotations/src/site/apt/index.apt
index 7ffc3ba..db372a2 100644
--- a/maven-plugin-tools-annotations/src/site/apt/index.apt
+++ b/maven-plugin-tools-annotations/src/site/apt/index.apt
@@ -83,6 +83,7 @@
alias = "myAlias",
property = "a.property",
defaultValue = "an expression, possibly with ${variables}",
+ implementation = "class of implementation in the case the parameter type is an interface"
readonly = <false|true>,
required = <false|true> )
private String parameter;
diff --git a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/DeprecatedMojo.java b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/DeprecatedMojo.java
new file mode 100644
index 0000000..74e9768
--- /dev/null
+++ b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/DeprecatedMojo.java
@@ -0,0 +1,43 @@
+package org.apache.maven.tools.plugin.extractor.annotations;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+@Deprecated
+@Mojo( name = "deprecated-mojo" )
+public class DeprecatedMojo extends AbstractMojo
+{
+ @Deprecated
+ @Parameter( alias = "deprecatedParametersAlias" )
+ private String deprecatedParameters;
+
+ @Parameter( property = "property.anotherNotDeprecated" )
+ private String anotherNotDeprecated;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ }
+}
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterface.java
similarity index 60%
copy from maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
copy to maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterface.java
index ce4f919..f893293 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
+++ b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterface.java
@@ -1,4 +1,4 @@
-package org.apache.maven.tools.plugin.generator;
+package org.apache.maven.tools.plugin.extractor.annotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,22 +19,6 @@
* under the License.
*/
-import org.codehaus.plexus.velocity.VelocityComponent;
-
-/**
- * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
- */
-public class PluginHelpGeneratorTest
- extends AbstractGeneratorTestCase
+public interface FooInterface
{
- // inherits tests from base class
- @Override
- protected void setupGenerator()
- throws Exception
- {
-
- generator =
- new PluginHelpGenerator().setVelocityComponent( (VelocityComponent) lookup( VelocityComponent.ROLE ) );
-
- }
}
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterfaceImpl.java
similarity index 60%
copy from maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
copy to maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterfaceImpl.java
index ce4f919..99f593b 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginHelpGeneratorTest.java
+++ b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooInterfaceImpl.java
@@ -1,4 +1,4 @@
-package org.apache.maven.tools.plugin.generator;
+package org.apache.maven.tools.plugin.extractor.annotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,22 +19,6 @@
* under the License.
*/
-import org.codehaus.plexus.velocity.VelocityComponent;
-
-/**
- * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
- */
-public class PluginHelpGeneratorTest
- extends AbstractGeneratorTestCase
+public class FooInterfaceImpl implements FooInterface
{
- // inherits tests from base class
- @Override
- protected void setupGenerator()
- throws Exception
- {
-
- generator =
- new PluginHelpGenerator().setVelocityComponent( (VelocityComponent) lookup( VelocityComponent.ROLE ) );
-
- }
}
diff --git a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java
index 3543dd2..36dd973 100644
--- a/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java
+++ b/maven-plugin-tools-annotations/src/test/java/org/apache/maven/tools/plugin/extractor/annotations/FooMojo.java
@@ -27,7 +27,6 @@
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
-import org.codehaus.plexus.compiler.manager.CompilerManager;
/**
* @author Olivier Lamy
@@ -45,6 +44,12 @@
protected String bar;
/**
+ * Interface type as parameter.
+ */
+ @Parameter( property = "fooInterface", implementation = FooInterfaceImpl.class )
+ protected FooInterface fooInterface;
+
+ /**
* beer for non french folks
* @deprecated wine is better
*/
@@ -53,12 +58,6 @@
protected String beer;
/**
- * Plexus compiler manager.
- */
- @Component
- protected CompilerManager compilerManager;
-
- /**
*
*/
@Component( role = ArtifactMetadataSource.class, hint = "maven" )
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 1f43e56..797f46e 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 @@
* 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.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" ) );
@@ -79,12 +89,21 @@
assertEquals( LifecyclePhase.PACKAGE, execute.phase() );
Collection<ComponentAnnotationContent> components = mojoAnnotatedClass.getComponents().values();
- assertThat( components ).isNotNull().isNotEmpty().hasSize( 2 );
+ assertThat( components ).isNotNull().isNotEmpty().hasSize( 1 );
Collection<ParameterAnnotationContent> parameters = mojoAnnotatedClass.getParameters().values();
- assertThat( parameters ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
- new ParameterAnnotationContent( "bar", null, "thebar", "coolbar", true, false, String.class.getName() ),
- new ParameterAnnotationContent( "beer", null, "thebeer", "coolbeer", false, false,
- String.class.getName() ) );
+ assertThat( parameters ).isNotNull()
+ .isNotEmpty()
+ .hasSize( 3 )
+ .contains(
+ new ParameterAnnotationContent( "bar", null, "thebar", "coolbar", null, true, false,
+ String.class.getName() ),
+ new ParameterAnnotationContent( "beer", null, "thebeer", "coolbeer", null, false, false,
+ String.class.getName() ),
+ new ParameterAnnotationContent( "fooInterface", null, "fooInterface", null,
+ FooInterfaceImpl.class,
+ false,
+ false, FooInterface.class.getName() )
+ );
}
}
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 11508b8..87dfc4e 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,28 +19,61 @@
* under the License.
*/
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.maven.tools.plugin.extractor.ExtractionException;
+import org.apache.maven.tools.plugin.extractor.annotations.DeprecatedMojo;
+import org.codehaus.plexus.logging.Logger;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
-import java.io.File;
-
-import org.codehaus.plexus.logging.Logger;
-import org.junit.Test;
-
-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 );
+ 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 );
+ scanner.scanArchive( new File( "target/test-classes/java8-annotations.jar" ), null, false );
+ }
+
+ @Test
+ void scanDeprecatedMojoAnnotatins() throws ExtractionException, IOException
+ {
+ File directoryToScan = new File( DeprecatedMojo.class.getResource( "" ).getFile() );
+
+ scanner.enableLogging( mock( Logger.class ) );
+ Map<String, MojoAnnotatedClass> result = scanner.scanDirectory(
+ directoryToScan, Collections.singletonList( "DeprecatedMojo.class" ), null, false );
+
+ assertThat( result ).hasSize( 1 );
+
+ MojoAnnotatedClass annotatedClass = result.get( DeprecatedMojo.class.getName() );
+ assertThat( annotatedClass.getClassName() ).isEqualTo( DeprecatedMojo.class.getName() );
+ assertThat( annotatedClass.getMojo().getDeprecated() ).isEmpty();
+
+ assertThat( annotatedClass.getParameters() )
+ .containsOnlyKeys( "deprecatedParameters", "anotherNotDeprecated" );
+
+ assertThat( annotatedClass.getParameters().get( "deprecatedParameters" ).getDeprecated() ).isEmpty();
+ assertThat( annotatedClass.getParameters().get( "deprecatedParameters" ).alias() )
+ .isEqualTo( "deprecatedParametersAlias" );
+
+ assertThat( annotatedClass.getParameters().get( "anotherNotDeprecated" ).getDeprecated() ).isNull();
+ assertThat( annotatedClass.getParameters().get( "anotherNotDeprecated" ).property() )
+ .isEqualTo( "property.anotherNotDeprecated" );
}
}
diff --git a/maven-plugin-tools-api/pom.xml b/maven-plugin-tools-api/pom.xml
index 75ab377..1fb86d6 100644
--- a/maven-plugin-tools-api/pom.xml
+++ b/maven-plugin-tools-api/pom.xml
@@ -51,11 +51,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-settings</artifactId>
- </dependency>
-
+
<!-- plexus -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
@@ -64,13 +60,8 @@
<!-- test -->
<dependency>
- <groupId>org.apache.maven.plugin-testing</groupId>
- <artifactId>maven-plugin-testing-harness</artifactId>
- <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>
@@ -78,6 +69,10 @@
<build>
<plugins>
<plugin>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>sisu-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
index 8955ffb..ee11cbc 100644
--- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
+++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/extractor/AbstractScriptedMojoDescriptorExtractor.java
@@ -37,8 +37,10 @@
import org.codehaus.plexus.util.StringUtils;
/**
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
* @author jdcasey
*/
+@Deprecated
public abstract class AbstractScriptedMojoDescriptorExtractor
extends AbstractLogEnabled
implements MojoDescriptorExtractor
@@ -75,6 +77,12 @@
copyScriptsToOutputDirectory( scriptFilesKeyedByBasedir, project.getBuild().getOutputDirectory(), request );
+ if ( !mojoDescriptors.isEmpty() )
+ {
+ getLogger().warn( "Scripting support for mojos is deprecated and is planned to be removed in Maven 4." );
+ getLogger().warn( "Found " + mojoDescriptors.size() + " scripted mojos." );
+ }
+
return mojoDescriptors;
}
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 67dc5dc..f53484d 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 @@
* 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 @@
/**
* @author jdcasey
*/
+@Named
public class DefaultMojoScanner
extends AbstractLogEnabled
implements MojoScanner
@@ -54,6 +58,7 @@
*
* @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 bea45db..0000000
--- 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 2c365e6..746ebc1 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.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.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 @@
private MavenProject project;
- @Before
- public void setUp()
+ @BeforeEach
+ void setUp()
{
extractors = new HashMap<>();
extractors.put( "one", new ScannerTestExtractor( "one" ) );
@@ -81,7 +81,7 @@
}
@Test
- public void testUnspecifiedExtractors()
+ void testUnspecifiedExtractors()
throws Exception
{
PluginDescriptor pluginDescriptor = createPluginDescriptor();
@@ -92,7 +92,7 @@
}
@Test
- public void testSpecifiedExtractors()
+ void testSpecifiedExtractors()
throws Exception
{
Set<String> activeExtractors = new HashSet<>();
@@ -110,7 +110,7 @@
}
@Test
- public void testAllExtractorsThroughNull()
+ void testAllExtractorsThroughNull()
throws Exception
{
PluginDescriptor pluginDescriptor = createPluginDescriptor();
@@ -122,12 +122,12 @@
}
@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 @@
// 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 @@
// Ok
}
- checkResult( pluginDescriptor, Collections.<String>emptySet() );
+ checkResult( pluginDescriptor, Collections.emptySet() );
}
private PluginDescriptor createPluginDescriptor()
@@ -196,11 +196,10 @@
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 f4d46b1..3ec5253 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 @@
*/
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 @@
}
@Test
- public void testShouldFindTwoScriptsWhenNoExcludesAreGiven()
+ void testShouldFindTwoScriptsWhenNoExcludesAreGiven()
{
String testScript = "test.txt";
@@ -54,7 +54,7 @@
}
@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 b96d871..a94dac2 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 @@
* 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 @@
{
@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-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java
index d652afa..f271b00 100644
--- a/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java
+++ b/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/stubs/MojoStub.java
@@ -28,8 +28,6 @@
/**
* Dummy Mojo.
- *
- * @goal dummy
*/
public class MojoStub
extends AbstractMojo
diff --git a/maven-plugin-tools-generators/pom.xml b/maven-plugin-tools-generators/pom.xml
index 7b221b7..12d89f3 100644
--- a/maven-plugin-tools-generators/pom.xml
+++ b/maven-plugin-tools-generators/pom.xml
@@ -87,8 +87,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>
@@ -109,24 +114,4 @@
</dependency>
</dependencies>
- <profiles>
- <profile>
- <id>reporting</id>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>l10n-maven-plugin</artifactId>
- <version>1.0-alpha-2</version>
- <configuration>
- <locales>
- <locale>de</locale>
- <locale>fr</locale>
- </locales>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
- </profile>
- </profiles>
</project>
diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
index 6e777c0..cfa4138 100644
--- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
+++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
@@ -19,10 +19,7 @@
* under the License.
*/
-import static java.nio.charset.StandardCharsets.UTF_8;
-
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
@@ -31,20 +28,22 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.maven.plugin.descriptor.DuplicateMojoDescriptorException;
+
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.descriptor.Requirement;
-import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
import org.apache.maven.tools.plugin.PluginToolsRequest;
import org.apache.maven.tools.plugin.util.PluginUtils;
import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.io.CachingOutputStream;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Generate a <a href="/ref/current/maven-plugin-api/plugin.html">Maven Plugin Descriptor XML file</a> and
* corresponding <code>plugin-help.xml</code> help content for {@link PluginHelpGenerator}.
@@ -54,20 +53,10 @@
implements Generator
{
- private final Log log;
-
- public PluginDescriptorGenerator( Log log )
- {
- this.log = log;
- }
-
@Override
public void execute( File destinationDirectory, PluginToolsRequest request )
throws GeneratorException
{
- // eventually rewrite help mojo class to match actual package name
- PluginHelpGenerator.rewriteHelpMojo( request, log );
-
try
{
// write complete plugin.xml descriptor
@@ -86,10 +75,6 @@
{
throw new GeneratorException( e.getMessage(), e );
}
- catch ( DuplicateMojoDescriptorException e )
- {
- throw new GeneratorException( e.getMessage(), e );
- }
}
private String getVersion()
@@ -100,20 +85,16 @@
}
public void writeDescriptor( File destinationFile, PluginToolsRequest request, boolean helpDescriptor )
- throws IOException, DuplicateMojoDescriptorException
+ throws IOException
{
PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
- if ( destinationFile.exists() )
- {
- destinationFile.delete();
- }
- else if ( !destinationFile.getParentFile().exists() )
+ if ( !destinationFile.getParentFile().exists() )
{
destinationFile.getParentFile().mkdirs();
}
- try ( Writer writer = new OutputStreamWriter( new FileOutputStream( destinationFile ), UTF_8 ) )
+ try ( Writer writer = new OutputStreamWriter( new CachingOutputStream( destinationFile ), UTF_8 ) )
{
XMLWriter w = new PrettyPrintXMLWriter( writer, UTF_8.name(), null );
@@ -169,11 +150,6 @@
}
}
- protected void processMojoDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w )
- {
- processMojoDescriptor( mojoDescriptor, w, false );
- }
-
/**
* @param mojoDescriptor not null
* @param w not null
diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
index 2c3af58..79ef6cb 100644
--- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
+++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
@@ -19,79 +19,44 @@
* under the License.
*/
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-import org.apache.maven.plugin.descriptor.MojoDescriptor;
-import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.tools.plugin.PluginToolsRequest;
-import org.apache.velocity.VelocityContext;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.logging.Logger;
-import org.codehaus.plexus.logging.console.ConsoleLogger;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.PropertyUtils;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.velocity.VelocityComponent;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.commons.ClassRemapper;
-import org.objectweb.asm.commons.Remapper;
-import org.objectweb.asm.commons.SimpleRemapper;
-
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.Reader;
import java.io.StringWriter;
-import java.nio.charset.Charset;
-import java.util.List;
-import java.util.Properties;
+import java.io.Writer;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.VelocityContext;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.io.CachingOutputStream;
+import org.codehaus.plexus.velocity.VelocityComponent;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
/**
* Generates an <code>HelpMojo</code> class from <code>help-class-source.vm</code> template.
* The generated mojo reads help content from <code>META-INF/maven/${groupId}/${artifactId}/plugin-help.xml</code>
* resource, which is generated by this {@link PluginDescriptorGenerator}.
- * <p>Notice that the help mojo source needs to be generated before compilation, but when Java annotations are used,
- * plugin descriptor content is available only after compilation (detecting annotations in .class files):
- * help mojo source can be generated with empty package only (and no plugin descriptor available yet), then needs
- * to be updated after compilation - through {@link #rewriteHelpMojo(PluginToolsRequest, Log)} which is called from
- * plugin descriptor XML generation.</p>
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @since 2.4
*/
public class PluginHelpGenerator
extends AbstractLogEnabled
- implements Generator
{
/**
* Default generated class name
*/
private static final String HELP_MOJO_CLASS_NAME = "HelpMojo";
- /**
- * Help properties file, to store data about generated source.
- */
- private static final String HELP_PROPERTIES_FILENAME = "maven-plugin-help.properties";
-
- /**
- * Default goal
- */
- private static final String HELP_GOAL = "help";
-
private String helpPackageName;
-
- private boolean useAnnotations;
-
+ private String goalPrefix;
+ private MavenProject mavenProject;
private VelocityComponent velocityComponent;
/**
@@ -106,41 +71,10 @@
// Public methods
// ----------------------------------------------------------------------
- /**
- * {@inheritDoc}
- */
- @Override
- public void execute( File destinationDirectory, PluginToolsRequest request )
+ public void execute( File destinationDirectory )
throws GeneratorException
{
- PluginDescriptor pluginDescriptor = request.getPluginDescriptor();
-
- String helpImplementation = getImplementation( pluginDescriptor );
-
- List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos();
-
- if ( mojoDescriptors != null )
- {
- // Verify that no help goal already exists
- MojoDescriptor descriptor = pluginDescriptor.getMojo( HELP_GOAL );
-
- if ( ( descriptor != null ) && !descriptor.getImplementation().equals( helpImplementation ) )
- {
- if ( getLogger().isWarnEnabled() )
- {
- getLogger().warn( "\n\nA help goal (" + descriptor.getImplementation()
- + ") already exists in this plugin. SKIPPED THE " + helpImplementation
- + " GENERATION.\n" );
- }
-
- return;
- }
- }
-
- writeHelpPropertiesFile( request, destinationDirectory );
-
- useAnnotations = request.getProject().getArtifactMap().containsKey(
- "org.apache.maven.plugin-tools:maven-plugin-annotations" );
+ String helpImplementation = getImplementation();
try
{
@@ -150,9 +84,12 @@
helpClass.getParentFile().mkdirs();
String helpClassSources =
- getHelpClassSources( getPluginHelpPath( request.getProject() ), pluginDescriptor );
+ getHelpClassSources( getPluginHelpPath( mavenProject ) );
- FileUtils.fileWrite( helpClass, request.getEncoding(), helpClassSources );
+ try ( Writer w = new OutputStreamWriter( new CachingOutputStream( helpClass ), UTF_8 ) )
+ {
+ w.write( helpClassSources );
+ }
}
catch ( IOException e )
{
@@ -166,38 +103,40 @@
return this;
}
- public VelocityComponent getVelocityComponent()
- {
- return velocityComponent;
- }
-
public PluginHelpGenerator setVelocityComponent( VelocityComponent velocityComponent )
{
this.velocityComponent = velocityComponent;
return this;
}
+ public PluginHelpGenerator setGoalPrefix( String goalPrefix )
+ {
+ this.goalPrefix = goalPrefix;
+ return this;
+ }
+
+ public PluginHelpGenerator setMavenProject( MavenProject mavenProject )
+ {
+ this.mavenProject = mavenProject;
+ return this;
+ }
+
// ----------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------
- private String getHelpClassSources( String pluginHelpPath, PluginDescriptor pluginDescriptor )
+ private String getHelpClassSources( String pluginHelpPath )
throws IOException
{
- Properties properties = new Properties();
- VelocityContext context = new VelocityContext( properties );
- if ( this.helpPackageName != null )
- {
- properties.put( "helpPackageName", this.helpPackageName );
- }
- else
- {
- properties.put( "helpPackageName", "" );
- }
- properties.put( "pluginHelpPath", pluginHelpPath );
- properties.put( "artifactId", pluginDescriptor.getArtifactId() );
- properties.put( "goalPrefix", pluginDescriptor.getGoalPrefix() );
- properties.put( "useAnnotations", useAnnotations );
+ VelocityContext context = new VelocityContext();
+ boolean useAnnotations = mavenProject.getArtifactMap().containsKey(
+ "org.apache.maven.plugin-tools:maven-plugin-annotations" );
+
+ context.put( "helpPackageName", helpPackageName );
+ context.put( "pluginHelpPath", pluginHelpPath );
+ context.put( "artifactId", mavenProject.getArtifactId() );
+ context.put( "goalPrefix", goalPrefix );
+ context.put( "useAnnotations", useAnnotations );
StringWriter stringWriter = new StringWriter();
@@ -215,226 +154,17 @@
}
/**
- * @param pluginDescriptor The descriptor of the plugin for which to generate a help goal, must not be
- * <code>null</code>.
* @return The implementation.
*/
- private String getImplementation( PluginDescriptor pluginDescriptor )
+ private String getImplementation( )
{
- if ( StringUtils.isEmpty( helpPackageName ) )
- {
- helpPackageName = GeneratorUtils.discoverPackageName( pluginDescriptor );
- }
-
return StringUtils.isEmpty( helpPackageName )
? HELP_MOJO_CLASS_NAME
: helpPackageName + '.' + HELP_MOJO_CLASS_NAME;
}
- /**
- * Write help properties files for later use to eventually rewrite Help Mojo.
- *
- * @param request
- * @throws GeneratorException
- * @see {@link #rewriteHelpMojo(PluginToolsRequest, Log)}
- */
- private void writeHelpPropertiesFile( PluginToolsRequest request, File destinationDirectory )
- throws GeneratorException
- {
- Properties properties = new Properties();
- properties.put( "helpPackageName", helpPackageName == null ? "" : helpPackageName );
- properties.put( "destinationDirectory", destinationDirectory.getAbsolutePath() );
-
- File tmpPropertiesFile = new File( request.getProject().getBuild().getDirectory(), HELP_PROPERTIES_FILENAME );
-
- if ( tmpPropertiesFile.exists() )
- {
- tmpPropertiesFile.delete();
- }
- else if ( !tmpPropertiesFile.getParentFile().exists() )
- {
- tmpPropertiesFile.getParentFile().mkdirs();
- }
-
- try ( FileOutputStream fos = new FileOutputStream( tmpPropertiesFile ) )
- {
- properties.store( fos, "maven plugin help mojo generation informations" );
- }
- catch ( IOException e )
- {
- throw new GeneratorException( e.getMessage(), e );
- }
- }
-
static String getPluginHelpPath( MavenProject mavenProject )
{
return mavenProject.getGroupId() + "/" + mavenProject.getArtifactId() + "/plugin-help.xml";
}
-
- /**
- * Rewrite Help Mojo to match actual Mojos package name if it was not available at source generation
- * time. This is used at descriptor generation time.
- *
- * @param request
- * @throws GeneratorException
- */
- static void rewriteHelpMojo( PluginToolsRequest request, Log log )
- throws GeneratorException
- {
- File tmpPropertiesFile = new File( request.getProject().getBuild().getDirectory(), HELP_PROPERTIES_FILENAME );
-
- if ( !tmpPropertiesFile.exists() )
- {
- return;
- }
-
- Properties properties;
- try
- {
- properties = PropertyUtils.loadProperties( tmpPropertiesFile );
- }
- catch ( IOException e )
- {
- throw new GeneratorException( e.getMessage(), e );
- }
-
- String helpPackageName = properties.getProperty( "helpPackageName" );
-
- // if helpPackageName property is empty, we have to rewrite the class with a better package name than empty
- if ( StringUtils.isEmpty( helpPackageName ) )
- {
- String destDir = properties.getProperty( "destinationDirectory" );
- File destinationDirectory;
- if ( StringUtils.isEmpty( destDir ) )
- {
- // writeHelpPropertiesFile() creates 2 properties: find one without the other should not be possible
- log.warn( "\n\nUnexpected situation: destinationDirectory not defined in " + HELP_PROPERTIES_FILENAME
- + " during help mojo source generation but expected during XML descriptor generation." );
- log.warn( "Please check helpmojo goal version used in previous build phase." );
- log.warn( "If you just upgraded to plugin-tools >= 3.2 you must run a clean build at least once." );
- destinationDirectory = new File( "target/generated-sources/plugin" );
- log.warn( "Trying default location: " + destinationDirectory );
- }
- else
- {
- destinationDirectory = new File( destDir );
- }
- String helpMojoImplementation = rewriteHelpClassToMojoPackage( request, destinationDirectory, log );
-
- if ( helpMojoImplementation != null )
- {
- // rewrite plugin descriptor with new HelpMojo implementation class
- updateHelpMojoDescriptor( request.getPluginDescriptor(), helpMojoImplementation );
- }
- }
- }
-
- private static String rewriteHelpClassToMojoPackage( PluginToolsRequest request, File destinationDirectory,
- Log log )
- throws GeneratorException
- {
- String destinationPackage = GeneratorUtils.discoverPackageName( request.getPluginDescriptor() );
- if ( StringUtils.isEmpty( destinationPackage ) )
- {
- return null;
- }
- String packageAsDirectory = StringUtils.replace( destinationPackage, '.', '/' );
-
- String outputDirectory = request.getProject().getBuild().getOutputDirectory();
- File helpClassFile = new File( outputDirectory, HELP_MOJO_CLASS_NAME + ".class" );
- if ( !helpClassFile.exists() )
- {
- return null;
- }
-
- // rewrite help mojo source
- File helpSourceFile = new File( destinationDirectory, HELP_MOJO_CLASS_NAME + ".java" );
- if ( !helpSourceFile.exists() )
- {
- log.warn( "HelpMojo.java not found in default location: " + helpSourceFile.getAbsolutePath() );
- log.warn( "Help goal source won't be moved to package: " + destinationPackage );
- }
- else
- {
- File helpSourceFileNew =
- new File( destinationDirectory, packageAsDirectory + '/' + HELP_MOJO_CLASS_NAME + ".java" );
- if ( !helpSourceFileNew.getParentFile().exists() )
- {
- helpSourceFileNew.getParentFile().mkdirs();
- }
- Charset encoding = Charset.forName( request.getEncoding() );
- try ( Reader sourceReader = new InputStreamReader( new FileInputStream( helpSourceFile ), //
- encoding ); //
- PrintWriter sourceWriter = new PrintWriter(
- new OutputStreamWriter( new FileOutputStream( helpSourceFileNew ), //
- encoding ) ) )
- {
- sourceWriter.println( "package " + destinationPackage + ";" );
- IOUtil.copy( sourceReader, sourceWriter );
- }
- catch ( IOException e )
- {
- throw new GeneratorException( e.getMessage(), e );
- }
- helpSourceFileNew.setLastModified( helpSourceFile.lastModified() );
- helpSourceFile.delete();
- }
-
- // rewrite help mojo .class
- File rewriteHelpClassFile =
- new File( outputDirectory + '/' + packageAsDirectory, HELP_MOJO_CLASS_NAME + ".class" );
- if ( !rewriteHelpClassFile.getParentFile().exists() )
- {
- rewriteHelpClassFile.getParentFile().mkdirs();
- }
-
- ClassReader cr;
- try ( FileInputStream fileInputStream = new FileInputStream( helpClassFile ) )
- {
- cr = new ClassReader( fileInputStream );
- }
- catch ( IOException e )
- {
- throw new GeneratorException( e.getMessage(), e );
- }
-
- ClassWriter cw = new ClassWriter( 0 );
-
- Remapper packageRemapper =
- new SimpleRemapper( HELP_MOJO_CLASS_NAME, packageAsDirectory + '/' + HELP_MOJO_CLASS_NAME );
- ClassVisitor cv = new ClassRemapper( cw, packageRemapper );
-
- try
- {
- cr.accept( cv, ClassReader.EXPAND_FRAMES );
- }
- catch ( Throwable e )
- {
- throw new GeneratorException( "ASM issue processing class-file " + helpClassFile.getPath(), e );
- }
-
- byte[] renamedClass = cw.toByteArray();
- try ( FileOutputStream fos = new FileOutputStream( rewriteHelpClassFile ) )
- {
- fos.write( renamedClass );
- }
- catch ( IOException e )
- {
- throw new GeneratorException( "Error rewriting help class: " + e.getMessage(), e );
- }
-
- helpClassFile.delete();
-
- return destinationPackage + ".HelpMojo";
- }
-
- private static void updateHelpMojoDescriptor( PluginDescriptor pluginDescriptor, String helpMojoImplementation )
- {
- MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( HELP_GOAL );
-
- if ( mojoDescriptor != null )
- {
- mojoDescriptor.setImplementation( helpMojoImplementation );
- }
- }
}
diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
index c17ec59..481dc5a 100644
--- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
+++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginXdocGenerator.java
@@ -27,11 +27,11 @@
import org.apache.maven.tools.plugin.ExtendedMojoDescriptor;
import org.apache.maven.tools.plugin.PluginToolsRequest;
import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.io.CachingOutputStream;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
@@ -133,7 +133,7 @@
throws IOException
{
File outputFile = new File( destinationDirectory, getMojoFilename( mojoDescriptor, "xml" ) );
- try ( Writer writer = new OutputStreamWriter( new FileOutputStream( outputFile ), UTF_8 ) )
+ try ( Writer writer = new OutputStreamWriter( new CachingOutputStream( outputFile ), UTF_8 ) )
{
XMLWriter w = new PrettyPrintXMLWriter( new PrintWriter( writer ), UTF_8.name(), null );
writeBody( mojoDescriptor, w );
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 b138f4c..c3a43c3 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.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 @@
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
*/
public abstract class AbstractGeneratorTestCase
- extends PlexusTestCase
{
protected Generator generator;
- protected String basedir;
+ protected String basedir = System.getProperty( "basedir" );
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
- 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 bb5a30d..a35ebdf 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.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 @@
}
@Test
- public void testMakeHtmlValid()
+ void testMakeHtmlValid()
{
String javadoc = null;
assertEquals( "", GeneratorUtils.makeHtmlValid( javadoc ) );
@@ -104,7 +104,7 @@
}
@Test
- public void testDecodeJavadocTags()
+ void testDecodeJavadocTags()
{
String javadoc = null;
assertEquals( "", GeneratorUtils.decodeJavadocTags( javadoc ) );
@@ -159,7 +159,7 @@
}
@Test
- public void testToText()
+ void testToText()
throws Exception
{
String javadoc = null;
@@ -191,7 +191,7 @@
}
@Test
- public void testIsMavenReport()
+ void testIsMavenReport()
throws Exception
{
try
@@ -215,7 +215,7 @@
}
@Test
- public void testExcludeProvidedScopeFormComponentDependencies()
+ void testExcludeProvidedScopeFormComponentDependencies()
{
Artifact a1 = new DefaultArtifact( "g", "a1", "1.0", Artifact.SCOPE_COMPILE, "jar", "", null );
@@ -239,5 +239,4 @@
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 870466d..1b73f4a 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.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.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/stubs/MavenReportStub.java b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/stubs/MavenReportStub.java
index 936c230..3b664c5 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/stubs/MavenReportStub.java
+++ b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/stubs/MavenReportStub.java
@@ -28,8 +28,6 @@
/**
* Dummy report.
- *
- * @goal dummyReport
*/
public class MavenReportStub
extends AbstractMavenReport
diff --git a/maven-plugin-tools-java/pom.xml b/maven-plugin-tools-java/pom.xml
index b3c4469..2c4db57 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 a441888..6602011 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 @@
* 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.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 @@
*
* @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 73dfaaa..e734dc7 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.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();
@@ -126,7 +128,7 @@
request.getPluginDescriptor().addMojo( mojoDescriptor );
}
- Generator descriptorGenerator = new PluginDescriptorGenerator( new SystemStreamLog() );
+ Generator descriptorGenerator = new PluginDescriptorGenerator();
descriptorGenerator.execute( new File( root, directory ), request );
@@ -151,10 +153,7 @@
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 @@
}
@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 @@
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 @@
* @throws Exception
*/
@Test
- public void testAnnotationInPlugin()
+ void testAnnotationInPlugin()
throws Exception
{
List<MojoDescriptor> results = extract( "source3" );
@@ -230,7 +229,7 @@
* generics.
*/
@Test
- public void testJava15SyntaxParsing()
+ void testJava15SyntaxParsing()
throws Exception
{
List<MojoDescriptor> results = extract( "java-1.5" );
@@ -239,7 +238,7 @@
}
@Test
- public void testSingleTypeImportWithFullyQualifiedClassName()
+ void testSingleTypeImportWithFullyQualifiedClassName()
throws Exception
{
List<MojoDescriptor> results = extract( "MPLUGIN-314" );
@@ -248,7 +247,7 @@
}
@Test
- public void testMethodReferenceInEnumConstructor()
+ void testMethodReferenceInEnumConstructor()
throws Exception
{
List<MojoDescriptor> results = extract( "MPLUGIN-320" );
@@ -257,12 +256,11 @@
}
@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 6faa83b..1816c5c 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,22 +55,17 @@
<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>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>sisu-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
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 acd08a1..bee647e 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 @@
* under the License.
*/
+import javax.inject.Named;
+import javax.inject.Singleton;
+
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
@@ -34,21 +37,21 @@
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;
/**
* Extracts Mojo descriptors from <a href="http://ant.apache.org">Ant</a> sources.
*
+ * @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 c11f23a..6634607 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.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 @@
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 @@
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 @@
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 0d0b5c0..05a80f5 100644
--- a/maven-script/maven-plugin-tools-beanshell/pom.xml
+++ b/maven-script/maven-plugin-tools-beanshell/pom.xml
@@ -43,16 +43,6 @@
<groupId>org.apache.maven</groupId>
<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>
- </dependency>
<!-- misc -->
<dependency>
@@ -65,8 +55,8 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>sisu-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
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 14ba47d..bce940d 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 @@
* 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.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;
@@ -41,11 +42,13 @@
/**
* Extracts Mojo descriptors from <a href="http://www.beanshell.org/">BeanShell</a> sources.
*
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
*/
-@Component( role = MojoDescriptorExtractor.class, hint = "bsh" )
+@Deprecated
+@Named( "bsh" )
+@Singleton
public class BeanshellMojoDescriptorExtractor
extends AbstractScriptedMojoDescriptorExtractor
- implements MojoDescriptorExtractor
{
/**
* {@inheritDoc}
@@ -130,4 +133,4 @@
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 d57e823..6a2479a 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/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParseException.java b/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParseException.java
index f078039..8887013 100644
--- a/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParseException.java
+++ b/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParseException.java
@@ -1,78 +1,80 @@
-package org.apache.maven.tools.plugin.extractor.model;
-
-/*
- * 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.
- */
-
-import java.io.File;
-
-/**
- * Exception when plugin metadata parsing occurred.
- *
- */
-public class PluginMetadataParseException
- extends Exception
-{
- /** serialVersionUID */
- static final long serialVersionUID = 4022348153707995574L;
-
- private final File metadataFile;
-
- private final String originalMessage;
-
- /**
- * @param metadataFile could be null
- * @param message could be null
- * @param cause could be null
- */
- public PluginMetadataParseException( File metadataFile, String message, Throwable cause )
- {
- super( "Error parsing file: " + metadataFile + ". Reason: " + message, cause );
-
- this.metadataFile = metadataFile;
- this.originalMessage = message;
- }
-
- /**
- * @param metadataFile could be null
- * @param message could be null
- */
- public PluginMetadataParseException( File metadataFile, String message )
- {
- super( "Error parsing file: " + metadataFile + ". Reason: " + message );
-
- this.metadataFile = metadataFile;
- this.originalMessage = message;
- }
-
- /**
- * @return the metadata file
- */
- public File getMetadataFile()
- {
- return metadataFile;
- }
-
- /**
- * @return the original message
- */
- public String getOriginalMessage()
- {
- return originalMessage;
- }
-}
+package org.apache.maven.tools.plugin.extractor.model;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+
+/**
+ * Exception when plugin metadata parsing occurred.
+ *
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
+ */
+@Deprecated
+public class PluginMetadataParseException
+ extends Exception
+{
+ /** serialVersionUID */
+ static final long serialVersionUID = 4022348153707995574L;
+
+ private final File metadataFile;
+
+ private final String originalMessage;
+
+ /**
+ * @param metadataFile could be null
+ * @param message could be null
+ * @param cause could be null
+ */
+ public PluginMetadataParseException( File metadataFile, String message, Throwable cause )
+ {
+ super( "Error parsing file: " + metadataFile + ". Reason: " + message, cause );
+
+ this.metadataFile = metadataFile;
+ this.originalMessage = message;
+ }
+
+ /**
+ * @param metadataFile could be null
+ * @param message could be null
+ */
+ public PluginMetadataParseException( File metadataFile, String message )
+ {
+ super( "Error parsing file: " + metadataFile + ". Reason: " + message );
+
+ this.metadataFile = metadataFile;
+ this.originalMessage = message;
+ }
+
+ /**
+ * @return the metadata file
+ */
+ public File getMetadataFile()
+ {
+ return metadataFile;
+ }
+
+ /**
+ * @return the original message
+ */
+ public String getOriginalMessage()
+ {
+ return originalMessage;
+ }
+}
diff --git a/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParser.java b/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParser.java
index e0596f4..035f997 100644
--- a/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParser.java
+++ b/maven-script/maven-plugin-tools-model/src/main/java/org/apache/maven/tools/plugin/extractor/model/PluginMetadataParser.java
@@ -1,190 +1,193 @@
-package org.apache.maven.tools.plugin.extractor.model;
-
-/*
- * 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.
- */
-
-import org.apache.maven.plugin.descriptor.DuplicateParameterException;
-import org.apache.maven.plugin.descriptor.MojoDescriptor;
-import org.apache.maven.plugin.descriptor.Parameter;
-import org.apache.maven.tools.plugin.extractor.model.io.xpp3.PluginMetadataXpp3Reader;
-import org.codehaus.plexus.component.repository.ComponentRequirement;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Parser for plugin metadata.
- */
-public class PluginMetadataParser
-{
- /**
- * Default implementation path which will be replaced in
- * AbstractScriptedMojoDescriptorExtractor#extractMojoDescriptorsFromMetadata(Map, PluginDescriptor)
- */
- public static final String IMPL_BASE_PLACEHOLDER = "<REPLACE-WITH-MOJO-PATH>";
-
- /**
- * @param metadataFile the metadata file to be parse
- * @return a set of <code>MojoDescriptor</code>
- * @throws PluginMetadataParseException if any
- */
- public Set<MojoDescriptor> parseMojoDescriptors( File metadataFile )
- throws PluginMetadataParseException
- {
- Set<MojoDescriptor> descriptors = new HashSet<>();
-
- try ( Reader reader = ReaderFactory.newXmlReader( metadataFile ) )
- {
-
- PluginMetadataXpp3Reader metadataReader = new PluginMetadataXpp3Reader();
-
- PluginMetadata pluginMetadata = metadataReader.read( reader );
-
- List<Mojo> mojos = pluginMetadata.getMojos();
-
- if ( mojos != null )
- {
- for ( Mojo mojo : mojos )
- {
- MojoDescriptor descriptor = asDescriptor( metadataFile, mojo );
-
- descriptors.add( descriptor );
- }
- }
- }
- catch ( IOException | XmlPullParserException e )
- {
- throw new PluginMetadataParseException( metadataFile, "Cannot parse plugin metadata from file.", e );
- }
-
- return descriptors;
- }
-
- /**
- * @param metadataFile not null
- * @param mojo not null
- * @return a mojo descriptor instance
- * @throws PluginMetadataParseException if any
- */
- private MojoDescriptor asDescriptor( File metadataFile, Mojo mojo )
- throws PluginMetadataParseException
- {
- MojoDescriptor descriptor = new MojoDescriptor();
-
- if ( mojo.getCall() != null )
- {
- descriptor.setImplementation( IMPL_BASE_PLACEHOLDER + ":" + mojo.getCall() );
- }
- else
- {
- descriptor.setImplementation( IMPL_BASE_PLACEHOLDER );
- }
-
- descriptor.setGoal( mojo.getGoal() );
- descriptor.setPhase( mojo.getPhase() );
- descriptor.setDependencyResolutionRequired( mojo.getRequiresDependencyResolution() );
- descriptor.setAggregator( mojo.isAggregator() );
- descriptor.setInheritedByDefault( mojo.isInheritByDefault() );
- descriptor.setDirectInvocationOnly( mojo.isRequiresDirectInvocation() );
- descriptor.setOnlineRequired( mojo.isRequiresOnline() );
- descriptor.setProjectRequired( mojo.isRequiresProject() );
- descriptor.setRequiresReports( mojo.isRequiresReports() );
- descriptor.setDescription( mojo.getDescription() );
- descriptor.setDeprecated( mojo.getDeprecation() );
- descriptor.setSince( mojo.getSince() );
-
- LifecycleExecution le = mojo.getExecution();
- if ( le != null )
- {
- descriptor.setExecuteLifecycle( le.getLifecycle() );
- descriptor.setExecutePhase( le.getPhase() );
- descriptor.setExecuteGoal( le.getGoal() );
- }
-
- List<org.apache.maven.tools.plugin.extractor.model.Parameter> parameters = mojo.getParameters();
-
- if ( parameters != null && !parameters.isEmpty() )
- {
- for ( org.apache.maven.tools.plugin.extractor.model.Parameter param : parameters )
- {
- Parameter dParam = new Parameter();
- dParam.setAlias( param.getAlias() );
- dParam.setDeprecated( param.getDeprecation() );
- dParam.setDescription( param.getDescription() );
- dParam.setEditable( !param.isReadonly() );
- dParam.setExpression( param.getExpression() );
- dParam.setDefaultValue( param.getDefaultValue() );
- dParam.setSince( param.getSince() );
-
- String property = param.getProperty();
- if ( StringUtils.isNotEmpty( property ) )
- {
- dParam.setName( property );
- }
- else
- {
- dParam.setName( param.getName() );
- }
-
- if ( StringUtils.isEmpty( dParam.getName() ) )
- {
- throw new PluginMetadataParseException( metadataFile, "Mojo: \'" + mojo.getGoal()
- + "\' has a parameter without either property or name attributes. Please specify one." );
- }
-
- dParam.setRequired( param.isRequired() );
- dParam.setType( param.getType() );
-
- try
- {
- descriptor.addParameter( dParam );
- }
- catch ( DuplicateParameterException e )
- {
- throw new PluginMetadataParseException( metadataFile,
- "Duplicate parameters detected for mojo: " + mojo.getGoal(),
- e );
- }
- }
- }
-
- List<Component> components = mojo.getComponents();
-
- if ( components != null && !components.isEmpty() )
- {
- for ( Component component : components )
- {
- ComponentRequirement cr = new ComponentRequirement();
- cr.setRole( component.getRole() );
- cr.setRoleHint( component.getHint() );
-
- descriptor.addRequirement( cr );
- }
- }
-
- return descriptor;
- }
-}
+package org.apache.maven.tools.plugin.extractor.model;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.descriptor.DuplicateParameterException;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.tools.plugin.extractor.model.io.xpp3.PluginMetadataXpp3Reader;
+import org.codehaus.plexus.component.repository.ComponentRequirement;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Parser for plugin metadata.
+ *
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
+ */
+@Deprecated
+public class PluginMetadataParser
+{
+ /**
+ * Default implementation path which will be replaced in
+ * AbstractScriptedMojoDescriptorExtractor#extractMojoDescriptorsFromMetadata(Map, PluginDescriptor)
+ */
+ public static final String IMPL_BASE_PLACEHOLDER = "<REPLACE-WITH-MOJO-PATH>";
+
+ /**
+ * @param metadataFile the metadata file to be parse
+ * @return a set of <code>MojoDescriptor</code>
+ * @throws PluginMetadataParseException if any
+ */
+ public Set<MojoDescriptor> parseMojoDescriptors( File metadataFile )
+ throws PluginMetadataParseException
+ {
+ Set<MojoDescriptor> descriptors = new HashSet<>();
+
+ try ( Reader reader = ReaderFactory.newXmlReader( metadataFile ) )
+ {
+
+ PluginMetadataXpp3Reader metadataReader = new PluginMetadataXpp3Reader();
+
+ PluginMetadata pluginMetadata = metadataReader.read( reader );
+
+ List<Mojo> mojos = pluginMetadata.getMojos();
+
+ if ( mojos != null )
+ {
+ for ( Mojo mojo : mojos )
+ {
+ MojoDescriptor descriptor = asDescriptor( metadataFile, mojo );
+
+ descriptors.add( descriptor );
+ }
+ }
+ }
+ catch ( IOException | XmlPullParserException e )
+ {
+ throw new PluginMetadataParseException( metadataFile, "Cannot parse plugin metadata from file.", e );
+ }
+
+ return descriptors;
+ }
+
+ /**
+ * @param metadataFile not null
+ * @param mojo not null
+ * @return a mojo descriptor instance
+ * @throws PluginMetadataParseException if any
+ */
+ private MojoDescriptor asDescriptor( File metadataFile, Mojo mojo )
+ throws PluginMetadataParseException
+ {
+ MojoDescriptor descriptor = new MojoDescriptor();
+
+ if ( mojo.getCall() != null )
+ {
+ descriptor.setImplementation( IMPL_BASE_PLACEHOLDER + ":" + mojo.getCall() );
+ }
+ else
+ {
+ descriptor.setImplementation( IMPL_BASE_PLACEHOLDER );
+ }
+
+ descriptor.setGoal( mojo.getGoal() );
+ descriptor.setPhase( mojo.getPhase() );
+ descriptor.setDependencyResolutionRequired( mojo.getRequiresDependencyResolution() );
+ descriptor.setAggregator( mojo.isAggregator() );
+ descriptor.setInheritedByDefault( mojo.isInheritByDefault() );
+ descriptor.setDirectInvocationOnly( mojo.isRequiresDirectInvocation() );
+ descriptor.setOnlineRequired( mojo.isRequiresOnline() );
+ descriptor.setProjectRequired( mojo.isRequiresProject() );
+ descriptor.setRequiresReports( mojo.isRequiresReports() );
+ descriptor.setDescription( mojo.getDescription() );
+ descriptor.setDeprecated( mojo.getDeprecation() );
+ descriptor.setSince( mojo.getSince() );
+
+ LifecycleExecution le = mojo.getExecution();
+ if ( le != null )
+ {
+ descriptor.setExecuteLifecycle( le.getLifecycle() );
+ descriptor.setExecutePhase( le.getPhase() );
+ descriptor.setExecuteGoal( le.getGoal() );
+ }
+
+ List<org.apache.maven.tools.plugin.extractor.model.Parameter> parameters = mojo.getParameters();
+
+ if ( parameters != null && !parameters.isEmpty() )
+ {
+ for ( org.apache.maven.tools.plugin.extractor.model.Parameter param : parameters )
+ {
+ Parameter dParam = new Parameter();
+ dParam.setAlias( param.getAlias() );
+ dParam.setDeprecated( param.getDeprecation() );
+ dParam.setDescription( param.getDescription() );
+ dParam.setEditable( !param.isReadonly() );
+ dParam.setExpression( param.getExpression() );
+ dParam.setDefaultValue( param.getDefaultValue() );
+ dParam.setSince( param.getSince() );
+
+ String property = param.getProperty();
+ if ( StringUtils.isNotEmpty( property ) )
+ {
+ dParam.setName( property );
+ }
+ else
+ {
+ dParam.setName( param.getName() );
+ }
+
+ if ( StringUtils.isEmpty( dParam.getName() ) )
+ {
+ throw new PluginMetadataParseException( metadataFile, "Mojo: \'" + mojo.getGoal()
+ + "\' has a parameter without either property or name attributes. Please specify one." );
+ }
+
+ dParam.setRequired( param.isRequired() );
+ dParam.setType( param.getType() );
+
+ try
+ {
+ descriptor.addParameter( dParam );
+ }
+ catch ( DuplicateParameterException e )
+ {
+ throw new PluginMetadataParseException( metadataFile,
+ "Duplicate parameters detected for mojo: " + mojo.getGoal(),
+ e );
+ }
+ }
+ }
+
+ List<Component> components = mojo.getComponents();
+
+ if ( components != null && !components.isEmpty() )
+ {
+ for ( Component component : components )
+ {
+ ComponentRequirement cr = new ComponentRequirement();
+ cr.setRole( component.getRole() );
+ cr.setRoleHint( component.getHint() );
+
+ descriptor.addRequirement( cr );
+ }
+ }
+
+ return descriptor;
+ }
+}
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 7632255..1fcb7da 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.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 @@
}
@Test
- public void testBasicDeclarationWithCall()
+ void testBasicDeclarationWithCall()
throws PluginMetadataParseException
{
File metadataFile = getMetadataFile( "test2.mojos.xml" );
@@ -65,10 +69,7 @@
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 @@
throw new AssertionError( e );
}
}
-
}
diff --git a/maven-script/maven-script-ant/pom.xml b/maven-script/maven-script-ant/pom.xml
index 2b02e49..aaa640d 100644
--- a/maven-script/maven-script-ant/pom.xml
+++ b/maven-script/maven-script-ant/pom.xml
@@ -60,15 +60,19 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
- <version>4.2.5</version><!-- Java 7 -->
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<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/main/java/org/apache/maven/script/ant/AntMojoComponentFactory.java b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoComponentFactory.java
index 6c5a916..e13e7ba 100644
--- a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoComponentFactory.java
+++ b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoComponentFactory.java
@@ -1,42 +1,44 @@
-package org.apache.maven.script.ant;
-
-/*
- * 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.
- */
-
-import org.codehaus.classworlds.ClassRealm;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.factory.ComponentInstantiationException;
-import org.codehaus.plexus.component.factory.ant.AntComponentFactory;
-import org.codehaus.plexus.component.factory.ant.AntScriptInvoker;
-import org.codehaus.plexus.component.repository.ComponentDescriptor;
-
-/**
- *
- */
-public class AntMojoComponentFactory
- extends AntComponentFactory
-{
-
- public Object newInstance( ComponentDescriptor descriptor, ClassRealm realm, PlexusContainer container )
- throws ComponentInstantiationException
- {
- return new AntMojoWrapper( (AntScriptInvoker) super.newInstance( descriptor, realm, container ) );
- }
-
-}
+package org.apache.maven.script.ant;
+
+/*
+ * 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.
+ */
+
+import org.codehaus.classworlds.ClassRealm;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.factory.ComponentInstantiationException;
+import org.codehaus.plexus.component.factory.ant.AntComponentFactory;
+import org.codehaus.plexus.component.factory.ant.AntScriptInvoker;
+import org.codehaus.plexus.component.repository.ComponentDescriptor;
+
+/**
+ *
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
+ */
+@Deprecated
+public class AntMojoComponentFactory
+ extends AntComponentFactory
+{
+
+ public Object newInstance( ComponentDescriptor descriptor, ClassRealm realm, PlexusContainer container )
+ throws ComponentInstantiationException
+ {
+ return new AntMojoWrapper( (AntScriptInvoker) super.newInstance( descriptor, realm, container ) );
+ }
+
+}
diff --git a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
index 90f33d0..852ee80 100644
--- a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
+++ b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.java
@@ -53,8 +53,10 @@
import java.util.Map;
/**
- *
+ *
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
*/
+@Deprecated
public class AntMojoWrapper
extends AbstractMojo
implements ContextEnabled, MapOrientedComponent, LogEnabled
diff --git a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java
index ee6c701..f5c8e0d 100644
--- a/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java
+++ b/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.java
@@ -1,205 +1,207 @@
-package org.apache.maven.script.ant;
-
-/*
- * 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.
- */
-
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-import org.apache.tools.ant.PropertyHelper;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
-import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
-
-/**
- * Makes the ${expressions} used in Maven available to Ant as properties.
- *
- * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
- */
-public class AntPropertyHelper
- extends PropertyHelper
-{
- private static final String DEPENDENCY_PREFIX = "maven.dependency.";
- private Log log;
- private ExpressionEvaluator exprEvaluator;
- private MavenProject mavenProject;
- private Map<String, String> artifactMap = new HashMap<String, String>();
-
- /**
- * @deprecated use the other constructor
- * @param project
- * @param l
- */
- public AntPropertyHelper( MavenProject project, Log l )
- {
- mavenProject = project;
- log = l;
- }
-
- /**
- * @deprecated use {@link #AntPropertyHelper(ExpressionEvaluator, Set, Log)} to resolve maven.dependency.*
- * properties
- * @param exprEvaluator
- * @param l
- */
- public AntPropertyHelper( ExpressionEvaluator exprEvaluator, Log l )
- {
- this( exprEvaluator, Collections.<Artifact>emptySet(), l );
- }
-
- /**
- * @param exprEvaluator
- * @param artifacts
- * @param l
- */
- public AntPropertyHelper( ExpressionEvaluator exprEvaluator, Set<Artifact> artifacts, Log l )
- {
- this.mavenProject = null;
- this.exprEvaluator = exprEvaluator;
- this.log = l;
-
- for ( Artifact artifact : artifacts )
- {
- String key = DEPENDENCY_PREFIX + artifact.getGroupId() + "." + artifact.getArtifactId()
- + ( artifact.getClassifier() != null ? "." + artifact.getClassifier() : "" )
- + ( artifact.getType() != null ? "." + artifact.getType() : "" ) + ".path";
-
- log.debug( "Storing: " + key + "=" + artifact.getFile().getPath() );
-
- artifactMap.put( key, artifact.getFile().getPath() );
- }
- }
-
- /**
- * @see org.apache.tools.ant.PropertyHelper#getPropertyHook(java.lang.String, java.lang.String, boolean)
- */
- public synchronized Object getPropertyHook( String ns, String name, boolean user )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( "getProperty(ns=" + ns + ", name=" + name + ", user=" + user + ")" );
- }
-
- /* keep old behaviour */
- if ( mavenProject != null )
- {
- return getPropertyHook( ns, name, user, mavenProject );
- }
-
-
- Object val = null;
-
- if ( name.startsWith( DEPENDENCY_PREFIX ) )
- {
- val = artifactMap.get( name );
- }
-
- if ( val == null )
- {
- try
- {
- val = exprEvaluator.evaluate( "${" + name + "}" );
- }
- catch ( ExpressionEvaluationException e )
- {
- if ( log.isErrorEnabled() )
- {
- log.error( "Failed to evaluate expression", e );
- }
- }
- }
-
- if ( val == null )
- {
- val = super.getPropertyHook( ns, name, user );
-
- if ( val == null )
- {
- val = System.getProperty( name );
- }
- }
-
- return val;
- }
-
- /**
- * @deprecated added to keep backwards compatibility
- * @param ns
- * @param name
- * @param user
- * @param mavenProject
- * @return The property value.
- */
- private Object getPropertyHook( String ns, String name, boolean user, MavenProject mavenProject )
- {
- Object val = null;
- try
- {
- if ( name.startsWith( DEPENDENCY_PREFIX ) )
- {
- val = artifactMap.get( name );
- }
- else if ( name.startsWith( "project." ) )
- {
- val = ReflectionValueExtractor.evaluate(
- name,
- mavenProject,
- true
- );
- }
- else if ( name.equals( "basedir" ) )
- {
- val = ReflectionValueExtractor.evaluate(
- "basedir.path",
- mavenProject,
- false
- );
- }
- }
- catch ( Exception e )
- {
- if ( log.isWarnEnabled() )
- {
- log.warn( "Error evaluating expression '" + name + "'", e );
- }
- }
-
- if ( val == null )
- {
- val = super.getPropertyHook( ns, name, user );
- if ( val == null )
- {
- val = System.getProperty( name );
- }
- }
-
- if ( val instanceof File )
- {
- val = ( (File) val ).getAbsoluteFile();
- }
-
- return val;
- }
-}
+package org.apache.maven.script.ant;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.tools.ant.PropertyHelper;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
+import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
+
+/**
+ * Makes the ${expressions} used in Maven available to Ant as properties.
+ *
+ * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
+ */
+@Deprecated
+public class AntPropertyHelper
+ extends PropertyHelper
+{
+ private static final String DEPENDENCY_PREFIX = "maven.dependency.";
+ private Log log;
+ private ExpressionEvaluator exprEvaluator;
+ private MavenProject mavenProject;
+ private Map<String, String> artifactMap = new HashMap<String, String>();
+
+ /**
+ * @deprecated use the other constructor
+ * @param project
+ * @param l
+ */
+ public AntPropertyHelper( MavenProject project, Log l )
+ {
+ mavenProject = project;
+ log = l;
+ }
+
+ /**
+ * @deprecated use {@link #AntPropertyHelper(ExpressionEvaluator, Set, Log)} to resolve maven.dependency.*
+ * properties
+ * @param exprEvaluator
+ * @param l
+ */
+ public AntPropertyHelper( ExpressionEvaluator exprEvaluator, Log l )
+ {
+ this( exprEvaluator, Collections.<Artifact>emptySet(), l );
+ }
+
+ /**
+ * @param exprEvaluator
+ * @param artifacts
+ * @param l
+ */
+ public AntPropertyHelper( ExpressionEvaluator exprEvaluator, Set<Artifact> artifacts, Log l )
+ {
+ this.mavenProject = null;
+ this.exprEvaluator = exprEvaluator;
+ this.log = l;
+
+ for ( Artifact artifact : artifacts )
+ {
+ String key = DEPENDENCY_PREFIX + artifact.getGroupId() + "." + artifact.getArtifactId()
+ + ( artifact.getClassifier() != null ? "." + artifact.getClassifier() : "" )
+ + ( artifact.getType() != null ? "." + artifact.getType() : "" ) + ".path";
+
+ log.debug( "Storing: " + key + "=" + artifact.getFile().getPath() );
+
+ artifactMap.put( key, artifact.getFile().getPath() );
+ }
+ }
+
+ /**
+ * @see org.apache.tools.ant.PropertyHelper#getPropertyHook(java.lang.String, java.lang.String, boolean)
+ */
+ public synchronized Object getPropertyHook( String ns, String name, boolean user )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "getProperty(ns=" + ns + ", name=" + name + ", user=" + user + ")" );
+ }
+
+ /* keep old behaviour */
+ if ( mavenProject != null )
+ {
+ return getPropertyHook( ns, name, user, mavenProject );
+ }
+
+
+ Object val = null;
+
+ if ( name.startsWith( DEPENDENCY_PREFIX ) )
+ {
+ val = artifactMap.get( name );
+ }
+
+ if ( val == null )
+ {
+ try
+ {
+ val = exprEvaluator.evaluate( "${" + name + "}" );
+ }
+ catch ( ExpressionEvaluationException e )
+ {
+ if ( log.isErrorEnabled() )
+ {
+ log.error( "Failed to evaluate expression", e );
+ }
+ }
+ }
+
+ if ( val == null )
+ {
+ val = super.getPropertyHook( ns, name, user );
+
+ if ( val == null )
+ {
+ val = System.getProperty( name );
+ }
+ }
+
+ return val;
+ }
+
+ /**
+ * @deprecated added to keep backwards compatibility
+ * @param ns
+ * @param name
+ * @param user
+ * @param mavenProject
+ * @return The property value.
+ */
+ private Object getPropertyHook( String ns, String name, boolean user, MavenProject mavenProject )
+ {
+ Object val = null;
+ try
+ {
+ if ( name.startsWith( DEPENDENCY_PREFIX ) )
+ {
+ val = artifactMap.get( name );
+ }
+ else if ( name.startsWith( "project." ) )
+ {
+ val = ReflectionValueExtractor.evaluate(
+ name,
+ mavenProject,
+ true
+ );
+ }
+ else if ( name.equals( "basedir" ) )
+ {
+ val = ReflectionValueExtractor.evaluate(
+ "basedir.path",
+ mavenProject,
+ false
+ );
+ }
+ }
+ catch ( Exception e )
+ {
+ if ( log.isWarnEnabled() )
+ {
+ log.warn( "Error evaluating expression '" + name + "'", e );
+ }
+ }
+
+ if ( val == null )
+ {
+ val = super.getPropertyHook( ns, name, user );
+ if ( val == null )
+ {
+ val = System.getProperty( name );
+ }
+ }
+
+ if ( val instanceof File )
+ {
+ val = ( (File) val ).getAbsoluteFile();
+ }
+
+ return val;
+ }
+}
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 791c87f..c63be02 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 @@
* 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.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 @@
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 @@
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/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java b/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java
index 405458a..b2008f8 100644
--- a/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java
+++ b/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java
@@ -1,70 +1,72 @@
-package org.apache.maven.script.beanshell;
-
-/*
- * 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.
- */
-
-import bsh.EvalError;
-import bsh.Interpreter;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.Mojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.component.factory.bsh.BshComponent;
-
-/**
- * Mojo adapter for a Beanshell Mojo.
- *
- * @author <a href="mailto:brett@apache.org">Brett Porter</a>
- */
-public class BeanshellMojoAdapter
- extends AbstractMojo
- implements BshComponent
-{
- private Mojo mojo;
-
- private Interpreter interpreter;
-
- public BeanshellMojoAdapter( Mojo mojo, Interpreter interpreter )
- {
- this.mojo = mojo;
- this.interpreter = interpreter;
- }
-
- public void execute()
- throws MojoExecutionException, MojoFailureException
- {
- try
- {
- interpreter.set( "logger", getLog() );
-
- // TODO: set out, err to a print stream that will log at info, error respectively
- }
- catch ( EvalError evalError )
- {
- throw new MojoExecutionException( "Unable to establish mojo", evalError );
- }
-
- mojo.execute();
- }
-
- public Interpreter getInterpreter()
- {
- return interpreter;
- }
-}
+package org.apache.maven.script.beanshell;
+
+/*
+ * 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.
+ */
+
+import bsh.EvalError;
+import bsh.Interpreter;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.component.factory.bsh.BshComponent;
+
+/**
+ * Mojo adapter for a Beanshell Mojo.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @deprecated Scripting support for mojos is deprecated and is planned tp be removed in maven 4.0
+ */
+@Deprecated
+public class BeanshellMojoAdapter
+ extends AbstractMojo
+ implements BshComponent
+{
+ private Mojo mojo;
+
+ private Interpreter interpreter;
+
+ public BeanshellMojoAdapter( Mojo mojo, Interpreter interpreter )
+ {
+ this.mojo = mojo;
+ this.interpreter = interpreter;
+ }
+
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ try
+ {
+ interpreter.set( "logger", getLog() );
+
+ // TODO: set out, err to a print stream that will log at info, error respectively
+ }
+ catch ( EvalError evalError )
+ {
+ throw new MojoExecutionException( "Unable to establish mojo", evalError );
+ }
+
+ mojo.execute();
+ }
+
+ public Interpreter getInterpreter()
+ {
+ return interpreter;
+ }
+}
diff --git a/pom.xml b/pom.xml
index 237da61..71a295e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.apache.maven</groupId>
- <version>34</version>
+ <version>37</version>
<relativePath/>
</parent>
@@ -80,7 +80,7 @@
</issueManagement>
<ciManagement>
<system>Jenkins</system>
- <url>https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-plugin-tools/</url>
+ <url>https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-plugin-tools/</url>
</ciManagement>
<distributionManagement>
<site>
@@ -90,14 +90,16 @@
</distributionManagement>
<properties>
- <surefireVersion>2.22.2</surefireVersion>
- <javaVersion>7</javaVersion>
+ <surefire.version>2.22.2</surefire.version>
+ <javaVersion>8</javaVersion>
<pluginTestingHarnessVersion>3.3.0</pluginTestingHarnessVersion>
<mavenVersion>3.2.5</mavenVersion>
+ <antVersion>1.10.12</antVersion>
+ <asmVersion>9.3</asmVersion>
+ <plexusUtilsVersion>3.4.2</plexusUtilsVersion>
+ <reportingApiVersion>3.1.1</reportingApiVersion>
+ <reportingImplVersion>3.2.0</reportingImplVersion>
<doxiaVersion>1.11.1</doxiaVersion>
- <antVersion>1.9.16</antVersion>
- <sisuVersion>0.3.5</sisuVersion>
- <asmVersion>9.2</asmVersion>
<maven.site.path>plugin-tools-archives/plugin-tools-LATEST</maven.site.path>
<project.build.outputTimestamp>2022-01-10T23:05:38Z</project.build.outputTimestamp>
@@ -181,12 +183,12 @@
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
- <version>3.0</version>
+ <version>${reportingApiVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
- <version>3.0.0</version>
+ <version>${reportingImplVersion}</version>
</dependency>
<!-- doxia -->
@@ -237,24 +239,14 @@
<!-- 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>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-annotations</artifactId>
- <version>2.1.1</version>
+ <version>${plexusUtilsVersion}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
- <version>3.6.0</version>
+ <version>4.2.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@@ -282,7 +274,7 @@
<dependency>
<groupId>com.thoughtworks.qdox</groupId>
<artifactId>qdox</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
</dependency>
<dependency>
@@ -296,6 +288,7 @@
<version>${asmVersion}</version>
</dependency>
+ <!-- testing -->
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
@@ -303,15 +296,34 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>2.28.2</version>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.23.1</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.2</version>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>3.12.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit</groupId>
+ <artifactId>junit-bom</artifactId>
+ <version>5.9.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-testing</artifactId>
+ <version>1.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -322,53 +334,14 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <!-- modello generate java sources with errors so do not fail -->
- <failOnError>false</failOnError>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.9.1</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<tagBase>https://svn.apache.org/repos/asf/maven/plugin-tools/tags</tagBase>
<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>
- <plugins>
- <plugin>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>3.0.0-M3</version>
- <dependencies>
- <dependency>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>extra-enforcer-rules</artifactId>
- <version>1.3</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
</build>
<profiles>
@@ -430,7 +403,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
- <version>3.1.1</version>
<reportSets>
<reportSet>
<id>non-aggregate</id>