o rolling back to r617947

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@618044 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2008-02-03 17:47:10 +00:00
parent 2282145d52
commit e30510f0c9
8 changed files with 199 additions and 100 deletions

View File

@ -25,7 +25,6 @@ import org.apache.maven.artifact.ArtifactStatus;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.UnknownRepositoryLayoutException;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
@ -163,8 +162,6 @@ public class DefaultMavenProjectBuilder
private MavenTools mavenTools;
private ArtifactHandlerManager artifactHandlerManager;
//DO NOT USE, it is here only for backward compatibility reasons. The existing
// maven-assembly-plugin (2.2-beta-1) is accessing it via reflection.

View File

@ -31,9 +31,26 @@ import java.util.List;
public class DefaultMavenProjectHelper
implements MavenProjectHelper
{
private ArtifactHandlerManager artifactHandlerManager;
public void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile )
{
Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType, artifactClassifier );
{
String type = artifactType;
ArtifactHandler handler = null;
if ( type != null )
{
handler = artifactHandlerManager.getArtifactHandler( artifactType );
}
if ( handler == null )
{
handler = artifactHandlerManager.getArtifactHandler( "jar" );
}
Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType, artifactClassifier, handler );
artifact.setFile( artifactFile );
artifact.setResolved( true );
@ -43,7 +60,9 @@ public class DefaultMavenProjectHelper
public void attachArtifact( MavenProject project, String artifactType, File artifactFile )
{
Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType );
ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( artifactType );
Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType, handler );
artifact.setFile( artifactFile );
artifact.setResolved( true );
@ -55,7 +74,7 @@ public class DefaultMavenProjectHelper
{
Artifact projectArtifact = project.getArtifact();
Artifact artifact = new AttachedArtifact( projectArtifact, projectArtifact.getType(), artifactClassifier );
Artifact artifact = new AttachedArtifact( projectArtifact, projectArtifact.getType(), artifactClassifier, projectArtifact.getArtifactHandler() );
artifact.setFile( artifactFile );
artifact.setResolved( true );

View File

@ -23,7 +23,6 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ManagedVersionMap;
@ -153,12 +152,6 @@ public class MavenProject
private Stack previousExecutionProjects = new Stack();
// This should not be in here and neither should any of artifact listing methods that pick off artifacts
// based on their scope as that forces MavenProject to know about all scopes that are available which
// makes the addition of new scopes unscalable. Another component should take as input a MavenProject and
// spit out the list of artifacts based on scope. jvz.
private ArtifactHandlerManager artifactHandlerManager;
public MavenProject()
{
Model model = new Model();
@ -175,12 +168,6 @@ public class MavenProject
this.model = model;
}
// This is temporary until we get the scope related elements out of here. jvz.
public void setArtifactHandlerManager( ArtifactHandlerManager artifactHandlerManager )
{
this.artifactHandlerManager = artifactHandlerManager;
}
public MavenProject( MavenProject project )
{
// disown the parent
@ -503,7 +490,7 @@ public class MavenProject
{
Artifact a = (Artifact) i.next();
if ( artifactHandlerManager.getArtifactHandler( a.getType() ).isAddedToClasspath() )
if ( a.getArtifactHandler().isAddedToClasspath() )
{
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) ||
@ -525,7 +512,7 @@ public class MavenProject
Artifact a = (Artifact) i.next();
// TODO: classpath check doesn't belong here - that's the other method
if ( artifactHandlerManager.getArtifactHandler( a.getType() ).isAddedToClasspath() )
if ( a.getArtifactHandler().isAddedToClasspath() )
{
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) ||
@ -585,7 +572,7 @@ public class MavenProject
{
Artifact a = (Artifact) i.next();
if ( artifactHandlerManager.getArtifactHandler( a.getType() ).isAddedToClasspath() )
if ( a.getArtifactHandler().isAddedToClasspath() )
{
// TODO: let the scope handler deal with this
// NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
@ -614,7 +601,7 @@ public class MavenProject
Artifact a = (Artifact) i.next();
// TODO: classpath check doesn't belong here - that's the other method
if ( artifactHandlerManager.getArtifactHandler( a.getType() ).isAddedToClasspath() )
if ( a.getArtifactHandler().isAddedToClasspath() )
{
// TODO: let the scope handler deal with this
// NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
@ -679,7 +666,7 @@ public class MavenProject
{
Artifact a = (Artifact) i.next();
if ( artifactHandlerManager.getArtifactHandler( a.getType() ).isAddedToClasspath() )
if ( a.getArtifactHandler().isAddedToClasspath() )
{
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
@ -705,7 +692,7 @@ public class MavenProject
Artifact a = (Artifact) i.next();
// TODO: classpath check doesn't belong here - that's the other method
if ( artifactHandlerManager.getArtifactHandler( a.getType() ).isAddedToClasspath() )
if ( a.getArtifactHandler().isAddedToClasspath() )
{
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
@ -761,7 +748,7 @@ public class MavenProject
{
Artifact a = (Artifact) i.next();
if ( artifactHandlerManager.getArtifactHandler( a.getType() ).isAddedToClasspath() )
if ( a.getArtifactHandler().isAddedToClasspath() )
{
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
@ -782,7 +769,7 @@ public class MavenProject
Artifact a = (Artifact) i.next();
// TODO: classpath check doesn't belong here - that's the other method
if ( artifactHandlerManager.getArtifactHandler( a.getType() ).isAddedToClasspath() )
if ( a.getArtifactHandler().isAddedToClasspath() )
{
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
@ -1763,4 +1750,30 @@ public class MavenProject
{
return (Plugin) getBuild().getPluginsAsMap().get( pluginKey );
}
/**
* Default toString
*/
public String toString()
{
StringBuffer sb = new StringBuffer(30);
sb.append( "MavenProject: " );
sb.append( this.getGroupId() );
sb.append( ":" );
sb.append( this.getArtifactId() );
sb.append( ":" );
sb.append( this.getVersion() );
sb.append( " @ " );
try
{
sb.append( this.getFile().getPath() );
}
catch (NullPointerException e)
{
//don't log it.
}
return sb.toString();
}
}

View File

@ -58,232 +58,345 @@ public class ActiveProjectArtifact
artifact.setResolved( true );
}
/** {@inheritDoc} */
public File getFile()
{
// we need to get the latest file for the project, not the artifact that was created at one point in time
return project.getArtifact().getFile();
}
/** {@inheritDoc} */
public String getGroupId()
{
return artifact.getGroupId();
}
/** {@inheritDoc} */
public String getArtifactId()
{
return artifact.getArtifactId();
}
/** {@inheritDoc} */
public String getVersion()
{
return artifact.getVersion();
}
/** {@inheritDoc} */
public void setVersion( String version )
{
artifact.setVersion( version );
}
/** {@inheritDoc} */
public String getScope()
{
return artifact.getScope();
}
/** {@inheritDoc} */
public String getType()
{
return artifact.getType();
}
/** {@inheritDoc} */
public String getClassifier()
{
return artifact.getClassifier();
}
/** {@inheritDoc} */
public boolean hasClassifier()
{
return artifact.hasClassifier();
}
/** {@inheritDoc} */
public void setFile( File destination )
{
artifact.setFile( destination );
project.getArtifact().setFile( destination );
}
/** {@inheritDoc} */
public String getBaseVersion()
{
return artifact.getBaseVersion();
}
/** {@inheritDoc} */
public void setBaseVersion( String baseVersion )
{
artifact.setBaseVersion( baseVersion );
}
/** {@inheritDoc} */
public String getId()
{
return artifact.getId();
}
/** {@inheritDoc} */
public String getDependencyConflictId()
{
return artifact.getDependencyConflictId();
}
/** {@inheritDoc} */
public void addMetadata( ArtifactMetadata metadata )
{
artifact.addMetadata( metadata );
}
/** {@inheritDoc} */
public Collection getMetadataList()
{
return artifact.getMetadataList();
}
/** {@inheritDoc} */
public void setRepository( ArtifactRepository remoteRepository )
{
artifact.setRepository( remoteRepository );
}
/** {@inheritDoc} */
public ArtifactRepository getRepository()
{
return artifact.getRepository();
}
/** {@inheritDoc} */
public void updateVersion( String version, ArtifactRepository localRepository )
{
artifact.updateVersion( version, localRepository );
}
/** {@inheritDoc} */
public String getDownloadUrl()
{
return artifact.getDownloadUrl();
}
/** {@inheritDoc} */
public void setDownloadUrl( String downloadUrl )
{
artifact.setDownloadUrl( downloadUrl );
}
/** {@inheritDoc} */
public ArtifactFilter getDependencyFilter()
{
return artifact.getDependencyFilter();
}
/** {@inheritDoc} */
public void setDependencyFilter( ArtifactFilter artifactFilter )
{
artifact.setDependencyFilter( artifactFilter );
}
/** {@inheritDoc} */
public ArtifactHandler getArtifactHandler()
{
return artifact.getArtifactHandler();
}
/** {@inheritDoc} */
public List getDependencyTrail()
{
return artifact.getDependencyTrail();
}
/** {@inheritDoc} */
public void setDependencyTrail( List dependencyTrail )
{
artifact.setDependencyTrail( dependencyTrail );
}
/** {@inheritDoc} */
public void setScope( String scope )
{
artifact.setScope( scope );
}
/** {@inheritDoc} */
public VersionRange getVersionRange()
{
return artifact.getVersionRange();
}
/** {@inheritDoc} */
public void setVersionRange( VersionRange newRange )
{
artifact.setVersionRange( newRange );
}
/** {@inheritDoc} */
public void selectVersion( String version )
{
artifact.selectVersion( version );
}
/** {@inheritDoc} */
public void setGroupId( String groupId )
{
artifact.setGroupId( groupId );
}
/** {@inheritDoc} */
public void setArtifactId( String artifactId )
{
artifact.setArtifactId( artifactId );
}
/** {@inheritDoc} */
public boolean isSnapshot()
{
return artifact.isSnapshot();
}
/** {@inheritDoc} */
public int compareTo( Object o )
{
return artifact.compareTo( o );
}
/** {@inheritDoc} */
public void setResolved( boolean resolved )
{
artifact.setResolved( resolved );
}
/** {@inheritDoc} */
public boolean isResolved()
{
return artifact.isResolved();
}
/** {@inheritDoc} */
public void setResolvedVersion( String version )
{
artifact.setResolvedVersion( version );
}
/** {@inheritDoc} */
public void setArtifactHandler( ArtifactHandler handler )
{
artifact.setArtifactHandler( handler );
}
/** {@inheritDoc} */
public String toString()
{
return "active project artifact:\n\tartifact = " + artifact + ";\n\tproject: " + project;
}
/** {@inheritDoc} */
public boolean isRelease()
{
return artifact.isRelease();
}
/** {@inheritDoc} */
public void setRelease( boolean release )
{
artifact.setRelease( release );
}
/** {@inheritDoc} */
public List getAvailableVersions()
{
return artifact.getAvailableVersions();
}
/** {@inheritDoc} */
public void setAvailableVersions( List versions )
{
artifact.setAvailableVersions( versions );
}
/** {@inheritDoc} */
public boolean isOptional()
{
return artifact.isOptional();
}
/** {@inheritDoc} */
public ArtifactVersion getSelectedVersion()
throws OverConstrainedVersionException
{
return artifact.getSelectedVersion();
}
/** {@inheritDoc} */
public boolean isSelectedVersionKnown()
throws OverConstrainedVersionException
{
return artifact.isSelectedVersionKnown();
}
/** {@inheritDoc} */
public void setOptional( boolean optional )
{
artifact.setOptional( optional );
}
/** {@inheritDoc} */
public int hashCode()
{
int result = 17;
result = 37 * result + getGroupId().hashCode();
result = 37 * result + getArtifactId().hashCode();
result = 37 * result + getType().hashCode();
if ( getVersion() != null )
{
result = 37 * result + getVersion().hashCode();
}
result = 37 * result + ( getClassifier() != null ? getClassifier().hashCode() : 0 );
return result;
}
/** {@inheritDoc} */
public boolean equals( Object o )
{
if ( o == this )
{
return true;
}
if ( !( o instanceof Artifact ) )
{
return false;
}
Artifact a = (Artifact) o;
if ( !a.getGroupId().equals( getGroupId() ) )
{
return false;
}
else if ( !a.getArtifactId().equals( getArtifactId() ) )
{
return false;
}
else if ( !a.getVersion().equals( getVersion() ) )
{
return false;
}
else if ( !a.getType().equals( getType() ) )
{
return false;
}
else if ( a.getClassifier() == null ? getClassifier() != null : !a.getClassifier().equals( getClassifier() ) )
{
return false;
}
return true;
}
}

View File

@ -37,10 +37,10 @@ public class AttachedArtifact
private final Artifact parent;
public AttachedArtifact( Artifact parent, String type, String classifier )
public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler )
{
super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type,
classifier, parent.isOptional() );
classifier, artifactHandler, parent.isOptional() );
setDependencyTrail( Collections.singletonList( parent.getId() ) );
@ -52,9 +52,9 @@ public class AttachedArtifact
}
}
public AttachedArtifact( Artifact parent, String type )
public AttachedArtifact( Artifact parent, String type, ArtifactHandler artifactHandler )
{
this( parent, type, null );
this( parent, type, null, artifactHandler );
}
public void setArtifactId( String artifactId )

View File

@ -21,7 +21,6 @@ package org.apache.maven.project.artifact;
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.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ResolutionGroup;
@ -85,8 +84,6 @@ public class MavenMetadataSource
private PlexusContainer container;
private ArtifactHandlerManager artifactHandlerManager;
/** Unfortunately we have projects that are still sending us JARs without the accompanying POMs. */
private boolean strictlyEnforceThePresenceOfAValidMavenPOM = false;
@ -130,6 +127,12 @@ public class MavenMetadataSource
}
catch ( InvalidProjectModelException e )
{
if ( strictlyEnforceThePresenceOfAValidMavenPOM )
{
throw new ArtifactMetadataRetrievalException( "Invalid POM file for artifact: '" +
artifact.getDependencyConflictId() + "' Reason: " + e.getMessage(), e, artifact );
}
getLogger().warn( "POM for \'" + pomArtifact +
"\' is invalid. It will be ignored for artifact resolution. Reason: " + e.getMessage() );
@ -148,6 +151,10 @@ public class MavenMetadataSource
}
getLogger().debug( "\n" );
}
else
{
getLogger().debug( "", e );
}
}
project = null;
@ -246,7 +253,7 @@ public class MavenMetadataSource
else
{
Set artifacts = Collections.EMPTY_SET;
if ( !artifactHandlerManager.getArtifactHandler( artifact.getType() ).isIncludesDependencies() )
if ( !artifact.getArtifactHandler().isIncludesDependencies() )
{
// TODO: we could possibly use p.getDependencyArtifacts instead of this call, but they haven't been filtered
// or used the inherited scope (should that be passed to the buildFromRepository method above?)

View File

@ -144,9 +144,6 @@ under the License.
<requirement>
<role>org.apache.maven.MavenTools</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component>
<!--
@ -247,6 +244,20 @@ under the License.
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
<role-hint>maven</role-hint>
<implementation>org.apache.maven.project.artifact.MavenMetadataSource</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
@ -262,26 +273,6 @@ under the License.
<requirement>
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
<role-hint>maven</role-hint>
<implementation>org.apache.maven.project.artifact.MavenMetadataSource</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component>
@ -296,9 +287,6 @@ under the License.
<requirement>
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
</requirements>
</component>

38
pom.xml
View File

@ -348,43 +348,5 @@ under the License.
</plugins>
</build>
</profile>
<profile>
<!-- To generate aggregate reports, calling twice mvn site -Preporting, mvn site -Preporting-aggregate -->
<id>reporting-aggregate</id>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<links>
<link>http://java.sun.com/j2se/1.4.2/docs/api</link>
<link>http://java.sun.com/j2ee/1.4/docs/api</link>
<link>http://java.sun.com/j2se/1.5.0/docs/api</link>
<link>http://commons.apache.org/collections/apidocs-COLLECTIONS_3_0/</link>
<link>http://commons.apache.org/dbcp/apidocs/</link>
<link>http://commons.apache.org/fileupload/apidocs/</link>
<link>http://commons.apache.org/httpclient/apidocs/</link>
<link>http://commons.apache.org/logging/apidocs/</link>
<link>http://commons.apache.org/pool/apidocs/</link>
<link>http://junit.sourceforge.net/javadoc/</link>
<link>http://logging.apache.org/log4j/1.2/apidocs/</link>
<link>http://jakarta.apache.org/regexp/apidocs/</link>
<link>http://velocity.apache.org/engine/releases/velocity-1.5/apidocs/</link>
</links>
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugins>
</reporting>
</profile>
</profiles>
</project>