diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java b/maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java index cac6e87808..92e6ccb25b 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java @@ -23,6 +23,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.codehaus.plexus.util.FileUtils; import java.io.File; +import java.io.IOException; /** * @todo notions of snapshots should be dealt with in one single place. @@ -64,7 +65,11 @@ public class DefaultArtifactInstaller FileUtils.copyFile( source, artifact.getFile() ); } - catch ( Exception e ) + catch ( IOException e ) + { + throw new ArtifactInstallationException( "Error installing artifact: ", e ); + } + catch ( ArtifactHandlerNotFoundException e ) { throw new ArtifactInstallationException( "Error installing artifact: ", e ); } diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java b/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java index 8435c40ca6..24a6273eb7 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java @@ -65,7 +65,7 @@ public class DefaultWagonManager } catch ( ComponentLookupException e ) { - throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " + protocol ); + throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " + protocol, e ); } return wagon; @@ -121,22 +121,13 @@ public class DefaultWagonManager public void get( Artifact artifact, File destination, Set repositories ) throws TransferFailedException { - boolean transfered = false; - File temp = null; - try - { - // TODO [BP]: do this handling in Wagon itself - temp = new File( destination + ".tmp" ); - - temp.deleteOnExit(); - } - catch ( Exception e ) - { - throw new TransferFailedException( "Could not create temporary file for transfering artificat: " + artifact ); - } + // TODO [BP]: do this handling in Wagon itself + temp = new File( destination + ".tmp" ); + temp.deleteOnExit(); + // TODO [BP]: The exception handling here needs some work for ( Iterator iter = repositories.iterator(); iter.hasNext(); ) { ArtifactRepository repository = (ArtifactRepository) iter.next(); diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java index ba1575c0c7..6161b6da81 100644 --- a/maven-artifact/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java @@ -60,6 +60,7 @@ public class DefaultWagonManagerTest catch ( UnsupportedProtocolException e ) { //ok + assertTrue( true ); } } } diff --git a/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java b/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java index 186d0e56eb..6c806f84c0 100644 --- a/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java +++ b/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java @@ -19,7 +19,6 @@ package org.apache.maven.artifact.resolver; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactComponentTestCase; import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -139,20 +138,12 @@ public class ArtifactResolverTest ArtifactMetadataSource mds = new ArtifactMetadataSource() { public Set retrieve( Artifact artifact, ArtifactRepository localRepository, Set remoteRepositories ) - throws ArtifactMetadataRetrievalException { Set dependencies = new HashSet(); if ( artifact.getArtifactId().equals( "g" ) ) { - try - { - dependencies.add( new DefaultArtifact( "maven", "h", "1.0", "jar" ) ); - } - catch ( Exception e ) - { - throw new ArtifactMetadataRetrievalException( "Cannot retrieve metadata." ); - } + dependencies.add( new DefaultArtifact( "maven", "h", "1.0", "jar" ) ); } return dependencies; @@ -187,20 +178,12 @@ public class ArtifactResolverTest ArtifactMetadataSource mds = new ArtifactMetadataSource() { public Set retrieve( Artifact artifact, ArtifactRepository localRepository, Set remoteRepositories ) - throws ArtifactMetadataRetrievalException { Set dependencies = new HashSet(); if ( artifact.getArtifactId().equals( "i" ) ) { - try - { - dependencies.add( new DefaultArtifact( "maven", "j", "1.0", "jar" ) ); - } - catch ( Exception e ) - { - throw new ArtifactMetadataRetrievalException( "Cannot retrieve metadata." ); - } + dependencies.add( new DefaultArtifact( "maven", "j", "1.0", "jar" ) ); } return dependencies;