You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kw...@apache.org on 2022/11/22 10:08:47 UTC
[maven-dependency-plugin] branch master updated: [MDEP-674] Add IDE build support (#257)
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 50a4b701 [MDEP-674] Add IDE build support (#257)
50a4b701 is described below
commit 50a4b7017f1e66e92d8b66d0985ffdff05e93fcc
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Nov 22 11:08:42 2022 +0100
[MDEP-674] Add IDE build support (#257)
Use BuildContext to notify about newly generated files/folders
---
pom.xml | 11 +++++++++--
.../plugins/dependency/AbstractDependencyMojo.java | 23 ++++++++++++++++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 01c6616e..c566e458 100644
--- a/pom.xml
+++ b/pom.xml
@@ -247,6 +247,15 @@ under the License.
<version>${resolverVersion}</version>
<scope>provided</scope>
</dependency>
+ <!-- IDE build support (https://github.com/codehaus-plexus/plexus-build-api) -->
+ <dependency>
+ <groupId>org.sonatype.plexus</groupId>
+ <artifactId>plexus-build-api</artifactId>
+ <version>0.0.7</version><!-- stick with old GAV until https://github.com/eclipse-m2e/m2e-core/issues/944 is fixed -->
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- test -->
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-basic</artifactId>
@@ -265,8 +274,6 @@ under the License.
<version>${resolverVersion}</version>
<scope>test</scope>
</dependency>
-
- <!-- test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
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 16756cb2..5294bef8 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.components.io.fileselectors.IncludeExcludeFileSelecto
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 <a href="mailto:brianf@apache.org">Brian Fox</a>
@@ -59,6 +60,22 @@ public abstract class AbstractDependencyMojo
@Component
private ArchiverManager archiverManager;
+
+ /**
+ * For IDE build support
+ */
+ @Component
+ private BuildContext buildContext;
+
+ /**
+ * Skip plugin execution only during incremental builds (e.g. triggered from M2E).
+ *
+ * @since 3.4.0
+ * @see #skip
+ */
+ @Parameter( defaultValue = "false" )
+ private boolean skipDuringIncrementalBuild;
+
/**
* <p>
* will use the jvm chmod, this is available for user and all level group level will be ignored
@@ -189,6 +206,7 @@ public abstract class AbstractDependencyMojo
}
FileUtils.copyFile( artifact, destFile );
+ buildContext.refresh( destFile );
}
catch ( IOException e )
{
@@ -326,6 +344,7 @@ public abstract class AbstractDependencyMojo
{
throw new MojoExecutionException( "Error unpacking file: " + file + " to: " + location, e );
}
+ buildContext.refresh( location );
}
private void silenceUnarchiver( UnArchiver unArchiver )
@@ -410,6 +429,10 @@ public abstract class AbstractDependencyMojo
*/
public boolean isSkip()
{
+ if ( skipDuringIncrementalBuild && buildContext.isIncremental() )
+ {
+ return true;
+ }
return skip;
}