mirror of https://github.com/apache/maven.git
PR: MNG-922
allow the disablement of timestamping snapshots, reusing the same file in the remote repo git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@293570 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3bcde49fca
commit
ba94b208d7
|
@ -38,8 +38,10 @@ public class DefaultArtifactRepository
|
|||
|
||||
private ArtifactRepositoryPolicy releases;
|
||||
|
||||
private boolean uniqueVersion;
|
||||
|
||||
/**
|
||||
* Create a local repository or a deployment repository.
|
||||
* Create a local repository or a test repository.
|
||||
*
|
||||
* @param id the unique identifier of the repository
|
||||
* @param url the URL of the repository
|
||||
|
@ -50,6 +52,21 @@ public class DefaultArtifactRepository
|
|||
this( id, url, layout, null, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a remote deployment repository.
|
||||
*
|
||||
* @param id the unique identifier of the repository
|
||||
* @param url the URL of the repository
|
||||
* @param layout the layout of the repository
|
||||
* @param uniqueVersion whether to assign each snapshot a unique version
|
||||
*/
|
||||
public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion )
|
||||
{
|
||||
super( id, url );
|
||||
this.layout = layout;
|
||||
this.uniqueVersion = uniqueVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a remote download repository.
|
||||
*
|
||||
|
@ -117,4 +134,9 @@ public class DefaultArtifactRepository
|
|||
{
|
||||
return getId();
|
||||
}
|
||||
|
||||
public boolean isUniqueVersion()
|
||||
{
|
||||
return uniqueVersion;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ public class DefaultArtifactRepositoryFactory
|
|||
|
||||
private String globalChecksumPolicy;
|
||||
|
||||
public ArtifactRepository createArtifactRepository( String id, String url,
|
||||
ArtifactRepositoryLayout repositoryLayout )
|
||||
public ArtifactRepository createDeploymentArtifactRepository( String id, String url,
|
||||
ArtifactRepositoryLayout repositoryLayout, boolean uniqueVersion )
|
||||
{
|
||||
return new DefaultArtifactRepository( id, url, repositoryLayout );
|
||||
return new DefaultArtifactRepository( id, url, repositoryLayout, uniqueVersion );
|
||||
}
|
||||
|
||||
public ArtifactRepository createArtifactRepository( String id, String url,
|
||||
|
|
|
@ -77,10 +77,15 @@ public class SnapshotTransformation
|
|||
{
|
||||
if ( artifact.isSnapshot() )
|
||||
{
|
||||
Snapshot snapshot = new Snapshot();
|
||||
if ( remoteRepository.isUniqueVersion() )
|
||||
{
|
||||
snapshot.setTimestamp( getDeploymentTimestamp() );
|
||||
}
|
||||
|
||||
// we update the build number anyway so that it doesn't get lost. It requires the timestamp to take effect
|
||||
int buildNumber = resolveLatestSnapshotBuildNumber( artifact, localRepository, remoteRepository );
|
||||
|
||||
Snapshot snapshot = new Snapshot();
|
||||
snapshot.setTimestamp( getDeploymentTimestamp() );
|
||||
snapshot.setBuildNumber( buildNumber + 1 );
|
||||
|
||||
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );
|
||||
|
|
|
@ -49,4 +49,6 @@ public interface ArtifactRepository
|
|||
ArtifactRepositoryLayout getLayout();
|
||||
|
||||
String getKey();
|
||||
|
||||
boolean isUniqueVersion();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,8 @@ public interface ArtifactRepositoryFactory
|
|||
{
|
||||
String ROLE = ArtifactRepositoryFactory.class.getName();
|
||||
|
||||
ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout );
|
||||
ArtifactRepository createDeploymentArtifactRepository( String id, String url, ArtifactRepositoryLayout layout,
|
||||
boolean uniqueVersion );
|
||||
|
||||
ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout,
|
||||
ArtifactRepositoryPolicy snapshots,
|
||||
|
@ -34,5 +35,4 @@ public interface ArtifactRepositoryFactory
|
|||
void setGlobalUpdatePolicy( String snapshotPolicy );
|
||||
|
||||
void setGlobalChecksumPolicy( String checksumPolicy );
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1530,7 +1530,7 @@
|
|||
generated by the project
|
||||
]]></description>
|
||||
<association>
|
||||
<type>RepositoryBase</type>
|
||||
<type>DeploymentRepository</type>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
|
@ -1540,7 +1540,7 @@
|
|||
Where to deploy snapshots of artifacts to. If not given, it defaults to the repository.
|
||||
</description>
|
||||
<association>
|
||||
<type>RepositoryBase</type>
|
||||
<type>DeploymentRepository</type>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
|
@ -2242,6 +2242,36 @@
|
|||
</codeSegments>
|
||||
</class>
|
||||
|
||||
<class>
|
||||
<name>DeploymentRepository</name>
|
||||
<superClass>RepositoryBase</superClass>
|
||||
<version>4.0.0</version>
|
||||
<description>
|
||||
Repository contains the information needed for deploying to the remote repoistory
|
||||
</description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>uniqueVersion</name>
|
||||
<description>Whether to assign snapshots a unique version comprised of the timestamp and build number, or to use the same version each time</description>
|
||||
<type>boolean</type>
|
||||
<defaultValue>true</defaultValue>
|
||||
<version>4.0.0</version>
|
||||
</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>
|
||||
|
|
|
@ -632,14 +632,15 @@ public class DefaultMavenProjectBuilder
|
|||
DistributionManagement dm = model.getDistributionManagement();
|
||||
if ( dm != null )
|
||||
{
|
||||
ArtifactRepository repo = ProjectUtils.buildArtifactRepositoryBase( dm.getRepository(),
|
||||
artifactRepositoryFactory, container );
|
||||
ArtifactRepository repo = ProjectUtils.buildDeploymentArtifactRepository( dm.getRepository(),
|
||||
artifactRepositoryFactory,
|
||||
container );
|
||||
project.setReleaseArtifactRepository( repo );
|
||||
|
||||
if ( dm.getSnapshotRepository() != null )
|
||||
{
|
||||
repo = ProjectUtils.buildArtifactRepositoryBase( dm.getSnapshotRepository(), artifactRepositoryFactory,
|
||||
container );
|
||||
repo = ProjectUtils.buildDeploymentArtifactRepository( dm.getSnapshotRepository(),
|
||||
artifactRepositoryFactory, container );
|
||||
project.setSnapshotArtifactRepository( repo );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.maven.model.RepositoryBase;
|
|||
import org.apache.maven.model.RepositoryPolicy;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.apache.maven.model.Site;
|
||||
import org.apache.maven.model.DeploymentRepository;
|
||||
import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler;
|
||||
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
@ -650,7 +651,7 @@ public final class ModelUtils
|
|||
|
||||
if ( repo != null )
|
||||
{
|
||||
RepositoryBase newRepo = new RepositoryBase();
|
||||
DeploymentRepository newRepo = new DeploymentRepository();
|
||||
|
||||
newRepo.setId( repo.getId() );
|
||||
newRepo.setLayout( repo.getLayout() );
|
||||
|
@ -677,7 +678,7 @@ public final class ModelUtils
|
|||
|
||||
if ( sRepo != null )
|
||||
{
|
||||
RepositoryBase newRepo = new RepositoryBase();
|
||||
DeploymentRepository newRepo = new DeploymentRepository();
|
||||
|
||||
newRepo.setId( sRepo.getId() );
|
||||
newRepo.setLayout( sRepo.getLayout() );
|
||||
|
|
|
@ -23,6 +23,7 @@ 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.apache.maven.model.DeploymentRepository;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
|
||||
|
@ -59,9 +60,9 @@ public final class ProjectUtils
|
|||
return repos;
|
||||
}
|
||||
|
||||
public static ArtifactRepository buildArtifactRepositoryBase( RepositoryBase repo,
|
||||
ArtifactRepositoryFactory artifactRepositoryFactory,
|
||||
PlexusContainer container )
|
||||
public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo,
|
||||
ArtifactRepositoryFactory artifactRepositoryFactory,
|
||||
PlexusContainer container )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( repo != null )
|
||||
|
@ -72,7 +73,7 @@ public final class ProjectUtils
|
|||
// TODO: make this a map inside the factory instead, so no lookup needed
|
||||
ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container );
|
||||
|
||||
return artifactRepositoryFactory.createArtifactRepository( id, url, layout );
|
||||
return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout, repo.isUniqueVersion() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.maven.model.Reporting;
|
|||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.Scm;
|
||||
import org.apache.maven.model.Site;
|
||||
import org.apache.maven.model.DeploymentRepository;
|
||||
import org.apache.maven.project.ModelUtils;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
|
@ -474,7 +475,7 @@ public class DefaultModelInheritanceAssembler
|
|||
{
|
||||
if ( parentDistMgmt.getRepository() != null )
|
||||
{
|
||||
Repository repository = new Repository();
|
||||
DeploymentRepository repository = new DeploymentRepository();
|
||||
|
||||
childDistMgmt.setRepository( repository );
|
||||
|
||||
|
@ -490,7 +491,7 @@ public class DefaultModelInheritanceAssembler
|
|||
{
|
||||
if ( parentDistMgmt.getSnapshotRepository() != null )
|
||||
{
|
||||
Repository repository = new Repository();
|
||||
DeploymentRepository repository = new DeploymentRepository();
|
||||
|
||||
childDistMgmt.setSnapshotRepository( repository );
|
||||
|
||||
|
|
Loading…
Reference in New Issue