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 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions pom.xml
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
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:brianf@apache.org">Brian Fox</a>
Expand All @@ -59,6 +60,21 @@ public abstract class AbstractDependencyMojo
@Component
private ArchiverManager archiverManager;


/**
* For IDE build support
*/
@Component
private BuildContext buildContext;

/**
* Skip plugin execution during incremental builds (e.g. triggered from M2E).
*
* @since 3.3.1
slawekjaranowski marked this conversation as resolved.
Show resolved Hide resolved
*/
@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 +205,7 @@ protected void copyFile( File artifact, File destFile )
}

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

Expand Down