Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
THAVEAU Alexis committed Nov 6, 2023
1 parent 633fdd4 commit 9e7a9b4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 44 deletions.
45 changes: 25 additions & 20 deletions src/main/java/org/codehaus/mojo/wagon/CopyMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,61 +34,66 @@
/**
* Copy artifacts from one Wagon repository to another Wagon repository.
*/
@Mojo(name = "copy", requiresProject = false)
public class CopyMojo extends AbstractCopyMojo {
@Mojo( name = "copy" , requiresProject = false)
public class CopyMojo
extends AbstractCopyMojo
{
/**
* Directory path relative to source's Wagon
*/
@Parameter(property = "wagon.fromDir")
private final String fromDir = "";
@Parameter( property = "wagon.fromDir")
private String fromDir = "";

/**
* Comma separated list of Ant's includes to scan for remote files
*/
@Parameter(property = "wagon.includes", defaultValue = "*")
@Parameter( property = "wagon.includes", defaultValue = "*")
private String includes;

/**
* Comma separated list of Ant's excludes to scan for remote files
*/
@Parameter(property = "wagon.excludes")
@Parameter( property = "wagon.excludes")
private String excludes;

/**
* Whether to consider remote path case sensitivity during scan.
*/
@Parameter(property = "wagon.caseSensitive")
private final boolean caseSensitive = true;
@Parameter( property = "wagon.caseSensitive")
private boolean caseSensitive = true;

/**
* Local directory to store downloaded artifacts. This directory is needed in order to use continuation type ONLY_MISSING during the download from source Wagin.
* If not provided, the artifacts are downloaded to a temporary directory
* If not provided, the continuation type ONLY_MISSING will only work during the upload to target
* Local directory to store downloaded artifacts. This directory is needed in order to use continuation type ONLY_MISSING during the download from source Wagon.
* If not provided, the artifacts are downloaded to a temporary directory and the continuation type ONLY_MISSING will only work during the upload to target Wagon
*/
@Parameter(property = "wagon.downloadDirectory")
@Parameter( property = "wagon.downloadDirectory" )
private File downloadDirectory;

/**
* Configure the continuation type.
* When continuation type is ONLY_MISSING, download file from source Wagon that do not exist in
* When continuation type is ONLY_MISSING, download file from source Wagon that do not exist in
* downloadDirectory and copy files that do not exist in target Wagon
* When continuation type is NONE, copy all files
*/
@Parameter(property = "wagon.continuationType")
@Parameter( property = "wagon.continuationType" )
private ContinuationType continuationType = ContinuationType.NONE;

/**
* Remote path relative to target's url to copy files to.
*/
@Parameter(property = "wagon.toDir")
private final String toDir = "";
@Parameter( property = "wagon.toDir" )
private String toDir = "";

@Component private WagonCopy wagonCopy;
@Component
private WagonCopy wagonCopy;

@Override
protected void copy(Wagon srcWagon, Wagon targetWagon) throws IOException, WagonException {
WagonFileSet fileSet = this.getWagonFileSet(fromDir, includes, excludes, caseSensitive, toDir);
if (downloadDirectory != null) {
protected void copy( Wagon srcWagon, Wagon targetWagon )
throws IOException, WagonException
{
WagonFileSet fileSet = this.getWagonFileSet( fromDir, includes, excludes, caseSensitive, toDir );
if ( downloadDirectory != null )
{
fileSet.setDownloadDirectory(downloadDirectory);
}
wagonCopy.copy(srcWagon, fileSet, targetWagon, optimize, this.getLog(), continuationType);
Expand Down
42 changes: 21 additions & 21 deletions src/main/java/org/codehaus/mojo/wagon/UploadMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@
/**
* Upload multiple sets of files.
*/
@Mojo(name = "upload")
@Mojo( name = "upload" )
public class UploadMojo
extends AbstractSingleWagonMojo
{
/**
* Local directory to upload to wagon's "url/toDir".
*/
@Parameter(property = "wagon.fromDir", defaultValue = "${project.basedir}")
@Parameter( property = "wagon.fromDir", defaultValue = "${project.basedir}")
private File fromDir;

/**
* Comma separate list of Ant's excludes to scan for local files.
*/
@Parameter(property = "wagon.excludes")
@Parameter( property = "wagon.excludes")
private String excludes;

/**
* Comma separate list of Ant's includes to scan for local files.
*/
@Parameter(property = "wagon.includes")
@Parameter( property = "wagon.includes")
private String includes;

/**
Expand All @@ -80,8 +80,8 @@ public class UploadMojo
* Optimize the upload by locally compressed all files in one bundle, upload the bundle, and finally remote
* uncompress the bundle.
*/
@Parameter(property = "wagon.optimize", defaultValue = "false")
private final boolean optimize = false;
@Parameter( property = "wagon.optimize", defaultValue = "false")
private boolean optimize = false;

@Component
protected WagonUpload wagonUpload;
Expand All @@ -91,34 +91,34 @@ public class UploadMojo
* When continuation type is ONLY_MISSING, upload files that do not exist in target Wagon
* When continuation type is NONE, upload all files
*/
@Parameter(property = "wagon.continuationType")
@Parameter( property = "wagon.continuationType" )
private ContinuationType continuationType = ContinuationType.NONE;

@Override
protected void execute(Wagon wagon) throws WagonException, IOException {
protected void execute( Wagon wagon )
throws WagonException, IOException
{
FileSet fileSet = new FileSet();

fileSet.setDirectory(this.fromDir.getAbsolutePath());
fileSet.setDirectory( this.fromDir.getAbsolutePath() );

if (!StringUtils.isBlank(includes)) {
fileSet.setIncludes(Arrays.asList(StringUtils.split(this.includes, ",")));
if ( !StringUtils.isBlank( includes ) )
{
fileSet.setIncludes( Arrays.asList( StringUtils.split( this.includes, "," ) ) );
}

if (!StringUtils.isBlank(excludes)) {
fileSet.setExcludes(Arrays.asList(StringUtils.split(this.excludes, ",")));
if ( !StringUtils.isBlank( excludes ) )
{
fileSet.setExcludes( Arrays.asList( StringUtils.split( this.excludes, "," ) ) );
}

fileSet.setFollowSymlinks(this.followSymLink);
fileSet.setFollowSymlinks( this.followSymLink );

fileSet.setUseDefaultExcludes(this.useDefaultExcludes);
fileSet.setUseDefaultExcludes( this.useDefaultExcludes );

fileSet.setOutputDirectory(toDir);
fileSet.setOutputDirectory( toDir );

this.wagonUpload.upload(wagon, fileSet, optimize, continuationType);
this.wagonUpload.upload( wagon, fileSet, optimize, continuationType );
}

}




Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public void copy(Wagon src, WagonFileSet wagonFileSet, Wagon target, boolean opt

try
{
this.downloader.download( src, wagonFileSet, logger, continuationType);
this.downloader.download( src, wagonFileSet, logger, continuationType );

FileSet localFileSet = new FileSet();
localFileSet.setDirectory( wagonFileSet.getDownloadDirectory().getAbsolutePath() );
localFileSet.setOutputDirectory( wagonFileSet.getOutputDirectory() );

this.uploader.upload( target, localFileSet, optimize, continuationType);
this.uploader.upload( target, localFileSet, optimize, continuationType );
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ List getFileList( Wagon wagon, WagonFileSet fileSet, Log logger )
* @param wagon - a Wagon instance
* @param remoteFileSet - Criteria to build the list
* @param logger - logger used
* @param continuationType - download only files that doesn't already exist in destination
* @param continuationType - continuation type.
* When ONLY_MISSING, download only files that do not already exist in destination
* When continuation type is NONE, download all files
* @throws WagonException if any wagon error
*/
void download( Wagon wagon, WagonFileSet remoteFileSet, Log logger, ContinuationType continuationType )
Expand Down

0 comments on commit 9e7a9b4

Please sign in to comment.