diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/LatestArtifactMetadata.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/LatestArtifactMetadata.java index de83e8217f..5fd02c53d9 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/LatestArtifactMetadata.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/LatestArtifactMetadata.java @@ -115,4 +115,24 @@ public class LatestArtifactMetadata { return false; } + + public int getBuildNumber() + { + return 0; + } + + public String getTimestamp() + { + return null; + } + + public String getLatestVersion() + { + return null; + } + + public String getReleaseVersion() + { + return null; + } } diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/ReleaseArtifactMetadata.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/ReleaseArtifactMetadata.java index dcc9c0ca22..07311e7f93 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/ReleaseArtifactMetadata.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/ReleaseArtifactMetadata.java @@ -122,4 +122,24 @@ public class ReleaseArtifactMetadata { return false; } + + public int getBuildNumber() + { + return 0; + } + + public String getTimestamp() + { + return null; + } + + public String getLatestVersion() + { + return null; + } + + public String getReleaseVersion() + { + return null; + } } diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java index 47d89f03b6..a5d57a7637 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java @@ -179,4 +179,14 @@ public class SnapshotArtifactMetadata { return artifact.getBaseVersion(); } + + public String getLatestVersion() + { + return null; + } + + public String getReleaseVersion() + { + return null; + } } diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/ArtifactRepositoryMetadata.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/ArtifactRepositoryMetadata.java index 6c98c4c131..80442a1715 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/ArtifactRepositoryMetadata.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/ArtifactRepositoryMetadata.java @@ -59,7 +59,7 @@ public class ArtifactRepositoryMetadata public String toString() { - return "repository metadata for artifact: \'" + artifact + "\'"; + return "repository metadata for: \'" + getKey() + "\'"; } public boolean storedInGroupDirectory() @@ -84,7 +84,7 @@ public class ArtifactRepositoryMetadata public String getBaseVersion() { - return artifact.getBaseVersion(); + return null; } protected void updateRepositoryMetadata( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) @@ -142,27 +142,6 @@ public class ArtifactRepositoryMetadata Versioning v = metadata.getVersioning(); if ( v != null ) { - // TODO: merge versioning (reuse code from transformation) - Snapshot s = v.getSnapshot(); - Snapshot snapshot = versioning.getSnapshot(); - if ( snapshot != null ) - { - if ( s == null ) - { - v.setSnapshot( snapshot ); - changed = true; - } - else if ( s.getTimestamp() != null && !s.getTimestamp().equals( snapshot.getTimestamp() ) ) - { - s.setTimestamp( snapshot.getTimestamp() ); - changed = true; - } - else if ( s.getBuildNumber() != snapshot.getBuildNumber() ) - { - s.setBuildNumber( snapshot.getBuildNumber() ); - changed = true; - } - } if ( versioning.getRelease() != null ) { changed = true; @@ -225,7 +204,7 @@ public class ArtifactRepositoryMetadata public Snapshot getSnapshot() { - return versioning != null ? versioning.getSnapshot() : null; + return null; } public String getLatestVersion() @@ -237,4 +216,14 @@ public class ArtifactRepositoryMetadata { return versioning.getRelease(); } + + public int getBuildNumber() + { + return 0; + } + + public String getTimestamp() + { + return null; + } } diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java index 3acb314a82..8dd8f17e4d 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java @@ -98,7 +98,7 @@ public class DefaultRepositoryMetadataManager File file = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, remoteRepository ) ); - resolveAlways( metadata, localRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); + resolveAlways( metadata, remoteRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); } private void resolveAlways( ArtifactMetadata metadata, ArtifactRepository repository, File file, diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/GroupRepositoryMetadata.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/GroupRepositoryMetadata.java index 27ce2054ca..449830d399 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/GroupRepositoryMetadata.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/GroupRepositoryMetadata.java @@ -199,4 +199,24 @@ public class GroupRepositoryMetadata { return false; } + + public int getBuildNumber() + { + return 0; + } + + public String getTimestamp() + { + return null; + } + + public String getLatestVersion() + { + return null; + } + + public String getReleaseVersion() + { + return null; + } } diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/SnapshotArtifactRepositoryMetadata.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/SnapshotArtifactRepositoryMetadata.java new file mode 100644 index 0000000000..2025570912 --- /dev/null +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/SnapshotArtifactRepositoryMetadata.java @@ -0,0 +1,218 @@ +package org.apache.maven.artifact.repository.metadata; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; +import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; + +/** + * Metadata for the artifact version directory of the repository. + * + * @author Brett Porter + * @version $Id$ + * @todo split instantiation (versioning, plugin mappings) from definition + */ +public class SnapshotArtifactRepositoryMetadata + extends AbstractRepositoryMetadata +{ + private Snapshot snapshot; + + private Artifact artifact; + + public SnapshotArtifactRepositoryMetadata( Artifact artifact ) + { + this.artifact = artifact; + } + + public SnapshotArtifactRepositoryMetadata( Artifact artifact, Snapshot snapshot ) + { + this.snapshot = snapshot; + this.artifact = artifact; + } + + public String toString() + { + return "repository metadata for: \'" + getKey() + "\'"; + } + + public boolean storedInGroupDirectory() + { + return false; + } + + public boolean storedInArtifactVersionDirectory() + { + return true; + } + + public String getGroupId() + { + return artifact.getGroupId(); + } + + public String getArtifactId() + { + return artifact.getArtifactId(); + } + + public String getBaseVersion() + { + return artifact.getBaseVersion(); + } + + protected void updateRepositoryMetadata( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) + throws IOException + { + MetadataXpp3Reader mappingReader = new MetadataXpp3Reader(); + + Metadata metadata = null; + + File metadataFile = new File( localRepository.getBasedir(), + localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) ); + + if ( metadataFile.exists() ) + { + Reader reader = null; + + try + { + reader = new FileReader( metadataFile ); + + metadata = mappingReader.read( reader ); + } + catch ( FileNotFoundException e ) + { + // TODO: Log a warning + } + catch ( IOException e ) + { + // TODO: Log a warning + } + catch ( XmlPullParserException e ) + { + // TODO: Log a warning + } + finally + { + IOUtil.close( reader ); + } + } + + boolean changed = false; + + // If file could not be found or was not valid, start from scratch + if ( metadata == null ) + { + metadata = new Metadata(); + + metadata.setGroupId( artifact.getGroupId() ); + metadata.setArtifactId( artifact.getArtifactId() ); + changed = true; + } + + if ( snapshot != null ) + { + Versioning v = metadata.getVersioning(); + if ( v == null ) + { + v = new Versioning(); + metadata.setVersioning( v ); + } + + Snapshot s = v.getSnapshot(); + if ( s == null ) + { + v.setSnapshot( snapshot ); + changed = true; + } + else if ( s.getTimestamp() != null && !s.getTimestamp().equals( snapshot.getTimestamp() ) ) + { + s.setTimestamp( snapshot.getTimestamp() ); + changed = true; + } + else if ( s.getBuildNumber() != snapshot.getBuildNumber() ) + { + s.setBuildNumber( snapshot.getBuildNumber() ); + changed = true; + } + } + + if ( changed ) + { + Writer writer = null; + try + { + metadataFile.getParentFile().mkdirs(); + writer = new FileWriter( metadataFile ); + + MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer(); + + mappingWriter.write( writer, metadata ); + } + finally + { + IOUtil.close( writer ); + } + } + else + { + metadataFile.setLastModified( System.currentTimeMillis() ); + } + } + + public Object getKey() + { + return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getBaseVersion(); + } + + public boolean isSnapshot() + { + return artifact.isSnapshot(); + } + + public int getBuildNumber() + { + return snapshot != null ? snapshot.getBuildNumber() : 0; + } + + public String getTimestamp() + { + return snapshot != null ? snapshot.getTimestamp() : null; + } + + public String getLatestVersion() + { + return null; + } + + public String getReleaseVersion() + { + return null; + } +} diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java index c22219478f..bab3fa0447 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.java @@ -27,7 +27,7 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager; -import org.apache.maven.artifact.repository.metadata.Snapshot; +import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.codehaus.plexus.logging.AbstractLogEnabled; @@ -68,7 +68,15 @@ public abstract class AbstractVersionTransformation throws ArtifactMetadataRetrievalException { // TODO: can we improve on this? - ArtifactMetadata metadata = new ArtifactRepositoryMetadata( artifact ); + ArtifactMetadata metadata = null; + if ( artifact.isSnapshot() ) + { + metadata = new ArtifactRepositoryMetadata( artifact ); + } + else + { + metadata = new SnapshotArtifactRepositoryMetadata( artifact ); + } repositoryMetadataManager.resolve( metadata, remoteRepositories, localRepository ); @@ -86,7 +94,7 @@ public abstract class AbstractVersionTransformation String version = selectVersion( versioning, artifact.getVersion() ); */ - ArtifactRepositoryMetadata localMetadata = null; + ArtifactMetadata localMetadata = null; for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); ) { ArtifactRepository repository = (ArtifactRepository) i.next(); @@ -99,8 +107,7 @@ public abstract class AbstractVersionTransformation break; } } - ArtifactRepositoryMetadata m = loadVersioningInformation( metadata, localRepository, localRepository, - artifact ); + ArtifactMetadata m = loadVersioningInformation( metadata, localRepository, localRepository, artifact ); if ( m != null ) { localMetadata = m; @@ -147,22 +154,20 @@ public abstract class AbstractVersionTransformation return version; } - protected Snapshot resolveLatestSnapshotVersion( Artifact artifact, ArtifactRepository localRepository, - ArtifactRepository remoteRepository ) + protected int resolveLatestSnapshotBuildNumber( Artifact artifact, ArtifactRepository localRepository, + ArtifactRepository remoteRepository ) throws ArtifactMetadataRetrievalException { // TODO: can we improve on this? - ArtifactMetadata metadata = new ArtifactRepositoryMetadata( artifact ); + ArtifactMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact ); + getLogger().info( "Retrieving previous build number from " + remoteRepository.getId() ); repositoryMetadataManager.resolveAlways( metadata, localRepository, remoteRepository ); - ArtifactRepositoryMetadata m = loadVersioningInformation( metadata, remoteRepository, localRepository, - artifact ); - Snapshot snapshot; + ArtifactMetadata m = loadVersioningInformation( metadata, remoteRepository, localRepository, artifact ); + int buildNumber = 0; if ( m == null ) { - snapshot = new Snapshot(); - try { SnapshotArtifactMetadata snapshotMetadata = new SnapshotArtifactMetadata( artifact ); @@ -170,8 +175,7 @@ public abstract class AbstractVersionTransformation ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); getLogger().warn( "Using old-style versioning metadata from remote repo for " + artifact ); - snapshot.setTimestamp( snapshotMetadata.getTimestamp() ); - snapshot.setBuildNumber( snapshotMetadata.getBuildNumber() ); + buildNumber = snapshotMetadata.getBuildNumber(); } catch ( ResourceDoesNotExistException e1 ) { @@ -181,12 +185,12 @@ public abstract class AbstractVersionTransformation } else { - snapshot = m.getSnapshot(); + buildNumber = m.getBuildNumber(); } - return snapshot; + return buildNumber; } - protected abstract String constructVersion( ArtifactRepositoryMetadata metadata ); + protected abstract String constructVersion( ArtifactMetadata metadata ); /* TODO private void mergeVersioning( Versioning dest, Versioning source ) @@ -345,22 +349,32 @@ public abstract class AbstractVersionTransformation return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getBaseVersion(); } - private ArtifactRepositoryMetadata loadVersioningInformation( ArtifactMetadata repoMetadata, - ArtifactRepository remoteRepository, - ArtifactRepository localRepository, - Artifact artifact ) + private ArtifactMetadata loadVersioningInformation( ArtifactMetadata repoMetadata, + ArtifactRepository remoteRepository, + ArtifactRepository localRepository, Artifact artifact ) throws ArtifactMetadataRetrievalException { File metadataFile = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( repoMetadata, remoteRepository ) ); - ArtifactRepositoryMetadata newMetadata = null; + ArtifactMetadata newMetadata = null; if ( metadataFile.exists() ) { Metadata metadata = readMetadata( metadataFile ); if ( metadata.getVersioning() != null ) { - newMetadata = new ArtifactRepositoryMetadata( artifact, metadata.getVersioning() ); + if ( artifact.isSnapshot() ) + { + if ( metadata.getVersioning().getSnapshot() != null ) + { + newMetadata = new SnapshotArtifactRepositoryMetadata( artifact, + metadata.getVersioning().getSnapshot() ); + } + } + else + { + newMetadata = new ArtifactRepositoryMetadata( artifact, metadata.getVersioning() ); + } } } return newMetadata; diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/LatestArtifactTransformation.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/LatestArtifactTransformation.java index 7f7b9fdd64..03e3a4e63f 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/LatestArtifactTransformation.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/LatestArtifactTransformation.java @@ -22,7 +22,6 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.LatestArtifactMetadata; import org.apache.maven.artifact.metadata.LegacyArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Versioning; import java.util.List; @@ -69,7 +68,7 @@ public class LatestArtifactTransformation return metadata; } - protected String constructVersion( ArtifactRepositoryMetadata metadata ) + protected String constructVersion( ArtifactMetadata metadata ) { return metadata.getLatestVersion(); } diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java index a49c6c87bb..eab51c74d8 100644 --- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java +++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.java @@ -17,11 +17,11 @@ package org.apache.maven.artifact.transform; */ import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.LegacyArtifactMetadata; import org.apache.maven.artifact.metadata.ReleaseArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import java.util.List; @@ -69,7 +69,7 @@ public class ReleaseArtifactTransformation return new ReleaseArtifactMetadata( artifact ); } - protected String constructVersion( ArtifactRepositoryMetadata metadata ) + protected String constructVersion( ArtifactMetadata metadata ) { return metadata.getReleaseVersion(); } 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 4d7b78b5d2..47b8532b03 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 @@ -22,9 +22,8 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.LegacyArtifactMetadata; import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Snapshot; -import org.apache.maven.artifact.repository.metadata.Versioning; +import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.codehaus.plexus.util.StringUtils; import java.util.Date; @@ -57,11 +56,7 @@ public class SnapshotTransformation if ( artifact.isSnapshot() ) { // TODO: Better way to create this - should have to construct Versioning - Versioning versioning = new Versioning(); - Snapshot snapshot = new Snapshot(); - versioning.setSnapshot( snapshot ); - - ArtifactMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning ); + ArtifactMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact ); // TODO: should merge with other repository metadata sitting on the same level? artifact.addMetadata( metadata ); @@ -74,15 +69,14 @@ public class SnapshotTransformation { if ( artifact.isSnapshot() ) { - Snapshot snapshot = resolveLatestSnapshotVersion( artifact, localRepository, remoteRepository ); - snapshot.setTimestamp( getDeploymentTimestamp() ); - snapshot.setBuildNumber( snapshot.getBuildNumber() + 1 ); + int buildNumber = resolveLatestSnapshotBuildNumber( artifact, localRepository, remoteRepository ); // TODO: Better way to create this - should have to construct Versioning - Versioning versioning = new Versioning(); - versioning.setSnapshot( snapshot ); + Snapshot snapshot = new Snapshot(); + snapshot.setTimestamp( getDeploymentTimestamp() ); + snapshot.setBuildNumber( buildNumber + 1 ); - ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning ); + ArtifactMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot ); artifact.setResolvedVersion( constructVersion( metadata ) ); @@ -104,23 +98,19 @@ public class SnapshotTransformation return new SnapshotArtifactMetadata( artifact ); } - protected String constructVersion( ArtifactRepositoryMetadata metadata ) + protected String constructVersion( ArtifactMetadata metadata ) { String version = metadata.getBaseVersion(); - Snapshot snapshot = metadata.getSnapshot(); - if ( snapshot != null ) + if ( metadata.getTimestamp() != null && metadata.getBuildNumber() > 0 ) { - if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 ) + String newVersion = metadata.getTimestamp() + "-" + metadata.getBuildNumber(); + if ( version != null ) { - String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber(); - if ( version != null ) - { - version = StringUtils.replace( version, "SNAPSHOT", newVersion ); - } - else - { - version = newVersion; - } + version = StringUtils.replace( version, "SNAPSHOT", newVersion ); + } + else + { + version = newVersion; } } return version; diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadata.java b/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadata.java index 44a4e0fefd..275b5b4718 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadata.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadata.java @@ -26,6 +26,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository; * @todo merge with artifactmetadatasource * @todo retrieval exception not appropriate for store * @todo not happy about the store/retrieve methods - they use "this" + * @todo separate specific interfaces */ public interface ArtifactMetadata { @@ -72,4 +73,12 @@ public interface ArtifactMetadata * @return the filename */ String getRemoteFilename(); + + int getBuildNumber(); + + String getTimestamp(); + + String getLatestVersion(); + + String getReleaseVersion(); } diff --git a/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java index a714a623d4..1ebf0e6f56 100644 --- a/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java +++ b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java @@ -129,14 +129,15 @@ public class DeployMojo artifact.addMetadata( metadata ); } + // TODO: clean up + Versioning versioning = new Versioning(); + versioning.addVersion( artifact.getVersion() ); if ( updateReleaseInfo ) { - // TODO: clean up - Versioning versioning = new Versioning(); versioning.setRelease( artifact.getVersion() ); - ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning ); - artifact.addMetadata( metadata ); } + ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning ); + artifact.addMetadata( metadata ); try { diff --git a/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java b/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java index d1299baca1..efad1af151 100644 --- a/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java +++ b/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java @@ -97,14 +97,15 @@ public class InstallMojo artifact.addMetadata( metadata ); } + // TODO: clean up + Versioning versioning = new Versioning(); + versioning.addVersion( artifact.getVersion() ); if ( updateReleaseInfo ) { - // TODO: clean up - Versioning versioning = new Versioning(); versioning.setRelease( artifact.getVersion() ); - ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning ); - artifact.addMetadata( metadata ); } + ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning ); + artifact.addMetadata( metadata ); try { diff --git a/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java b/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java index 02466baec1..c0727959c2 100644 --- a/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java +++ b/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java @@ -145,4 +145,24 @@ public class ProjectArtifactMetadata { return artifact.isSnapshot(); } + + public String getLatestVersion() + { + return null; + } + + public String getReleaseVersion() + { + return null; + } + + public int getBuildNumber() + { + return 0; + } + + public String getTimestamp() + { + return null; + } }