PR: MNG-257

refactor artifact creation to all go through the factory, and assign the type handler from there.
Attach EJB client to the EJB artifact so that it is installed/deployed along with it.



git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@191096 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-06-17 06:49:57 +00:00
parent 3c2de055e8
commit 01e6c8daa6
48 changed files with 390 additions and 458 deletions

View File

@ -137,6 +137,7 @@ public class MavenArchiver
for ( Iterator iter = artifacts.iterator(); iter.hasNext(); ) for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
{ {
Artifact artifact = (Artifact) iter.next(); Artifact artifact = (Artifact) iter.next();
// TODO: type of ejb should be added too?
if ( "jar".equals( artifact.getType() ) ) if ( "jar".equals( artifact.getType() ) )
{ {
if ( extensionsList.length() > 0 ) if ( extensionsList.length() > 0 )

View File

@ -19,6 +19,8 @@ package org.apache.maven.artifact.ant;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Server; import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings; import org.apache.maven.settings.Settings;
@ -300,4 +302,13 @@ public abstract class AbstractArtifactTask
System.setProperty( ProfileActivationUtils.ACTIVE_PROFILE_IDS, profiles ); System.setProperty( ProfileActivationUtils.ACTIVE_PROFILE_IDS, profiles );
} }
} }
protected Artifact createArtifact( Pom pom )
{
ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
// TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
Artifact artifact = factory.createArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(), null,
pom.getPackaging() );
return artifact;
}
} }

View File

@ -17,9 +17,9 @@ package org.apache.maven.artifact.ant;
*/ */
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.ArtifactResolver;
@ -59,7 +59,8 @@ public class DependenciesTask
ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE ); ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
MavenMetadataSource metadataSource = new MavenMetadataSource( resolver, projectBuilder ); ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
MavenMetadataSource metadataSource = new MavenMetadataSource( resolver, projectBuilder, artifactFactory );
List dependencies = this.dependencies; List dependencies = this.dependencies;
@ -118,15 +119,7 @@ public class DependenciesTask
for ( Iterator i = result.getArtifacts().values().iterator(); i.hasNext(); ) for ( Iterator i = result.getArtifacts().values().iterator(); i.hasNext(); )
{ {
Artifact artifact = (Artifact) i.next(); Artifact artifact = (Artifact) i.next();
String filename = null; String filename = localRepo.pathOf( artifact );
try
{
filename = localRepo.pathOf( artifact );
}
catch ( ArtifactPathFormatException e )
{
throw new BuildException( "Unable to determine path to artifact: " + artifact, e );
}
FileList.FileName file = new FileList.FileName(); FileList.FileName file = new FileList.FileName();
file.setName( filename ); file.setName( filename );

View File

@ -66,8 +66,8 @@ public class DeployTask
ArtifactRepository deploymentRepository = createRemoteArtifactRepository( remoteRepository ); ArtifactRepository deploymentRepository = createRemoteArtifactRepository( remoteRepository );
// Deploy the POM // Deploy the POM
Artifact artifact = new DefaultArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(), Artifact artifact = createArtifact( pom );
pom.getPackaging() );
boolean isPomArtifact = "pom".equals( pom.getPackaging() ); boolean isPomArtifact = "pom".equals( pom.getPackaging() );
if ( !isPomArtifact ) if ( !isPomArtifact )
{ {

View File

@ -17,7 +17,7 @@ package org.apache.maven.artifact.ant;
*/ */
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.installer.ArtifactInstallationException;
import org.apache.maven.artifact.installer.ArtifactInstaller; import org.apache.maven.artifact.installer.ArtifactInstaller;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
@ -47,8 +47,7 @@ public class InstallTask
MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
Pom pom = buildPom( builder, localRepo ); Pom pom = buildPom( builder, localRepo );
Artifact artifact = new DefaultArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(), Artifact artifact = createArtifact( pom );
pom.getPackaging() );
boolean isPomArtifact = "pom".equals( pom.getPackaging() ); boolean isPomArtifact = "pom".equals( pom.getPackaging() );
if ( !isPomArtifact ) if ( !isPomArtifact )
@ -75,7 +74,7 @@ public class InstallTask
throw new BuildException( "Error installing artifact", e ); throw new BuildException( "Error installing artifact", e );
} }
} }
public File getFile() public File getFile()
{ {
return file; return file;

View File

@ -10,11 +10,6 @@
<component> <component>
<role>org.apache.maven.artifact.manager.WagonManager</role> <role>org.apache.maven.artifact.manager.WagonManager</role>
<implementation>org.apache.maven.artifact.ant.CustomWagonManager</implementation> <implementation>org.apache.maven.artifact.ant.CustomWagonManager</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component> </component>
<!-- <!--
@ -44,9 +39,6 @@
<requirement> <requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role> <role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement> </requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role> <role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
<field-name>artifactTransformations</field-name> <field-name>artifactTransformations</field-name>
@ -66,9 +58,6 @@
<role>org.apache.maven.artifact.installer.ArtifactInstaller</role> <role>org.apache.maven.artifact.installer.ArtifactInstaller</role>
<implementation>org.apache.maven.artifact.installer.DefaultArtifactInstaller</implementation> <implementation>org.apache.maven.artifact.installer.DefaultArtifactInstaller</implementation>
<requirements> <requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role> <role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
<field-name>artifactTransformations</field-name> <field-name>artifactTransformations</field-name>
@ -88,9 +77,6 @@
<requirement> <requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role> <role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement> </requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role> <role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
<field-name>artifactTransformations</field-name> <field-name>artifactTransformations</field-name>
@ -102,22 +88,12 @@
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role> <role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
<role-hint>default</role-hint> <role-hint>default</role-hint>
<implementation>org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout</implementation> <implementation>org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component> </component>
<component> <component>
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role> <role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
<role-hint>legacy</role-hint> <role-hint>legacy</role-hint>
<implementation>org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout</implementation> <implementation>org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component> </component>
<!-- <!--
@ -193,6 +169,18 @@
</configuration> </configuration>
</component> </component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>ejb-client</role-hint>
<implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
<configuration>
<type>ejb-client</type>
<extension>jar</extension>
<packaging>ejb</packaging>
<classifier>client</classifier>
</configuration>
</component>
<!-- <!--
| |
| |
@ -320,6 +308,11 @@
<component> <component>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role> <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
<implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation> <implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component> </component>
<component> <component>

View File

@ -18,9 +18,7 @@ package org.apache.maven.artifact.test;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.settings.Profile;
import org.apache.maven.settings.Settings; import org.apache.maven.settings.Settings;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
@ -40,7 +38,6 @@ public abstract class ArtifactTestCase
private ArtifactRepository localRepository; private ArtifactRepository localRepository;
protected File getLocalArtifactPath( Artifact artifact ) protected File getLocalArtifactPath( Artifact artifact )
throws ArtifactPathFormatException
{ {
return new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ); return new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
} }

View File

@ -20,6 +20,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.handler.ArtifactHandler;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -80,7 +81,7 @@ public interface Artifact
String getId(); String getId();
String getConflictId(); String getDependencyConflictId();
void addMetadata( ArtifactMetadata metadata ); void addMetadata( ArtifactMetadata metadata );
@ -90,8 +91,7 @@ public interface Artifact
ArtifactRepository getRepository(); ArtifactRepository getRepository();
void updateVersion( String version, ArtifactRepository localRepository ) void updateVersion( String version, ArtifactRepository localRepository );
throws ArtifactMetadataRetrievalException;
String getDownloadUrl(); String getDownloadUrl();
@ -100,4 +100,6 @@ public interface Artifact
ArtifactFilter getDependencyFilter(); ArtifactFilter getDependencyFilter();
void setDependencyFilter( ArtifactFilter artifactFilter ); void setDependencyFilter( ArtifactFilter artifactFilter );
ArtifactHandler getArtifactHandler();
} }

View File

@ -17,10 +17,9 @@ package org.apache.maven.artifact;
*/ */
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
import java.io.File; import java.io.File;
@ -61,16 +60,16 @@ public class DefaultArtifact
private ArtifactFilter dependencyFilter; private ArtifactFilter dependencyFilter;
/** private final ArtifactHandler artifactHandler;
* !!! WARNING !!! Never put <classifier/> in the POM. It is for mojo use
* only. Classifier is for specifying derived artifacts, like ejb-client. // TODO: direct all through the artifact factory
*/
public DefaultArtifact( String groupId, public DefaultArtifact( String groupId,
String artifactId, String artifactId,
String version, String version,
String scope, String scope,
String type, String type,
String classifier ) String classifier,
ArtifactHandler artifactHandler )
{ {
this.groupId = groupId; this.groupId = groupId;
@ -78,12 +77,14 @@ public class DefaultArtifact
this.version = version; this.version = version;
this.type = type; this.artifactHandler = artifactHandler;
this.scope = scope; this.scope = scope;
this.type = type;
this.classifier = classifier; this.classifier = classifier;
validateIdentity(); validateIdentity();
} }
@ -115,16 +116,6 @@ public class DefaultArtifact
return value == null || value.trim().length() < 1; return value == null || value.trim().length() < 1;
} }
public DefaultArtifact( String groupId, String artifactId, String version, String scope, String type )
{
this( groupId, artifactId, version, scope, type, null );
}
public DefaultArtifact( String groupId, String artifactId, String version, String type )
{
this( groupId, artifactId, version, null, type, null );
}
public String getClassifier() public String getClassifier()
{ {
return classifier; return classifier;
@ -191,10 +182,10 @@ public class DefaultArtifact
public String getId() public String getId()
{ {
return getConflictId() + ( hasClassifier() ? ( ":" + getClassifier() ) : "" ) + ":" + getBaseVersion(); return getDependencyConflictId() + ( hasClassifier() ? ( ":" + getClassifier() ) : "" ) + ":" + getBaseVersion();
} }
public String getConflictId() public String getDependencyConflictId()
{ {
return getGroupId() + ":" + getArtifactId() + ":" + getType(); return getGroupId() + ":" + getArtifactId() + ":" + getType();
} }
@ -331,17 +322,9 @@ public class DefaultArtifact
} }
public void updateVersion( String version, ArtifactRepository localRepository ) public void updateVersion( String version, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{ {
setVersion( version ); setVersion( version );
try setFile( new File( localRepository.getBasedir(), localRepository.pathOf( this ) ) );
{
setFile( new File( localRepository.getBasedir(), localRepository.pathOf( this ) ) );
}
catch ( ArtifactPathFormatException e )
{
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
}
} }
public String getDownloadUrl() public String getDownloadUrl()
@ -363,4 +346,9 @@ public class DefaultArtifact
{ {
this.dependencyFilter = artifactFilter; this.dependencyFilter = artifactFilter;
} }
public ArtifactHandler getArtifactHandler()
{
return artifactHandler;
}
} }

View File

@ -17,13 +17,10 @@ package org.apache.maven.artifact.deployer;
*/ */
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.transform.ArtifactTransformation; import org.apache.maven.artifact.transform.ArtifactTransformation;
import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.TransferFailedException;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
@ -40,8 +37,6 @@ public class DefaultArtifactDeployer
{ {
private WagonManager wagonManager; private WagonManager wagonManager;
private ArtifactHandlerManager artifactHandlerManager;
private List artifactTransformations; private List artifactTransformations;
public void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository, public void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository,
@ -50,16 +45,8 @@ public class DefaultArtifactDeployer
{ {
File source = null; File source = null;
try String extension = artifact.getArtifactHandler().getExtension();
{ source = new File( basedir, finalName + "." + extension );
String extension = artifactHandlerManager.getArtifactHandler( artifact.getType() ).getExtension();
source = new File( basedir, finalName + "." + extension );
}
catch ( ArtifactHandlerNotFoundException e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
}
deploy( source, artifact, deploymentRepository, localRepository ); deploy( source, artifact, deploymentRepository, localRepository );
} }
@ -103,10 +90,6 @@ public class DefaultArtifactDeployer
{ {
throw new ArtifactDeploymentException( "Error deploying artifact: ", e ); throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
} }
catch ( ArtifactPathFormatException e )
{
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
}
catch ( IOException e ) catch ( IOException e )
{ {
throw new ArtifactDeploymentException( "Error deploying artifact: ", e ); throw new ArtifactDeploymentException( "Error deploying artifact: ", e );

View File

@ -27,6 +27,6 @@ public interface ArtifactFactory
Artifact createArtifact( String groupId, String artifactId, String knownVersion, String scope, String type ); Artifact createArtifact( String groupId, String artifactId, String knownVersion, String scope, String type );
public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String scope, Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String scope,
String type, String classifier ); String type, String classifier );
} }

View File

@ -18,10 +18,15 @@ package org.apache.maven.artifact.factory;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
public class DefaultArtifactFactory public class DefaultArtifactFactory
implements ArtifactFactory implements ArtifactFactory
{ {
// TODO: remove, it doesn't know the ones from the plugins
private ArtifactHandlerManager artifactHandlerManager;
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ) public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type )
{ {
return createArtifact( groupId, artifactId, version, scope, type, null, null ); return createArtifact( groupId, artifactId, version, scope, type, null, null );
@ -39,8 +44,8 @@ public class DefaultArtifactFactory
return createArtifact( groupId, artifactId, version, scope, type, null, inheritedScope ); return createArtifact( groupId, artifactId, version, scope, type, null, inheritedScope );
} }
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type, private Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
String classifier, String inheritedScope ) String classifier, String inheritedScope )
{ {
// TODO: can refactor, use scope handler // TODO: can refactor, use scope handler
@ -71,7 +76,9 @@ public class DefaultArtifactFactory
desiredScope = Artifact.SCOPE_PROVIDED; desiredScope = Artifact.SCOPE_PROVIDED;
} }
DefaultArtifact artifact = new DefaultArtifact( groupId, artifactId, version, desiredScope, type, classifier ); ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( type );
DefaultArtifact artifact = new DefaultArtifact( groupId, artifactId, version, desiredScope, type, classifier,
handler );
return artifact; return artifact;
} }

View File

@ -65,7 +65,7 @@ public class DefaultArtifactHandler
{ {
if ( directory == null ) if ( directory == null )
{ {
directory = type + "s"; directory = getPackaging() + "s";
} }
return directory; return directory;
} }

View File

@ -16,25 +16,15 @@ package org.apache.maven.artifact.handler.manager;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.maven.artifact.handler.ArtifactHandler;
/** /**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$ * @version $Id$
*/ */
public class ArtifactHandlerNotFoundException public interface ArtifactHandlerManager
extends Exception
{ {
public ArtifactHandlerNotFoundException( String message ) String ROLE = ArtifactHandlerManager.class.getName();
{
super( message );
}
public ArtifactHandlerNotFoundException( Throwable cause ) ArtifactHandler getArtifactHandler( String type );
{ }
super( cause );
}
public ArtifactHandlerNotFoundException( String message, Throwable cause )
{
super( message, cause );
}
}

View File

@ -0,0 +1,54 @@
package org.apache.maven.artifact.handler.manager;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import java.util.Map;
import java.util.Set;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
* @version $Id: DefaultArtifactHandlerManager.java,v 1.1.1.1 2004/08/09
* 18:37:32 jvanzyl Exp $
*/
public class DefaultArtifactHandlerManager
implements ArtifactHandlerManager
{
private Map artifactHandlers;
private ArtifactRepositoryLayout artifactRepositoryLayout;
public ArtifactHandler getArtifactHandler( String type )
{
ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( type );
if ( handler == null )
{
handler = new DefaultArtifactHandler( type );
}
return handler;
}
public Set getHandlerTypes()
{
return artifactHandlers.keySet();
}
}

View File

@ -17,12 +17,9 @@ package org.apache.maven.artifact.installer;
*/ */
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.transform.ArtifactTransformation; import org.apache.maven.artifact.transform.ArtifactTransformation;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.FileUtils;
@ -36,8 +33,6 @@ public class DefaultArtifactInstaller
extends AbstractLogEnabled extends AbstractLogEnabled
implements ArtifactInstaller implements ArtifactInstaller
{ {
private ArtifactHandlerManager artifactHandlerManager;
private List artifactTransformations; private List artifactTransformations;
public void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository ) public void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository )
@ -45,15 +40,8 @@ public class DefaultArtifactInstaller
{ {
File source = null; File source = null;
try String extension = artifact.getArtifactHandler().getExtension();
{ source = new File( basedir, finalName + "." + extension );
String extension = artifactHandlerManager.getArtifactHandler( artifact.getType() ).getExtension();
source = new File( basedir, finalName + "." + extension );
}
catch ( ArtifactHandlerNotFoundException e )
{
throw new ArtifactInstallationException( "Error installing artifact: ", e );
}
install( source, artifact, localRepository ); install( source, artifact, localRepository );
} }
@ -94,10 +82,6 @@ public class DefaultArtifactInstaller
{ {
throw new ArtifactInstallationException( "Error installing artifact: ", e ); throw new ArtifactInstallationException( "Error installing artifact: ", e );
} }
catch ( ArtifactPathFormatException e )
{
throw new ArtifactInstallationException( "Error installing artifact: ", e );
}
catch ( ArtifactMetadataRetrievalException e ) catch ( ArtifactMetadataRetrievalException e )
{ {
throw new ArtifactInstallationException( "Error installing artifact: ", e ); throw new ArtifactInstallationException( "Error installing artifact: ", e );

View File

@ -18,10 +18,8 @@ package org.apache.maven.artifact.manager;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ChecksumFailedException; import org.apache.maven.artifact.ChecksumFailedException;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.ConnectionException;
import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.TransferFailedException;
@ -68,8 +66,6 @@ public class DefaultWagonManager
private TransferListener downloadMonitor; private TransferListener downloadMonitor;
private ArtifactHandlerManager artifactHandlerManager;
public Wagon getWagon( String protocol ) public Wagon getWagon( String protocol )
throws UnsupportedProtocolException throws UnsupportedProtocolException
{ {
@ -91,28 +87,14 @@ public class DefaultWagonManager
public void putArtifact( File source, Artifact artifact, ArtifactRepository repository ) public void putArtifact( File source, Artifact artifact, ArtifactRepository repository )
throws TransferFailedException throws TransferFailedException
{ {
try putRemoteFile( repository, source, repository.pathOf( artifact ), downloadMonitor );
{
putRemoteFile( repository, source, repository.pathOf( artifact ), downloadMonitor );
}
catch ( ArtifactPathFormatException e )
{
throw new TransferFailedException( "Path of artifact could not be determined: ", e );
}
} }
public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository ) public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository )
throws TransferFailedException throws TransferFailedException
{ {
try getLogger().info( "Uploading " + artifactMetadata );
{ putRemoteFile( repository, source, repository.pathOfMetadata( artifactMetadata ), null );
getLogger().info( "Uploading " + artifactMetadata );
putRemoteFile( repository, source, repository.pathOfMetadata( artifactMetadata ), null );
}
catch ( ArtifactPathFormatException e )
{
throw new TransferFailedException( "Path of artifact could not be determined: ", e );
}
} }
private void putRemoteFile( ArtifactRepository repository, File source, String remotePath, private void putRemoteFile( ArtifactRepository repository, File source, String remotePath,
@ -244,16 +226,7 @@ public class DefaultWagonManager
public void getArtifact( Artifact artifact, ArtifactRepository repository, File destination ) public void getArtifact( Artifact artifact, ArtifactRepository repository, File destination )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
String remotePath = null; String remotePath = repository.pathOf( artifact );
try
{
remotePath = repository.pathOf( artifact );
}
catch ( ArtifactPathFormatException e )
{
// TODO may be more appropriate to propogate the APFE
throw new TransferFailedException( "Failed to determine path for artifact", e );
}
getRemoteFile( repository, destination, remotePath, downloadMonitor ); getRemoteFile( repository, destination, remotePath, downloadMonitor );
} }
@ -261,16 +234,7 @@ public class DefaultWagonManager
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination ) public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination )
throws TransferFailedException, ResourceDoesNotExistException throws TransferFailedException, ResourceDoesNotExistException
{ {
String remotePath; String remotePath = remoteRepository.pathOfMetadata( metadata );
try
{
remotePath = remoteRepository.pathOfMetadata( metadata );
}
catch ( ArtifactPathFormatException e )
{
// TODO may be more appropriate to propogate APFE
throw new TransferFailedException( "Failed to determine path for artifact", e );
}
getLogger().info( "Retrieving " + metadata ); getLogger().info( "Retrieving " + metadata );
getRemoteFile( remoteRepository, destination, remotePath, null ); getRemoteFile( remoteRepository, destination, remotePath, null );

View File

@ -19,7 +19,6 @@ package org.apache.maven.artifact.metadata;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.TransferFailedException;
import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.FileUtils;
@ -48,7 +47,6 @@ public abstract class AbstractVersionArtifactMetadata
} }
protected File getLocalRepositoryLocation( ArtifactRepository localRepository ) protected File getLocalRepositoryLocation( ArtifactRepository localRepository )
throws ArtifactPathFormatException
{ {
return new File( localRepository.getBasedir(), localRepository.pathOfMetadata( this ) ); return new File( localRepository.getBasedir(), localRepository.pathOfMetadata( this ) );
} }
@ -75,7 +73,7 @@ public abstract class AbstractVersionArtifactMetadata
} }
public void readFromLocalRepository( ArtifactRepository localRepository ) public void readFromLocalRepository( ArtifactRepository localRepository )
throws ArtifactPathFormatException, IOException throws IOException
{ {
File f = getLocalRepositoryLocation( localRepository ); File f = getLocalRepositoryLocation( localRepository );
if ( f.exists() ) if ( f.exists() )
@ -123,9 +121,5 @@ public abstract class AbstractVersionArtifactMetadata
{ {
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e ); throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
} }
catch ( ArtifactPathFormatException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
}
} }
} }

View File

@ -18,7 +18,6 @@ package org.apache.maven.artifact.repository;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.wagon.repository.Repository; import org.apache.maven.wagon.repository.Repository;
@ -59,13 +58,11 @@ public class ArtifactRepository
} }
public String pathOf( Artifact artifact ) public String pathOf( Artifact artifact )
throws ArtifactPathFormatException
{ {
return layout.pathOf( artifact ); return layout.pathOf( artifact );
} }
public String pathOfMetadata( ArtifactMetadata artifactMetadata ) public String pathOfMetadata( ArtifactMetadata artifactMetadata )
throws ArtifactPathFormatException
{ {
return layout.pathOfMetadata( artifactMetadata ); return layout.pathOfMetadata( artifactMetadata );
} }

View File

@ -1,31 +0,0 @@
package org.apache.maven.artifact.repository.layout;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author jdcasey
*/
public class ArtifactPathFormatException
extends Exception
{
public ArtifactPathFormatException( String message, Throwable cause )
{
super( message, cause );
}
}

View File

@ -27,9 +27,7 @@ public interface ArtifactRepositoryLayout
String ROLE = ArtifactRepositoryLayout.class.getName(); String ROLE = ArtifactRepositoryLayout.class.getName();
String pathOf( Artifact artifact ) String pathOf( Artifact artifact );
throws ArtifactPathFormatException;
String pathOfMetadata( ArtifactMetadata metadata ) String pathOfMetadata( ArtifactMetadata metadata );
throws ArtifactPathFormatException;
} }

View File

@ -18,8 +18,6 @@ package org.apache.maven.artifact.repository.layout;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.transform.ReleaseArtifactTransformation; import org.apache.maven.artifact.transform.ReleaseArtifactTransformation;
@ -30,31 +28,15 @@ public class DefaultRepositoryLayout
implements ArtifactRepositoryLayout implements ArtifactRepositoryLayout
{ {
private ArtifactHandlerManager artifactHandlerManager;
public String pathOf( Artifact artifact ) public String pathOf( Artifact artifact )
throws ArtifactPathFormatException
{ {
ArtifactHandler artifactHandler = null; ArtifactHandler artifactHandler = artifact.getArtifactHandler();
try
{
// TODO: this is a poor excuse to have this method throwing an exception. Validate the artifact first, perhaps associate the handler with it
artifactHandler = artifactHandlerManager.getArtifactHandler( artifact.getType() );
}
catch ( ArtifactHandlerNotFoundException e )
{
throw new ArtifactPathFormatException( "Cannot find ArtifactHandler for artifact: \'" + artifact.getId() +
"\'.", e );
}
StringBuffer path = new StringBuffer(); StringBuffer path = new StringBuffer();
path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' ); path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' );
// if ( !artifact.getType().equals( "pom" ) )
// {
path.append( artifact.getArtifactId() ).append( '/' ); path.append( artifact.getArtifactId() ).append( '/' );
path.append( artifact.getBaseVersion() ).append( '/' ); path.append( artifact.getBaseVersion() ).append( '/' );
// }
path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
if ( artifact.hasClassifier() ) if ( artifact.hasClassifier() )
@ -71,19 +53,15 @@ public class DefaultRepositoryLayout
} }
public String pathOfMetadata( ArtifactMetadata metadata ) public String pathOfMetadata( ArtifactMetadata metadata )
throws ArtifactPathFormatException
{ {
StringBuffer path = new StringBuffer(); StringBuffer path = new StringBuffer();
path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' ); path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' );
// if ( !artifact.getType().equals( "pom" ) )
// {
path.append( metadata.getArtifactId() ).append( '/' ); path.append( metadata.getArtifactId() ).append( '/' );
if ( !metadata.getBaseVersion().equals( ReleaseArtifactTransformation.RELEASE_VERSION ) ) if ( !metadata.getBaseVersion().equals( ReleaseArtifactTransformation.RELEASE_VERSION ) )
{ {
path.append( metadata.getBaseVersion() ).append( '/' ); path.append( metadata.getBaseVersion() ).append( '/' );
} }
// }
path.append( metadata.getFilename() ); path.append( metadata.getFilename() );

View File

@ -18,8 +18,6 @@ package org.apache.maven.artifact.repository.layout;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
/** /**
@ -28,23 +26,9 @@ import org.apache.maven.artifact.metadata.ArtifactMetadata;
public class LegacyRepositoryLayout public class LegacyRepositoryLayout
implements ArtifactRepositoryLayout implements ArtifactRepositoryLayout
{ {
private ArtifactHandlerManager artifactHandlerManager;
public String pathOf( Artifact artifact ) public String pathOf( Artifact artifact )
throws ArtifactPathFormatException
{ {
ArtifactHandler artifactHandler = null; ArtifactHandler artifactHandler = artifact.getArtifactHandler();
try
{
// TODO: this is a poor excuse to have this method throwing an exception. Validate the artifact first, perhaps associate the handler with it
artifactHandler = artifactHandlerManager.getArtifactHandler( artifact.getType() );
}
catch ( ArtifactHandlerNotFoundException e )
{
throw new ArtifactPathFormatException( "Cannot find ArtifactHandler for artifact: \'" + artifact.getId() +
"\'.", e );
}
StringBuffer path = new StringBuffer(); StringBuffer path = new StringBuffer();
@ -66,7 +50,6 @@ public class LegacyRepositoryLayout
} }
public String pathOfMetadata( ArtifactMetadata metadata ) public String pathOfMetadata( ArtifactMetadata metadata )
throws ArtifactPathFormatException
{ {
StringBuffer path = new StringBuffer(); StringBuffer path = new StringBuffer();

View File

@ -18,13 +18,11 @@ package org.apache.maven.artifact.resolver;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.transform.ArtifactTransformation; import org.apache.maven.artifact.transform.ArtifactTransformation;
import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.ResourceDoesNotExistException;
@ -54,11 +52,9 @@ public class DefaultArtifactResolver
private WagonManager wagonManager; private WagonManager wagonManager;
private ArtifactHandlerManager artifactHandlerManager;
private List artifactTransformations; private List artifactTransformations;
private ArtifactFactory artifactFactory; protected ArtifactFactory artifactFactory;
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Implementation // Implementation
@ -82,16 +78,7 @@ public class DefaultArtifactResolver
logger.debug( "Resolving: " + artifact.getId() + " from:\n" + "{localRepository: " + localRepository + "}\n" + logger.debug( "Resolving: " + artifact.getId() + " from:\n" + "{localRepository: " + localRepository + "}\n" +
"{remoteRepositories: " + remoteRepositories + "}" ); "{remoteRepositories: " + remoteRepositories + "}" );
String localPath; String localPath = localRepository.pathOf( artifact );
try
{
localPath = localRepository.pathOf( artifact );
}
catch ( ArtifactPathFormatException e )
{
throw new ArtifactResolutionException( e.getMessage(), e );
}
artifact.setFile( new File( localRepository.getBasedir(), localPath ) ); artifact.setFile( new File( localRepository.getBasedir(), localPath ) );
@ -209,7 +196,7 @@ public class DefaultArtifactResolver
{ {
Artifact newArtifact = (Artifact) i.next(); Artifact newArtifact = (Artifact) i.next();
String id = newArtifact.getConflictId(); String id = newArtifact.getDependencyConflictId();
if ( resolvedArtifacts.containsKey( id ) ) if ( resolvedArtifacts.containsKey( id ) )
{ {
@ -247,7 +234,7 @@ public class DefaultArtifactResolver
knownArtifact.getArtifactId(), knownArtifact.getArtifactId(),
knownVersion, newArtifact.getScope(), knownVersion, newArtifact.getScope(),
knownArtifact.getType() ); knownArtifact.getType() );
resolvedArtifacts.put( artifact.getConflictId(), artifact ); resolvedArtifacts.put( artifact.getDependencyConflictId(), artifact );
} }
} }
else else
@ -304,7 +291,7 @@ public class DefaultArtifactResolver
{ {
List conflicts; List conflicts;
conflicts = (List) result.getConflicts().get( newArtifact.getConflictId() ); conflicts = (List) result.getConflicts().get( newArtifact.getDependencyConflictId() );
if ( conflicts == null ) if ( conflicts == null )
{ {
@ -312,7 +299,7 @@ public class DefaultArtifactResolver
conflicts.add( knownArtifact ); conflicts.add( knownArtifact );
result.getConflicts().put( newArtifact.getConflictId(), conflicts ); result.getConflicts().put( newArtifact.getDependencyConflictId(), conflicts );
} }
conflicts.add( newArtifact ); conflicts.add( newArtifact );

View File

@ -21,7 +21,6 @@ import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.VersionArtifactMetadata; import org.apache.maven.artifact.metadata.VersionArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.io.IOException; import java.io.IOException;
@ -57,10 +56,6 @@ public abstract class AbstractVersionTransformation
{ {
localMetadata = readFromLocalRepository( artifact, localRepository ); localMetadata = readFromLocalRepository( artifact, localRepository );
} }
catch ( ArtifactPathFormatException e )
{
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
}
catch ( IOException e ) catch ( IOException e )
{ {
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e ); throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
@ -170,7 +165,7 @@ public abstract class AbstractVersionTransformation
protected abstract VersionArtifactMetadata readFromLocalRepository( Artifact artifact, protected abstract VersionArtifactMetadata readFromLocalRepository( Artifact artifact,
ArtifactRepository localRepository ) ArtifactRepository localRepository )
throws IOException, ArtifactPathFormatException; throws IOException;
private Date getMidnightBoundary() private Date getMidnightBoundary()
{ {

View File

@ -22,7 +22,6 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ReleaseArtifactMetadata; import org.apache.maven.artifact.metadata.ReleaseArtifactMetadata;
import org.apache.maven.artifact.metadata.VersionArtifactMetadata; import org.apache.maven.artifact.metadata.VersionArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.ResourceDoesNotExistException;
import java.io.IOException; import java.io.IOException;
@ -92,7 +91,7 @@ public class ReleaseArtifactTransformation
} }
protected VersionArtifactMetadata readFromLocalRepository( Artifact artifact, ArtifactRepository localRepository ) protected VersionArtifactMetadata readFromLocalRepository( Artifact artifact, ArtifactRepository localRepository )
throws IOException, ArtifactPathFormatException throws IOException
{ {
AbstractVersionArtifactMetadata metadata = new ReleaseArtifactMetadata( artifact ); AbstractVersionArtifactMetadata metadata = new ReleaseArtifactMetadata( artifact );
metadata.readFromLocalRepository( localRepository ); metadata.readFromLocalRepository( localRepository );

View File

@ -21,7 +21,6 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata; import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
import org.apache.maven.artifact.metadata.VersionArtifactMetadata; import org.apache.maven.artifact.metadata.VersionArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.ResourceDoesNotExistException;
import java.io.IOException; import java.io.IOException;
@ -115,7 +114,7 @@ public class SnapshotTransformation
} }
protected VersionArtifactMetadata readFromLocalRepository( Artifact artifact, ArtifactRepository localRepository ) protected VersionArtifactMetadata readFromLocalRepository( Artifact artifact, ArtifactRepository localRepository )
throws IOException, ArtifactPathFormatException throws IOException
{ {
SnapshotArtifactMetadata metadata = new SnapshotArtifactMetadata( artifact ); SnapshotArtifactMetadata metadata = new SnapshotArtifactMetadata( artifact );
metadata.readFromLocalRepository( localRepository ); metadata.readFromLocalRepository( localRepository );

View File

@ -8,11 +8,6 @@
<component> <component>
<role>org.apache.maven.artifact.manager.WagonManager</role> <role>org.apache.maven.artifact.manager.WagonManager</role>
<implementation>org.apache.maven.artifact.manager.DefaultWagonManager</implementation> <implementation>org.apache.maven.artifact.manager.DefaultWagonManager</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component> </component>
<!-- <!--
@ -53,9 +48,6 @@
<requirement> <requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role> <role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement> </requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role> <role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
<field-name>artifactTransformations</field-name> <field-name>artifactTransformations</field-name>
@ -75,9 +67,6 @@
<role>org.apache.maven.artifact.installer.ArtifactInstaller</role> <role>org.apache.maven.artifact.installer.ArtifactInstaller</role>
<implementation>org.apache.maven.artifact.installer.DefaultArtifactInstaller</implementation> <implementation>org.apache.maven.artifact.installer.DefaultArtifactInstaller</implementation>
<requirements> <requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role> <role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
<field-name>artifactTransformations</field-name> <field-name>artifactTransformations</field-name>
@ -97,9 +86,6 @@
<requirement> <requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role> <role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement> </requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role> <role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
<field-name>artifactTransformations</field-name> <field-name>artifactTransformations</field-name>
@ -111,22 +97,12 @@
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role> <role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
<role-hint>default</role-hint> <role-hint>default</role-hint>
<implementation>org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout</implementation> <implementation>org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component> </component>
<component> <component>
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role> <role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
<role-hint>legacy</role-hint> <role-hint>legacy</role-hint>
<implementation>org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout</implementation> <implementation>org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component> </component>
<!-- <!--
@ -202,9 +178,26 @@
</configuration> </configuration>
</component> </component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>ejb-client</role-hint>
<implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
<configuration>
<type>ejb-client</type>
<extension>jar</extension>
<packaging>ejb</packaging>
<classifier>client</classifier>
</configuration>
</component>
<component> <component>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role> <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
<implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation> <implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component> </component>
<component> <component>

View File

@ -16,9 +16,9 @@
package org.apache.maven.artifact; package org.apache.maven.artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
import java.io.File; import java.io.File;
@ -36,16 +36,6 @@ import java.util.List;
public abstract class ArtifactComponentTestCase public abstract class ArtifactComponentTestCase
extends PlexusTestCase extends PlexusTestCase
{ {
protected ArtifactHandlerManager artifactHandlerManager;
protected void setUp()
throws Exception
{
super.setUp();
artifactHandlerManager = (ArtifactHandlerManager) lookup( ArtifactHandlerManager.ROLE );
}
protected abstract String component(); protected abstract String component();
/** /**
@ -252,12 +242,14 @@ public abstract class ArtifactComponentTestCase
protected Artifact createArtifact( String artifactId, String version, String type ) protected Artifact createArtifact( String artifactId, String version, String type )
{ {
return new DefaultArtifact( "org.apache.maven", artifactId, version, type ); // TODO: fix handler instantiation
return new DefaultArtifact( "org.apache.maven", artifactId, version, null, type, null, new DefaultArtifactHandler( type ) );
} }
protected Artifact createArtifact( String groupId, String artifactId, String version, String type ) protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
{ {
return new DefaultArtifact( groupId, artifactId, version, Artifact.SCOPE_COMPILE, type ); // TODO: fix handler instantiation
return new DefaultArtifact( groupId, artifactId, version, Artifact.SCOPE_COMPILE, type, null, new DefaultArtifactHandler( type ) );
} }
protected void deleteLocalArtifact( Artifact artifact ) protected void deleteLocalArtifact( Artifact artifact )

View File

@ -10,6 +10,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId> <artifactId>maven-ejb-plugin</artifactId>
<configuration><generateClient>true</generateClient></configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

View File

@ -91,8 +91,6 @@ public class DefaultPluginManager
protected PathTranslator pathTranslator; protected PathTranslator pathTranslator;
private ArtifactFactory artifactFactory;
private Set pluginsInProcess = new HashSet(); private Set pluginsInProcess = new HashSet();
private Log mojoLogger; private Log mojoLogger;
@ -178,7 +176,7 @@ public class DefaultPluginManager
} }
public PluginDescriptor verifyPlugin( String groupId, String artifactId, String version, MavenProject project, public PluginDescriptor verifyPlugin( String groupId, String artifactId, String version, MavenProject project,
Settings settings, ArtifactRepository localRepository ) Settings settings, ArtifactRepository localRepository )
throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException
{ {
String pluginKey = groupId + ":" + artifactId; String pluginKey = groupId + ":" + artifactId;
@ -193,7 +191,8 @@ public class DefaultPluginManager
{ {
pluginVersionManager = (PluginVersionManager) container.lookup( PluginVersionManager.ROLE ); pluginVersionManager = (PluginVersionManager) container.lookup( PluginVersionManager.ROLE );
version = pluginVersionManager.resolvePluginVersion( groupId, artifactId, project, settings, localRepository ); version = pluginVersionManager.resolvePluginVersion( groupId, artifactId, project, settings,
localRepository );
} }
catch ( ComponentLookupException e ) catch ( ComponentLookupException e )
{ {
@ -210,8 +209,11 @@ public class DefaultPluginManager
// TODO: this might result in an artifact "RELEASE" being resolved continuously // TODO: this might result in an artifact "RELEASE" being resolved continuously
if ( !isPluginInstalled( pluginKey ) ) if ( !isPluginInstalled( pluginKey ) )
{ {
ArtifactFactory artifactFactory = null;
try try
{ {
artifactFactory = (ArtifactFactory) container.lookup( ArtifactFactory.ROLE );
Artifact pluginArtifact = artifactFactory.createArtifact( groupId, artifactId, version, Artifact pluginArtifact = artifactFactory.createArtifact( groupId, artifactId, version,
Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME,
MojoDescriptor.MAVEN_PLUGIN, null ); MojoDescriptor.MAVEN_PLUGIN, null );
@ -223,14 +225,15 @@ public class DefaultPluginManager
catch ( PlexusContainerException e ) catch ( PlexusContainerException e )
{ {
throw new PluginManagerException( throw new PluginManagerException(
"Error occurred in the artifact container attempting to download plugin " "Error occurred in the artifact container attempting to download plugin " + groupId + ":" +
+ groupId + ":" + artifactId, e ); artifactId, e );
} }
catch ( ArtifactResolutionException e ) catch ( ArtifactResolutionException e )
{ {
if ( ( groupId == null || artifactId == null || version == null || ( groupId.equals( e.getGroupId() ) if (
&& artifactId.equals( e.getArtifactId() ) && version.equals( e.getVersion() ) ) ) ( groupId == null || artifactId == null || version == null ||
&& "maven-plugin".equals( e.getType() ) ) ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) &&
version.equals( e.getVersion() ) ) ) && "maven-plugin".equals( e.getType() ) )
{ {
throw new PluginNotFoundException( e ); throw new PluginNotFoundException( e );
} }
@ -241,31 +244,41 @@ public class DefaultPluginManager
} }
catch ( ComponentLookupException e ) catch ( ComponentLookupException e )
{ {
throw new PluginManagerException( "Internal configuration error while retrieving " + groupId + ":" throw new PluginManagerException(
+ artifactId, e ); "Internal configuration error while retrieving " + groupId + ":" + artifactId, e );
}
finally
{
if ( artifactFactory != null )
{
releaseComponent( artifactFactory );
}
} }
} }
return getPluginDescriptor( groupId, artifactId, version ); return getPluginDescriptor( groupId, artifactId, version );
} }
protected void addPlugin( String pluginKey, Artifact pluginArtifact, MavenProject project, protected void addPlugin( String pluginKey, Artifact pluginArtifact, MavenProject project,
ArtifactRepository localRepository ) ArtifactRepository localRepository )
throws ArtifactResolutionException, ComponentLookupException, PlexusContainerException throws ArtifactResolutionException, ComponentLookupException, PlexusContainerException
{ {
ArtifactResolver artifactResolver = null; ArtifactResolver artifactResolver = null;
MavenProjectBuilder mavenProjectBuilder = null; MavenProjectBuilder mavenProjectBuilder = null;
ArtifactFactory artifactFactory = null;
try try
{ {
artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE ); artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE ); mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE );
artifactFactory = (ArtifactFactory) container.lookup( ArtifactFactory.ROLE );
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder ); MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
artifactFactory );
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections
.singleton( pluginArtifact ), project.getRemoteArtifactRepositories(), localRepository, metadataSource, .singleton( pluginArtifact ), project.getRemoteArtifactRepositories(), localRepository, metadataSource,
artifactFilter ); artifactFilter );
Map resolved = result.getArtifacts(); Map resolved = result.getArtifacts();
@ -278,7 +291,8 @@ public class DefaultPluginManager
files.add( artifact.getFile() ); files.add( artifact.getFile() );
} }
container.createChildContainer( pluginKey, files, Collections.EMPTY_MAP, Collections.singletonList( this ) ); container.createChildContainer( pluginKey, files, Collections.EMPTY_MAP,
Collections.singletonList( this ) );
// this plugin's descriptor should have been discovered by now, so we should be able to circle // this plugin's descriptor should have been discovered by now, so we should be able to circle
// around and set the artifacts. // around and set the artifacts.
@ -288,7 +302,7 @@ public class DefaultPluginManager
ArtifactResolutionResult distroProvidedResult = artifactResolver.resolveTransitively( Collections ArtifactResolutionResult distroProvidedResult = artifactResolver.resolveTransitively( Collections
.singleton( pluginArtifact ), project.getRemoteArtifactRepositories(), localRepository, metadataSource, .singleton( pluginArtifact ), project.getRemoteArtifactRepositories(), localRepository, metadataSource,
distroProvidedFilter ); distroProvidedFilter );
Map distroProvided = distroProvidedResult.getArtifacts(); Map distroProvided = distroProvidedResult.getArtifacts();
@ -301,6 +315,10 @@ public class DefaultPluginManager
} }
finally finally
{ {
if ( artifactFactory != null )
{
releaseComponent( artifactFactory );
}
if ( artifactResolver != null ) if ( artifactResolver != null )
{ {
releaseComponent( artifactResolver ); releaseComponent( artifactResolver );
@ -340,14 +358,16 @@ public class DefaultPluginManager
ArtifactResolver artifactResolver = null; ArtifactResolver artifactResolver = null;
MavenProjectBuilder mavenProjectBuilder = null; MavenProjectBuilder mavenProjectBuilder = null;
ArtifactFactory artifactFactory = null;
try try
{ {
artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE ); artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE ); mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE );
artifactFactory = (ArtifactFactory) container.lookup( ArtifactFactory.ROLE );
resolveTransitiveDependencies( session, artifactResolver, mavenProjectBuilder, mojoDescriptor resolveTransitiveDependencies( session, artifactResolver, mavenProjectBuilder, mojoDescriptor
.isDependencyResolutionRequired() ); .isDependencyResolutionRequired(), artifactFactory );
downloadDependencies( session, artifactResolver ); downloadDependencies( session, artifactResolver );
} }
catch ( ComponentLookupException e ) catch ( ComponentLookupException e )
@ -364,6 +384,10 @@ public class DefaultPluginManager
{ {
releaseComponent( mavenProjectBuilder ); releaseComponent( mavenProjectBuilder );
} }
if ( artifactFactory != null )
{
releaseComponent( artifactFactory );
}
} }
} }
@ -412,8 +436,7 @@ public class DefaultPluginManager
// PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration, // PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration,
// mojoDescriptor.getConfiguration() ); // mojoDescriptor.getConfiguration() );
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, pluginDescriptor,
pluginDescriptor,
pathTranslator, pathTranslator,
getLogger() ); getLogger() );
@ -475,7 +498,7 @@ public class DefaultPluginManager
} }
private void checkRequiredParameters( MojoDescriptor goal, PlexusConfiguration configuration, private void checkRequiredParameters( MojoDescriptor goal, PlexusConfiguration configuration,
ExpressionEvaluator expressionEvaluator, Mojo plugin ) ExpressionEvaluator expressionEvaluator, Mojo plugin )
throws PluginConfigurationException throws PluginConfigurationException
{ {
// TODO: this should be built in to the configurator, as we presently double process the expressions // TODO: this should be built in to the configurator, as we presently double process the expressions
@ -548,8 +571,8 @@ public class DefaultPluginManager
if ( fieldValue != null ) if ( fieldValue != null )
{ {
getLogger().warn( getLogger().warn(
"DEPRECATED: using default-value to set the default value of field '" "DEPRECATED: using default-value to set the default value of field '" +
+ parameter.getName() + "'" ); parameter.getName() + "'" );
} }
} }
catch ( NoSuchFieldException e ) catch ( NoSuchFieldException e )
@ -665,7 +688,7 @@ public class DefaultPluginManager
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
private void populatePluginFields( Mojo plugin, MojoDescriptor mojoDescriptor, PlexusConfiguration configuration, private void populatePluginFields( Mojo plugin, MojoDescriptor mojoDescriptor, PlexusConfiguration configuration,
PlexusContainer pluginContainer, ExpressionEvaluator expressionEvaluator ) PlexusContainer pluginContainer, ExpressionEvaluator expressionEvaluator )
throws PluginConfigurationException throws PluginConfigurationException
{ {
ComponentConfigurator configurator = null; ComponentConfigurator configurator = null;
@ -695,8 +718,7 @@ public class DefaultPluginManager
catch ( ComponentLookupException e ) catch ( ComponentLookupException e )
{ {
throw new PluginConfigurationException( throw new PluginConfigurationException(
"Unable to retrieve component configurator for plugin configuration", "Unable to retrieve component configurator for plugin configuration", e );
e );
} }
finally finally
{ {
@ -736,7 +758,7 @@ public class DefaultPluginManager
} }
public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, Parameter parameter, public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, Parameter parameter,
String expression ) String expression )
{ {
StringBuffer message = new StringBuffer(); StringBuffer message = new StringBuffer();
@ -792,22 +814,8 @@ public class DefaultPluginManager
public void initialize() public void initialize()
{ {
// TODO: configure this from bootstrap or scan lib // TODO: configure this from bootstrap or scan lib
artifactFilter = new ExclusionSetFilter( new String[] { artifactFilter = new ExclusionSetFilter(
"classworlds", new String[]{"classworlds", "maven-artifact", "maven-core", "maven-model", "maven-monitor", "maven-plugin-api", "maven-plugin-descriptor", "maven-project", "maven-settings", "plexus-container-default", "plexus-utils", "wagon-provider-api", "wagon-ssh", "wagon-http-lightweight", "wagon-file"} );
"maven-artifact",
"maven-core",
"maven-model",
"maven-monitor",
"maven-plugin-api",
"maven-plugin-descriptor",
"maven-project",
"maven-settings",
"plexus-container-default",
"plexus-utils",
"wagon-provider-api",
"wagon-ssh",
"wagon-http-lightweight",
"wagon-file" } );
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -815,12 +823,14 @@ public class DefaultPluginManager
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver, private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver,
MavenProjectBuilder mavenProjectBuilder, String scope ) MavenProjectBuilder mavenProjectBuilder, String scope,
ArtifactFactory artifactFactory )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
MavenProject project = context.getProject(); MavenProject project = context.getProject();
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, mavenProjectBuilder ); MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
artifactFactory );
ArtifactFilter filter = new ScopeArtifactFilter( scope ); ArtifactFilter filter = new ScopeArtifactFilter( scope );

View File

@ -17,9 +17,6 @@
<requirement> <requirement>
<role>org.apache.maven.project.path.PathTranslator</role> <role>org.apache.maven.project.path.PathTranslator</role>
</requirement> </requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
</requirements> </requirements>
</component> </component>
@ -28,11 +25,5 @@
<role>org.apache.maven.project.path.PathTranslator</role> <role>org.apache.maven.project.path.PathTranslator</role>
<implementation>org.apache.maven.project.path.DefaultPathTranslator</implementation> <implementation>org.apache.maven.project.path.DefaultPathTranslator</implementation>
</component> </component>
<!-- Duplicated from Maven artifact as it is used in the plugin manager -->
<component>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
<implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation>
</component>
</components> </components>
</plexus> </plexus>

View File

@ -102,7 +102,7 @@ public class PluginParameterExpressionEvaluatorTest
{ {
PluginDescriptor pd = new PluginDescriptor(); PluginDescriptor pd = new PluginDescriptor();
Artifact artifact = new DefaultArtifact( "testGroup", "testArtifact", "1.0", Artifact.SCOPE_COMPILE, "jar" ); Artifact artifact = new DefaultArtifact( "testGroup", "testArtifact", "1.0", Artifact.SCOPE_COMPILE, "jar", null, null );
pd.setArtifacts( Collections.singletonList( artifact ) ); pd.setArtifacts( Collections.singletonList( artifact ) );

View File

@ -61,7 +61,7 @@ public class InvalidArtifactDiagnoserTest
try try
{ {
new DefaultArtifact( groupId, artifactId, version, type ); new DefaultArtifact( groupId, artifactId, version, null, type, null, null );
fail( "artifact creation did not fail; nothing to diagnose." ); fail( "artifact creation did not fail; nothing to diagnose." );
} }

View File

@ -18,6 +18,7 @@ package org.apache.maven.plugin.deploy;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.deployer.ArtifactDeployer; import org.apache.maven.artifact.deployer.ArtifactDeployer;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
@ -28,6 +29,8 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import java.io.File; import java.io.File;
import java.util.Iterator;
import java.util.List;
/** /**
* Deploys an artifact to remote repository. * Deploys an artifact to remote repository.
@ -110,6 +113,20 @@ public class DeployMojo
*/ */
private ArtifactRepository localRepository; private ArtifactRepository localRepository;
/**
* @parameter expression="${project.attachedArtifacts}
* @required
* @readonly
*/
private List attachedArtifacts;
/**
* @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
* @required
* @readonly
*/
private ArtifactFactory artifactFactory;
/** /**
* @parameter expression="${updateReleaseInfo}" * @parameter expression="${updateReleaseInfo}"
*/ */
@ -126,7 +143,9 @@ public class DeployMojo
} }
// Deploy the POM // Deploy the POM
Artifact artifact = new DefaultArtifact( groupId, artifactId, version, packaging ); // TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, packaging );
boolean isPomArtifact = "pom".equals( packaging ); boolean isPomArtifact = "pom".equals( packaging );
File pom = new File( parentDir, "pom.xml" ); File pom = new File( parentDir, "pom.xml" );
if ( !isPomArtifact ) if ( !isPomArtifact )
@ -152,7 +171,13 @@ public class DeployMojo
{ {
deployer.deploy( buildDirectory, finalName, artifact, deploymentRepository, localRepository ); deployer.deploy( buildDirectory, finalName, artifact, deploymentRepository, localRepository );
} }
}
for ( Iterator i = attachedArtifacts.iterator(); i.hasNext(); )
{
Artifact attached = (Artifact) i.next();
deployer.deploy( attached.getFile(), attached, deploymentRepository, localRepository );
}
}
catch ( ArtifactDeploymentException e ) catch ( ArtifactDeploymentException e )
{ {
// TODO: deployment exception that does not give a trace // TODO: deployment exception that does not give a trace

View File

@ -15,5 +15,10 @@
<artifactId>maven-archiver</artifactId> <artifactId>maven-archiver</artifactId>
<version>2.0-alpha-2</version> <version>2.0-alpha-2</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</model> </model>

View File

@ -18,6 +18,8 @@ package org.apache.maven.plugin.ejb;
import org.apache.maven.archiver.MavenArchiveConfiguration; import org.apache.maven.archiver.MavenArchiveConfiguration;
import org.apache.maven.archiver.MavenArchiver; import org.apache.maven.archiver.MavenArchiver;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
@ -37,12 +39,10 @@ public class EjbMojo
// TODO: will null work instead? // TODO: will null work instead?
private static final String[] DEFAULT_INCLUDES = new String[]{"**/**"}; private static final String[] DEFAULT_INCLUDES = new String[]{"**/**"};
private static final String[] DEFAULT_EXCLUDES = new String[]{"**/*Bean.class", "**/*CMP.class", private static final String[] DEFAULT_EXCLUDES = new String[]{"**/*Bean.class", "**/*CMP.class", "**/*Session.class", "**/package.html"};
"**/*Session.class", "**/package.html"};
/** /**
* @todo File instead * @todo File instead
*
* @parameter expression="${project.build.directory}" * @parameter expression="${project.build.directory}"
* @required * @required
* @readonly * @readonly
@ -63,7 +63,6 @@ public class EjbMojo
/** /**
* @todo boolean instead * @todo boolean instead
*
* @parameter * @parameter
*/ */
private String generateClient = Boolean.FALSE.toString(); private String generateClient = Boolean.FALSE.toString();
@ -75,6 +74,13 @@ public class EjbMojo
*/ */
private MavenProject project; private MavenProject project;
/**
* @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
* @required
* @readonly
*/
private ArtifactFactory artifactFactory;
/** /**
* @parameter * @parameter
*/ */
@ -121,6 +127,14 @@ public class EjbMojo
// create archive // create archive
clientArchiver.createArchive( project, archive ); clientArchiver.createArchive( project, archive );
Artifact artifact = artifactFactory.createArtifactWithClassifier( project.getGroupId(),
project.getArtifactId(),
project.getVersion(), null,
"ejb-client", "client" );
artifact.setFile( clientJarFile );
project.addAttachedArtifact( artifact );
} }
} }
catch ( Exception e ) catch ( Exception e )

View File

@ -18,6 +18,7 @@ package org.apache.maven.plugin.install;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.installer.ArtifactInstallationException;
import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoExecutionException;
@ -68,10 +69,18 @@ public class InstallFileMojo
*/ */
private File file; private File file;
/**
* @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
* @required
* @readonly
*/
private ArtifactFactory artifactFactory;
public void execute() public void execute()
throws MojoExecutionException throws MojoExecutionException
{ {
Artifact artifact = new DefaultArtifact( groupId, artifactId, version, packaging ); // TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, packaging );
try try
{ {

View File

@ -18,6 +18,7 @@ package org.apache.maven.plugin.install;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.installer.ArtifactInstallationException;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ReleaseArtifactMetadata; import org.apache.maven.artifact.metadata.ReleaseArtifactMetadata;
@ -25,6 +26,8 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import java.io.File; import java.io.File;
import java.util.Iterator;
import java.util.List;
/** /**
* Installs project's main artifact in local repository. * Installs project's main artifact in local repository.
@ -89,10 +92,25 @@ public class InstallMojo
*/ */
private boolean updateReleaseInfo = false; private boolean updateReleaseInfo = false;
/**
* @parameter expression="${project.attachedArtifacts}
* @required
* @readonly
*/
private List attachedArtifacts;
/**
* @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
* @required
* @readonly
*/
private ArtifactFactory artifactFactory;
public void execute() public void execute()
throws MojoExecutionException throws MojoExecutionException
{ {
Artifact artifact = new DefaultArtifact( groupId, artifactId, version, packaging ); // TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, packaging );
boolean isPomArtifact = "pom".equals( packaging ); boolean isPomArtifact = "pom".equals( packaging );
File pom = new File( basedir, "pom.xml" ); File pom = new File( basedir, "pom.xml" );
@ -120,6 +138,12 @@ public class InstallMojo
// TODO: would be something nice to get back from the project to get the full filename (the OGNL feedback thing) // TODO: would be something nice to get back from the project to get the full filename (the OGNL feedback thing)
installer.install( buildDirectory, finalName, artifact, localRepository ); installer.install( buildDirectory, finalName, artifact, localRepository );
} }
for ( Iterator i = attachedArtifacts.iterator(); i.hasNext(); )
{
Artifact attached = (Artifact) i.next();
installer.install( attached.getFile(), attached, localRepository );
}
} }
catch ( ArtifactInstallationException e ) catch ( ArtifactInstallationException e )
{ {

View File

@ -16,9 +16,8 @@ package org.apache.maven.test;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
@ -117,6 +116,11 @@ public class SurefirePlugin
*/ */
private Properties systemProperties; private Properties systemProperties;
/**
* @parameter expression="${plugin.artifacts}"
*/
private List pluginArtifacts;
public void execute() public void execute()
throws MojoExecutionException throws MojoExecutionException
{ {
@ -194,19 +198,10 @@ public class SurefirePlugin
} }
} }
// TODO: we should really just trust the plugin classloader? for ( Iterator i = pluginArtifacts.iterator(); i.hasNext(); )
try
{ {
DefaultArtifact artifact = new DefaultArtifact( "junit", "junit", "3.8.1", "jar" ); Artifact artifact = (Artifact) i.next();
File file = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ); surefireBooter.addClassPathUrl( artifact.getFile().getAbsolutePath() );
surefireBooter.addClassPathUrl( file.getAbsolutePath() );
artifact = new DefaultArtifact( "surefire", "surefire", "1.2", "jar" );
file = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
surefireBooter.addClassPathUrl( file.getAbsolutePath() );
}
catch ( ArtifactPathFormatException e )
{
throw new MojoExecutionException( "Error finding surefire JAR", e );
} }
surefireBooter.addClassPathUrl( new File( classesDirectory ).getPath() ); surefireBooter.addClassPathUrl( new File( classesDirectory ).getPath() );

View File

@ -169,6 +169,7 @@ public class WarMojo
Artifact artifact = (Artifact) iter.next(); Artifact artifact = (Artifact) iter.next();
// TODO: scope handler // TODO: scope handler
// TODO: use classpath instead
// Include runtime and compile time libraries // Include runtime and compile time libraries
if ( "jar".equals( artifact.getType() ) && !Artifact.SCOPE_TEST.equals( artifact.getScope() ) && !Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) ) if ( "jar".equals( artifact.getType() ) && !Artifact.SCOPE_TEST.equals( artifact.getScope() ) && !Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
{ {

View File

@ -471,7 +471,7 @@ public class DefaultMavenProjectBuilder
protected Set createArtifacts( List dependencies ) protected Set createArtifacts( List dependencies )
{ {
// TODO: merge with MavenMetadataSource properly // TODO: merge with MavenMetadataSource properly
return new MavenMetadataSource( artifactResolver, this ).createArtifacts( dependencies, null, null ); return new MavenMetadataSource( artifactResolver, this, artifactFactory ).createArtifacts( dependencies, null, null );
} }
protected Set createPluginArtifacts( List plugins ) protected Set createPluginArtifacts( List plugins )

View File

@ -79,11 +79,13 @@ public class MavenProject
private Set pluginArtifacts; private Set pluginArtifacts;
private List remoteArtifactRepositories; private List remoteArtifactRepositories;
private Properties profileProperties = new Properties(); private Properties profileProperties = new Properties();
private List collectedProjects = Collections.EMPTY_LIST; private List collectedProjects = Collections.EMPTY_LIST;
private List attachedArtifacts;
public MavenProject( Model model ) public MavenProject( Model model )
{ {
this.model = model; this.model = model;
@ -266,12 +268,12 @@ public class MavenProject
public List getCompileDependencies() public List getCompileDependencies()
{ {
Set artifacts = getArtifacts(); Set artifacts = getArtifacts();
if(artifacts == null || artifacts.isEmpty()) if ( artifacts == null || artifacts.isEmpty() )
{ {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
List list = new ArrayList( artifacts.size() ); List list = new ArrayList( artifacts.size() );
for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
@ -309,8 +311,8 @@ public class MavenProject
if ( isAddedToClasspath( a ) ) if ( isAddedToClasspath( a ) )
{ {
// TODO: let the scope handler deal with this // TODO: let the scope handler deal with this
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
|| Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
{ {
File file = a.getFile(); File file = a.getFile();
if ( file == null ) if ( file == null )
@ -327,12 +329,12 @@ public class MavenProject
public List getTestDependencies() public List getTestDependencies()
{ {
Set artifacts = getArtifacts(); Set artifacts = getArtifacts();
if(artifacts == null || artifacts.isEmpty()) if ( artifacts == null || artifacts.isEmpty() )
{ {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
List list = new ArrayList( artifacts.size() ); List list = new ArrayList( artifacts.size() );
for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
@ -340,8 +342,8 @@ public class MavenProject
Artifact a = (Artifact) i.next(); Artifact a = (Artifact) i.next();
// TODO: let the scope handler deal with this // TODO: let the scope handler deal with this
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
|| Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
{ {
Dependency dependency = new Dependency(); Dependency dependency = new Dependency();
@ -388,12 +390,12 @@ public class MavenProject
public List getRuntimeDependencies() public List getRuntimeDependencies()
{ {
Set artifacts = getArtifacts(); Set artifacts = getArtifacts();
if(artifacts == null || artifacts.isEmpty()) if ( artifacts == null || artifacts.isEmpty() )
{ {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
List list = new ArrayList( artifacts.size() ); List list = new ArrayList( artifacts.size() );
for ( Iterator i = artifacts.iterator(); i.hasNext(); ) for ( Iterator i = artifacts.iterator(); i.hasNext(); )
@ -422,7 +424,7 @@ public class MavenProject
String type = artifact.getType(); String type = artifact.getType();
// TODO: utilise type handler // TODO: utilise type handler
if ( "jar".equals( type ) || "ejb".equals( type ) ) if ( "jar".equals( type ) || "ejb".equals( type ) || "ejb-client".equals( type ) )
{ {
return true; return true;
} }
@ -715,6 +717,7 @@ public class MavenProject
return model.getReports().getPlugins(); return model.getReports().getPlugins();
} }
public List getBuildPlugins() public List getBuildPlugins()
{ {
if ( model.getBuild() == null ) if ( model.getBuild() == null )
@ -785,13 +788,14 @@ public class MavenProject
{ {
Artifact existing = (Artifact) artifacts.get( id ); Artifact existing = (Artifact) artifacts.get( id );
boolean updateScope = false; boolean updateScope = false;
if ( Artifact.SCOPE_RUNTIME.equals( a.getScope() ) && Artifact.SCOPE_TEST.equals( existing.getScope() ) ) if ( Artifact.SCOPE_RUNTIME.equals( a.getScope() ) &&
Artifact.SCOPE_TEST.equals( existing.getScope() ) )
{ {
updateScope = true; updateScope = true;
} }
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) &&
&& !Artifact.SCOPE_COMPILE.equals( existing.getScope() ) ) !Artifact.SCOPE_COMPILE.equals( existing.getScope() ) )
{ {
updateScope = true; updateScope = true;
} }
@ -800,10 +804,9 @@ public class MavenProject
{ {
// TODO: Artifact factory? // TODO: Artifact factory?
// TODO: [jc] Is this a better way to centralize artifact construction here? // TODO: [jc] Is this a better way to centralize artifact construction here?
Artifact artifact = artifactFactory.createArtifact( existing.getGroupId(), Artifact artifact = artifactFactory.createArtifact( existing.getGroupId(), existing.getArtifactId(),
existing.getArtifactId(),
existing.getVersion(), a.getScope(), existing existing.getVersion(), a.getScope(), existing
.getType() ); .getType() );
artifact.setFile( existing.getFile() ); artifact.setFile( existing.getFile() );
artifact.setBaseVersion( existing.getBaseVersion() ); artifact.setBaseVersion( existing.getBaseVersion() );
@ -905,10 +908,23 @@ public class MavenProject
{ {
this.activeProfiles.addAll( activeProfiles ); this.activeProfiles.addAll( activeProfiles );
} }
public List getActiveProfiles() public List getActiveProfiles()
{ {
return activeProfiles; return activeProfiles;
} }
public void addAttachedArtifact( Artifact artifact )
{
getAttachedArtifacts().add( artifact );
}
public List getAttachedArtifacts()
{
if ( attachedArtifacts == null )
{
attachedArtifacts = new ArrayList();
}
return attachedArtifacts;
}
} }

View File

@ -18,15 +18,14 @@ package org.apache.maven.project.artifact;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.factory.DefaultArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.Exclusion; import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
@ -58,24 +57,26 @@ public class MavenMetadataSource
private ArtifactResolver artifactResolver; private ArtifactResolver artifactResolver;
// TODO: configure? private ArtifactFactory artifactFactory;
protected ArtifactFactory artifactFactory = new DefaultArtifactFactory();
/** /**
* @todo remove. * @todo remove.
*/ */
private MavenXpp3Reader reader = new MavenXpp3Reader(); private MavenXpp3Reader reader = new MavenXpp3Reader();
public MavenMetadataSource( ArtifactResolver artifactResolver ) public MavenMetadataSource( ArtifactResolver artifactResolver, ArtifactFactory artifactFactory )
{ {
this.artifactResolver = artifactResolver; this.artifactResolver = artifactResolver;
this.mavenProjectBuilder = null; this.mavenProjectBuilder = null;
this.artifactFactory = artifactFactory;
} }
public MavenMetadataSource( ArtifactResolver artifactResolver, MavenProjectBuilder projectBuilder ) public MavenMetadataSource( ArtifactResolver artifactResolver, MavenProjectBuilder projectBuilder,
ArtifactFactory artifactFactory )
{ {
this.artifactResolver = artifactResolver; this.artifactResolver = artifactResolver;
this.mavenProjectBuilder = projectBuilder; this.mavenProjectBuilder = projectBuilder;
this.artifactFactory = artifactFactory;
} }
public Set retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) public Set retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
@ -180,7 +181,7 @@ public class MavenMetadataSource
artifact.setDependencyFilter( dependencyFilter ); artifact.setDependencyFilter( dependencyFilter );
projectArtifacts.add( artifact ); projectArtifacts.add( artifact );
} }
} }

View File

@ -21,7 +21,6 @@ import org.apache.maven.artifact.metadata.AbstractArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
@ -64,15 +63,7 @@ public class ProjectArtifactMetadata
public void storeInLocalRepository( ArtifactRepository localRepository ) public void storeInLocalRepository( ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException throws ArtifactMetadataRetrievalException
{ {
File destination; File destination = new File( localRepository.getBasedir(), localRepository.pathOfMetadata( this ) );
try
{
destination = new File( localRepository.getBasedir(), localRepository.pathOfMetadata( this ) );
}
catch ( ArtifactPathFormatException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to install POM", e );
}
destination.getParentFile().mkdirs(); destination.getParentFile().mkdirs();

View File

@ -18,6 +18,7 @@ package org.apache.maven.project;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
import java.io.File; import java.io.File;
@ -34,12 +35,15 @@ public abstract class MavenProjectTestCase
{ {
protected MavenProjectBuilder projectBuilder; protected MavenProjectBuilder projectBuilder;
private ArtifactFactory artifactFactory;
protected void setUp() protected void setUp()
throws Exception throws Exception
{ {
super.setUp(); super.setUp();
projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
artifactFactory = ( ArtifactFactory ) lookup( ArtifactFactory.ROLE );
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -94,7 +98,7 @@ public abstract class MavenProjectTestCase
throws Exception throws Exception
{ {
return projectBuilder.buildWithDependencies( pom, getLocalRepository(), return projectBuilder.buildWithDependencies( pom, getLocalRepository(),
new ProjectClasspathArtifactResolver.Source(), new ProjectClasspathArtifactResolver.Source( artifactFactory ),
Collections.EMPTY_LIST ); Collections.EMPTY_LIST );
} }

View File

@ -46,10 +46,11 @@ public class ProjectClasspathArtifactResolver
public static class Source public static class Source
implements ArtifactMetadataSource implements ArtifactMetadataSource
{ {
private ArtifactFactory artifactFactory = new DefaultArtifactFactory(); private ArtifactFactory artifactFactory;
public Source() public Source( ArtifactFactory artifactFactory )
{ {
this.artifactFactory = artifactFactory;
} }
public Set retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) public Set retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
@ -111,7 +112,7 @@ public class ProjectClasspathArtifactResolver
ArtifactMetadataSource source, ArtifactFilter filter ) ArtifactMetadataSource source, ArtifactFilter filter )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
return super.resolveTransitively( artifacts, remoteRepositories, localRepository, new Source(), filter ); return super.resolveTransitively( artifacts, remoteRepositories, localRepository, new Source( artifactFactory ), filter );
} }
public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories, public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
@ -119,7 +120,7 @@ public class ProjectClasspathArtifactResolver
ArtifactMetadataSource source ) ArtifactMetadataSource source )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
return super.resolveTransitively( artifacts, remoteRepositories, localRepository, new Source() ); return super.resolveTransitively( artifacts, remoteRepositories, localRepository, new Source( artifactFactory ) );
} }
public ArtifactResolutionResult resolveTransitively( Artifact artifact, List remoteRepositories, public ArtifactResolutionResult resolveTransitively( Artifact artifact, List remoteRepositories,
@ -127,6 +128,6 @@ public class ProjectClasspathArtifactResolver
ArtifactMetadataSource source ) ArtifactMetadataSource source )
throws ArtifactResolutionException throws ArtifactResolutionException
{ {
return super.resolveTransitively( artifact, remoteRepositories, localRepository, new Source() ); return super.resolveTransitively( artifact, remoteRepositories, localRepository, new Source( artifactFactory ) );
} }
} }

View File

@ -8,9 +8,6 @@
<requirement> <requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role> <role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement> </requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role> <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement> </requirement>
@ -24,9 +21,6 @@
<requirement> <requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role> <role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement> </requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role> <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement> </requirement>