You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/09/26 22:43:41 UTC

[maven-plugin-tools] branch MPLUGIN-351 created (now 1a7b0ec)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch MPLUGIN-351
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git.


      at 1a7b0ec  [MPLUGIN-351] m2e support

This branch includes the following new commits:

     new 1a7b0ec  [MPLUGIN-351] m2e support

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[maven-plugin-tools] 01/01: [MPLUGIN-351] m2e support

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MPLUGIN-351
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git

commit 1a7b0ec308ac49a296684d9711fbddeb6af161b4
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Wed Aug 11 11:30:46 2021 +0200

    [MPLUGIN-351] m2e support
    
    incremental builds are not supported
    
    Closes #36
---
 maven-plugin-plugin/pom.xml                        |  7 +++++
 .../maven/plugin/plugin/AbstractGeneratorMojo.java | 10 +++++--
 .../META-INF/m2e/lifecycle-mapping-metadata.xml    | 34 ++++++++++++++++++++++
 3 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/maven-plugin-plugin/pom.xml b/maven-plugin-plugin/pom.xml
index 5eb117d..1377acb 100644
--- a/maven-plugin-plugin/pom.xml
+++ b/maven-plugin-plugin/pom.xml
@@ -166,6 +166,13 @@
       </exclusions>
     </dependency>
 
+    <!-- for m2e support: https://www.eclipse.org/m2e/documentation/m2e-making-maven-plugins-compat.html -->
+    <dependency>
+      <groupId>org.sonatype.plexus</groupId>
+      <artifactId>plexus-build-api</artifactId>
+      <version>0.0.7</version>
+    </dependency>
+ 
     <!-- needed for it tests -->
     <dependency>
       <groupId>org.apache.maven.plugin-tools</groupId>
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 2709b24..203bac2 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
@@ -39,6 +39,7 @@ 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;
@@ -67,6 +68,9 @@ public abstract class AbstractGeneratorMojo
     @Component
     protected MojoScanner mojoScanner;
 
+    @Component
+    protected BuildContext buildContext;
+
     /**
      * The file encoding of the source files.
      *
@@ -254,9 +258,11 @@ public abstract class AbstractGeneratorMojo
 
             mojoScanner.populatePluginDescriptor( request );
 
-            getOutputDirectory().mkdirs();
+            File outputDirectory = getOutputDirectory();
+            outputDirectory.mkdirs();
 
-            createGenerator().execute( getOutputDirectory(), request );
+            createGenerator().execute( outputDirectory, request );
+            buildContext.refresh( outputDirectory );
         }
         catch ( GeneratorException e )
         {
diff --git a/maven-plugin-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/maven-plugin-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
new file mode 100644
index 0000000..6c6ee1a
--- /dev/null
+++ b/maven-plugin-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
@@ -0,0 +1,34 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<lifecycleMappingMetadata>
+  <pluginExecutions>
+    <pluginExecution>
+      <pluginExecutionFilter>
+        <goals>
+          <goal>descriptor</goal>
+          <goal>helpmojo</goal>
+        </goals>
+      </pluginExecutionFilter>
+      <action>
+        <execute>
+          <runOnIncremental>false</runOnIncremental>
+          <runOnConfiguration>false</runOnConfiguration>
+        </execute>
+      </action>
+    </pluginExecution>
+  </pluginExecutions>
+</lifecycleMappingMetadata>
\ No newline at end of file