Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Jun 16, 2024
1 parent 618dc54 commit 9da2f57
Show file tree
Hide file tree
Showing 36 changed files with 753 additions and 1,202 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand Down Expand Up @@ -81,3 +80,4 @@ cd target/checkout
../mvnw site
../mvnw scm-publish:publish-scm
```

70 changes: 34 additions & 36 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>mojo-parent</artifactId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mojo-parent</artifactId>
<version>84</version>
</parent>

Expand All @@ -13,33 +13,19 @@
<packaging>maven-plugin</packaging>
<name>Wagon Maven Plugin</name>

<description>
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.
</description>
<url>http://www.mojohaus.org/wagon-maven-plugin/</url>
<description>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.</description>
<url>https://www.mojohaus.org/wagon-maven-plugin/</url>

<inceptionYear>2008</inceptionYear>

<prerequisites>
<maven>3.0</maven>
</prerequisites>

<scm>
<connection>scm:git:https://github.com/mojohaus/wagon-maven-plugin.git</connection>
<developerConnection>scm:git:ssh://[email protected]/mojohaus/wagon-maven-plugin.git</developerConnection>
<url>https://github.com/mojohaus/wagon-maven-plugin/</url>
<tag>HEAD</tag>
</scm>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/mojohaus/wagon-maven-plugin/issues/</url>
</issueManagement>
<ciManagement>
<system>Travis-CI</system>
<url>https://travis-ci.org/mojohaus/wagon-maven-plugin</url>
</ciManagement>
<licenses>
<license>
<name>Apache License 2</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
Expand All @@ -61,25 +47,37 @@
</roles>
</developer>
<developer>
<name>Tony Chemit</name>
<id>tchemit</id>
<name>Tony Chemit</name>
<email>[email protected]</email>
<organization>Ultreia.io</organization>
<organizationUrl>https://www.ultreia.io</organizationUrl>
<email>[email protected]</email>
<timezone>Europe/Paris</timezone>
<roles>
<role>Developer</role>
</roles>
<timezone>Europe/Paris</timezone>
</developer>
</developers>

<licenses>
<license>
<name>Apache License 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<prerequisites>
<maven>3.0</maven>
</prerequisites>

<scm>
<connection>scm:git:https://github.com/mojohaus/wagon-maven-plugin.git</connection>
<developerConnection>scm:git:ssh://[email protected]/mojohaus/wagon-maven-plugin.git</developerConnection>
<tag>HEAD</tag>
<url>https://github.com/mojohaus/wagon-maven-plugin/</url>
</scm>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/mojohaus/wagon-maven-plugin/issues/</url>
</issueManagement>
<ciManagement>
<system>Travis-CI</system>
<url>https://travis-ci.org/mojohaus/wagon-maven-plugin</url>
</ciManagement>

<properties>
<maven.api.version>3.6.3</maven.api.version>
Expand Down Expand Up @@ -329,10 +327,10 @@
<executions>
<execution>
<id>testProperties</id>
<phase>process-test-resources</phase>
<goals>
<goal>testProperties</goal>
</goals>
<phase>process-test-resources</phase>
</execution>
</executions>
</plugin>
Expand Down
56 changes: 19 additions & 37 deletions src/main/java/org/codehaus/mojo/wagon/AbstractCopyMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
53 changes: 19 additions & 34 deletions src/main/java/org/codehaus/mojo/wagon/AbstractSingleWagonMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand All @@ -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;
}
18 changes: 7 additions & 11 deletions src/main/java/org/codehaus/mojo/wagon/AbstractWagonListMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
}

}
Loading

0 comments on commit 9da2f57

Please sign in to comment.