[MPLUGIN-363] Consistent HelpMojo result relies on 'clean'
diff --git a/maven-plugin-plugin/pom.xml b/maven-plugin-plugin/pom.xml
index 8578d40..de3dad8 100644
--- a/maven-plugin-plugin/pom.xml
+++ b/maven-plugin-plugin/pom.xml
@@ -334,7 +334,6 @@
<artifactId>maven-invoker-plugin</artifactId>
<version>${mavenInvokerPluginVersion}</version>
<configuration>
- <debug>${it.debug}</debug>
<projectsDirectory>src/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<preBuildHookScript>setup</preBuildHookScript>
diff --git a/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/invoker.properties b/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/invoker.properties
new file mode 100644
index 0000000..a56062a
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/invoker.properties
@@ -0,0 +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.goals.1 = clean package
+invoker.goals.2 = process-classes
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
new file mode 100644
index 0000000..63e4d47
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/pom.xml
@@ -0,0 +1,109 @@
+<?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>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>3.0.1</version>
+ </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>2.4</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>
+ <execution>
+ <id>default-descriptor</id>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <resources>
+ <resource>
+ <directory>target/generated-sources</directory>
+ </resource>
+ </resources>
+ <outputDirectory>target/generated-sources-run1</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/src/main/java/test/MyMojo.java b/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/src/main/java/test/MyMojo.java
new file mode 100644
index 0000000..0be9fd3
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/src/main/java/test/MyMojo.java
@@ -0,0 +1,68 @@
+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}.
+ *
+ * @deprecated As of 1.0, use the "quoted" goal instead.
+ * @since 2.1
+ */
+@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;
+
+ /**
+ * This parameter is deprecated.
+ *
+ * @deprecated As of version 1.0, use the {@link #defaultParam} instead.
+ */
+ @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/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/verify.groovy b/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/verify.groovy
new file mode 100644
index 0000000..b64de43
--- /dev/null
+++ b/maven-plugin-plugin/src/it/mplugin-363_help-reproducible/verify.groovy
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+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;
+
+assert firstRun == secondRun;
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 736d301..59f2b7c 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
@@ -413,7 +413,7 @@
// Parameters
// ----------------------------------------------------------------------
- @SuppressWarnings( "unchecked" ) List<Parameter> parameters = mojoDescriptor.getParameters();
+ List<Parameter> parameters = mojoDescriptor.getParameters();
w.startElement( "parameters" );
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 d86144d..884e386 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
@@ -116,7 +116,7 @@
String helpImplementation = getImplementation( pluginDescriptor );
- @SuppressWarnings( "unchecked" ) List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos();
+ List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos();
if ( mojoDescriptors != null )
{
@@ -208,7 +208,9 @@
//isReader =
velocityComponent.getEngine().evaluate( context, stringWriter, "", isReader );
}
- return stringWriter.toString();
+ // Apply OS lineSeparator instead of template's lineSeparator to have consistent separators for
+ // all source files.
+ return stringWriter.toString().replaceAll( "(\r\n|\n|\r)", System.lineSeparator() );
}
/**
diff --git a/maven-plugin-tools-generators/src/main/resources/help-class-source.vm b/maven-plugin-tools-generators/src/main/resources/help-class-source.vm
index b467873..178a242 100644
--- a/maven-plugin-tools-generators/src/main/resources/help-class-source.vm
+++ b/maven-plugin-tools-generators/src/main/resources/help-class-source.vm
@@ -14,7 +14,6 @@
## KIND, either express or implied. See the License for the
## specific language governing permissions and limitations
## under the License.
-
#if ($helpPackageName.length()>0)
package ${helpPackageName};
#end