mirror of https://github.com/apache/maven.git
upload checksums
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@164029 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c435539656
commit
26c968d770
|
@ -48,6 +48,7 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DefaultWagonManager
|
||||
extends AbstractLogEnabled
|
||||
|
@ -125,11 +126,17 @@ public class DefaultWagonManager
|
|||
wagon.addTransferListener( downloadMonitor );
|
||||
}
|
||||
|
||||
// TODO: configure these
|
||||
Map checksums = new HashMap();
|
||||
|
||||
// TODO: configure these on the repository
|
||||
try
|
||||
{
|
||||
wagon.addTransferListener( new ChecksumObserver( "MD5" ) );
|
||||
wagon.addTransferListener( new ChecksumObserver( "SHA-1" ) );
|
||||
ChecksumObserver checksumObserver = new ChecksumObserver( "MD5" );
|
||||
wagon.addTransferListener( checksumObserver );
|
||||
checksums.put( "md5", checksumObserver );
|
||||
checksumObserver = new ChecksumObserver( "SHA-1" );
|
||||
wagon.addTransferListener( checksumObserver );
|
||||
checksums.put( "sha1", checksumObserver );
|
||||
}
|
||||
catch ( NoSuchAlgorithmException e )
|
||||
{
|
||||
|
@ -141,6 +148,22 @@ public class DefaultWagonManager
|
|||
wagon.connect( repository, getProxy( repository.getProtocol() ) );
|
||||
|
||||
wagon.put( source, remotePath );
|
||||
|
||||
wagon.removeTransferListener( downloadMonitor );
|
||||
|
||||
// We do this in here so we can checksum the artifact metadata too, otherwise it could be metadata itself
|
||||
for ( Iterator i = checksums.keySet().iterator(); i.hasNext(); )
|
||||
{
|
||||
String extension = (String) i.next();
|
||||
ChecksumObserver observer = (ChecksumObserver) checksums.get( extension );
|
||||
|
||||
// TODO: shouldn't need a file intermediatary - improve wagon to take a stream
|
||||
File temp = File.createTempFile( "maven-artifact", null );
|
||||
temp.deleteOnExit();
|
||||
FileUtils.fileWrite( temp.getAbsolutePath(), observer.getActualChecksum() );
|
||||
|
||||
wagon.put( temp, remotePath + "." + extension );
|
||||
}
|
||||
}
|
||||
catch ( ConnectionException e )
|
||||
{
|
||||
|
@ -158,6 +181,10 @@ public class DefaultWagonManager
|
|||
{
|
||||
throw new TransferFailedException( "Resource to deploy not found: ", e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new TransferFailedException( "Error creating temporary file for deployment: ", e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
disconnectWagon( wagon );
|
||||
|
|
|
@ -144,6 +144,7 @@ public class SnapshotArtifactMetadata
|
|||
|
||||
try
|
||||
{
|
||||
// TODO: shouldn't need a file intermediatary - improve wagon to take a stream
|
||||
File destination = File.createTempFile( "maven-artifact", null );
|
||||
destination.deleteOnExit();
|
||||
|
||||
|
|
Loading…
Reference in New Issue