diff --git a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java
index 7240efb663..c9006e95bb 100644
--- a/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java
+++ b/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java
@@ -159,6 +159,7 @@ public abstract class AbstractRepositoryMetadata
{
Versioning versioning = new Versioning();
versioning.setSnapshot( snapshot );
+ versioning.updateTimestamp();
return versioning;
}
@@ -178,16 +179,16 @@ public abstract class AbstractRepositoryMetadata
AbstractRepositoryMetadata repoMetadata = (AbstractRepositoryMetadata) metadata;
this.metadata.merge( repoMetadata.getMetadata() );
}
-
+
public String extendedToString()
{
StringBuffer buffer = new StringBuffer();
-
+
buffer.append( "\nRepository Metadata\n--------------------------" );
buffer.append( "\nGroupId: " ).append( getGroupId() );
buffer.append( "\nArtifactId: " ).append( getArtifactId() );
- buffer.append( "\nMetadata Type: " ).append(getClass().getName() );
-
+ buffer.append( "\nMetadata Type: " ).append( getClass().getName() );
+
return buffer.toString();
}
}
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 2a9319518b..53aa398ab8 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
@@ -89,12 +89,6 @@ public class DefaultRepositoryMetadataManager
}
else
{
- // NOTE: [jc; 21-sept-2005] won't this cause inconsistencies if the metadata wasn't found?
- // this will write out an essentially empty metadata file, which will result
- // in the loop below NOT merging anything (each successive pass is still empty),
- // which means that the last repository will be set as the artifact repo, rather
- // than leaving it null. This is the root cause of MNG-900, but I'm not sure how
- // to fix it.
metadata.storeInLocalRepository( localRepository, repository );
}
}
@@ -105,7 +99,6 @@ public class DefaultRepositoryMetadataManager
// snapshot timestamp, or some other timestamp later encoded into the metadata.
// TODO: this needs to be repeated here so the merging doesn't interfere with the written metadata
// - we'd be much better having a pristine input, and an ongoing metadata for merging instead
- loadMetadata( metadata, localRepository, localRepository );
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
{
@@ -119,6 +112,7 @@ public class DefaultRepositoryMetadataManager
loadMetadata( metadata, repository, localRepository );
}
}
+ loadMetadata( metadata, localRepository, localRepository );
}
private void loadMetadata( RepositoryMetadata repoMetadata, ArtifactRepository remoteRepository,
@@ -134,12 +128,15 @@ public class DefaultRepositoryMetadataManager
if ( repoMetadata.getMetadata() != null )
{
- if ( !metadata.merge( repoMetadata.getMetadata() ) )
+ if ( repoMetadata.getMetadata().merge( metadata ) )
{
repoMetadata.setRepository( remoteRepository );
}
}
- repoMetadata.setMetadata( metadata );
+ else
+ {
+ repoMetadata.setMetadata( metadata );
+ }
}
}
@@ -188,7 +185,7 @@ public class DefaultRepositoryMetadataManager
getLogger().debug( "System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" );
return;
}
-
+
File file = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( metadata, remoteRepository ) );
@@ -210,7 +207,7 @@ public class DefaultRepositoryMetadataManager
getLogger().debug( "System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" );
return;
}
-
+
try
{
wagonManager.getArtifactMetadata( metadata, repository, file, checksumPolicy );
@@ -245,7 +242,7 @@ public class DefaultRepositoryMetadataManager
getLogger().warn( "System is offline. Cannot deploy metadata:\n" + metadata.extendedToString() + "\n\n" );
return;
}
-
+
getLogger().info( "Retrieving previous metadata from " + deploymentRepository.getId() );
File file = new File( localRepository.getBasedir(),
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
index f1703fa3a4..17d4bbfe49 100644
--- 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
@@ -33,7 +33,8 @@ public class SnapshotArtifactRepositoryMetadata
public SnapshotArtifactRepositoryMetadata( Artifact artifact )
{
- this( artifact, new Snapshot() );
+ super( createMetadata( artifact, null ) );
+ this.artifact = artifact;
}
public SnapshotArtifactRepositoryMetadata( Artifact artifact, Snapshot snapshot )
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 aff61ea5bd..ad102ace06 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
@@ -109,17 +109,9 @@ public abstract class AbstractVersionTransformation
else
{
// Locally installed file is newer, don't use the resolved version
- getLogger().debug( artifact.getArtifactId() + ": using locally installed snapshot");
+ getLogger().debug( artifact.getArtifactId() + ": using locally installed snapshot" );
}
}
-
- if ( version.equals( artifact.getBaseVersion() ) )
- {
- // odd: we hit here when: using legecy repo, not local, and no snapshot version meta data was availble
- // but the repository was set to one of the remote repos (and it was the wrong one).
- artifact.setRepository( null );
- }
-
return version;
}
@@ -157,12 +149,12 @@ public abstract class AbstractVersionTransformation
if ( !wagonManager.isOnline() )
{
LegacyArtifactMetadata metadata = createLegacyMetadata( artifact );
- getLogger().debug( "System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" );
-
+ getLogger().debug(
+ "System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" );
+
return null;
}
-
-
+
boolean checkedUpdates = false;
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
{
@@ -178,8 +170,8 @@ public abstract class AbstractVersionTransformation
}
else
{
- boolean checkForUpdates = localMetadata == null
- || policy.checkOutOfDate( localMetadata.getLastModified() );
+ boolean checkForUpdates = localMetadata == null ||
+ policy.checkOutOfDate( localMetadata.getLastModified() );
if ( checkForUpdates )
{
@@ -207,7 +199,7 @@ public abstract class AbstractVersionTransformation
catch ( ResourceDoesNotExistException e )
{
getLogger().debug( "Legacy metadata for: " + artifact.getId() +
- " could not be found on repository: " + repository.getId(), e );
+ " could not be found on repository: " + repository.getId() );
}
catch ( ArtifactMetadataRetrievalException e )
{
@@ -233,7 +225,8 @@ public abstract class AbstractVersionTransformation
resolvedArtifactCache.add( getCacheKey( artifact ) );
}
- if ( localMetadata != null && artifact.getFile().exists() && !localMetadata.newerThanFile( artifact.getFile() ) )
+ if ( localMetadata != null && artifact.getFile().exists() &&
+ !localMetadata.newerThanFile( artifact.getFile() ) )
{
if ( getLogger().isDebugEnabled() && !alreadyResolved )
{
@@ -242,7 +235,7 @@ public abstract class AbstractVersionTransformation
}
localMetadata = null;
}
-
+
return localMetadata != null ? localMetadata.constructVersion() : null;
}
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 e5876a8f3d..019ea70189 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
@@ -73,6 +73,7 @@ public class ReleaseArtifactTransformation
private ArtifactMetadata createMetadata( Artifact artifact )
{
Versioning versioning = new Versioning();
+ versioning.updateTimestamp();
versioning.addVersion( artifact.getVersion() );
if ( artifact.isRelease() )
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 403d36e82c..f70b4a8e74 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
@@ -59,8 +59,9 @@ public class SnapshotTransformation
{
if ( artifact.isSnapshot() )
{
- RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact );
- metadata.getMetadata().getVersioning().getSnapshot().setLocalCopy( true );
+ Snapshot snapshot = new Snapshot();
+ snapshot.setLocalCopy( true );
+ RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );
artifact.addMetadata( metadata );
}
@@ -129,12 +130,13 @@ public class SnapshotTransformation
if ( !wagonManager.isOnline() )
{
getLogger().debug( "System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" );
-
- getLogger().info( "System is offline. Assuming build number of 0 for " + metadata.getGroupId() + ":" + metadata.getArtifactId() + " snapshot." );
+
+ getLogger().info( "System is offline. Assuming build number of 0 for " + metadata.getGroupId() + ":" +
+ metadata.getArtifactId() + " snapshot." );
return 0;
}
-
+
getLogger().info( "Retrieving previous build number from " + remoteRepository.getId() );
repositoryMetadataManager.resolveAlways( metadata, localRepository, remoteRepository );
diff --git a/maven-plugins/maven-plugin-plugin/pom.xml b/maven-plugins/maven-plugin-plugin/pom.xml
index ca982f9cf4..e499b08da7 100644
--- a/maven-plugins/maven-plugin-plugin/pom.xml
+++ b/maven-plugins/maven-plugin-plugin/pom.xml
@@ -2,7 +2,7 @@
maven-plugin-parent
org.apache.maven.plugins
- 2.0-beta-1
+ 2.0-beta-3-SNAPSHOT
4.0.0
maven-plugin-plugin
@@ -26,6 +26,11 @@
org.apache.maven
maven-project
+
+ org.apache.maven
+ maven-repository-metadata
+ 2.0-beta-3-SNAPSHOT
+
org.apache.maven
maven-plugin-tools-api
diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java
index a29065cb79..3961a6e8d5 100644
--- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java
+++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/metadata/AddPluginArtifactMetadataMojo.java
@@ -42,6 +42,7 @@ public class AddPluginArtifactMetadataMojo
Versioning versioning = new Versioning();
versioning.setLatest( projectArtifact.getVersion() );
+ versioning.updateTimestamp();
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( projectArtifact, versioning );
projectArtifact.addMetadata( metadata );
diff --git a/maven-repository-metadata/src/main/mdo/metadata.mdo b/maven-repository-metadata/src/main/mdo/metadata.mdo
index 0630b17112..559a79075a 100644
--- a/maven-repository-metadata/src/main/mdo/metadata.mdo
+++ b/maven-repository-metadata/src/main/mdo/metadata.mdo
@@ -53,109 +53,123 @@
1.0.0
0 )
+ {
+ v.setLastUpdated( versioning.getLastUpdated() );
+
+ if ( versioning.getRelease() != null )
+ {
+ changed = true;
+ v.setRelease( versioning.getRelease() );
+ }
+ if ( versioning.getLatest() != null )
+ {
+ changed = true;
+ v.setLatest( versioning.getLatest() );
}
- Versioning versioning = sourceMetadata.getVersioning();
- if ( versioning != null )
+ Snapshot s = v.getSnapshot();
+ Snapshot snapshot = versioning.getSnapshot();
+ if ( snapshot != null )
{
- Versioning v = getVersioning();
- if ( v != null )
+ if ( s == null )
{
- if ( versioning.getRelease() != null )
- {
- changed = true;
- v.setRelease( versioning.getRelease() );
- }
- if ( versioning.getLatest() != null )
- {
- changed = true;
- v.setLatest( versioning.getLatest() );
- }
- for ( java.util.Iterator i = versioning.getVersions().iterator(); i.hasNext(); )
- {
- String version = (String) i.next();
- if ( !v.getVersions().contains( version ) )
- {
- changed = true;
- v.getVersions().add( version );
- }
- }
+ s = new Snapshot();
+ v.setSnapshot( s );
+ changed = true;
+ }
- Snapshot s = v.getSnapshot();
- Snapshot snapshot = versioning.getSnapshot();
- if ( snapshot != null )
- {
- if ( s == null )
- {
- v.setSnapshot( snapshot );
- changed = true;
- }
- else if ( snapshot.isLocalCopy() )
- {
- s.setLocalCopy( true );
- s.setTimestamp( null );
- s.setBuildNumber( 0 );
- changed = true;
- }
- else
- {
- if ( snapshot.getTimestamp() != null && !snapshot.getTimestamp().equals( s.getTimestamp() ) )
- {
- s.setTimestamp( snapshot.getTimestamp() );
- changed = true;
- }
- if ( snapshot.getBuildNumber() > 0 && s.getBuildNumber() != snapshot.getBuildNumber() )
- {
- s.setBuildNumber( snapshot.getBuildNumber() );
- changed = true;
- }
- if ( s.isLocalCopy() )
- {
- s.setLocalCopy( false );
- changed = true;
- }
- }
- }
+ if ( snapshot.isLocalCopy() )
+ {
+ s.setLocalCopy( true );
+ s.setTimestamp( null );
+ s.setBuildNumber( 0 );
+ changed = true;
}
else
{
- setVersioning( versioning );
- changed = true;
+ if ( snapshot.getTimestamp() != null && !snapshot.getTimestamp().equals( s.getTimestamp() ) )
+ {
+ s.setTimestamp( snapshot.getTimestamp() );
+ changed = true;
+ }
+ if ( snapshot.getBuildNumber() > 0 && s.getBuildNumber() != snapshot.getBuildNumber() )
+ {
+ s.setBuildNumber( snapshot.getBuildNumber() );
+ changed = true;
+ }
+ if ( s.isLocalCopy() )
+ {
+ s.setLocalCopy( false );
+ changed = true;
+ }
}
}
- return changed;
}
+ }
+ return changed;
+ }
]]>
@@ -194,7 +208,27 @@
*
+
+ lastUpdated
+ 1.0.0
+ String
+ When the metadata was last updated
+
+
+
+ 1.0.0
+
+ public void updateTimestamp()
+ {
+ java.util.TimeZone timezone = java.util.TimeZone.getTimeZone( "UTC" );
+ java.text.DateFormat fmt = new java.text.SimpleDateFormat( "yyyyMMddHHmmss" );
+ fmt.setTimeZone( timezone );
+ setLastUpdated( fmt.format( new java.util.Date() ) );
+ }
+
+
+
Snapshot