Skip to content

Commit

Permalink
[#67] remove maven-compat
Browse files Browse the repository at this point in the history
fixes #67
  • Loading branch information
bmarwell committed Oct 26, 2023
1 parent 63322f7 commit ea40575
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 38 deletions.
16 changes: 1 addition & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,6 @@
<scope>provided</scope>
</dependency>

<!-- needed by update-maven-3 goal -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>${maven.api.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-repository-metadata</artifactId>
Expand Down Expand Up @@ -205,7 +191,7 @@
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>file-management</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
</dependency>

<dependency>
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/org/codehaus/mojo/wagon/UpdateMaven3Mojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.impl.ArtifactResolver;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResult;

/**
* Work around for WAGON-407 to copy commons-io, commons-lang, and jsoup to ${maven.home}/lib/ext directory.
Expand Down Expand Up @@ -87,9 +90,12 @@ private void updateMavenLib( Artifact artifact )
try
{
File mavenLibDir = new File( System.getProperty( "maven.home" ), "lib/ext" );
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
this.getLog().info( "Copy " + artifact.getFile() + " to " + mavenLibDir );
FileUtils.copyFileToDirectory( artifact.getFile(), mavenLibDir );
org.eclipse.aether.artifact.Artifact aetherArtifact = new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getVersion(), artifact.getType());
ArtifactRequest request = new ArtifactRequest(aetherArtifact, null, null);
ArtifactResult artifactResult = artifactResolver.resolveArtifact(null, request);
File artifactFile = artifactResult.getArtifact().getFile();
this.getLog().info( "Copy " + artifactFile + " to " + mavenLibDir );
FileUtils.copyFileToDirectory( artifactFile, mavenLibDir );
}
catch ( Exception e )
{
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/codehaus/mojo/wagon/UploadMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected void execute( Wagon wagon )

fileSet.setOutputDirectory( toDir );

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

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void merge( Wagon src, Wagon target, boolean optimize, Log logger )
FileSet tobeUploadedFileSet = new FileSet();
tobeUploadedFileSet.setDirectory( downloadSrcDir.getAbsolutePath() );

this.uploader.upload( target, tobeUploadedFileSet, optimize, logger );
this.uploader.upload( target, tobeUploadedFileSet, optimize );

}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void copy( Wagon src, WagonFileSet wagonFileSet, Wagon target, boolean op
localFileSet.setDirectory( wagonFileSet.getDownloadDirectory().getAbsolutePath() );
localFileSet.setOutputDirectory( wagonFileSet.getOutputDirectory() );

this.uploader.upload( target, localFileSet, optimize, logger );
this.uploader.upload( target, localFileSet, optimize );
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,24 @@
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component(role = WagonUpload.class, hint = "default")
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, Log logger )
public void upload( Wagon wagon, FileSet fileset )
throws WagonException
{

FileSetManager fileSetManager = new FileSetManager( logger, logger.isDebugEnabled() );
FileSetManager fileSetManager = new FileSetManager( LOG, LOG.isDebugEnabled() );

String[] files = fileSetManager.getIncludedFiles( fileset );
Arrays.sort(files);
Expand All @@ -58,7 +62,7 @@ public void upload( Wagon wagon, FileSet fileset, Log logger )

if ( files.length == 0 )
{
logger.info( "Nothing to upload." );
LOG.info( "Nothing to upload." );
return;
}

Expand All @@ -73,20 +77,20 @@ public void upload( Wagon wagon, FileSet fileset, Log logger )

File source = new File( fileset.getDirectory(), file );

logger.info( "Uploading " + source + " to " + url + relativeDestPath + " ..." );
LOG.info( "Uploading " + source + " to " + url + relativeDestPath + " ..." );

wagon.put( source, relativeDestPath );
}

}

@Override
public void upload( Wagon wagon, FileSet fileset, boolean optimize, Log logger )
public void upload( Wagon wagon, FileSet fileset, boolean optimize )
throws WagonException, IOException
{
if ( !optimize )
{
upload( wagon, fileset, logger );
upload( wagon, fileset );
return;
}

Expand All @@ -96,23 +100,23 @@ public void upload( Wagon wagon, FileSet fileset, boolean optimize, Log logger )
+ " does not support optimize upload" );
}

logger.info( "Uploading " + fileset );
LOG.info( "Uploading " + fileset );

File zipFile;
zipFile = File.createTempFile( "wagon", ".zip" );

try
{
FileSetManager fileSetManager = new FileSetManager( logger, logger.isDebugEnabled() );
FileSetManager fileSetManager = new FileSetManager( LOG, LOG.isDebugEnabled() );
String[] files = fileSetManager.getIncludedFiles( fileset );

if ( files.length == 0 )
{
logger.info( "Nothing to upload." );
LOG.info( "Nothing to upload." );
return;
}

logger.info( "Creating " + zipFile + " ..." );
LOG.info( "Creating " + zipFile + " ..." );
createZip( files, zipFile, fileset.getDirectory() );

String remoteFile = zipFile.getName();
Expand All @@ -122,7 +126,7 @@ public void upload( Wagon wagon, FileSet fileset, boolean optimize, Log logger )
remoteFile = remoteDir + "/" + remoteFile;
}

logger.info( "Uploading " + zipFile + " to " + wagon.getRepository().getUrl() + "/" + 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
Expand All @@ -134,13 +138,13 @@ public void upload( Wagon wagon, FileSet fileset, boolean optimize, Log logger )

try
{
logger.info( "Remote: " + command );
LOG.info( "Remote: " + command );
( (CommandExecutor) wagon ).executeCommand( command );
}
finally
{
command = "rm -f " + remoteFile;
logger.info( "Remote: " + command );
LOG.info( "Remote: " + command );

( (CommandExecutor) wagon ).executeCommand( command );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ public interface WagonUpload
*
* @param wagon - a Wagon instance
* @param fileset file set to upload
* @param logger logger used
* @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, Log logger )
void upload( Wagon wagon, FileSet fileset, boolean optimize )
throws WagonException, IOException;
}

0 comments on commit ea40575

Please sign in to comment.