Skip to content

[MDEP-651] - allow unpack dependency to configure entries overwrite #13

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

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,26 @@ protected void unpack( Artifact artifact, File location, String includes, String
*/
protected void unpack( Artifact artifact, String type, File location, String includes, String excludes,
String encoding, FileMapper[] fileMappers )
throws MojoExecutionException
{
unpack( artifact, type, location, includes, excludes, encoding, fileMappers, true );
}

/**
* @param artifact {@link Artifact}
* @param type The type.
* @param location The location.
* @param includes includes list.
* @param excludes excludes list.
* @param encoding the encoding.
* @param fileMappers {@link FileMapper}s to be used for rewriting each target path, or {@code null} if no rewriting
* shall happen.
* @param overwrite overwrite duplicate entries when unpacking artifacts
*
* @throws MojoExecutionException in case of an error.
*/
protected void unpack( Artifact artifact, String type, File location, String includes, String excludes,
String encoding, FileMapper[] fileMappers, boolean overwrite )
throws MojoExecutionException
{
File file = artifact.getFile();
Expand Down Expand Up @@ -283,6 +303,8 @@ protected void unpack( Artifact artifact, String type, File location, String inc

unArchiver.setDestDirectory( location );

unArchiver.setOverwrite( overwrite );

if ( StringUtils.isNotEmpty( excludes ) || StringUtils.isNotEmpty( includes ) )
{
// Create the selectors that will filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ public class UnpackDependenciesMojo
@Parameter( property = "mdep.unpack.filemappers" )
private FileMapper[] fileMappers;

/**
* @since 3.1.2
*/
@Parameter( property = "mdep.unpack.overwrite", defaultValue = "true" )
private boolean overwrite = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already don via the defaultValue from the annotation above.


/**
* Main entry into mojo. This method gets the dependencies and iterates through each one passing it to
* DependencyUtil.unpackFile().
*
* @throws MojoExecutionException with a message if an error occurs.
* @see #getDependencySets(boolean)
* @see #unpack(Artifact, File, String)
* @see #unpack(Artifact, String, File, String, String, String, FileMapper[], boolean)
*/
@Override
protected void doExecute()
Expand All @@ -102,7 +108,8 @@ protected void doExecute()
destDir = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerScope, useSubDirectoryPerType,
useSubDirectoryPerArtifact, useRepositoryLayout,
stripVersion, outputDirectory, artifact );
unpack( artifact, destDir, getIncludes(), getExcludes(), getEncoding(), getFileMappers() );
unpack( artifact, artifact.getType(), destDir, getIncludes(), getExcludes(),
getEncoding(), getFileMappers(), isOverwrite() );
DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( artifact, this.markersDirectory );
handler.setMarker();
}
Expand Down Expand Up @@ -191,4 +198,20 @@ public void setFileMappers( FileMapper[] fileMappers )
{
this.fileMappers = fileMappers;
}

/**
* @since 3.1.2
*/
public boolean isOverwrite()
{
return overwrite;
}

/**
* @since 3.1.2
*/
public void setOverwrite( boolean overwrite )
{
this.overwrite = overwrite;
}
}