PR: MNG-613

make repository metadata behave more like snapshots with daily updates.
next step is to move the version checking to use that instead and fallback to the old files

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@266298 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-02 07:16:16 +00:00
parent a3a73ebaec
commit abd4ae6018
37 changed files with 551 additions and 720 deletions

View File

@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven</groupId>
@ -17,6 +17,11 @@
<artifactId>maven-artifact</artifactId>
<version>2.0-beta-1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-repository-metadata</artifactId>
<version>2.0-beta-1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-container-default</artifactId>

View File

@ -71,6 +71,7 @@ public void deploy( File source, Artifact artifact, ArtifactRepository deploymen
for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); )
{
ArtifactMetadata metadata = (ArtifactMetadata) i.next();
// TODO: method should be on repository?
metadata.storeInLocalRepository( localRepository );
// TODO: shouldn't need to calculate this
File f = new File( localRepository.getBasedir(), localRepository.pathOfArtifactMetadata( metadata ) );

View File

@ -34,7 +34,9 @@ public class DefaultArtifactInstaller
{
private ArtifactTransformationManager transformationManager;
/** @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly. */
/**
* @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly.
*/
public void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository )
throws ArtifactInstallationException
{
@ -68,7 +70,8 @@ public void install( File source, Artifact artifact, ArtifactRepository localRep
for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); )
{
ArtifactMetadata metadata = (ArtifactMetadata) i.next();
// TODO: method should be on repository?
metadata.storeInLocalRepository( localRepository );
}
}

View File

@ -21,7 +21,6 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.wagon.ConnectionException;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
@ -99,14 +98,6 @@ public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata,
putRemoteFile( repository, source, repository.pathOfArtifactMetadata( artifactMetadata ), null );
}
public void putRepositoryMetadata( File source, RepositoryMetadata metadata, ArtifactRepository repository )
throws TransferFailedException
{
getLogger().info( "Uploading " + metadata );
putRemoteFile( repository, source, repository.pathOfRepositoryMetadata( metadata ), null );
}
private void putRemoteFile( ArtifactRepository repository, File source, String remotePath,
TransferListener downloadMonitor )
throws TransferFailedException
@ -263,17 +254,6 @@ public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository r
getRemoteFile( repository, destination, remotePath, null, checksumPolicy );
}
public void getRepositoryMetadata( RepositoryMetadata metadata, ArtifactRepository remoteRepository,
File destination )
throws TransferFailedException, ResourceDoesNotExistException
{
String remotePath = remoteRepository.pathOfRepositoryMetadata( metadata );
getLogger().info( "Retrieving " + metadata );
getRemoteFile( remoteRepository, destination, remotePath, null, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
}
private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath,
TransferListener downloadMonitor, String checksumPolicy )
throws TransferFailedException, ResourceDoesNotExistException, ChecksumFailedException

View File

@ -19,7 +19,6 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.UnsupportedProtocolException;
@ -58,12 +57,6 @@ void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRe
String checksumPolicy )
throws TransferFailedException, ResourceDoesNotExistException;
void putRepositoryMetadata( File source, RepositoryMetadata metadata, ArtifactRepository repository )
throws TransferFailedException;
void getRepositoryMetadata( RepositoryMetadata metadata, ArtifactRepository remoteRepository, File destination )
throws TransferFailedException, ResourceDoesNotExistException;
void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts );
void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey,

View File

@ -91,9 +91,13 @@ public String getBaseVersion()
return Artifact.LATEST_VERSION;
}
public boolean storedInArtifactDirectory()
public boolean storedInArtifactVersionDirectory()
{
return false;
}
public boolean isSnapshot()
{
return false;
}
}

View File

@ -99,9 +99,13 @@ public String getBaseVersion()
return ReleaseArtifactTransformation.RELEASE_VERSION;
}
public boolean storedInArtifactDirectory()
public boolean storedInArtifactVersionDirectory()
{
return false;
}
public boolean isSnapshot()
{
return false;
}
}

View File

@ -80,7 +80,7 @@ protected void setContent( String content )
buildNumber = 0;
}
}
public void setVersion( String timestamp, int buildNumber )
{
this.timestamp = timestamp;
@ -91,7 +91,7 @@ public String getTimestamp()
{
return timestamp;
}
public int getBuildNumber()
{
return buildNumber;
@ -157,4 +157,19 @@ public String toString()
{
return "snapshot information for " + artifact.getArtifactId() + " " + artifact.getBaseVersion();
}
public boolean storedInArtifactVersionDirectory()
{
return true;
}
public boolean isSnapshot()
{
return true;
}
public String getBaseVersion()
{
return artifact.getBaseVersion();
}
}

View File

@ -19,7 +19,6 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.wagon.repository.Repository;
/**
@ -82,11 +81,6 @@ public String pathOfArtifactMetadata( ArtifactMetadata artifactMetadata )
return layout.pathOfArtifactMetadata( artifactMetadata );
}
public String pathOfRepositoryMetadata( RepositoryMetadata metadata )
{
return layout.pathOfRepositoryMetadata( metadata );
}
public ArtifactRepositoryLayout getLayout()
{
return layout;

View File

@ -17,14 +17,16 @@
*/
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -38,106 +40,77 @@ public class DefaultRepositoryMetadataManager
private 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 very primitive. Probably we can cache artifacts themselves in a central location, as well as reset the flag over time in a long running process.
*/
private Set cachedMetadata = new HashSet();
public void resolve( RepositoryMetadata metadata, List repositories, ArtifactRepository local )
throws RepositoryMetadataManagementException
public void resolve( ArtifactMetadata metadata, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{
boolean alreadyResolved = alreadyResolved( metadata );
if ( !alreadyResolved )
{
for ( Iterator i = repositories.iterator(); i.hasNext(); )
File file = new File( localRepository.getBasedir(), localRepository.pathOfArtifactMetadata( metadata ) );
boolean checkedUpdates = false;
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
{
ArtifactRepository repository = (ArtifactRepository) i.next();
// TODO: replace with a more general repository update mechanism like artifact metadata uses
// (Actually, this should now supersede artifact metadata...)
File metadataFile = new File( local.getBasedir(), local.pathOfRepositoryMetadata( metadata ) );
ArtifactRepositoryPolicy policy = metadata.isSnapshot() ? repository.getSnapshots()
: repository.getReleases();
if ( !metadataFile.exists() )
if ( policy == null || !policy.isEnabled() )
{
try
{
try
{
wagonManager.getRepositoryMetadata( metadata, repository, metadataFile );
}
catch ( ResourceDoesNotExistException e )
{
if ( !metadataFile.exists() )
{
throw new RepositoryMetadataManagementException( metadata,
"Remote repository metadata not found.",
e );
}
else
{
String message = "Cannot find " + metadata +
" in remote repository - Using local copy.";
getLogger().info( message );
getLogger().debug( message, e );
}
}
}
catch ( TransferFailedException e )
{
throw new RepositoryMetadataManagementException( metadata,
"Failed to download repository metadata.", e );
}
getLogger().debug( "Skipping disabled repository " + repository.getId() );
}
else
{
getLogger().info( "Using local copy of " + metadata + " from: " + metadataFile );
// TODO: should be able to calculate this less often
boolean checkForUpdates = policy.checkOutOfDate( new Date( file.lastModified() ) );
if ( checkForUpdates )
{
checkedUpdates = true;
getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() );
try
{
wagonManager.getArtifactMetadata( metadata, repository, file, policy.getChecksumPolicy() );
// TODO: ???
// metadata.setRepository( repository );
}
catch ( ResourceDoesNotExistException e )
{
getLogger().info( "Repository metadata " + metadata +
" could not be found on repository: " + repository.getId(), e );
}
catch ( TransferFailedException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
}
}
}
cachedMetadata.add( metadata.getRepositoryPath() );
}
}
}
public void deploy( File source, RepositoryMetadata metadata, ArtifactRepository remote )
throws RepositoryMetadataManagementException
{
try
{
wagonManager.putRepositoryMetadata( source, metadata, remote );
}
catch ( TransferFailedException e )
{
throw new RepositoryMetadataManagementException( metadata, "Failed to upload repository metadata.", e );
}
}
public void install( File source, RepositoryMetadata metadata, ArtifactRepository local )
throws RepositoryMetadataManagementException
{
File metadataFile = new File( local.getBasedir(), local.pathOfRepositoryMetadata( metadata ) );
try
{
File dir = metadataFile.getParentFile();
if ( !dir.exists() )
// touch the file if it was checked for updates, but don't create it if it doesn't exist to avoid
// storing SNAPSHOT as the actual version which doesn't exist remotely.
if ( checkedUpdates )
{
dir.mkdirs();
if ( file.exists() )
{
file.setLastModified( System.currentTimeMillis() );
}
}
FileUtils.copyFile( source, metadataFile );
cachedMetadata.add( metadata.getKey() );
}
catch ( IOException e )
{
throw new RepositoryMetadataManagementException( metadata, "Failed to install repository metadata.", e );
}
}
private boolean alreadyResolved( RepositoryMetadata metadata )
private boolean alreadyResolved( ArtifactMetadata metadata )
{
return cachedMetadata.contains( metadata.getRepositoryPath() );
return cachedMetadata.contains( metadata.getKey() );
}
}

View File

@ -0,0 +1,216 @@
package org.apache.maven.artifact.repository.metadata;
/*
* Copyright 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 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;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* Metadata for the group directory of the repository.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class GroupRepositoryMetadata
implements ArtifactMetadata
{
/**
* TODO: reuse.
*/
protected static final String METADATA_FILE = "maven-metadata.xml";
private final String groupId;
private Map pluginMappings = new HashMap();
public GroupRepositoryMetadata( String groupId )
{
this.groupId = groupId;
}
public String toString()
{
return "repository metadata for group: \'" + groupId + "\'";
}
public void storeInLocalRepository( ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{
if ( !pluginMappings.isEmpty() )
{
try
{
updateRepositoryMetadata( localRepository );
}
catch ( IOException e )
{
throw new ArtifactMetadataRetrievalException( "Error updating group repository metadata", e );
}
}
}
public String getFilename()
{
return METADATA_FILE;
}
public boolean storedInGroupDirectory()
{
return true;
}
public boolean storedInArtifactVersionDirectory()
{
return false;
}
public String getGroupId()
{
return groupId;
}
public String getArtifactId()
{
return null;
}
public String getBaseVersion()
{
return null;
}
public void addPluginMapping( String goalPrefix, String artifactId )
{
pluginMappings.put( goalPrefix, artifactId );
}
private void updateRepositoryMetadata( ArtifactRepository localRepository )
throws IOException
{
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
Metadata pluginMap = null;
File metadataFile = new File( localRepository.getBasedir(), localRepository.pathOfArtifactMetadata( this ) );
if ( metadataFile.exists() )
{
Reader reader = null;
try
{
reader = new FileReader( metadataFile );
pluginMap = 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 );
}
}
// If file could not be found or was not valid, start from scratch
if ( pluginMap == null )
{
pluginMap = new Metadata();
pluginMap.setGroupId( groupId );
}
for ( Iterator i = pluginMappings.keySet().iterator(); i.hasNext(); )
{
String prefix = (String) i.next();
boolean found = false;
for ( Iterator it = pluginMap.getPlugins().iterator(); it.hasNext() && !found; )
{
Plugin preExisting = (Plugin) it.next();
if ( preExisting.getPrefix().equals( prefix ) )
{
// TODO: log
// getLog().info( "Plugin-mapping metadata for prefix: " + prefix + " already exists. Skipping." );
found = true;
}
}
if ( !found )
{
Plugin mappedPlugin = new Plugin();
mappedPlugin.setArtifactId( (String) pluginMappings.get( prefix ) );
mappedPlugin.setPrefix( prefix );
pluginMap.addPlugin( mappedPlugin );
}
}
Writer writer = null;
try
{
writer = new FileWriter( metadataFile );
MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer();
mappingWriter.write( writer, pluginMap );
}
finally
{
IOUtil.close( writer );
}
}
public Object getKey()
{
return groupId;
}
public boolean isSnapshot()
{
return false;
}
}

View File

@ -81,8 +81,8 @@ private void resolve( Artifact artifact, List remoteRepositories, ArtifactReposi
if ( !systemFile.exists() )
{
throw new ArtifactResolutionException( "System artifact: " + artifact.getId()
+ " not found in path: " + systemFile, artifact );
throw new ArtifactResolutionException(
"System artifact: " + artifact.getId() + " not found in path: " + systemFile, artifact );
}
else
{
@ -90,7 +90,7 @@ private void resolve( Artifact artifact, List remoteRepositories, ArtifactReposi
}
}
// skip artifacts with a file - they are already resolved
else if ( artifact.getFile() == null )
else if ( !artifact.isResolved() )
{
// ----------------------------------------------------------------------
// Check for the existence of the artifact in the specified local
@ -129,8 +129,8 @@ else if ( artifact.getFile() == null )
if ( !artifact.isResolved() )
{
throw new ArtifactResolutionException(
"Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.",
artifact, remoteRepositories );
"Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.",
artifact, remoteRepositories );
}
// must be after the artifact is downloaded

View File

@ -19,6 +19,7 @@
import org.apache.maven.artifact.Artifact;
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.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.VersionArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
@ -51,6 +52,52 @@ public abstract class AbstractVersionTransformation
protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
throws ArtifactMetadataRetrievalException
{
ArtifactMetadata localMetadata = resolveMetadata( artifact, localRepository, remoteRepositories );
String version;
if ( localMetadata == null )
{
version = artifact.getVersion();
}
else
{
VersionArtifactMetadata versionMetadata = (VersionArtifactMetadata) localMetadata;
version = versionMetadata.constructVersion();
}
// TODO: also do this logging for other metadata?
if ( getLogger().isDebugEnabled() )
{
if ( version != null && !version.equals( artifact.getBaseVersion() ) )
{
String message = artifact.getArtifactId() + ": resolved to version " + version;
if ( artifact.getRepository() != null )
{
message += " from repository " + artifact.getRepository().getId();
}
else
{
message += " from local repository";
}
getLogger().debug( message );
}
}
return version;
}
/**
* @param artifact
* @param localRepository
* @param remoteRepositories
* @return
* @throws ArtifactMetadataRetrievalException
* @todo share with DefaultRepositoryMetadataManager
*/
private ArtifactMetadata resolveMetadata( Artifact artifact, ArtifactRepository localRepository,
List remoteRepositories )
throws ArtifactMetadataRetrievalException
{
VersionArtifactMetadata localMetadata;
try
@ -116,9 +163,9 @@ protected String resolveVersion( Artifact artifact, ArtifactRepository localRepo
}
}
// touch the file if it was checked for updates, but don't create it if it doesn't exist to avoid
// touch the file if it was checked for updates, but don't create it if it doesn't exist remotely to avoid
// storing SNAPSHOT as the actual version which doesn't exist remotely.
if ( checkedUpdates && localMetadata.exists() )
if ( checkedUpdates && localMetadata.getLastModified().getTime() > 0 )
{
localMetadata.storeInLocalRepository( localRepository );
}
@ -126,44 +173,22 @@ protected String resolveVersion( Artifact artifact, ArtifactRepository localRepo
resolvedArtifactCache.add( getCacheKey( artifact ) );
}
String version = localMetadata.constructVersion();
// 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().isInfoEnabled() && !alreadyResolved )
{
if ( version != null && !version.equals( artifact.getBaseVersion() ) )
{
String message = artifact.getArtifactId() + ": resolved to version " + version;
if ( artifact.getRepository() != null )
{
message += " from repository " + artifact.getRepository().getId();
}
else
{
message += " from local repository";
}
getLogger().info( message );
}
}
return version;
}
else
{
if ( getLogger().isInfoEnabled() && !alreadyResolved )
if ( getLogger().isDebugEnabled() && !alreadyResolved )
{
// Locally installed file is newer, don't use the resolved version
getLogger().info( artifact.getArtifactId() + ": using locally installed snapshot" );
getLogger().debug( artifact.getArtifactId() + ": using locally installed snapshot" );
}
return artifact.getVersion();
localMetadata = null;
}
return localMetadata;
}
protected VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact,
ArtifactRepository remoteRepository,
VersionArtifactMetadata localMetadata,
ArtifactMetadata localMetadata,
String checksumPolicy )
throws ArtifactMetadataRetrievalException, ResourceDoesNotExistException
{

View File

@ -54,7 +54,8 @@ public void transformForInstall( Artifact artifact, ArtifactRepository localRepo
if ( artifact.isSnapshot() )
{
SnapshotArtifactMetadata metadata = new SnapshotArtifactMetadata( artifact );
metadata.storeInLocalRepository( localRepository );
artifact.addMetadata( metadata );
}
}

View File

@ -41,10 +41,10 @@ public String getFilename()
{
return filename;
}
public boolean storedInArtifactDirectory()
public boolean storedInGroupDirectory()
{
return true;
return false;
}
public String getGroupId()
@ -62,9 +62,8 @@ public String getVersion()
return artifact.getVersion();
}
public String getBaseVersion()
public Object getKey()
{
return artifact.getBaseVersion();
return artifact.getGroupId() + ":" + artifact.getArtifactId();
}
}

View File

@ -44,23 +44,26 @@ void storeInLocalRepository( ArtifactRepository localRepository )
*/
String getFilename();
/**
* Whether the artifact metadata exists.
* @return true or false
*/
boolean exists();
/**
* Whether this metadata should be stored alongside the artifact.
*/
boolean storedInArtifactDirectory();
boolean storedInArtifactVersionDirectory();
/**
* Whether this metadata should be stored alongside the group.
*/
boolean storedInGroupDirectory();
String getGroupId();
String getArtifactId();
String getVersion();
String getBaseVersion();
Object getKey();
/**
* @Todo delete?
*/
boolean isSnapshot();
}

View File

@ -28,7 +28,6 @@
public interface VersionArtifactMetadata
extends ArtifactMetadata, Comparable
{
/**
* Determine if the metadata is considered newer than a given file.
*

View File

@ -19,7 +19,6 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
/**
* Specifies the repository used for artifact handling.
@ -33,8 +32,6 @@ public interface ArtifactRepository
String pathOfArtifactMetadata( ArtifactMetadata artifactMetadata );
String pathOfRepositoryMetadata( RepositoryMetadata metadata );
String getUrl();
String getBasedir();

View File

@ -18,7 +18,6 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
/**
* @author jdcasey
@ -32,5 +31,4 @@ public interface ArtifactRepositoryLayout
String pathOfArtifactMetadata( ArtifactMetadata metadata );
String pathOfRepositoryMetadata( RepositoryMetadata metadata );
}

View File

@ -19,7 +19,6 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
/**
* @author jdcasey
@ -62,10 +61,14 @@ public String pathOfArtifactMetadata( ArtifactMetadata metadata )
StringBuffer path = new StringBuffer();
path.append( formatAsDirectory( metadata.getGroupId() ) ).append( PATH_SEPARATOR );
path.append( metadata.getArtifactId() ).append( PATH_SEPARATOR );
if ( metadata.storedInArtifactDirectory() )
if ( !metadata.storedInGroupDirectory() )
{
path.append( metadata.getBaseVersion() ).append( PATH_SEPARATOR );
path.append( metadata.getArtifactId() ).append( PATH_SEPARATOR );
if ( metadata.storedInArtifactVersionDirectory() )
{
path.append( metadata.getBaseVersion() ).append( PATH_SEPARATOR );
}
}
path.append( metadata.getFilename() );
@ -73,28 +76,6 @@ public String pathOfArtifactMetadata( ArtifactMetadata metadata )
return path.toString();
}
public String pathOfRepositoryMetadata( RepositoryMetadata metadata )
{
String file = metadata.getRepositoryPath();
String result;
int lastSlash = file.lastIndexOf( PATH_SEPARATOR );
if ( lastSlash > -1 )
{
String filePart = file.substring( lastSlash );
String dirPart = file.substring( 0, lastSlash );
result = formatAsDirectory( dirPart ) + filePart;
}
else
{
result = file;
}
return result;
}
private String formatAsDirectory( String directory )
{
return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR );

View File

@ -19,7 +19,6 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
/**
* @author jdcasey
@ -60,9 +59,4 @@ public String pathOfArtifactMetadata( ArtifactMetadata metadata )
return path.toString();
}
public String pathOfRepositoryMetadata( RepositoryMetadata metadata )
{
return metadata.getRepositoryPath();
}
}

View File

@ -1,44 +0,0 @@
package org.apache.maven.artifact.repository.metadata;
/*
* Copyright 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.
*/
public class GroupRepositoryMetadata
implements RepositoryMetadata
{
/**
* TODO: reuse.
*/
protected static final String METADATA_FILE = "maven-metadata.xml";
private final String groupId;
public GroupRepositoryMetadata( String groupId )
{
this.groupId = groupId;
}
public String getRepositoryPath()
{
return groupId + "/" + METADATA_FILE;
}
public String toString()
{
return "repository metadata for group: \'" + groupId + "\'";
}
}

View File

@ -1,23 +0,0 @@
package org.apache.maven.artifact.repository.metadata;
/*
* Copyright 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.
*/
public interface RepositoryMetadata
{
String getRepositoryPath();
}

View File

@ -1,54 +0,0 @@
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.
*/
public class RepositoryMetadataManagementException
extends Exception
{
private final RepositoryMetadata metadata;
public RepositoryMetadataManagementException( RepositoryMetadata metadata, String message, Throwable cause )
{
super( "Failed to resolve repository metadata: " + metadata + ".\n\nOriginal message: " + message +
"\n\nError was: " + cause.getMessage(), cause );
this.metadata = metadata;
}
public RepositoryMetadataManagementException( RepositoryMetadata metadata, String message )
{
super( "Failed to resolve repository metadata: " + metadata + ".\n\nOriginal message: " + message );
this.metadata = metadata;
}
public RepositoryMetadataManagementException( String message )
{
super( message );
this.metadata = null;
}
public RepositoryMetadataManagementException( String message, Throwable cause )
{
super( message, cause );
this.metadata = null;
}
public RepositoryMetadata getMetadata()
{
return metadata;
}
}

View File

@ -16,21 +16,14 @@
* 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.File;
import java.util.List;
public interface RepositoryMetadataManager
{
void resolve( RepositoryMetadata repositoryMetadata, List repositories, ArtifactRepository local )
throws RepositoryMetadataManagementException;
void deploy( File source, RepositoryMetadata repositoryMetadata, ArtifactRepository remote )
throws RepositoryMetadataManagementException;
void install( File source, RepositoryMetadata repositoryMetadata, ArtifactRepository local )
throws RepositoryMetadataManagementException;
void resolve( ArtifactMetadata repositoryMetadata, List repositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException;
}

View File

@ -61,5 +61,5 @@ void transformForInstall( Artifact artifact, ArtifactRepository localRepository
*/
void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException;
}

View File

@ -23,7 +23,6 @@
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManagementException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver;
@ -142,16 +141,9 @@ public Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session,
{
// TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other
// use for the mapping manager in here
try
{
return pluginMappingManager.getByPrefix( prefix, session.getSettings().getPluginGroups(),
project.getPluginArtifactRepositories(),
session.getLocalRepository() );
}
catch ( RepositoryMetadataManagementException e )
{
throw new PluginManagerException( "Error getting plugin prefix", e );
}
return pluginMappingManager.getByPrefix( prefix, session.getSettings().getPluginGroups(),
project.getPluginArtifactRepositories(),
session.getLocalRepository() );
}
public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,

View File

@ -16,11 +16,11 @@
* limitations under the License.
*/
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.Plugin;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManagementException;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@ -54,7 +54,6 @@ public class DefaultPluginMappingManager
public org.apache.maven.model.Plugin getByPrefix( String pluginPrefix, List groupIds, List pluginRepositories,
ArtifactRepository localRepository )
throws RepositoryMetadataManagementException
{
// if not found, try from the remote repository
if ( !pluginDefinitionsByPrefix.containsKey( pluginPrefix ) )
@ -85,7 +84,7 @@ private void loadPluginMappings( List groupIds, List pluginRepositories, Artifac
{
loadPluginMappings( groupId, pluginRepositories, localRepository );
}
catch ( RepositoryMetadataManagementException e )
catch ( ArtifactMetadataRetrievalException e )
{
getLogger().warn( "Cannot resolve plugin-mapping metadata for groupId: " + groupId + " - IGNORING." );
@ -95,15 +94,15 @@ private void loadPluginMappings( List groupIds, List pluginRepositories, Artifac
}
private void loadPluginMappings( String groupId, List pluginRepositories, ArtifactRepository localRepository )
throws RepositoryMetadataManagementException
throws ArtifactMetadataRetrievalException
{
GroupRepositoryMetadata metadata = new GroupRepositoryMetadata( groupId );
// TOOD: aggregate the results of this instead
// TODO: aggregate the results of this instead
repositoryMetadataManager.resolve( metadata, pluginRepositories, localRepository );
File metadataFile = new File( localRepository.getBasedir(),
localRepository.pathOfRepositoryMetadata( metadata ) );
localRepository.pathOfArtifactMetadata( metadata ) );
if ( metadataFile.exists() )
{
@ -132,7 +131,7 @@ private void loadPluginMappings( String groupId, List pluginRepositories, Artifa
}
private static Metadata readMetadata( File mappingFile )
throws RepositoryMetadataManagementException
throws ArtifactMetadataRetrievalException
{
Metadata result;
@ -147,15 +146,15 @@ private static Metadata readMetadata( File mappingFile )
}
catch ( FileNotFoundException e )
{
throw new RepositoryMetadataManagementException( "Cannot read plugin mappings from: " + mappingFile, e );
throw new ArtifactMetadataRetrievalException( "Cannot read plugin mappings from: " + mappingFile, e );
}
catch ( IOException e )
{
throw new RepositoryMetadataManagementException( "Cannot read plugin mappings from: " + mappingFile, e );
throw new ArtifactMetadataRetrievalException( "Cannot read plugin mappings from: " + mappingFile, e );
}
catch ( XmlPullParserException e )
{
throw new RepositoryMetadataManagementException( "Cannot parse plugin mappings from: " + mappingFile, e );
throw new ArtifactMetadataRetrievalException( "Cannot parse plugin mappings from: " + mappingFile, e );
}
finally
{

View File

@ -17,7 +17,6 @@
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManagementException;
import org.apache.maven.model.Plugin;
import java.util.List;
@ -31,6 +30,5 @@
public interface PluginMappingManager
{
Plugin getByPrefix( String pluginPrefix, List groupIds, List pluginRepositories,
ArtifactRepository localRepository )
throws RepositoryMetadataManagementException;
ArtifactRepository localRepository );
}

View File

@ -244,14 +244,8 @@
org.apache.maven.plugins:maven-jar-plugin:jar,
org.apache.maven.plugins:maven-plugin-plugin:addPluginArtifactMetadata
</package>
<install>
org.apache.maven.plugins:maven-install-plugin:install,
org.apache.maven.plugins:maven-plugin-plugin:installMapping
</install>
<deploy>
org.apache.maven.plugins:maven-deploy-plugin:deploy,
org.apache.maven.plugins:maven-plugin-plugin:deployMapping
</deploy>
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
</phases>
<!-- END SNIPPET: maven-plugin-lifecycle -->
</configuration>

View File

@ -1,207 +0,0 @@
package org.apache.maven.plugin.plugin.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.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.Plugin;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.EOFException;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.Iterator;
public abstract class AbstractPluginMappingMojo
extends AbstractMojo
{
/**
* @parameter
*/
private String goalPrefix;
/**
* @parameter expression="${project}"
* @required
* @readonly
*/
private MavenProject project;
/**
* @parameter expression="${project.build.outputDirectory}"
* @required
* @readonly
*/
private String classesDirectory;
/**
* @parameter expression="${project.build.directory}/repository-metadata"
* @required
* @readonly
*/
private String metadataOutputDirectory;
/**
* @parameter expression="${localRepository}"
* @required
* @readonly
*/
private ArtifactRepository localRepository;
/**
* @parameter expression="${component.org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager}"
* @required
* @readonly
*/
private RepositoryMetadataManager repositoryMetadataManager;
protected RepositoryMetadataManager getRepositoryMetadataManager()
{
return repositoryMetadataManager;
}
protected ArtifactRepository getLocalRepository()
{
return localRepository;
}
protected MavenProject getProject()
{
return project;
}
protected File updatePluginMap( RepositoryMetadata metadata )
throws MojoExecutionException
{
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
Metadata pluginMap = null;
File metadataFile = new File( localRepository.getBasedir(),
localRepository.pathOfRepositoryMetadata( metadata ) );
if ( metadataFile.exists() )
{
Reader reader = null;
try
{
reader = new FileReader( metadataFile );
pluginMap = mappingReader.read( reader );
}
catch ( EOFException e )
{
getLog().warn( metadata + " located in: " + metadataFile + " seems to be corrupt - OVERWRITING." );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Cannot read plugin-mapping metadata from file: " + metadataFile, e );
}
catch ( XmlPullParserException e )
{
throw new MojoExecutionException( "Cannot parse plugin-mapping metadata from file: " + metadataFile,
e );
}
finally
{
IOUtil.close( reader );
}
}
if ( pluginMap == null )
{
pluginMap = new Metadata();
pluginMap.setGroupId( project.getGroupId() );
}
for ( Iterator it = pluginMap.getPlugins().iterator(); it.hasNext(); )
{
Plugin preExisting = (Plugin) it.next();
if ( preExisting.getArtifactId().equals( project.getArtifactId() ) )
{
getLog().info(
"Plugin-mapping metadata for prefix: " + project.getArtifactId() + " already exists. Skipping." );
return null;
}
}
Plugin mappedPlugin = new Plugin();
mappedPlugin.setArtifactId( project.getArtifactId() );
mappedPlugin.setPrefix( getGoalPrefix() );
pluginMap.addPlugin( mappedPlugin );
Writer writer = null;
try
{
File generatedMetadataFile = new File( metadataOutputDirectory, metadata.getRepositoryPath() );
File dir = generatedMetadataFile.getParentFile();
if ( !dir.exists() )
{
dir.mkdirs();
}
writer = new FileWriter( generatedMetadataFile );
MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer();
mappingWriter.write( writer, pluginMap );
return generatedMetadataFile;
}
catch ( IOException e )
{
throw new MojoExecutionException( "Error writing repository metadata to build directory.", e );
}
finally
{
IOUtil.close( writer );
}
}
private String getGoalPrefix()
{
if ( goalPrefix == null )
{
goalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() );
}
return goalPrefix;
}
}

View File

@ -2,39 +2,62 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.LatestArtifactMetadata;
import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
/** Inject any plugin-specific artifact metadata to the project's artifact, for subsequent installation
* and deployment. The first use-case for this is to add the LATEST metadata (which is plugin-specific)
* for shipping alongside the plugin's artifact.
*
/**
* Inject any plugin-specific artifact metadata to the project's artifact, for subsequent installation
* and deployment. The first use-case for this is to add the LATEST metadata (which is plugin-specific)
* for shipping alongside the plugin's artifact.
*
* @phase package
* @goal addPluginArtifactMetadata
*/
public class AddPluginArtifactMetadataMojo
extends AbstractMojo
{
/** The project artifact, which should have the LATEST metadata added to it.
*
/**
* The project artifact, which should have the LATEST metadata added to it.
*
* @parameter expression="${project}"
* @required
* @readonly
*/
private MavenProject project;
/**
* @parameter
*/
private String goalPrefix;
public void execute()
throws MojoExecutionException
{
Artifact projectArtifact = project.getArtifact();
LatestArtifactMetadata metadata = new LatestArtifactMetadata( projectArtifact );
metadata.setVersion( projectArtifact.getVersion() );
projectArtifact.addMetadata( metadata );
GroupRepositoryMetadata groupMetadata = new GroupRepositoryMetadata( project.getGroupId() );
groupMetadata.addPluginMapping( getGoalPrefix(), project.getArtifactId() );
projectArtifact.addMetadata( groupMetadata );
}
private String getGoalPrefix()
{
if ( goalPrefix == null )
{
goalPrefix = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() );
}
return goalPrefix;
}
}

View File

@ -1,67 +0,0 @@
package org.apache.maven.plugin.plugin.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.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManagementException;
import org.apache.maven.plugin.MojoExecutionException;
import java.io.File;
import java.util.Collections;
/**
* @goal deployMapping
* @phase deploy
*/
public class PluginMappingDeployMojo
extends AbstractPluginMappingMojo
{
public void execute()
throws MojoExecutionException
{
RepositoryMetadata metadata = new GroupRepositoryMetadata( getProject().getGroupId() );
ArtifactRepository distributionRepository = getProject().getDistributionManagementArtifactRepository();
if ( distributionRepository == null )
{
throw new MojoExecutionException(
"No distribution repository specified. You must specify a <distributionManagement/> section with a valid <repository/> specified within." );
}
try
{
getRepositoryMetadataManager().resolve( metadata, Collections.singletonList( distributionRepository ),
getLocalRepository() );
File metadataFile = updatePluginMap( metadata );
if ( metadataFile != null )
{
getRepositoryMetadataManager().deploy( metadataFile, metadata, distributionRepository );
}
}
catch ( RepositoryMetadataManagementException e )
{
throw new MojoExecutionException( "Failed to install " + metadata, e );
}
}
}

View File

@ -1,54 +0,0 @@
package org.apache.maven.plugin.plugin.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.repository.metadata.GroupRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManagementException;
import org.apache.maven.plugin.MojoExecutionException;
import java.io.File;
/**
* @goal installMapping
* @phase install
*/
public class PluginMappingInstallMojo
extends AbstractPluginMappingMojo
{
public void execute()
throws MojoExecutionException
{
RepositoryMetadata metadata = new GroupRepositoryMetadata( getProject().getGroupId() );
try
{
File metadataFile = updatePluginMap( metadata );
if ( metadataFile != null )
{
getRepositoryMetadataManager().install( metadataFile, metadata, getLocalRepository() );
}
}
catch ( RepositoryMetadataManagementException e )
{
throw new MojoExecutionException( "Failed to install " + metadata, e );
}
}
}

View File

@ -354,7 +354,7 @@ private Model findModelFromRepository( Artifact artifact, List remoteArtifactRep
artifact.getArtifactId() + ": updating metadata due to status of '" + status + "'" );
try
{
artifact.setFile( null );
artifact.setResolved( false );
artifactResolver.resolveAlways( artifact, remoteArtifactRepositories, localRepository );
}
catch ( ArtifactResolutionException e )
@ -581,7 +581,7 @@ private MavenProject processProjectLogic( String pomLocation, MavenProject proje
// We don't need all the project methods that are added over those in the model, but we do need basedir
Map context = new HashMap( System.getProperties() );
context.put( "basedir", project.getBasedir() );
model = modelInterpolator.interpolate( model, context );
// interpolation is before injection, because interpolation is off-limits in the injected variables

View File

@ -33,6 +33,7 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Date;
/**
* Attach a POM to an artifact.
@ -53,12 +54,7 @@ public ProjectArtifactMetadata( Artifact artifact, File file )
public String getFilename()
{
return getArtifactId() + "-" + getVersion() + ".pom";
}
public boolean exists()
{
return file.exists();
return getArtifactId() + "-" + artifact.getVersion() + ".pom";
}
public void storeInLocalRepository( ArtifactRepository localRepository )
@ -77,7 +73,7 @@ public void storeInLocalRepository( ArtifactRepository localRepository )
MavenXpp3Reader modelReader = new MavenXpp3Reader();
Model model = modelReader.read( reader );
model.setVersion( getVersion() );
model.setVersion( artifact.getVersion() );
DistributionManagement distributionManagement = model.getDistributionManagement();
if ( distributionManagement == null )
@ -113,4 +109,29 @@ public String toString()
{
return "project information for " + artifact.getArtifactId() + " " + artifact.getVersion();
}
public boolean storedInArtifactVersionDirectory()
{
return true;
}
public String getBaseVersion()
{
return artifact.getBaseVersion();
}
public boolean newerThanFile( File file )
{
return this.file.lastModified() > file.lastModified();
}
public Date getLastModified()
{
return new Date( file.lastModified() );
}
public boolean isSnapshot()
{
return artifact.isSnapshot();
}
}

View File

@ -19,6 +19,26 @@
<type>String</type>
<description>The groupId that is directory represents, if any.</description>
</field>
<field>
<name>artifactId</name>
<version>1.0.0</version>
<type>String</type>
<description>The artifactId that is directory represents, if any.</description>
</field>
<field>
<name>version</name>
<version>1.0.0</version>
<type>String</type>
<description>The version that is directory represents, if any.</description>
</field>
<field>
<name>versioning</name>
<version>1.0.0</version>
<association>
<type>Versioning</type>
</association>
<description>Versioning information for the artifact.</description>
</field>
<field>
<name>plugins</name>
<version>1.0.0</version>
@ -30,6 +50,61 @@
</field>
</fields>
</class>
<class>
<name>Versioning</name>
<version>1.0.0</version>
<description>Versioning information for an artifact</description>
<fields>
<field>
<name>latest</name>
<version>1.0.0</version>
<type>String</type>
<description>What the latest version in the directory is, including snapshots</description>
</field>
<field>
<name>release</name>
<version>1.0.0</version>
<type>String</type>
<description>What the latest version in the directory is, of the releases</description>
</field>
<field>
<name>snapshot</name>
<version>1.0.0</version>
<association>
<type>Snapshot</type>
</association>
<description>The current snapshot data in use for this version</description>
</field>
<field>
<name>versions</name>
<version>1.0.0</version>
<description>Versions available for the artifact</description>
<association>
<type>String</type>
<multiplicity>*</multiplicity>
</association>
</field>
</fields>
</class>
<class>
<name>Snapshot</name>
<version>1.0.0</version>
<description>Snapshot data for the current version</description>
<fields>
<field>
<name>timestamp</name>
<version>1.0.0</version>
<description>The time it was deployed</description>
<type>String</type>
</field>
<field>
<name>buildNumber</name>
<version>1.0.0</version>
<description>The incremental build number</description>
<type>int</type>
</field>
</fields>
</class>
<class>
<name>Plugin</name>
<version>1.0.0</version>
@ -53,4 +128,4 @@
</fields>
</class>
</classes>
</model>
</model>