Skip to content

Commit

Permalink
[maven-scm] copy for tag maven-3.0-beta-3
Browse files Browse the repository at this point in the history
  • Loading branch information
bentmann committed Aug 30, 2010
2 parents 94bdc62 + 546399c commit b1ac777
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 43 deletions.
2 changes: 2 additions & 0 deletions build.xml
Expand Up @@ -78,6 +78,7 @@ Do you want to continue?</input>
<property name="maven.repo.local" value="${user.home}/.m2/repository" />
<property name="maven.debug" value="-e" />
<property name="maven.test.skip" value="false" />
<property name="skipTests" value="false" />
<property name="surefire.useFile" value="true" />
<property name="maven.test.redirectTestOutputToFile" value="${surefire.useFile}" />
<echo>maven.home = ${maven.home}</echo>
Expand Down Expand Up @@ -233,6 +234,7 @@ Do you want to continue?</input>
<arg value="clean" />
<arg value="install" />
<arg value="-Dmaven.test.skip=${maven.test.skip}" />
<arg value="-DskipTests=${skipTests}" />
<arg value="-Dmaven.repo.local=${maven.repo.local}" />
<arg value="-Dsurefire.useFile=${surefire.useFile}" />
<arg value="-Dmaven.test.redirectTestOutputToFile=${maven.test.redirectTestOutputToFile}" />
Expand Down
Expand Up @@ -19,7 +19,6 @@
* under the License.
*/

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -366,18 +365,13 @@ private Dependency convert( org.apache.maven.model.Dependency dependency, Artifa
Map<String, String> props = null;
if ( system )
{
props = Collections.singletonMap( ArtifactProperties.LACKS_DESCRIPTOR, Boolean.TRUE.toString() );
props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() );
}

Artifact artifact =
new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null,
dependency.getVersion(), props, stereotype );

if ( system )
{
artifact = artifact.setFile( new File( dependency.getSystemPath() ) );
}

List<Exclusion> exclusions = new ArrayList<Exclusion>( dependency.getExclusions().size() );
for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() )
{
Expand Down
Expand Up @@ -21,6 +21,7 @@

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

Expand All @@ -40,6 +41,8 @@ class VersionsMetadataGenerator

private Map<Object, VersionsMetadata> versions;

private Map<Object, VersionsMetadata> processedVersions;

public VersionsMetadataGenerator( RepositorySystemSession session, InstallRequest request )
{
this( session, request.getMetadata() );
Expand All @@ -53,19 +56,22 @@ public VersionsMetadataGenerator( RepositorySystemSession session, DeployRequest
private VersionsMetadataGenerator( RepositorySystemSession session, Collection<? extends Metadata> metadatas )
{
versions = new LinkedHashMap<Object, VersionsMetadata>();
processedVersions = new LinkedHashMap<Object, VersionsMetadata>();

/*
* NOTE: This should be considered a quirk to support interop with Maven's legacy ArtifactDeployer which
* processes one artifact at a time and hence cannot associate the artifacts from the same project to use the
* same timestamp+buildno for the snapshot versions. Allowing the caller to pass in metadata from a previous
* deployment allows to re-establish the association between the artifacts of the same project.
* same version index. Allowing the caller to pass in metadata from a previous deployment allows to re-establish
* the association between the artifacts of the same project.
*/
for ( Metadata metadata : metadatas )
for ( Iterator<? extends Metadata> it = metadatas.iterator(); it.hasNext(); )
{
Metadata metadata = it.next();
if ( metadata instanceof VersionsMetadata )
{
it.remove();
VersionsMetadata versionsMetadata = (VersionsMetadata) metadata;
versions.put( versionsMetadata.getKey(), versionsMetadata );
processedVersions.put( versionsMetadata.getKey(), versionsMetadata );
}
}
}
Expand All @@ -85,11 +91,14 @@ public Collection<? extends Metadata> finish( Collection<? extends Artifact> art
for ( Artifact artifact : artifacts )
{
Object key = VersionsMetadata.getKey( artifact );
VersionsMetadata versionsMetadata = versions.get( key );
if ( versionsMetadata == null )
if ( processedVersions.get( key ) == null )
{
versionsMetadata = new VersionsMetadata( artifact );
versions.put( key, versionsMetadata );
VersionsMetadata versionsMetadata = versions.get( key );
if ( versionsMetadata == null )
{
versionsMetadata = new VersionsMetadata( artifact );
versions.put( key, versionsMetadata );
}
}
}

Expand Down
Expand Up @@ -58,7 +58,7 @@ public class DefaultArtifactDeployer
@Requirement
private LegacySupport legacySupport;

private Map<Object, MergeableMetadata> snapshots = new ConcurrentHashMap<Object, MergeableMetadata>();
private Map<Object, MergeableMetadata> relatedMetadata = new ConcurrentHashMap<Object, MergeableMetadata>();

/**
* @deprecated we want to use the artifact method only, and ensure artifact.file is set
Expand Down Expand Up @@ -89,12 +89,14 @@ public void deploy( File source, Artifact artifact, ArtifactRepository deploymen
mainArtifact = mainArtifact.setFile( source );
request.addArtifact( mainArtifact );

String versionKey = artifact.getGroupId() + ':' + artifact.getArtifactId();
String snapshotKey = null;
if ( artifact.isSnapshot() )
{
snapshotKey = artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion();
request.addMetadata( snapshots.get( snapshotKey ) );
snapshotKey = versionKey + ':' + artifact.getBaseVersion();
request.addMetadata( relatedMetadata.get( snapshotKey ) );
}
request.addMetadata( relatedMetadata.get( versionKey ) );

for ( ArtifactMetadata metadata : artifact.getMetadataList() )
{
Expand Down Expand Up @@ -138,14 +140,15 @@ else if ( metadata instanceof SnapshotArtifactRepositoryMetadata
throw new ArtifactDeploymentException( e.getMessage(), e );
}

if ( snapshotKey != null )
for ( Object metadata : result.getMetadata() )
{
for ( Object metadata : result.getMetadata() )
if ( metadata.getClass().getName().endsWith( ".internal.VersionsMetadata" ) )
{
if ( metadata.getClass().getName().endsWith( ".internal.RemoteSnapshotMetadata" ) )
{
snapshots.put( snapshotKey, (MergeableMetadata) metadata );
}
relatedMetadata.put( versionKey, (MergeableMetadata) metadata );
}
if ( snapshotKey != null && metadata.getClass().getName().endsWith( ".internal.RemoteSnapshotMetadata" ) )
{
relatedMetadata.put( snapshotKey, (MergeableMetadata) metadata );
}
}

Expand Down
16 changes: 15 additions & 1 deletion maven-core/pom.xml
Expand Up @@ -56,12 +56,23 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-impl</artifactId>
<version>${aetherVersion}</version>
</dependency>
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-api</artifactId>
<version>${aetherVersion}</version>
</dependency>
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-util</artifactId>
<version>${aetherVersion}</version>
</dependency>
<!-- Plexus -->
<dependency>
<groupId>org.sonatype.spice</groupId>
Expand Down Expand Up @@ -132,7 +143,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<version>1.0-beta-4</version>
<executions>
<execution>
<phase>generate-resources</phase>
Expand All @@ -144,6 +155,9 @@
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
</configuration>
</plugin>
</plugins>
Expand Down
Expand Up @@ -81,6 +81,7 @@ public class DefaultArtifactFilterManager
artifacts.add( "org.apache.maven.wagon:wagon-provider-api" );
artifacts.add( "org.sonatype.aether:aether-api" );
artifacts.add( "org.sonatype.aether:aether-spi" );
artifacts.add( "org.sonatype.aether:aether-impl" );

/*
* NOTE: Don't exclude the wagons or any of their dependencies (apart from the wagon API). This would otherwise
Expand Down
47 changes: 46 additions & 1 deletion maven-core/src/main/java/org/apache/maven/DefaultMaven.java
Expand Up @@ -16,6 +16,8 @@
*/

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -27,6 +29,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
Expand Down Expand Up @@ -66,8 +69,10 @@
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.dag.CycleDetectedException;
import org.sonatype.aether.ConfigurationProperties;
import org.sonatype.aether.RepositoryEvent;
import org.sonatype.aether.RepositorySystem;
import org.sonatype.aether.RepositorySystemSession;
Expand Down Expand Up @@ -329,7 +334,12 @@ public RepositorySystemSession newRepositorySession( MavenExecutionRequest reque

session.setUserProps( request.getUserProperties() );
session.setSystemProps( request.getSystemProperties() );
session.setConfigProps( request.getSystemProperties() );
Map<Object, Object> configProps = new LinkedHashMap<Object, Object>();
configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() );
configProps.put( ConfigurationProperties.INTERACTIVE, Boolean.valueOf( request.isInteractiveMode() ) );
configProps.putAll( request.getSystemProperties() );
configProps.putAll( request.getUserProperties() );
session.setConfigProps( configProps );

session.setOffline( request.isOffline() );
session.setChecksumPolicy( request.getGlobalChecksumPolicy() );
Expand Down Expand Up @@ -445,6 +455,41 @@ public void artifactDescriptorMissing( RepositoryEvent event )
return session;
}

private String getUserAgent()
{
StringBuilder buffer = new StringBuilder( 128 );

buffer.append( "Apache-Maven/" ).append( getMavenVersion() );
buffer.append( " (" );
buffer.append( "Java " ).append( System.getProperty( "java.version" ) );
buffer.append( "; " );
buffer.append( System.getProperty( "os.name" ) ).append( " " ).append( System.getProperty( "os.version" ) );
buffer.append( ")" );

return buffer.toString();
}

private String getMavenVersion()
{
Properties props = new Properties();

InputStream is = getClass().getResourceAsStream( "/META-INF/maven/org.apache.maven/maven-core/pom.properties" );
if ( is != null )
{
try
{
props.load( is );
}
catch ( IOException e )
{
logger.debug( "Failed to read Maven version", e );
}
IOUtil.close( is );
}

return props.getProperty( "version", "unknown-version" );
}

@SuppressWarnings({"ResultOfMethodCallIgnored"})
private void validateLocalRepository( MavenExecutionRequest request )
throws LocalRepositoryNotAccessibleException
Expand Down
10 changes: 3 additions & 7 deletions maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
Expand Up @@ -142,7 +142,8 @@ public static Artifact toArtifact( org.apache.maven.artifact.Artifact artifact )
Map<String, String> props = null;
if ( org.apache.maven.artifact.Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
{
props = Collections.singletonMap( ArtifactProperties.LACKS_DESCRIPTOR, Boolean.TRUE.toString() );
String localPath = ( artifact.getFile() != null ) ? artifact.getFile().getPath() : "";
props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, localPath );
}

Artifact result =
Expand Down Expand Up @@ -270,18 +271,13 @@ public static Dependency toDependency( org.apache.maven.model.Dependency depende
Map<String, String> props = null;
if ( system )
{
props = Collections.singletonMap( ArtifactProperties.LACKS_DESCRIPTOR, Boolean.TRUE.toString() );
props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() );
}

Artifact artifact =
new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null,
dependency.getVersion(), props, stereotype );

if ( system )
{
artifact = artifact.setFile( new File( dependency.getSystemPath() ) );
}

List<Exclusion> exclusions = new ArrayList<Exclusion>( dependency.getExclusions().size() );
for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() )
{
Expand Down
Expand Up @@ -33,5 +33,6 @@ public interface ArtifactHandlerManager

ArtifactHandler getArtifactHandler( String type );

@Deprecated
void addHandlers( Map<String, ArtifactHandler> handlers );
}
}
Expand Up @@ -21,6 +21,7 @@

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
Expand All @@ -35,28 +36,39 @@
public class DefaultArtifactHandlerManager
implements ArtifactHandlerManager
{

@Requirement( role = ArtifactHandler.class )
private Map<String, ArtifactHandler> artifactHandlers;

private Map<String, ArtifactHandler> unmanagedHandlers = new ConcurrentHashMap<String, ArtifactHandler>();

public ArtifactHandler getArtifactHandler( String type )
{
ArtifactHandler handler = artifactHandlers.get( type );
ArtifactHandler handler = unmanagedHandlers.get( type );

if ( handler == null )
{
handler = new DefaultArtifactHandler( type );
handler = artifactHandlers.get( type );

if ( handler == null )
{
handler = new DefaultArtifactHandler( type );
}
}

return handler;
}

public void addHandlers( Map<String, ArtifactHandler> handlers )
{
artifactHandlers.putAll( handlers );
// legacy support for maven-gpg-plugin:1.0
unmanagedHandlers.putAll( handlers );
}

@Deprecated
public Set<String> getHandlerTypes()
{
return artifactHandlers.keySet();
}

}

0 comments on commit b1ac777

Please sign in to comment.