From 2567b542960b46720f7e8b589e760380abca3bba Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 16 Jun 2024 17:06:55 +0200 Subject: [PATCH] Format code --- README.md | 2 +- pom.xml | 109 +++---- .../codehaus/mojo/wagon/AbstractCopyMojo.java | 56 ++-- .../mojo/wagon/AbstractDoubleWagonMojo.java | 15 +- .../mojo/wagon/AbstractSingleWagonMojo.java | 53 ++-- .../mojo/wagon/AbstractWagonListMojo.java | 18 +- .../mojo/wagon/AbstractWagonMojo.java | 33 +-- .../org/codehaus/mojo/wagon/CopyMojo.java | 25 +- .../org/codehaus/mojo/wagon/DownloadMojo.java | 17 +- .../mojo/wagon/DownloadSingleMojo.java | 59 ++-- .../org/codehaus/mojo/wagon/ExistMojo.java | 24 +- .../org/codehaus/mojo/wagon/ListMojo.java | 17 +- .../mojo/wagon/MergeMavenRepoMojo.java | 13 +- .../org/codehaus/mojo/wagon/SshExecMojo.java | 53 ++-- .../org/codehaus/mojo/wagon/UploadMojo.java | 45 ++- .../codehaus/mojo/wagon/UploadSingleMojo.java | 29 +- .../wagon/shared/DefaultMavenRepoMerger.java | 172 +++++------ .../mojo/wagon/shared/DefaultWagonCopy.java | 40 +-- .../wagon/shared/DefaultWagonDownload.java | 55 ++-- .../wagon/shared/DefaultWagonFactory.java | 199 +++++-------- .../mojo/wagon/shared/DefaultWagonUpload.java | 118 +++----- .../mojo/wagon/shared/MavenRepoMerger.java | 6 +- .../mojo/wagon/shared/SelectorUtils.java | 274 +++++++----------- .../codehaus/mojo/wagon/shared/WagonCopy.java | 10 +- .../wagon/shared/WagonDirectoryScanner.java | 218 +++++--------- .../mojo/wagon/shared/WagonDownload.java | 13 +- .../mojo/wagon/shared/WagonFactory.java | 6 +- .../mojo/wagon/shared/WagonFileSet.java | 55 ++-- .../mojo/wagon/shared/WagonUpload.java | 8 +- .../mojo/wagon/shared/WagonUtils.java | 27 +- .../codehaus/mojo/wagon/AbstractJettyIT.java | 5 +- .../mojo/wagon/Wagon334MojoHttpIT.java | 45 ++- .../mojo/wagon/WagonMojoFtpBasicIT.java | 62 ++-- .../codehaus/mojo/wagon/WagonMojoHttpIT.java | 44 ++- .../mojo/wagon/WagonMojoHttpSettingsIT.java | 37 ++- .../codehaus/mojo/wagon/WagonMojoSshIT.java | 32 +- 36 files changed, 753 insertions(+), 1241 deletions(-) diff --git a/README.md b/README.md index c61dec3..b236859 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ This is the [wagon-maven-plugin](http://www.mojohaus.org/wagon-maven-plugin/). [![Apache License 2](https://img.shields.io/badge/wagon-Apache_v2-yellow.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt) [![GitHub CI](https://github.com/mojohaus/wagon-maven-plugin/actions/workflows/maven.yml/badge.svg)](https://github.com/mojohaus/wagon-maven-plugin/actions/workflows/maven.yml) - ## Maintained versions Wagen Maven Plugin requires Maven 3.6.3+ and JDK 8+ @@ -81,3 +80,4 @@ cd target/checkout ../mvnw site ../mvnw scm-publish:publish-scm ``` + diff --git a/pom.xml b/pom.xml index 80354e3..200e6b4 100644 --- a/pom.xml +++ b/pom.xml @@ -3,8 +3,8 @@ 4.0.0 - mojo-parent org.codehaus.mojo + mojo-parent 84 @@ -13,33 +13,19 @@ maven-plugin Wagon Maven Plugin - - Maven plugin that can be used to access various operations on a given URL using a supported maven wagon. Supports - recursive upload, download, and list directory content functionality. - - http://www.mojohaus.org/wagon-maven-plugin/ + Maven plugin that can be used to access various operations on a given URL using a supported maven wagon. Supports + recursive upload, download, and list directory content functionality. + https://www.mojohaus.org/wagon-maven-plugin/ 2008 - - 3.0 - - - - scm:git:https://github.com/mojohaus/wagon-maven-plugin.git - scm:git:ssh://git@github.com/mojohaus/wagon-maven-plugin.git - https://github.com/mojohaus/wagon-maven-plugin/ - HEAD - - - - GitHub - https://github.com/mojohaus/wagon-maven-plugin/issues/ - - - Travis-CI - https://travis-ci.org/mojohaus/wagon-maven-plugin - + + + Apache License 2 + https://www.apache.org/licenses/LICENSE-2.0.txt + repo + + @@ -61,29 +47,40 @@ - Tony Chemit tchemit + Tony Chemit + dev@tchemit.fr Ultreia.io https://www.ultreia.io - dev@tchemit.fr - Europe/Paris Developer + Europe/Paris - - - Apache License 2 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - + + 3.6.3 + + + + scm:git:https://github.com/mojohaus/wagon-maven-plugin.git + scm:git:ssh://git@github.com/mojohaus/wagon-maven-plugin.git + HEAD + https://github.com/mojohaus/wagon-maven-plugin/ + + + + GitHub + https://github.com/mojohaus/wagon-maven-plugin/issues/ + + + GitHub + https://github.com/mojohaus/wagon-maven-plugin/actions + 3.6.3 - 8 3.4.0 @@ -134,12 +131,6 @@ maven-core ${maven.api.version} provided - - - org.codehaus.plexus - plexus-component-api - - @@ -173,12 +164,6 @@ org.apache.maven.wagon wagon-ssh ${wagon.api.version} - - - org.codehaus.plexus - plexus-component-api - - @@ -257,32 +242,6 @@ - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.codehaus.plexus - plexus-maven-plugin - [1.0.0,) - - descriptor - - - - - false - - - - - - - maven-site-plugin @@ -329,10 +288,10 @@ testProperties - process-test-resources testProperties + process-test-resources diff --git a/src/main/java/org/codehaus/mojo/wagon/AbstractCopyMojo.java b/src/main/java/org/codehaus/mojo/wagon/AbstractCopyMojo.java index 0996749..027de40 100644 --- a/src/main/java/org/codehaus/mojo/wagon/AbstractCopyMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/AbstractCopyMojo.java @@ -26,58 +26,40 @@ import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.WagonException; -public abstract class AbstractCopyMojo - extends AbstractDoubleWagonMojo -{ +public abstract class AbstractCopyMojo extends AbstractDoubleWagonMojo { - protected abstract void copy( Wagon src, Wagon target ) - throws IOException, WagonException; + protected abstract void copy(Wagon src, Wagon target) throws IOException, WagonException; @Override - public void execute() - throws MojoExecutionException - { + public void execute() throws MojoExecutionException { - if ( this.skip ) - { - this.getLog().info( "Skip execution." ); + if (this.skip) { + this.getLog().info("Skip execution."); return; } Wagon srcWagon = null; Wagon targetWagon = null; - try - { - srcWagon = createWagon( sourceId, source ); - targetWagon = createWagon( targetId, target ); - copy( srcWagon, targetWagon ); + try { + srcWagon = createWagon(sourceId, source); + targetWagon = createWagon(targetId, target); + copy(srcWagon, targetWagon); + } catch (Exception e) { + throw new MojoExecutionException("Error during performing repository copy", e); + } finally { + disconnectWagon(srcWagon); + disconnectWagon(targetWagon); } - catch ( Exception e ) - { - throw new MojoExecutionException( "Error during performing repository copy", e ); - } - finally - { - disconnectWagon( srcWagon ); - disconnectWagon( targetWagon ); - } - } - private void disconnectWagon( Wagon wagon ) - { - try - { - if ( wagon != null ) - { + private void disconnectWagon(Wagon wagon) { + try { + if (wagon != null) { wagon.disconnect(); } - } - catch ( ConnectionException e ) - { - getLog().debug( "Error disconnecting wagon - ignored", e ); + } catch (ConnectionException e) { + getLog().debug("Error disconnecting wagon - ignored", e); } } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/AbstractDoubleWagonMojo.java b/src/main/java/org/codehaus/mojo/wagon/AbstractDoubleWagonMojo.java index 1fde336..dacc466 100644 --- a/src/main/java/org/codehaus/mojo/wagon/AbstractDoubleWagonMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/AbstractDoubleWagonMojo.java @@ -24,41 +24,38 @@ /** * Provides base functionality for dealing with I/O using single wagon. */ -public abstract class AbstractDoubleWagonMojo - extends AbstractWagonMojo -{ +public abstract class AbstractDoubleWagonMojo extends AbstractWagonMojo { /** * The URL to the source repository. */ - @Parameter( property = "wagon.source", required = true) + @Parameter(property = "wagon.source", required = true) protected String source; /** * The URL to the target repository. */ - @Parameter( property = "wagon.target", required = true) + @Parameter(property = "wagon.target", required = true) protected String target; /** * settings.xml's server id of the source repository. This is used when wagon needs extra authentication * information. */ - @Parameter( property = "wagon.sourceId", defaultValue = "source") + @Parameter(property = "wagon.sourceId", defaultValue = "source") protected String sourceId; /** * settings.xml's server id of the target repository. This is used when wagon needs extra authentication * information. */ - @Parameter( property = "wagon.targetId", defaultValue = "target") + @Parameter(property = "wagon.targetId", defaultValue = "target") protected String targetId; /** * Optimize the upload by locally compressed all files in one bundle, upload the bundle, and finally remote * uncompress the bundle. This only works with SCP's URL */ - @Parameter( property = "wagon.optimize", defaultValue = "false") + @Parameter(property = "wagon.optimize", defaultValue = "false") protected boolean optimize = false; - } diff --git a/src/main/java/org/codehaus/mojo/wagon/AbstractSingleWagonMojo.java b/src/main/java/org/codehaus/mojo/wagon/AbstractSingleWagonMojo.java index 7b0fc41..80b44df 100644 --- a/src/main/java/org/codehaus/mojo/wagon/AbstractSingleWagonMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/AbstractSingleWagonMojo.java @@ -19,64 +19,51 @@ * under the License. */ +import java.io.IOException; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.WagonException; -import java.io.IOException; - /** * Provides base functionality for dealing with I/O using single wagon. */ -public abstract class AbstractSingleWagonMojo - extends AbstractWagonMojo -{ +public abstract class AbstractSingleWagonMojo extends AbstractWagonMojo { /** * URL to upload to or download from or list. Must exist and point to a directory. */ - @Parameter( property = "wagon.url", required = true ) + @Parameter(property = "wagon.url", required = true) protected String url; /** * settings.xml's server id for the URL. This is used when wagon needs extra authentication information. */ - @Parameter( property = "wagon.serverId", defaultValue = "serverId") + @Parameter(property = "wagon.serverId", defaultValue = "serverId") private String serverId; @Override - public void execute() - throws MojoExecutionException - { - if ( this.skip ) - { - this.getLog().info( "Skip execution." ); + public void execute() throws MojoExecutionException { + if (this.skip) { + this.getLog().info("Skip execution."); return; } Wagon wagon = null; - try - { - wagon = createWagon( serverId, url ); - execute( wagon ); - } - catch ( WagonException | IOException e ) - { - throw new MojoExecutionException( "Error handling resource", e ); - } finally - { - try - { - if ( wagon != null ) - { + try { + wagon = createWagon(serverId, url); + execute(wagon); + } catch (WagonException | IOException e) { + throw new MojoExecutionException("Error handling resource", e); + } finally { + try { + if (wagon != null) { wagon.disconnect(); } - } - catch ( ConnectionException e ) - { - getLog().debug( "Error disconnecting wagon - ignored", e ); + } catch (ConnectionException e) { + getLog().debug("Error disconnecting wagon - ignored", e); } } } @@ -89,7 +76,5 @@ public void execute() * @throws WagonException if any wagon error * @throws IOException if any io error */ - protected abstract void execute( Wagon wagon ) - throws MojoExecutionException, WagonException, IOException; - + protected abstract void execute(Wagon wagon) throws MojoExecutionException, WagonException, IOException; } diff --git a/src/main/java/org/codehaus/mojo/wagon/AbstractWagonListMojo.java b/src/main/java/org/codehaus/mojo/wagon/AbstractWagonListMojo.java index ab7230f..e5f64e0 100644 --- a/src/main/java/org/codehaus/mojo/wagon/AbstractWagonListMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/AbstractWagonListMojo.java @@ -27,40 +27,36 @@ /** * Contains common configuration to scan for Wagon's files */ -public abstract class AbstractWagonListMojo - extends AbstractSingleWagonMojo +public abstract class AbstractWagonListMojo extends AbstractSingleWagonMojo { -{ /** * Directory path relative to Wagon's URL */ - @Parameter( property = "wagon.fromDir") + @Parameter(property = "wagon.fromDir") protected String fromDir = ""; /** * Comma separated list of Ant's includes to scan for remote files */ - @Parameter( property = "wagon.includes", defaultValue = "*") + @Parameter(property = "wagon.includes", defaultValue = "*") protected String includes; /** * Comma separated list of Ant's excludes to scan for remote files. */ - @Parameter( property = "wagon.excludes") + @Parameter(property = "wagon.excludes") protected String excludes; /** * Whether to consider remote path case sensitivity during scan. */ - @Parameter( property = "wagon.caseSensitive", defaultValue = "true") + @Parameter(property = "wagon.caseSensitive", defaultValue = "true") protected boolean caseSensitive = true; @Component protected WagonDownload wagonDownload; - protected WagonFileSet getWagonFileSet() - { - return this.getWagonFileSet( fromDir, includes, excludes, caseSensitive, "" ); + protected WagonFileSet getWagonFileSet() { + return this.getWagonFileSet(fromDir, includes, excludes, caseSensitive, ""); } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/AbstractWagonMojo.java b/src/main/java/org/codehaus/mojo/wagon/AbstractWagonMojo.java index 527412c..f5b86df 100644 --- a/src/main/java/org/codehaus/mojo/wagon/AbstractWagonMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/AbstractWagonMojo.java @@ -14,9 +14,7 @@ /** * Provides base functionality for dealing with I/O using wagon. */ -public abstract class AbstractWagonMojo - extends AbstractMojo -{ +public abstract class AbstractWagonMojo extends AbstractMojo { @Component protected WagonFactory wagonFactory; @@ -24,41 +22,34 @@ public abstract class AbstractWagonMojo /** * The current user system settings for use in Maven. */ - @Parameter( defaultValue = "${settings}", readonly = true ) + @Parameter(defaultValue = "${settings}", readonly = true) protected Settings settings; /** * Internal Maven's project. */ - @Parameter( defaultValue = "${project}", readonly = true ) + @Parameter(defaultValue = "${project}", readonly = true) protected MavenProject project; /** * When true, skip the execution. * @since 2.0.0 */ - @Parameter( property = "wagon.skip" ) + @Parameter(property = "wagon.skip") protected boolean skip = false; ///////////////////////////////////////////////////////////////////////// - protected Wagon createWagon( String id, String url ) - throws MojoExecutionException - { - try - { - return wagonFactory.create( url, id, settings ); + protected Wagon createWagon(String id, String url) throws MojoExecutionException { + try { + return wagonFactory.create(url, id, settings); + } catch (Exception e) { + throw new MojoExecutionException("Unable to create a Wagon instance for " + url, e); } - catch ( Exception e ) - { - throw new MojoExecutionException( "Unable to create a Wagon instance for " + url, e ); - } - } - protected WagonFileSet getWagonFileSet( String fromDir, String includes, String excludes, boolean caseSensitive, - String toDir ) - { - return WagonUtils.getWagonFileSet( fromDir, includes, excludes, caseSensitive, toDir ); + protected WagonFileSet getWagonFileSet( + String fromDir, String includes, String excludes, boolean caseSensitive, String toDir) { + return WagonUtils.getWagonFileSet(fromDir, includes, excludes, caseSensitive, toDir); } } diff --git a/src/main/java/org/codehaus/mojo/wagon/CopyMojo.java b/src/main/java/org/codehaus/mojo/wagon/CopyMojo.java index 51cf5bc..5bee64d 100644 --- a/src/main/java/org/codehaus/mojo/wagon/CopyMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/CopyMojo.java @@ -32,50 +32,45 @@ /** * 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") + @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") + @Parameter(property = "wagon.caseSensitive") private boolean caseSensitive = true; /** * Remote path relative to target's url to copy files to. */ - @Parameter( property = "wagon.toDir") + @Parameter(property = "wagon.toDir") private String toDir = ""; @Component private WagonCopy wagonCopy; @Override - protected void copy( Wagon srcWagon, Wagon targetWagon ) - throws IOException, WagonException - { - WagonFileSet fileSet = this.getWagonFileSet( fromDir, includes, excludes, caseSensitive, toDir ); + protected void copy(Wagon srcWagon, Wagon targetWagon) throws IOException, WagonException { + WagonFileSet fileSet = this.getWagonFileSet(fromDir, includes, excludes, caseSensitive, toDir); - wagonCopy.copy( srcWagon, fileSet, targetWagon, optimize, this.getLog() ); + wagonCopy.copy(srcWagon, fileSet, targetWagon, optimize, this.getLog()); } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/DownloadMojo.java b/src/main/java/org/codehaus/mojo/wagon/DownloadMojo.java index 398e0cc..5f6ba81 100644 --- a/src/main/java/org/codehaus/mojo/wagon/DownloadMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/DownloadMojo.java @@ -30,25 +30,20 @@ /** * Transfers a set of files from a remote URL to a specified local directory. */ -@Mojo( name = "download" , requiresProject = false) -public class DownloadMojo - extends AbstractWagonListMojo -{ +@Mojo(name = "download", requiresProject = false) +public class DownloadMojo extends AbstractWagonListMojo { /** * Local directory to download the remote resource ( tree ) to. */ - @Parameter( property = "wagon.toDir", defaultValue = "${project.build.directory}/wagon-plugin") + @Parameter(property = "wagon.toDir", defaultValue = "${project.build.directory}/wagon-plugin") private File toDir; @Override - protected void execute( Wagon wagon ) - throws WagonException - { + protected void execute(Wagon wagon) throws WagonException { WagonFileSet fileSet = this.getWagonFileSet(); - fileSet.setDownloadDirectory( this.toDir ); + fileSet.setDownloadDirectory(this.toDir); - this.wagonDownload.download( wagon, fileSet, this.getLog() ); + this.wagonDownload.download(wagon, fileSet, this.getLog()); } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/DownloadSingleMojo.java b/src/main/java/org/codehaus/mojo/wagon/DownloadSingleMojo.java index c104815..9fadfc8 100644 --- a/src/main/java/org/codehaus/mojo/wagon/DownloadSingleMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/DownloadSingleMojo.java @@ -19,6 +19,8 @@ * under the License. */ +import java.io.File; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -26,82 +28,69 @@ import org.apache.maven.wagon.WagonException; import org.codehaus.plexus.util.StringUtils; -import java.io.File; - /** * Download a single file. */ -@Mojo( name = "download-single", requiresProject = false) -public class DownloadSingleMojo - extends AbstractSingleWagonMojo -{ +@Mojo(name = "download-single", requiresProject = false) +public class DownloadSingleMojo extends AbstractSingleWagonMojo { /** * Relative path to the base URL. When empty, assume base URL has the full path */ - @Parameter( property = "wagon.fromFile") + @Parameter(property = "wagon.fromFile") private String fromFile; /** * Directory to download the remote file to. */ - @Parameter( property = "wagon.toDir") + @Parameter(property = "wagon.toDir") private File toDir; /** * File to download the remote file to. Use this option to rename the file after download. When toDir is present, * this argument is ignored. */ - @Parameter( property = "wagon.toFile") + @Parameter(property = "wagon.toFile") private File toFile; /** * Skip download if local file already exists. */ - @Parameter( property = "wagon.skipIfExists") + @Parameter(property = "wagon.skipIfExists") private boolean skipIfExists; @Override - protected void execute( Wagon wagon ) - throws MojoExecutionException, WagonException - { + protected void execute(Wagon wagon) throws MojoExecutionException, WagonException { - if ( this.skip ) - { - this.getLog().info( "Skip execution." ); + if (this.skip) { + this.getLog().info("Skip execution."); return; } - if ( toDir != null ) - { - toFile = new File( toDir, new File( fromFile ).getName() ); + if (toDir != null) { + toFile = new File(toDir, new File(fromFile).getName()); } - if ( toFile == null ) - { - throw new MojoExecutionException( "Either toDir or toFile is required" ); + if (toFile == null) { + throw new MojoExecutionException("Either toDir or toFile is required"); } - if ( skipIfExists && toFile.exists() ) - { - getLog().info("Skip execution - file " + toFile + " already exists." ); + if (skipIfExists && toFile.exists()) { + getLog().info("Skip execution - file " + toFile + " already exists."); return; } - this.getLog().info( "Downloading: " + wagon.getRepository().getUrl() + "/" + fromFile + " to " + toFile ); - - wagon.get( fromFile, toFile ); + this.getLog().info("Downloading: " + wagon.getRepository().getUrl() + "/" + fromFile + " to " + toFile); + wagon.get(fromFile, toFile); } @Override - public void execute() - throws MojoExecutionException - { - if ( StringUtils.isBlank( this.fromFile ) ) { + public void execute() throws MojoExecutionException { + if (StringUtils.isBlank(this.fromFile)) { - //recompute base url and fromFile - String [] tokens = StringUtils.split( this.url, "/\\" ); + // recompute base url and fromFile + String[] tokens = StringUtils.split(this.url, "/\\"); this.fromFile = tokens[tokens.length - 1]; - this.url = url.substring( 0, url.length() - this.fromFile.length() - 1 ); + this.url = url.substring(0, url.length() - this.fromFile.length() - 1); } super.execute(); diff --git a/src/main/java/org/codehaus/mojo/wagon/ExistMojo.java b/src/main/java/org/codehaus/mojo/wagon/ExistMojo.java index 38885cd..f27ac6b 100644 --- a/src/main/java/org/codehaus/mojo/wagon/ExistMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/ExistMojo.java @@ -29,31 +29,23 @@ /** * Check for the existing of remote resource. */ -@Mojo( name = "exist" ) -public class ExistMojo - extends AbstractSingleWagonMojo -{ +@Mojo(name = "exist") +public class ExistMojo extends AbstractSingleWagonMojo { /** * relative path to a remote resource. */ - @Parameter( property = "wagon.resource") + @Parameter(property = "wagon.resource") private String resource = ""; @Component protected WagonDownload wagonDownload; @Override - protected void execute( Wagon wagon ) - throws WagonException - { - if ( this.wagonDownload.exists( wagon, resource ) ) - { - this.getLog().info( resource + " exists. " ); - } - else - { - this.getLog().info( resource + " does not exists. " ); + protected void execute(Wagon wagon) throws WagonException { + if (this.wagonDownload.exists(wagon, resource)) { + this.getLog().info(resource + " exists. "); + } else { + this.getLog().info(resource + " does not exists. "); } } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/ListMojo.java b/src/main/java/org/codehaus/mojo/wagon/ListMojo.java index 1a83541..74b73f0 100644 --- a/src/main/java/org/codehaus/mojo/wagon/ListMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/ListMojo.java @@ -9,21 +9,16 @@ /** * Lists the content of the specified directory (remotePath) under a specified repository (url). */ -@Mojo( name = "list" , requiresProject = false) -public class ListMojo - extends AbstractWagonListMojo -{ +@Mojo(name = "list", requiresProject = false) +public class ListMojo extends AbstractWagonListMojo { @Override - protected void execute( Wagon wagon ) - throws WagonException - { - List files = wagonDownload.getFileList( wagon, this.getWagonFileSet(), this.getLog() ); + protected void execute(Wagon wagon) throws WagonException { + List files = wagonDownload.getFileList(wagon, this.getWagonFileSet(), this.getLog()); - for ( Object file1 : files ) - { + for (Object file1 : files) { String file = (String) file1; - getLog().info( "\t" + file ); + getLog().info("\t" + file); } } } diff --git a/src/main/java/org/codehaus/mojo/wagon/MergeMavenRepoMojo.java b/src/main/java/org/codehaus/mojo/wagon/MergeMavenRepoMojo.java index b48450f..6237cab 100644 --- a/src/main/java/org/codehaus/mojo/wagon/MergeMavenRepoMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/MergeMavenRepoMojo.java @@ -30,19 +30,14 @@ /** * Merge artifacts from one Maven repository to another Maven repository. */ -@Mojo( name = "merge-maven-repos" , requiresProject = false) -public class MergeMavenRepoMojo - extends AbstractCopyMojo -{ +@Mojo(name = "merge-maven-repos", requiresProject = false) +public class MergeMavenRepoMojo extends AbstractCopyMojo { @Component private MavenRepoMerger mavenRepoMerger; @Override - protected void copy( Wagon srcWagon, Wagon targetWagon ) - throws IOException, WagonException - { - mavenRepoMerger.merge( srcWagon, targetWagon, optimize, this.getLog() ); + protected void copy(Wagon srcWagon, Wagon targetWagon) throws IOException, WagonException { + mavenRepoMerger.merge(srcWagon, targetWagon, optimize, this.getLog()); } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/SshExecMojo.java b/src/main/java/org/codehaus/mojo/wagon/SshExecMojo.java index 65f7d8b..8e0034b 100644 --- a/src/main/java/org/codehaus/mojo/wagon/SshExecMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/SshExecMojo.java @@ -31,10 +31,8 @@ /** * Executes a list of commands against a given server. */ -@Mojo( name = "sshexec") -public class SshExecMojo - extends AbstractSingleWagonMojo -{ +@Mojo(name = "sshexec") +public class SshExecMojo extends AbstractSingleWagonMojo { /** * The commands that we will execute. @@ -55,41 +53,28 @@ public class SshExecMojo private boolean displayCommandOutputs = true; @Override - protected void execute( final Wagon wagon ) - throws MojoExecutionException - { - if ( commands != null ) - { - for ( String command : commands ) - { - try - { + protected void execute(final Wagon wagon) throws MojoExecutionException { + if (commands != null) { + for (String command : commands) { + try { Streams stream; - if ( wagon instanceof AbstractJschWagon ) - { - stream = ( (AbstractJschWagon) wagon ).executeCommand( command, true, false ); - } else - { - stream = ( (CommandExecutor) wagon ).executeCommand( command, false ); + if (wagon instanceof AbstractJschWagon) { + stream = ((AbstractJschWagon) wagon).executeCommand(command, true, false); + } else { + stream = ((CommandExecutor) wagon).executeCommand(command, false); } - this.getLog().info( "sshexec: " + command + " ..." ); - if ( displayCommandOutputs ) - { - System.out.println( stream.getOut() ); - System.out.println( stream.getErr() ); + this.getLog().info("sshexec: " + command + " ..."); + if (displayCommandOutputs) { + System.out.println(stream.getOut()); + System.out.println(stream.getErr()); } - } catch ( final WagonException e ) - { - if ( this.failOnError ) - { - throw new MojoExecutionException( "Unable to execute remote command", e ); - } - else - { - this.getLog().warn( e ); + } catch (final WagonException e) { + if (this.failOnError) { + throw new MojoExecutionException("Unable to execute remote command", e); + } else { + this.getLog().warn(e); } } - } } } diff --git a/src/main/java/org/codehaus/mojo/wagon/UploadMojo.java b/src/main/java/org/codehaus/mojo/wagon/UploadMojo.java index cff4fe0..9714eec 100644 --- a/src/main/java/org/codehaus/mojo/wagon/UploadMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/UploadMojo.java @@ -35,81 +35,74 @@ /** * Upload multiple sets of files. */ -@Mojo( name = "upload" ) -public class UploadMojo - extends AbstractSingleWagonMojo -{ +@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; /** * Follow local symbolic link if possible. */ - @Parameter( property = "wagon.followSymLink", defaultValue = "false") + @Parameter(property = "wagon.followSymLink", defaultValue = "false") private boolean followSymLink = false; /** * Use default exclude sets. */ - @Parameter( property = "wagon.useDefaultExcludes", defaultValue = "true") + @Parameter(property = "wagon.useDefaultExcludes", defaultValue = "true") private boolean useDefaultExcludes = true; /** * Remote path relative to Wagon's url to upload local files to. */ - @Parameter( property = "wagon.toDir") + @Parameter(property = "wagon.toDir") private String toDir = ""; /** * 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") + @Parameter(property = "wagon.optimize", defaultValue = "false") private boolean optimize = false; @Component protected WagonUpload wagonUpload; @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 ); + this.wagonUpload.upload(wagon, fileSet, optimize); } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/UploadSingleMojo.java b/src/main/java/org/codehaus/mojo/wagon/UploadSingleMojo.java index 603d1b3..d361c7d 100644 --- a/src/main/java/org/codehaus/mojo/wagon/UploadSingleMojo.java +++ b/src/main/java/org/codehaus/mojo/wagon/UploadSingleMojo.java @@ -30,41 +30,34 @@ /** * Upload a single file with option to change name */ -@Mojo( name = "upload-single" , requiresProject = false ) -public class UploadSingleMojo - extends AbstractSingleWagonMojo -{ +@Mojo(name = "upload-single", requiresProject = false) +public class UploadSingleMojo extends AbstractSingleWagonMojo { /** * Path to a local file to be uploaded. */ - @Parameter( property = "wagon.fromFile", required = true) + @Parameter(property = "wagon.fromFile", required = true) private File fromFile; /** * Relative path to the URL. When blank, default to fromFile's file name. */ - @Parameter( property = "wagon.toFile") + @Parameter(property = "wagon.toFile") private String toFile; @Override - protected void execute( Wagon wagon ) - throws WagonException - { - if ( this.skip ) - { - this.getLog().info( "Skip execution." ); + protected void execute(Wagon wagon) throws WagonException { + if (this.skip) { + this.getLog().info("Skip execution."); return; } - if ( StringUtils.isBlank( toFile ) ) - { + if (StringUtils.isBlank(toFile)) { toFile = fromFile.getName(); } - this.getLog().info( "Uploading: " + fromFile + " " + wagon.getRepository().getUrl() + "/" + toFile ); - - wagon.put( fromFile, toFile ); + this.getLog() + .info("Uploading: " + fromFile + " " + wagon.getRepository().getUrl() + "/" + toFile); + wagon.put(fromFile, toFile); } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/DefaultMavenRepoMerger.java b/src/main/java/org/codehaus/mojo/wagon/shared/DefaultMavenRepoMerger.java index b2d721a..8197dd5 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/DefaultMavenRepoMerger.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/DefaultMavenRepoMerger.java @@ -49,9 +49,7 @@ * A copy of stage's plugin RepositoryCopier but use WagonUpload and WagonDownload instead. */ @Component(role = MavenRepoMerger.class, hint = "default") -public class DefaultMavenRepoMerger - implements MavenRepoMerger -{ +public class DefaultMavenRepoMerger implements MavenRepoMerger { @Requirement private WagonDownload downloader; @@ -59,106 +57,89 @@ public class DefaultMavenRepoMerger private WagonUpload uploader; @Override - public void merge( Wagon src, Wagon target, boolean optimize, Log logger ) - throws WagonException, IOException - { + public void merge(Wagon src, Wagon target, boolean optimize, Log logger) throws WagonException, IOException { // copy src to a local dir - File downloadSrcDir = createTempDirectory( "wagon-maven-plugin" ); + File downloadSrcDir = createTempDirectory("wagon-maven-plugin"); WagonFileSet srcFileSet = new WagonFileSet(); - srcFileSet.setDownloadDirectory( downloadSrcDir ); + srcFileSet.setDownloadDirectory(downloadSrcDir); // ignore archiva/nexus .index at root dir - String[] excludes = { ".*/**", "archetype-catalog.xml*" }; - srcFileSet.setExcludes( excludes ); + String[] excludes = {".*/**", "archetype-catalog.xml*"}; + srcFileSet.setExcludes(excludes); - try - { - downloader.download( src, srcFileSet, logger ); + try { + downloader.download(src, srcFileSet, logger); // merge metadata DirectoryScanner scanner = new DirectoryScanner(); - scanner.setBasedir( downloadSrcDir ); - String[] includes = { "**/" + MAVEN_METADATA }; - scanner.setIncludes( includes ); + scanner.setBasedir(downloadSrcDir); + String[] includes = {"**/" + MAVEN_METADATA}; + scanner.setIncludes(includes); scanner.scan(); String[] files = scanner.getIncludedFiles(); - for ( String file : files ) - { - File srcMetadaFile = new File( downloadSrcDir, file + IN_PROCESS_MARKER ); + for (String file : files) { + File srcMetadaFile = new File(downloadSrcDir, file + IN_PROCESS_MARKER); - try - { - target.get( file.replace( '\\', '/' ), srcMetadaFile ); - } catch ( ResourceDoesNotExistException e ) - { + try { + target.get(file.replace('\\', '/'), srcMetadaFile); + } catch (ResourceDoesNotExistException e) { // We don't have an equivalent on the targetRepositoryUrl side because we have something // new on the sourceRepositoryUrl side so just skip the metadata merging. continue; } - try - { - mergeMetadata( srcMetadaFile, logger ); - } catch ( XmlPullParserException e ) - { - throw new IOException( "Metadata file is corrupt " + file + " Reason: " + e.getMessage() ); + try { + mergeMetadata(srcMetadaFile, logger); + } catch (XmlPullParserException e) { + throw new IOException("Metadata file is corrupt " + file + " Reason: " + e.getMessage()); } - } // upload to target FileSet tobeUploadedFileSet = new FileSet(); - tobeUploadedFileSet.setDirectory( downloadSrcDir.getAbsolutePath() ); + tobeUploadedFileSet.setDirectory(downloadSrcDir.getAbsolutePath()); - this.uploader.upload( target, tobeUploadedFileSet, optimize ); + this.uploader.upload(target, tobeUploadedFileSet, optimize); + } finally { + FileUtils.deleteDirectory(downloadSrcDir); } - finally - { - FileUtils.deleteDirectory( downloadSrcDir ); - } - } - private void mergeMetadata( File existingMetadata, Log logger ) - throws IOException, XmlPullParserException - { + private void mergeMetadata(File existingMetadata, Log logger) throws IOException, XmlPullParserException { Writer stagedMetadataWriter = null; Reader existingMetadataReader = null; Reader stagedMetadataReader = null; File stagedMetadataFile; - try - { + try { MetadataXpp3Reader xppReader = new MetadataXpp3Reader(); MetadataXpp3Writer xppWriter = new MetadataXpp3Writer(); // Existing Metadata in target stage - existingMetadataReader = new FileReader( existingMetadata ); - Metadata existing = xppReader.read( existingMetadataReader ); + existingMetadataReader = new FileReader(existingMetadata); + Metadata existing = xppReader.read(existingMetadataReader); // Staged Metadata - stagedMetadataFile = new File( existingMetadata.getParentFile(), MAVEN_METADATA ); - stagedMetadataReader = new FileReader( stagedMetadataFile ); - Metadata staged = xppReader.read( stagedMetadataReader ); + stagedMetadataFile = new File(existingMetadata.getParentFile(), MAVEN_METADATA); + stagedMetadataReader = new FileReader(stagedMetadataFile); + Metadata staged = xppReader.read(stagedMetadataReader); // Merge and write back to staged metadata to replace the remote one - existing.merge( staged ); + existing.merge(staged); - stagedMetadataWriter = new FileWriter( stagedMetadataFile ); - xppWriter.write( stagedMetadataWriter, existing ); + stagedMetadataWriter = new FileWriter(stagedMetadataFile); + xppWriter.write(stagedMetadataWriter, existing); - logger.info( "Merging metadata file: " + stagedMetadataFile ); + logger.info("Merging metadata file: " + stagedMetadataFile); - } - finally - { - IOUtil.close( stagedMetadataWriter ); - IOUtil.close( stagedMetadataReader ); - IOUtil.close( existingMetadataReader ); + } finally { + IOUtil.close(stagedMetadataWriter); + IOUtil.close(stagedMetadataReader); + IOUtil.close(existingMetadataReader); existingMetadata.delete(); } @@ -166,64 +147,52 @@ private void mergeMetadata( File existingMetadata, Log logger ) // Mark all metadata as in-process and regenerate the checksums as they will be different // after the merger - try - { - File newMd5 = new File( stagedMetadataFile.getParentFile(), MAVEN_METADATA + ".md5" ); - FileUtils.fileWrite( newMd5.getAbsolutePath(), checksum( stagedMetadataFile, MD5 ) ); + try { + File newMd5 = new File(stagedMetadataFile.getParentFile(), MAVEN_METADATA + ".md5"); + FileUtils.fileWrite(newMd5.getAbsolutePath(), checksum(stagedMetadataFile, MD5)); - File newSha1 = new File( stagedMetadataFile.getParentFile(), MAVEN_METADATA + ".sha1" ); - FileUtils.fileWrite( newSha1.getAbsolutePath(), checksum( stagedMetadataFile, SHA1 ) ); - } - catch ( NoSuchAlgorithmException e ) - { - throw new RuntimeException( e ); + File newSha1 = new File(stagedMetadataFile.getParentFile(), MAVEN_METADATA + ".sha1"); + FileUtils.fileWrite(newSha1.getAbsolutePath(), checksum(stagedMetadataFile, SHA1)); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); } // We have the new merged copy so we're good } - private String checksum( File file, String type ) - throws IOException, NoSuchAlgorithmException - { - MessageDigest md5 = MessageDigest.getInstance( type ); + private String checksum(File file, String type) throws IOException, NoSuchAlgorithmException { + MessageDigest md5 = MessageDigest.getInstance(type); - InputStream is = new FileInputStream( file ); + InputStream is = new FileInputStream(file); byte[] buf = new byte[8192]; int i; - while ( ( i = is.read( buf ) ) > 0 ) - { - md5.update( buf, 0, i ); + while ((i = is.read(buf)) > 0) { + md5.update(buf, 0, i); } - IOUtil.close( is ); + IOUtil.close(is); - return encode( md5.digest() ); + return encode(md5.digest()); } - private String encode( byte[] binaryData ) - { - if ( binaryData.length != 16 && binaryData.length != 20 ) - { + private String encode(byte[] binaryData) { + if (binaryData.length != 16 && binaryData.length != 20) { int bitLength = binaryData.length * 8; - throw new IllegalArgumentException( "Unrecognised length for binary data: " + bitLength + " bits" ); + throw new IllegalArgumentException("Unrecognised length for binary data: " + bitLength + " bits"); } String retValue = ""; - for ( byte aBinaryData : binaryData ) - { - String t = Integer.toHexString( aBinaryData & 0xff ); + for (byte aBinaryData : binaryData) { + String t = Integer.toHexString(aBinaryData & 0xff); - if ( t.length() == 1 ) - { - retValue += ( "0" + t ); - } - else - { + if (t.length() == 1) { + retValue += ("0" + t); + } else { retValue += t; } } @@ -231,24 +200,19 @@ private String encode( byte[] binaryData ) return retValue.trim(); } - public static File createTempDirectory( String prefix ) - throws IOException - { + public static File createTempDirectory(String prefix) throws IOException { final File temp; - temp = File.createTempFile( prefix, Long.toString( System.nanoTime() ) ); + temp = File.createTempFile(prefix, Long.toString(System.nanoTime())); - if ( !( temp.delete() ) ) - { - throw new IOException( "Could not delete temp file: " + temp.getAbsolutePath() ); + if (!(temp.delete())) { + throw new IOException("Could not delete temp file: " + temp.getAbsolutePath()); } - if ( !( temp.mkdir() ) ) - { - throw new IOException( "Could not create temp directory: " + temp.getAbsolutePath() ); + if (!(temp.mkdir())) { + throw new IOException("Could not create temp directory: " + temp.getAbsolutePath()); } - return ( temp ); + return (temp); } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonCopy.java b/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonCopy.java index 5c0f2e3..75b986e 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonCopy.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonCopy.java @@ -34,9 +34,7 @@ * Copy a set of file from a wagon repo to another wagon repo. */ @Component(role = WagonCopy.class, hint = "default") -public class DefaultWagonCopy - implements WagonCopy -{ +public class DefaultWagonCopy implements WagonCopy { @Requirement private WagonDownload downloader; @@ -44,41 +42,33 @@ public class DefaultWagonCopy private WagonUpload uploader; @Override - public void copy( Wagon src, WagonFileSet wagonFileSet, Wagon target, boolean optimize, Log logger ) - throws WagonException, IOException - { - if ( wagonFileSet == null ) - { + public void copy(Wagon src, WagonFileSet wagonFileSet, Wagon target, boolean optimize, Log logger) + throws WagonException, IOException { + if (wagonFileSet == null) { wagonFileSet = new WagonFileSet(); } boolean removeDownloadDir = false; - if ( wagonFileSet.getDownloadDirectory() == null ) - { - File downloadSrcDir = File.createTempFile( "wagon", "wagon" ); + if (wagonFileSet.getDownloadDirectory() == null) { + File downloadSrcDir = File.createTempFile("wagon", "wagon"); downloadSrcDir.delete(); - wagonFileSet.setDownloadDirectory( downloadSrcDir ); + wagonFileSet.setDownloadDirectory(downloadSrcDir); removeDownloadDir = true; } - try - { - this.downloader.download( src, wagonFileSet, logger ); + try { + this.downloader.download(src, wagonFileSet, logger); FileSet localFileSet = new FileSet(); - localFileSet.setDirectory( wagonFileSet.getDownloadDirectory().getAbsolutePath() ); - localFileSet.setOutputDirectory( wagonFileSet.getOutputDirectory() ); + localFileSet.setDirectory(wagonFileSet.getDownloadDirectory().getAbsolutePath()); + localFileSet.setOutputDirectory(wagonFileSet.getOutputDirectory()); - this.uploader.upload( target, localFileSet, optimize ); - } - finally - { - if ( removeDownloadDir ) - { - FileUtils.deleteDirectory( wagonFileSet.getDownloadDirectory() ); + this.uploader.upload(target, localFileSet, optimize); + } finally { + if (removeDownloadDir) { + FileUtils.deleteDirectory(wagonFileSet.getDownloadDirectory()); } } - } } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonDownload.java b/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonDownload.java index 47c835d..a926ddd 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonDownload.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonDownload.java @@ -29,25 +29,20 @@ import org.codehaus.plexus.util.StringUtils; @Component(role = WagonDownload.class, hint = "default") -public class DefaultWagonDownload - implements WagonDownload -{ +public class DefaultWagonDownload implements WagonDownload { @Override - public List getFileList( Wagon wagon, WagonFileSet fileSet, Log logger ) - throws WagonException - { - logger.info( "Scanning remote file system: " + wagon.getRepository().getUrl() + " ..." ); + public List getFileList(Wagon wagon, WagonFileSet fileSet, Log logger) throws WagonException { + logger.info("Scanning remote file system: " + wagon.getRepository().getUrl() + " ..."); WagonDirectoryScanner dirScan = new WagonDirectoryScanner(); - dirScan.setLogger( logger ); - dirScan.setWagon( wagon ); - dirScan.setExcludes( fileSet.getExcludes() ); - dirScan.setIncludes( fileSet.getIncludes() ); - dirScan.setCaseSensitive( fileSet.isCaseSensitive() ); - dirScan.setDirectory( fileSet.getDirectory() ); - if ( fileSet.isUseDefaultExcludes() ) - { + dirScan.setLogger(logger); + dirScan.setWagon(wagon); + dirScan.setExcludes(fileSet.getExcludes()); + dirScan.setIncludes(fileSet.getIncludes()); + dirScan.setCaseSensitive(fileSet.isCaseSensitive()); + dirScan.setDirectory(fileSet.getDirectory()); + if (fileSet.isUseDefaultExcludes()) { dirScan.addDefaultExcludes(); } @@ -57,42 +52,34 @@ public List getFileList( Wagon wagon, WagonFileSet fileSet, Log logger ) } @Override - public void download( Wagon wagon, WagonFileSet remoteFileSet, Log logger ) - throws WagonException - { - List fileList = this.getFileList( wagon, remoteFileSet, logger ); + public void download(Wagon wagon, WagonFileSet remoteFileSet, Log logger) throws WagonException { + List fileList = this.getFileList(wagon, remoteFileSet, logger); String url = wagon.getRepository().getUrl() + "/"; - if ( fileList.size() == 0 ) - { - logger.info( "Nothing to download." ); + if (fileList.size() == 0) { + logger.info("Nothing to download."); return; } - for ( Object aFileList : fileList ) - { + for (Object aFileList : fileList) { String remoteFile = (String) aFileList; - File destination = new File( remoteFileSet.getDownloadDirectory() + "/" + remoteFile ); + File destination = new File(remoteFileSet.getDownloadDirectory() + "/" + remoteFile); destination.getParentFile().mkdirs(); - if ( !StringUtils.isBlank( remoteFileSet.getDirectory() ) ) - { + if (!StringUtils.isBlank(remoteFileSet.getDirectory())) { remoteFile = remoteFileSet.getDirectory() + "/" + remoteFile; } - logger.info( "Downloading " + url + remoteFile + " to " + destination + " ..." ); + logger.info("Downloading " + url + remoteFile + " to " + destination + " ..."); - wagon.get( remoteFile, destination ); + wagon.get(remoteFile, destination); } } @Override - public boolean exists( Wagon wagon, String resource ) - throws WagonException - { - return wagon.resourceExists( resource ); + public boolean exists(Wagon wagon, String resource) throws WagonException { + return wagon.resourceExists(resource); } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonFactory.java b/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonFactory.java index f3acdbd..23edb9a 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonFactory.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonFactory.java @@ -1,5 +1,7 @@ package org.codehaus.mojo.wagon.shared; +import java.util.List; + import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; @@ -18,9 +20,9 @@ import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.configurator.BasicComponentConfigurator; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.component.configurator.BasicComponentConfigurator; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ComponentConfigurator; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; @@ -34,13 +36,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; @Component(role = WagonFactory.class, hint = "default") -public class DefaultWagonFactory - implements WagonFactory, Contextualizable -{ +public class DefaultWagonFactory implements WagonFactory, Contextualizable { - private final Logger logger = LoggerFactory.getLogger( this.getClass() ); + private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Requirement private SettingsDecrypter settingsDecrypter; @@ -55,62 +54,49 @@ public class DefaultWagonFactory private PlexusContainer container; @Override - public Wagon create( String url, String serverId, Settings settings ) - throws WagonException - { - final Repository repository = new Repository( serverId, url == null ? "" : url ); - repository.setPermissions( getPermissions( serverId, settings ) ); + public Wagon create(String url, String serverId, Settings settings) throws WagonException { + final Repository repository = new Repository(serverId, url == null ? "" : url); + repository.setPermissions(getPermissions(serverId, settings)); Wagon wagon; - if ( url == null ) - { - wagon = createAndConfigureWagon( serverId, settings, repository ); - } - else - { - wagon = getWagon( repository.getProtocol() ); + if (url == null) { + wagon = createAndConfigureWagon(serverId, settings, repository); + } else { + wagon = getWagon(repository.getProtocol()); - configureWagon( wagon, serverId, settings ); + configureWagon(wagon, serverId, settings); } - - - if ( logger.isDebugEnabled() ) - { + if (logger.isDebugEnabled()) { Debug debug = new Debug(); - wagon.addSessionListener( debug ); - wagon.addTransferListener( debug ); + wagon.addSessionListener(debug); + wagon.addTransferListener(debug); } - AuthenticationInfo authInfo = getAuthenticationInfo( serverId, settings ); - ProxyInfo proxyInfo = getProxyInfo( settings ); - wagon.connect( repository, authInfo, proxyInfo ); + AuthenticationInfo authInfo = getAuthenticationInfo(serverId, settings); + ProxyInfo proxyInfo = getProxyInfo(settings); + wagon.connect(repository, authInfo, proxyInfo); return wagon; } - private Wagon createAndConfigureWagon( String repositoryId, Settings settings, Repository repository ) - throws WagonException - { + private Wagon createAndConfigureWagon(String repositoryId, Settings settings, Repository repository) + throws WagonException { Wagon wagon = null; - for ( Server server : settings.getServers() ) - { + for (Server server : settings.getServers()) { String id = server.getId(); - if ( id != null && id.equals( repositoryId ) ) - { + if (id != null && id.equals(repositoryId)) { Xpp3Dom configuration = (Xpp3Dom) server.getConfiguration(); - String url = configuration == null ? null : configuration.getAttribute( "url" ); - if ( StringUtils.isBlank( url ) ) - { - throw new NullPointerException( "url cannot be null" ); + String url = configuration == null ? null : configuration.getAttribute("url"); + if (StringUtils.isBlank(url)) { + throw new NullPointerException("url cannot be null"); } - repository.setUrl( url ); + repository.setUrl(url); - wagon = getWagon( repository.getProtocol() ); - configureWagon( wagon, repositoryId, server ); + wagon = getWagon(repository.getProtocol()); + configureWagon(wagon, repositoryId, server); break; - } } @@ -120,37 +106,28 @@ private Wagon createAndConfigureWagon( String repositoryId, Settings settings, R /////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// - private Wagon getWagon( String protocol ) - throws UnsupportedProtocolException - { - if ( protocol == null ) - { - throw new UnsupportedProtocolException( "Unspecified protocol" ); + private Wagon getWagon(String protocol) throws UnsupportedProtocolException { + if (protocol == null) { + throw new UnsupportedProtocolException("Unspecified protocol"); } - try - { - return container.lookup( Wagon.class, protocol.toLowerCase( java.util.Locale.ENGLISH ) ); - } - catch ( ComponentLookupException e ) - { - throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " - + protocol, e ); + try { + return container.lookup(Wagon.class, protocol.toLowerCase(java.util.Locale.ENGLISH)); + } catch (ComponentLookupException e) { + throw new UnsupportedProtocolException( + "Cannot find wagon which supports the requested protocol: " + protocol, e); } } - private static RepositoryPermissions getPermissions( String id, Settings settings ) - { + private static RepositoryPermissions getPermissions(String id, Settings settings) { // May not have an id - if ( StringUtils.isBlank( id ) ) - { + if (StringUtils.isBlank(id)) { return null; } // May not be a server matching that id - Server server = settings.getServer( id ); - if ( server == null ) - { + Server server = settings.getServer(id); + if (server == null) { return null; } @@ -159,15 +136,14 @@ private static RepositoryPermissions getPermissions( String id, Settings setting String dirPerms = server.getDirectoryPermissions(); // Check to see if custom permissions were supplied - if ( StringUtils.isBlank( filePerms ) && StringUtils.isBlank( dirPerms ) ) - { + if (StringUtils.isBlank(filePerms) && StringUtils.isBlank(dirPerms)) { return null; } // There are custom permissions specified in settings.xml for this server RepositoryPermissions permissions = new RepositoryPermissions(); - permissions.setFileMode( filePerms ); - permissions.setDirectoryMode( dirPerms ); + permissions.setFileMode(filePerms); + permissions.setDirectoryMode(dirPerms); return permissions; } @@ -177,91 +153,73 @@ private static RepositoryPermissions getPermissions( String id, Settings setting * * @return a proxyInfo object or null if no active proxy is define in the settings.xml */ - private ProxyInfo getProxyInfo( Settings settings ) - { + private ProxyInfo getProxyInfo(Settings settings) { ProxyInfo proxyInfo = null; - if ( settings != null && settings.getActiveProxy() != null ) - { + if (settings != null && settings.getActiveProxy() != null) { SettingsDecryptionResult result = - settingsDecrypter.decrypt( new DefaultSettingsDecryptionRequest( settings.getActiveProxy() ) ); + settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(settings.getActiveProxy())); Proxy settingsProxy = result.getProxy(); proxyInfo = new ProxyInfo(); - proxyInfo.setHost( settingsProxy.getHost() ); - proxyInfo.setType( settingsProxy.getProtocol() ); - proxyInfo.setPort( settingsProxy.getPort() ); - proxyInfo.setNonProxyHosts( settingsProxy.getNonProxyHosts() ); - proxyInfo.setUserName( settingsProxy.getUsername() ); - proxyInfo.setPassword( settingsProxy.getPassword() ); + proxyInfo.setHost(settingsProxy.getHost()); + proxyInfo.setType(settingsProxy.getProtocol()); + proxyInfo.setPort(settingsProxy.getPort()); + proxyInfo.setNonProxyHosts(settingsProxy.getNonProxyHosts()); + proxyInfo.setUserName(settingsProxy.getUsername()); + proxyInfo.setPassword(settingsProxy.getPassword()); } return proxyInfo; } - private Wagon configureWagon( Wagon wagon, String repositoryId, Settings settings ) - throws TransferFailedException - { - for ( Server server : settings.getServers() ) - { + private Wagon configureWagon(Wagon wagon, String repositoryId, Settings settings) throws TransferFailedException { + for (Server server : settings.getServers()) { String id = server.getId(); - if ( id != null && id.equals( repositoryId ) && ( server.getConfiguration() != null ) ) - { + if (id != null && id.equals(repositoryId) && (server.getConfiguration() != null)) { - configureWagon( wagon, repositoryId, server); + configureWagon(wagon, repositoryId, server); break; - } } return wagon; } - private Wagon configureWagon( Wagon wagon, String repositoryId, Server server) - throws TransferFailedException - { - final PlexusConfiguration plexusConf = - new XmlPlexusConfiguration( (Xpp3Dom) server.getConfiguration() ); - try - { - if ( !( componentConfigurator instanceof BasicComponentConfigurator ) ) { + private Wagon configureWagon(Wagon wagon, String repositoryId, Server server) throws TransferFailedException { + final PlexusConfiguration plexusConf = new XmlPlexusConfiguration((Xpp3Dom) server.getConfiguration()); + try { + if (!(componentConfigurator instanceof BasicComponentConfigurator)) { componentConfigurator = new BasicComponentConfigurator(); } - componentConfigurator.configureComponent( wagon, plexusConf, - (ClassRealm) this.getClass().getClassLoader() ); - } - catch ( ComponentConfigurationException e ) - { - throw new TransferFailedException( "While configuring wagon for \'" + repositoryId - + "\': Unable to apply wagon configuration.", e ); + componentConfigurator.configureComponent( + wagon, plexusConf, (ClassRealm) this.getClass().getClassLoader()); + } catch (ComponentConfigurationException e) { + throw new TransferFailedException( + "While configuring wagon for \'" + repositoryId + "\': Unable to apply wagon configuration.", e); } return wagon; } - public AuthenticationInfo getAuthenticationInfo( String id, Settings settings ) - { + public AuthenticationInfo getAuthenticationInfo(String id, Settings settings) { List servers = settings.getServers(); - if ( servers != null ) - { - for ( Server server : servers ) - { - if ( id.equalsIgnoreCase( server.getId() ) ) - { + if (servers != null) { + for (Server server : servers) { + if (id.equalsIgnoreCase(server.getId())) { SettingsDecryptionResult result = - settingsDecrypter.decrypt( new DefaultSettingsDecryptionRequest( server ) ); + settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(server)); server = result.getServer(); AuthenticationInfo authInfo = new AuthenticationInfo(); - authInfo.setUserName( server.getUsername() ); - authInfo.setPassword( server.getPassword() ); - authInfo.setPrivateKey( server.getPrivateKey() ); - authInfo.setPassphrase( server.getPassphrase() ); + authInfo.setUserName(server.getUsername()); + authInfo.setPassword(server.getPassword()); + authInfo.setPrivateKey(server.getPrivateKey()); + authInfo.setPassphrase(server.getPassphrase()); return authInfo; } } - } // empty one to prevent NPE @@ -269,10 +227,7 @@ public AuthenticationInfo getAuthenticationInfo( String id, Settings settings ) } @Override - public void contextualize( Context context ) - throws ContextException - { - container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); + public void contextualize(Context context) throws ContextException { + container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY); } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonUpload.java b/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonUpload.java index 50672ef..d27ccae 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonUpload.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/DefaultWagonUpload.java @@ -39,138 +39,110 @@ import org.slf4j.LoggerFactory; @Component(role = WagonUpload.class, hint = "default") -public class DefaultWagonUpload - implements WagonUpload -{ +public class DefaultWagonUpload implements WagonUpload { private static final Logger LOG = LoggerFactory.getLogger(DefaultWagonUpload.class); @Requirement private ArchiverManager archiverManager; - public void upload( Wagon wagon, FileSet fileset ) - throws WagonException - { + public void upload(Wagon wagon, FileSet fileset) throws WagonException { - FileSetManager fileSetManager = new FileSetManager( LOG, LOG.isDebugEnabled() ); + FileSetManager fileSetManager = new FileSetManager(LOG, LOG.isDebugEnabled()); - String[] files = fileSetManager.getIncludedFiles( fileset ); + String[] files = fileSetManager.getIncludedFiles(fileset); Arrays.sort(files); String url = wagon.getRepository().getUrl() + "/"; - if ( files.length == 0 ) - { - LOG.info( "Nothing to upload." ); + if (files.length == 0) { + LOG.info("Nothing to upload."); return; } - for ( String file : files ) - { - String relativeDestPath = StringUtils.replace( file, "\\", "/" ); + for (String file : files) { + String relativeDestPath = StringUtils.replace(file, "\\", "/"); - if ( !StringUtils.isBlank( fileset.getOutputDirectory() ) ) - { + if (!StringUtils.isBlank(fileset.getOutputDirectory())) { relativeDestPath = fileset.getOutputDirectory() + "/" + relativeDestPath; } - File source = new File( fileset.getDirectory(), file ); + File source = new File(fileset.getDirectory(), file); - LOG.info( "Uploading " + source + " to " + url + relativeDestPath + " ..." ); + LOG.info("Uploading " + source + " to " + url + relativeDestPath + " ..."); - wagon.put( source, relativeDestPath ); + wagon.put(source, relativeDestPath); } - } @Override - public void upload( Wagon wagon, FileSet fileset, boolean optimize ) - throws WagonException, IOException - { - if ( !optimize ) - { - upload( wagon, fileset ); + public void upload(Wagon wagon, FileSet fileset, boolean optimize) throws WagonException, IOException { + if (!optimize) { + upload(wagon, fileset); return; } - if ( !( wagon instanceof CommandExecutor ) ) - { - throw new UnsupportedProtocolException( "Wagon " + wagon.getRepository().getProtocol() - + " does not support optimize upload" ); + if (!(wagon instanceof CommandExecutor)) { + throw new UnsupportedProtocolException( + "Wagon " + wagon.getRepository().getProtocol() + " does not support optimize upload"); } - LOG.info( "Uploading " + fileset ); + LOG.info("Uploading " + fileset); File zipFile; - zipFile = File.createTempFile( "wagon", ".zip" ); + zipFile = File.createTempFile("wagon", ".zip"); - try - { - FileSetManager fileSetManager = new FileSetManager( LOG, LOG.isDebugEnabled() ); - String[] files = fileSetManager.getIncludedFiles( fileset ); + try { + FileSetManager fileSetManager = new FileSetManager(LOG, LOG.isDebugEnabled()); + String[] files = fileSetManager.getIncludedFiles(fileset); - if ( files.length == 0 ) - { - LOG.info( "Nothing to upload." ); + if (files.length == 0) { + LOG.info("Nothing to upload."); return; } - LOG.info( "Creating " + zipFile + " ..." ); - createZip( files, zipFile, fileset.getDirectory() ); + LOG.info("Creating " + zipFile + " ..."); + createZip(files, zipFile, fileset.getDirectory()); String remoteFile = zipFile.getName(); String remoteDir = fileset.getOutputDirectory(); - if ( !StringUtils.isBlank( remoteDir ) ) - { + if (!StringUtils.isBlank(remoteDir)) { remoteFile = remoteDir + "/" + remoteFile; } - LOG.info( "Uploading " + zipFile + " to " + wagon.getRepository().getUrl() + "/" + remoteFile + " ..." ); - wagon.put( zipFile, remoteFile ); + LOG.info("Uploading " + zipFile + " to " + wagon.getRepository().getUrl() + "/" + remoteFile + " ..."); + wagon.put(zipFile, remoteFile); // We use the super quiet option here as all the noise seems to kill/stall the connection String command = "unzip -o -qq -d " + remoteDir + " " + remoteFile; - if ( StringUtils.isBlank( remoteDir ) ) - { + if (StringUtils.isBlank(remoteDir)) { command = "unzip -o -qq " + remoteFile; } - try - { - LOG.info( "Remote: " + command ); - ( (CommandExecutor) wagon ).executeCommand( command ); - } - finally - { + try { + LOG.info("Remote: " + command); + ((CommandExecutor) wagon).executeCommand(command); + } finally { command = "rm -f " + remoteFile; - LOG.info( "Remote: " + command ); + LOG.info("Remote: " + command); - ( (CommandExecutor) wagon ).executeCommand( command ); + ((CommandExecutor) wagon).executeCommand(command); } - } - finally - { + } finally { zipFile.delete(); } - } - private void createZip( String[] files, File zipFile, String basedir ) - throws IOException - { - try - { - ZipArchiver archiver = (ZipArchiver) this.archiverManager.getArchiver( zipFile ); - archiver.setDestFile( zipFile ); - for ( String file : files ) - { - archiver.addFile( new File( basedir, file ), file ); + private void createZip(String[] files, File zipFile, String basedir) throws IOException { + try { + ZipArchiver archiver = (ZipArchiver) this.archiverManager.getArchiver(zipFile); + archiver.setDestFile(zipFile); + for (String file : files) { + archiver.addFile(new File(basedir, file), file); } archiver.createArchive(); - } - catch ( NoSuchArchiverException e ) - { + } catch (NoSuchArchiverException e) { // should never happen } } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/MavenRepoMerger.java b/src/main/java/org/codehaus/mojo/wagon/shared/MavenRepoMerger.java index 71310b9..fb0e456 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/MavenRepoMerger.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/MavenRepoMerger.java @@ -25,8 +25,7 @@ import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.WagonException; -public interface MavenRepoMerger -{ +public interface MavenRepoMerger { String IN_PROCESS_MARKER = ".rip"; @@ -36,6 +35,5 @@ public interface MavenRepoMerger String MAVEN_METADATA = "maven-metadata.xml"; - void merge( Wagon fromWagon, Wagon toWagon, boolean optimize, Log logger ) - throws WagonException, IOException; + void merge(Wagon fromWagon, Wagon toWagon, boolean optimize, Log logger) throws WagonException, IOException; } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/SelectorUtils.java b/src/main/java/org/codehaus/mojo/wagon/shared/SelectorUtils.java index 6d34e2f..0d25a1c 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/SelectorUtils.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/SelectorUtils.java @@ -25,22 +25,20 @@ /** * A copy of plexus-util's SelectorUtils to deal with unix file separator only. */ -public final class SelectorUtils -{ +public final class SelectorUtils { /** * Tests whether or not a given path matches the start of a given pattern up to the first "**". *

* This is not a general purpose test and should only be used if you can live with false positives. For example, * pattern=**\a and str=b will yield true. - * + * * @param pattern The pattern to match against. Must not be null. * @param str The path to match, as a String. Must not be null. * @return whether or not a given path matches the start of a given pattern up to the first "**". */ - public static boolean matchPatternStart( String pattern, String str ) - { - return matchPatternStart( pattern, str, true ); + public static boolean matchPatternStart(String pattern, String str) { + return matchPatternStart(pattern, str, true); } /** @@ -48,25 +46,23 @@ public static boolean matchPatternStart( String pattern, String str ) *

* This is not a general purpose test and should only be used if you can live with false positives. For example, * pattern=**\a and str=b will yield true. - * + * * @param pattern The pattern to match against. Must not be null. * @param str The path to match, as a String. Must not be null. * @param isCaseSensitive Whether or not matching should be performed case sensitively. * @return whether or not a given path matches the start of a given pattern up to the first "**". */ - public static boolean matchPatternStart( String pattern, String str, boolean isCaseSensitive ) - { + public static boolean matchPatternStart(String pattern, String str, boolean isCaseSensitive) { // When str starts with a separator, pattern has to start with a // separator. // When pattern starts with a separator, str has to start with a // separator. - if ( str.startsWith( "/" ) != pattern.startsWith( "/" ) ) - { + if (str.startsWith("/") != pattern.startsWith("/")) { return false; } - Vector patDirs = tokenizePath( pattern ); - Vector strDirs = tokenizePath( str ); + Vector patDirs = tokenizePath(pattern); + Vector strDirs = tokenizePath(str); int patIdxStart = 0; int patIdxEnd = patDirs.size() - 1; @@ -74,33 +70,25 @@ public static boolean matchPatternStart( String pattern, String str, boolean isC int strIdxEnd = strDirs.size() - 1; // up to first '**' - while ( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) - { - String patDir = (String) patDirs.elementAt( patIdxStart ); - if ( patDir.equals( "**" ) ) - { + while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { + String patDir = (String) patDirs.elementAt(patIdxStart); + if (patDir.equals("**")) { break; } - if ( !match( patDir, (String) strDirs.elementAt( strIdxStart ), isCaseSensitive ) ) - { + if (!match(patDir, (String) strDirs.elementAt(strIdxStart), isCaseSensitive)) { return false; } patIdxStart++; strIdxStart++; } - if ( strIdxStart > strIdxEnd ) - { + if (strIdxStart > strIdxEnd) { // String is exhausted return true; - } - else if ( patIdxStart > patIdxEnd ) - { + } else if (patIdxStart > patIdxEnd) { // String not exhausted, but pattern is. Failure. return false; - } - else - { + } else { // pattern now holds ** while string is not exhausted // this will generate false positives but we can live with that. return true; @@ -109,37 +97,34 @@ else if ( patIdxStart > patIdxEnd ) /** * Tests whether or not a given path matches a given pattern. - * + * * @param pattern The pattern to match against. Must not be null. * @param str The path to match, as a String. Must not be null. * @return true if the pattern matches against the string, or false otherwise. */ - public static boolean matchPath( String pattern, String str ) - { - return matchPath( pattern, str, true ); + public static boolean matchPath(String pattern, String str) { + return matchPath(pattern, str, true); } /** * Tests whether or not a given path matches a given pattern. - * + * * @param pattern The pattern to match against. Must not be null. * @param str The path to match, as a String. Must not be null. * @param isCaseSensitive Whether or not matching should be performed case sensitively. * @return true if the pattern matches against the string, or false otherwise. */ - public static boolean matchPath( String pattern, String str, boolean isCaseSensitive ) - { + public static boolean matchPath(String pattern, String str, boolean isCaseSensitive) { // When str starts with a separator, pattern has to start with a // separator. // When pattern starts with a separator, str has to start with a // separator. - if ( str.startsWith( "/" ) != pattern.startsWith( "/" ) ) - { + if (str.startsWith("/") != pattern.startsWith("/")) { return false; } - Vector patDirs = tokenizePath( pattern ); - Vector strDirs = tokenizePath( str ); + Vector patDirs = tokenizePath(pattern); + Vector strDirs = tokenizePath(str); int patIdxStart = 0; int patIdxEnd = patDirs.size() - 1; @@ -147,99 +132,78 @@ public static boolean matchPath( String pattern, String str, boolean isCaseSensi int strIdxEnd = strDirs.size() - 1; // up to first '**' - while ( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) - { - String patDir = (String) patDirs.elementAt( patIdxStart ); - if ( patDir.equals( "**" ) ) - { + while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { + String patDir = (String) patDirs.elementAt(patIdxStart); + if (patDir.equals("**")) { break; } - if ( !match( patDir, (String) strDirs.elementAt( strIdxStart ), isCaseSensitive ) ) - { + if (!match(patDir, (String) strDirs.elementAt(strIdxStart), isCaseSensitive)) { return false; } patIdxStart++; strIdxStart++; } - if ( strIdxStart > strIdxEnd ) - { + if (strIdxStart > strIdxEnd) { // String is exhausted - for ( int i = patIdxStart; i <= patIdxEnd; i++ ) - { - if ( !patDirs.elementAt( i ).equals( "**" ) ) - { + for (int i = patIdxStart; i <= patIdxEnd; i++) { + if (!patDirs.elementAt(i).equals("**")) { return false; } } return true; - } - else - { - if ( patIdxStart > patIdxEnd ) - { + } else { + if (patIdxStart > patIdxEnd) { // String not exhausted, but pattern is. Failure. return false; } } // up to last '**' - while ( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) - { - String patDir = (String) patDirs.elementAt( patIdxEnd ); - if ( patDir.equals( "**" ) ) - { + while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { + String patDir = (String) patDirs.elementAt(patIdxEnd); + if (patDir.equals("**")) { break; } - if ( !match( patDir, (String) strDirs.elementAt( strIdxEnd ), isCaseSensitive ) ) - { + if (!match(patDir, (String) strDirs.elementAt(strIdxEnd), isCaseSensitive)) { return false; } patIdxEnd--; strIdxEnd--; } - if ( strIdxStart > strIdxEnd ) - { + if (strIdxStart > strIdxEnd) { // String is exhausted - for ( int i = patIdxStart; i <= patIdxEnd; i++ ) - { - if ( !patDirs.elementAt( i ).equals( "**" ) ) - { + for (int i = patIdxStart; i <= patIdxEnd; i++) { + if (!patDirs.elementAt(i).equals("**")) { return false; } } return true; } - while ( patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd ) - { + while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { int patIdxTmp = -1; - for ( int i = patIdxStart + 1; i <= patIdxEnd; i++ ) - { - if ( patDirs.elementAt( i ).equals( "**" ) ) - { + for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { + if (patDirs.elementAt(i).equals("**")) { patIdxTmp = i; break; } } - if ( patIdxTmp == patIdxStart + 1 ) - { + if (patIdxTmp == patIdxStart + 1) { // '**/**' situation, so skip one patIdxStart++; continue; } // Find the pattern between padIdxStart & padIdxTmp in str between // strIdxStart & strIdxEnd - int patLength = ( patIdxTmp - patIdxStart - 1 ); - int strLength = ( strIdxEnd - strIdxStart + 1 ); + int patLength = (patIdxTmp - patIdxStart - 1); + int strLength = (strIdxEnd - strIdxStart + 1); int foundIdx = -1; - strLoop: for ( int i = 0; i <= strLength - patLength; i++ ) - { - for ( int j = 0; j < patLength; j++ ) - { - String subPat = (String) patDirs.elementAt( patIdxStart + j + 1 ); - String subStr = (String) strDirs.elementAt( strIdxStart + i + j ); - if ( !match( subPat, subStr, isCaseSensitive ) ) - { + strLoop: + for (int i = 0; i <= strLength - patLength; i++) { + for (int j = 0; j < patLength; j++) { + String subPat = (String) patDirs.elementAt(patIdxStart + j + 1); + String subStr = (String) strDirs.elementAt(strIdxStart + i + j); + if (!match(subPat, subStr, isCaseSensitive)) { continue strLoop; } } @@ -248,8 +212,7 @@ public static boolean matchPath( String pattern, String str, boolean isCaseSensi break; } - if ( foundIdx == -1 ) - { + if (foundIdx == -1) { return false; } @@ -257,10 +220,8 @@ public static boolean matchPath( String pattern, String str, boolean isCaseSensi strIdxStart = foundIdx + patLength; } - for ( int i = patIdxStart; i <= patIdxEnd; i++ ) - { - if ( !patDirs.elementAt( i ).equals( "**" ) ) - { + for (int i = patIdxStart; i <= patIdxEnd; i++) { + if (!patDirs.elementAt(i).equals("**")) { return false; } } @@ -272,28 +233,26 @@ public static boolean matchPath( String pattern, String str, boolean isCaseSensi * Tests whether or not a string matches against a pattern. The pattern may contain two special characters:
* '*' means zero or more characters
* '?' means one and only one character - * + * * @param pattern The pattern to match against. Must not be null. * @param str The string which must be matched against the pattern. Must not be null. * @return true if the string matches against the pattern, or false otherwise. */ - public static boolean match( String pattern, String str ) - { - return match( pattern, str, true ); + public static boolean match(String pattern, String str) { + return match(pattern, str, true); } /** * Tests whether or not a string matches against a pattern. The pattern may contain two special characters:
* '*' means zero or more characters
* '?' means one and only one character - * + * * @param pattern The pattern to match against. Must not be null. * @param str The string which must be matched against the pattern. Must not be null. * @param isCaseSensitive Whether or not matching should be performed case sensitively. * @return true if the string matches against the pattern, or false otherwise. */ - public static boolean match( String pattern, String str, boolean isCaseSensitive ) - { + public static boolean match(String pattern, String str, boolean isCaseSensitive) { char[] patArr = pattern.toCharArray(); char[] strArr = str.toCharArray(); int patIdxStart = 0; @@ -303,56 +262,44 @@ public static boolean match( String pattern, String str, boolean isCaseSensitive char ch; boolean containsStar = false; - for ( char aPatArr : patArr ) - { - if ( aPatArr == '*' ) - { + for (char aPatArr : patArr) { + if (aPatArr == '*') { containsStar = true; break; } } - if ( !containsStar ) - { + if (!containsStar) { // No '*'s, so we make a shortcut - if ( patIdxEnd != strIdxEnd ) - { + if (patIdxEnd != strIdxEnd) { return false; // Pattern and string do not have the same size } - for ( int i = 0; i <= patIdxEnd; i++ ) - { + for (int i = 0; i <= patIdxEnd; i++) { ch = patArr[i]; - if ( ch != '?' && !equals( ch, strArr[i], isCaseSensitive ) ) - { + if (ch != '?' && !equals(ch, strArr[i], isCaseSensitive)) { return false; // Character mismatch } } return true; // String matches against pattern } - if ( patIdxEnd == 0 ) - { + if (patIdxEnd == 0) { return true; // Pattern contains only '*', which matches anything } // Process characters before first star - while ( ( ch = patArr[patIdxStart] ) != '*' && strIdxStart <= strIdxEnd ) - { - if ( ch != '?' && !equals( ch, strArr[strIdxStart], isCaseSensitive ) ) - { + while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) { + if (ch != '?' && !equals(ch, strArr[strIdxStart], isCaseSensitive)) { return false; // Character mismatch } patIdxStart++; strIdxStart++; } - if ( strIdxStart > strIdxEnd ) - { + if (strIdxStart > strIdxEnd) { // All characters in the string are used. Check if only '*'s are // left in the pattern. If so, we succeeded. Otherwise failure. - for ( int i = patIdxStart; i <= patIdxEnd; i++ ) - { - if ( patArr[i] != '*' ) - { + for (int i = patIdxStart; i <= patIdxEnd; i++) { + if (patArr[i] != '*') { return false; } } @@ -360,23 +307,18 @@ public static boolean match( String pattern, String str, boolean isCaseSensitive } // Process characters after last star - while ( ( ch = patArr[patIdxEnd] ) != '*' && strIdxStart <= strIdxEnd ) - { - if ( ch != '?' && !equals( ch, strArr[strIdxEnd], isCaseSensitive ) ) - { + while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) { + if (ch != '?' && !equals(ch, strArr[strIdxEnd], isCaseSensitive)) { return false; // Character mismatch } patIdxEnd--; strIdxEnd--; } - if ( strIdxStart > strIdxEnd ) - { + if (strIdxStart > strIdxEnd) { // All characters in the string are used. Check if only '*'s are // left in the pattern. If so, we succeeded. Otherwise failure. - for ( int i = patIdxStart; i <= patIdxEnd; i++ ) - { - if ( patArr[i] != '*' ) - { + for (int i = patIdxStart; i <= patIdxEnd; i++) { + if (patArr[i] != '*') { return false; } } @@ -385,35 +327,29 @@ public static boolean match( String pattern, String str, boolean isCaseSensitive // process pattern between stars. padIdxStart and patIdxEnd point // always to a '*'. - while ( patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd ) - { + while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { int patIdxTmp = -1; - for ( int i = patIdxStart + 1; i <= patIdxEnd; i++ ) - { - if ( patArr[i] == '*' ) - { + for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { + if (patArr[i] == '*') { patIdxTmp = i; break; } } - if ( patIdxTmp == patIdxStart + 1 ) - { + if (patIdxTmp == patIdxStart + 1) { // Two stars next to each other, skip the first one. patIdxStart++; continue; } // Find the pattern between padIdxStart & padIdxTmp in str between // strIdxStart & strIdxEnd - int patLength = ( patIdxTmp - patIdxStart - 1 ); - int strLength = ( strIdxEnd - strIdxStart + 1 ); + int patLength = (patIdxTmp - patIdxStart - 1); + int strLength = (strIdxEnd - strIdxStart + 1); int foundIdx = -1; - strLoop: for ( int i = 0; i <= strLength - patLength; i++ ) - { - for ( int j = 0; j < patLength; j++ ) - { + strLoop: + for (int i = 0; i <= strLength - patLength; i++) { + for (int j = 0; j < patLength; j++) { ch = patArr[patIdxStart + j + 1]; - if ( ch != '?' && !equals( ch, strArr[strIdxStart + i + j], isCaseSensitive ) ) - { + if (ch != '?' && !equals(ch, strArr[strIdxStart + i + j], isCaseSensitive)) { continue strLoop; } } @@ -422,8 +358,7 @@ public static boolean match( String pattern, String str, boolean isCaseSensitive break; } - if ( foundIdx == -1 ) - { + if (foundIdx == -1) { return false; } @@ -433,10 +368,8 @@ public static boolean match( String pattern, String str, boolean isCaseSensitive // All characters in the string are used. Check if only '*'s are left // in the pattern. If so, we succeeded. Otherwise failure. - for ( int i = patIdxStart; i <= patIdxEnd; i++ ) - { - if ( patArr[i] != '*' ) - { + for (int i = patIdxStart; i <= patIdxEnd; i++) { + if (patArr[i] != '*') { return false; } } @@ -446,18 +379,14 @@ public static boolean match( String pattern, String str, boolean isCaseSensitive /** * Tests whether two characters are equal. */ - private static boolean equals( char c1, char c2, boolean isCaseSensitive ) - { - if ( c1 == c2 ) - { + private static boolean equals(char c1, char c2, boolean isCaseSensitive) { + if (c1 == c2) { return true; } - if ( !isCaseSensitive ) - { + if (!isCaseSensitive) { // NOTE: Try both upper case and lower case as done by String.equalsIgnoreCase() - if ( Character.toUpperCase( c1 ) == Character.toUpperCase( c2 ) - || Character.toLowerCase( c1 ) == Character.toLowerCase( c2 ) ) - { + if (Character.toUpperCase(c1) == Character.toUpperCase(c2) + || Character.toLowerCase(c1) == Character.toLowerCase(c2)) { return true; } } @@ -466,19 +395,16 @@ private static boolean equals( char c1, char c2, boolean isCaseSensitive ) /** * Breaks a path up into a Vector of path elements, tokenizing on File.separator. - * + * * @param path Path to tokenize. Must not be null. * @return a Vector of path elements from the tokenized path */ - public static Vector tokenizePath( String path ) - { + public static Vector tokenizePath(String path) { Vector ret = new Vector(); - StringTokenizer st = new StringTokenizer( path, "/" ); - while ( st.hasMoreTokens() ) - { - ret.addElement( st.nextToken() ); + StringTokenizer st = new StringTokenizer(path, "/"); + while (st.hasMoreTokens()) { + ret.addElement(st.nextToken()); } return ret; } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/WagonCopy.java b/src/main/java/org/codehaus/mojo/wagon/shared/WagonCopy.java index 6e70961..75dc6c5 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/WagonCopy.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/WagonCopy.java @@ -28,13 +28,12 @@ /** * */ -public interface WagonCopy -{ +public interface WagonCopy { /** * Transfer files between 2 Wagon URLs. If download directory is not given in the fileset a temporary one will be * created. - * + * * @param fromWagon - source Wagon * @param fileset - file set to copy * @param toWagon - target Wagon @@ -43,7 +42,6 @@ public interface WagonCopy * @throws WagonException if any wagon error * @throws IOException if any io error */ - void copy( Wagon fromWagon, WagonFileSet fileset, Wagon toWagon, boolean optimize, Log logger ) - throws WagonException, IOException; - + void copy(Wagon fromWagon, WagonFileSet fileset, Wagon toWagon, boolean optimize, Log logger) + throws WagonException, IOException; } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/WagonDirectoryScanner.java b/src/main/java/org/codehaus/mojo/wagon/shared/WagonDirectoryScanner.java index fa67927..7ffdd12 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/WagonDirectoryScanner.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/WagonDirectoryScanner.java @@ -28,8 +28,7 @@ import org.apache.maven.wagon.WagonException; import org.codehaus.plexus.util.StringUtils; -public class WagonDirectoryScanner -{ +public class WagonDirectoryScanner { /** * Patterns which should be excluded by default. * @@ -74,21 +73,15 @@ public class WagonDirectoryScanner * @param includes A list of include patterns. May be null, indicating that all files should be * included. If a non-null list is given, all elements must be non-null. */ - public void setIncludes( String[] includes ) - { - if ( includes == null ) - { + public void setIncludes(String[] includes) { + if (includes == null) { this.includes = null; - } - else - { + } else { this.includes = new String[includes.length]; - for ( int i = 0; i < includes.length; i++ ) - { + for (int i = 0; i < includes.length; i++) { String pattern = includes[i].trim(); - if ( pattern.endsWith( "/" ) ) - { + if (pattern.endsWith("/")) { pattern += "**"; } this.includes[i] = pattern; @@ -104,21 +97,15 @@ public void setIncludes( String[] includes ) * @param excludes A list of exclude patterns. May be null, indicating that no files should be * excluded. If a non-null list is given, all elements must be non-null. */ - public void setExcludes( String[] excludes ) - { - if ( excludes == null ) - { + public void setExcludes(String[] excludes) { + if (excludes == null) { this.excludes = null; - } - else - { + } else { this.excludes = new String[excludes.length]; - for ( int i = 0; i < excludes.length; i++ ) - { + for (int i = 0; i < excludes.length; i++) { String pattern = excludes[i].trim(); - if ( pattern.endsWith( "/" ) ) - { + if (pattern.endsWith("/")) { pattern += "**"; } this.excludes[i] = pattern; @@ -133,12 +120,9 @@ public void setExcludes( String[] excludes ) * @return true when the name matches against at least one include pattern, or false * otherwise. */ - private boolean isIncluded( String name ) - { - for ( String include : includes ) - { - if ( matchPath( include, name, isCaseSensitive ) ) - { + private boolean isIncluded(String name) { + for (String include : includes) { + if (matchPath(include, name, isCaseSensitive)) { return true; } } @@ -152,12 +136,9 @@ private boolean isIncluded( String name ) * @return true when the name matches against at least one exclude pattern, or false * otherwise. */ - protected boolean isExcluded( String name ) - { - for ( String exclude : excludes ) - { - if ( matchPath( exclude, name, isCaseSensitive ) ) - { + protected boolean isExcluded(String name) { + for (String exclude : excludes) { + if (matchPath(exclude, name, isCaseSensitive)) { return true; } } @@ -171,12 +152,9 @@ protected boolean isExcluded( String name ) * @return true when the name matches against the start of at least one include pattern, or * false otherwise. */ - protected boolean couldHoldIncluded( String name ) - { - for ( String include : includes ) - { - if ( matchPatternStart( include, name, isCaseSensitive ) ) - { + protected boolean couldHoldIncluded(String name) { + for (String include : includes) { + if (matchPatternStart(include, name, isCaseSensitive)) { return true; } } @@ -194,9 +172,8 @@ protected boolean couldHoldIncluded( String name ) * @param isCaseSensitive Whether or not matching should be performed case sensitively. * @return whether or not a given path matches the start of a given pattern up to the first "**". */ - protected static boolean matchPatternStart( String pattern, String str, boolean isCaseSensitive ) - { - return SelectorUtils.matchPatternStart( pattern, str, isCaseSensitive ); + protected static boolean matchPatternStart(String pattern, String str, boolean isCaseSensitive) { + return SelectorUtils.matchPatternStart(pattern, str, isCaseSensitive); } /** @@ -207,57 +184,47 @@ protected static boolean matchPatternStart( String pattern, String str, boolean * @param isCaseSensitive Whether or not matching should be performed case sensitively. * @return true if the pattern matches against the string, or false otherwise. */ - private static boolean matchPath( String pattern, String str, boolean isCaseSensitive ) - { - return SelectorUtils.matchPath( pattern, str, isCaseSensitive ); + private static boolean matchPath(String pattern, String str, boolean isCaseSensitive) { + return SelectorUtils.matchPath(pattern, str, isCaseSensitive); } - public void scan() - throws WagonException - { - if ( wagon == null ) - { - throw new IllegalStateException( "No wagon set" ); + public void scan() throws WagonException { + if (wagon == null) { + throw new IllegalStateException("No wagon set"); } - if ( StringUtils.isBlank( directory ) ) - { + if (StringUtils.isBlank(directory)) { directory = ""; } - if ( includes == null ) - { + if (includes == null) { // No includes supplied, so set it to 'matches all' includes = new String[1]; includes[0] = "**"; } - if ( excludes == null ) - { + if (excludes == null) { excludes = new String[0]; } filesIncluded = new ArrayList(); - scandir( directory, "" ); - - Collections.sort( filesIncluded ); + scandir(directory, ""); + Collections.sort(filesIncluded); } /** * Adds default exclusions to the current exclusions set. */ - public void addDefaultExcludes() - { + public void addDefaultExcludes() { int excludesLength = excludes == null ? 0 : excludes.length; String[] newExcludes; newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length]; - if ( excludesLength > 0 ) - { - System.arraycopy( excludes, 0, newExcludes, 0, excludesLength ); + if (excludesLength > 0) { + System.arraycopy(excludes, 0, newExcludes, 0, excludesLength); } - System.arraycopy( DEFAULTEXCLUDES, 0, newExcludes, excludesLength, DEFAULTEXCLUDES.length ); + System.arraycopy(DEFAULTEXCLUDES, 0, newExcludes, excludesLength, DEFAULTEXCLUDES.length); excludes = newExcludes; } @@ -269,10 +236,8 @@ public void addDefaultExcludes() * @param fileName supposed file name * @return true if it seems like a bad idea. */ - private boolean isRidiculousFile( String fileName ) - { - return fileName.endsWith( "." ) || fileName.contains( "*" ) || fileName.startsWith( "?" ) - || fileName.startsWith( "#" ); + private boolean isRidiculousFile(String fileName) { + return fileName.endsWith(".") || fileName.contains("*") || fileName.startsWith("?") || fileName.startsWith("#"); } // ////////////////////////////////////////////////////////////////////////////////// @@ -283,133 +248,100 @@ private boolean isRidiculousFile( String fileName ) * @throws WagonException if any wagon error * @see #filesIncluded */ - private void scandir( String dir, String vpath ) - throws WagonException - { - logger.debug( "scandir: dir: " + dir + " vpath: " + vpath ); - List files = wagon.getFileList( dir ); - - for ( Object file1 : files ) - { + private void scandir(String dir, String vpath) throws WagonException { + logger.debug("scandir: dir: " + dir + " vpath: " + vpath); + List files = wagon.getFileList(dir); + + for (Object file1 : files) { String fileName = (String) file1; - if ( isRidiculousFile( fileName ) ) // including ".." + if (isRidiculousFile(fileName)) // including ".." { continue; } String file = fileName; - if ( !StringUtils.isBlank( dir ) ) - { - if ( dir.endsWith( "/" ) ) - { + if (!StringUtils.isBlank(dir)) { + if (dir.endsWith("/")) { file = dir + fileName; - } - else - { + } else { file = dir + "/" + fileName; } } String name = vpath + fileName; - if ( this.isDirectory( file ) ) - { + if (this.isDirectory(file)) { - if ( !name.endsWith( "/" ) ) - { + if (!name.endsWith("/")) { name += "/"; } - if ( isIncluded( name ) ) - { - if ( !isExcluded( name ) ) - { - scandir( file, name ); - } - else - { - if ( couldHoldIncluded( name ) ) - { - scandir( file, name ); + if (isIncluded(name)) { + if (!isExcluded(name)) { + scandir(file, name); + } else { + if (couldHoldIncluded(name)) { + scandir(file, name); } } - } - else - { - if ( couldHoldIncluded( name ) ) - { - scandir( file, name ); + } else { + if (couldHoldIncluded(name)) { + scandir(file, name); } } - } - else - { + } else { - if ( isIncluded( name ) ) - { - if ( !isExcluded( name ) ) - { - filesIncluded.add( name ); + if (isIncluded(name)) { + if (!isExcluded(name)) { + filesIncluded.add(name); } } } } } - private boolean isDirectory( String existedRemotePath ) { - if ( existedRemotePath.endsWith( "/" ) ) - { + private boolean isDirectory(String existedRemotePath) { + if (existedRemotePath.endsWith("/")) { return true; } - return canListPath( existedRemotePath + "/" ); + return canListPath(existedRemotePath + "/"); } - private boolean canListPath( String remotePath ) - { - try - { - List resources = wagon.getFileList( remotePath ); + private boolean canListPath(String remotePath) { + try { + List resources = wagon.getFileList(remotePath); return resources != null && !resources.isEmpty(); - } - catch ( WagonException e ) - { + } catch (WagonException e) { return false; } } // /////////////////////////////////////////////////////////////////////////////// - public List getFilesIncluded() - { + public List getFilesIncluded() { return filesIncluded; } - public void setWagon( Wagon wagon ) - { + public void setWagon(Wagon wagon) { this.wagon = wagon; } - public void setCaseSensitive( boolean isCaseSensitive ) - { + public void setCaseSensitive(boolean isCaseSensitive) { this.isCaseSensitive = isCaseSensitive; } - public void setDirectory( String basePath ) - { + public void setDirectory(String basePath) { this.directory = basePath; } - public Log getLogger() - { + public Log getLogger() { return logger; } - public void setLogger( Log logger ) - { + public void setLogger(Log logger) { this.logger = logger; } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/WagonDownload.java b/src/main/java/org/codehaus/mojo/wagon/shared/WagonDownload.java index e174e6c..502bda9 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/WagonDownload.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/WagonDownload.java @@ -28,8 +28,7 @@ /** * */ -public interface WagonDownload -{ +public interface WagonDownload { /** * @param wagon - a Wagon instance @@ -38,8 +37,7 @@ public interface WagonDownload * @return a list of files at the remote host relative to RemoteFileSet's directory * @throws WagonException if any wagon error */ - List getFileList( Wagon wagon, WagonFileSet fileSet, Log logger ) - throws WagonException; + List getFileList(Wagon wagon, WagonFileSet fileSet, Log logger) throws WagonException; /** * @param wagon - a Wagon instance @@ -47,8 +45,7 @@ List getFileList( Wagon wagon, WagonFileSet fileSet, Log logger ) * @param logger - logger used * @throws WagonException if any wagon error */ - void download( Wagon wagon, WagonFileSet remoteFileSet, Log logger ) - throws WagonException; + void download(Wagon wagon, WagonFileSet remoteFileSet, Log logger) throws WagonException; /** * @param wagon - a Wagon instance @@ -56,7 +53,5 @@ void download( Wagon wagon, WagonFileSet remoteFileSet, Log logger ) * @throws WagonException if any wagon error * @return {@code true} if found, {@code false} otherwise */ - boolean exists( Wagon wagon, String resource ) - throws WagonException; - + boolean exists(Wagon wagon, String resource) throws WagonException; } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/WagonFactory.java b/src/main/java/org/codehaus/mojo/wagon/shared/WagonFactory.java index 558b0cd..3cbad14 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/WagonFactory.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/WagonFactory.java @@ -4,8 +4,6 @@ import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.WagonException; -public interface WagonFactory -{ - Wagon create( String url, String serverId, Settings settings ) - throws WagonException; +public interface WagonFactory { + Wagon create(String url, String serverId, Settings settings) throws WagonException; } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/WagonFileSet.java b/src/main/java/org/codehaus/mojo/wagon/shared/WagonFileSet.java index c96df5f..d1a723a 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/WagonFileSet.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/WagonFileSet.java @@ -25,12 +25,10 @@ /** * Wagon configuration to scan for a set of remote files. */ -public class WagonFileSet -{ +public class WagonFileSet { /** * Path after the url, this is where the scan starts */ - private String directory = ""; /** @@ -65,53 +63,43 @@ public class WagonFileSet // //////////////////////////////////////////////////////////////////////////////////// - public String getDirectory() - { + public String getDirectory() { return directory; } - public void setDirectory( String remotePath ) - { + public void setDirectory(String remotePath) { this.directory = remotePath; } - public File getDownloadDirectory() - { + public File getDownloadDirectory() { return downloadDirectory; } - public void setDownloadDirectory( File downloadDirectory ) - { + public void setDownloadDirectory(File downloadDirectory) { this.downloadDirectory = downloadDirectory; } - public String[] getExcludes() - { + public String[] getExcludes() { return excludes; } - public void setExcludes( String[] excludes ) - { + public void setExcludes(String[] excludes) { this.excludes = excludes; } - public String[] getIncludes() - { + public String[] getIncludes() { return includes; } - public void setIncludes( String[] includes ) - { + public void setIncludes(String[] includes) { this.includes = includes; } - public boolean isCaseSensitive() - { + public boolean isCaseSensitive() { return caseSensitive; } - public void setCaseSensitive( boolean caseSensitive ) - { + public void setCaseSensitive(boolean caseSensitive) { this.caseSensitive = caseSensitive; } @@ -119,35 +107,30 @@ public void setCaseSensitive( boolean caseSensitive ) * Retrieves the included and excluded files from this file-set's directory. Specifically, * "file-set: [directory] (included: * [included files], excluded: [excluded files])" - * + * * @return The included and excluded files from this file-set's directory. Specifically, * "file-set: [directory] (included: * [included files], excluded: [excluded files])" * @see java.lang.Object#toString() */ - public String toString() - { - return "file-set: " + getDirectory() + " (included: " + Arrays.toString( getIncludes() ) + ", excluded: " + Arrays.toString( getExcludes() ) + ")"; + public String toString() { + return "file-set: " + getDirectory() + " (included: " + Arrays.toString(getIncludes()) + ", excluded: " + + Arrays.toString(getExcludes()) + ")"; } - public boolean isUseDefaultExcludes() - { + public boolean isUseDefaultExcludes() { return useDefaultExcludes; } - public void setUseDefaultExcludes( boolean useDefaultExcludes ) - { + public void setUseDefaultExcludes(boolean useDefaultExcludes) { this.useDefaultExcludes = useDefaultExcludes; } - public String getOutputDirectory() - { + public String getOutputDirectory() { return outputDirectory; } - public void setOutputDirectory( String outputDirectory ) - { + public void setOutputDirectory(String outputDirectory) { this.outputDirectory = outputDirectory; } - } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/WagonUpload.java b/src/main/java/org/codehaus/mojo/wagon/shared/WagonUpload.java index bf9b752..51f434c 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/WagonUpload.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/WagonUpload.java @@ -28,18 +28,16 @@ /** * */ -public interface WagonUpload -{ +public interface WagonUpload { /** * Upload a set of files via FileSet interface to a remote repository via Wagon - * + * * @param wagon - a Wagon instance * @param fileset file set to upload * @param optimize locally compressed and uncompress at the remote site if scp is use * @throws WagonException if nay wagon exception * @throws IOException if any io exception */ - void upload( Wagon wagon, FileSet fileset, boolean optimize ) - throws WagonException, IOException; + void upload(Wagon wagon, FileSet fileset, boolean optimize) throws WagonException, IOException; } diff --git a/src/main/java/org/codehaus/mojo/wagon/shared/WagonUtils.java b/src/main/java/org/codehaus/mojo/wagon/shared/WagonUtils.java index fd45dc7..5309131 100644 --- a/src/main/java/org/codehaus/mojo/wagon/shared/WagonUtils.java +++ b/src/main/java/org/codehaus/mojo/wagon/shared/WagonUtils.java @@ -2,32 +2,25 @@ import org.codehaus.plexus.util.StringUtils; -public class WagonUtils -{ +public class WagonUtils { - public static WagonFileSet getWagonFileSet( String fromDir, String includes, String excludes, - boolean isCaseSensitive, String toDir ) - { + public static WagonFileSet getWagonFileSet( + String fromDir, String includes, String excludes, boolean isCaseSensitive, String toDir) { WagonFileSet fileSet = new WagonFileSet(); - fileSet.setDirectory( fromDir ); + fileSet.setDirectory(fromDir); - if ( !StringUtils.isBlank( includes ) ) - { - fileSet.setIncludes( StringUtils.split( includes, "," ) ); + if (!StringUtils.isBlank(includes)) { + fileSet.setIncludes(StringUtils.split(includes, ",")); } - if ( !StringUtils.isBlank( excludes ) ) - { - fileSet.setExcludes( StringUtils.split( excludes, "," ) ); + if (!StringUtils.isBlank(excludes)) { + fileSet.setExcludes(StringUtils.split(excludes, ",")); } - fileSet.setCaseSensitive( isCaseSensitive ); + fileSet.setCaseSensitive(isCaseSensitive); - fileSet.setOutputDirectory( toDir ); + fileSet.setOutputDirectory(toDir); return fileSet; - } - - } diff --git a/src/test/java/org/codehaus/mojo/wagon/AbstractJettyIT.java b/src/test/java/org/codehaus/mojo/wagon/AbstractJettyIT.java index 8130640..bc31f1b 100644 --- a/src/test/java/org/codehaus/mojo/wagon/AbstractJettyIT.java +++ b/src/test/java/org/codehaus/mojo/wagon/AbstractJettyIT.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.nio.file.Path; + import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; @@ -29,14 +30,13 @@ public void runJetty() throws Exception { resource_handler.setResourceBase(getDirectoryToServe().toString()); HandlerList handlers = new HandlerList(); - handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() }); + handlers.setHandlers(new Handler[] {resource_handler, new DefaultHandler()}); server.setHandler(handlers); server.start(); this.port = connector.getLocalPort(); } - @After public void tearDown() throws Exception { server.stop(); @@ -47,5 +47,4 @@ protected int getServerPort() { } protected abstract Path getDirectoryToServe() throws IOException; - } diff --git a/src/test/java/org/codehaus/mojo/wagon/Wagon334MojoHttpIT.java b/src/test/java/org/codehaus/mojo/wagon/Wagon334MojoHttpIT.java index 091b885..d4183b5 100644 --- a/src/test/java/org/codehaus/mojo/wagon/Wagon334MojoHttpIT.java +++ b/src/test/java/org/codehaus/mojo/wagon/Wagon334MojoHttpIT.java @@ -1,14 +1,8 @@ package org.codehaus.mojo.wagon; import java.io.File; - import java.io.IOException; import java.nio.file.Path; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; import io.takari.maven.testing.TestResources; import io.takari.maven.testing.executor.MavenExecution; @@ -17,46 +11,49 @@ import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder; import io.takari.maven.testing.executor.MavenVersions; import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; -@RunWith( MavenJUnitTestRunner.class ) -@MavenVersions( { "3.6.3" } ) -public class Wagon334MojoHttpIT extends AbstractJettyIT -{ +@RunWith(MavenJUnitTestRunner.class) +@MavenVersions({"3.6.3"}) +public class Wagon334MojoHttpIT extends AbstractJettyIT { @Rule public final TestResources resources = new TestResources(); private final MavenRuntimeBuilder mavenBuilder; public MavenRuntime maven; - public Wagon334MojoHttpIT(MavenRuntimeBuilder builder ) { - this.mavenBuilder = builder.withCliOptions( "-B" ); + public Wagon334MojoHttpIT(MavenRuntimeBuilder builder) { + this.mavenBuilder = builder.withCliOptions("-B"); } @Before public void setPort() throws Exception { - this.maven = this.mavenBuilder.withCliOptions( "-Dserver.port=" + getServerPort() ).build(); + this.maven = this.mavenBuilder + .withCliOptions("-Dserver.port=" + getServerPort()) + .build(); } @Test - public void testDownload() - throws Exception - { + public void testDownload() throws Exception { // issue: https://github.com/mojohaus/wagon-maven-plugin/issues/39 - File projDir = resources.getBasedir( "http-download-02" ); - MavenExecution mavenExec = maven.forProject( projDir ); + File projDir = resources.getBasedir("http-download-02"); + MavenExecution mavenExec = maven.forProject(projDir); - MavenExecutionResult result = mavenExec.execute( "clean", "verify" ); + MavenExecutionResult result = mavenExec.execute("clean", "verify"); result.assertErrorFreeLog(); File downloadDir = new File(result.getBasedir(), "target/it/http-download/"); - Assert.assertTrue( new File(downloadDir, "commons-dbutils-1.2-bin.tar.gz.asc" ).exists() ); - Assert.assertTrue( new File(downloadDir, "commons-dbutils-1.2-bin.tar.gz.asc.md5" ).exists() ); - Assert.assertTrue( new File(downloadDir, "commons-dbutils-1.2-bin.tar.gz.asc.sha1" ).exists() ); + Assert.assertTrue(new File(downloadDir, "commons-dbutils-1.2-bin.tar.gz.asc").exists()); + Assert.assertTrue(new File(downloadDir, "commons-dbutils-1.2-bin.tar.gz.asc.md5").exists()); + Assert.assertTrue(new File(downloadDir, "commons-dbutils-1.2-bin.tar.gz.asc.sha1").exists()); } @Override protected Path getDirectoryToServe() throws IOException { - return resources.getBasedir("http-download-02").toPath() - .resolve("files"); + return resources.getBasedir("http-download-02").toPath().resolve("files"); } } diff --git a/src/test/java/org/codehaus/mojo/wagon/WagonMojoFtpBasicIT.java b/src/test/java/org/codehaus/mojo/wagon/WagonMojoFtpBasicIT.java index 87d0ff6..6bb17af 100644 --- a/src/test/java/org/codehaus/mojo/wagon/WagonMojoFtpBasicIT.java +++ b/src/test/java/org/codehaus/mojo/wagon/WagonMojoFtpBasicIT.java @@ -1,5 +1,7 @@ package org.codehaus.mojo.wagon; +import java.io.File; + import io.takari.maven.testing.TestResources; import io.takari.maven.testing.executor.MavenExecution; import io.takari.maven.testing.executor.MavenExecutionResult; @@ -7,7 +9,6 @@ import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder; import io.takari.maven.testing.executor.MavenVersions; import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner; -import java.io.File; import org.apache.ftpserver.ConnectionConfigFactory; import org.apache.ftpserver.FtpServer; import org.apache.ftpserver.FtpServerFactory; @@ -21,66 +22,65 @@ import org.junit.Test; import org.junit.runner.RunWith; -@RunWith( MavenJUnitTestRunner.class ) -@MavenVersions( { "3.6.3" } ) -public class WagonMojoFtpBasicIT -{ +@RunWith(MavenJUnitTestRunner.class) +@MavenVersions({"3.6.3"}) +public class WagonMojoFtpBasicIT { @Rule public final TestResources resources = new TestResources(); public final MavenRuntime maven; public final FtpServer ftpServer; - public WagonMojoFtpBasicIT( MavenRuntimeBuilder builder ) - throws Exception - { + public WagonMojoFtpBasicIT(MavenRuntimeBuilder builder) throws Exception { this.ftpServer = createFtp(); - this.maven = builder.withCliOptions( "-B", "-e", "-s", "settings.xml" ).build(); + this.maven = builder.withCliOptions("-B", "-e", "-s", "settings.xml").build(); } @Before - public void setup() throws Exception { + public void setup() throws Exception { ftpServer.start(); } @After public void teardown() { - if (ftpServer != null && !ftpServer.isStopped()){ + if (ftpServer != null && !ftpServer.isStopped()) { ftpServer.stop(); } } @Test - public void testFtpBasic() - throws Exception - { - File projDir = resources.getBasedir( "ftp-basic" ); - MavenExecution mavenExec = maven.forProject( projDir ); - MavenExecutionResult result = mavenExec.execute( "clean", "verify" ); + public void testFtpBasic() throws Exception { + File projDir = resources.getBasedir("ftp-basic"); + MavenExecution mavenExec = maven.forProject(projDir); + MavenExecutionResult result = mavenExec.execute("clean", "verify"); result.assertErrorFreeLog(); - Assert.assertTrue( new File( result.getBasedir(), "target/it/" + this.getClass().getSimpleName() + ".class" ).exists() ); - Assert.assertTrue( new File( result.getBasedir(), "target/it/single-dir/"+ this.getClass().getSimpleName() + ".class" ).exists() ); - Assert.assertTrue( new File( result.getBasedir(), "target/it/single-dir/" + this.getClass().getSimpleName() + ".class" ).exists() ); - + Assert.assertTrue( + new File(result.getBasedir(), "target/it/" + this.getClass().getSimpleName() + ".class").exists()); + Assert.assertTrue(new File( + result.getBasedir(), + "target/it/single-dir/" + this.getClass().getSimpleName() + ".class") + .exists()); + Assert.assertTrue(new File( + result.getBasedir(), + "target/it/single-dir/" + this.getClass().getSimpleName() + ".class") + .exists()); } - private FtpServer createFtp() - throws FtpException - { + private FtpServer createFtp() throws FtpException { FtpServerFactory serverFactory = new FtpServerFactory(); ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory(); - connectionConfigFactory.setAnonymousLoginEnabled( true ); + connectionConfigFactory.setAnonymousLoginEnabled(true); ListenerFactory factory = new ListenerFactory(); - factory.setPort( 8221 ); + factory.setPort(8221); - serverFactory.setConnectionConfig( connectionConfigFactory.createConnectionConfig() ); - serverFactory.addListener( "default", factory.createListener() ); + serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig()); + serverFactory.addListener("default", factory.createListener()); BaseUser user = new BaseUser(); - user.setName( "anonymous" ); - user.setHomeDirectory( new File( "target" ).getAbsolutePath() ); - serverFactory.getUserManager().save( user ); + user.setName("anonymous"); + user.setHomeDirectory(new File("target").getAbsolutePath()); + serverFactory.getUserManager().save(user); return serverFactory.createServer(); } diff --git a/src/test/java/org/codehaus/mojo/wagon/WagonMojoHttpIT.java b/src/test/java/org/codehaus/mojo/wagon/WagonMojoHttpIT.java index 949226f..289e7ea 100644 --- a/src/test/java/org/codehaus/mojo/wagon/WagonMojoHttpIT.java +++ b/src/test/java/org/codehaus/mojo/wagon/WagonMojoHttpIT.java @@ -1,6 +1,8 @@ package org.codehaus.mojo.wagon; -import static java.util.Objects.requireNonNull; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; import io.takari.maven.testing.TestResources; import io.takari.maven.testing.executor.MavenExecution; @@ -9,55 +11,47 @@ import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder; import io.takari.maven.testing.executor.MavenVersions; import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.nio.file.Path; -import java.nio.file.Paths; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -@RunWith( MavenJUnitTestRunner.class ) -@MavenVersions( { "3.6.3" } ) -public class WagonMojoHttpIT extends AbstractJettyIT -{ +@RunWith(MavenJUnitTestRunner.class) +@MavenVersions({"3.6.3"}) +public class WagonMojoHttpIT extends AbstractJettyIT { @Rule public final TestResources resources = new TestResources(); + private final MavenRuntimeBuilder mavenBuilder; public MavenRuntime maven; - public WagonMojoHttpIT( MavenRuntimeBuilder builder ) - throws Exception - { - this.mavenBuilder = builder.withCliOptions( "-B" ); + public WagonMojoHttpIT(MavenRuntimeBuilder builder) throws Exception { + this.mavenBuilder = builder.withCliOptions("-B"); } @Before public void setPort() throws Exception { - this.maven = this.mavenBuilder.withCliOptions( "-Dserver.port=" + getServerPort() ).build(); + this.maven = this.mavenBuilder + .withCliOptions("-Dserver.port=" + getServerPort()) + .build(); } @Test - public void testDownload() - throws Exception - { - File projDir = resources.getBasedir( "http-download" ); - MavenExecution mavenExec = maven.forProject( projDir ); + public void testDownload() throws Exception { + File projDir = resources.getBasedir("http-download"); + MavenExecution mavenExec = maven.forProject(projDir); - MavenExecutionResult result = mavenExec.execute( "clean", "verify" ); + MavenExecutionResult result = mavenExec.execute("clean", "verify"); result.assertErrorFreeLog(); - Assert.assertTrue( new File( result.getBasedir(), - "target/it/http-download/1.1/commons-dbutils-1.1-sources.txt" ).exists() ); + Assert.assertTrue( + new File(result.getBasedir(), "target/it/http-download/1.1/commons-dbutils-1.1-sources.txt").exists()); } @Override protected Path getDirectoryToServe() throws IOException { - return resources.getBasedir("http-download").toPath() - .resolve("files"); + return resources.getBasedir("http-download").toPath().resolve("files"); } } diff --git a/src/test/java/org/codehaus/mojo/wagon/WagonMojoHttpSettingsIT.java b/src/test/java/org/codehaus/mojo/wagon/WagonMojoHttpSettingsIT.java index ca747b9..ac36f1d 100644 --- a/src/test/java/org/codehaus/mojo/wagon/WagonMojoHttpSettingsIT.java +++ b/src/test/java/org/codehaus/mojo/wagon/WagonMojoHttpSettingsIT.java @@ -1,5 +1,9 @@ package org.codehaus.mojo.wagon; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; + import io.takari.maven.testing.TestResources; import io.takari.maven.testing.executor.MavenExecution; import io.takari.maven.testing.executor.MavenExecutionResult; @@ -7,49 +11,42 @@ import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder; import io.takari.maven.testing.executor.MavenVersions; import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner; -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -@RunWith( MavenJUnitTestRunner.class ) -@MavenVersions( { "3.6.3" } ) -public class WagonMojoHttpSettingsIT extends AbstractJettyIT -{ +@RunWith(MavenJUnitTestRunner.class) +@MavenVersions({"3.6.3"}) +public class WagonMojoHttpSettingsIT extends AbstractJettyIT { @Rule public final TestResources resources = new TestResources(); public MavenRuntime maven; private final MavenRuntimeBuilder mavenBuilder; - public WagonMojoHttpSettingsIT( MavenRuntimeBuilder builder ) - throws Exception - { - this.mavenBuilder = builder.withCliOptions( "-B", "-e", "-s", "settings.xml"); + public WagonMojoHttpSettingsIT(MavenRuntimeBuilder builder) throws Exception { + this.mavenBuilder = builder.withCliOptions("-B", "-e", "-s", "settings.xml"); } @Before public void setPort() throws Exception { - this.maven = this.mavenBuilder.withCliOptions( "-Dserver.port=" + getServerPort() ).build(); + this.maven = this.mavenBuilder + .withCliOptions("-Dserver.port=" + getServerPort()) + .build(); } @Test - public void testDownload() - throws Exception - { - File projDir = resources.getBasedir( "http-download" ); - MavenExecution mavenExec = maven.forProject( projDir ); + public void testDownload() throws Exception { + File projDir = resources.getBasedir("http-download"); + MavenExecution mavenExec = maven.forProject(projDir); - MavenExecutionResult result = mavenExec.execute( "clean", "verify" ); + MavenExecutionResult result = mavenExec.execute("clean", "verify"); result.assertErrorFreeLog(); } @Override protected Path getDirectoryToServe() throws IOException { - return resources.getBasedir("http-download").toPath() - .resolve("files"); + return resources.getBasedir("http-download").toPath().resolve("files"); } } diff --git a/src/test/java/org/codehaus/mojo/wagon/WagonMojoSshIT.java b/src/test/java/org/codehaus/mojo/wagon/WagonMojoSshIT.java index 24729c6..d215cad 100644 --- a/src/test/java/org/codehaus/mojo/wagon/WagonMojoSshIT.java +++ b/src/test/java/org/codehaus/mojo/wagon/WagonMojoSshIT.java @@ -2,11 +2,6 @@ import java.io.File; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - import io.takari.maven.testing.TestResources; import io.takari.maven.testing.executor.MavenExecution; import io.takari.maven.testing.executor.MavenExecutionResult; @@ -14,31 +9,30 @@ import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder; import io.takari.maven.testing.executor.MavenVersions; import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; -@RunWith( MavenJUnitTestRunner.class ) -@MavenVersions( { "3.6.3" } ) -public class WagonMojoSshIT -{ +@RunWith(MavenJUnitTestRunner.class) +@MavenVersions({"3.6.3"}) +public class WagonMojoSshIT { @Rule public final TestResources resources = new TestResources(); public final MavenRuntime maven; - public WagonMojoSshIT( MavenRuntimeBuilder builder ) - throws Exception - { - this.maven = builder.withCliOptions( "-B", "-e", "-s", "settings.xml" ).build(); + public WagonMojoSshIT(MavenRuntimeBuilder builder) throws Exception { + this.maven = builder.withCliOptions("-B", "-e", "-s", "settings.xml").build(); } @Test @Ignore - public void testSsh() - throws Exception - { - File projDir = resources.getBasedir( "ssh-it" ); - MavenExecution mavenExec = maven.forProject( projDir ); + public void testSsh() throws Exception { + File projDir = resources.getBasedir("ssh-it"); + MavenExecution mavenExec = maven.forProject(projDir); - MavenExecutionResult result = mavenExec.execute( "clean", "verify" ); + MavenExecutionResult result = mavenExec.execute("clean", "verify"); result.assertErrorFreeLog(); } }