You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/04/26 10:49:53 UTC
svn commit: r397148 - in /maven/plugins/trunk/maven-release-plugin: ./
src/main/java/org/apache/maven/plugins/release/
src/main/java/org/apache/maven/plugins/release/config/
src/main/java/org/apache/maven/plugins/release/phase/
src/main/resources/META-...
Author: brett
Date: Wed Apr 26 01:49:51 2006
New Revision: 397148
URL: http://svn.apache.org/viewcvs?rev=397148&view=rev
Log:
[MRELEASE-98] mapping and input of dev/release versions
Added:
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/MapVersionsPhase.java (with props)
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.java (with props)
maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.xml (with props)
Modified:
maven/plugins/trunk/maven-release-plugin/pom.xml
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/DefaultReleaseManager.java
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStore.java
maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/config/ReleaseConfiguration.java
maven/plugins/trunk/maven-release-plugin/src/main/resources/META-INF/plexus/components.xml
maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java
maven/plugins/trunk/maven-release-plugin/src/test/resources/release.properties
Modified: maven/plugins/trunk/maven-release-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/pom.xml?rev=397148&r1=397147&r2=397148&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-release-plugin/pom.xml Wed Apr 26 01:49:51 2006
@@ -113,6 +113,13 @@
<build>
<plugins>
<plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<childDelegation>false</childDelegation>
Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/DefaultReleaseManager.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/DefaultReleaseManager.java?rev=397148&r1=397147&r2=397148&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/DefaultReleaseManager.java (original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/DefaultReleaseManager.java Wed Apr 26 01:49:51 2006
@@ -59,7 +59,7 @@
*/
private ReleaseConfigurationStore configStore;
- // TODO: config - release pom generation, interactive, tag, use edit mode
+ // TODO: config - tag
public void prepare( ReleaseConfiguration releaseConfiguration )
throws ReleaseExecutionException
@@ -80,10 +80,6 @@
{
config = releaseConfiguration;
}
-
- // TODO: move these to phases? Into the rewriting, or as a separate phase? Separate phase sounds best to be able to rearrange
- // - walk through modules, map out values, prompt as necessary - for development versions
- // - walk through modules, map out values, prompt as necessary - for release versions
// Later, it would be a good idea to introduce a proper workflow tool so that the release can be made up of a
// more flexible set of steps.
Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStore.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStore.java?rev=397148&r1=397147&r2=397148&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStore.java (original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStore.java Wed Apr 26 01:49:51 2006
@@ -26,6 +26,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.Map;
import java.util.Properties;
/**
@@ -83,6 +85,23 @@
releaseConfiguration.setPassphrase( properties.getProperty( "scm.passphrase" ) );
releaseConfiguration.setTagBase( properties.getProperty( "scm.tagBase" ) );
+ // boolean properties are not written to the properties file because the value from the caller is always used
+
+ for ( Iterator i = properties.keySet().iterator(); i.hasNext(); )
+ {
+ String property = (String) i.next();
+ if ( property.startsWith( "project.rel." ) )
+ {
+ releaseConfiguration.mapReleaseVersion( property.substring( "project.rel.".length() ),
+ properties.getProperty( property ) );
+ }
+ else if ( property.startsWith( "project.dev." ) )
+ {
+ releaseConfiguration.mapDevelopmentVersion( property.substring( "project.dev.".length() ),
+ properties.getProperty( property ) );
+ }
+ }
+
if ( mergeConfiguration != null )
{
releaseConfiguration.merge( mergeConfiguration );
@@ -102,6 +121,20 @@
properties.setProperty( "scm.privateKey", config.getPrivateKey() );
properties.setProperty( "scm.passphrase", config.getPassphrase() );
properties.setProperty( "scm.tagBase", config.getTagBase() );
+
+ // boolean properties are not written to the properties file because the value from the caller is always used
+
+ for ( Iterator i = config.getReleaseVersions().entrySet().iterator(); i.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ properties.setProperty( "project.rel." + entry.getKey(), (String) entry.getValue() );
+ }
+
+ for ( Iterator i = config.getDevelopmentVersions().entrySet().iterator(); i.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ properties.setProperty( "project.dev." + entry.getKey(), (String) entry.getValue() );
+ }
OutputStream outStream = null;
//noinspection OverlyBroadCatchBlock
Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/config/ReleaseConfiguration.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/config/ReleaseConfiguration.java?rev=397148&r1=397147&r2=397148&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/config/ReleaseConfiguration.java (original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/config/ReleaseConfiguration.java Wed Apr 26 01:49:51 2006
@@ -19,7 +19,10 @@
import org.apache.maven.settings.Settings;
import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* Configuration used for the release.
@@ -95,6 +98,32 @@
*/
private boolean generateReleasePoms;
+ /**
+ * Whether the release process is interactive and the release manager should be prompted to confirm values, or
+ * whether the defaults are used regardless.
+ */
+ private boolean interactive = true;
+
+ /**
+ * A map of projects to versions to use when releasing the given projects.
+ */
+ private Map releaseVersions = new HashMap();
+
+ /**
+ * A map of projects to versions to use when moving the given projects back into devlopment after release.
+ */
+ private Map developmentVersions = new HashMap();
+
+ public boolean isInteractive()
+ {
+ return interactive;
+ }
+
+ public void setInteractive( boolean interactive )
+ {
+ this.interactive = interactive;
+ }
+
public boolean isGenerateReleasePoms()
{
return generateReleasePoms;
@@ -225,6 +254,16 @@
this.generateReleasePoms = generateReleasePoms;
}
+ public Map getReleaseVersions()
+ {
+ return Collections.unmodifiableMap( releaseVersions );
+ }
+
+ public Map getDevelopmentVersions()
+ {
+ return Collections.unmodifiableMap( developmentVersions );
+ }
+
/**
* Merge two configurations together. All SCM settings are overridden by the merge configuration, as are the
* <code>settings</code> and <code>workingDirectory</code> fields. The <code>completedPhase</code> field is used as
@@ -245,6 +284,7 @@
this.useEditMode = mergeConfiguration.useEditMode;
this.addSchema = mergeConfiguration.addSchema;
this.generateReleasePoms = mergeConfiguration.generateReleasePoms;
+ this.interactive = mergeConfiguration.interactive;
// These must be overridden, as they are not stored
this.settings = mergeOverride( this.settings, mergeConfiguration.settings );
@@ -253,6 +293,8 @@
// Not overridden - not configured from caller
this.completedPhase = mergeDefault( this.completedPhase, mergeConfiguration.completedPhase );
+
+ // The version maps are never merged
}
private List mergeOverride( List thisValue, List mergeValue )
@@ -280,24 +322,6 @@
return thisValue != null ? thisValue : mergeValue;
}
- public int hashCode()
- {
- int result = completedPhase != null ? completedPhase.hashCode() : 0;
- result = 29 * result + ( settings != null ? settings.hashCode() : 0 );
- result = 29 * result + ( tagBase != null ? tagBase.hashCode() : 0 );
- result = 29 * result + ( username != null ? username.hashCode() : 0 );
- result = 29 * result + ( password != null ? password.hashCode() : 0 );
- result = 29 * result + ( url != null ? url.hashCode() : 0 );
- result = 29 * result + ( privateKey != null ? privateKey.hashCode() : 0 );
- result = 29 * result + ( passphrase != null ? passphrase.hashCode() : 0 );
- result = 29 * result + ( workingDirectory != null ? workingDirectory.hashCode() : 0 );
- result = 29 * result + ( reactorProjects != null ? reactorProjects.hashCode() : 0 );
- result = 29 * result + ( useEditMode ? 1 : 0 );
- result = 29 * result + ( addSchema ? 1 : 0 );
- result = 29 * result + ( generateReleasePoms ? 1 : 0 );
- return result;
- }
-
public boolean equals( Object obj )
{
if ( this == obj )
@@ -315,11 +339,15 @@
{
return false;
}
- if ( useEditMode != that.useEditMode )
+ if ( generateReleasePoms != that.generateReleasePoms )
{
return false;
}
- if ( generateReleasePoms != that.generateReleasePoms )
+ if ( interactive != that.interactive )
+ {
+ return false;
+ }
+ if ( useEditMode != that.useEditMode )
{
return false;
}
@@ -327,6 +355,11 @@
{
return false;
}
+ if ( developmentVersions != null ? !developmentVersions.equals( that.developmentVersions )
+ : that.developmentVersions != null )
+ {
+ return false;
+ }
if ( passphrase != null ? !passphrase.equals( that.passphrase ) : that.passphrase != null )
{
return false;
@@ -343,6 +376,10 @@
{
return false;
}
+ if ( releaseVersions != null ? !releaseVersions.equals( that.releaseVersions ) : that.releaseVersions != null )
+ {
+ return false;
+ }
if ( settings != null ? !settings.equals( that.settings ) : that.settings != null )
{
return false;
@@ -367,5 +404,52 @@
}
return true;
+ }
+
+ public int hashCode()
+ {
+ int result = completedPhase != null ? completedPhase.hashCode() : 0;
+ result = 29 * result + ( settings != null ? settings.hashCode() : 0 );
+ result = 29 * result + ( tagBase != null ? tagBase.hashCode() : 0 );
+ result = 29 * result + ( username != null ? username.hashCode() : 0 );
+ result = 29 * result + ( password != null ? password.hashCode() : 0 );
+ result = 29 * result + ( url != null ? url.hashCode() : 0 );
+ result = 29 * result + ( privateKey != null ? privateKey.hashCode() : 0 );
+ result = 29 * result + ( passphrase != null ? passphrase.hashCode() : 0 );
+ result = 29 * result + ( workingDirectory != null ? workingDirectory.hashCode() : 0 );
+ result = 29 * result + ( reactorProjects != null ? reactorProjects.hashCode() : 0 );
+ result = 29 * result + ( useEditMode ? 1 : 0 );
+ result = 29 * result + ( addSchema ? 1 : 0 );
+ result = 29 * result + ( generateReleasePoms ? 1 : 0 );
+ result = 29 * result + ( interactive ? 1 : 0 );
+ result = 29 * result + ( releaseVersions != null ? releaseVersions.hashCode() : 0 );
+ result = 29 * result + ( developmentVersions != null ? developmentVersions.hashCode() : 0 );
+ return result;
+ }
+
+ /**
+ * Map a given project to a specified version from when it is released.
+ *
+ * @param projectId the project's group and artifact ID
+ * @param nextVersion the version to map to
+ */
+ public void mapReleaseVersion( String projectId, String nextVersion )
+ {
+ assert !releaseVersions.containsKey( projectId );
+
+ releaseVersions.put( projectId, nextVersion );
+ }
+
+ /**
+ * Map a given project to a specified version from when it is incremented and placed back into development.
+ *
+ * @param projectId the project's group and artifact ID
+ * @param nextVersion the version to map to
+ */
+ public void mapDevelopmentVersion( String projectId, String nextVersion )
+ {
+ assert !developmentVersions.containsKey( projectId );
+
+ developmentVersions.put( projectId, nextVersion );
}
}
Added: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/MapVersionsPhase.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/MapVersionsPhase.java?rev=397148&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/MapVersionsPhase.java (added)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/MapVersionsPhase.java Wed Apr 26 01:49:51 2006
@@ -0,0 +1,136 @@
+package org.apache.maven.plugins.release.phase;
+
+/*
+ * Copyright 2005-2006 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.ArtifactUtils;
+import org.apache.maven.plugins.release.ReleaseExecutionException;
+import org.apache.maven.plugins.release.config.ReleaseConfiguration;
+import org.apache.maven.plugins.release.versions.DefaultVersionInfo;
+import org.apache.maven.plugins.release.versions.VersionInfo;
+import org.apache.maven.plugins.release.versions.VersionParseException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.components.interactivity.Prompter;
+import org.codehaus.plexus.components.interactivity.PrompterException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+import java.util.Iterator;
+
+/**
+ * Map projects to their new versions after release / into the next development cycle.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class MapVersionsPhase
+ extends AbstractLogEnabled
+ implements ReleasePhase
+{
+ /**
+ * Whether to convert to a snapshot or a release.
+ */
+ private boolean convertToSnapshot;
+
+ /**
+ * Component used to prompt for input.
+ */
+ private Prompter prompter;
+
+ void setPrompter( Prompter prompter )
+ {
+ this.prompter = prompter;
+ }
+
+ public void execute( ReleaseConfiguration releaseConfiguration )
+ throws ReleaseExecutionException
+ {
+ for ( Iterator i = releaseConfiguration.getReactorProjects().iterator(); i.hasNext(); )
+ {
+ MavenProject project = (MavenProject) i.next();
+
+ String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
+
+ VersionInfo version = null;
+ try
+ {
+ // TODO: make sure to test inherited version
+ version = new DefaultVersionInfo( project.getVersion() );
+ }
+ catch ( VersionParseException e )
+ {
+ String msg = "Error parsing version, cannot determine next version: " + e.getMessage();
+ if ( releaseConfiguration.isInteractive() )
+ {
+ getLogger().warn( msg );
+ getLogger().debug( e.getMessage(), e );
+ }
+ else
+ {
+ // cannot proceed without a next value in batch mode
+ throw new ReleaseExecutionException( msg, e );
+ }
+ }
+
+ try
+ {
+ if ( convertToSnapshot )
+ {
+ String nextVersion = null;
+ if ( version != null )
+ {
+ nextVersion = version.getNextVersion().getSnapshotVersionString();
+ }
+
+ if ( releaseConfiguration.isInteractive() )
+ {
+ nextVersion = prompter.prompt( "What is the new development version for \"" +
+ project.getName() + "\"? (" + projectId + ")", nextVersion );
+ }
+
+ releaseConfiguration.mapDevelopmentVersion( projectId, nextVersion );
+ }
+ else
+ {
+ String nextVersion = null;
+ if ( version != null )
+ {
+ nextVersion = version.getReleaseVersionString();
+ }
+
+ if ( releaseConfiguration.isInteractive() )
+ {
+ nextVersion = prompter.prompt(
+ "What is the release version for \"" + project.getName() + "\"? (" + projectId + ")",
+ nextVersion );
+ }
+
+ releaseConfiguration.mapReleaseVersion( projectId, nextVersion );
+ }
+ }
+ catch ( PrompterException e )
+ {
+ throw new ReleaseExecutionException( "Error reading version from input handler: " + e.getMessage(), e );
+ }
+ }
+ }
+
+ public void simulate( ReleaseConfiguration releaseConfiguration )
+ throws ReleaseExecutionException
+ {
+ // It makes no modifications, so simulate is the same as execute
+ execute( releaseConfiguration );
+ }
+
+}
Propchange: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/MapVersionsPhase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/phase/MapVersionsPhase.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugins/trunk/maven-release-plugin/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/resources/META-INF/plexus/components.xml?rev=397148&r1=397147&r2=397148&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/resources/META-INF/plexus/components.xml Wed Apr 26 01:49:51 2006
@@ -18,6 +18,8 @@
<configuration>
<phases>
<phase>check-poms</phase>
+ <phase>map-release-versions</phase>
+ <phase>map-development-versions</phase>
<phase>scm-check-modifications</phase>
<phase>check-dependency-snapshots</phase>
<phase>rewrite-poms-for-release</phase>
@@ -34,6 +36,32 @@
<role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
<role-hint>check-poms</role-hint>
<implementation>org.apache.maven.plugins.release.phase.CheckPomPhase</implementation>
+ </component>
+ <component>
+ <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
+ <role-hint>map-release-versions</role-hint>
+ <implementation>org.apache.maven.plugins.release.phase.MapVersionsPhase</implementation>
+ <configuration>
+ <convertToSnapshot>false</convertToSnapshot>
+ </configuration>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.components.interactivity.Prompter</role>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
+ <role-hint>map-development-versions</role-hint>
+ <implementation>org.apache.maven.plugins.release.phase.MapVersionsPhase</implementation>
+ <configuration>
+ <convertToSnapshot>true</convertToSnapshot>
+ </configuration>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.components.interactivity.Prompter</role>
+ </requirement>
+ </requirements>
</component>
<component>
<role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
Modified: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java?rev=397148&r1=397147&r2=397148&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java (original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/config/PropertiesReleaseConfigurationStoreTest.java Wed Apr 26 01:49:51 2006
@@ -19,6 +19,7 @@
import org.codehaus.plexus.PlexusTestCase;
import java.io.File;
+import java.util.Map;
/**
* Test the properties store.
@@ -53,6 +54,24 @@
assertEquals( "Expected tag base of 'tagBase'", "tagBase", config.getTagBase() );
assertNull( "Expected no workingDirectory", config.getWorkingDirectory() );
assertNull( "Expected no settings", config.getSettings() );
+ assertFalse( "Expected default generateReleasePoms", config.isGenerateReleasePoms() );
+ assertFalse( "Expected default useEditMode", config.isUseEditMode() );
+ assertTrue( "Expected default interactive", config.isInteractive() );
+ assertFalse( "Expected default addScema", config.isAddSchema() );
+
+ Map versions = config.getReleaseVersions();
+ assertEquals( "Expected 2 version mappings", 2, versions.size() );
+ assertTrue( "missing project mapping", versions.containsKey( "groupId:artifactId1" ) );
+ assertEquals( "Incorrect version mapping", "2.0", versions.get( "groupId:artifactId1" ) );
+ assertTrue( "missing project mapping", versions.containsKey( "groupId:artifactId2" ) );
+ assertEquals( "Incorrect version mapping", "3.0", versions.get( "groupId:artifactId2" ) );
+
+ versions = config.getDevelopmentVersions();
+ assertEquals( "Expected 2 version mappings", 2, versions.size() );
+ assertTrue( "missing project mapping", versions.containsKey( "groupId:artifactId1" ) );
+ assertEquals( "Incorrect version mapping", "2.1-SNAPSHOT", versions.get( "groupId:artifactId1" ) );
+ assertTrue( "missing project mapping", versions.containsKey( "groupId:artifactId2" ) );
+ assertEquals( "Incorrect version mapping", "3.0.1-SNAPSHOT", versions.get( "groupId:artifactId2" ) );
}
public void testReadFromEmptyFile()
@@ -109,14 +128,7 @@
assertFalse( "Check file doesn't exist", file.exists() );
store.setPropertiesFile( file );
- ReleaseConfiguration config = new ReleaseConfiguration();
- config.setCompletedPhase( "completed-phase-write" );
- config.setUrl( "url-write" );
- config.setUsername( "username-write" );
- config.setPassword( "password-write" );
- config.setPrivateKey( "private-key-write" );
- config.setPassphrase( "passphrase-write" );
- config.setTagBase( "tag-base" );
+ ReleaseConfiguration config = createReleaseConfigurationForWriting();
store.write( config );
@@ -132,6 +144,17 @@
assertTrue( "Check file already exists", file.exists() );
store.setPropertiesFile( file );
+ ReleaseConfiguration config = createReleaseConfigurationForWriting();
+
+ store.write( config );
+
+ ReleaseConfiguration rereadConfiguration = store.read();
+
+ assertEquals( "compare configuration", config, rereadConfiguration );
+ }
+
+ private ReleaseConfiguration createReleaseConfigurationForWriting()
+ {
ReleaseConfiguration config = new ReleaseConfiguration();
config.setCompletedPhase( "completed-phase-write" );
config.setUrl( "url-write" );
@@ -141,11 +164,10 @@
config.setPassphrase( "passphrase-write" );
config.setTagBase( "tag-base" );
- store.write( config );
+ config.mapReleaseVersion( "groupId:artifactId", "1.0" );
+ config.mapDevelopmentVersion( "groupId:artifactId", "1.1-SNAPSHOT" );
- ReleaseConfiguration rereadConfiguration = store.read();
-
- assertEquals( "compare configuration", config, rereadConfiguration );
+ return config;
}
private static void assertDefaultReleaseConfiguration( ReleaseConfiguration config )
@@ -160,6 +182,14 @@
assertNull( "Expected no workingDirectory", config.getWorkingDirectory() );
assertNull( "Expected no settings", config.getSettings() );
+
+ assertFalse( "Expected no generateReleasePoms", config.isGenerateReleasePoms() );
+ assertFalse( "Expected no useEditMode", config.isUseEditMode() );
+ assertTrue( "Expected default interactive", config.isInteractive() );
+ assertFalse( "Expected no addScema", config.isAddSchema() );
+
+ assertTrue( "Expected no release version mappings", config.getReleaseVersions().isEmpty() );
+ assertTrue( "Expected no dev version mappings", config.getDevelopmentVersions().isEmpty() );
}
public ReleaseConfiguration createMergeConfiguration()
Added: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.java?rev=397148&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.java (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.java Wed Apr 26 01:49:51 2006
@@ -0,0 +1,308 @@
+package org.apache.maven.plugins.release.phase;
+
+/*
+ * Copyright 2005-2006 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.model.Model;
+import org.apache.maven.plugins.release.ReleaseExecutionException;
+import org.apache.maven.plugins.release.config.ReleaseConfiguration;
+import org.apache.maven.plugins.release.versions.VersionParseException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.components.interactivity.Prompter;
+import org.codehaus.plexus.components.interactivity.PrompterException;
+import org.jmock.cglib.Mock;
+import org.jmock.core.constraint.IsAnything;
+import org.jmock.core.constraint.IsEqual;
+import org.jmock.core.constraint.IsNull;
+import org.jmock.core.matcher.InvokeOnceMatcher;
+import org.jmock.core.matcher.TestFailureMatcher;
+import org.jmock.core.stub.ReturnStub;
+import org.jmock.core.stub.ThrowStub;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Test the version mapping phase.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class MapVersionsPhaseTest
+ extends PlexusTestCase
+{
+ public void testMapReleaseVersionsInteractive()
+ throws Exception
+ {
+ MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, "test-map-release-versions" );
+
+ Mock mockPrompter = new Mock( Prompter.class );
+ mockPrompter.expects( new InvokeOnceMatcher() ).method( "prompt" ).with( new IsAnything(),
+ new IsEqual( "1.0" ) ).will(
+ new ReturnStub( "2.0" ) );
+ phase.setPrompter( (Prompter) mockPrompter.proxy() );
+
+ List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0-SNAPSHOT" ) );
+
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+
+ phase.execute( releaseConfiguration );
+
+ assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "2.0" ),
+ releaseConfiguration.getReleaseVersions() );
+
+ releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+
+ mockPrompter.reset();
+ mockPrompter.expects( new InvokeOnceMatcher() ).method( "prompt" ).with( new IsAnything(),
+ new IsEqual( "1.0" ) ).will(
+ new ReturnStub( "2.0" ) );
+
+ phase.simulate( releaseConfiguration );
+
+ assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "2.0" ),
+ releaseConfiguration.getReleaseVersions() );
+ }
+
+ public void testMapReleaseVersionsNonInteractive()
+ throws Exception
+ {
+ MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, "test-map-release-versions" );
+
+ Mock mockPrompter = new Mock( Prompter.class );
+ mockPrompter.expects( new TestFailureMatcher( "prompter should not be called" ) ).method( "prompt" );
+ phase.setPrompter( (Prompter) mockPrompter.proxy() );
+
+ List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0-SNAPSHOT" ) );
+
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+ releaseConfiguration.setInteractive( false );
+
+ phase.execute( releaseConfiguration );
+
+ assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "1.0" ),
+ releaseConfiguration.getReleaseVersions() );
+
+ mockPrompter.reset();
+ mockPrompter.expects( new TestFailureMatcher( "prompter should not be called" ) ).method( "prompt" );
+
+ releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+ releaseConfiguration.setInteractive( false );
+
+ phase.simulate( releaseConfiguration );
+
+ assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "1.0" ),
+ releaseConfiguration.getReleaseVersions() );
+ }
+
+ public void testMapDevVersionsInteractive()
+ throws Exception
+ {
+ MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, "test-map-development-versions" );
+
+ Mock mockPrompter = new Mock( Prompter.class );
+ mockPrompter.expects( new InvokeOnceMatcher() ).method( "prompt" ).with( new IsAnything(),
+ new IsEqual( "1.1-SNAPSHOT" ) ).will(
+ new ReturnStub( "2.0-SNAPSHOT" ) );
+ phase.setPrompter( (Prompter) mockPrompter.proxy() );
+
+ List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) );
+
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+
+ phase.execute( releaseConfiguration );
+
+ assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "2.0-SNAPSHOT" ),
+ releaseConfiguration.getDevelopmentVersions() );
+
+ releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+
+ mockPrompter.reset();
+ mockPrompter.expects( new InvokeOnceMatcher() ).method( "prompt" ).with( new IsAnything(),
+ new IsEqual( "1.1-SNAPSHOT" ) ).will(
+ new ReturnStub( "2.0-SNAPSHOT" ) );
+
+ phase.simulate( releaseConfiguration );
+
+ assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "2.0-SNAPSHOT" ),
+ releaseConfiguration.getDevelopmentVersions() );
+ }
+
+ public void testMapDevVersionsNonInteractive()
+ throws Exception
+ {
+ MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, "test-map-development-versions" );
+
+ Mock mockPrompter = new Mock( Prompter.class );
+ mockPrompter.expects( new TestFailureMatcher( "prompter should not be called" ) ).method( "prompt" );
+ phase.setPrompter( (Prompter) mockPrompter.proxy() );
+
+ List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) );
+
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+ releaseConfiguration.setInteractive( false );
+
+ phase.execute( releaseConfiguration );
+
+ assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "1.1-SNAPSHOT" ),
+ releaseConfiguration.getDevelopmentVersions() );
+
+ mockPrompter.reset();
+ mockPrompter.expects( new TestFailureMatcher( "prompter should not be called" ) ).method( "prompt" );
+
+ releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+ releaseConfiguration.setInteractive( false );
+
+ phase.simulate( releaseConfiguration );
+
+ assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "1.1-SNAPSHOT" ),
+ releaseConfiguration.getDevelopmentVersions() );
+ }
+
+ public void testPrompterException()
+ throws Exception
+ {
+ MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, "test-map-development-versions" );
+
+ Mock mockPrompter = new Mock( Prompter.class );
+ mockPrompter.expects( new InvokeOnceMatcher() ).method( "prompt" ).will(
+ new ThrowStub( new PrompterException( "..." ) ) );
+ phase.setPrompter( (Prompter) mockPrompter.proxy() );
+
+ List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) );
+
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+
+ try
+ {
+ phase.execute( releaseConfiguration );
+
+ fail( "Expected an exception" );
+ }
+ catch ( ReleaseExecutionException e )
+ {
+ assertEquals( "check cause", PrompterException.class, e.getCause().getClass() );
+ }
+
+ releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+
+ mockPrompter.reset();
+ mockPrompter.expects( new InvokeOnceMatcher() ).method( "prompt" ).will(
+ new ThrowStub( new PrompterException( "..." ) ) );
+
+ try
+ {
+ phase.simulate( releaseConfiguration );
+
+ fail( "Expected an exception" );
+ }
+ catch ( ReleaseExecutionException e )
+ {
+ assertEquals( "check cause", PrompterException.class, e.getCause().getClass() );
+ }
+ }
+
+ public void testInvalidVersionInteractive()
+ throws Exception
+ {
+ MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, "test-map-development-versions" );
+
+ Mock mockPrompter = new Mock( Prompter.class );
+ mockPrompter.expects( new InvokeOnceMatcher() ).method( "prompt" ).with( new IsAnything(), new IsNull() ).will(
+ new ReturnStub( "2.0-SNAPSHOT" ) );
+ phase.setPrompter( (Prompter) mockPrompter.proxy() );
+
+ List reactorProjects = Collections.singletonList( createProject( "artifactId", "foo" ) );
+
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+
+ phase.execute( releaseConfiguration );
+
+ assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "2.0-SNAPSHOT" ),
+ releaseConfiguration.getDevelopmentVersions() );
+
+ mockPrompter.reset();
+ mockPrompter.expects( new InvokeOnceMatcher() ).method( "prompt" ).with( new IsAnything(), new IsNull() ).will(
+ new ReturnStub( "2.0-SNAPSHOT" ) );
+
+ releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+
+ phase.simulate( releaseConfiguration );
+
+ assertEquals( "Check mapped versions", Collections.singletonMap( "groupId:artifactId", "2.0-SNAPSHOT" ),
+ releaseConfiguration.getDevelopmentVersions() );
+ }
+
+ public void testInvalidVersionNonInteractive()
+ throws Exception
+ {
+ MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.ROLE, "test-map-development-versions" );
+
+ List reactorProjects = Collections.singletonList( createProject( "artifactId", "foo" ) );
+
+ ReleaseConfiguration releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+ releaseConfiguration.setInteractive( false );
+
+ try
+ {
+ phase.execute( releaseConfiguration );
+
+ fail( "Expected an exception" );
+ }
+ catch ( ReleaseExecutionException e )
+ {
+ assertEquals( "check cause", VersionParseException.class, e.getCause().getClass() );
+ }
+
+ releaseConfiguration = new ReleaseConfiguration();
+ releaseConfiguration.setReactorProjects( reactorProjects );
+ releaseConfiguration.setInteractive( false );
+
+ try
+ {
+ phase.simulate( releaseConfiguration );
+
+ fail( "Expected an exception" );
+ }
+ catch ( ReleaseExecutionException e )
+ {
+ assertEquals( "check cause", VersionParseException.class, e.getCause().getClass() );
+ }
+ }
+
+ private static MavenProject createProject( String artifactId, String version )
+ {
+ Model model = new Model();
+ model.setGroupId( "groupId" );
+ model.setArtifactId( artifactId );
+ model.setVersion( version );
+ return new MavenProject( model );
+ }
+
+}
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/java/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.xml?rev=397148&view=auto
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.xml (added)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.xml Wed Apr 26 01:49:51 2006
@@ -0,0 +1,36 @@
+<!--
+ ~ Copyright 2005-2006 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.
+ -->
+
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
+ <role-hint>test-map-development-versions</role-hint>
+ <implementation>org.apache.maven.plugins.release.phase.MapVersionsPhase</implementation>
+ <configuration>
+ <convertToSnapshot>true</convertToSnapshot>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.plugins.release.phase.ReleasePhase</role>
+ <role-hint>test-map-release-versions</role-hint>
+ <implementation>org.apache.maven.plugins.release.phase.MapVersionsPhase</implementation>
+ <configuration>
+ <convertToSnapshot>false</convertToSnapshot>
+ </configuration>
+ </component>
+ </components>
+</component-set>
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-release-plugin/src/test/resources/org/apache/maven/plugins/release/phase/MapVersionsPhaseTest.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugins/trunk/maven-release-plugin/src/test/resources/release.properties
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/test/resources/release.properties?rev=397148&r1=397147&r2=397148&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/test/resources/release.properties (original)
+++ maven/plugins/trunk/maven-release-plugin/src/test/resources/release.properties Wed Apr 26 01:49:51 2006
@@ -21,3 +21,8 @@
scm.privateKey=private-key
scm.passphrase=passphrase
scm.tagBase=tagBase
+
+project.rel.groupId\:artifactId1=2.0
+project.rel.groupId\:artifactId2=3.0
+project.dev.groupId\:artifactId1=2.1-SNAPSHOT
+project.dev.groupId\:artifactId2=3.0.1-SNAPSHOT