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:
Brett Leslie Porter 2005-10-04 08:43:36 +00:00
parent 3bcde49fca
commit ba94b208d7
10 changed files with 86 additions and 23 deletions

View File

@ -38,8 +38,10 @@ public class DefaultArtifactRepository
private ArtifactRepositoryPolicy releases; 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 id the unique identifier of the repository
* @param url the URL of the repository * @param url the URL of the repository
@ -50,6 +52,21 @@ public class DefaultArtifactRepository
this( id, url, layout, null, null ); 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. * Create a remote download repository.
* *
@ -117,4 +134,9 @@ public class DefaultArtifactRepository
{ {
return getId(); return getId();
} }
public boolean isUniqueVersion()
{
return uniqueVersion;
}
} }

View File

@ -29,10 +29,10 @@ public class DefaultArtifactRepositoryFactory
private String globalChecksumPolicy; private String globalChecksumPolicy;
public ArtifactRepository createArtifactRepository( String id, String url, public ArtifactRepository createDeploymentArtifactRepository( String id, String url,
ArtifactRepositoryLayout repositoryLayout ) ArtifactRepositoryLayout repositoryLayout, boolean uniqueVersion )
{ {
return new DefaultArtifactRepository( id, url, repositoryLayout ); return new DefaultArtifactRepository( id, url, repositoryLayout, uniqueVersion );
} }
public ArtifactRepository createArtifactRepository( String id, String url, public ArtifactRepository createArtifactRepository( String id, String url,

View File

@ -77,10 +77,15 @@ public class SnapshotTransformation
{ {
if ( artifact.isSnapshot() ) 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 ); int buildNumber = resolveLatestSnapshotBuildNumber( artifact, localRepository, remoteRepository );
Snapshot snapshot = new Snapshot();
snapshot.setTimestamp( getDeploymentTimestamp() );
snapshot.setBuildNumber( buildNumber + 1 ); snapshot.setBuildNumber( buildNumber + 1 );
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot ); RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );

View File

@ -49,4 +49,6 @@ public interface ArtifactRepository
ArtifactRepositoryLayout getLayout(); ArtifactRepositoryLayout getLayout();
String getKey(); String getKey();
boolean isUniqueVersion();
} }

View File

@ -25,7 +25,8 @@ public interface ArtifactRepositoryFactory
{ {
String ROLE = ArtifactRepositoryFactory.class.getName(); 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, ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout,
ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy snapshots,
@ -34,5 +35,4 @@ public interface ArtifactRepositoryFactory
void setGlobalUpdatePolicy( String snapshotPolicy ); void setGlobalUpdatePolicy( String snapshotPolicy );
void setGlobalChecksumPolicy( String checksumPolicy ); void setGlobalChecksumPolicy( String checksumPolicy );
} }

View File

@ -1530,7 +1530,7 @@
generated by the project generated by the project
]]></description> ]]></description>
<association> <association>
<type>RepositoryBase</type> <type>DeploymentRepository</type>
</association> </association>
</field> </field>
<field> <field>
@ -1540,7 +1540,7 @@
Where to deploy snapshots of artifacts to. If not given, it defaults to the repository. Where to deploy snapshots of artifacts to. If not given, it defaults to the repository.
</description> </description>
<association> <association>
<type>RepositoryBase</type> <type>DeploymentRepository</type>
</association> </association>
</field> </field>
<field> <field>
@ -2242,6 +2242,36 @@
</codeSegments> </codeSegments>
</class> </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> <class>
<name>RepositoryPolicy</name> <name>RepositoryPolicy</name>
<version>4.0.0</version> <version>4.0.0</version>

View File

@ -632,14 +632,15 @@ public class DefaultMavenProjectBuilder
DistributionManagement dm = model.getDistributionManagement(); DistributionManagement dm = model.getDistributionManagement();
if ( dm != null ) if ( dm != null )
{ {
ArtifactRepository repo = ProjectUtils.buildArtifactRepositoryBase( dm.getRepository(), ArtifactRepository repo = ProjectUtils.buildDeploymentArtifactRepository( dm.getRepository(),
artifactRepositoryFactory, container ); artifactRepositoryFactory,
container );
project.setReleaseArtifactRepository( repo ); project.setReleaseArtifactRepository( repo );
if ( dm.getSnapshotRepository() != null ) if ( dm.getSnapshotRepository() != null )
{ {
repo = ProjectUtils.buildArtifactRepositoryBase( dm.getSnapshotRepository(), artifactRepositoryFactory, repo = ProjectUtils.buildDeploymentArtifactRepository( dm.getSnapshotRepository(),
container ); artifactRepositoryFactory, container );
project.setSnapshotArtifactRepository( repo ); project.setSnapshotArtifactRepository( repo );
} }
} }

View File

@ -42,6 +42,7 @@ import org.apache.maven.model.RepositoryBase;
import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.model.Resource; import org.apache.maven.model.Resource;
import org.apache.maven.model.Site; 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.DefaultModelInheritanceAssembler;
import org.apache.maven.project.inheritance.ModelInheritanceAssembler; import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3Dom;
@ -650,7 +651,7 @@ public final class ModelUtils
if ( repo != null ) if ( repo != null )
{ {
RepositoryBase newRepo = new RepositoryBase(); DeploymentRepository newRepo = new DeploymentRepository();
newRepo.setId( repo.getId() ); newRepo.setId( repo.getId() );
newRepo.setLayout( repo.getLayout() ); newRepo.setLayout( repo.getLayout() );
@ -677,7 +678,7 @@ public final class ModelUtils
if ( sRepo != null ) if ( sRepo != null )
{ {
RepositoryBase newRepo = new RepositoryBase(); DeploymentRepository newRepo = new DeploymentRepository();
newRepo.setId( sRepo.getId() ); newRepo.setId( sRepo.getId() );
newRepo.setLayout( sRepo.getLayout() ); newRepo.setLayout( sRepo.getLayout() );

View File

@ -23,6 +23,7 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryBase; import org.apache.maven.model.RepositoryBase;
import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.model.DeploymentRepository;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@ -59,7 +60,7 @@ public final class ProjectUtils
return repos; return repos;
} }
public static ArtifactRepository buildArtifactRepositoryBase( RepositoryBase repo, public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo,
ArtifactRepositoryFactory artifactRepositoryFactory, ArtifactRepositoryFactory artifactRepositoryFactory,
PlexusContainer container ) PlexusContainer container )
throws ProjectBuildingException throws ProjectBuildingException
@ -72,7 +73,7 @@ public final class ProjectUtils
// TODO: make this a map inside the factory instead, so no lookup needed // TODO: make this a map inside the factory instead, so no lookup needed
ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container ); ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container );
return artifactRepositoryFactory.createArtifactRepository( id, url, layout ); return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout, repo.isUniqueVersion() );
} }
else else
{ {

View File

@ -26,6 +26,7 @@ import org.apache.maven.model.Reporting;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.model.Scm; import org.apache.maven.model.Scm;
import org.apache.maven.model.Site; import org.apache.maven.model.Site;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.project.ModelUtils; import org.apache.maven.project.ModelUtils;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
@ -474,7 +475,7 @@ public class DefaultModelInheritanceAssembler
{ {
if ( parentDistMgmt.getRepository() != null ) if ( parentDistMgmt.getRepository() != null )
{ {
Repository repository = new Repository(); DeploymentRepository repository = new DeploymentRepository();
childDistMgmt.setRepository( repository ); childDistMgmt.setRepository( repository );
@ -490,7 +491,7 @@ public class DefaultModelInheritanceAssembler
{ {
if ( parentDistMgmt.getSnapshotRepository() != null ) if ( parentDistMgmt.getSnapshotRepository() != null )
{ {
Repository repository = new Repository(); DeploymentRepository repository = new DeploymentRepository();
childDistMgmt.setSnapshotRepository( repository ); childDistMgmt.setSnapshotRepository( repository );