mirror of https://github.com/apache/maven.git
PR: MNG-456
allow separate snapshot and release repositories deprecate existing snapshotPolicy and checksumPolicy in favour of updatePolicy and checksumPolicy within the <releases> and <snapshots> elements in the <repository> element. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@224707 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7a2d130893
commit
086463b5b4
|
@ -21,6 +21,7 @@ import org.apache.maven.artifact.factory.ArtifactFactory;
|
|||
import org.apache.maven.artifact.manager.WagonManager;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.model.Model;
|
||||
|
@ -34,7 +35,6 @@ import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
|||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.apache.tools.ant.Task;
|
||||
import org.codehaus.classworlds.ClassRealm;
|
||||
import org.codehaus.classworlds.ClassWorld;
|
||||
import org.codehaus.classworlds.DuplicateRealmException;
|
||||
import org.codehaus.plexus.PlexusContainerException;
|
||||
|
@ -113,12 +113,15 @@ public abstract class AbstractArtifactTask
|
|||
{
|
||||
repositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
|
||||
|
||||
String snapshotPolicy = repository.getSnapshotPolicy();
|
||||
String checksumPolicy = repository.getChecksumPolicy();
|
||||
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repository.getSnapshots(),
|
||||
repository.getSnapshotPolicy(),
|
||||
repository.getChecksumPolicy() );
|
||||
ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repository.getReleases(),
|
||||
repository.getSnapshotPolicy(),
|
||||
repository.getChecksumPolicy() );
|
||||
|
||||
artifactRepository = repositoryFactory.createArtifactRepository( "remote", repository.getUrl(),
|
||||
repositoryLayout, snapshotPolicy,
|
||||
checksumPolicy );
|
||||
repositoryLayout, snapshots, releases );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -135,6 +138,29 @@ public abstract class AbstractArtifactTask
|
|||
return artifactRepository;
|
||||
}
|
||||
|
||||
private static ArtifactRepositoryPolicy buildArtifactRepositoryPolicy(
|
||||
RepositoryPolicy policy, String defaultUpdatePolicy, String defaultChecksumPolicy )
|
||||
{
|
||||
boolean enabled = true;
|
||||
String updatePolicy = defaultUpdatePolicy;
|
||||
String checksumPolicy = defaultChecksumPolicy;
|
||||
|
||||
if ( policy != null )
|
||||
{
|
||||
enabled = policy.isEnabled();
|
||||
if ( policy.getUpdatePolicy() != null )
|
||||
{
|
||||
updatePolicy = policy.getUpdatePolicy();
|
||||
}
|
||||
if ( policy.getChecksumPolicy() != null )
|
||||
{
|
||||
checksumPolicy = policy.getChecksumPolicy();
|
||||
}
|
||||
}
|
||||
|
||||
return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy );
|
||||
}
|
||||
|
||||
protected LocalRepository getDefaultLocalRepository()
|
||||
{
|
||||
Settings settings = getSettings();
|
||||
|
@ -192,6 +218,24 @@ public abstract class AbstractArtifactTask
|
|||
}
|
||||
|
||||
protected RemoteRepository createAntRemoteRepository( org.apache.maven.model.Repository pomRepository )
|
||||
{
|
||||
RemoteRepository r = createAntRemoteRepositoryBase( pomRepository );
|
||||
|
||||
r.setSnapshotPolicy( pomRepository.getSnapshotPolicy() );
|
||||
|
||||
if ( pomRepository.getSnapshots() != null )
|
||||
{
|
||||
r.setSnapshots( convertRepositoryPolicy( pomRepository.getSnapshots() ) );
|
||||
}
|
||||
if ( pomRepository.getReleases() != null )
|
||||
{
|
||||
r.setReleases( convertRepositoryPolicy( pomRepository.getReleases() ) );
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
protected RemoteRepository createAntRemoteRepositoryBase( org.apache.maven.model.RepositoryBase pomRepository )
|
||||
{
|
||||
// TODO: actually, we need to not funnel this through the ant repository - we should pump settings into wagon
|
||||
// manager at the start like m2 does, and then match up by repository id
|
||||
|
@ -199,7 +243,6 @@ public abstract class AbstractArtifactTask
|
|||
|
||||
RemoteRepository r = new RemoteRepository();
|
||||
r.setUrl( pomRepository.getUrl() );
|
||||
r.setSnapshotPolicy( pomRepository.getSnapshotPolicy() );
|
||||
r.setLayout( pomRepository.getLayout() );
|
||||
|
||||
Server server = getSettings().getServer( pomRepository.getId() );
|
||||
|
@ -219,7 +262,6 @@ public abstract class AbstractArtifactTask
|
|||
{
|
||||
r.setUrl( mirror.getUrl() );
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -360,6 +402,15 @@ public abstract class AbstractArtifactTask
|
|||
{
|
||||
ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||
// TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
|
||||
return factory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(), pom.getPackaging() );
|
||||
return factory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(),
|
||||
pom.getPackaging() );
|
||||
}
|
||||
|
||||
private static RepositoryPolicy convertRepositoryPolicy( org.apache.maven.model.RepositoryPolicy pomRepoPolicy )
|
||||
{
|
||||
RepositoryPolicy policy = new RepositoryPolicy();
|
||||
policy.setEnabled( pomRepoPolicy.isEnabled() );
|
||||
policy.setUpdatePolicy( pomRepoPolicy.getUpdatePolicy() );
|
||||
return policy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ package org.apache.maven.artifact.ant;
|
|||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.DefaultArtifact;
|
||||
import org.apache.maven.artifact.deployer.ArtifactDeployer;
|
||||
import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
|
@ -39,6 +38,8 @@ public class DeployTask
|
|||
{
|
||||
private RemoteRepository remoteRepository;
|
||||
|
||||
private RemoteRepository remoteSnapshotRepository;
|
||||
|
||||
private File file;
|
||||
|
||||
public void execute()
|
||||
|
@ -60,11 +61,26 @@ public class DeployTask
|
|||
throw new BuildException( "A distributionManagement element is required in your POM to deploy" );
|
||||
}
|
||||
|
||||
remoteRepository = createAntRemoteRepository( pom.getDistributionManagement().getRepository() );
|
||||
remoteRepository = createAntRemoteRepositoryBase( pom.getDistributionManagement().getRepository() );
|
||||
}
|
||||
|
||||
if ( remoteSnapshotRepository == null )
|
||||
{
|
||||
if ( pom.getDistributionManagement().getSnapshotRepository() != null )
|
||||
{
|
||||
remoteSnapshotRepository = createAntRemoteRepositoryBase(
|
||||
pom.getDistributionManagement().getSnapshotRepository() );
|
||||
}
|
||||
}
|
||||
|
||||
ArtifactRepository deploymentRepository = createRemoteArtifactRepository( remoteRepository );
|
||||
|
||||
ArtifactRepository snapshotRepository = null;
|
||||
if ( remoteSnapshotRepository != null )
|
||||
{
|
||||
snapshotRepository = createRemoteArtifactRepository( remoteSnapshotRepository );
|
||||
}
|
||||
|
||||
// Deploy the POM
|
||||
Artifact artifact = createArtifact( pom );
|
||||
|
||||
|
@ -100,6 +116,11 @@ public class DeployTask
|
|||
return remoteRepository;
|
||||
}
|
||||
|
||||
public void addRemoteSnapshotRepository( RemoteRepository remoteSnapshotRepository )
|
||||
{
|
||||
this.remoteSnapshotRepository = remoteSnapshotRepository;
|
||||
}
|
||||
|
||||
public void addRemoteRepository( RemoteRepository remoteRepository )
|
||||
{
|
||||
this.remoteRepository = remoteRepository;
|
||||
|
|
|
@ -29,12 +29,18 @@ public class RemoteRepository
|
|||
|
||||
private Authentication authentication;
|
||||
|
||||
/** @deprecated use <snapshots/> and <updatePolicy> instead. */
|
||||
private String snapshotPolicy;
|
||||
|
||||
/** @deprecated use <snapshots/> and <checksumPolicy> instead. */
|
||||
private String checksumPolicy;
|
||||
|
||||
private Proxy proxy;
|
||||
|
||||
private RepositoryPolicy snapshots;
|
||||
|
||||
private RepositoryPolicy releases;
|
||||
|
||||
public String getUrl()
|
||||
{
|
||||
return ( (RemoteRepository) getInstance() ).url;
|
||||
|
@ -84,4 +90,24 @@ public class RemoteRepository
|
|||
{
|
||||
this.checksumPolicy = checksumPolicy;
|
||||
}
|
||||
|
||||
public RepositoryPolicy getSnapshots()
|
||||
{
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
public void setSnapshots( RepositoryPolicy snapshots )
|
||||
{
|
||||
this.snapshots = snapshots;
|
||||
}
|
||||
|
||||
public RepositoryPolicy getReleases()
|
||||
{
|
||||
return releases;
|
||||
}
|
||||
|
||||
public void setReleases( RepositoryPolicy releases )
|
||||
{
|
||||
this.releases = releases;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package org.apache.maven.artifact.ant;
|
||||
|
||||
/*
|
||||
* 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.tools.ant.ProjectComponent;
|
||||
|
||||
/**
|
||||
* Base class for a repository.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class RepositoryPolicy
|
||||
extends ProjectComponent
|
||||
{
|
||||
private String updatePolicy;
|
||||
|
||||
private String checksumPolicy;
|
||||
|
||||
private boolean enabled = true;
|
||||
|
||||
public String getUpdatePolicy()
|
||||
{
|
||||
return updatePolicy;
|
||||
}
|
||||
|
||||
public void setUpdatePolicy( String updatePolicy )
|
||||
{
|
||||
this.updatePolicy = updatePolicy;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled( boolean enabled )
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getChecksumPolicy()
|
||||
{
|
||||
return checksumPolicy;
|
||||
}
|
||||
|
||||
public void setChecksumPolicy( String checksumPolicy )
|
||||
{
|
||||
this.checksumPolicy = checksumPolicy;
|
||||
}
|
||||
}
|
|
@ -43,10 +43,8 @@ public class DefaultArtifactDeployer
|
|||
ArtifactRepository localRepository )
|
||||
throws ArtifactDeploymentException
|
||||
{
|
||||
File source = null;
|
||||
|
||||
String extension = artifact.getArtifactHandler().getExtension();
|
||||
source = new File( basedir, finalName + "." + extension );
|
||||
File source = new File( basedir, finalName + "." + extension );
|
||||
deploy( source, artifact, deploymentRepository, localRepository );
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.artifact.manager;
|
|||
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.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
|
||||
import org.apache.maven.wagon.ConnectionException;
|
||||
|
@ -238,16 +239,26 @@ public class DefaultWagonManager
|
|||
{
|
||||
String remotePath = repository.pathOf( artifact );
|
||||
|
||||
getRemoteFile( repository, destination, remotePath, downloadMonitor );
|
||||
ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases();
|
||||
|
||||
if ( policy.isEnabled() )
|
||||
{
|
||||
getRemoteFile( repository, destination, remotePath, downloadMonitor, policy.getUpdatePolicy() );
|
||||
}
|
||||
else
|
||||
{
|
||||
getLogger().info( "Skipping disabled repository " + repository.getId() );
|
||||
}
|
||||
}
|
||||
|
||||
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination )
|
||||
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository repository, File destination,
|
||||
String updatePolicy )
|
||||
throws TransferFailedException, ResourceDoesNotExistException
|
||||
{
|
||||
String remotePath = remoteRepository.pathOfMetadata( metadata );
|
||||
String remotePath = repository.pathOfMetadata( metadata );
|
||||
|
||||
getLogger().info( "Retrieving " + metadata );
|
||||
getRemoteFile( remoteRepository, destination, remotePath, null );
|
||||
getRemoteFile( repository, destination, remotePath, null, updatePolicy );
|
||||
}
|
||||
|
||||
public void getRepositoryMetadata( RepositoryMetadata metadata, ArtifactRepository remoteRepository,
|
||||
|
@ -258,11 +269,11 @@ public class DefaultWagonManager
|
|||
|
||||
getLogger().info( "Retrieving " + metadata );
|
||||
|
||||
getRemoteFile( remoteRepository, destination, remotePath, null );
|
||||
getRemoteFile( remoteRepository, destination, remotePath, null, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
|
||||
}
|
||||
|
||||
private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath,
|
||||
TransferListener downloadMonitor )
|
||||
TransferListener downloadMonitor, String updatePolicy )
|
||||
throws TransferFailedException, ResourceDoesNotExistException, ChecksumFailedException
|
||||
{
|
||||
// TODO: better excetpions - transfer failed is not enough?
|
||||
|
@ -272,7 +283,8 @@ public class DefaultWagonManager
|
|||
ArtifactRepository mirror = getMirror( repository.getId() );
|
||||
if ( mirror != null )
|
||||
{
|
||||
repository = mirror;
|
||||
repository = new DefaultArtifactRepository( mirror.getId(), mirror.getUrl(), repository.getLayout(),
|
||||
repository.getSnapshots(), repository.getReleases() );
|
||||
}
|
||||
|
||||
String protocol = repository.getProtocol();
|
||||
|
@ -351,7 +363,7 @@ public class DefaultWagonManager
|
|||
}
|
||||
else
|
||||
{
|
||||
handleChecksumFailure( repository, e.getMessage(), e.getCause() );
|
||||
handleChecksumFailure( updatePolicy, e.getMessage(), e.getCause() );
|
||||
}
|
||||
}
|
||||
catch ( ResourceDoesNotExistException sha1TryException )
|
||||
|
@ -374,13 +386,13 @@ public class DefaultWagonManager
|
|||
}
|
||||
else
|
||||
{
|
||||
handleChecksumFailure( repository, e.getMessage(), e.getCause() );
|
||||
handleChecksumFailure( updatePolicy, e.getMessage(), e.getCause() );
|
||||
}
|
||||
}
|
||||
catch ( ResourceDoesNotExistException md5TryException )
|
||||
{
|
||||
// this was a failed transfer, and we don't want to retry.
|
||||
handleChecksumFailure( repository, "Error retrieving checksum file for " + remotePath,
|
||||
handleChecksumFailure( updatePolicy, "Error retrieving checksum file for " + remotePath,
|
||||
md5TryException );
|
||||
}
|
||||
}
|
||||
|
@ -440,10 +452,10 @@ public class DefaultWagonManager
|
|||
}
|
||||
}
|
||||
|
||||
private void handleChecksumFailure( ArtifactRepository repository, String message, Throwable cause )
|
||||
private void handleChecksumFailure( String updatePolicy, String message, Throwable cause )
|
||||
throws ChecksumFailedException
|
||||
{
|
||||
if ( repository.failOnChecksumMismatch() )
|
||||
if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL.equals( updatePolicy ) )
|
||||
{
|
||||
throw new ChecksumFailedException( message, cause );
|
||||
}
|
||||
|
|
|
@ -54,7 +54,8 @@ public interface WagonManager
|
|||
void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository )
|
||||
throws TransferFailedException;
|
||||
|
||||
void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination )
|
||||
void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination,
|
||||
String updatePolicy )
|
||||
throws TransferFailedException, ResourceDoesNotExistException;
|
||||
|
||||
void putRepositoryMetadata( File source, RepositoryMetadata metadata, ArtifactRepository repository )
|
||||
|
|
|
@ -39,7 +39,7 @@ public abstract class AbstractVersionArtifactMetadata
|
|||
{
|
||||
protected static final String SNAPSHOT_VERSION_FILE = "version.txt";
|
||||
|
||||
protected long lastModified = 0;
|
||||
protected long lastModified;
|
||||
|
||||
public AbstractVersionArtifactMetadata( Artifact artifact, String filename )
|
||||
{
|
||||
|
@ -82,7 +82,8 @@ public abstract class AbstractVersionArtifactMetadata
|
|||
}
|
||||
}
|
||||
|
||||
public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager )
|
||||
public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager,
|
||||
String updatePolicy )
|
||||
throws ArtifactMetadataRetrievalException, ResourceDoesNotExistException
|
||||
{
|
||||
try
|
||||
|
@ -91,7 +92,7 @@ public abstract class AbstractVersionArtifactMetadata
|
|||
File destination = File.createTempFile( "maven-artifact", null );
|
||||
destination.deleteOnExit();
|
||||
|
||||
wagonManager.getArtifactMetadata( this, remoteRepository, destination );
|
||||
wagonManager.getArtifactMetadata( this, remoteRepository, destination, updatePolicy );
|
||||
|
||||
readFromFile( destination );
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public class LatestArtifactMetadata
|
|||
|
||||
public LatestArtifactMetadata( Artifact artifact )
|
||||
{
|
||||
super( artifact, artifact.getArtifactId() + "-" + LatestArtifactTransformation.LATEST_VERSION + "." + SNAPSHOT_VERSION_FILE );
|
||||
super( artifact, artifact.getArtifactId() + "-" + Artifact.LATEST_VERSION + "." + SNAPSHOT_VERSION_FILE );
|
||||
}
|
||||
|
||||
public String constructVersion()
|
||||
|
@ -74,7 +74,7 @@ public class LatestArtifactMetadata
|
|||
|
||||
public String getBaseVersion()
|
||||
{
|
||||
return LatestArtifactTransformation.LATEST_VERSION;
|
||||
return Artifact.LATEST_VERSION;
|
||||
}
|
||||
|
||||
public boolean storedInArtifactDirectory()
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Contains the information stored for a snapshot.
|
||||
|
@ -36,16 +35,14 @@ import java.util.regex.Pattern;
|
|||
public class SnapshotArtifactMetadata
|
||||
extends AbstractVersionArtifactMetadata
|
||||
{
|
||||
private String timestamp = null;
|
||||
private String timestamp;
|
||||
|
||||
private int buildNumber = 0;
|
||||
private int buildNumber;
|
||||
|
||||
private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
|
||||
|
||||
private static final String UTC_TIMESTAMP_PATTERN = "yyyyMMdd.HHmmss";
|
||||
|
||||
public static final Pattern VERSION_FILE_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$" );
|
||||
|
||||
// TODO: very quick and nasty hack to get the same timestamp across a build - not embedder friendly
|
||||
private static String sessionTimestamp = null;
|
||||
|
||||
|
@ -74,7 +71,7 @@ public class SnapshotArtifactMetadata
|
|||
|
||||
protected void setContent( String content )
|
||||
{
|
||||
Matcher matcher = VERSION_FILE_PATTERN.matcher( content );
|
||||
Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( content );
|
||||
if ( matcher.matches() )
|
||||
{
|
||||
timestamp = matcher.group( 2 );
|
||||
|
@ -159,7 +156,7 @@ public class SnapshotArtifactMetadata
|
|||
if ( timestamp != null )
|
||||
{
|
||||
String fileTimestamp = getUtcDateFormatter().format( new Date( fileTime ) );
|
||||
return ( fileTimestamp.compareTo( timestamp ) < 0 );
|
||||
return fileTimestamp.compareTo( timestamp ) < 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -32,26 +32,43 @@ public class DefaultArtifactRepository
|
|||
extends Repository
|
||||
implements ArtifactRepository
|
||||
{
|
||||
private final String snapshotPolicy;
|
||||
|
||||
private final String checksumPolicy;
|
||||
|
||||
private final ArtifactRepositoryLayout layout;
|
||||
|
||||
private ArtifactRepositoryPolicy snapshots;
|
||||
|
||||
private ArtifactRepositoryPolicy releases;
|
||||
|
||||
/**
|
||||
* Create a local repository or a deployment repository.
|
||||
*
|
||||
* @param id the unique identifier of the repository
|
||||
* @param url the URL of the repository
|
||||
* @param layout the layout of the repository
|
||||
*/
|
||||
public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout )
|
||||
{
|
||||
this( id, url, layout, SNAPSHOT_POLICY_NEVER, CHECKSUM_POLICY_WARN );
|
||||
this( id, url, layout, null, null );
|
||||
}
|
||||
|
||||
public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, String snapshotPolicy, String checksumPolicy )
|
||||
/**
|
||||
* Create a remote download repository.
|
||||
*
|
||||
* @param id the unique identifier of the repository
|
||||
* @param url the URL of the repository
|
||||
* @param layout the layout of the repository
|
||||
* @param snapshots the policies to use for snapshots
|
||||
* @param releases the policies to use for releases
|
||||
*/
|
||||
public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout,
|
||||
ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases )
|
||||
{
|
||||
super( id, url );
|
||||
|
||||
this.layout = layout;
|
||||
|
||||
this.snapshotPolicy = snapshotPolicy;
|
||||
this.snapshots = snapshots;
|
||||
|
||||
this.checksumPolicy = checksumPolicy;
|
||||
this.releases = releases;
|
||||
}
|
||||
|
||||
public String pathOf( Artifact artifact )
|
||||
|
@ -74,19 +91,18 @@ public class DefaultArtifactRepository
|
|||
return layout.formatAsFile( file );
|
||||
}
|
||||
|
||||
public String getSnapshotPolicy()
|
||||
public ArtifactRepositoryLayout getLayout()
|
||||
{
|
||||
return snapshotPolicy;
|
||||
return layout;
|
||||
}
|
||||
|
||||
public String getChecksumPolicy()
|
||||
public ArtifactRepositoryPolicy getSnapshots()
|
||||
{
|
||||
return checksumPolicy;
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
public boolean failOnChecksumMismatch()
|
||||
public ArtifactRepositoryPolicy getReleases()
|
||||
{
|
||||
return CHECKSUM_POLICY_FAIL.equals( checksumPolicy );
|
||||
return releases;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,52 +25,67 @@ public class DefaultArtifactRepositoryFactory
|
|||
implements ArtifactRepositoryFactory
|
||||
{
|
||||
// TODO: use settings?
|
||||
private String globalSnapshotPolicy = null;
|
||||
private String globalUpdatePolicy;
|
||||
|
||||
private String globalChecksumPolicy = null;
|
||||
private String globalChecksumPolicy;
|
||||
|
||||
private boolean globalEnable = true;
|
||||
|
||||
public ArtifactRepository createArtifactRepository( String id, String url,
|
||||
ArtifactRepositoryLayout repositoryLayout )
|
||||
{
|
||||
return new DefaultArtifactRepository( id, url, repositoryLayout );
|
||||
}
|
||||
|
||||
public ArtifactRepository createArtifactRepository( String id, String url,
|
||||
ArtifactRepositoryLayout repositoryLayout,
|
||||
String snapshotPolicy, String checksumPolicy )
|
||||
ArtifactRepositoryPolicy snapshots,
|
||||
ArtifactRepositoryPolicy releases )
|
||||
{
|
||||
ArtifactRepository repo = null;
|
||||
|
||||
String snapPolicy = snapshotPolicy;
|
||||
|
||||
if ( globalSnapshotPolicy != null )
|
||||
if ( snapshots == null )
|
||||
{
|
||||
snapPolicy = globalSnapshotPolicy;
|
||||
snapshots = new ArtifactRepositoryPolicy();
|
||||
}
|
||||
|
||||
if ( snapPolicy == null )
|
||||
if ( releases == null )
|
||||
{
|
||||
snapPolicy = ArtifactRepository.SNAPSHOT_POLICY_NEVER;
|
||||
releases = new ArtifactRepositoryPolicy();
|
||||
}
|
||||
|
||||
String csumPolicy = checksumPolicy;
|
||||
if ( globalUpdatePolicy != null )
|
||||
{
|
||||
snapshots.setUpdatePolicy( globalUpdatePolicy );
|
||||
releases.setUpdatePolicy( globalUpdatePolicy );
|
||||
}
|
||||
|
||||
if ( globalChecksumPolicy != null )
|
||||
{
|
||||
csumPolicy = globalChecksumPolicy;
|
||||
snapshots.setChecksumPolicy( globalChecksumPolicy );
|
||||
releases.setChecksumPolicy( globalChecksumPolicy );
|
||||
}
|
||||
|
||||
if ( csumPolicy == null )
|
||||
// TODO: needed, or can offline cover it?
|
||||
if ( !globalEnable )
|
||||
{
|
||||
csumPolicy = ArtifactRepository.CHECKSUM_POLICY_WARN;
|
||||
snapshots.setEnabled( false );
|
||||
releases.setEnabled( false );
|
||||
}
|
||||
|
||||
repo = new DefaultArtifactRepository( id, url, repositoryLayout, snapPolicy, csumPolicy );
|
||||
|
||||
return repo;
|
||||
return new DefaultArtifactRepository( id, url, repositoryLayout, snapshots, releases );
|
||||
}
|
||||
|
||||
public void setGlobalSnapshotPolicy( String snapshotPolicy )
|
||||
public void setGlobalUpdatePolicy( String updatePolicy )
|
||||
{
|
||||
this.globalSnapshotPolicy = snapshotPolicy;
|
||||
this.globalUpdatePolicy = updatePolicy;
|
||||
}
|
||||
|
||||
public void setGlobalChecksumPolicy( String checksumPolicy )
|
||||
{
|
||||
this.globalChecksumPolicy = checksumPolicy;
|
||||
}
|
||||
|
||||
public void setGlobalEnable( boolean enable )
|
||||
{
|
||||
this.globalEnable = enable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.maven.artifact.metadata.AbstractVersionArtifactMetadata;
|
|||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||
import org.apache.maven.artifact.metadata.VersionArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
||||
|
@ -69,62 +70,74 @@ public abstract class AbstractVersionTransformation
|
|||
boolean checkedUpdates = false;
|
||||
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
|
||||
{
|
||||
ArtifactRepository remoteRepository = (ArtifactRepository) i.next();
|
||||
ArtifactRepository repository = (ArtifactRepository) i.next();
|
||||
|
||||
String snapshotPolicy = remoteRepository.getSnapshotPolicy();
|
||||
// TODO: should be able to calculate this less often
|
||||
boolean checkForUpdates = false;
|
||||
if ( ArtifactRepository.SNAPSHOT_POLICY_ALWAYS.equals( snapshotPolicy ) )
|
||||
ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots()
|
||||
: repository.getReleases();
|
||||
|
||||
if ( !policy.isEnabled() )
|
||||
{
|
||||
checkForUpdates = true;
|
||||
getLogger().info( "Skipping disabled repository " + repository.getId() );
|
||||
}
|
||||
else if ( ArtifactRepository.SNAPSHOT_POLICY_DAILY.equals( snapshotPolicy ) )
|
||||
else
|
||||
{
|
||||
if ( !localMetadata.checkedSinceDate( getMidnightBoundary() ) )
|
||||
String updatePolicy = policy.getUpdatePolicy();
|
||||
// TODO: should be able to calculate this less often
|
||||
boolean checkForUpdates = false;
|
||||
if ( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS.equals( updatePolicy ) )
|
||||
{
|
||||
checkForUpdates = true;
|
||||
}
|
||||
}
|
||||
else if ( snapshotPolicy.startsWith( ArtifactRepository.SNAPSHOT_POLICY_INTERVAL ) )
|
||||
{
|
||||
String s = snapshotPolicy.substring( ArtifactRepository.SNAPSHOT_POLICY_INTERVAL.length() + 1 );
|
||||
int minutes = Integer.valueOf( s ).intValue();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add( Calendar.MINUTE, -minutes );
|
||||
if ( !localMetadata.checkedSinceDate( cal.getTime() ) )
|
||||
else if ( ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY.equals( updatePolicy ) )
|
||||
{
|
||||
checkForUpdates = true;
|
||||
if ( !localMetadata.checkedSinceDate( getMidnightBoundary() ) )
|
||||
{
|
||||
checkForUpdates = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// else assume "never"
|
||||
|
||||
if ( checkForUpdates )
|
||||
{
|
||||
getLogger().info(
|
||||
artifact.getArtifactId() + ": checking for updates from " + remoteRepository.getId() );
|
||||
|
||||
VersionArtifactMetadata remoteMetadata;
|
||||
|
||||
checkedUpdates = true;
|
||||
|
||||
try
|
||||
else if ( updatePolicy.startsWith( ArtifactRepositoryPolicy.UPDATE_POLICY_INTERVAL ) )
|
||||
{
|
||||
remoteMetadata = retrieveFromRemoteRepository( artifact, remoteRepository, localMetadata );
|
||||
String s = updatePolicy.substring(
|
||||
ArtifactRepositoryPolicy.UPDATE_POLICY_INTERVAL.length() + 1 );
|
||||
int minutes = Integer.valueOf( s ).intValue();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add( Calendar.MINUTE, -minutes );
|
||||
if ( !localMetadata.checkedSinceDate( cal.getTime() ) )
|
||||
{
|
||||
checkForUpdates = true;
|
||||
}
|
||||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
// else assume "never"
|
||||
|
||||
if ( checkForUpdates )
|
||||
{
|
||||
getLogger().debug( "Error resolving artifact version from metadata.", e );
|
||||
getLogger().info(
|
||||
artifact.getArtifactId() + ": checking for updates from " + repository.getId() );
|
||||
|
||||
continue;
|
||||
}
|
||||
VersionArtifactMetadata remoteMetadata;
|
||||
|
||||
int difference = remoteMetadata.compareTo( localMetadata );
|
||||
if ( difference > 0 )
|
||||
{
|
||||
// remote is newer
|
||||
artifact.setRepository( remoteRepository );
|
||||
checkedUpdates = true;
|
||||
|
||||
localMetadata = remoteMetadata;
|
||||
try
|
||||
{
|
||||
remoteMetadata = retrieveFromRemoteRepository( artifact, repository, localMetadata,
|
||||
updatePolicy );
|
||||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
{
|
||||
getLogger().debug( "Error resolving artifact version from metadata.", e );
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
int difference = remoteMetadata.compareTo( localMetadata );
|
||||
if ( difference > 0 )
|
||||
{
|
||||
// remote is newer
|
||||
artifact.setRepository( repository );
|
||||
|
||||
localMetadata = remoteMetadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,12 +187,13 @@ public abstract class AbstractVersionTransformation
|
|||
|
||||
protected VersionArtifactMetadata retrieveFromRemoteRepository( Artifact artifact,
|
||||
ArtifactRepository remoteRepository,
|
||||
VersionArtifactMetadata localMetadata )
|
||||
VersionArtifactMetadata localMetadata,
|
||||
String updatePolicy )
|
||||
throws ArtifactMetadataRetrievalException, ResourceDoesNotExistException
|
||||
{
|
||||
AbstractVersionArtifactMetadata metadata = createMetadata( artifact );
|
||||
|
||||
metadata.retrieveFromRemoteRepository( remoteRepository, wagonManager );
|
||||
metadata.retrieveFromRemoteRepository( remoteRepository, wagonManager, updatePolicy );
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
|
|
@ -27,12 +27,10 @@ import java.util.List;
|
|||
public class LatestArtifactTransformation
|
||||
extends AbstractVersionTransformation
|
||||
{
|
||||
public static final String LATEST_VERSION = "LATEST";
|
||||
|
||||
public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
if ( LATEST_VERSION.equals( artifact.getVersion() ) )
|
||||
if ( Artifact.LATEST_VERSION.equals( artifact.getVersion() ) )
|
||||
{
|
||||
String version = resolveVersion( artifact, localRepository, remoteRepositories );
|
||||
if ( version != null && !version.equals( artifact.getVersion() ) )
|
||||
|
|
|
@ -21,10 +21,10 @@ import org.apache.maven.artifact.metadata.AbstractVersionArtifactMetadata;
|
|||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
|
@ -35,18 +35,10 @@ import java.util.regex.Matcher;
|
|||
public class SnapshotTransformation
|
||||
extends AbstractVersionTransformation
|
||||
{
|
||||
public static final String SNAPSHOT_VERSION = "SNAPSHOT";
|
||||
|
||||
public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
Matcher m = SnapshotArtifactMetadata.VERSION_FILE_PATTERN.matcher( artifact.getBaseVersion() );
|
||||
if ( m.matches() )
|
||||
{
|
||||
// This corrects the base version, but ensure it is not resolved again
|
||||
artifact.setBaseVersion( m.group( 1 ) + "-" + SNAPSHOT_VERSION );
|
||||
}
|
||||
else if ( isSnapshot( artifact ) )
|
||||
if ( artifact.isSnapshot() )
|
||||
{
|
||||
String version = resolveVersion( artifact, localRepository, remoteRepositories );
|
||||
artifact.updateVersion( version, localRepository );
|
||||
|
@ -56,12 +48,7 @@ public class SnapshotTransformation
|
|||
public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
Matcher m = SnapshotArtifactMetadata.VERSION_FILE_PATTERN.matcher( artifact.getBaseVersion() );
|
||||
if ( m.matches() )
|
||||
{
|
||||
artifact.setBaseVersion( m.group( 1 ) + "-" + SNAPSHOT_VERSION );
|
||||
}
|
||||
else if ( isSnapshot( artifact ) )
|
||||
if ( artifact.isSnapshot() )
|
||||
{
|
||||
SnapshotArtifactMetadata metadata = new SnapshotArtifactMetadata( artifact );
|
||||
metadata.storeInLocalRepository( localRepository );
|
||||
|
@ -71,19 +58,14 @@ public class SnapshotTransformation
|
|||
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
Matcher m = SnapshotArtifactMetadata.VERSION_FILE_PATTERN.matcher( artifact.getBaseVersion() );
|
||||
if ( m.matches() )
|
||||
{
|
||||
// This corrects the base version, but ensure it is not updated again
|
||||
artifact.setBaseVersion( m.group( 1 ) + "-" + SNAPSHOT_VERSION );
|
||||
}
|
||||
else if ( isSnapshot( artifact ) )
|
||||
if ( artifact.isSnapshot() )
|
||||
{
|
||||
SnapshotArtifactMetadata metadata;
|
||||
|
||||
try
|
||||
{
|
||||
metadata = (SnapshotArtifactMetadata) retrieveFromRemoteRepository( artifact, remoteRepository, null );
|
||||
metadata = (SnapshotArtifactMetadata) retrieveFromRemoteRepository( artifact, remoteRepository, null,
|
||||
ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
|
||||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
{
|
||||
|
@ -99,11 +81,6 @@ public class SnapshotTransformation
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean isSnapshot( Artifact artifact )
|
||||
{
|
||||
return artifact.getVersion().endsWith( SNAPSHOT_VERSION );
|
||||
}
|
||||
|
||||
protected AbstractVersionArtifactMetadata createMetadata( Artifact artifact )
|
||||
{
|
||||
return new SnapshotArtifactMetadata( artifact );
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.maven.artifact;
|
|||
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
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.layout.ArtifactRepositoryLayout;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
@ -56,7 +57,7 @@ public abstract class ArtifactComponentTestCase
|
|||
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||
"legacy" );
|
||||
|
||||
return (ArtifactRepository) new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout );
|
||||
return new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout );
|
||||
}
|
||||
|
||||
protected String getRepositoryLayout()
|
||||
|
@ -74,7 +75,7 @@ public abstract class ArtifactComponentTestCase
|
|||
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||
"legacy" );
|
||||
|
||||
return (ArtifactRepository) new DefaultArtifactRepository( "local", "file://" + f.getPath(), repoLayout );
|
||||
return new DefaultArtifactRepository( "local", "file://" + f.getPath(), repoLayout );
|
||||
}
|
||||
|
||||
protected ArtifactRepository remoteRepository()
|
||||
|
@ -87,9 +88,8 @@ public abstract class ArtifactComponentTestCase
|
|||
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||
"legacy" );
|
||||
|
||||
return (ArtifactRepository) new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout,
|
||||
ArtifactRepository.SNAPSHOT_POLICY_NEVER,
|
||||
ArtifactRepository.CHECKSUM_POLICY_WARN );
|
||||
return new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout,
|
||||
new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() );
|
||||
}
|
||||
|
||||
protected ArtifactRepository badRemoteRepository()
|
||||
|
@ -98,7 +98,7 @@ public abstract class ArtifactComponentTestCase
|
|||
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||
"legacy" );
|
||||
|
||||
return (ArtifactRepository) new DefaultArtifactRepository( "test", "http://foo.bar/repository", repoLayout );
|
||||
return new DefaultArtifactRepository( "test", "http://foo.bar/repository", repoLayout );
|
||||
}
|
||||
|
||||
protected void assertRemoteArtifactPresent( Artifact artifact )
|
||||
|
|
|
@ -24,6 +24,8 @@ import org.apache.maven.artifact.versioning.VersionRange;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Description of an artifact.
|
||||
|
@ -33,6 +35,12 @@ import java.util.List;
|
|||
public interface Artifact
|
||||
extends Comparable
|
||||
{
|
||||
String LATEST_VERSION = "LATEST";
|
||||
|
||||
String SNAPSHOT_VERSION = "SNAPSHOT";
|
||||
|
||||
Pattern VERSION_FILE_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$" );
|
||||
|
||||
// TODO: into scope handler
|
||||
String SCOPE_COMPILE = "compile";
|
||||
|
||||
|
@ -118,4 +126,6 @@ public interface Artifact
|
|||
void setGroupId( String groupId );
|
||||
|
||||
void setArtifactId( String artifactId );
|
||||
|
||||
boolean isSnapshot();
|
||||
}
|
|
@ -1,5 +1,21 @@
|
|||
package org.apache.maven.artifact;
|
||||
|
||||
/*
|
||||
* 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 java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -24,12 +40,14 @@ public final class ArtifactUtils
|
|||
|
||||
public static String artifactId( String groupId, String artifactId, String type, String version )
|
||||
{
|
||||
return artifactId( groupId, artifactId, type, version, null, version );
|
||||
return artifactId( groupId, artifactId, type, null, version );
|
||||
}
|
||||
|
||||
public static String artifactId( String groupId, String artifactId, String type, String version, String classifier, String baseVersion )
|
||||
public static String artifactId( String groupId, String artifactId, String type, String classifier,
|
||||
String baseVersion )
|
||||
{
|
||||
return groupId + ":" + artifactId + ":" + type + ( ( classifier != null ) ? ( ":" + classifier ) : ( "" ) ) + ":" + baseVersion;
|
||||
return groupId + ":" + artifactId + ":" + type + ( classifier != null ? ":" + classifier : "" ) + ":" +
|
||||
baseVersion;
|
||||
}
|
||||
|
||||
public static Map artifactMapByVersionlessId( Collection artifacts )
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||
|
@ -420,4 +421,18 @@ public class DefaultArtifact
|
|||
{
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
|
||||
public boolean isSnapshot()
|
||||
{
|
||||
Matcher m = VERSION_FILE_PATTERN.matcher( getBaseVersion() );
|
||||
if ( m.matches() )
|
||||
{
|
||||
setBaseVersion( m.group( 1 ) + "-" + SNAPSHOT_VERSION );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return getVersion().endsWith( SNAPSHOT_VERSION ) || getVersion().equals( LATEST_VERSION );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,11 +37,6 @@ public abstract class AbstractArtifactMetadata
|
|||
this.filename = filename;
|
||||
}
|
||||
|
||||
public void setArtifact( Artifact artifact )
|
||||
{
|
||||
this.artifact = artifact;
|
||||
}
|
||||
|
||||
public String getFilename()
|
||||
{
|
||||
return filename;
|
||||
|
@ -71,4 +66,5 @@ public abstract class AbstractArtifactMetadata
|
|||
{
|
||||
return artifact.getBaseVersion();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,14 +45,6 @@ public interface ArtifactMetadata
|
|||
*/
|
||||
String getFilename();
|
||||
|
||||
/**
|
||||
* Set the associated artifact.
|
||||
*
|
||||
* @param artifact the artifact
|
||||
* @todo prefer not to have this, and just modify the artifacts as they are transformed
|
||||
*/
|
||||
void setArtifact( Artifact artifact );
|
||||
|
||||
/**
|
||||
* Whether the artifact metadata exists.
|
||||
* @return true or false
|
||||
|
@ -71,4 +63,5 @@ public interface ArtifactMetadata
|
|||
String getVersion();
|
||||
|
||||
String getBaseVersion();
|
||||
|
||||
}
|
||||
|
|
|
@ -17,31 +17,17 @@ package org.apache.maven.artifact.repository;
|
|||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
|
||||
/**
|
||||
* TODO: describe
|
||||
* Specifies the repository used for artifact handling.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ArtifactRepository
|
||||
{
|
||||
String SNAPSHOT_POLICY_NEVER = "never";
|
||||
|
||||
String SNAPSHOT_POLICY_ALWAYS = "always";
|
||||
|
||||
String SNAPSHOT_POLICY_DAILY = "daily";
|
||||
|
||||
String SNAPSHOT_POLICY_INTERVAL = "interval";
|
||||
|
||||
String CHECKSUM_POLICY_FAIL = "fail";
|
||||
|
||||
String CHECKSUM_POLICY_WARN = "warn";
|
||||
|
||||
String CHECKSUM_ALGORITHM_SHA1 = "SHA-1";
|
||||
|
||||
String CHECKSUM_ALGORITHM_MD5 = "MD5";
|
||||
|
||||
String pathOf( Artifact artifact );
|
||||
|
||||
|
@ -55,13 +41,13 @@ public interface ArtifactRepository
|
|||
|
||||
String getBasedir();
|
||||
|
||||
String getSnapshotPolicy();
|
||||
|
||||
String getProtocol();
|
||||
|
||||
String getId();
|
||||
|
||||
String getChecksumPolicy();
|
||||
ArtifactRepositoryPolicy getSnapshots();
|
||||
|
||||
boolean failOnChecksumMismatch();
|
||||
ArtifactRepositoryPolicy getReleases();
|
||||
|
||||
ArtifactRepositoryLayout getLayout();
|
||||
}
|
||||
|
|
|
@ -23,14 +23,17 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
|||
*/
|
||||
public interface ArtifactRepositoryFactory
|
||||
{
|
||||
String ROLE = ArtifactRepositoryFactory.class.getName();
|
||||
|
||||
public static final String ROLE = ArtifactRepositoryFactory.class.getName();
|
||||
ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout );
|
||||
|
||||
public ArtifactRepository createArtifactRepository( String id, String url,
|
||||
ArtifactRepositoryLayout repositoryLayout,
|
||||
String snapshotPolicy, String checksumPolicy );
|
||||
ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout,
|
||||
ArtifactRepositoryPolicy snapshots,
|
||||
ArtifactRepositoryPolicy releases );
|
||||
|
||||
void setGlobalSnapshotPolicy( String snapshotPolicy );
|
||||
void setGlobalUpdatePolicy( String snapshotPolicy );
|
||||
|
||||
void setGlobalChecksumPolicy( String checksumPolicy );
|
||||
|
||||
void setGlobalEnable( boolean enable );
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package org.apache.maven.artifact.repository;/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Describes a set of policies for a repository to use under certain conditions.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ArtifactRepositoryPolicy
|
||||
{
|
||||
public static final String UPDATE_POLICY_NEVER = "never";
|
||||
|
||||
public static final String UPDATE_POLICY_ALWAYS = "always";
|
||||
|
||||
public static final String UPDATE_POLICY_DAILY = "daily";
|
||||
|
||||
public static final String UPDATE_POLICY_INTERVAL = "interval";
|
||||
|
||||
public static final String CHECKSUM_POLICY_FAIL = "fail";
|
||||
|
||||
public static final String CHECKSUM_POLICY_WARN = "warn";
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private String updatePolicy;
|
||||
|
||||
private String checksumPolicy;
|
||||
|
||||
public ArtifactRepositoryPolicy()
|
||||
{
|
||||
this( true, null, null );
|
||||
}
|
||||
|
||||
public ArtifactRepositoryPolicy( boolean enabled, String updatePolicy, String checksumPolicy )
|
||||
{
|
||||
this.enabled = enabled;
|
||||
|
||||
if ( updatePolicy == null )
|
||||
{
|
||||
updatePolicy = UPDATE_POLICY_DAILY;
|
||||
}
|
||||
this.updatePolicy = updatePolicy;
|
||||
|
||||
if ( checksumPolicy == null )
|
||||
{
|
||||
checksumPolicy = CHECKSUM_POLICY_WARN;
|
||||
}
|
||||
this.checksumPolicy = checksumPolicy;
|
||||
}
|
||||
|
||||
public void setEnabled( boolean enabled )
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setUpdatePolicy( String updatePolicy )
|
||||
{
|
||||
this.updatePolicy = updatePolicy;
|
||||
}
|
||||
|
||||
public void setChecksumPolicy( String checksumPolicy )
|
||||
{
|
||||
this.checksumPolicy = checksumPolicy;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public String getUpdatePolicy()
|
||||
{
|
||||
return updatePolicy;
|
||||
}
|
||||
|
||||
public String getChecksumPolicy()
|
||||
{
|
||||
return checksumPolicy;
|
||||
}
|
||||
}
|
|
@ -29,24 +29,24 @@ import java.util.List;
|
|||
*/
|
||||
public interface ArtifactTransformation
|
||||
{
|
||||
static String ROLE = ArtifactTransformation.class.getName();
|
||||
String ROLE = ArtifactTransformation.class.getName();
|
||||
|
||||
/**
|
||||
* Take in a artifact and return the transformed artifact for locating in the remote repository. If no
|
||||
* transformation has occured the original artifact is returned.
|
||||
*
|
||||
* @param artifact Artifact to be transformed.
|
||||
* @param artifact Artifact to be transformed.
|
||||
* @param remoteRepositories the repositories to check
|
||||
* @param localRepository the local repository
|
||||
* @param localRepository the local repository
|
||||
*/
|
||||
public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||
void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||
throws ArtifactMetadataRetrievalException;
|
||||
|
||||
/**
|
||||
* Take in a artifact and return the transformed artifact for locating in the local repository. If no
|
||||
* transformation has occured the original artifact is returned.
|
||||
*
|
||||
* @param artifact Artifact to be transformed.
|
||||
* @param artifact Artifact to be transformed.
|
||||
* @param localRepository the local repository it will be stored in
|
||||
*/
|
||||
void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
|
||||
|
@ -56,7 +56,7 @@ public interface ArtifactTransformation
|
|||
* Take in a artifact and return the transformed artifact for distributing toa remote repository. If no
|
||||
* transformation has occured the original artifact is returned.
|
||||
*
|
||||
* @param artifact Artifact to be transformed.
|
||||
* @param artifact Artifact to be transformed.
|
||||
* @param remoteRepository the repository to deploy to
|
||||
*/
|
||||
void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.maven.artifact.manager.WagonManager;
|
|||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
|
@ -401,27 +402,26 @@ public class MavenCli
|
|||
{
|
||||
settings.setOffline( true );
|
||||
|
||||
// TODO: this will still check to download if the artifact does not exist locally, instead of failing as it should in offline mode
|
||||
artifactRepositoryFactory.setGlobalSnapshotPolicy( ArtifactRepository.SNAPSHOT_POLICY_NEVER );
|
||||
artifactRepositoryFactory.setGlobalEnable( false );
|
||||
snapshotPolicySet = true;
|
||||
}
|
||||
|
||||
if ( !snapshotPolicySet && commandLine.hasOption( CLIManager.UPDATE_SNAPSHOTS ) )
|
||||
{
|
||||
artifactRepositoryFactory.setGlobalSnapshotPolicy( ArtifactRepository.SNAPSHOT_POLICY_ALWAYS );
|
||||
artifactRepositoryFactory.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
|
||||
}
|
||||
|
||||
if ( commandLine.hasOption( CLIManager.CHECKSUM_FAILURE_POLICY ) )
|
||||
{
|
||||
System.out.println( "+ Enabling strict checksum verification on all artifact downloads." );
|
||||
|
||||
artifactRepositoryFactory.setGlobalChecksumPolicy( ArtifactRepository.CHECKSUM_POLICY_FAIL );
|
||||
artifactRepositoryFactory.setGlobalChecksumPolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
|
||||
}
|
||||
else if ( commandLine.hasOption( CLIManager.CHECKSUM_WARNING_POLICY ) )
|
||||
{
|
||||
System.out.println( "+ Disabling strict checksum verification on all artifact downloads." );
|
||||
|
||||
artifactRepositoryFactory.setGlobalChecksumPolicy( ArtifactRepository.CHECKSUM_POLICY_WARN );
|
||||
artifactRepositoryFactory.setGlobalChecksumPolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
|
||||
}
|
||||
|
||||
return localRepository;
|
||||
|
|
|
@ -158,7 +158,7 @@ public class DefaultPluginVersionManager
|
|||
{
|
||||
// 1. resolve the version to be used
|
||||
version = resolveMetaVersion( groupId, artifactId, project.getPluginArtifactRepositories(), localRepository,
|
||||
LatestArtifactTransformation.LATEST_VERSION );
|
||||
Artifact.LATEST_VERSION );
|
||||
|
||||
if ( version != null )
|
||||
{
|
||||
|
|
|
@ -28,10 +28,8 @@
|
|||
<p>This is a reference for the Maven project descriptor used in Maven.</p>
|
||||
<p>An XSD is available at:</p>
|
||||
<ul>
|
||||
<li><a href="http://maven.apache.org/maven-v3_0_0.xsd">http://maven.apache.org/maven-v3_0_0.xsd</a> for Maven 1.1
|
||||
.</li>
|
||||
<li><a href="http://maven.apache.org/maven-v4_0_0.xsd">http://maven.apache.org/maven-v4_0_0.xsd</a> for Maven 2.0
|
||||
.</li>
|
||||
<li><a href="http://maven.apache.org/maven-v3_0_0.xsd">http://maven.apache.org/maven-v3_0_0.xsd</a> for Maven 1.1.</li>
|
||||
<li><a href="http://maven.apache.org/maven-v4_0_0.xsd">http://maven.apache.org/maven-v4_0_0.xsd</a> for Maven 2.0.</li>
|
||||
</ul>
|
||||
]]></description>
|
||||
<defaults>
|
||||
|
@ -1415,7 +1413,17 @@
|
|||
generated by the project
|
||||
]]></description>
|
||||
<association>
|
||||
<type>Repository</type>
|
||||
<type>RepositoryBase</type>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>snapshotRepository</name>
|
||||
<version>4.0.0</version>
|
||||
<description>
|
||||
Where to deploy snapshots of artifacts to. If not given, it defaults to the repository.
|
||||
</description>
|
||||
<association>
|
||||
<type>RepositoryBase</type>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
|
@ -1974,7 +1982,7 @@
|
|||
</class>
|
||||
|
||||
<class>
|
||||
<name>Repository</name>
|
||||
<name>RepositoryBase</name>
|
||||
<version>4.0.0</version>
|
||||
<description><![CDATA[
|
||||
Repository contains the information needed
|
||||
|
@ -2005,16 +2013,6 @@
|
|||
]]></description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>snapshotPolicy</name>
|
||||
<version>4.0.0</version>
|
||||
<description>
|
||||
The policy for downloading snapshots - can be "always", "daily" (default), "interval:XXX" (in minutes) or
|
||||
"never".
|
||||
</description>
|
||||
<type>String</type>
|
||||
<defaultValue>daily</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>layout</name>
|
||||
<version>4.0.0</version>
|
||||
|
@ -2023,14 +2021,6 @@
|
|||
<type>String</type>
|
||||
<defaultValue>default</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>checksumPolicy</name>
|
||||
<version>4.0.0</version>
|
||||
<description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are
|
||||
"fail" or "warn"</description>
|
||||
<type>String</type>
|
||||
<defaultValue>warn</defaultValue>
|
||||
</field>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
|
@ -2038,7 +2028,7 @@
|
|||
<code><![CDATA[
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
Repository other = ( Repository ) obj;
|
||||
RepositoryBase other = (RepositoryBase) obj;
|
||||
|
||||
boolean retValue = false;
|
||||
|
||||
|
@ -2053,6 +2043,95 @@
|
|||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<name>Repository</name>
|
||||
<superClass>RepositoryBase</superClass>
|
||||
<version>4.0.0</version>
|
||||
<description>
|
||||
Repository contains the information needed for establishing connections with remote repoistory
|
||||
</description>
|
||||
<fields>
|
||||
<!-- TODO: deprecated -->
|
||||
<field>
|
||||
<name>snapshotPolicy</name>
|
||||
<version>4.0.0</version>
|
||||
<description>
|
||||
The policy for downloading snapshots - can be "always", "daily" (default), "interval:XXX" (in minutes) or
|
||||
"never" (repository is not checked, even if the snapshot is not present locally).
|
||||
</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<!-- TODO: deprecated -->
|
||||
<field>
|
||||
<name>checksumPolicy</name>
|
||||
<version>4.0.0</version>
|
||||
<description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are
|
||||
"fail" or "warn"</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>releases</name>
|
||||
<version>4.0.0</version>
|
||||
<description>How to handle downloading of releases from this repository</description>
|
||||
<association>
|
||||
<type>RepositoryPolicy</type>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>snapshots</name>
|
||||
<version>4.0.0</version>
|
||||
<description>How to handle downloading of snapshots from this repository</description>
|
||||
<association>
|
||||
<type>RepositoryPolicy</type>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
<!-- prevent modello generation of an incorrect equals method. Could be avoided by using <identity/> tags to mark ID as the only identity field -->
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
<version>4.0.0</version>
|
||||
<code><![CDATA[
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
return super.equals( obj );
|
||||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<name>RepositoryPolicy</name>
|
||||
<version>4.0.0</version>
|
||||
<description>Download policy</description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>enabled</name>
|
||||
<version>4.0.0</version>
|
||||
<description>Whether to use this repository for downloading this type of artifact</description>
|
||||
<type>boolean</type>
|
||||
<defaultValue>true</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>updatePolicy</name>
|
||||
<version>4.0.0</version>
|
||||
<description>
|
||||
The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or
|
||||
"never" (only if it doesn't exist locally).
|
||||
</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>checksumPolicy</name>
|
||||
<version>4.0.0</version>
|
||||
<description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are
|
||||
"fail" or "warn"</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
||||
<!--@todo find better solution for management of site deployments -->
|
||||
<class>
|
||||
<name>Site</name>
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* Deploys an artifact to remote repository.
|
||||
*
|
||||
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @author <a href="mailto:jdcasey@apache.org">John Casey (refactoring only)</a>
|
||||
* @version $Id$
|
||||
|
@ -105,17 +106,17 @@ public class DeployMojo
|
|||
private List attachedArtifacts;
|
||||
|
||||
/**
|
||||
* @parameter expression="${updateReleaseInfo}"
|
||||
* @parameter expression="${updateReleaseInfo}" default-value="false"
|
||||
*/
|
||||
private boolean updateReleaseInfo = false;
|
||||
private boolean updateReleaseInfo;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
if ( deploymentRepository == null )
|
||||
{
|
||||
String msg = "Deployment failed: repository element was not specified in the pom inside"
|
||||
+ " distributionManagement element";
|
||||
String msg = "Deployment failed: repository element was not specified in the pom inside" +
|
||||
" distributionManagement element";
|
||||
throw new MojoExecutionException( msg );
|
||||
}
|
||||
|
||||
|
@ -151,7 +152,7 @@ public class DeployMojo
|
|||
Artifact attached = (Artifact) i.next();
|
||||
deployer.deploy( attached.getFile(), attached, deploymentRepository, localRepository );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( ArtifactDeploymentException e )
|
||||
{
|
||||
// TODO: deployment exception that does not give a trace
|
||||
|
|
|
@ -39,7 +39,8 @@ public class PluginMappingDeployMojo
|
|||
|
||||
if ( distributionRepository == null )
|
||||
{
|
||||
throw new MojoExecutionException( "No distribution repository specified. You must specify a <distributionManagement/> section with a valid <repository/> specified within." );
|
||||
throw new MojoExecutionException(
|
||||
"No distribution repository specified. You must specify a <distributionManagement/> section with a valid <repository/> specified within." );
|
||||
}
|
||||
|
||||
try
|
||||
|
|
|
@ -71,6 +71,11 @@
|
|||
<url>http://www.apache.org/</url>
|
||||
</organization>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>central-plugins-snapshots</id>
|
||||
<name>Maven Central Plugins Development Repository</name>
|
||||
<url>scp://repo1.maven.org/home/projects/maven/repository-staging/snapshots/maven2/plugins</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>central-plugins</id>
|
||||
<name>Maven Central Plugins Repository</name>
|
||||
|
@ -83,11 +88,18 @@
|
|||
</distributionManagement>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central-plugins</id>
|
||||
<name>Maven Central Plugins Repository</name>
|
||||
<url>http://repo1.maven.org/maven2/plugins</url>
|
||||
<id>snapshots</id>
|
||||
<name>Maven Central Development Repository</name>
|
||||
<url>http://snapshots.maven.codehaus.org/maven2</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>snapshots</id>
|
||||
<name>Maven Central Plugins Development Repository</name>
|
||||
<url>http://snapshots.maven.codehaus.org/maven2/plugins</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<modules>
|
||||
<module>maven-ant-plugin</module>
|
||||
<module>maven-assembly-plugin</module>
|
||||
|
|
|
@ -132,8 +132,10 @@
|
|||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
||||
<!-- TODO: reproduced from maven-model/maven.mdo, instead should inherit code and link to external docs -->
|
||||
<class>
|
||||
<name>Repository</name>
|
||||
<name>RepositoryBase</name>
|
||||
<version>1.0.0</version>
|
||||
<description><![CDATA[
|
||||
Repository contains the information needed
|
||||
|
@ -164,31 +166,14 @@
|
|||
]]></description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>snapshotPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>The policy for downloading snapshots - can be "always",
|
||||
"daily" (default), "interval:XXX" (in minutes) or "never".
|
||||
</description>
|
||||
<type>String</type>
|
||||
<defaultValue>daily</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>layout</name>
|
||||
<version>1.0.0</version>
|
||||
<description>The type of layout this repository uses for locating and
|
||||
storing artifacts - can be "legacy" or "default".</description>
|
||||
<description>The type of layout this repository uses for locating and storing artifacts - can be "legacy" or
|
||||
"default".</description>
|
||||
<type>String</type>
|
||||
<defaultValue>default</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>checksumPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are
|
||||
"fail" or "warn"</description>
|
||||
<type>String</type>
|
||||
<defaultValue>warn</defaultValue>
|
||||
</field>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
|
@ -196,7 +181,7 @@
|
|||
<code><![CDATA[
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
Repository other = ( Repository ) obj;
|
||||
RepositoryBase other = (RepositoryBase) obj;
|
||||
|
||||
boolean retValue = false;
|
||||
|
||||
|
@ -211,6 +196,95 @@
|
|||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<name>Repository</name>
|
||||
<superClass>RepositoryBase</superClass>
|
||||
<version>1.0.0</version>
|
||||
<description>
|
||||
Repository contains the information needed for establishing connections with remote repoistory
|
||||
</description>
|
||||
<fields>
|
||||
<!-- TODO: deprecated -->
|
||||
<field>
|
||||
<name>snapshotPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>
|
||||
The policy for downloading snapshots - can be "always", "daily" (default), "interval:XXX" (in minutes) or
|
||||
"never" (repository is not checked, even if the snapshot is not present locally).
|
||||
</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<!-- TODO: deprecated -->
|
||||
<field>
|
||||
<name>checksumPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are
|
||||
"fail" or "warn"</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>releases</name>
|
||||
<version>1.0.0</version>
|
||||
<description>How to handle downloading of releases from this repository</description>
|
||||
<association>
|
||||
<type>RepositoryPolicy</type>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>snapshots</name>
|
||||
<version>1.0.0</version>
|
||||
<description>How to handle downloading of snapshots from this repository</description>
|
||||
<association>
|
||||
<type>RepositoryPolicy</type>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
<!-- prevent modello generation of an incorrect equals method. Could be avoided by using <identity/> tags to mark ID as the only identity field -->
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
<version>1.0.0</version>
|
||||
<code><![CDATA[
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
return super.equals( obj );
|
||||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<name>RepositoryPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>Download policy</description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>enabled</name>
|
||||
<version>1.0.0</version>
|
||||
<description>Whether to use this repository for downloading this type of artifact</description>
|
||||
<type>boolean</type>
|
||||
<defaultValue>true</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>updatePolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>
|
||||
The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or
|
||||
"never" (only if it doesn't exist locally).
|
||||
</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>checksumPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are
|
||||
"fail" or "warn"</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<name>ActivationProperty</name>
|
||||
<version>1.0.0</version>
|
||||
|
|
|
@ -102,7 +102,25 @@ public class ProfilesConversionUtils
|
|||
repo.setChecksumPolicy( profileXmlRepo.getChecksumPolicy() );
|
||||
repo.setUrl( profileXmlRepo.getUrl() );
|
||||
|
||||
if ( profileXmlRepo.getSnapshots() != null )
|
||||
{
|
||||
repo.setSnapshots( convertRepositoryPolicy( profileXmlRepo.getSnapshots() ) );
|
||||
}
|
||||
if ( profileXmlRepo.getReleases() != null )
|
||||
{
|
||||
repo.setReleases( convertRepositoryPolicy( profileXmlRepo.getReleases() ) );
|
||||
}
|
||||
|
||||
return repo;
|
||||
}
|
||||
|
||||
private static org.apache.maven.model.RepositoryPolicy convertRepositoryPolicy( RepositoryPolicy profileXmlRepo )
|
||||
{
|
||||
org.apache.maven.model.RepositoryPolicy policy = new org.apache.maven.model.RepositoryPolicy();
|
||||
policy.setEnabled( profileXmlRepo.isEnabled() );
|
||||
policy.setUpdatePolicy( profileXmlRepo.getUpdatePolicy() );
|
||||
policy.setChecksumPolicy( profileXmlRepo.getChecksumPolicy() );
|
||||
return policy;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -308,6 +308,7 @@ public class DefaultMavenProjectBuilder
|
|||
{
|
||||
Model superModel = getSuperModel();
|
||||
|
||||
//noinspection CollectionDeclaredAsConcreteClass
|
||||
LinkedList lineage = new LinkedList();
|
||||
|
||||
Set aggregatedRemoteWagonRepositories = new HashSet();
|
||||
|
@ -434,8 +435,16 @@ public class DefaultMavenProjectBuilder
|
|||
DistributionManagement dm = model.getDistributionManagement();
|
||||
if ( dm != null )
|
||||
{
|
||||
project.setDistributionManagementArtifactRepository(
|
||||
ProjectUtils.buildArtifactRepository( dm.getRepository(), artifactRepositoryFactory, container ) );
|
||||
ArtifactRepository repo = ProjectUtils.buildArtifactRepositoryBase( dm.getRepository(),
|
||||
artifactRepositoryFactory, container );
|
||||
project.setReleaseArtifactRepository( repo );
|
||||
|
||||
if ( dm.getSnapshotRepository() != null )
|
||||
{
|
||||
repo = ProjectUtils.buildArtifactRepositoryBase( dm.getSnapshotRepository(), artifactRepositoryFactory,
|
||||
container );
|
||||
project.setSnapshotArtifactRepository( repo );
|
||||
}
|
||||
}
|
||||
|
||||
project.setParent( parentProject );
|
||||
|
@ -464,6 +473,7 @@ public class DefaultMavenProjectBuilder
|
|||
return project;
|
||||
}
|
||||
|
||||
/** @noinspection CollectionDeclaredAsConcreteClass*/
|
||||
private MavenProject assembleLineage( Model model, LinkedList lineage, List aggregatedRemoteWagonRepositories,
|
||||
ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException
|
||||
|
|
|
@ -100,7 +100,9 @@ public class MavenProject
|
|||
|
||||
private List pluginArtifactRepositories;
|
||||
|
||||
private ArtifactRepository distMgmtArtifactRepository;
|
||||
private ArtifactRepository releaseArtifactRepository;
|
||||
|
||||
private ArtifactRepository snapshotArtifactRepository;
|
||||
|
||||
private List activeProfiles = new ArrayList();
|
||||
|
||||
|
@ -957,14 +959,9 @@ public class MavenProject
|
|||
return pluginArtifactRepositories;
|
||||
}
|
||||
|
||||
public void setDistributionManagementArtifactRepository( ArtifactRepository distMgmtArtifactRepository )
|
||||
{
|
||||
this.distMgmtArtifactRepository = distMgmtArtifactRepository;
|
||||
}
|
||||
|
||||
public ArtifactRepository getDistributionManagementArtifactRepository()
|
||||
{
|
||||
return distMgmtArtifactRepository;
|
||||
return getArtifact().isSnapshot() ? snapshotArtifactRepository : releaseArtifactRepository;
|
||||
}
|
||||
|
||||
public List getPluginRepositories()
|
||||
|
@ -1152,6 +1149,16 @@ public class MavenProject
|
|||
this.dependencyArtifacts = dependencyArtifacts;
|
||||
}
|
||||
|
||||
public void setReleaseArtifactRepository( ArtifactRepository releaseArtifactRepository )
|
||||
{
|
||||
this.releaseArtifactRepository = releaseArtifactRepository;
|
||||
}
|
||||
|
||||
public void setSnapshotArtifactRepository( ArtifactRepository snapshotArtifactRepository )
|
||||
{
|
||||
this.snapshotArtifactRepository = snapshotArtifactRepository;
|
||||
}
|
||||
|
||||
public void setOriginalModel( Model originalModel )
|
||||
{
|
||||
this.originalModel = originalModel;
|
||||
|
@ -1184,5 +1191,4 @@ public class MavenProject
|
|||
{
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,11 @@ package org.apache.maven.project;
|
|||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.RepositoryBase;
|
||||
import org.apache.maven.model.RepositoryPolicy;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
|
||||
|
@ -56,6 +59,27 @@ public final class ProjectUtils
|
|||
return repos;
|
||||
}
|
||||
|
||||
public static ArtifactRepository buildArtifactRepositoryBase( RepositoryBase repo,
|
||||
ArtifactRepositoryFactory artifactRepositoryFactory,
|
||||
PlexusContainer container )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( repo != null )
|
||||
{
|
||||
String id = repo.getId();
|
||||
String url = repo.getUrl();
|
||||
|
||||
// TODO: make this a map inside the factory instead, so no lookup needed
|
||||
ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container );
|
||||
|
||||
return artifactRepositoryFactory.createArtifactRepository( id, url, layout );
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ArtifactRepository buildArtifactRepository( Repository repo,
|
||||
ArtifactRepositoryFactory artifactRepositoryFactory,
|
||||
PlexusContainer container )
|
||||
|
@ -65,14 +89,18 @@ public final class ProjectUtils
|
|||
{
|
||||
String id = repo.getId();
|
||||
String url = repo.getUrl();
|
||||
String snapshotPolicy = repo.getSnapshotPolicy();
|
||||
String checksumPolicy = repo.getChecksumPolicy();
|
||||
|
||||
// TODO: make this a map inside the factory instead, so no lookup needed
|
||||
ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container );
|
||||
|
||||
return artifactRepositoryFactory.createArtifactRepository( id, url, layout, snapshotPolicy,
|
||||
checksumPolicy );
|
||||
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots(),
|
||||
repo.getSnapshotPolicy(),
|
||||
repo.getChecksumPolicy() );
|
||||
ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases(),
|
||||
repo.getSnapshotPolicy(),
|
||||
repo.getChecksumPolicy() );
|
||||
|
||||
return artifactRepositoryFactory.createArtifactRepository( id, url, layout, snapshots, releases );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -80,21 +108,44 @@ public final class ProjectUtils
|
|||
}
|
||||
}
|
||||
|
||||
private static ArtifactRepositoryLayout getRepositoryLayout( Repository mavenRepo, PlexusContainer container )
|
||||
private static ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( RepositoryPolicy policy,
|
||||
String defaultUpdatePolicy,
|
||||
String defaultChecksumPolicy )
|
||||
{
|
||||
boolean enabled = true;
|
||||
String updatePolicy = defaultUpdatePolicy;
|
||||
String checksumPolicy = defaultChecksumPolicy;
|
||||
|
||||
if ( policy != null )
|
||||
{
|
||||
enabled = policy.isEnabled();
|
||||
if ( policy.getUpdatePolicy() != null )
|
||||
{
|
||||
updatePolicy = policy.getUpdatePolicy();
|
||||
}
|
||||
if ( policy.getChecksumPolicy() != null )
|
||||
{
|
||||
checksumPolicy = policy.getChecksumPolicy();
|
||||
}
|
||||
}
|
||||
|
||||
return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy );
|
||||
}
|
||||
|
||||
private static ArtifactRepositoryLayout getRepositoryLayout( RepositoryBase mavenRepo, PlexusContainer container )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
String layout = mavenRepo.getLayout();
|
||||
|
||||
ArtifactRepositoryLayout repositoryLayout = null;
|
||||
ArtifactRepositoryLayout repositoryLayout;
|
||||
try
|
||||
{
|
||||
repositoryLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, layout );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new ProjectBuildingException(
|
||||
"Cannot find layout implementation corresponding to: \'" + layout +
|
||||
"\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e );
|
||||
throw new ProjectBuildingException( "Cannot find layout implementation corresponding to: \'" + layout +
|
||||
"\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e );
|
||||
}
|
||||
return repositoryLayout;
|
||||
}
|
||||
|
|
|
@ -581,6 +581,22 @@ public class DefaultModelInheritanceAssembler
|
|||
repository.setUrl( parentDistMgmt.getRepository().getUrl() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( childDistMgmt.getSnapshotRepository() == null )
|
||||
{
|
||||
if ( parentDistMgmt.getSnapshotRepository() != null )
|
||||
{
|
||||
Repository repository = new Repository();
|
||||
|
||||
childDistMgmt.setSnapshotRepository( repository );
|
||||
|
||||
repository.setId( parentDistMgmt.getSnapshotRepository().getId() );
|
||||
|
||||
repository.setName( parentDistMgmt.getSnapshotRepository().getName() );
|
||||
|
||||
repository.setUrl( parentDistMgmt.getSnapshotRepository().getUrl() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -579,8 +579,10 @@
|
|||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
||||
<!-- TODO: reproduced from maven-model/maven.mdo, instead should inherit code and link to external docs -->
|
||||
<class>
|
||||
<name>Repository</name>
|
||||
<name>RepositoryBase</name>
|
||||
<version>1.0.0</version>
|
||||
<description><![CDATA[
|
||||
Repository contains the information needed
|
||||
|
@ -611,30 +613,14 @@
|
|||
]]></description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>snapshotPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description> The policy for downloading snapshots - can be "always",
|
||||
"daily" (default), "interval:XXX" (in minutes) or "never".
|
||||
</description>
|
||||
<type>String</type>
|
||||
<defaultValue>daily</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>layout</name>
|
||||
<version>1.0.0</version>
|
||||
<description>The type of layout this repository uses for locating and
|
||||
storing artifacts - can be "legacy" or "default".</description>
|
||||
<description>The type of layout this repository uses for locating and storing artifacts - can be "legacy" or
|
||||
"default".</description>
|
||||
<type>String</type>
|
||||
<defaultValue>default</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>checksumPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are "fail" or "warn"</description>
|
||||
<type>String</type>
|
||||
<defaultValue>warn</defaultValue>
|
||||
</field>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
|
@ -642,7 +628,7 @@
|
|||
<code><![CDATA[
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
Repository other = ( Repository ) obj;
|
||||
RepositoryBase other = (RepositoryBase) obj;
|
||||
|
||||
boolean retValue = false;
|
||||
|
||||
|
@ -657,6 +643,95 @@
|
|||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<name>Repository</name>
|
||||
<superClass>RepositoryBase</superClass>
|
||||
<version>1.0.0</version>
|
||||
<description>
|
||||
Repository contains the information needed for establishing connections with remote repoistory
|
||||
</description>
|
||||
<fields>
|
||||
<!-- TODO: deprecated -->
|
||||
<field>
|
||||
<name>snapshotPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>
|
||||
The policy for downloading snapshots - can be "always", "daily" (default), "interval:XXX" (in minutes) or
|
||||
"never" (repository is not checked, even if the snapshot is not present locally).
|
||||
</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<!-- TODO: deprecated -->
|
||||
<field>
|
||||
<name>checksumPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are
|
||||
"fail" or "warn"</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>releases</name>
|
||||
<version>1.0.0</version>
|
||||
<description>How to handle downloading of releases from this repository</description>
|
||||
<association>
|
||||
<type>RepositoryPolicy</type>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>snapshots</name>
|
||||
<version>1.0.0</version>
|
||||
<description>How to handle downloading of snapshots from this repository</description>
|
||||
<association>
|
||||
<type>RepositoryPolicy</type>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
<!-- prevent modello generation of an incorrect equals method. Could be avoided by using <identity/> tags to mark ID as the only identity field -->
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
<version>1.0.0</version>
|
||||
<code><![CDATA[
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
return super.equals( obj );
|
||||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<name>RepositoryPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>Download policy</description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>enabled</name>
|
||||
<version>1.0.0</version>
|
||||
<description>Whether to use this repository for downloading this type of artifact</description>
|
||||
<type>boolean</type>
|
||||
<defaultValue>true</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>updatePolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>
|
||||
The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or
|
||||
"never" (only if it doesn't exist locally).
|
||||
</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>checksumPolicy</name>
|
||||
<version>1.0.0</version>
|
||||
<description>What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are
|
||||
"fail" or "warn"</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<name>ActivationProperty</name>
|
||||
<version>1.0.0</version>
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
package org.apache.maven.settings;
|
||||
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
|
@ -24,9 +16,16 @@ import java.util.Map;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class SettingsUtils
|
||||
{
|
||||
|
||||
private SettingsUtils()
|
||||
{
|
||||
// don't allow construction.
|
||||
|
@ -68,9 +67,9 @@ public final class SettingsUtils
|
|||
List dominantPluginGroupIds = dominant.getPluginGroups();
|
||||
List recessivePluginGroupIds = recessive.getPluginGroups();
|
||||
|
||||
if( recessivePluginGroupIds != null )
|
||||
if ( recessivePluginGroupIds != null )
|
||||
{
|
||||
if( dominantPluginGroupIds == null )
|
||||
if ( dominantPluginGroupIds == null )
|
||||
{
|
||||
dominantPluginGroupIds = new ArrayList();
|
||||
dominant.setPluginGroups( dominantPluginGroupIds );
|
||||
|
@ -142,7 +141,7 @@ public final class SettingsUtils
|
|||
|
||||
profile.setSource( "settings.xml" );
|
||||
|
||||
org.apache.maven.settings.Activation settingsActivation = settingsProfile.getActivation();
|
||||
Activation settingsActivation = settingsProfile.getActivation();
|
||||
|
||||
if ( settingsActivation != null )
|
||||
{
|
||||
|
@ -150,7 +149,7 @@ public final class SettingsUtils
|
|||
|
||||
activation.setJdk( settingsActivation.getJdk() );
|
||||
|
||||
org.apache.maven.settings.ActivationProperty settingsProp = settingsActivation.getProperty();
|
||||
ActivationProperty settingsProp = settingsActivation.getProperty();
|
||||
|
||||
if ( settingsProp != null )
|
||||
{
|
||||
|
@ -197,7 +196,25 @@ public final class SettingsUtils
|
|||
repo.setChecksumPolicy( settingsRepo.getChecksumPolicy() );
|
||||
repo.setUrl( settingsRepo.getUrl() );
|
||||
|
||||
if ( settingsRepo.getSnapshots() != null )
|
||||
{
|
||||
repo.setSnapshots( convertRepositoryPolicy( settingsRepo.getSnapshots() ) );
|
||||
}
|
||||
if ( settingsRepo.getReleases() != null )
|
||||
{
|
||||
repo.setReleases( convertRepositoryPolicy( settingsRepo.getReleases() ) );
|
||||
}
|
||||
|
||||
return repo;
|
||||
}
|
||||
|
||||
private static org.apache.maven.model.RepositoryPolicy convertRepositoryPolicy( RepositoryPolicy settingsPolicy )
|
||||
{
|
||||
org.apache.maven.model.RepositoryPolicy policy = new org.apache.maven.model.RepositoryPolicy();
|
||||
policy.setEnabled( settingsPolicy.isEnabled() );
|
||||
policy.setUpdatePolicy( settingsPolicy.getUpdatePolicy() );
|
||||
policy.setChecksumPolicy( settingsPolicy.getChecksumPolicy() );
|
||||
return policy;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
23
pom.xml
23
pom.xml
|
@ -105,17 +105,32 @@
|
|||
<repository>
|
||||
<id>repo1</id>
|
||||
<name>Maven Central Repository</name>
|
||||
<!-- Waiting for release files to be mirror
|
||||
<url>scp://repo1.maven.org/home/projects/maven/repository-staging/to-ibiblio/maven</url>
|
||||
<layout>legacy</layout>
|
||||
-->
|
||||
<url>scp://repo1.maven.org/home/projects/maven/repository-staging/to-ibiblio/maven2</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>snapshots</id>
|
||||
<name>Maven Central Development Repository</name>
|
||||
<url>scp://repo1.maven.org/home/projects/maven/repository-staging/snapshots/maven2</url>
|
||||
</snapshotRepository>
|
||||
<site>
|
||||
<id>website</id>
|
||||
<url>scp://minotaur.apache.org/www/maven.apache.org/maven2/</url>
|
||||
</site>
|
||||
</distributionManagement>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>snapshots</id>
|
||||
<name>Maven Central Development Repository</name>
|
||||
<url>http://snapshots.maven.codehaus.org/maven2</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>snapshots</id>
|
||||
<name>Maven Central Plugins Development Repository</name>
|
||||
<url>http://snapshots.maven.codehaus.org/maven2/plugins</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<modules>
|
||||
<!-- module>maven-archetype</module -->
|
||||
<module>maven-archiver</module>
|
||||
|
|
Loading…
Reference in New Issue