| |
@@ -3,25 +3,28 @@
|
| |
Date: Mon, 27 Apr 2020 12:52:15 +0200
|
| |
Subject: [PATCH 1/3] Disable help MOJO generation
|
| |
|
| |
+ Forwarded: not-needed
|
| |
+
|
| |
---
|
| |
- .../plugin/plugin/HelpGeneratorMojo.java | 20 +------------------
|
| |
- .../generator/PluginDescriptorGenerator.java | 11 ----------
|
| |
- 2 files changed, 1 insertion(+), 30 deletions(-)
|
| |
+ .../plugin/plugin/HelpGeneratorMojo.java | 23 ----------------
|
| |
+ .../plugin/generator/PluginHelpGenerator.java | 27 -------------------
|
| |
+ 2 files changed, 50 deletions(-)
|
| |
|
| |
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 7cc472e5..a51430d1 100644
|
| |
+ index eeadd65e..a7220d71 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
|
| |
- @@ -28,8 +28,6 @@ import org.apache.maven.plugins.annotations.Mojo;
|
| |
+ @@ -31,9 +31,7 @@ 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.
|
| |
- @@ -58,12 +56,6 @@ public class HelpGeneratorMojo
|
| |
+ @@ -68,12 +66,6 @@ public class HelpGeneratorMojo extends AbstractGeneratorMojo {
|
| |
@Parameter
|
| |
private String helpPackageName;
|
| |
|
| |
@@ -31,62 +34,95 @@
|
| |
- @Component
|
| |
- private VelocityComponent velocity;
|
| |
-
|
| |
- /**
|
| |
- * {@inheritDoc}
|
| |
- */
|
| |
- @@ -79,7 +71,7 @@ public class HelpGeneratorMojo
|
| |
- @Override
|
| |
- protected Generator createGenerator()
|
| |
- {
|
| |
- - return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setVelocityComponent( this.velocity );
|
| |
- + return null;
|
| |
- }
|
| |
+ String getHelpPackageName() {
|
| |
+ String packageName = null;
|
| |
+ if (StringUtils.isNotBlank(helpPackageName)) {
|
| |
+ @@ -101,20 +93,5 @@ public class HelpGeneratorMojo extends AbstractGeneratorMojo {
|
| |
|
| |
- /**
|
| |
- @@ -89,16 +81,6 @@ public class HelpGeneratorMojo
|
| |
- public void execute()
|
| |
- throws MojoExecutionException
|
| |
- {
|
| |
- - // force value for this plugin
|
| |
- - skipErrorNoDescriptorsFound = true;
|
| |
- -
|
| |
- - super.execute();
|
| |
+ @Override
|
| |
+ protected void generate() throws MojoExecutionException {
|
| |
+ - PluginHelpGenerator pluginHelpGenerator = new PluginHelpGenerator()
|
| |
+ - .setMavenProject(project)
|
| |
+ - .setHelpPackageName(getHelpPackageName())
|
| |
+ - .setGoalPrefix(goalPrefix)
|
| |
+ - .setVelocityComponent(velocity);
|
| |
-
|
| |
- - if ( !project.getCompileSourceRoots().contains( outputDirectory.getAbsolutePath() ) && !skip )
|
| |
- - {
|
| |
- - project.addCompileSourceRoot( outputDirectory.getAbsolutePath() );
|
| |
+ - try {
|
| |
+ - pluginHelpGenerator.execute(outputDirectory);
|
| |
+ - } catch (GeneratorException e) {
|
| |
+ - throw new MojoExecutionException(e.getMessage(), e);
|
| |
- }
|
| |
-
|
| |
+ - if (!project.getCompileSourceRoots().contains(outputDirectory.getAbsolutePath())) {
|
| |
+ - project.addCompileSourceRoot(outputDirectory.getAbsolutePath());
|
| |
+ - }
|
| |
}
|
| |
-
|
| |
}
|
| |
- 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 6e777c08..3d3f8c59 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
|
| |
- @@ -65,22 +65,11 @@ public class PluginDescriptorGenerator
|
| |
- 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
|
| |
- File f = new File( destinationDirectory, "plugin.xml" );
|
| |
- writeDescriptor( f, request, false );
|
| |
+ 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 474a92d6..4d706332 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
|
| |
+ @@ -27,12 +27,10 @@ import java.io.StringWriter;
|
| |
+ 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.io.CachingOutputStream;
|
| |
+ -import org.codehaus.plexus.velocity.VelocityComponent;
|
| |
+
|
| |
+ import static java.nio.charset.StandardCharsets.UTF_8;
|
| |
+
|
| |
+ @@ -54,7 +52,6 @@ public class PluginHelpGenerator extends AbstractLogEnabled {
|
| |
+ private String goalPrefix;
|
| |
+ private MavenProject mavenProject;
|
| |
+ private boolean useMaven4Api;
|
| |
+ - private VelocityComponent velocityComponent;
|
| |
+
|
| |
+ /**
|
| |
+ * Default constructor
|
| |
+ @@ -95,11 +92,6 @@ public class PluginHelpGenerator extends AbstractLogEnabled {
|
| |
+ return this;
|
| |
+ }
|
| |
+
|
| |
+ - public PluginHelpGenerator setVelocityComponent(VelocityComponent velocityComponent) {
|
| |
+ - this.velocityComponent = velocityComponent;
|
| |
+ - return this;
|
| |
+ - }
|
| |
-
|
| |
- - // write plugin-help.xml help-descriptor
|
| |
- - MavenProject mavenProject = request.getProject();
|
| |
+ public PluginHelpGenerator setGoalPrefix(String goalPrefix) {
|
| |
+ this.goalPrefix = goalPrefix;
|
| |
+ return this;
|
| |
+ @@ -115,27 +107,8 @@ public class PluginHelpGenerator extends AbstractLogEnabled {
|
| |
+ // ----------------------------------------------------------------------
|
| |
+
|
| |
+ private String getHelpClassSources(String pluginHelpPath) throws IOException {
|
| |
+ - VelocityContext context = new VelocityContext();
|
| |
+ - boolean useAnnotations =
|
| |
+ - mavenProject.getArtifactMap().containsKey("org.apache.maven.plugin-tools:maven-plugin-annotations");
|
| |
-
|
| |
- - f = new File( destinationDirectory,
|
| |
- - PluginHelpGenerator.getPluginHelpPath( mavenProject ) );
|
| |
+ - context.put("helpPackageName", helpPackageName);
|
| |
+ - context.put("pluginHelpPath", pluginHelpPath);
|
| |
+ - context.put("artifactId", mavenProject.getArtifactId());
|
| |
+ - // TODO: evaluate prefix from deserialized plugin
|
| |
+ - context.put("goalPrefix", goalPrefix);
|
| |
+ - context.put("useAnnotations", useAnnotations);
|
| |
-
|
| |
- - writeDescriptor( f, request, true );
|
| |
- }
|
| |
- catch ( IOException e )
|
| |
- {
|
| |
+ StringWriter stringWriter = new StringWriter();
|
| |
+
|
| |
+ - // plugin-tools sources are UTF-8 (and even ASCII in this case))
|
| |
+ - try (InputStream is = Thread.currentThread()
|
| |
+ - .getContextClassLoader()
|
| |
+ - .getResourceAsStream(useMaven4Api ? "help-class-source-v4.vm" : "help-class-source.vm"); //
|
| |
+ - InputStreamReader isReader = new InputStreamReader(is, UTF_8)) {
|
| |
+ - // isReader =
|
| |
+ - velocityComponent.getEngine().evaluate(context, stringWriter, "", isReader);
|
| |
+ - }
|
| |
+ // 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());
|
| |
--
|
| |
- 2.35.1
|
| |
+ 2.41.0
|
| |
|
| |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2140775