Skip to content

Commit 50a4b70

Browse files
authored
[MDEP-674] Add IDE build support (#257)
Use BuildContext to notify about newly generated files/folders
1 parent 0eabeef commit 50a4b70

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,15 @@ under the License.
247247
<version>${resolverVersion}</version>
248248
<scope>provided</scope>
249249
</dependency>
250+
<!-- IDE build support (https://github.com/codehaus-plexus/plexus-build-api) -->
251+
<dependency>
252+
<groupId>org.sonatype.plexus</groupId>
253+
<artifactId>plexus-build-api</artifactId>
254+
<version>0.0.7</version><!-- stick with old GAV until https://github.com/eclipse-m2e/m2e-core/issues/944 is fixed -->
255+
<scope>compile</scope>
256+
</dependency>
257+
258+
<!-- test -->
250259
<dependency>
251260
<groupId>org.eclipse.aether</groupId>
252261
<artifactId>aether-connector-basic</artifactId>
@@ -265,8 +274,6 @@ under the License.
265274
<version>${resolverVersion}</version>
266275
<scope>test</scope>
267276
</dependency>
268-
269-
<!-- test -->
270277
<dependency>
271278
<groupId>junit</groupId>
272279
<artifactId>junit</artifactId>

src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.codehaus.plexus.util.FileUtils;
4747
import org.codehaus.plexus.util.ReflectionUtils;
4848
import 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

Comments
 (0)