mirror of https://github.com/apache/maven.git
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:
parent
3c2de055e8
commit
01e6c8daa6
|
@ -137,6 +137,7 @@ public class MavenArchiver
|
|||
for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) iter.next();
|
||||
// TODO: type of ejb should be added too?
|
||||
if ( "jar".equals( artifact.getType() ) )
|
||||
{
|
||||
if ( extensionsList.length() > 0 )
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.maven.artifact.ant;
|
|||
import org.apache.maven.artifact.manager.WagonManager;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
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.Server;
|
||||
import org.apache.maven.settings.Settings;
|
||||
|
@ -300,4 +302,13 @@ public abstract class AbstractArtifactTask
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ package org.apache.maven.artifact.ant;
|
|||
*/
|
||||
|
||||
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.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
|
@ -59,7 +59,8 @@ public class DependenciesTask
|
|||
|
||||
ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.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;
|
||||
|
||||
|
@ -118,15 +119,7 @@ public class DependenciesTask
|
|||
for ( Iterator i = result.getArtifacts().values().iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
String filename = null;
|
||||
try
|
||||
{
|
||||
filename = localRepo.pathOf( artifact );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new BuildException( "Unable to determine path to artifact: " + artifact, e );
|
||||
}
|
||||
String filename = localRepo.pathOf( artifact );
|
||||
|
||||
FileList.FileName file = new FileList.FileName();
|
||||
file.setName( filename );
|
||||
|
|
|
@ -66,8 +66,8 @@ public class DeployTask
|
|||
ArtifactRepository deploymentRepository = createRemoteArtifactRepository( remoteRepository );
|
||||
|
||||
// Deploy the POM
|
||||
Artifact artifact = new DefaultArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(),
|
||||
pom.getPackaging() );
|
||||
Artifact artifact = createArtifact( pom );
|
||||
|
||||
boolean isPomArtifact = "pom".equals( pom.getPackaging() );
|
||||
if ( !isPomArtifact )
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.maven.artifact.ant;
|
|||
*/
|
||||
|
||||
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.ArtifactInstaller;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
|
@ -47,8 +47,7 @@ public class InstallTask
|
|||
MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||
Pom pom = buildPom( builder, localRepo );
|
||||
|
||||
Artifact artifact = new DefaultArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(),
|
||||
pom.getPackaging() );
|
||||
Artifact artifact = createArtifact( pom );
|
||||
|
||||
boolean isPomArtifact = "pom".equals( pom.getPackaging() );
|
||||
if ( !isPomArtifact )
|
||||
|
@ -75,7 +74,7 @@ public class InstallTask
|
|||
throw new BuildException( "Error installing artifact", e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public File getFile()
|
||||
{
|
||||
return file;
|
||||
|
|
|
@ -10,11 +10,6 @@
|
|||
<component>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
<implementation>org.apache.maven.artifact.ant.CustomWagonManager</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<!--
|
||||
|
@ -44,9 +39,6 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||
<field-name>artifactTransformations</field-name>
|
||||
|
@ -66,9 +58,6 @@
|
|||
<role>org.apache.maven.artifact.installer.ArtifactInstaller</role>
|
||||
<implementation>org.apache.maven.artifact.installer.DefaultArtifactInstaller</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||
<field-name>artifactTransformations</field-name>
|
||||
|
@ -88,9 +77,6 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||
<field-name>artifactTransformations</field-name>
|
||||
|
@ -102,22 +88,12 @@
|
|||
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
|
||||
<role-hint>legacy</role-hint>
|
||||
<implementation>org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<!--
|
||||
|
@ -193,6 +169,18 @@
|
|||
</configuration>
|
||||
</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>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
<implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
|
|
|
@ -18,9 +18,7 @@ package org.apache.maven.artifact.test;
|
|||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
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.settings.Profile;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
@ -40,7 +38,6 @@ public abstract class ArtifactTestCase
|
|||
private ArtifactRepository localRepository;
|
||||
|
||||
protected File getLocalArtifactPath( Artifact artifact )
|
||||
throws ArtifactPathFormatException
|
||||
{
|
||||
return new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ 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.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
@ -80,7 +81,7 @@ public interface Artifact
|
|||
|
||||
String getId();
|
||||
|
||||
String getConflictId();
|
||||
String getDependencyConflictId();
|
||||
|
||||
void addMetadata( ArtifactMetadata metadata );
|
||||
|
||||
|
@ -90,8 +91,7 @@ public interface Artifact
|
|||
|
||||
ArtifactRepository getRepository();
|
||||
|
||||
void updateVersion( String version, ArtifactRepository localRepository )
|
||||
throws ArtifactMetadataRetrievalException;
|
||||
void updateVersion( String version, ArtifactRepository localRepository );
|
||||
|
||||
String getDownloadUrl();
|
||||
|
||||
|
@ -100,4 +100,6 @@ public interface Artifact
|
|||
ArtifactFilter getDependencyFilter();
|
||||
|
||||
void setDependencyFilter( ArtifactFilter artifactFilter );
|
||||
|
||||
ArtifactHandler getArtifactHandler();
|
||||
}
|
|
@ -17,10 +17,9 @@ package org.apache.maven.artifact;
|
|||
*/
|
||||
|
||||
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.layout.ArtifactPathFormatException;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -61,16 +60,16 @@ public class DefaultArtifact
|
|||
|
||||
private ArtifactFilter dependencyFilter;
|
||||
|
||||
/**
|
||||
* !!! WARNING !!! Never put <classifier/> in the POM. It is for mojo use
|
||||
* only. Classifier is for specifying derived artifacts, like ejb-client.
|
||||
*/
|
||||
private final ArtifactHandler artifactHandler;
|
||||
|
||||
// TODO: direct all through the artifact factory
|
||||
public DefaultArtifact( String groupId,
|
||||
String artifactId,
|
||||
String version,
|
||||
String scope,
|
||||
String type,
|
||||
String classifier )
|
||||
String classifier,
|
||||
ArtifactHandler artifactHandler )
|
||||
{
|
||||
this.groupId = groupId;
|
||||
|
||||
|
@ -78,12 +77,14 @@ public class DefaultArtifact
|
|||
|
||||
this.version = version;
|
||||
|
||||
this.type = type;
|
||||
this.artifactHandler = artifactHandler;
|
||||
|
||||
this.scope = scope;
|
||||
|
||||
this.type = type;
|
||||
|
||||
this.classifier = classifier;
|
||||
|
||||
|
||||
validateIdentity();
|
||||
}
|
||||
|
||||
|
@ -115,16 +116,6 @@ public class DefaultArtifact
|
|||
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()
|
||||
{
|
||||
return classifier;
|
||||
|
@ -191,10 +182,10 @@ public class DefaultArtifact
|
|||
|
||||
public String getId()
|
||||
{
|
||||
return getConflictId() + ( hasClassifier() ? ( ":" + getClassifier() ) : "" ) + ":" + getBaseVersion();
|
||||
return getDependencyConflictId() + ( hasClassifier() ? ( ":" + getClassifier() ) : "" ) + ":" + getBaseVersion();
|
||||
}
|
||||
|
||||
public String getConflictId()
|
||||
public String getDependencyConflictId()
|
||||
{
|
||||
return getGroupId() + ":" + getArtifactId() + ":" + getType();
|
||||
}
|
||||
|
@ -331,17 +322,9 @@ public class DefaultArtifact
|
|||
}
|
||||
|
||||
public void updateVersion( String version, ArtifactRepository localRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
setVersion( version );
|
||||
try
|
||||
{
|
||||
setFile( new File( localRepository.getBasedir(), localRepository.pathOf( this ) ) );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
|
||||
}
|
||||
setFile( new File( localRepository.getBasedir(), localRepository.pathOf( this ) ) );
|
||||
}
|
||||
|
||||
public String getDownloadUrl()
|
||||
|
@ -363,4 +346,9 @@ public class DefaultArtifact
|
|||
{
|
||||
this.dependencyFilter = artifactFilter;
|
||||
}
|
||||
|
||||
public ArtifactHandler getArtifactHandler()
|
||||
{
|
||||
return artifactHandler;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,10 @@ package org.apache.maven.artifact.deployer;
|
|||
*/
|
||||
|
||||
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.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||
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.wagon.TransferFailedException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
@ -40,8 +37,6 @@ public class DefaultArtifactDeployer
|
|||
{
|
||||
private WagonManager wagonManager;
|
||||
|
||||
private ArtifactHandlerManager artifactHandlerManager;
|
||||
|
||||
private List artifactTransformations;
|
||||
|
||||
public void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository,
|
||||
|
@ -50,16 +45,8 @@ public class DefaultArtifactDeployer
|
|||
{
|
||||
File source = null;
|
||||
|
||||
try
|
||||
{
|
||||
String extension = artifactHandlerManager.getArtifactHandler( artifact.getType() ).getExtension();
|
||||
source = new File( basedir, finalName + "." + extension );
|
||||
}
|
||||
catch ( ArtifactHandlerNotFoundException e )
|
||||
{
|
||||
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
|
||||
}
|
||||
|
||||
String extension = artifact.getArtifactHandler().getExtension();
|
||||
source = new File( basedir, finalName + "." + extension );
|
||||
deploy( source, artifact, deploymentRepository, localRepository );
|
||||
}
|
||||
|
||||
|
@ -103,10 +90,6 @@ public class DefaultArtifactDeployer
|
|||
{
|
||||
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ArtifactDeploymentException( "Error deploying artifact: ", e );
|
||||
|
|
|
@ -27,6 +27,6 @@ public interface ArtifactFactory
|
|||
|
||||
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 );
|
||||
}
|
||||
|
|
|
@ -18,10 +18,15 @@ package org.apache.maven.artifact.factory;
|
|||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.DefaultArtifact;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||
|
||||
public class DefaultArtifactFactory
|
||||
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 )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
||||
String classifier, String inheritedScope )
|
||||
private Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
||||
String classifier, String inheritedScope )
|
||||
{
|
||||
// TODO: can refactor, use scope handler
|
||||
|
||||
|
@ -71,7 +76,9 @@ public class DefaultArtifactFactory
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class DefaultArtifactHandler
|
|||
{
|
||||
if ( directory == null )
|
||||
{
|
||||
directory = type + "s";
|
||||
directory = getPackaging() + "s";
|
||||
}
|
||||
return directory;
|
||||
}
|
||||
|
|
|
@ -16,25 +16,15 @@ package org.apache.maven.artifact.handler.manager;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ArtifactHandlerNotFoundException
|
||||
extends Exception
|
||||
public interface ArtifactHandlerManager
|
||||
{
|
||||
public ArtifactHandlerNotFoundException( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
String ROLE = ArtifactHandlerManager.class.getName();
|
||||
|
||||
public ArtifactHandlerNotFoundException( Throwable cause )
|
||||
{
|
||||
super( cause );
|
||||
}
|
||||
|
||||
public ArtifactHandlerNotFoundException( String message, Throwable cause )
|
||||
{
|
||||
super( message, cause );
|
||||
}
|
||||
}
|
||||
ArtifactHandler getArtifactHandler( String type );
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -17,12 +17,9 @@ package org.apache.maven.artifact.installer;
|
|||
*/
|
||||
|
||||
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.ArtifactMetadataRetrievalException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||
import org.apache.maven.artifact.transform.ArtifactTransformation;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
@ -36,8 +33,6 @@ public class DefaultArtifactInstaller
|
|||
extends AbstractLogEnabled
|
||||
implements ArtifactInstaller
|
||||
{
|
||||
private ArtifactHandlerManager artifactHandlerManager;
|
||||
|
||||
private List artifactTransformations;
|
||||
|
||||
public void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository )
|
||||
|
@ -45,15 +40,8 @@ public class DefaultArtifactInstaller
|
|||
{
|
||||
File source = null;
|
||||
|
||||
try
|
||||
{
|
||||
String extension = artifactHandlerManager.getArtifactHandler( artifact.getType() ).getExtension();
|
||||
source = new File( basedir, finalName + "." + extension );
|
||||
}
|
||||
catch ( ArtifactHandlerNotFoundException e )
|
||||
{
|
||||
throw new ArtifactInstallationException( "Error installing artifact: ", e );
|
||||
}
|
||||
String extension = artifact.getArtifactHandler().getExtension();
|
||||
source = new File( basedir, finalName + "." + extension );
|
||||
|
||||
install( source, artifact, localRepository );
|
||||
}
|
||||
|
@ -94,10 +82,6 @@ public class DefaultArtifactInstaller
|
|||
{
|
||||
throw new ArtifactInstallationException( "Error installing artifact: ", e );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new ArtifactInstallationException( "Error installing artifact: ", e );
|
||||
}
|
||||
catch ( ArtifactMetadataRetrievalException e )
|
||||
{
|
||||
throw new ArtifactInstallationException( "Error installing artifact: ", e );
|
||||
|
|
|
@ -18,10 +18,8 @@ package org.apache.maven.artifact.manager;
|
|||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
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.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||
import org.apache.maven.wagon.ConnectionException;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
import org.apache.maven.wagon.TransferFailedException;
|
||||
|
@ -68,8 +66,6 @@ public class DefaultWagonManager
|
|||
|
||||
private TransferListener downloadMonitor;
|
||||
|
||||
private ArtifactHandlerManager artifactHandlerManager;
|
||||
|
||||
public Wagon getWagon( String protocol )
|
||||
throws UnsupportedProtocolException
|
||||
{
|
||||
|
@ -91,28 +87,14 @@ public class DefaultWagonManager
|
|||
public void putArtifact( File source, Artifact artifact, ArtifactRepository repository )
|
||||
throws TransferFailedException
|
||||
{
|
||||
try
|
||||
{
|
||||
putRemoteFile( repository, source, repository.pathOf( artifact ), downloadMonitor );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new TransferFailedException( "Path of artifact could not be determined: ", e );
|
||||
}
|
||||
putRemoteFile( repository, source, repository.pathOf( artifact ), downloadMonitor );
|
||||
}
|
||||
|
||||
public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository )
|
||||
throws TransferFailedException
|
||||
{
|
||||
try
|
||||
{
|
||||
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 );
|
||||
}
|
||||
getLogger().info( "Uploading " + artifactMetadata );
|
||||
putRemoteFile( repository, source, repository.pathOfMetadata( artifactMetadata ), null );
|
||||
}
|
||||
|
||||
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 )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
String remotePath = null;
|
||||
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 );
|
||||
}
|
||||
String remotePath = repository.pathOf( artifact );
|
||||
|
||||
getRemoteFile( repository, destination, remotePath, downloadMonitor );
|
||||
}
|
||||
|
@ -261,16 +234,7 @@ public class DefaultWagonManager
|
|||
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
String remotePath;
|
||||
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 );
|
||||
}
|
||||
String remotePath = remoteRepository.pathOfMetadata( metadata );
|
||||
|
||||
getLogger().info( "Retrieving " + metadata );
|
||||
getRemoteFile( remoteRepository, destination, remotePath, null );
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.artifact.metadata;
|
|||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.manager.WagonManager;
|
||||
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.TransferFailedException;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
@ -48,7 +47,6 @@ public abstract class AbstractVersionArtifactMetadata
|
|||
}
|
||||
|
||||
protected File getLocalRepositoryLocation( ArtifactRepository localRepository )
|
||||
throws ArtifactPathFormatException
|
||||
{
|
||||
return new File( localRepository.getBasedir(), localRepository.pathOfMetadata( this ) );
|
||||
}
|
||||
|
@ -75,7 +73,7 @@ public abstract class AbstractVersionArtifactMetadata
|
|||
}
|
||||
|
||||
public void readFromLocalRepository( ArtifactRepository localRepository )
|
||||
throws ArtifactPathFormatException, IOException
|
||||
throws IOException
|
||||
{
|
||||
File f = getLocalRepositoryLocation( localRepository );
|
||||
if ( f.exists() )
|
||||
|
@ -123,9 +121,5 @@ public abstract class AbstractVersionArtifactMetadata
|
|||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.maven.artifact.repository;
|
|||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
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.wagon.repository.Repository;
|
||||
|
||||
|
@ -59,13 +58,11 @@ public class ArtifactRepository
|
|||
}
|
||||
|
||||
public String pathOf( Artifact artifact )
|
||||
throws ArtifactPathFormatException
|
||||
{
|
||||
return layout.pathOf( artifact );
|
||||
}
|
||||
|
||||
public String pathOfMetadata( ArtifactMetadata artifactMetadata )
|
||||
throws ArtifactPathFormatException
|
||||
{
|
||||
return layout.pathOfMetadata( artifactMetadata );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
}
|
|
@ -27,9 +27,7 @@ public interface ArtifactRepositoryLayout
|
|||
|
||||
String ROLE = ArtifactRepositoryLayout.class.getName();
|
||||
|
||||
String pathOf( Artifact artifact )
|
||||
throws ArtifactPathFormatException;
|
||||
String pathOf( Artifact artifact );
|
||||
|
||||
String pathOfMetadata( ArtifactMetadata metadata )
|
||||
throws ArtifactPathFormatException;
|
||||
String pathOfMetadata( ArtifactMetadata metadata );
|
||||
}
|
|
@ -18,8 +18,6 @@ package org.apache.maven.artifact.repository.layout;
|
|||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
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.transform.ReleaseArtifactTransformation;
|
||||
|
||||
|
@ -30,31 +28,15 @@ public class DefaultRepositoryLayout
|
|||
implements ArtifactRepositoryLayout
|
||||
{
|
||||
|
||||
private ArtifactHandlerManager artifactHandlerManager;
|
||||
|
||||
public String pathOf( Artifact artifact )
|
||||
throws ArtifactPathFormatException
|
||||
{
|
||||
ArtifactHandler artifactHandler = null;
|
||||
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 );
|
||||
}
|
||||
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
|
||||
|
||||
StringBuffer path = new StringBuffer();
|
||||
|
||||
path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' );
|
||||
// if ( !artifact.getType().equals( "pom" ) )
|
||||
// {
|
||||
path.append( artifact.getArtifactId() ).append( '/' );
|
||||
path.append( artifact.getBaseVersion() ).append( '/' );
|
||||
// }
|
||||
path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
|
||||
|
||||
if ( artifact.hasClassifier() )
|
||||
|
@ -71,19 +53,15 @@ public class DefaultRepositoryLayout
|
|||
}
|
||||
|
||||
public String pathOfMetadata( ArtifactMetadata metadata )
|
||||
throws ArtifactPathFormatException
|
||||
{
|
||||
StringBuffer path = new StringBuffer();
|
||||
|
||||
path.append( metadata.getGroupId().replace( '.', '/' ) ).append( '/' );
|
||||
// if ( !artifact.getType().equals( "pom" ) )
|
||||
// {
|
||||
path.append( metadata.getArtifactId() ).append( '/' );
|
||||
if ( !metadata.getBaseVersion().equals( ReleaseArtifactTransformation.RELEASE_VERSION ) )
|
||||
{
|
||||
path.append( metadata.getBaseVersion() ).append( '/' );
|
||||
}
|
||||
// }
|
||||
|
||||
path.append( metadata.getFilename() );
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@ package org.apache.maven.artifact.repository.layout;
|
|||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -28,23 +26,9 @@ import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
|||
public class LegacyRepositoryLayout
|
||||
implements ArtifactRepositoryLayout
|
||||
{
|
||||
|
||||
private ArtifactHandlerManager artifactHandlerManager;
|
||||
|
||||
public String pathOf( Artifact artifact )
|
||||
throws ArtifactPathFormatException
|
||||
{
|
||||
ArtifactHandler artifactHandler = null;
|
||||
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 );
|
||||
}
|
||||
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
|
||||
|
||||
StringBuffer path = new StringBuffer();
|
||||
|
||||
|
@ -66,7 +50,6 @@ public class LegacyRepositoryLayout
|
|||
}
|
||||
|
||||
public String pathOfMetadata( ArtifactMetadata metadata )
|
||||
throws ArtifactPathFormatException
|
||||
{
|
||||
StringBuffer path = new StringBuffer();
|
||||
|
||||
|
|
|
@ -18,13 +18,11 @@ package org.apache.maven.artifact.resolver;
|
|||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
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.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||
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.transform.ArtifactTransformation;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
|
@ -54,11 +52,9 @@ public class DefaultArtifactResolver
|
|||
|
||||
private WagonManager wagonManager;
|
||||
|
||||
private ArtifactHandlerManager artifactHandlerManager;
|
||||
|
||||
private List artifactTransformations;
|
||||
|
||||
private ArtifactFactory artifactFactory;
|
||||
protected ArtifactFactory artifactFactory;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Implementation
|
||||
|
@ -82,16 +78,7 @@ public class DefaultArtifactResolver
|
|||
logger.debug( "Resolving: " + artifact.getId() + " from:\n" + "{localRepository: " + localRepository + "}\n" +
|
||||
"{remoteRepositories: " + remoteRepositories + "}" );
|
||||
|
||||
String localPath;
|
||||
|
||||
try
|
||||
{
|
||||
localPath = localRepository.pathOf( artifact );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new ArtifactResolutionException( e.getMessage(), e );
|
||||
}
|
||||
String localPath = localRepository.pathOf( artifact );
|
||||
|
||||
artifact.setFile( new File( localRepository.getBasedir(), localPath ) );
|
||||
|
||||
|
@ -209,7 +196,7 @@ public class DefaultArtifactResolver
|
|||
{
|
||||
Artifact newArtifact = (Artifact) i.next();
|
||||
|
||||
String id = newArtifact.getConflictId();
|
||||
String id = newArtifact.getDependencyConflictId();
|
||||
|
||||
if ( resolvedArtifacts.containsKey( id ) )
|
||||
{
|
||||
|
@ -247,7 +234,7 @@ public class DefaultArtifactResolver
|
|||
knownArtifact.getArtifactId(),
|
||||
knownVersion, newArtifact.getScope(),
|
||||
knownArtifact.getType() );
|
||||
resolvedArtifacts.put( artifact.getConflictId(), artifact );
|
||||
resolvedArtifacts.put( artifact.getDependencyConflictId(), artifact );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -304,7 +291,7 @@ public class DefaultArtifactResolver
|
|||
{
|
||||
List conflicts;
|
||||
|
||||
conflicts = (List) result.getConflicts().get( newArtifact.getConflictId() );
|
||||
conflicts = (List) result.getConflicts().get( newArtifact.getDependencyConflictId() );
|
||||
|
||||
if ( conflicts == null )
|
||||
{
|
||||
|
@ -312,7 +299,7 @@ public class DefaultArtifactResolver
|
|||
|
||||
conflicts.add( knownArtifact );
|
||||
|
||||
result.getConflicts().put( newArtifact.getConflictId(), conflicts );
|
||||
result.getConflicts().put( newArtifact.getDependencyConflictId(), conflicts );
|
||||
}
|
||||
|
||||
conflicts.add( newArtifact );
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.apache.maven.artifact.manager.WagonManager;
|
|||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||
import org.apache.maven.artifact.metadata.VersionArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -57,10 +56,6 @@ public abstract class AbstractVersionTransformation
|
|||
{
|
||||
localMetadata = readFromLocalRepository( artifact, localRepository );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
|
||||
|
@ -170,7 +165,7 @@ public abstract class AbstractVersionTransformation
|
|||
|
||||
protected abstract VersionArtifactMetadata readFromLocalRepository( Artifact artifact,
|
||||
ArtifactRepository localRepository )
|
||||
throws IOException, ArtifactPathFormatException;
|
||||
throws IOException;
|
||||
|
||||
private Date getMidnightBoundary()
|
||||
{
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
|||
import org.apache.maven.artifact.metadata.ReleaseArtifactMetadata;
|
||||
import org.apache.maven.artifact.metadata.VersionArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -92,7 +91,7 @@ public class ReleaseArtifactTransformation
|
|||
}
|
||||
|
||||
protected VersionArtifactMetadata readFromLocalRepository( Artifact artifact, ArtifactRepository localRepository )
|
||||
throws IOException, ArtifactPathFormatException
|
||||
throws IOException
|
||||
{
|
||||
AbstractVersionArtifactMetadata metadata = new ReleaseArtifactMetadata( artifact );
|
||||
metadata.readFromLocalRepository( localRepository );
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
|||
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
|
||||
import org.apache.maven.artifact.metadata.VersionArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -115,7 +114,7 @@ public class SnapshotTransformation
|
|||
}
|
||||
|
||||
protected VersionArtifactMetadata readFromLocalRepository( Artifact artifact, ArtifactRepository localRepository )
|
||||
throws IOException, ArtifactPathFormatException
|
||||
throws IOException
|
||||
{
|
||||
SnapshotArtifactMetadata metadata = new SnapshotArtifactMetadata( artifact );
|
||||
metadata.readFromLocalRepository( localRepository );
|
||||
|
|
|
@ -8,11 +8,6 @@
|
|||
<component>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
<implementation>org.apache.maven.artifact.manager.DefaultWagonManager</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<!--
|
||||
|
@ -53,9 +48,6 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||
<field-name>artifactTransformations</field-name>
|
||||
|
@ -75,9 +67,6 @@
|
|||
<role>org.apache.maven.artifact.installer.ArtifactInstaller</role>
|
||||
<implementation>org.apache.maven.artifact.installer.DefaultArtifactInstaller</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||
<field-name>artifactTransformations</field-name>
|
||||
|
@ -97,9 +86,6 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.transform.ArtifactTransformation</role>
|
||||
<field-name>artifactTransformations</field-name>
|
||||
|
@ -111,22 +97,12 @@
|
|||
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
|
||||
<role-hint>legacy</role-hint>
|
||||
<implementation>org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<!--
|
||||
|
@ -202,9 +178,26 @@
|
|||
</configuration>
|
||||
</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>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
<implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
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.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -36,16 +36,6 @@ import java.util.List;
|
|||
public abstract class ArtifactComponentTestCase
|
||||
extends PlexusTestCase
|
||||
{
|
||||
protected ArtifactHandlerManager artifactHandlerManager;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
artifactHandlerManager = (ArtifactHandlerManager) lookup( ArtifactHandlerManager.ROLE );
|
||||
}
|
||||
|
||||
protected abstract String component();
|
||||
|
||||
/**
|
||||
|
@ -252,12 +242,14 @@ public abstract class ArtifactComponentTestCase
|
|||
|
||||
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 )
|
||||
{
|
||||
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 )
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-ejb-plugin</artifactId>
|
||||
<configuration><generateClient>true</generateClient></configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
|
|
@ -91,8 +91,6 @@ public class DefaultPluginManager
|
|||
|
||||
protected PathTranslator pathTranslator;
|
||||
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
private Set pluginsInProcess = new HashSet();
|
||||
|
||||
private Log mojoLogger;
|
||||
|
@ -178,7 +176,7 @@ public class DefaultPluginManager
|
|||
}
|
||||
|
||||
public PluginDescriptor verifyPlugin( String groupId, String artifactId, String version, MavenProject project,
|
||||
Settings settings, ArtifactRepository localRepository )
|
||||
Settings settings, ArtifactRepository localRepository )
|
||||
throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException
|
||||
{
|
||||
String pluginKey = groupId + ":" + artifactId;
|
||||
|
@ -193,7 +191,8 @@ public class DefaultPluginManager
|
|||
{
|
||||
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 )
|
||||
{
|
||||
|
@ -210,8 +209,11 @@ public class DefaultPluginManager
|
|||
// TODO: this might result in an artifact "RELEASE" being resolved continuously
|
||||
if ( !isPluginInstalled( pluginKey ) )
|
||||
{
|
||||
ArtifactFactory artifactFactory = null;
|
||||
try
|
||||
{
|
||||
artifactFactory = (ArtifactFactory) container.lookup( ArtifactFactory.ROLE );
|
||||
|
||||
Artifact pluginArtifact = artifactFactory.createArtifact( groupId, artifactId, version,
|
||||
Artifact.SCOPE_RUNTIME,
|
||||
MojoDescriptor.MAVEN_PLUGIN, null );
|
||||
|
@ -223,14 +225,15 @@ public class DefaultPluginManager
|
|||
catch ( PlexusContainerException e )
|
||||
{
|
||||
throw new PluginManagerException(
|
||||
"Error occurred in the artifact container attempting to download plugin "
|
||||
+ groupId + ":" + artifactId, e );
|
||||
"Error occurred in the artifact container attempting to download plugin " + groupId + ":" +
|
||||
artifactId, e );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
if ( ( groupId == null || artifactId == null || version == null || ( groupId.equals( e.getGroupId() )
|
||||
&& artifactId.equals( e.getArtifactId() ) && version.equals( e.getVersion() ) ) )
|
||||
&& "maven-plugin".equals( e.getType() ) )
|
||||
if (
|
||||
( groupId == null || artifactId == null || version == null ||
|
||||
( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) &&
|
||||
version.equals( e.getVersion() ) ) ) && "maven-plugin".equals( e.getType() ) )
|
||||
{
|
||||
throw new PluginNotFoundException( e );
|
||||
}
|
||||
|
@ -241,31 +244,41 @@ public class DefaultPluginManager
|
|||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new PluginManagerException( "Internal configuration error while retrieving " + groupId + ":"
|
||||
+ artifactId, e );
|
||||
throw new PluginManagerException(
|
||||
"Internal configuration error while retrieving " + groupId + ":" + artifactId, e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( artifactFactory != null )
|
||||
{
|
||||
releaseComponent( artifactFactory );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return getPluginDescriptor( groupId, artifactId, version );
|
||||
}
|
||||
|
||||
protected void addPlugin( String pluginKey, Artifact pluginArtifact, MavenProject project,
|
||||
ArtifactRepository localRepository )
|
||||
ArtifactRepository localRepository )
|
||||
throws ArtifactResolutionException, ComponentLookupException, PlexusContainerException
|
||||
{
|
||||
ArtifactResolver artifactResolver = null;
|
||||
MavenProjectBuilder mavenProjectBuilder = null;
|
||||
ArtifactFactory artifactFactory = null;
|
||||
|
||||
try
|
||||
{
|
||||
artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.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
|
||||
.singleton( pluginArtifact ), project.getRemoteArtifactRepositories(), localRepository, metadataSource,
|
||||
artifactFilter );
|
||||
artifactFilter );
|
||||
|
||||
Map resolved = result.getArtifacts();
|
||||
|
||||
|
@ -278,7 +291,8 @@ public class DefaultPluginManager
|
|||
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
|
||||
// around and set the artifacts.
|
||||
|
@ -288,7 +302,7 @@ public class DefaultPluginManager
|
|||
|
||||
ArtifactResolutionResult distroProvidedResult = artifactResolver.resolveTransitively( Collections
|
||||
.singleton( pluginArtifact ), project.getRemoteArtifactRepositories(), localRepository, metadataSource,
|
||||
distroProvidedFilter );
|
||||
distroProvidedFilter );
|
||||
|
||||
Map distroProvided = distroProvidedResult.getArtifacts();
|
||||
|
||||
|
@ -301,6 +315,10 @@ public class DefaultPluginManager
|
|||
}
|
||||
finally
|
||||
{
|
||||
if ( artifactFactory != null )
|
||||
{
|
||||
releaseComponent( artifactFactory );
|
||||
}
|
||||
if ( artifactResolver != null )
|
||||
{
|
||||
releaseComponent( artifactResolver );
|
||||
|
@ -340,14 +358,16 @@ public class DefaultPluginManager
|
|||
|
||||
ArtifactResolver artifactResolver = null;
|
||||
MavenProjectBuilder mavenProjectBuilder = null;
|
||||
ArtifactFactory artifactFactory = null;
|
||||
|
||||
try
|
||||
{
|
||||
artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
|
||||
mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE );
|
||||
artifactFactory = (ArtifactFactory) container.lookup( ArtifactFactory.ROLE );
|
||||
|
||||
resolveTransitiveDependencies( session, artifactResolver, mavenProjectBuilder, mojoDescriptor
|
||||
.isDependencyResolutionRequired() );
|
||||
.isDependencyResolutionRequired(), artifactFactory );
|
||||
downloadDependencies( session, artifactResolver );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
|
@ -364,6 +384,10 @@ public class DefaultPluginManager
|
|||
{
|
||||
releaseComponent( mavenProjectBuilder );
|
||||
}
|
||||
if ( artifactFactory != null )
|
||||
{
|
||||
releaseComponent( artifactFactory );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,8 +436,7 @@ public class DefaultPluginManager
|
|||
// PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration,
|
||||
// mojoDescriptor.getConfiguration() );
|
||||
|
||||
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session,
|
||||
pluginDescriptor,
|
||||
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, pluginDescriptor,
|
||||
pathTranslator,
|
||||
getLogger() );
|
||||
|
||||
|
@ -475,7 +498,7 @@ public class DefaultPluginManager
|
|||
}
|
||||
|
||||
private void checkRequiredParameters( MojoDescriptor goal, PlexusConfiguration configuration,
|
||||
ExpressionEvaluator expressionEvaluator, Mojo plugin )
|
||||
ExpressionEvaluator expressionEvaluator, Mojo plugin )
|
||||
throws PluginConfigurationException
|
||||
{
|
||||
// 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 )
|
||||
{
|
||||
getLogger().warn(
|
||||
"DEPRECATED: using default-value to set the default value of field '"
|
||||
+ parameter.getName() + "'" );
|
||||
"DEPRECATED: using default-value to set the default value of field '" +
|
||||
parameter.getName() + "'" );
|
||||
}
|
||||
}
|
||||
catch ( NoSuchFieldException e )
|
||||
|
@ -665,7 +688,7 @@ public class DefaultPluginManager
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
private void populatePluginFields( Mojo plugin, MojoDescriptor mojoDescriptor, PlexusConfiguration configuration,
|
||||
PlexusContainer pluginContainer, ExpressionEvaluator expressionEvaluator )
|
||||
PlexusContainer pluginContainer, ExpressionEvaluator expressionEvaluator )
|
||||
throws PluginConfigurationException
|
||||
{
|
||||
ComponentConfigurator configurator = null;
|
||||
|
@ -695,8 +718,7 @@ public class DefaultPluginManager
|
|||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new PluginConfigurationException(
|
||||
"Unable to retrieve component configurator for plugin configuration",
|
||||
e );
|
||||
"Unable to retrieve component configurator for plugin configuration", e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -736,7 +758,7 @@ public class DefaultPluginManager
|
|||
}
|
||||
|
||||
public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, Parameter parameter,
|
||||
String expression )
|
||||
String expression )
|
||||
{
|
||||
StringBuffer message = new StringBuffer();
|
||||
|
||||
|
@ -792,22 +814,8 @@ public class DefaultPluginManager
|
|||
public void initialize()
|
||||
{
|
||||
// TODO: configure this from bootstrap or scan lib
|
||||
artifactFilter = new ExclusionSetFilter( 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" } );
|
||||
artifactFilter = new ExclusionSetFilter(
|
||||
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"} );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -815,12 +823,14 @@ public class DefaultPluginManager
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver,
|
||||
MavenProjectBuilder mavenProjectBuilder, String scope )
|
||||
MavenProjectBuilder mavenProjectBuilder, String scope,
|
||||
ArtifactFactory artifactFactory )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
MavenProject project = context.getProject();
|
||||
|
||||
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, mavenProjectBuilder );
|
||||
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
|
||||
artifactFactory );
|
||||
|
||||
ArtifactFilter filter = new ScopeArtifactFilter( scope );
|
||||
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.project.path.PathTranslator</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
|
@ -28,11 +25,5 @@
|
|||
<role>org.apache.maven.project.path.PathTranslator</role>
|
||||
<implementation>org.apache.maven.project.path.DefaultPathTranslator</implementation>
|
||||
</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>
|
||||
</plexus>
|
||||
|
|
|
@ -102,7 +102,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
{
|
||||
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 ) );
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public class InvalidArtifactDiagnoserTest
|
|||
|
||||
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." );
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.plugin.deploy;
|
|||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
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.ArtifactDeploymentException;
|
||||
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 java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Deploys an artifact to remote repository.
|
||||
|
@ -110,6 +113,20 @@ public class DeployMojo
|
|||
*/
|
||||
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}"
|
||||
*/
|
||||
|
@ -126,7 +143,9 @@ public class DeployMojo
|
|||
}
|
||||
|
||||
// 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 );
|
||||
File pom = new File( parentDir, "pom.xml" );
|
||||
if ( !isPomArtifact )
|
||||
|
@ -152,7 +171,13 @@ public class DeployMojo
|
|||
{
|
||||
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 )
|
||||
{
|
||||
// TODO: deployment exception that does not give a trace
|
||||
|
|
|
@ -15,5 +15,10 @@
|
|||
<artifactId>maven-archiver</artifactId>
|
||||
<version>2.0-alpha-2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-project</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</model>
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.apache.maven.plugin.ejb;
|
|||
|
||||
import org.apache.maven.archiver.MavenArchiveConfiguration;
|
||||
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.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
@ -37,12 +39,10 @@ public class EjbMojo
|
|||
// TODO: will null work instead?
|
||||
private static final String[] DEFAULT_INCLUDES = new String[]{"**/**"};
|
||||
|
||||
private static final String[] DEFAULT_EXCLUDES = new String[]{"**/*Bean.class", "**/*CMP.class",
|
||||
"**/*Session.class", "**/package.html"};
|
||||
private static final String[] DEFAULT_EXCLUDES = new String[]{"**/*Bean.class", "**/*CMP.class", "**/*Session.class", "**/package.html"};
|
||||
|
||||
/**
|
||||
* @todo File instead
|
||||
*
|
||||
* @parameter expression="${project.build.directory}"
|
||||
* @required
|
||||
* @readonly
|
||||
|
@ -63,7 +63,6 @@ public class EjbMojo
|
|||
|
||||
/**
|
||||
* @todo boolean instead
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
private String generateClient = Boolean.FALSE.toString();
|
||||
|
@ -75,6 +74,13 @@ public class EjbMojo
|
|||
*/
|
||||
private MavenProject project;
|
||||
|
||||
/**
|
||||
* @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
/**
|
||||
* @parameter
|
||||
*/
|
||||
|
@ -121,6 +127,14 @@ public class EjbMojo
|
|||
|
||||
// create 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 )
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.plugin.install;
|
|||
|
||||
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.plugin.MojoExecutionException;
|
||||
|
||||
|
@ -68,10 +69,18 @@ public class InstallFileMojo
|
|||
*/
|
||||
private File file;
|
||||
|
||||
/**
|
||||
* @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
public void execute()
|
||||
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
|
||||
{
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.plugin.install;
|
|||
|
||||
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.metadata.ArtifactMetadata;
|
||||
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 java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Installs project's main artifact in local repository.
|
||||
|
@ -89,10 +92,25 @@ public class InstallMojo
|
|||
*/
|
||||
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()
|
||||
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 );
|
||||
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)
|
||||
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 )
|
||||
{
|
||||
|
|
|
@ -16,9 +16,8 @@ package org.apache.maven.test;
|
|||
* 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.layout.ArtifactPathFormatException;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
@ -117,6 +116,11 @@ public class SurefirePlugin
|
|||
*/
|
||||
private Properties systemProperties;
|
||||
|
||||
/**
|
||||
* @parameter expression="${plugin.artifacts}"
|
||||
*/
|
||||
private List pluginArtifacts;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
|
@ -194,19 +198,10 @@ public class SurefirePlugin
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: we should really just trust the plugin classloader?
|
||||
try
|
||||
for ( Iterator i = pluginArtifacts.iterator(); i.hasNext(); )
|
||||
{
|
||||
DefaultArtifact artifact = new DefaultArtifact( "junit", "junit", "3.8.1", "jar" );
|
||||
File file = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
|
||||
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 );
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
surefireBooter.addClassPathUrl( artifact.getFile().getAbsolutePath() );
|
||||
}
|
||||
|
||||
surefireBooter.addClassPathUrl( new File( classesDirectory ).getPath() );
|
||||
|
|
|
@ -169,6 +169,7 @@ public class WarMojo
|
|||
Artifact artifact = (Artifact) iter.next();
|
||||
|
||||
// TODO: scope handler
|
||||
// TODO: use classpath instead
|
||||
// Include runtime and compile time libraries
|
||||
if ( "jar".equals( artifact.getType() ) && !Artifact.SCOPE_TEST.equals( artifact.getScope() ) && !Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) )
|
||||
{
|
||||
|
|
|
@ -471,7 +471,7 @@ public class DefaultMavenProjectBuilder
|
|||
protected Set createArtifacts( List dependencies )
|
||||
{
|
||||
// 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 )
|
||||
|
|
|
@ -79,11 +79,13 @@ public class MavenProject
|
|||
private Set pluginArtifacts;
|
||||
|
||||
private List remoteArtifactRepositories;
|
||||
|
||||
|
||||
private Properties profileProperties = new Properties();
|
||||
|
||||
private List collectedProjects = Collections.EMPTY_LIST;
|
||||
|
||||
private List attachedArtifacts;
|
||||
|
||||
public MavenProject( Model model )
|
||||
{
|
||||
this.model = model;
|
||||
|
@ -266,12 +268,12 @@ public class MavenProject
|
|||
public List getCompileDependencies()
|
||||
{
|
||||
Set artifacts = getArtifacts();
|
||||
|
||||
if(artifacts == null || artifacts.isEmpty())
|
||||
|
||||
if ( artifacts == null || artifacts.isEmpty() )
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
|
||||
List list = new ArrayList( artifacts.size() );
|
||||
|
||||
for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
|
||||
|
@ -309,8 +311,8 @@ public class MavenProject
|
|||
if ( isAddedToClasspath( a ) )
|
||||
{
|
||||
// TODO: let the scope handler deal with this
|
||||
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() )
|
||||
|| Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
|
||||
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
|
||||
Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
|
||||
{
|
||||
File file = a.getFile();
|
||||
if ( file == null )
|
||||
|
@ -327,12 +329,12 @@ public class MavenProject
|
|||
public List getTestDependencies()
|
||||
{
|
||||
Set artifacts = getArtifacts();
|
||||
|
||||
if(artifacts == null || artifacts.isEmpty())
|
||||
|
||||
if ( artifacts == null || artifacts.isEmpty() )
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
|
||||
List list = new ArrayList( artifacts.size() );
|
||||
|
||||
for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
|
||||
|
@ -340,8 +342,8 @@ public class MavenProject
|
|||
Artifact a = (Artifact) i.next();
|
||||
|
||||
// TODO: let the scope handler deal with this
|
||||
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() )
|
||||
|| Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
|
||||
if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
|
||||
Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
|
||||
{
|
||||
Dependency dependency = new Dependency();
|
||||
|
||||
|
@ -388,12 +390,12 @@ public class MavenProject
|
|||
public List getRuntimeDependencies()
|
||||
{
|
||||
Set artifacts = getArtifacts();
|
||||
|
||||
if(artifacts == null || artifacts.isEmpty())
|
||||
|
||||
if ( artifacts == null || artifacts.isEmpty() )
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
|
||||
List list = new ArrayList( artifacts.size() );
|
||||
|
||||
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
||||
|
@ -422,7 +424,7 @@ public class MavenProject
|
|||
String type = artifact.getType();
|
||||
|
||||
// TODO: utilise type handler
|
||||
if ( "jar".equals( type ) || "ejb".equals( type ) )
|
||||
if ( "jar".equals( type ) || "ejb".equals( type ) || "ejb-client".equals( type ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -715,6 +717,7 @@ public class MavenProject
|
|||
return model.getReports().getPlugins();
|
||||
|
||||
}
|
||||
|
||||
public List getBuildPlugins()
|
||||
{
|
||||
if ( model.getBuild() == null )
|
||||
|
@ -785,13 +788,14 @@ public class MavenProject
|
|||
{
|
||||
Artifact existing = (Artifact) artifacts.get( id );
|
||||
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;
|
||||
}
|
||||
|
||||
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() )
|
||||
&& !Artifact.SCOPE_COMPILE.equals( existing.getScope() ) )
|
||||
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) &&
|
||||
!Artifact.SCOPE_COMPILE.equals( existing.getScope() ) )
|
||||
{
|
||||
updateScope = true;
|
||||
}
|
||||
|
@ -800,10 +804,9 @@ public class MavenProject
|
|||
{
|
||||
// TODO: Artifact factory?
|
||||
// TODO: [jc] Is this a better way to centralize artifact construction here?
|
||||
Artifact artifact = artifactFactory.createArtifact( existing.getGroupId(),
|
||||
existing.getArtifactId(),
|
||||
Artifact artifact = artifactFactory.createArtifact( existing.getGroupId(), existing.getArtifactId(),
|
||||
existing.getVersion(), a.getScope(), existing
|
||||
.getType() );
|
||||
.getType() );
|
||||
|
||||
artifact.setFile( existing.getFile() );
|
||||
artifact.setBaseVersion( existing.getBaseVersion() );
|
||||
|
@ -905,10 +908,23 @@ public class MavenProject
|
|||
{
|
||||
this.activeProfiles.addAll( activeProfiles );
|
||||
}
|
||||
|
||||
|
||||
public List getActiveProfiles()
|
||||
{
|
||||
return activeProfiles;
|
||||
}
|
||||
|
||||
public void addAttachedArtifact( Artifact artifact )
|
||||
{
|
||||
getAttachedArtifacts().add( artifact );
|
||||
}
|
||||
|
||||
public List getAttachedArtifacts()
|
||||
{
|
||||
if ( attachedArtifacts == null )
|
||||
{
|
||||
attachedArtifacts = new ArrayList();
|
||||
}
|
||||
return attachedArtifacts;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,15 +18,14 @@ package org.apache.maven.project.artifact;
|
|||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
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.ArtifactMetadataSource;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
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.ExcludesArtifactFilter;
|
||||
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Exclusion;
|
||||
import org.apache.maven.model.Model;
|
||||
|
@ -58,24 +57,26 @@ public class MavenMetadataSource
|
|||
|
||||
private ArtifactResolver artifactResolver;
|
||||
|
||||
// TODO: configure?
|
||||
protected ArtifactFactory artifactFactory = new DefaultArtifactFactory();
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
/**
|
||||
* @todo remove.
|
||||
*/
|
||||
private MavenXpp3Reader reader = new MavenXpp3Reader();
|
||||
|
||||
public MavenMetadataSource( ArtifactResolver artifactResolver )
|
||||
public MavenMetadataSource( ArtifactResolver artifactResolver, ArtifactFactory artifactFactory )
|
||||
{
|
||||
this.artifactResolver = artifactResolver;
|
||||
this.mavenProjectBuilder = null;
|
||||
this.artifactFactory = artifactFactory;
|
||||
}
|
||||
|
||||
public MavenMetadataSource( ArtifactResolver artifactResolver, MavenProjectBuilder projectBuilder )
|
||||
public MavenMetadataSource( ArtifactResolver artifactResolver, MavenProjectBuilder projectBuilder,
|
||||
ArtifactFactory artifactFactory )
|
||||
{
|
||||
this.artifactResolver = artifactResolver;
|
||||
this.mavenProjectBuilder = projectBuilder;
|
||||
this.artifactFactory = artifactFactory;
|
||||
}
|
||||
|
||||
public Set retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
||||
|
@ -180,7 +181,7 @@ public class MavenMetadataSource
|
|||
|
||||
artifact.setDependencyFilter( dependencyFilter );
|
||||
|
||||
projectArtifacts.add( artifact );
|
||||
projectArtifacts.add( artifact );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.apache.maven.artifact.metadata.AbstractArtifactMetadata;
|
|||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||
import org.apache.maven.artifact.manager.WagonManager;
|
||||
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.io.xpp3.MavenXpp3Reader;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
||||
|
@ -64,15 +63,7 @@ public class ProjectArtifactMetadata
|
|||
public void storeInLocalRepository( ArtifactRepository localRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
File destination;
|
||||
try
|
||||
{
|
||||
destination = new File( localRepository.getBasedir(), localRepository.pathOfMetadata( this ) );
|
||||
}
|
||||
catch ( ArtifactPathFormatException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Unable to install POM", e );
|
||||
}
|
||||
File destination = new File( localRepository.getBasedir(), localRepository.pathOfMetadata( this ) );
|
||||
|
||||
destination.getParentFile().mkdirs();
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.project;
|
|||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -34,12 +35,15 @@ public abstract class MavenProjectTestCase
|
|||
{
|
||||
protected MavenProjectBuilder projectBuilder;
|
||||
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||
artifactFactory = ( ArtifactFactory ) lookup( ArtifactFactory.ROLE );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -94,7 +98,7 @@ public abstract class MavenProjectTestCase
|
|||
throws Exception
|
||||
{
|
||||
return projectBuilder.buildWithDependencies( pom, getLocalRepository(),
|
||||
new ProjectClasspathArtifactResolver.Source(),
|
||||
new ProjectClasspathArtifactResolver.Source( artifactFactory ),
|
||||
Collections.EMPTY_LIST );
|
||||
}
|
||||
|
||||
|
|
|
@ -46,10 +46,11 @@ public class ProjectClasspathArtifactResolver
|
|||
public static class Source
|
||||
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 )
|
||||
|
@ -111,7 +112,7 @@ public class ProjectClasspathArtifactResolver
|
|||
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||
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,
|
||||
|
@ -119,7 +120,7 @@ public class ProjectClasspathArtifactResolver
|
|||
ArtifactMetadataSource source )
|
||||
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,
|
||||
|
@ -127,6 +128,6 @@ public class ProjectClasspathArtifactResolver
|
|||
ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
return super.resolveTransitively( artifact, remoteRepositories, localRepository, new Source() );
|
||||
return super.resolveTransitively( artifact, remoteRepositories, localRepository, new Source( artifactFactory ) );
|
||||
}
|
||||
}
|
|
@ -8,9 +8,6 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
|
@ -24,9 +21,6 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
|
|
Loading…
Reference in New Issue