You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by ev...@apache.org on 2004/09/29 13:20:39 UTC
cvs commit: maven-components/maven-artifact/src/test/java/org/apache/maven/artifact ArtifactComponentTestCase.java
evenisse 2004/09/29 04:20:39
Modified: maven-artifact/src/main/java/org/apache/maven/artifact
AbstractArtifactComponent.java
maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager
ArtifactHandlerManager.java
DefaultArtifactHandlerManager.java
maven-artifact/src/main/java/org/apache/maven/artifact/installer
DefaultArtifactInstaller.java
maven-artifact/src/main/java/org/apache/maven/artifact/resolver
DefaultArtifactResolver.java
maven-artifact/src/test/java/org/apache/maven/artifact
ArtifactComponentTestCase.java
Log:
Fix artifact handling for unsupported artifact type.
Revision Changes Path
1.2 +3 -1 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/AbstractArtifactComponent.java
Index: AbstractArtifactComponent.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/AbstractArtifactComponent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractArtifactComponent.java 9 Aug 2004 18:37:32 -0000 1.1
+++ AbstractArtifactComponent.java 29 Sep 2004 11:20:38 -0000 1.2
@@ -38,11 +38,13 @@
}
protected String path( Artifact artifact )
+ throws ArtifactHandlerNotFoundException
{
return artifactHandlerManager.path( artifact );
}
protected void setLocalRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
+ throws ArtifactHandlerNotFoundException
{
artifact.setPath( artifactHandlerManager.localRepositoryPath( artifact, localRepository ) );
}
1.2 +5 -3 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.java
Index: ArtifactHandlerManager.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ArtifactHandlerManager.java 9 Aug 2004 18:37:33 -0000 1.1
+++ ArtifactHandlerManager.java 29 Sep 2004 11:20:38 -0000 1.2
@@ -33,9 +33,11 @@
ArtifactHandler getArtifactHandler( String type )
throws ArtifactHandlerNotFoundException;
- String localRepositoryPath( Artifact artifact, ArtifactRepository localRepository );
+ String localRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
+ throws ArtifactHandlerNotFoundException;
- String path( Artifact artifact );
+ String path( Artifact artifact )
+ throws ArtifactHandlerNotFoundException;
Set getHandlerTypes();
1.4 +4 -7 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java
Index: DefaultArtifactHandlerManager.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultArtifactHandlerManager.java 29 Sep 2004 10:21:22 -0000 1.3
+++ DefaultArtifactHandlerManager.java 29 Sep 2004 11:20:38 -0000 1.4
@@ -68,23 +68,20 @@
}
public String localRepositoryPath( Artifact artifact, ArtifactRepository localRepository )
+ throws ArtifactHandlerNotFoundException
{
return localRepository.getBasedir() + "/" + path( artifact );
}
public String artifactUrl( Artifact artifact, ArtifactRepository remoteRepository )
+ throws ArtifactHandlerNotFoundException
{
return remoteRepository.getUrl() + "/" + path( artifact );
}
- public String path( Artifact artifact )
+ public String path( Artifact artifact ) throws ArtifactHandlerNotFoundException
{
- ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( artifact.getType() );
-
- if ( handler == null )
- {
- throw new ArtifactHandlerNotFoundException( "Artifact handler for type '" + type + "' cannot be found." );
- }
+ ArtifactHandler handler = getArtifactHandler( artifact.getType() );
return interpolateLayout( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), handler
.directory(), handler.extension() );
1.2 +7 -7 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java
Index: DefaultArtifactInstaller.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultArtifactInstaller.java 9 Aug 2004 18:37:33 -0000 1.1
+++ DefaultArtifactInstaller.java 29 Sep 2004 11:20:38 -0000 1.2
@@ -51,15 +51,15 @@
public void install( File source, Artifact artifact, ArtifactRepository localRepository )
throws ArtifactInstallationException
{
- setLocalRepositoryPath( artifact, localRepository );
-
- if ( !artifact.getFile().getParentFile().exists() )
- {
- artifact.getFile().getParentFile().mkdirs();
- }
-
try
{
+ setLocalRepositoryPath( artifact, localRepository );
+
+ if ( !artifact.getFile().getParentFile().exists() )
+ {
+ artifact.getFile().getParentFile().mkdirs();
+ }
+
getLogger().info( "Installing " + source.getPath() + " to " + artifact.getPath() );
FileUtils.copyFile( source, artifact.getFile() );
1.5 +20 -8 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
Index: DefaultArtifactResolver.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultArtifactResolver.java 15 Aug 2004 04:30:31 -0000 1.4
+++ DefaultArtifactResolver.java 29 Sep 2004 11:20:38 -0000 1.5
@@ -2,6 +2,7 @@
import org.apache.maven.artifact.AbstractArtifactComponent;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
@@ -37,17 +38,21 @@
// for resolution has been satisfied.
// ----------------------------------------------------------------------
- setLocalRepositoryPath( artifact, localRepository );
-
- if ( artifact.exists() )
- {
- return artifact;
- }
-
try
{
+ setLocalRepositoryPath( artifact, localRepository );
+
+ if ( artifact.exists() )
+ {
+ return artifact;
+ }
+
wagonManager.get( artifact, remoteRepositories, localRepository );
}
+ catch ( ArtifactHandlerNotFoundException e )
+ {
+ throw new ArtifactResolutionException( "Error resolving artifact: ", e );
+ }
catch ( TransferFailedException e )
{
throw new ArtifactResolutionException( artifactNotFound( artifact, remoteRepositories ), e );
@@ -223,7 +228,14 @@
{
Artifact artifact = (Artifact) it.next();
- setLocalRepositoryPath( artifact, localRepository );
+ try
+ {
+ setLocalRepositoryPath( artifact, localRepository );
+ }
+ catch ( ArtifactHandlerNotFoundException e )
+ {
+ throw new TransitiveArtifactResolutionException( "Error collecting artifact: ", e );
+ }
artifactResult.put( artifact.getId(), artifact );
}
1.4 +6 -1 maven-components/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java
Index: ArtifactComponentTestCase.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ArtifactComponentTestCase.java 2 Sep 2004 12:34:17 -0000 1.3
+++ ArtifactComponentTestCase.java 29 Sep 2004 11:20:38 -0000 1.4
@@ -18,6 +18,7 @@
import org.codehaus.plexus.PlexusTestCase;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.io.File;
@@ -89,6 +90,7 @@
}
protected void assertRemoteArtifactPresent( Artifact artifact )
+ throws ArtifactHandlerNotFoundException
{
String path = artifactHandlerManager.path( artifact );
@@ -101,6 +103,7 @@
}
protected void assertLocalArtifactPresent( Artifact artifact )
+ throws ArtifactHandlerNotFoundException
{
String path = artifactHandlerManager.path( artifact );
@@ -113,6 +116,7 @@
}
protected void assertRemoteArtifactNotPresent( Artifact artifact )
+ throws ArtifactHandlerNotFoundException
{
String path = artifactHandlerManager.path( artifact );
@@ -125,6 +129,7 @@
}
protected void assertLocalArtifactNotPresent( Artifact artifact )
+ throws ArtifactHandlerNotFoundException
{
String path = artifactHandlerManager.path( artifact );