remove legacy metadata handling

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@292155 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-28 09:57:10 +00:00
parent 7773aa4d40
commit 3c8a171004
10 changed files with 23 additions and 775 deletions

View File

@ -69,7 +69,7 @@ public class DefaultWagonManager
private Map mirrors = new HashMap();
private TransferListener downloadMonitor;
private boolean online = true;
public Wagon getWagon( String protocol )
@ -108,7 +108,7 @@ public class DefaultWagonManager
throws TransferFailedException
{
failIfNotOnline();
String protocol = repository.getProtocol();
Wagon wagon;
@ -281,9 +281,9 @@ public class DefaultWagonManager
throws TransferFailedException, ResourceDoesNotExistException, ChecksumFailedException
{
// TODO: better excetpions - transfer failed is not enough?
failIfNotOnline();
Wagon wagon;
ArtifactRepository mirror = getMirror( repository.getId() );
@ -329,7 +329,6 @@ public class DefaultWagonManager
try
{
wagon.connect( new Repository( repository.getId(), repository.getUrl() ),
getAuthenticationInfo( repository.getId() ), getProxy( protocol ) );
@ -460,7 +459,8 @@ public class DefaultWagonManager
}
}
private void failIfNotOnline() throws TransferFailedException
private void failIfNotOnline()
throws TransferFailedException
{
if ( !isOnline() )
{
@ -659,7 +659,7 @@ public class DefaultWagonManager
{
this.online = online;
}
public boolean isOnline()
{
return online;

View File

@ -1,123 +0,0 @@
package org.apache.maven.artifact.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.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.Date;
/**
* Base version artifact metadata.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public abstract class AbstractVersionArtifactMetadata
extends AbstractArtifactMetadata
implements LegacyArtifactMetadata
{
protected static final String SNAPSHOT_VERSION_FILE = "version.txt";
protected long lastModified;
public AbstractVersionArtifactMetadata( Artifact artifact )
{
super( artifact );
}
public void readFromFile( File file )
throws IOException
{
setContent( FileUtils.fileRead( file ) );
lastModified = file.lastModified();
}
protected abstract void setContent( String content );
public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager,
String checksumPolicy )
throws ArtifactMetadataRetrievalException, ResourceDoesNotExistException
{
try
{
// TODO: shouldn't need a file intermediatary - improve wagon to take a stream
File destination = File.createTempFile( "maven-artifact", null );
destination.deleteOnExit();
wagonManager.getArtifactMetadata( this, remoteRepository, destination, checksumPolicy );
readFromFile( destination );
}
catch ( TransferFailedException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
}
catch ( IOException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
}
}
public void storeInLocalRepository( ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{
String version = constructVersion();
if ( version != null )
{
try
{
File file = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( this, null ) );
file.getParentFile().mkdirs();
FileUtils.fileWrite( file.getPath(), version );
lastModified = file.lastModified();
}
catch ( IOException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
}
}
}
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException
{
throw new IllegalStateException( "This code should no longer be called" );
}
public Date getLastModified()
{
return new Date( lastModified );
}
public Object getKey()
{
return "legacy " + artifact.getGroupId() + ":" + artifact.getArtifactId();
}
public void merge( ArtifactMetadata metadata )
{
throw new IllegalStateException( "Cannot add two pieces of metadata for: " + getKey() );
}
}

View File

@ -1,108 +0,0 @@
package org.apache.maven.artifact.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 java.io.File;
public class LatestArtifactMetadata
extends AbstractVersionArtifactMetadata
{
private String version;
public LatestArtifactMetadata( Artifact artifact )
{
super( artifact );
}
public String getRemoteFilename()
{
return getFilename();
}
public String getLocalFilename( ArtifactRepository repository )
{
return getFilename();
}
private String getFilename()
{
return artifact.getArtifactId() + "-" + Artifact.LATEST_VERSION + "." + SNAPSHOT_VERSION_FILE;
}
public String constructVersion()
{
return version;
}
public int compareTo( Object o )
{
LatestArtifactMetadata metadata = (LatestArtifactMetadata) o;
if ( version == null )
{
if ( metadata.version == null )
{
return 0;
}
else
{
return -1;
}
}
else
{
if ( metadata.version == null )
{
return 1;
}
else
{
return version.compareTo( metadata.version );
}
}
}
public boolean newerThanFile( File file )
{
long fileTime = file.lastModified();
return lastModified > fileTime;
}
public String toString()
{
return "latest-version information for " + artifact.getArtifactId();
}
protected void setContent( String content )
{
this.version = content.trim();
}
public String getBaseVersion()
{
return Artifact.LATEST_VERSION;
}
public boolean storedInArtifactVersionDirectory()
{
return false;
}
}

View File

@ -1,50 +0,0 @@
package org.apache.maven.artifact.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.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import java.io.File;
import java.io.IOException;
import java.util.Date;
/**
* Methods used by the old artifact metadata. To be removed in beta-2.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public interface LegacyArtifactMetadata
extends ArtifactMetadata, Comparable
{
void readFromFile( File file )
throws IOException;
void retrieveFromRemoteRepository( ArtifactRepository repository, WagonManager wagonManager, String checksumPolicy )
throws ArtifactMetadataRetrievalException, ResourceDoesNotExistException;
void storeInLocalRepository( ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException;
boolean newerThanFile( File file );
String constructVersion();
Date getLastModified();
}

View File

@ -1,115 +0,0 @@
package org.apache.maven.artifact.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.transform.ReleaseArtifactTransformation;
import java.io.File;
/**
* Contains the information stored for a release.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class ReleaseArtifactMetadata
extends AbstractVersionArtifactMetadata
{
private String version;
public ReleaseArtifactMetadata( Artifact artifact )
{
super( artifact );
}
public String getRemoteFilename()
{
return getFilename();
}
public String getLocalFilename( ArtifactRepository repository )
{
return getFilename();
}
private String getFilename()
{
return artifact.getArtifactId() + "-RELEASE." + SNAPSHOT_VERSION_FILE;
}
public String constructVersion()
{
return version;
}
public int compareTo( Object o )
{
ReleaseArtifactMetadata metadata = (ReleaseArtifactMetadata) o;
if ( version == null )
{
if ( metadata.version == null )
{
return 0;
}
else
{
return -1;
}
}
else
{
if ( metadata.version == null )
{
return 1;
}
else
{
return version.compareTo( metadata.version );
}
}
}
public boolean newerThanFile( File file )
{
long fileTime = file.lastModified();
return lastModified > fileTime;
}
public String toString()
{
return "release information for " + artifact.getArtifactId();
}
protected void setContent( String content )
{
this.version = content.trim();
}
public String getBaseVersion()
{
return ReleaseArtifactTransformation.RELEASE_VERSION;
}
public boolean storedInArtifactVersionDirectory()
{
return false;
}
}

View File

@ -1,172 +0,0 @@
package org.apache.maven.artifact.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.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.regex.Matcher;
/**
* Contains the information stored for a snapshot.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class SnapshotArtifactMetadata
extends AbstractVersionArtifactMetadata
{
private String timestamp;
private int buildNumber;
private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
private static final String UTC_TIMESTAMP_PATTERN = "yyyyMMdd.HHmmss";
public SnapshotArtifactMetadata( Artifact artifact )
{
super( artifact );
}
public String getRemoteFilename()
{
return getFilename();
}
public String getLocalFilename( ArtifactRepository repository )
{
return getFilename();
}
private String getFilename()
{
return artifact.getArtifactId() + "-" + artifact.getBaseVersion() + "." + SNAPSHOT_VERSION_FILE;
}
public String constructVersion()
{
String version = artifact.getBaseVersion();
if ( timestamp != null && buildNumber > 0 )
{
String newVersion = timestamp + "-" + buildNumber;
if ( version != null )
{
version = StringUtils.replace( version, "SNAPSHOT", newVersion );
}
else
{
version = newVersion;
}
}
return version;
}
protected void setContent( String content )
{
Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( content.trim() );
if ( matcher.matches() )
{
timestamp = matcher.group( 2 );
buildNumber = Integer.valueOf( matcher.group( 3 ) ).intValue();
}
else
{
timestamp = null;
buildNumber = 0;
}
}
public int getBuildNumber()
{
return buildNumber;
}
public static DateFormat getUtcDateFormatter()
{
DateFormat utcDateFormatter = new SimpleDateFormat( UTC_TIMESTAMP_PATTERN );
utcDateFormatter.setTimeZone( UTC_TIME_ZONE );
return utcDateFormatter;
}
public int compareTo( Object o )
{
SnapshotArtifactMetadata metadata = (SnapshotArtifactMetadata) o;
if ( buildNumber > metadata.buildNumber )
{
return 1;
}
else if ( timestamp == null )
{
if ( metadata.timestamp == null )
{
return 0;
}
else
{
return -1;
}
}
else if ( metadata.timestamp == null )
{
return 1;
}
else
{
return timestamp.compareTo( metadata.timestamp );
}
}
public boolean newerThanFile( File file )
{
long fileTime = file.lastModified();
// previous behaviour - compare based on timestamp of file
// problem was that version.txt is often updated even if the remote snapshot was not
// return ( lastModified > fileTime );
// Compare to timestamp
if ( timestamp != null )
{
String fileTimestamp = getUtcDateFormatter().format( new Date( fileTime ) );
return fileTimestamp.compareTo( timestamp ) < 0;
}
return false;
}
public String toString()
{
return "snapshot information for " + artifact.getArtifactId() + " " + artifact.getBaseVersion();
}
public boolean storedInArtifactVersionDirectory()
{
return true;
}
public String getBaseVersion()
{
return artifact.getBaseVersion();
}
}

View File

@ -19,24 +19,16 @@ package org.apache.maven.artifact.transform;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.LegacyArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
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.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* Describes a version transformation during artifact resolution.
@ -53,11 +45,6 @@ public abstract class AbstractVersionTransformation
protected WagonManager wagonManager;
/**
* @todo remove in beta-2 - used for legacy handling
*/
private static Set resolvedArtifactCache = new HashSet();
protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
throws ArtifactMetadataRetrievalException
{
@ -83,11 +70,8 @@ public abstract class AbstractVersionTransformation
if ( version == null )
{
version = resolveLegacyVersion( artifact, localRepository, remoteRepositories );
if ( version == null )
{
version = artifact.getBaseVersion();
}
// use the local copy, or if it doesn't exist - go to the remote repo for it
version = artifact.getBaseVersion();
}
// TODO: also do this logging for other metadata?
@ -117,145 +101,4 @@ public abstract class AbstractVersionTransformation
}
protected abstract String constructVersion( Versioning versioning, String baseVersion );
/**
* @todo remove in beta-2 - used for legacy handling
*/
private String resolveLegacyVersion( Artifact artifact, ArtifactRepository localRepository,
List remoteRepositories )
throws ArtifactMetadataRetrievalException
{
LegacyArtifactMetadata localMetadata = createLegacyMetadata( artifact );
File f = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( localMetadata, null ) );
if ( f.exists() )
{
try
{
localMetadata.readFromFile( f );
}
catch ( IOException e )
{
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
}
}
else
{
localMetadata = null;
}
boolean alreadyResolved = alreadyResolved( artifact );
if ( !alreadyResolved )
{
if ( !wagonManager.isOnline() )
{
LegacyArtifactMetadata metadata = createLegacyMetadata( artifact );
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(); )
{
ArtifactRepository repository = (ArtifactRepository) i.next();
ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots()
: repository.getReleases();
if ( !policy.isEnabled() )
{
getLogger().debug( "Legacy metadata: " + artifact.getId() + ": Skipping disabled repository " +
repository.getId() + " (" + repository.getUrl() + ")" );
}
else
{
boolean checkForUpdates = localMetadata == null ||
policy.checkOutOfDate( localMetadata.getLastModified() );
if ( checkForUpdates )
{
checkedUpdates = true;
LegacyArtifactMetadata remoteMetadata;
try
{
remoteMetadata = createLegacyMetadata( artifact );
remoteMetadata.retrieveFromRemoteRepository( repository, wagonManager,
policy.getChecksumPolicy() );
getLogger().warn( "Using old-style versioning metadata from remote repo for " + artifact );
if ( localMetadata == null || remoteMetadata.compareTo( localMetadata ) > 0 )
{
// remote is newer
artifact.setRepository( repository );
localMetadata = remoteMetadata;
getLogger().debug( "Found repository for the artifact." );
}
}
catch ( ResourceDoesNotExistException e )
{
getLogger().debug( "Legacy metadata for: " + artifact.getId() +
" could not be found on repository: " + repository.getId() );
}
catch ( ArtifactMetadataRetrievalException e )
{
getLogger().warn( "Legacy metadata for: " + artifact.getId() +
" could not be found on repository: " + repository.getId(), e );
}
}
else
{
getLogger().debug( "resolveMetaData: " + artifact.getId() + ": NOT checking for updates from " +
repository.getId() + " (" + repository.getUrl() + ")" );
}
}
}
// touch the file if it was checked for updates, but don't create it if it did't exist to avoid
// storing SNAPSHOT as the actual version which doesn't exist remotely.
if ( checkedUpdates && localMetadata != null && localMetadata.getLastModified().getTime() > 0 )
{
localMetadata.storeInLocalRepository( localRepository );
}
resolvedArtifactCache.add( getCacheKey( artifact ) );
}
if ( localMetadata != null && artifact.getFile().exists() &&
!localMetadata.newerThanFile( artifact.getFile() ) )
{
if ( getLogger().isDebugEnabled() && !alreadyResolved )
{
// Locally installed file is newer, don't use the resolved version
getLogger().debug( artifact.getArtifactId() + ": using locally installed snapshot" );
}
localMetadata = null;
}
return localMetadata != null ? localMetadata.constructVersion() : null;
}
protected abstract LegacyArtifactMetadata createLegacyMetadata( Artifact artifact );
/**
* @todo remove in beta-2 - used for legacy handling
*/
private boolean alreadyResolved( Artifact artifact )
{
return resolvedArtifactCache.contains( getCacheKey( artifact ) );
}
/**
* @todo remove in beta-2 - used for legacy handling
*/
private static String getCacheKey( Artifact artifact )
{
// No type - one per POM
return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getBaseVersion();
}
}

View File

@ -18,8 +18,6 @@ package org.apache.maven.artifact.transform;
import org.apache.maven.artifact.Artifact;
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.Versioning;
@ -55,11 +53,6 @@ public class LatestArtifactTransformation
// metadata is added via addPluginArtifactMetadata
}
protected LegacyArtifactMetadata createLegacyMetadata( Artifact artifact )
{
return new LatestArtifactMetadata( artifact );
}
protected String constructVersion( Versioning versioning, String baseVersion )
{
return versioning.getLatest();

View File

@ -19,8 +19,6 @@ 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 org.apache.maven.artifact.repository.metadata.Versioning;
@ -84,11 +82,6 @@ public class ReleaseArtifactTransformation
return new ArtifactRepositoryMetadata( artifact, versioning );
}
protected LegacyArtifactMetadata createLegacyMetadata( Artifact artifact )
{
return new ReleaseArtifactMetadata( artifact );
}
protected String constructVersion( Versioning versioning, String baseVersion )
{
return versioning.getRelease();

View File

@ -18,20 +18,19 @@ package org.apache.maven.artifact.transform;
import org.apache.maven.artifact.Artifact;
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.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Snapshot;
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.codehaus.plexus.util.StringUtils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
@ -44,6 +43,10 @@ public class SnapshotTransformation
{
private String deploymentTimestamp;
private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
private static final String UTC_TIMESTAMP_PATTERN = "yyyyMMdd.HHmmss";
public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException
{
@ -93,16 +96,11 @@ public class SnapshotTransformation
{
if ( deploymentTimestamp == null )
{
deploymentTimestamp = SnapshotArtifactMetadata.getUtcDateFormatter().format( new Date() );
deploymentTimestamp = getUtcDateFormatter().format( new Date() );
}
return deploymentTimestamp;
}
protected LegacyArtifactMetadata createLegacyMetadata( Artifact artifact )
{
return new SnapshotArtifactMetadata( artifact );
}
protected String constructVersion( Versioning versioning, String baseVersion )
{
String version = null;
@ -150,24 +148,13 @@ public class SnapshotTransformation
buildNumber = repoMetadata.getVersioning().getSnapshot().getBuildNumber();
}
}
else
{
try
{
SnapshotArtifactMetadata snapshotMetadata = new SnapshotArtifactMetadata( artifact );
snapshotMetadata.retrieveFromRemoteRepository( remoteRepository, wagonManager,
ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
getLogger().warn( "Using old-style versioning metadata from remote repo for " + artifact );
buildNumber = snapshotMetadata.getBuildNumber();
}
catch ( ResourceDoesNotExistException e1 )
{
// safe to ignore, use default snapshot data
getLogger().debug( "Unable to find legacy metadata - ignoring" );
}
}
return buildNumber;
}
public static DateFormat getUtcDateFormatter()
{
DateFormat utcDateFormatter = new SimpleDateFormat( UTC_TIMESTAMP_PATTERN );
utcDateFormatter.setTimeZone( UTC_TIME_ZONE );
return utcDateFormatter;
}
}