mirror of https://github.com/apache/maven.git
repair snapshot build numbering (previous code makes it get stuck at 1).
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@240405 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7572427594
commit
0481c45fc9
|
@ -63,6 +63,7 @@ public class MavenArchiver
|
|||
|
||||
Artifact projectArtifact = project.getArtifact();
|
||||
|
||||
/* TODO: rethink this, it wasn't working
|
||||
if ( projectArtifact.isSnapshot() )
|
||||
{
|
||||
Manifest.Attribute buildNumberAttr = new Manifest.Attribute( "Build-Number", "" +
|
||||
|
@ -70,6 +71,7 @@ public class MavenArchiver
|
|||
m.addConfiguredAttribute( buildNumberAttr );
|
||||
}
|
||||
|
||||
*/
|
||||
if ( config.getPackageName() != null )
|
||||
{
|
||||
Manifest.Attribute packageAttr = new Manifest.Attribute( "Package", config.getPackageName() );
|
||||
|
@ -231,7 +233,7 @@ public class MavenArchiver
|
|||
|
||||
if ( workingProject.getArtifact().isSnapshot() )
|
||||
{
|
||||
workingProject.setVersion( workingProject.getSnapshotDeploymentVersion() );
|
||||
workingProject.setVersion( workingProject.getArtifact().getVersion() );
|
||||
}
|
||||
|
||||
String groupId = workingProject.getGroupId();
|
||||
|
|
|
@ -12,7 +12,7 @@ public class DefaultArtifactTransformationManager
|
|||
{
|
||||
|
||||
private List artifactTransformations;
|
||||
|
||||
|
||||
private SnapshotTransformation snapshotTransformation;
|
||||
|
||||
public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||
|
@ -45,19 +45,4 @@ public class DefaultArtifactTransformationManager
|
|||
}
|
||||
}
|
||||
|
||||
public String getSnapshotDeploymentTimestamp()
|
||||
{
|
||||
return snapshotTransformation.getDeploymentTimestamp();
|
||||
}
|
||||
|
||||
public int getSnapshotDeploymentBuildNumber( Artifact artifact )
|
||||
{
|
||||
return snapshotTransformation.getDeploymentBuildNumber( artifact);
|
||||
}
|
||||
|
||||
public String getSnapshotDeploymentVersion( Artifact snapshotArtifact )
|
||||
{
|
||||
return snapshotTransformation.getDeploymentVersion( snapshotArtifact );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ package org.apache.maven.artifact.transform;
|
|||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
import org.apache.maven.artifact.metadata.AbstractVersionArtifactMetadata;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||
import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
|
||||
|
@ -26,9 +25,7 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
|||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
|
@ -41,10 +38,6 @@ public class SnapshotTransformation
|
|||
{
|
||||
private String deploymentTimestamp;
|
||||
|
||||
private int deploymentBuildNumber = 1;
|
||||
|
||||
private Map buildNumbers = new HashMap();
|
||||
|
||||
public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
|
@ -76,20 +69,17 @@ public class SnapshotTransformation
|
|||
{
|
||||
metadata = (SnapshotArtifactMetadata) retrieveFromRemoteRepository( artifact, remoteRepository, null,
|
||||
ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
|
||||
|
||||
updateDeploymentBuildNumber( artifact, metadata.getTimestamp(), metadata.getBuildNumber() );
|
||||
}
|
||||
catch ( ResourceDoesNotExistException e )
|
||||
{
|
||||
getLogger().debug(
|
||||
"Snapshot version metadata for: " + artifact.getId()
|
||||
+ " not found. Creating a new metadata instance.", e );
|
||||
|
||||
getLogger().debug( "Snapshot version metadata for: " + artifact.getId() +
|
||||
" not found. Creating a new metadata instance.", e );
|
||||
|
||||
// ignore. We'll be creating this metadata if it doesn't exist...
|
||||
metadata = (SnapshotArtifactMetadata) createMetadata( artifact );
|
||||
}
|
||||
|
||||
metadata.setVersion( getDeploymentTimestamp(), deploymentBuildNumber );
|
||||
metadata.setVersion( getDeploymentTimestamp(), metadata.getBuildNumber() + 1 );
|
||||
|
||||
artifact.setResolvedVersion( metadata.constructVersion() );
|
||||
|
||||
|
@ -97,24 +87,6 @@ public class SnapshotTransformation
|
|||
}
|
||||
}
|
||||
|
||||
private void updateDeploymentBuildNumber( Artifact artifact, String timestamp, int buildNumberFromMetadata )
|
||||
{
|
||||
// we only have to handle bumping the build number if we're on the same timestamp, somehow...miraculously
|
||||
if ( deploymentTimestamp.equals( timestamp ) )
|
||||
{
|
||||
String artifactKey = ArtifactUtils.versionlessKey( artifact );
|
||||
|
||||
Integer buildNum = (Integer) buildNumbers.get( artifactKey );
|
||||
|
||||
if ( buildNum == null || buildNum.intValue() <= buildNumberFromMetadata )
|
||||
{
|
||||
buildNum = new Integer( buildNumberFromMetadata + 1 );
|
||||
|
||||
buildNumbers.put( artifactKey, buildNum );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getDeploymentTimestamp()
|
||||
{
|
||||
if ( deploymentTimestamp == null )
|
||||
|
@ -123,36 +95,10 @@ public class SnapshotTransformation
|
|||
}
|
||||
return deploymentTimestamp;
|
||||
}
|
||||
|
||||
public int getDeploymentBuildNumber( Artifact artifact )
|
||||
{
|
||||
String artifactKey = ArtifactUtils.versionlessKey( artifact );
|
||||
|
||||
Integer buildNum = (Integer) buildNumbers.get( artifactKey );
|
||||
|
||||
if ( buildNum == null )
|
||||
{
|
||||
buildNum = new Integer( 1 );
|
||||
buildNumbers.put( artifactKey, buildNum );
|
||||
}
|
||||
|
||||
return buildNum.intValue();
|
||||
}
|
||||
|
||||
protected AbstractVersionArtifactMetadata createMetadata( Artifact artifact )
|
||||
{
|
||||
return new SnapshotArtifactMetadata( artifact );
|
||||
}
|
||||
|
||||
public String getDeploymentVersion( Artifact artifact )
|
||||
{
|
||||
int buildnum = getDeploymentBuildNumber( artifact );
|
||||
|
||||
SnapshotArtifactMetadata metadata = (SnapshotArtifactMetadata) createMetadata( artifact );
|
||||
|
||||
metadata.setVersion( getDeploymentTimestamp(), buildnum );
|
||||
|
||||
return metadata.constructVersion();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,30 @@
|
|||
package org.apache.maven.artifact.repository.metadata;
|
||||
|
||||
/*
|
||||
* Copyright 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 java.io.File;
|
||||
|
||||
public interface RepositoryMetadata
|
||||
{
|
||||
|
||||
|
||||
String getRepositoryPath();
|
||||
|
||||
|
||||
File getFile();
|
||||
|
||||
|
||||
void setFile( File file );
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,21 @@
|
|||
package org.apache.maven.artifact.transform;
|
||||
|
||||
/*
|
||||
* 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.metadata.ArtifactMetadataRetrievalException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
|
@ -44,19 +60,4 @@ public interface ArtifactTransformationManager
|
|||
void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository )
|
||||
throws ArtifactMetadataRetrievalException;
|
||||
|
||||
/**
|
||||
* Return the timestamp which will be used to deploy artifacts from this build.
|
||||
*/
|
||||
String getSnapshotDeploymentTimestamp();
|
||||
|
||||
/**
|
||||
* Return the buildnumber which will be used to deploy artifacts from this build.
|
||||
*/
|
||||
int getSnapshotDeploymentBuildNumber( Artifact snapshotArtifact );
|
||||
|
||||
/**
|
||||
* Return the artifact-version which will be used to deploy artifacts from this build.
|
||||
*/
|
||||
String getSnapshotDeploymentVersion( Artifact snapshotArtifact );
|
||||
|
||||
}
|
||||
|
|
|
@ -605,15 +605,6 @@ public class DefaultMavenProjectBuilder
|
|||
project.getVersion(), project.getPackaging() );
|
||||
project.setArtifact( projectArtifact );
|
||||
|
||||
if ( projectArtifact.isSnapshot() )
|
||||
{
|
||||
project.setSnapshotDeploymentVersion(
|
||||
transformationManager.getSnapshotDeploymentVersion( projectArtifact ) );
|
||||
|
||||
project.setSnapshotDeploymentBuildNumber(
|
||||
transformationManager.getSnapshotDeploymentBuildNumber( projectArtifact ) );
|
||||
}
|
||||
|
||||
project.setPluginArtifactRepositories( ProjectUtils.buildArtifactRepositories( model.getPluginRepositories(),
|
||||
artifactRepositoryFactory,
|
||||
container ) );
|
||||
|
|
|
@ -137,10 +137,6 @@ public class MavenProject
|
|||
|
||||
private Build buildOverlay;
|
||||
|
||||
private String snapshotDeploymentVersion;
|
||||
|
||||
private int snapshotDeploymentBuildNumber = -1;
|
||||
|
||||
public MavenProject( Model model )
|
||||
{
|
||||
this.model = model;
|
||||
|
@ -187,9 +183,6 @@ public class MavenProject
|
|||
this.originalModel = ModelUtils.cloneModel( project.originalModel );
|
||||
}
|
||||
|
||||
this.snapshotDeploymentVersion = project.snapshotDeploymentVersion;
|
||||
this.snapshotDeploymentBuildNumber = project.snapshotDeploymentBuildNumber;
|
||||
|
||||
// TODO: need to clone this too?
|
||||
this.artifact = project.artifact;
|
||||
}
|
||||
|
@ -481,7 +474,7 @@ public class MavenProject
|
|||
// {
|
||||
// list.add( a );
|
||||
// }
|
||||
|
||||
|
||||
list.add( a );
|
||||
}
|
||||
}
|
||||
|
@ -510,7 +503,7 @@ public class MavenProject
|
|||
// Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
|
||||
// {
|
||||
// }
|
||||
|
||||
|
||||
Dependency dependency = new Dependency();
|
||||
|
||||
dependency.setArtifactId( a.getArtifactId() );
|
||||
|
@ -1359,31 +1352,4 @@ public class MavenProject
|
|||
{
|
||||
}
|
||||
|
||||
public void setSnapshotDeploymentVersion( String deploymentVersion )
|
||||
{
|
||||
this.snapshotDeploymentVersion = deploymentVersion;
|
||||
}
|
||||
|
||||
public String getSnapshotDeploymentVersion()
|
||||
{
|
||||
if ( snapshotDeploymentVersion == null )
|
||||
{
|
||||
return getVersion();
|
||||
}
|
||||
else
|
||||
{
|
||||
return snapshotDeploymentVersion;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSnapshotDeploymentBuildNumber( int deploymentBuildNumber )
|
||||
{
|
||||
this.snapshotDeploymentBuildNumber = deploymentBuildNumber;
|
||||
}
|
||||
|
||||
public int getSnapshotDeploymentBuildNumber()
|
||||
{
|
||||
return snapshotDeploymentBuildNumber;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue