From c22e5a5403e5c1307e2b92fdb395766b867b6d89 Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Fri, 28 Oct 2022 13:24:58 +0200 Subject: [PATCH 1/6] [MDEP-674] Add m2e lifecycle metadata Use BuildContext to notify about newly generated files/folders --- pom.xml | 11 ++- .../dependency/AbstractDependencyMojo.java | 22 ++++++ .../m2e/lifecycle-mapping-metadata.xml | 68 +++++++++++++++++++ 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml diff --git a/pom.xml b/pom.xml index b3de43a3a..39eab2b9c 100644 --- a/pom.xml +++ b/pom.xml @@ -247,6 +247,15 @@ under the License. ${resolverVersion} provided + + + org.sonatype.plexus + plexus-build-api + 0.0.7 + compile + + + org.eclipse.aether aether-connector-basic @@ -265,8 +274,6 @@ under the License. ${resolverVersion} test - - junit junit diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index 16756cb23..6466b010d 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -46,6 +46,7 @@ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.ReflectionUtils; import org.codehaus.plexus.util.StringUtils; +import org.sonatype.plexus.build.incremental.BuildContext; /** * @author Brian Fox @@ -59,6 +60,21 @@ public abstract class AbstractDependencyMojo @Component private ArchiverManager archiverManager; + + /** + * For m2e incremental build support + */ + @Component + private BuildContext buildContext; + + /** + * Skip plugin execution during incremental builds (e.g. triggered from M2E). + * + * @since 3.3.1 + */ + @Parameter( defaultValue = "false" ) + private boolean skipDuringIncrementalBuild; + /** *

* will use the jvm chmod, this is available for user and all level group level will be ignored @@ -189,6 +205,7 @@ protected void copyFile( File artifact, File destFile ) } FileUtils.copyFile( artifact, destFile ); + buildContext.refresh( destFile ); } catch ( IOException e ) { @@ -326,6 +343,7 @@ protected void unpack( Artifact artifact, String type, File location, String inc { throw new MojoExecutionException( "Error unpacking file: " + file + " to: " + location, e ); } + buildContext.refresh( location ); } private void silenceUnarchiver( UnArchiver unArchiver ) @@ -410,6 +428,10 @@ public void setUseJvmChmod( boolean useJvmChmod ) */ public boolean isSkip() { + if ( skipDuringIncrementalBuild && buildContext.isIncremental() ) + { + return true; + } return skip; } diff --git a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml new file mode 100644 index 000000000..39432065b --- /dev/null +++ b/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml @@ -0,0 +1,68 @@ + + + + + + + copy + copy-dependencies + properties + unpack + unpack-dependencies + + + + + true + false + + + + + + + analyze + analyze-dep-mgmt + analyze-only + analyze-report + analyze-duplicate + build-classpath + display-ancestors + get + go-offline + list + list-classes + list-repositories + purge-local-repository + resolve + resolve-plugins + sources + tree + + + + + false + false + + + + + \ No newline at end of file From c34c3c754433d2a6805fd98eb60d6874222ed3dd Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Wed, 9 Nov 2022 17:01:56 +0100 Subject: [PATCH 2/6] fix comments remove m2e specific lifecycle mapping metadata --- pom.xml | 2 +- .../apache/maven/plugins/dependency/AbstractDependencyMojo.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 39eab2b9c..8310ae943 100644 --- a/pom.xml +++ b/pom.xml @@ -247,7 +247,7 @@ under the License. ${resolverVersion} provided - + org.sonatype.plexus plexus-build-api diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index 6466b010d..e7e844541 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -62,7 +62,7 @@ public abstract class AbstractDependencyMojo /** - * For m2e incremental build support + * For IDE build support */ @Component private BuildContext buildContext; From 2da2ab8e7128862922c4f9fcdf1d4860302633b7 Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Wed, 9 Nov 2022 18:57:50 +0100 Subject: [PATCH 3/6] replace m2e link by plexus-build-api one --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8310ae943..13cd42222 100644 --- a/pom.xml +++ b/pom.xml @@ -247,7 +247,7 @@ under the License. ${resolverVersion} provided - + org.sonatype.plexus plexus-build-api From 512800eb8719aa335d7caba2456a10130b0f5f09 Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Wed, 9 Nov 2022 19:00:18 +0100 Subject: [PATCH 4/6] add more context to why old coordinates are used --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 13cd42222..fb2755898 100644 --- a/pom.xml +++ b/pom.xml @@ -251,7 +251,7 @@ under the License. org.sonatype.plexus plexus-build-api - 0.0.7 + 0.0.7 compile From 5c310ad02eb69c25fbed78f3c2ce7d660f51cb32 Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Wed, 9 Nov 2022 19:30:44 +0100 Subject: [PATCH 5/6] remove m2e specific metadata --- .../m2e/lifecycle-mapping-metadata.xml | 68 ------------------- 1 file changed, 68 deletions(-) delete mode 100644 src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml diff --git a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml deleted file mode 100644 index 39432065b..000000000 --- a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - copy - copy-dependencies - properties - unpack - unpack-dependencies - - - - - true - false - - - - - - - analyze - analyze-dep-mgmt - analyze-only - analyze-report - analyze-duplicate - build-classpath - display-ancestors - get - go-offline - list - list-classes - list-repositories - purge-local-repository - resolve - resolve-plugins - sources - tree - - - - - false - false - - - - - \ No newline at end of file From 1b792776244ea793ea718058baa8c83348a0e44b Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Tue, 22 Nov 2022 10:48:04 +0100 Subject: [PATCH 6/6] reword javadoc fix since version --- .../maven/plugins/dependency/AbstractDependencyMojo.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java index e7e844541..5294bef87 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java @@ -68,9 +68,10 @@ public abstract class AbstractDependencyMojo private BuildContext buildContext; /** - * Skip plugin execution during incremental builds (e.g. triggered from M2E). + * Skip plugin execution only during incremental builds (e.g. triggered from M2E). * - * @since 3.3.1 + * @since 3.4.0 + * @see #skip */ @Parameter( defaultValue = "false" ) private boolean skipDuringIncrementalBuild;