Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MDEP-674] Add IDE build support #257

Merged
merged 6 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -265,8 +274,6 @@ under the License.
<version>${resolverVersion}</version>
<scope>test</scope>
</dependency>

<!-- test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="mailto:[email protected]">Brian Fox</a>
Expand All @@ -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
Expand Down Expand Up @@ -189,6 +206,7 @@ protected void copyFile( File artifact, File destFile )
}

FileUtils.copyFile( artifact, destFile );
buildContext.refresh( destFile );
}
catch ( IOException e )
{
Expand Down Expand Up @@ -326,6 +344,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 )
Expand Down Expand Up @@ -410,6 +429,10 @@ public void setUseJvmChmod( boolean useJvmChmod )
*/
public boolean isSkip()
{
if ( skipDuringIncrementalBuild && buildContext.isIncremental() )
{
return true;
}
return skip;
}

Expand Down