From ba94b208d7f4b394e8b60ea682100aa689340b1f Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Tue, 4 Oct 2005 08:43:36 +0000 Subject: [PATCH] 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 --- .../repository/DefaultArtifactRepository.java | 24 ++++++++++++- .../DefaultArtifactRepositoryFactory.java | 6 ++-- .../transform/SnapshotTransformation.java | 9 +++-- .../repository/ArtifactRepository.java | 2 ++ .../repository/ArtifactRepositoryFactory.java | 6 ++-- maven-model/maven.mdo | 34 +++++++++++++++++-- .../project/DefaultMavenProjectBuilder.java | 9 ++--- .../org/apache/maven/project/ModelUtils.java | 5 +-- .../apache/maven/project/ProjectUtils.java | 9 ++--- .../DefaultModelInheritanceAssembler.java | 5 +-- 10 files changed, 86 insertions(+), 23 deletions(-) diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java index ad2f9acf86..bd32bfea70 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java @@ -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; + } } diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java index 691ec58f36..f74fa65318 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java @@ -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, diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java index f151b08288..1c7644ff88 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java @@ -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 ); diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java index c2f7d92b4b..758414f99f 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java @@ -49,4 +49,6 @@ public interface ArtifactRepository ArtifactRepositoryLayout getLayout(); String getKey(); + + boolean isUniqueVersion(); } diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java index 68cf8bc81a..7dc5213e63 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.java @@ -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 ); - -} \ No newline at end of file +} diff --git a/maven-model/maven.mdo b/maven-model/maven.mdo index 0698399bcd..8d8528da64 100644 --- a/maven-model/maven.mdo +++ b/maven-model/maven.mdo @@ -1530,7 +1530,7 @@ generated by the project ]]> - RepositoryBase + DeploymentRepository @@ -1540,7 +1540,7 @@ Where to deploy snapshots of artifacts to. If not given, it defaults to the repository. - RepositoryBase + DeploymentRepository @@ -2242,6 +2242,36 @@ + + DeploymentRepository + RepositoryBase + 4.0.0 + + Repository contains the information needed for deploying to the remote repoistory + + + + uniqueVersion + Whether to assign snapshots a unique version comprised of the timestamp and build number, or to use the same version each time + boolean + true + 4.0.0 + + + + + + 4.0.0 + + + + + RepositoryPolicy 4.0.0 diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 3fb6f6e49d..201b338e12 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -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 ); } } diff --git a/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java b/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java index 45a9552573..f900c0c265 100644 --- a/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java +++ b/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java @@ -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() ); diff --git a/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java b/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java index 754578b78b..3f51def211 100644 --- a/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java +++ b/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java @@ -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 { diff --git a/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java b/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java index 741312ba7f..531a95191d 100644 --- a/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java +++ b/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java @@ -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 );