mirror of https://github.com/apache/maven.git
PR: MNG-613
changes versioning to use repository metadata git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@278881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a5b853b357
commit
8f3c207194
|
@ -154,6 +154,9 @@
|
||||||
<requirement>
|
<requirement>
|
||||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||||
</requirement>
|
</requirement>
|
||||||
|
<requirement>
|
||||||
|
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
|
||||||
|
</requirement>
|
||||||
</requirements>
|
</requirements>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
@ -165,6 +168,9 @@
|
||||||
<requirement>
|
<requirement>
|
||||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||||
</requirement>
|
</requirement>
|
||||||
|
<requirement>
|
||||||
|
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
|
||||||
|
</requirement>
|
||||||
</requirements>
|
</requirements>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
@ -176,6 +182,9 @@
|
||||||
<requirement>
|
<requirement>
|
||||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||||
</requirement>
|
</requirement>
|
||||||
|
<requirement>
|
||||||
|
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
|
||||||
|
</requirement>
|
||||||
</requirements>
|
</requirements>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class DefaultArtifactDeployer
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
transformationManager.transformForDeployment( artifact, deploymentRepository );
|
transformationManager.transformForDeployment( artifact, deploymentRepository, localRepository );
|
||||||
|
|
||||||
// Copy the original file to the new one if it was transformed
|
// Copy the original file to the new one if it was transformed
|
||||||
File artifactFile = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
|
File artifactFile = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
|
||||||
|
|
|
@ -215,7 +215,8 @@ public class DefaultWagonManager
|
||||||
// This one we will eat when looking through remote repositories
|
// This one we will eat when looking through remote repositories
|
||||||
// because we want to cycle through them all before squawking.
|
// because we want to cycle through them all before squawking.
|
||||||
|
|
||||||
getLogger().warn( "Unable to get resource from repository " + repository.getId() + " (" + repository.getUrl() + ")" );
|
getLogger().warn(
|
||||||
|
"Unable to get resource from repository " + repository.getId() + " (" + repository.getUrl() + ")" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +237,7 @@ public class DefaultWagonManager
|
||||||
{
|
{
|
||||||
getLogger().debug( "Trying repository " + repository.getId() );
|
getLogger().debug( "Trying repository " + repository.getId() );
|
||||||
getRemoteFile( repository, artifact.getFile(), remotePath, downloadMonitor, policy.getChecksumPolicy() );
|
getRemoteFile( repository, artifact.getFile(), remotePath, downloadMonitor, policy.getChecksumPolicy() );
|
||||||
getLogger().debug( " Artifact resolved");
|
getLogger().debug( " Artifact resolved" );
|
||||||
|
|
||||||
artifact.setResolved( true );
|
artifact.setResolved( true );
|
||||||
}
|
}
|
||||||
|
@ -252,7 +253,6 @@ public class DefaultWagonManager
|
||||||
{
|
{
|
||||||
String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata );
|
String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata );
|
||||||
|
|
||||||
getLogger().info( "Retrieving " + metadata );
|
|
||||||
getRemoteFile( repository, destination, remotePath, null, checksumPolicy );
|
getRemoteFile( repository, destination, remotePath, null, checksumPolicy );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ import java.util.Date;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractVersionArtifactMetadata
|
public abstract class AbstractVersionArtifactMetadata
|
||||||
extends AbstractArtifactMetadata
|
extends AbstractArtifactMetadata
|
||||||
implements VersionArtifactMetadata
|
implements LegacyArtifactMetadata
|
||||||
{
|
{
|
||||||
protected static final String SNAPSHOT_VERSION_FILE = "version.txt";
|
protected static final String SNAPSHOT_VERSION_FILE = "version.txt";
|
||||||
|
|
||||||
|
@ -46,13 +46,7 @@ public abstract class AbstractVersionArtifactMetadata
|
||||||
super( artifact );
|
super( artifact );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File getLocalRepositoryLocation( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
public void readFromFile( File file )
|
||||||
{
|
|
||||||
return new File( localRepository.getBasedir(),
|
|
||||||
localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readFromFile( File file )
|
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
setContent( FileUtils.fileRead( file ) );
|
setContent( FileUtils.fileRead( file ) );
|
||||||
|
@ -61,26 +55,6 @@ public abstract class AbstractVersionArtifactMetadata
|
||||||
|
|
||||||
protected abstract void setContent( String content );
|
protected abstract void setContent( String content );
|
||||||
|
|
||||||
public boolean exists()
|
|
||||||
{
|
|
||||||
return lastModified > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getLastModified()
|
|
||||||
{
|
|
||||||
return new Date( lastModified );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readFromLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
File f = getLocalRepositoryLocation( localRepository, remoteRepository );
|
|
||||||
if ( f.exists() )
|
|
||||||
{
|
|
||||||
readFromFile( f );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager,
|
public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager,
|
||||||
String checksumPolicy )
|
String checksumPolicy )
|
||||||
throws ArtifactMetadataRetrievalException, ResourceDoesNotExistException
|
throws ArtifactMetadataRetrievalException, ResourceDoesNotExistException
|
||||||
|
@ -105,7 +79,7 @@ public abstract class AbstractVersionArtifactMetadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
public void storeInLocalRepository( ArtifactRepository localRepository )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
String version = constructVersion();
|
String version = constructVersion();
|
||||||
|
@ -113,11 +87,10 @@ public abstract class AbstractVersionArtifactMetadata
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String path = getLocalRepositoryLocation( localRepository, remoteRepository ).getPath();
|
File file = new File( localRepository.getBasedir(),
|
||||||
File file = new File( path );
|
localRepository.pathOfLocalRepositoryMetadata( this, null ) );
|
||||||
// TODO: this should be centralised before the resolution of the artifact
|
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
FileUtils.fileWrite( path, version );
|
FileUtils.fileWrite( file.getPath(), version );
|
||||||
lastModified = file.lastModified();
|
lastModified = file.lastModified();
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
|
@ -126,4 +99,15 @@ public abstract class AbstractVersionArtifactMetadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
throw new IllegalStateException( "This code should no longer be called" );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastModified()
|
||||||
|
{
|
||||||
|
return new Date( lastModified );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ public class LatestArtifactMetadata
|
||||||
{
|
{
|
||||||
LatestArtifactMetadata metadata = (LatestArtifactMetadata) o;
|
LatestArtifactMetadata metadata = (LatestArtifactMetadata) o;
|
||||||
|
|
||||||
// TODO: we need some more complicated version comparison
|
|
||||||
if ( version == null )
|
if ( version == null )
|
||||||
{
|
{
|
||||||
if ( metadata.version == null )
|
if ( metadata.version == null )
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
package org.apache.maven.artifact.metadata;
|
package org.apache.maven.artifact.metadata;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.manager.WagonManager;
|
||||||
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2001-2005 The Apache Software Foundation.
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
*
|
*
|
||||||
|
@ -16,36 +24,27 @@ package org.apache.maven.artifact.metadata;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains metadata about a versioned artifact.
|
* Methods used by the old artifact metadata. To be removed in beta-2.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public interface VersionArtifactMetadata
|
public interface LegacyArtifactMetadata
|
||||||
extends ArtifactMetadata, Comparable
|
extends ArtifactMetadata, Comparable
|
||||||
{
|
{
|
||||||
/**
|
void readFromFile( File file )
|
||||||
* Determine if the metadata is considered newer than a given file.
|
throws IOException;
|
||||||
*
|
|
||||||
* @return whether it is newer
|
void retrieveFromRemoteRepository( ArtifactRepository repository, WagonManager wagonManager, String checksumPolicy )
|
||||||
*/
|
throws ArtifactMetadataRetrievalException, ResourceDoesNotExistException;
|
||||||
|
|
||||||
|
void storeInLocalRepository( ArtifactRepository localRepository )
|
||||||
|
throws ArtifactMetadataRetrievalException;
|
||||||
|
|
||||||
boolean newerThanFile( File file );
|
boolean newerThanFile( File file );
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the resolved version from the metadata.
|
|
||||||
*
|
|
||||||
* @return the resolved version
|
|
||||||
*/
|
|
||||||
String constructVersion();
|
String constructVersion();
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine when the metadata was last modified.
|
|
||||||
*
|
|
||||||
* @return the date the metadata was last modified.
|
|
||||||
*/
|
|
||||||
Date getLastModified();
|
Date getLastModified();
|
||||||
}
|
}
|
|
@ -30,7 +30,6 @@ import java.io.File;
|
||||||
*/
|
*/
|
||||||
public class ReleaseArtifactMetadata
|
public class ReleaseArtifactMetadata
|
||||||
extends AbstractVersionArtifactMetadata
|
extends AbstractVersionArtifactMetadata
|
||||||
implements Comparable
|
|
||||||
{
|
{
|
||||||
private String version;
|
private String version;
|
||||||
|
|
||||||
|
@ -63,7 +62,6 @@ public class ReleaseArtifactMetadata
|
||||||
{
|
{
|
||||||
ReleaseArtifactMetadata metadata = (ReleaseArtifactMetadata) o;
|
ReleaseArtifactMetadata metadata = (ReleaseArtifactMetadata) o;
|
||||||
|
|
||||||
// TODO: we need some more complicated version comparison
|
|
||||||
if ( version == null )
|
if ( version == null )
|
||||||
{
|
{
|
||||||
if ( metadata.version == null )
|
if ( metadata.version == null )
|
||||||
|
|
|
@ -97,12 +97,6 @@ public class SnapshotArtifactMetadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVersion( String timestamp, int buildNumber )
|
|
||||||
{
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
this.buildNumber = buildNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTimestamp()
|
public String getTimestamp()
|
||||||
{
|
{
|
||||||
return timestamp;
|
return timestamp;
|
||||||
|
@ -124,9 +118,6 @@ public class SnapshotArtifactMetadata
|
||||||
{
|
{
|
||||||
SnapshotArtifactMetadata metadata = (SnapshotArtifactMetadata) o;
|
SnapshotArtifactMetadata metadata = (SnapshotArtifactMetadata) o;
|
||||||
|
|
||||||
// TODO: probably shouldn't test timestamp - except that it may be used do differentiate for a build number of 0
|
|
||||||
// in the local repository. check, then remove from here and just compare the build numbers
|
|
||||||
|
|
||||||
if ( buildNumber > metadata.buildNumber )
|
if ( buildNumber > metadata.buildNumber )
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -66,8 +66,20 @@ public class DefaultArtifactRepository
|
||||||
|
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
|
|
||||||
|
if ( snapshots == null )
|
||||||
|
{
|
||||||
|
snapshots = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
|
||||||
|
ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
|
||||||
|
}
|
||||||
|
|
||||||
this.snapshots = snapshots;
|
this.snapshots = snapshots;
|
||||||
|
|
||||||
|
if ( releases == null )
|
||||||
|
{
|
||||||
|
releases = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
|
||||||
|
ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
|
||||||
|
}
|
||||||
|
|
||||||
this.releases = releases;
|
this.releases = releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
package org.apache.maven.artifact.repository.metadata;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.metadata.ArtifactMetadata;
|
||||||
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared methods of the repository metadata handling.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public abstract class AbstractRepositoryMetadata
|
||||||
|
implements ArtifactMetadata
|
||||||
|
{
|
||||||
|
public String getRemoteFilename()
|
||||||
|
{
|
||||||
|
return "maven-metadata.xml";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalFilename( ArtifactRepository repository )
|
||||||
|
{
|
||||||
|
return "maven-metadata-" + repository.getKey() + ".xml";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
updateRepositoryMetadata( localRepository, remoteRepository );
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new ArtifactMetadataRetrievalException( "Error updating group repository metadata", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void updateRepositoryMetadata( ArtifactRepository localRepository,
|
||||||
|
ArtifactRepository remoteRepository )
|
||||||
|
throws IOException;
|
||||||
|
}
|
|
@ -0,0 +1,220 @@
|
||||||
|
package org.apache.maven.artifact.repository.metadata;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.Artifact;
|
||||||
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
|
||||||
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metadata for the artifact directory of the repository.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
|
* @version $Id$
|
||||||
|
* @todo split instantiation (versioning, plugin mappings) from definition
|
||||||
|
*/
|
||||||
|
public class ArtifactRepositoryMetadata
|
||||||
|
extends AbstractRepositoryMetadata
|
||||||
|
{
|
||||||
|
private Versioning versioning;
|
||||||
|
|
||||||
|
private Artifact artifact;
|
||||||
|
|
||||||
|
public ArtifactRepositoryMetadata( Artifact artifact )
|
||||||
|
{
|
||||||
|
this.artifact = artifact;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArtifactRepositoryMetadata( Artifact artifact, Versioning versioning )
|
||||||
|
{
|
||||||
|
this.versioning = versioning;
|
||||||
|
this.artifact = artifact;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "repository metadata for artifact: \'" + artifact + "\'";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean storedInGroupDirectory()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean storedInArtifactVersionDirectory()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupId()
|
||||||
|
{
|
||||||
|
return artifact.getGroupId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArtifactId()
|
||||||
|
{
|
||||||
|
return artifact.getArtifactId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBaseVersion()
|
||||||
|
{
|
||||||
|
return artifact.getBaseVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateRepositoryMetadata( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
|
||||||
|
|
||||||
|
Metadata metadata = null;
|
||||||
|
|
||||||
|
File metadataFile = new File( localRepository.getBasedir(),
|
||||||
|
localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) );
|
||||||
|
|
||||||
|
if ( metadataFile.exists() )
|
||||||
|
{
|
||||||
|
Reader reader = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
reader = new FileReader( metadataFile );
|
||||||
|
|
||||||
|
metadata = mappingReader.read( reader );
|
||||||
|
}
|
||||||
|
catch ( FileNotFoundException e )
|
||||||
|
{
|
||||||
|
// TODO: Log a warning
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
// TODO: Log a warning
|
||||||
|
}
|
||||||
|
catch ( XmlPullParserException e )
|
||||||
|
{
|
||||||
|
// TODO: Log a warning
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtil.close( reader );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
|
// If file could not be found or was not valid, start from scratch
|
||||||
|
if ( metadata == null )
|
||||||
|
{
|
||||||
|
metadata = new Metadata();
|
||||||
|
|
||||||
|
metadata.setGroupId( artifact.getGroupId() );
|
||||||
|
metadata.setArtifactId( artifact.getArtifactId() );
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( versioning != null )
|
||||||
|
{
|
||||||
|
Versioning v = metadata.getVersioning();
|
||||||
|
if ( v != null )
|
||||||
|
{
|
||||||
|
// TODO: merge versioning (reuse code from transformation)
|
||||||
|
Snapshot s = v.getSnapshot();
|
||||||
|
Snapshot snapshot = versioning.getSnapshot();
|
||||||
|
if ( snapshot != null )
|
||||||
|
{
|
||||||
|
if ( s == null )
|
||||||
|
{
|
||||||
|
v.setSnapshot( snapshot );
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
else if ( s.getTimestamp() != null && !s.getTimestamp().equals( snapshot.getTimestamp() ) )
|
||||||
|
{
|
||||||
|
s.setTimestamp( snapshot.getTimestamp() );
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
else if ( s.getBuildNumber() != snapshot.getBuildNumber() )
|
||||||
|
{
|
||||||
|
s.setBuildNumber( snapshot.getBuildNumber() );
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
metadata.setVersioning( versioning );
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( changed )
|
||||||
|
{
|
||||||
|
Writer writer = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
metadataFile.getParentFile().mkdirs();
|
||||||
|
writer = new FileWriter( metadataFile );
|
||||||
|
|
||||||
|
MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer();
|
||||||
|
|
||||||
|
mappingWriter.write( writer, metadata );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtil.close( writer );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
metadataFile.setLastModified( System.currentTimeMillis() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getKey()
|
||||||
|
{
|
||||||
|
return artifact.getGroupId() + ":" + artifact.getArtifactId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSnapshot()
|
||||||
|
{
|
||||||
|
return artifact.isSnapshot();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Snapshot getSnapshot()
|
||||||
|
{
|
||||||
|
return versioning != null ? versioning.getSnapshot() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLatestVersion()
|
||||||
|
{
|
||||||
|
return versioning.getLatest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReleaseVersion()
|
||||||
|
{
|
||||||
|
return versioning.getRelease();
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,7 +57,7 @@ public class DefaultRepositoryMetadataManager
|
||||||
ArtifactRepositoryPolicy policy = metadata.isSnapshot() ? repository.getSnapshots()
|
ArtifactRepositoryPolicy policy = metadata.isSnapshot() ? repository.getSnapshots()
|
||||||
: repository.getReleases();
|
: repository.getReleases();
|
||||||
|
|
||||||
if ( policy == null || !policy.isEnabled() )
|
if ( !policy.isEnabled() )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Skipping disabled repository " + repository.getId() );
|
getLogger().debug( "Skipping disabled repository " + repository.getId() );
|
||||||
}
|
}
|
||||||
|
@ -66,37 +66,23 @@ public class DefaultRepositoryMetadataManager
|
||||||
File file = new File( localRepository.getBasedir(),
|
File file = new File( localRepository.getBasedir(),
|
||||||
localRepository.pathOfLocalRepositoryMetadata( metadata, repository ) );
|
localRepository.pathOfLocalRepositoryMetadata( metadata, repository ) );
|
||||||
|
|
||||||
// TODO: should be able to calculate this less often
|
|
||||||
boolean checkForUpdates = policy.checkOutOfDate( new Date( file.lastModified() ) );
|
boolean checkForUpdates = policy.checkOutOfDate( new Date( file.lastModified() ) );
|
||||||
|
|
||||||
if ( checkForUpdates )
|
if ( checkForUpdates )
|
||||||
{
|
{
|
||||||
|
|
||||||
getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() );
|
getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() );
|
||||||
|
|
||||||
try
|
resolveAlways( metadata, repository, file, policy.getChecksumPolicy() );
|
||||||
{
|
}
|
||||||
wagonManager.getArtifactMetadata( metadata, repository, file, policy.getChecksumPolicy() );
|
|
||||||
|
|
||||||
// TODO: ???
|
// touch file so that this is not checked again until interval has passed
|
||||||
// metadata.setRepository( repository );
|
if ( file.exists() )
|
||||||
|
{
|
||||||
// touch file so that this is not checked again until interval has passed
|
file.setLastModified( System.currentTimeMillis() );
|
||||||
if ( file.exists() )
|
}
|
||||||
{
|
else
|
||||||
file.setLastModified( System.currentTimeMillis() );
|
{
|
||||||
}
|
metadata.storeInLocalRepository( localRepository, repository );
|
||||||
}
|
|
||||||
catch ( ResourceDoesNotExistException e )
|
|
||||||
{
|
|
||||||
getLogger().info( "Repository metadata " + metadata +
|
|
||||||
" could not be found on repository: " + repository.getId() );
|
|
||||||
getLogger().debug( "Cause", e );
|
|
||||||
}
|
|
||||||
catch ( TransferFailedException e )
|
|
||||||
{
|
|
||||||
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +91,40 @@ public class DefaultRepositoryMetadataManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resolveAlways( ArtifactMetadata metadata, ArtifactRepository localRepository,
|
||||||
|
ArtifactRepository remoteRepository )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
File file = new File( localRepository.getBasedir(),
|
||||||
|
localRepository.pathOfLocalRepositoryMetadata( metadata, remoteRepository ) );
|
||||||
|
|
||||||
|
resolveAlways( metadata, localRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resolveAlways( ArtifactMetadata metadata, ArtifactRepository repository, File file,
|
||||||
|
String checksumPolicy )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
wagonManager.getArtifactMetadata( metadata, repository, file, checksumPolicy );
|
||||||
|
}
|
||||||
|
catch ( ResourceDoesNotExistException e )
|
||||||
|
{
|
||||||
|
getLogger().debug( metadata + " could not be found on repository: " + repository.getId() );
|
||||||
|
|
||||||
|
// delete the local copy so the old details aren't used.
|
||||||
|
if ( file.exists() )
|
||||||
|
{
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( TransferFailedException e )
|
||||||
|
{
|
||||||
|
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean alreadyResolved( ArtifactMetadata metadata )
|
private boolean alreadyResolved( ArtifactMetadata metadata )
|
||||||
{
|
{
|
||||||
return cachedMetadata.contains( metadata.getKey() );
|
return cachedMetadata.contains( metadata.getKey() );
|
||||||
|
|
|
@ -16,8 +16,6 @@ package org.apache.maven.artifact.repository.metadata;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
||||||
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
|
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
|
||||||
|
@ -42,7 +40,7 @@ import java.util.Map;
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class GroupRepositoryMetadata
|
public class GroupRepositoryMetadata
|
||||||
implements ArtifactMetadata
|
extends AbstractRepositoryMetadata
|
||||||
{
|
{
|
||||||
private final String groupId;
|
private final String groupId;
|
||||||
|
|
||||||
|
@ -58,32 +56,6 @@ public class GroupRepositoryMetadata
|
||||||
return "repository metadata for group: \'" + groupId + "\'";
|
return "repository metadata for group: \'" + groupId + "\'";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
|
||||||
throws ArtifactMetadataRetrievalException
|
|
||||||
{
|
|
||||||
if ( !pluginMappings.isEmpty() )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
updateRepositoryMetadata( localRepository, remoteRepository );
|
|
||||||
}
|
|
||||||
catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new ArtifactMetadataRetrievalException( "Error updating group repository metadata", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRemoteFilename()
|
|
||||||
{
|
|
||||||
return "maven-metadata.xml";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLocalFilename( ArtifactRepository repository )
|
|
||||||
{
|
|
||||||
return "maven-metadata-" + repository.getKey() + ".xml";
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean storedInGroupDirectory()
|
public boolean storedInGroupDirectory()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -114,7 +86,7 @@ public class GroupRepositoryMetadata
|
||||||
pluginMappings.put( goalPrefix, artifactId );
|
pluginMappings.put( goalPrefix, artifactId );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRepositoryMetadata( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
protected void updateRepositoryMetadata( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
|
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
|
||||||
|
@ -152,12 +124,16 @@ public class GroupRepositoryMetadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
// If file could not be found or was not valid, start from scratch
|
// If file could not be found or was not valid, start from scratch
|
||||||
if ( pluginMap == null )
|
if ( pluginMap == null )
|
||||||
{
|
{
|
||||||
pluginMap = new Metadata();
|
pluginMap = new Metadata();
|
||||||
|
|
||||||
pluginMap.setGroupId( groupId );
|
pluginMap.setGroupId( groupId );
|
||||||
|
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Iterator i = pluginMappings.keySet().iterator(); i.hasNext(); )
|
for ( Iterator i = pluginMappings.keySet().iterator(); i.hasNext(); )
|
||||||
|
@ -187,21 +163,30 @@ public class GroupRepositoryMetadata
|
||||||
mappedPlugin.setPrefix( prefix );
|
mappedPlugin.setPrefix( prefix );
|
||||||
|
|
||||||
pluginMap.addPlugin( mappedPlugin );
|
pluginMap.addPlugin( mappedPlugin );
|
||||||
|
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Writer writer = null;
|
if ( changed )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
writer = new FileWriter( metadataFile );
|
Writer writer = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
writer = new FileWriter( metadataFile );
|
||||||
|
|
||||||
MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer();
|
MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer();
|
||||||
|
|
||||||
mappingWriter.write( writer, pluginMap );
|
mappingWriter.write( writer, pluginMap );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtil.close( writer );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
else
|
||||||
{
|
{
|
||||||
IOUtil.close( writer );
|
metadataFile.setLastModified( System.currentTimeMillis() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,15 +131,6 @@ public class DefaultArtifactResolver
|
||||||
"Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.",
|
"Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.",
|
||||||
artifact, remoteRepositories );
|
artifact, remoteRepositories );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: pretty sure this can be removed. No metadata on resolved artifacts
|
|
||||||
// must be after the artifact is downloaded
|
|
||||||
for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); )
|
|
||||||
{
|
|
||||||
ArtifactMetadata metadata = (ArtifactMetadata) i.next();
|
|
||||||
metadata.storeInLocalRepository( localRepository );
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
catch ( ResourceDoesNotExistException e )
|
catch ( ResourceDoesNotExistException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,16 +18,27 @@ package org.apache.maven.artifact.transform;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.manager.WagonManager;
|
import org.apache.maven.artifact.manager.WagonManager;
|
||||||
import org.apache.maven.artifact.metadata.AbstractVersionArtifactMetadata;
|
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
import org.apache.maven.artifact.metadata.VersionArtifactMetadata;
|
import org.apache.maven.artifact.metadata.LegacyArtifactMetadata;
|
||||||
|
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.Metadata;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.Snapshot;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
|
||||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -38,33 +49,82 @@ import java.util.Set;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
* @todo try and refactor to remove abstract methods - not particular happy about current design
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractVersionTransformation
|
public abstract class AbstractVersionTransformation
|
||||||
extends AbstractLogEnabled
|
extends AbstractLogEnabled
|
||||||
implements ArtifactTransformation
|
implements ArtifactTransformation
|
||||||
{
|
{
|
||||||
|
protected RepositoryMetadataManager repositoryMetadataManager;
|
||||||
|
|
||||||
protected WagonManager wagonManager;
|
protected WagonManager wagonManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo very primitve. Probably we can cache artifacts themselves in a central location, as well as reset the flag over time in a long running process.
|
* @todo remove in beta-2 - used for legacy handling
|
||||||
*/
|
*/
|
||||||
private static Set resolvedArtifactCache = new HashSet();
|
private static Set resolvedArtifactCache = new HashSet();
|
||||||
|
|
||||||
protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
ArtifactMetadata localMetadata = resolveMetadata( artifact, localRepository, remoteRepositories );
|
// TODO: can we improve on this?
|
||||||
|
ArtifactMetadata metadata = new ArtifactRepositoryMetadata( artifact );
|
||||||
|
|
||||||
String version;
|
repositoryMetadataManager.resolve( metadata, remoteRepositories, localRepository );
|
||||||
|
|
||||||
if ( localMetadata == null )
|
/*
|
||||||
|
// TODO: can this go directly into the manager? At least share with DefaultPluginMappingManager
|
||||||
|
// TODO: use this, cache the output, select from that list instead of the next set
|
||||||
|
Versioning versioning = new Versioning();
|
||||||
|
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
version = artifact.getVersion();
|
ArtifactRepository repository = (ArtifactRepository) i.next();
|
||||||
|
|
||||||
|
mergeVersioning( versioning, loadVersioningInformation( metadata, repository, localRepository ) );
|
||||||
}
|
}
|
||||||
else
|
mergeVersioning( versioning, loadVersioningInformation( metadata, localRepository, localRepository ) );
|
||||||
|
|
||||||
|
String version = selectVersion( versioning, artifact.getVersion() );
|
||||||
|
*/
|
||||||
|
ArtifactRepositoryMetadata localMetadata = null;
|
||||||
|
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
VersionArtifactMetadata versionMetadata = (VersionArtifactMetadata) localMetadata;
|
ArtifactRepository repository = (ArtifactRepository) i.next();
|
||||||
version = versionMetadata.constructVersion();
|
|
||||||
|
localMetadata = loadVersioningInformation( metadata, repository, localRepository, artifact );
|
||||||
|
if ( localMetadata != null )
|
||||||
|
{
|
||||||
|
artifact.setRepository( repository );
|
||||||
|
// TODO: merge instead (see above)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArtifactRepositoryMetadata m = loadVersioningInformation( metadata, localRepository, localRepository,
|
||||||
|
artifact );
|
||||||
|
if ( m != null )
|
||||||
|
{
|
||||||
|
localMetadata = m;
|
||||||
|
// TODO: figure out way to avoid duplicated message
|
||||||
|
if ( getLogger().isDebugEnabled() /*&& !alreadyResolved*/ )
|
||||||
|
{
|
||||||
|
// Locally installed file is newer, don't use the resolved version
|
||||||
|
getLogger().debug( artifact.getArtifactId() + ": using locally installed snapshot" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String version = null;
|
||||||
|
if ( localMetadata != null )
|
||||||
|
{
|
||||||
|
version = constructVersion( localMetadata );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version == null )
|
||||||
|
{
|
||||||
|
version = resolveLegacyVersion( artifact, localRepository, remoteRepositories );
|
||||||
|
if ( version == null )
|
||||||
|
{
|
||||||
|
version = artifact.getVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: also do this logging for other metadata?
|
// TODO: also do this logging for other metadata?
|
||||||
|
@ -87,28 +147,95 @@ public abstract class AbstractVersionTransformation
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected Snapshot resolveLatestSnapshotVersion( Artifact artifact, ArtifactRepository localRepository,
|
||||||
* @param artifact
|
ArtifactRepository remoteRepository )
|
||||||
* @param localRepository
|
|
||||||
* @param remoteRepositories
|
|
||||||
* @return
|
|
||||||
* @throws ArtifactMetadataRetrievalException
|
|
||||||
* @todo share with DefaultRepositoryMetadataManager
|
|
||||||
*/
|
|
||||||
private ArtifactMetadata resolveMetadata( Artifact artifact, ArtifactRepository localRepository,
|
|
||||||
List remoteRepositories )
|
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
getLogger().debug( "resolveMetaData(" + artifact.getId()+ "): repositories: " + remoteRepositories);
|
// TODO: can we improve on this?
|
||||||
|
ArtifactMetadata metadata = new ArtifactRepositoryMetadata( artifact );
|
||||||
|
|
||||||
VersionArtifactMetadata localMetadata;
|
repositoryMetadataManager.resolveAlways( metadata, localRepository, remoteRepository );
|
||||||
try
|
|
||||||
|
ArtifactRepositoryMetadata m = loadVersioningInformation( metadata, remoteRepository, localRepository,
|
||||||
|
artifact );
|
||||||
|
Snapshot snapshot;
|
||||||
|
if ( m == null )
|
||||||
{
|
{
|
||||||
localMetadata = readFromLocalRepository( artifact, localRepository );
|
snapshot = new Snapshot();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SnapshotArtifactMetadata snapshotMetadata = new SnapshotArtifactMetadata( artifact );
|
||||||
|
snapshotMetadata.retrieveFromRemoteRepository( remoteRepository, wagonManager,
|
||||||
|
ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
|
||||||
|
getLogger().warn( "Using old-style versioning metadata from remote repo for " + artifact );
|
||||||
|
|
||||||
|
snapshot.setTimestamp( snapshotMetadata.getTimestamp() );
|
||||||
|
snapshot.setBuildNumber( snapshotMetadata.getBuildNumber() );
|
||||||
|
}
|
||||||
|
catch ( ResourceDoesNotExistException e1 )
|
||||||
|
{
|
||||||
|
// safe to ignore, use default snapshot data
|
||||||
|
getLogger().debug( "Unable to find legacy metadata - ignoring" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
else
|
||||||
{
|
{
|
||||||
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
|
snapshot = m.getSnapshot();
|
||||||
|
}
|
||||||
|
return snapshot;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract String constructVersion( ArtifactRepositoryMetadata metadata );
|
||||||
|
|
||||||
|
/* TODO
|
||||||
|
private void mergeVersioning( Versioning dest, Versioning source )
|
||||||
|
{
|
||||||
|
// TODO: currently, it is first wins. We should probably compare the versions, or check timestamping?
|
||||||
|
// This could also let us choose the newer of the locally installed version and the remotely built version
|
||||||
|
if ( dest.getLatest() == null )
|
||||||
|
{
|
||||||
|
dest.setLatest( source.getLatest() );
|
||||||
|
}
|
||||||
|
if ( dest.getRelease() == null )
|
||||||
|
{
|
||||||
|
dest.setRelease( source.getRelease() );
|
||||||
|
}
|
||||||
|
if ( dest.getSnapshot() == null )
|
||||||
|
{
|
||||||
|
dest.setSnapshot( source.getSnapshot() );
|
||||||
|
}
|
||||||
|
for ( Iterator i = source.getVersions().iterator(); i.hasNext(); )
|
||||||
|
{
|
||||||
|
String version = (String) i.next();
|
||||||
|
if ( !dest.getVersions().contains( version ) )
|
||||||
|
{
|
||||||
|
dest.getVersions().add( version );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo remove in beta-2 - used for legacy handling
|
||||||
|
*/
|
||||||
|
private String resolveLegacyVersion( Artifact artifact, ArtifactRepository localRepository,
|
||||||
|
List remoteRepositories )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
LegacyArtifactMetadata localMetadata = createLegacyMetadata( artifact );
|
||||||
|
File f = new File( localRepository.getBasedir(),
|
||||||
|
localRepository.pathOfLocalRepositoryMetadata( localMetadata, null ) );
|
||||||
|
if ( f.exists() )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
localMetadata.readFromFile( f );
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean alreadyResolved = alreadyResolved( artifact );
|
boolean alreadyResolved = alreadyResolved( artifact );
|
||||||
|
@ -122,69 +249,63 @@ public abstract class AbstractVersionTransformation
|
||||||
ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots()
|
ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots()
|
||||||
: repository.getReleases();
|
: repository.getReleases();
|
||||||
|
|
||||||
if ( policy == null || !policy.isEnabled() )
|
if ( !policy.isEnabled() )
|
||||||
{
|
{
|
||||||
getLogger().debug( "resolveMetaData: " + artifact.getId() + ": Skipping disabled repository " +
|
getLogger().debug( "resolveMetaData: " + artifact.getId() + ": Skipping disabled repository " +
|
||||||
repository.getId() + " (" + repository.getUrl() + ")" );
|
repository.getId() + " (" + repository.getUrl() + ")" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: should be able to calculate this less often
|
|
||||||
boolean checkForUpdates = policy.checkOutOfDate( localMetadata.getLastModified() );
|
boolean checkForUpdates = policy.checkOutOfDate( localMetadata.getLastModified() );
|
||||||
|
|
||||||
if ( checkForUpdates )
|
if ( checkForUpdates )
|
||||||
{
|
{
|
||||||
checkedUpdates = true;
|
checkedUpdates = true;
|
||||||
|
|
||||||
getLogger().info(
|
LegacyArtifactMetadata remoteMetadata;
|
||||||
artifact.getId() + ": checking for updates from " + repository.getId() +
|
|
||||||
" (" + repository.getUrl() + ")" );
|
|
||||||
|
|
||||||
VersionArtifactMetadata remoteMetadata;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
remoteMetadata = retrieveFromRemoteRepository( artifact, repository, localMetadata,
|
remoteMetadata = createLegacyMetadata( artifact );
|
||||||
policy.getChecksumPolicy() );
|
|
||||||
|
remoteMetadata.retrieveFromRemoteRepository( repository, wagonManager,
|
||||||
|
policy.getChecksumPolicy() );
|
||||||
|
|
||||||
|
getLogger().warn( "Using old-style versioning metadata from remote repo for " + artifact );
|
||||||
|
|
||||||
|
int difference = remoteMetadata.compareTo( localMetadata );
|
||||||
|
if ( difference > 0 )
|
||||||
|
{
|
||||||
|
// remote is newer
|
||||||
|
artifact.setRepository( repository );
|
||||||
|
|
||||||
|
localMetadata = remoteMetadata;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch ( ResourceDoesNotExistException e )
|
catch ( ResourceDoesNotExistException e )
|
||||||
{
|
{
|
||||||
getLogger().debug( "resolveMetaData: Artifact version metadata for: " +
|
getLogger().debug( "resolveMetaData: Artifact version metadata for: " + artifact.getId() +
|
||||||
artifact.getId() + " could not be found on repository: " + repository.getId(), e );
|
" could not be found on repository: " + repository.getId(), e );
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int difference = remoteMetadata.compareTo( localMetadata );
|
|
||||||
if ( difference > 0 )
|
|
||||||
{
|
|
||||||
// remote is newer
|
|
||||||
artifact.setRepository( repository );
|
|
||||||
|
|
||||||
localMetadata = remoteMetadata;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getLogger().debug( "resolveMetaData: " + artifact.getId() +
|
getLogger().debug( "resolveMetaData: " + artifact.getId() + ": NOT checking for updates from " +
|
||||||
": NOT checking for updates from " + repository.getId() +
|
repository.getId() + " (" + repository.getUrl() + ")" );
|
||||||
" (" + repository.getUrl() + ")" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// touch the file if it was checked for updates, but don't create it if it doesn't exist remotely to avoid
|
// touch the file if it was checked for updates, but don't create it if it did't exist to avoid
|
||||||
// storing SNAPSHOT as the actual version which doesn't exist remotely.
|
// storing SNAPSHOT as the actual version which doesn't exist remotely.
|
||||||
if ( checkedUpdates && localMetadata.getLastModified().getTime() > 0 )
|
if ( checkedUpdates && localMetadata.getLastModified().getTime() > 0 )
|
||||||
{
|
{
|
||||||
localMetadata.storeInLocalRepository( localRepository,
|
localMetadata.storeInLocalRepository( localRepository );
|
||||||
null ); // TODO: fix artifact repository - but this will be removed anyway
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resolvedArtifactCache.add( getCacheKey( artifact ) );
|
resolvedArtifactCache.add( getCacheKey( artifact ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: if the POM and JAR are inconsistent, this might mean that different version of each are used
|
|
||||||
if ( artifact.getFile().exists() && !localMetadata.newerThanFile( artifact.getFile() ) )
|
if ( artifact.getFile().exists() && !localMetadata.newerThanFile( artifact.getFile() ) )
|
||||||
{
|
{
|
||||||
if ( getLogger().isDebugEnabled() && !alreadyResolved )
|
if ( getLogger().isDebugEnabled() && !alreadyResolved )
|
||||||
|
@ -194,42 +315,90 @@ public abstract class AbstractVersionTransformation
|
||||||
}
|
}
|
||||||
localMetadata = null;
|
localMetadata = null;
|
||||||
}
|
}
|
||||||
return localMetadata;
|
return localMetadata != null ? localMetadata.constructVersion() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact,
|
/**
|
||||||
ArtifactRepository remoteRepository,
|
* Select the version to use based on a merged versioning element.
|
||||||
ArtifactMetadata localMetadata,
|
*
|
||||||
String checksumPolicy )
|
* @param versioning the versioning element
|
||||||
throws ArtifactMetadataRetrievalException, ResourceDoesNotExistException
|
* @param defaultVersion the version to select if none is selected from versioning
|
||||||
{
|
* @return the version selected
|
||||||
AbstractVersionArtifactMetadata metadata = createMetadata( artifact );
|
*/
|
||||||
|
// protected abstract String selectVersion( Versioning versioning, String defaultVersion );
|
||||||
metadata.retrieveFromRemoteRepository( remoteRepository, wagonManager, checksumPolicy );
|
protected abstract LegacyArtifactMetadata createLegacyMetadata( Artifact artifact );
|
||||||
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract AbstractVersionArtifactMetadata createMetadata( Artifact artifact );
|
|
||||||
|
|
||||||
private VersionArtifactMetadata readFromLocalRepository( Artifact artifact, ArtifactRepository localRepository )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
// TODO: we could cache the results of this, perhaps inside the artifact repository?
|
|
||||||
AbstractVersionArtifactMetadata metadata = createMetadata( artifact );
|
|
||||||
metadata.readFromLocalRepository( localRepository,
|
|
||||||
null ); // TODO: fix artifact repository - but this will be removed anyway
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo remove in beta-2 - used for legacy handling
|
||||||
|
*/
|
||||||
private boolean alreadyResolved( Artifact artifact )
|
private boolean alreadyResolved( Artifact artifact )
|
||||||
{
|
{
|
||||||
return resolvedArtifactCache.contains( getCacheKey( artifact ) );
|
return resolvedArtifactCache.contains( getCacheKey( artifact ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo remove in beta-2 - used for legacy handling
|
||||||
|
*/
|
||||||
private static String getCacheKey( Artifact artifact )
|
private static String getCacheKey( Artifact artifact )
|
||||||
{
|
{
|
||||||
// No type - one per POM
|
// No type - one per POM
|
||||||
return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getBaseVersion();
|
return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getBaseVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ArtifactRepositoryMetadata loadVersioningInformation( ArtifactMetadata repoMetadata,
|
||||||
|
ArtifactRepository remoteRepository,
|
||||||
|
ArtifactRepository localRepository,
|
||||||
|
Artifact artifact )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
File metadataFile = new File( localRepository.getBasedir(),
|
||||||
|
localRepository.pathOfLocalRepositoryMetadata( repoMetadata, remoteRepository ) );
|
||||||
|
|
||||||
|
ArtifactRepositoryMetadata newMetadata = null;
|
||||||
|
if ( metadataFile.exists() )
|
||||||
|
{
|
||||||
|
Metadata metadata = readMetadata( metadataFile );
|
||||||
|
if ( metadata.getVersioning() != null )
|
||||||
|
{
|
||||||
|
newMetadata = new ArtifactRepositoryMetadata( artifact, metadata.getVersioning() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo share with DefaultPluginMappingManager.
|
||||||
|
*/
|
||||||
|
private static Metadata readMetadata( File mappingFile )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
|
{
|
||||||
|
Metadata result;
|
||||||
|
|
||||||
|
Reader fileReader = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fileReader = new FileReader( mappingFile );
|
||||||
|
|
||||||
|
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
|
||||||
|
|
||||||
|
result = mappingReader.read( fileReader );
|
||||||
|
}
|
||||||
|
catch ( FileNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new ArtifactMetadataRetrievalException( "Cannot read version information from: " + mappingFile, e );
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new ArtifactMetadataRetrievalException( "Cannot read version information from: " + mappingFile, e );
|
||||||
|
}
|
||||||
|
catch ( XmlPullParserException e )
|
||||||
|
{
|
||||||
|
throw new ArtifactMetadataRetrievalException( "Cannot parse version information from: " + mappingFile, e );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtil.close( fileReader );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,13 +48,14 @@ public class DefaultArtifactTransformationManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
|
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
|
||||||
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
|
for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
ArtifactTransformation transform = (ArtifactTransformation) i.next();
|
ArtifactTransformation transform = (ArtifactTransformation) i.next();
|
||||||
transform.transformForDeployment( artifact, remoteRepository );
|
transform.transformForDeployment( artifact, remoteRepository, localRepository );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,13 @@ package org.apache.maven.artifact.transform;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.AbstractVersionArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
import org.apache.maven.artifact.metadata.LatestArtifactMetadata;
|
import org.apache.maven.artifact.metadata.LatestArtifactMetadata;
|
||||||
|
import org.apache.maven.artifact.metadata.LegacyArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.Versioning;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -47,15 +50,27 @@ public class LatestArtifactTransformation
|
||||||
// metadata is added at install time
|
// metadata is added at install time
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
|
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
|
||||||
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
// metadata is added at deploy time
|
// metadata is added at deploy time
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractVersionArtifactMetadata createMetadata( Artifact artifact )
|
protected LegacyArtifactMetadata createLegacyMetadata( Artifact artifact )
|
||||||
{
|
{
|
||||||
return new LatestArtifactMetadata( artifact );
|
return new LatestArtifactMetadata( artifact );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ArtifactMetadata createMetadata( Artifact artifact, Versioning versioning )
|
||||||
|
{
|
||||||
|
LatestArtifactMetadata metadata = new LatestArtifactMetadata( artifact );
|
||||||
|
metadata.setVersion( versioning.getLatest() );
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String constructVersion( ArtifactRepositoryMetadata metadata )
|
||||||
|
{
|
||||||
|
return metadata.getLatestVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,11 @@ package org.apache.maven.artifact.transform;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.AbstractVersionArtifactMetadata;
|
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
|
import org.apache.maven.artifact.metadata.LegacyArtifactMetadata;
|
||||||
import org.apache.maven.artifact.metadata.ReleaseArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ReleaseArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -56,15 +57,20 @@ public class ReleaseArtifactTransformation
|
||||||
// metadata is added at install time
|
// metadata is added at install time
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
|
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
|
||||||
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
// metadata is added at deploy time
|
// metadata is added at deploy time
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractVersionArtifactMetadata createMetadata( Artifact artifact )
|
protected LegacyArtifactMetadata createLegacyMetadata( Artifact artifact )
|
||||||
{
|
{
|
||||||
return new ReleaseArtifactMetadata( artifact );
|
return new ReleaseArtifactMetadata( artifact );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String constructVersion( ArtifactRepositoryMetadata metadata )
|
||||||
|
{
|
||||||
|
return metadata.getReleaseVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,15 @@ package org.apache.maven.artifact.transform;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.AbstractVersionArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
|
import org.apache.maven.artifact.metadata.LegacyArtifactMetadata;
|
||||||
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
|
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
|
||||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
import org.apache.maven.artifact.repository.metadata.Snapshot;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.Versioning;
|
||||||
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -53,36 +56,35 @@ public class SnapshotTransformation
|
||||||
{
|
{
|
||||||
if ( artifact.isSnapshot() )
|
if ( artifact.isSnapshot() )
|
||||||
{
|
{
|
||||||
SnapshotArtifactMetadata metadata = new SnapshotArtifactMetadata( artifact );
|
// TODO: Better way to create this - should have to construct Versioning
|
||||||
|
Versioning versioning = new Versioning();
|
||||||
|
Snapshot snapshot = new Snapshot();
|
||||||
|
versioning.setSnapshot( snapshot );
|
||||||
|
|
||||||
|
ArtifactMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
|
||||||
|
|
||||||
|
// TODO: should merge with other repository metadata sitting on the same level?
|
||||||
artifact.addMetadata( metadata );
|
artifact.addMetadata( metadata );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
|
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
|
||||||
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
if ( artifact.isSnapshot() )
|
if ( artifact.isSnapshot() )
|
||||||
{
|
{
|
||||||
SnapshotArtifactMetadata metadata;
|
Snapshot snapshot = resolveLatestSnapshotVersion( artifact, localRepository, remoteRepository );
|
||||||
|
snapshot.setTimestamp( getDeploymentTimestamp() );
|
||||||
|
snapshot.setBuildNumber( snapshot.getBuildNumber() + 1 );
|
||||||
|
|
||||||
try
|
// TODO: Better way to create this - should have to construct Versioning
|
||||||
{
|
Versioning versioning = new Versioning();
|
||||||
metadata = (SnapshotArtifactMetadata) retrieveFromRemoteRepository( artifact, remoteRepository, null,
|
versioning.setSnapshot( snapshot );
|
||||||
ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
|
|
||||||
}
|
|
||||||
catch ( ResourceDoesNotExistException e )
|
|
||||||
{
|
|
||||||
getLogger().debug( "Snapshot version metadata for: " + artifact.getId() +
|
|
||||||
" not found. Creating a new metadata instance.", e );
|
|
||||||
|
|
||||||
// ignore. We'll be creating this metadata if it doesn't exist...
|
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
|
||||||
metadata = (SnapshotArtifactMetadata) createMetadata( artifact );
|
|
||||||
}
|
|
||||||
|
|
||||||
metadata.setVersion( getDeploymentTimestamp(), metadata.getBuildNumber() + 1 );
|
artifact.setResolvedVersion( constructVersion( metadata ) );
|
||||||
|
|
||||||
artifact.setResolvedVersion( metadata.constructVersion() );
|
|
||||||
|
|
||||||
artifact.addMetadata( metadata );
|
artifact.addMetadata( metadata );
|
||||||
}
|
}
|
||||||
|
@ -97,9 +99,30 @@ public class SnapshotTransformation
|
||||||
return deploymentTimestamp;
|
return deploymentTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractVersionArtifactMetadata createMetadata( Artifact artifact )
|
protected LegacyArtifactMetadata createLegacyMetadata( Artifact artifact )
|
||||||
{
|
{
|
||||||
return new SnapshotArtifactMetadata( artifact );
|
return new SnapshotArtifactMetadata( artifact );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String constructVersion( ArtifactRepositoryMetadata metadata )
|
||||||
|
{
|
||||||
|
String version = metadata.getBaseVersion();
|
||||||
|
Snapshot snapshot = metadata.getSnapshot();
|
||||||
|
if ( snapshot != null )
|
||||||
|
{
|
||||||
|
if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 )
|
||||||
|
{
|
||||||
|
String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber();
|
||||||
|
if ( version != null )
|
||||||
|
{
|
||||||
|
version = StringUtils.replace( version, "SNAPSHOT", newVersion );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
version = newVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -23,6 +23,9 @@
|
||||||
<requirement>
|
<requirement>
|
||||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||||
</requirement>
|
</requirement>
|
||||||
|
<requirement>
|
||||||
|
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
|
||||||
|
</requirement>
|
||||||
</requirements>
|
</requirements>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
@ -34,6 +37,9 @@
|
||||||
<requirement>
|
<requirement>
|
||||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||||
</requirement>
|
</requirement>
|
||||||
|
<requirement>
|
||||||
|
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
|
||||||
|
</requirement>
|
||||||
</requirements>
|
</requirements>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
@ -45,6 +51,9 @@
|
||||||
<requirement>
|
<requirement>
|
||||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||||
</requirement>
|
</requirement>
|
||||||
|
<requirement>
|
||||||
|
<role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
|
||||||
|
</requirement>
|
||||||
</requirements>
|
</requirements>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,6 @@ public abstract class AbstractArtifactComponentTestCase
|
||||||
{
|
{
|
||||||
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||||
|
|
||||||
// TODO: used to be SCOPE_COMPILE, check
|
|
||||||
return artifactFactory.createBuildArtifact( groupId, artifactId, version, type );
|
return artifactFactory.createBuildArtifact( groupId, artifactId, version, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.maven.artifact;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @todo it may be better for this to move to maven-artifact, and artifact.getFile() to throw it - perhaps it is a runtime exception?
|
* @todo it may be better for artifact.getFile() to throw it - perhaps it is a runtime exception?
|
||||||
*/
|
*/
|
||||||
public class DependencyResolutionRequiredException
|
public class DependencyResolutionRequiredException
|
||||||
extends Exception
|
extends Exception
|
||||||
|
|
|
@ -100,7 +100,6 @@ public class DefaultArtifactFactory
|
||||||
private Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
private Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
||||||
String classifier, String inheritedScope )
|
String classifier, String inheritedScope )
|
||||||
{
|
{
|
||||||
// TODO: better constructor
|
|
||||||
VersionRange versionRange = null;
|
VersionRange versionRange = null;
|
||||||
if ( version != null )
|
if ( version != null )
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,6 @@ package org.apache.maven.artifact.metadata;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common elements of artifact metadata.
|
* Common elements of artifact metadata.
|
||||||
|
@ -30,8 +29,6 @@ public abstract class AbstractArtifactMetadata
|
||||||
{
|
{
|
||||||
protected Artifact artifact;
|
protected Artifact artifact;
|
||||||
|
|
||||||
protected ArtifactRepository repository;
|
|
||||||
|
|
||||||
protected AbstractArtifactMetadata( Artifact artifact )
|
protected AbstractArtifactMetadata( Artifact artifact )
|
||||||
{
|
{
|
||||||
this.artifact = artifact;
|
this.artifact = artifact;
|
||||||
|
@ -62,8 +59,4 @@ public abstract class AbstractArtifactMetadata
|
||||||
return artifact.getGroupId() + ":" + artifact.getArtifactId();
|
return artifact.getGroupId() + ":" + artifact.getArtifactId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRepository( ArtifactRepository repository )
|
|
||||||
{
|
|
||||||
this.repository = repository;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,9 +56,6 @@ public interface ArtifactMetadata
|
||||||
|
|
||||||
Object getKey();
|
Object getKey();
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo delete?
|
|
||||||
*/
|
|
||||||
boolean isSnapshot();
|
boolean isSnapshot();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,4 +26,8 @@ public interface RepositoryMetadataManager
|
||||||
{
|
{
|
||||||
void resolve( ArtifactMetadata repositoryMetadata, List repositories, ArtifactRepository localRepository )
|
void resolve( ArtifactMetadata repositoryMetadata, List repositories, ArtifactRepository localRepository )
|
||||||
throws ArtifactMetadataRetrievalException;
|
throws ArtifactMetadataRetrievalException;
|
||||||
|
|
||||||
|
void resolveAlways( ArtifactMetadata metadata, ArtifactRepository localRepository,
|
||||||
|
ArtifactRepository remoteRepository )
|
||||||
|
throws ArtifactMetadataRetrievalException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,5 @@ import org.apache.maven.artifact.Artifact;
|
||||||
*/
|
*/
|
||||||
public interface ArtifactFilter
|
public interface ArtifactFilter
|
||||||
{
|
{
|
||||||
//TODO(JVZ): change the signature of this to filter(Artifact) where the meaning of filter is
|
|
||||||
// to exclude. I did this backward and it's confusing.
|
|
||||||
boolean include( Artifact artifact );
|
boolean include( Artifact artifact );
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,10 @@ public interface ArtifactTransformation
|
||||||
*
|
*
|
||||||
* @param artifact Artifact to be transformed.
|
* @param artifact Artifact to be transformed.
|
||||||
* @param remoteRepository the repository to deploy to
|
* @param remoteRepository the repository to deploy to
|
||||||
|
* @param localRepository the local repository
|
||||||
*/
|
*/
|
||||||
void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
|
void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
|
||||||
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactMetadataRetrievalException;
|
throws ArtifactMetadataRetrievalException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,10 @@ public interface ArtifactTransformationManager
|
||||||
*
|
*
|
||||||
* @param artifact Artifact to be transformed.
|
* @param artifact Artifact to be transformed.
|
||||||
* @param remoteRepository the repository to deploy to
|
* @param remoteRepository the repository to deploy to
|
||||||
|
* @param localRepository the local repository the metadata is stored in
|
||||||
*/
|
*/
|
||||||
void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
|
void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
|
||||||
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactMetadataRetrievalException;
|
throws ArtifactMetadataRetrievalException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import java.net.URL;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -178,7 +177,7 @@ public class Verifier
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.addAll( replaceArtifacts( line ) );
|
lines.add( replaceArtifacts( line ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.close();
|
reader.close();
|
||||||
|
@ -192,7 +191,7 @@ public class Verifier
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List replaceArtifacts( String line )
|
private static String replaceArtifacts( String line )
|
||||||
{
|
{
|
||||||
String MARKER = "${artifact:";
|
String MARKER = "${artifact:";
|
||||||
int index = line.indexOf( MARKER );
|
int index = line.indexOf( MARKER );
|
||||||
|
@ -209,22 +208,11 @@ public class Verifier
|
||||||
newLine += convertArtifact( artifact );
|
newLine += convertArtifact( artifact );
|
||||||
newLine += line.substring( index + 1 );
|
newLine += line.substring( index + 1 );
|
||||||
|
|
||||||
index = newLine.lastIndexOf( "SNAPSHOT" );
|
return newLine;
|
||||||
if ( index >= 0 )
|
|
||||||
{
|
|
||||||
List l = new ArrayList();
|
|
||||||
l.add( newLine );
|
|
||||||
l.add( newLine.substring( 0, index ) + "SNAPSHOT.version.txt" );
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Collections.singletonList( newLine );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Collections.singletonList( line );
|
return line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -600,7 +600,6 @@ public class DefaultLifecycleExecutor
|
||||||
String goal = tok.nextToken().trim();
|
String goal = tok.nextToken().trim();
|
||||||
|
|
||||||
// Not from the CLI, don't use prefix
|
// Not from the CLI, don't use prefix
|
||||||
// TODO: [MNG-608] this needs to be false
|
|
||||||
MojoDescriptor mojoDescriptor = getMojoDescriptor( goal, session, project, selectedPhase, false );
|
MojoDescriptor mojoDescriptor = getMojoDescriptor( goal, session, project, selectedPhase, false );
|
||||||
|
|
||||||
if ( mojoDescriptor.isDirectInvocationOnly() )
|
if ( mojoDescriptor.isDirectInvocationOnly() )
|
||||||
|
|
|
@ -16,6 +16,7 @@ package org.apache.maven.plugin;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
|
import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
|
||||||
|
@ -96,7 +97,7 @@ public class DefaultPluginMappingManager
|
||||||
private void loadPluginMappings( String groupId, List pluginRepositories, ArtifactRepository localRepository )
|
private void loadPluginMappings( String groupId, List pluginRepositories, ArtifactRepository localRepository )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
GroupRepositoryMetadata metadata = new GroupRepositoryMetadata( groupId );
|
ArtifactMetadata metadata = new GroupRepositoryMetadata( groupId );
|
||||||
|
|
||||||
repositoryMetadataManager.resolve( metadata, pluginRepositories, localRepository );
|
repositoryMetadataManager.resolve( metadata, pluginRepositories, localRepository );
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ public class DefaultPluginMappingManager
|
||||||
loadRepositoryPluginMappings( metadata, localRepository, localRepository );
|
loadRepositoryPluginMappings( metadata, localRepository, localRepository );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadRepositoryPluginMappings( GroupRepositoryMetadata metadata, ArtifactRepository remoteRepository,
|
private void loadRepositoryPluginMappings( ArtifactMetadata metadata, ArtifactRepository remoteRepository,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
|
@ -121,24 +122,21 @@ public class DefaultPluginMappingManager
|
||||||
{
|
{
|
||||||
Metadata pluginMap = readMetadata( metadataFile );
|
Metadata pluginMap = readMetadata( metadataFile );
|
||||||
|
|
||||||
if ( pluginMap != null )
|
for ( Iterator pluginIterator = pluginMap.getPlugins().iterator(); pluginIterator.hasNext(); )
|
||||||
{
|
{
|
||||||
for ( Iterator pluginIterator = pluginMap.getPlugins().iterator(); pluginIterator.hasNext(); )
|
Plugin mapping = (Plugin) pluginIterator.next();
|
||||||
{
|
|
||||||
Plugin mapping = (Plugin) pluginIterator.next();
|
|
||||||
|
|
||||||
String prefix = mapping.getPrefix();
|
String prefix = mapping.getPrefix();
|
||||||
|
|
||||||
String artifactId = mapping.getArtifactId();
|
String artifactId = mapping.getArtifactId();
|
||||||
|
|
||||||
org.apache.maven.model.Plugin plugin = new org.apache.maven.model.Plugin();
|
org.apache.maven.model.Plugin plugin = new org.apache.maven.model.Plugin();
|
||||||
|
|
||||||
plugin.setGroupId( metadata.getGroupId() );
|
plugin.setGroupId( metadata.getGroupId() );
|
||||||
|
|
||||||
plugin.setArtifactId( artifactId );
|
plugin.setArtifactId( artifactId );
|
||||||
|
|
||||||
pluginDefinitionsByPrefix.put( prefix, plugin );
|
pluginDefinitionsByPrefix.put( prefix, plugin );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,7 @@ public class ArtifactDownloader
|
||||||
String version = dep.getVersion();
|
String version = dep.getVersion();
|
||||||
if ( snapshot )
|
if ( snapshot )
|
||||||
{
|
{
|
||||||
|
// TODO: augment with maven-metadata
|
||||||
String filename = getSnapshotMetadataFile( destinationFile.getName(), "SNAPSHOT.version.txt" );
|
String filename = getSnapshotMetadataFile( destinationFile.getName(), "SNAPSHOT.version.txt" );
|
||||||
File file = localRepository.getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
|
File file = localRepository.getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
|
||||||
dep.getVersion(), dep.getType(), filename );
|
dep.getVersion(), dep.getType(), filename );
|
||||||
|
|
|
@ -20,8 +20,9 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.deployer.ArtifactDeployer;
|
import org.apache.maven.artifact.deployer.ArtifactDeployer;
|
||||||
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.metadata.ReleaseArtifactMetadata;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.Versioning;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
|
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
|
||||||
|
@ -130,8 +131,10 @@ public class DeployMojo
|
||||||
|
|
||||||
if ( updateReleaseInfo )
|
if ( updateReleaseInfo )
|
||||||
{
|
{
|
||||||
ReleaseArtifactMetadata metadata = new ReleaseArtifactMetadata( artifact );
|
// TODO: clean up
|
||||||
metadata.setVersion( artifact.getVersion() );
|
Versioning versioning = new Versioning();
|
||||||
|
versioning.setRelease( artifact.getVersion() );
|
||||||
|
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
|
||||||
artifact.addMetadata( metadata );
|
artifact.addMetadata( metadata );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@ package org.apache.maven.plugin.install;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.installer.ArtifactInstallationException;
|
import org.apache.maven.artifact.installer.ArtifactInstallationException;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.metadata.ReleaseArtifactMetadata;
|
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.Versioning;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
|
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs project's main artifact in local repository.
|
* Installs project's main artifact in local repository.
|
||||||
|
*
|
||||||
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @goal install
|
* @goal install
|
||||||
|
@ -97,8 +99,10 @@ public class InstallMojo
|
||||||
|
|
||||||
if ( updateReleaseInfo )
|
if ( updateReleaseInfo )
|
||||||
{
|
{
|
||||||
ReleaseArtifactMetadata metadata = new ReleaseArtifactMetadata( artifact );
|
// TODO: clean up
|
||||||
metadata.setVersion( artifact.getVersion() );
|
Versioning versioning = new Versioning();
|
||||||
|
versioning.setRelease( artifact.getVersion() );
|
||||||
|
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
|
||||||
artifact.addMetadata( metadata );
|
artifact.addMetadata( metadata );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package org.apache.maven.plugin.plugin.metadata;
|
package org.apache.maven.plugin.plugin.metadata;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.LatestArtifactMetadata;
|
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
|
||||||
import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
|
import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
|
||||||
|
import org.apache.maven.artifact.repository.metadata.Versioning;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
|
@ -39,10 +40,10 @@ public class AddPluginArtifactMetadataMojo
|
||||||
{
|
{
|
||||||
Artifact projectArtifact = project.getArtifact();
|
Artifact projectArtifact = project.getArtifact();
|
||||||
|
|
||||||
LatestArtifactMetadata metadata = new LatestArtifactMetadata( projectArtifact );
|
// TODO: clean up
|
||||||
|
Versioning versioning = new Versioning();
|
||||||
metadata.setVersion( projectArtifact.getVersion() );
|
versioning.setLatest( projectArtifact.getVersion() );
|
||||||
|
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( projectArtifact, versioning );
|
||||||
projectArtifact.addMetadata( metadata );
|
projectArtifact.addMetadata( metadata );
|
||||||
|
|
||||||
GroupRepositoryMetadata groupMetadata = new GroupRepositoryMetadata( project.getGroupId() );
|
GroupRepositoryMetadata groupMetadata = new GroupRepositoryMetadata( project.getGroupId() );
|
||||||
|
|
Loading…
Reference in New Issue