4646import org .codehaus .plexus .util .FileUtils ;
4747import org .codehaus .plexus .util .ReflectionUtils ;
4848import org .codehaus .plexus .util .StringUtils ;
49+ import org .sonatype .plexus .build .incremental .BuildContext ;
4950
5051/**
5152 * @author <a href="mailto:[email protected] ">Brian Fox</a> @@ -59,6 +60,22 @@ public abstract class AbstractDependencyMojo
5960 @ Component
6061 private ArchiverManager archiverManager ;
6162
63+
64+ /**
65+ * For IDE build support
66+ */
67+ @ Component
68+ private BuildContext buildContext ;
69+
70+ /**
71+ * Skip plugin execution only during incremental builds (e.g. triggered from M2E).
72+ *
73+ * @since 3.4.0
74+ * @see #skip
75+ */
76+ @ Parameter ( defaultValue = "false" )
77+ private boolean skipDuringIncrementalBuild ;
78+
6279 /**
6380 * <p>
6481 * will use the jvm chmod, this is available for user and all level group level will be ignored
@@ -189,6 +206,7 @@ protected void copyFile( File artifact, File destFile )
189206 }
190207
191208 FileUtils .copyFile ( artifact , destFile );
209+ buildContext .refresh ( destFile );
192210 }
193211 catch ( IOException e )
194212 {
@@ -326,6 +344,7 @@ protected void unpack( Artifact artifact, String type, File location, String inc
326344 {
327345 throw new MojoExecutionException ( "Error unpacking file: " + file + " to: " + location , e );
328346 }
347+ buildContext .refresh ( location );
329348 }
330349
331350 private void silenceUnarchiver ( UnArchiver unArchiver )
@@ -410,6 +429,10 @@ public void setUseJvmChmod( boolean useJvmChmod )
410429 */
411430 public boolean isSkip ()
412431 {
432+ if ( skipDuringIncrementalBuild && buildContext .isIncremental () )
433+ {
434+ return true ;
435+ }
413436 return skip ;
414437 }
415438
0 commit comments