You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2004/02/25 23:34:46 UTC

cvs commit: maven-plugins/release/xdocs changes.xml

brett       2004/02/25 14:34:46

  Modified:    release  plugin.jelly
               release/src/main/org/apache/maven/release
                        AbstractPomTransformer.java
               release/src/main/org/apache/maven/release/jelly
                        ReleaseTagLibrary.java
               release/xdocs changes.xml
  Added:       release/src/main/org/apache/maven/release
                        VersionTransformer.java
               release/src/main/org/apache/maven/release/jelly
                        VersionTransformerTag.java
               release/src/test/org/apache/maven/release
                        VersionTransformerTest.java
               release/src/test-data test-pom-no-versions.xml
                        test-pom-versions-correct.xml
                        test-pom-versions-multiple.xml
                        test-pom-versions-overwrite.xml
                        test-pom-versions-tag-match-only.xml
                        test-pom-versions-wrong-order.xml
                        test-pom-versions.xml
  Log:
  transformations for releasing projects that update versions
  
  Revision  Changes    Path
  1.20      +23 -0     maven-plugins/release/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/maven-plugins/release/plugin.jelly,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- plugin.jelly	17 Oct 2003 22:21:41 -0000	1.19
  +++ plugin.jelly	25 Feb 2004 22:34:46 -0000	1.20
  @@ -3,6 +3,7 @@
   <project
     xmlns:ant="jelly:ant"
     xmlns:archive="release:archive"
  +  xmlns:transform="release:transform"
     xmlns:define="jelly:define"
     xmlns:deploy="deploy"
     xmlns:maven="jelly:maven"
  @@ -98,6 +99,28 @@
   	      	  siteCommand="cd @deployDirectory@; chmod g+w ${name}; chgrp ${maven.remote.group} ${name}"/>
           </define:tag>
       </define:taglib>
  +
  +    <define:taglib uri="release:transform">
  +      <define:tag name="release-version">
  +        <r:release-version
  +          version="${version}"
  +          tag="${tag}"
  +          transformer="transformer"
  +          transformations="transformations"/>
  +        <j:set var="required" value="${transformer.transformRequired()}" />
  +        <j:if test="${required}">
  +          <ant:echo>Updating POM with version ${version}; tag ${tag}</ant:echo>
  +          ${transformer.transformNodes()}
  +          ${transformer.write()}
  +        </j:if>
  +      </define:tag>
  +    </define:taglib>
  +
  +  <goal name="release:update-pom">
  +    <transform:release-version
  +      version="${version}"
  +      tag="${tag}" />
  +  </goal>
   
     <!--
      |
  
  
  
  1.9       +1 -18     maven-plugins/release/src/main/org/apache/maven/release/AbstractPomTransformer.java
  
  Index: AbstractPomTransformer.java
  ===================================================================
  RCS file: /home/cvs/maven-plugins/release/src/main/org/apache/maven/release/AbstractPomTransformer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractPomTransformer.java	12 Apr 2003 08:12:46 -0000	1.8
  +++ AbstractPomTransformer.java	25 Feb 2004 22:34:46 -0000	1.9
  @@ -285,23 +285,6 @@
       public abstract String selectNodesXPathExpression();
   
       /**
  -     * The XPath expression returned will select the single node
  -     * within the single node which needs to be transformed.
  -     *
  -     * @return
  -     */
  -    public abstract String selectNodeXPath();
  -
  -    /**
  -     *
  -     * @param node
  -     * @return
  -     * @throws Exception
  -     */
  -    public abstract String getNodeContent( Node node )
  -        throws Exception;
  -
  -    /**
        *
        * @param node
        * @throws Exception
  
  
  
  1.1                  maven-plugins/release/src/main/org/apache/maven/release/VersionTransformer.java
  
  Index: VersionTransformer.java
  ===================================================================
  package org.apache.maven.release;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  import org.apache.commons.io.FileUtils;
  import org.apache.maven.MavenConstants;
  import org.apache.maven.project.Project;
  import org.apache.maven.util.HttpUtils;
  import org.dom4j.Element;
  import org.dom4j.Node;
  
  import java.io.File;
  import java.util.Iterator;
  
  /**
   *
   *
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   *
   * @version $Id: VersionTransformer.java,v 1.1 2004/02/25 22:34:46 brett Exp $
   */
  public class VersionTransformer
      extends AbstractPomTransformer
  {
      private String version;
      private String tag;
  
      public VersionTransformer( String version, String tag )
      {
          this.version = version;
          this.tag = tag;
      }
  
      // -------------------------------------------------------------------------
      // Accessors
      // -------------------------------------------------------------------------
  
      public String selectNodesXPathExpression()
      {
          return "/project";
      }
  
      public void transformNode( Node node )
          throws Exception
      {
          Node currentVersion = node.selectSingleNode( "currentVersion" );
          currentVersion.setText( version );
  
          Node version = node.selectSingleNode( "versions/version[tag='" + tag + "']" );
          if ( version != null )
          {
              // tag exists - overwrite
              version.selectSingleNode( "id" ).setText( this.version );
              version.selectSingleNode( "name" ).setText( this.version );
          }
          else
          {
              // tag doesn't exist - add
              Element project = ( Element ) node;
              Element versions = ( Element ) project.selectSingleNode( "versions" );
              if ( versions == null )
              {
                  versions = project.addElement( "versions" );
              }
              Element v = versions.addElement( "version" );
              v.addElement( "id" ).addText( this.version );
              v.addElement( "name" ).addText( this.version );
              v.addElement( "tag" ).addText( tag );
          }
      }
  
      public Node getTransformedNode( Node node )
          throws Exception
      {
          throw new UnsupportedOperationException( "getTransformedNode not implemented" );
      }
  
      public boolean transformRequired()
      {
          Node node = ( Node ) getSelectedNodes().get( 0 );
          Node currentVersion = node.selectSingleNode( "currentVersion" );
          if ( !currentVersion.getText().equals( version ))
          {
              return true;
          }
  
          
          Node v = node.selectSingleNode( "versions/version[tag='" + tag + "' and id='" + version + "' and name='" + version + "']" );
          return ( v == null );
      }
  }
  
  
  
  1.4       +2 -1      maven-plugins/release/src/main/org/apache/maven/release/jelly/ReleaseTagLibrary.java
  
  Index: ReleaseTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/maven-plugins/release/src/main/org/apache/maven/release/jelly/ReleaseTagLibrary.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ReleaseTagLibrary.java	11 Feb 2003 22:01:13 -0000	1.3
  +++ ReleaseTagLibrary.java	25 Feb 2004 22:34:46 -0000	1.4
  @@ -19,5 +19,6 @@
       {
           registerTag( "resolve-snapshots", ResolveSnapshotsTag.class );
           registerTag( "increment-snapshot-version", SnapshotVersionTransformerTag.class );
  +        registerTag( "release-version", VersionTransformerTag.class );
       }
   }
  
  
  
  1.1                  maven-plugins/release/src/main/org/apache/maven/release/jelly/VersionTransformerTag.java
  
  Index: VersionTransformerTag.java
  ===================================================================
  package org.apache.maven.release.jelly;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  import org.apache.commons.jelly.JellyTagException;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.maven.MavenConstants;
  import org.apache.maven.project.Project;
  import org.apache.maven.release.VersionTransformer;
  
  public class VersionTransformerTag
      extends AbstractTransformerTag
  {
      private VersionTransformer transformer;
  
      private String version;
  
      private String tag;
  
      public String getVersion()
      {
          return this.version;
      }
  
      public void setVersion( String version )
      {
          this.version = version;
      }
  
      public String getTag()
      {
          return this.tag;
      }
  
      public void setTag( String tag )
      {
          this.tag = tag;
      }
  
      public void doTag( XMLOutput output )
          throws JellyTagException
      {
          Project project = (Project) context.getVariable( MavenConstants.MAVEN_POM );
  
          transformer = new VersionTransformer( version, tag );
          transformer.setProject( project.getFile() );
          transformer.setVariables( project.getContext().getVariables() );
          transformer.setOutputFile( project.getFile() );
  
          context.setVariable( getTransformer(), transformer );
          context.setVariable( getTransformations(), transformer.getTransformations() );
      }
  }
  
  
  
  1.1                  maven-plugins/release/src/test/org/apache/maven/release/VersionTransformerTest.java
  
  Index: VersionTransformerTest.java
  ===================================================================
  package org.apache.maven.release;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import junit.framework.TestCase;
  
  import java.io.File;
  
  import java.util.List;
  
  import org.dom4j.Node;
  
  /**
   */
  public class VersionTransformerTest
      extends TestCase
  {
      /**
       * Constructor.
       *
       * @param name Name of the test.
       */
      public VersionTransformerTest( String name )
      {
          super( name );
      }
  
      public void testNoVersions()
          throws Exception
      {
          VersionTransformer vt = new VersionTransformer( "1.2", "TEST_1_2" );
          vt.setProject( new File( System.getProperty( "basedir" ), "/src/test-data/test-pom-no-versions.xml" ) );
  
          assertTrue( "check transform required", vt.transformRequired() );
  
          vt.transformNodes();
          vt.write();
  
          List nodes = vt.getDocument().selectNodes( "/project" );
  
          assertEquals( 1, nodes.size() );
  
          Node project = ( Node ) nodes.get( 0 );
  
          assertEquals( "Check currentVersion is 1.2", "1.2", project.selectSingleNode( "currentVersion" ).getText() );
  
          List versionNodes = project.selectNodes( "versions/version" );
  
          assertEquals( "Check # versions is 1", 1, versionNodes.size() );
  
          Node version = ( Node ) versionNodes.get( 0 );
  
          assertEquals( "Check version id is 1.2", "1.2", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.2", "1.2", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_2", "TEST_1_2", version.selectSingleNode( "tag" ).getText() );
      }
  
      public void testOneVersion()
          throws Exception
      {
          VersionTransformer vt = new VersionTransformer( "1.2", "TEST_1_2" );
          vt.setProject( new File( System.getProperty( "basedir" ), "/src/test-data/test-pom-versions.xml" ) );
  
          assertTrue( "check transform required", vt.transformRequired() );
  
          vt.transformNodes();
          vt.write();
  
          List nodes = vt.getDocument().selectNodes( "/project" );
  
          assertEquals( 1, nodes.size() );
  
          Node project = ( Node ) nodes.get( 0 );
  
          assertEquals( "Check currentVersion is 1.2", "1.2", project.selectSingleNode( "currentVersion" ).getText() );
  
          List versionNodes = project.selectNodes( "versions/version" );
  
          assertEquals( "Check # versions is 2", 2, versionNodes.size() );
  
          Node version = ( Node ) versionNodes.get( 0 );
  
          assertEquals( "Check version id is 1.1", "1.1", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.1", "1.1", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_1", "TEST_1_1", version.selectSingleNode( "tag" ).getText() );
  
          version = ( Node ) versionNodes.get( 1 );
  
          assertEquals( "Check version id is 1.2", "1.2", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.2", "1.2", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_2", "TEST_1_2", version.selectSingleNode( "tag" ).getText() );
      }
  
      public void testMultipleVersions()
          throws Exception
      {
          VersionTransformer vt = new VersionTransformer( "1.2", "TEST_1_2" );
          vt.setProject( new File( System.getProperty( "basedir" ), "/src/test-data/test-pom-versions-multiple.xml" ) );
  
          assertTrue( "check transform required", vt.transformRequired() );
  
          vt.transformNodes();
          vt.write();
  
          List nodes = vt.getDocument().selectNodes( "/project" );
  
          assertEquals( 1, nodes.size() );
  
          Node project = ( Node ) nodes.get( 0 );
  
          assertEquals( "Check currentVersion is 1.2", "1.2", project.selectSingleNode( "currentVersion" ).getText() );
  
          List versionNodes = project.selectNodes( "versions/version" );
  
          assertEquals( "Check # versions is 3", 3, versionNodes.size() );
  
          Node version = ( Node ) versionNodes.get( 0 );
  
          assertEquals( "Check version id is 1.0", "1.0", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.0", "1.0", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_0", "TEST_1_0", version.selectSingleNode( "tag" ).getText() );
  
          version = ( Node ) versionNodes.get( 1 );
  
          assertEquals( "Check version id is 1.1", "1.1", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.1", "1.1", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_1", "TEST_1_1", version.selectSingleNode( "tag" ).getText() );
  
          version = ( Node ) versionNodes.get( 2 );
  
          assertEquals( "Check version id is 1.2", "1.2", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.2", "1.2", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_2", "TEST_1_2", version.selectSingleNode( "tag" ).getText() );
      }
  
      public void testMultipleVersionsWrongOrder()
          throws Exception
      {
          VersionTransformer vt = new VersionTransformer( "1.2", "TEST_1_2" );
          vt.setProject( new File( System.getProperty( "basedir" ), "/src/test-data/test-pom-versions-wrong-order.xml" ) );
  
          assertTrue( "check transform required", vt.transformRequired() );
  
          vt.transformNodes();
          vt.write();
  
          List nodes = vt.getDocument().selectNodes( "/project" );
  
          assertEquals( 1, nodes.size() );
  
          Node project = ( Node ) nodes.get( 0 );
  
          assertEquals( "Check currentVersion is 1.2", "1.2", project.selectSingleNode( "currentVersion" ).getText() );
  
          List versionNodes = project.selectNodes( "versions/version" );
  
          assertEquals( "Check # versions is 3", 3, versionNodes.size() );
  
          Node version = ( Node ) versionNodes.get( 0 );
  
          assertEquals( "Check version id is 1.1", "1.1", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.1", "1.1", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_1", "TEST_1_1", version.selectSingleNode( "tag" ).getText() );
  
          version = ( Node ) versionNodes.get( 1 );
  
          assertEquals( "Check version id is 1.0", "1.0", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.0", "1.0", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_0", "TEST_1_0", version.selectSingleNode( "tag" ).getText() );
  
          version = ( Node ) versionNodes.get( 2 );
  
          assertEquals( "Check version id is 1.2", "1.2", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.2", "1.2", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_2", "TEST_1_2", version.selectSingleNode( "tag" ).getText() );
      }
  
      public void testVersionsOverwrite()
          throws Exception
      {
          VersionTransformer vt = new VersionTransformer( "1.2", "TEST_1_2" );
          vt.setProject( new File( System.getProperty( "basedir" ), "/src/test-data/test-pom-versions-overwrite.xml" ) );
  
          assertTrue( "check transform required", vt.transformRequired() );
  
          vt.transformNodes();
          vt.write();
  
          List nodes = vt.getDocument().selectNodes( "/project" );
  
          assertEquals( 1, nodes.size() );
  
          Node project = ( Node ) nodes.get( 0 );
  
          assertEquals( "Check currentVersion is 1.2", "1.2", project.selectSingleNode( "currentVersion" ).getText() );
  
          List versionNodes = project.selectNodes( "versions/version" );
  
          assertEquals( "Check # versions is 2", 2, versionNodes.size() );
  
          Node version = ( Node ) versionNodes.get( 0 );
  
          assertEquals( "Check version id is 1.0", "1.0", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.0", "1.0", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_0", "TEST_1_0", version.selectSingleNode( "tag" ).getText() );
  
          version = ( Node ) versionNodes.get( 1 );
  
          assertEquals( "Check version id is 1.2", "1.2", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.2", "1.2", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_2", "TEST_1_2", version.selectSingleNode( "tag" ).getText() );
      }
  
      public void testVersionsCorrect()
          throws Exception
      {
          VersionTransformer vt = new VersionTransformer( "1.2", "TEST_1_2" );
          vt.setProject( new File( System.getProperty( "basedir" ), "/src/test-data/test-pom-versions-correct.xml" ) );
  
          assertFalse( "check transform not required", vt.transformRequired() );
  
          vt.transformNodes();
          vt.write();
  
          List nodes = vt.getDocument().selectNodes( "/project" );
  
          assertEquals( 1, nodes.size() );
  
          Node project = ( Node ) nodes.get( 0 );
  
          assertEquals( "Check currentVersion is 1.2", "1.2", project.selectSingleNode( "currentVersion" ).getText() );
  
          List versionNodes = project.selectNodes( "versions/version" );
  
          assertEquals( "Check # versions is 2", 2, versionNodes.size() );
  
          Node version = ( Node ) versionNodes.get( 0 );
  
          assertEquals( "Check version id is 1.0", "1.0", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.0", "1.0", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_0", "TEST_1_0", version.selectSingleNode( "tag" ).getText() );
  
          version = ( Node ) versionNodes.get( 1 );
  
          assertEquals( "Check version id is 1.2", "1.2", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.2", "1.2", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_2", "TEST_1_2", version.selectSingleNode( "tag" ).getText() );
      }
  
      public void testVersionsTagMatchOnly()
          throws Exception
      {
          VersionTransformer vt = new VersionTransformer( "1.2", "TEST_1_2" );
          vt.setProject( new File( System.getProperty( "basedir" ), "/src/test-data/test-pom-versions-tag-match-only.xml" ) );
  
          assertTrue( "check transform required", vt.transformRequired() );
  
          vt.transformNodes();
          vt.write();
  
          List nodes = vt.getDocument().selectNodes( "/project" );
  
          assertEquals( 1, nodes.size() );
  
          Node project = ( Node ) nodes.get( 0 );
  
          assertEquals( "Check currentVersion is 1.2", "1.2", project.selectSingleNode( "currentVersion" ).getText() );
  
          List versionNodes = project.selectNodes( "versions/version" );
  
          assertEquals( "Check # versions is 1", 1, versionNodes.size() );
  
          Node version = ( Node ) versionNodes.get( 0 );
  
          assertEquals( "Check version id is 1.2", "1.2", version.selectSingleNode( "id" ).getText() );
          assertEquals( "Check version name is 1.2", "1.2", version.selectSingleNode( "name" ).getText() );
          assertEquals( "Check version tag is TEST_1_2", "TEST_1_2", version.selectSingleNode( "tag" ).getText() );
      }
  }
  
  
  
  
  1.1                  maven-plugins/release/src/test-data/test-pom-no-versions.xml
  
  Index: test-pom-no-versions.xml
  ===================================================================
  <project>
  
    <currentVersion>1.2-SNAPSHOT</currentVersion>
  
  </project>
  
  
  
  1.1                  maven-plugins/release/src/test-data/test-pom-versions-correct.xml
  
  Index: test-pom-versions-correct.xml
  ===================================================================
  <project>
  
    <currentVersion>1.2</currentVersion>
  
    <versions>
      <version>
        <id>1.0</id>
        <name>1.0</name>
        <tag>TEST_1_0</tag>
      </version>
      <version>
        <id>1.2</id>
        <name>1.2</name>
        <tag>TEST_1_2</tag>
      </version>
    </versions>
  
  </project>
  
  
  
  1.1                  maven-plugins/release/src/test-data/test-pom-versions-multiple.xml
  
  Index: test-pom-versions-multiple.xml
  ===================================================================
  <project>
  
    <currentVersion>1.2-SNAPSHOT</currentVersion>
  
    <versions>
      <version>
        <id>1.0</id>
        <name>1.0</name>
        <tag>TEST_1_0</tag>
      </version>
      <version>
        <id>1.1</id>
        <name>1.1</name>
        <tag>TEST_1_1</tag>
      </version>
    </versions>
  
  </project>
  
  
  
  1.1                  maven-plugins/release/src/test-data/test-pom-versions-overwrite.xml
  
  Index: test-pom-versions-overwrite.xml
  ===================================================================
  <project>
  
    <currentVersion>1.2-SNAPSHOT</currentVersion>
  
    <versions>
      <version>
        <id>1.0</id>
        <name>1.0</name>
        <tag>TEST_1_0</tag>
      </version>
      <version>
        <id>1.2</id>
        <name>1.2</name>
        <tag>TEST_1_2</tag>
      </version>
    </versions>
  
  </project>
  
  
  
  1.1                  maven-plugins/release/src/test-data/test-pom-versions-tag-match-only.xml
  
  Index: test-pom-versions-tag-match-only.xml
  ===================================================================
  <project>
  
    <currentVersion>1.2-SNAPSHOT</currentVersion>
  
    <versions>
      <version>
        <id>1.2-SNAPSHOT</id>
        <name>1.2-SNAPSHOT</name>
        <tag>TEST_1_2</tag>
      </version>
    </versions>
  
  </project>
  
  
  
  1.1                  maven-plugins/release/src/test-data/test-pom-versions-wrong-order.xml
  
  Index: test-pom-versions-wrong-order.xml
  ===================================================================
  <project>
  
    <currentVersion>1.2-SNAPSHOT</currentVersion>
  
    <versions>
      <version>
        <id>1.1</id>
        <name>1.1</name>
        <tag>TEST_1_1</tag>
      </version>
      <version>
        <id>1.0</id>
        <name>1.0</name>
        <tag>TEST_1_0</tag>
      </version>
    </versions>
  
  </project>
  
  
  
  1.1                  maven-plugins/release/src/test-data/test-pom-versions.xml
  
  Index: test-pom-versions.xml
  ===================================================================
  <project>
  
    <currentVersion>1.2-SNAPSHOT</currentVersion>
  
    <versions>
      <version>
        <id>1.1</id>
        <name>1.1</name>
        <tag>TEST_1_1</tag>
      </version>
    </versions>
  
  </project>
  
  
  
  1.5       +6 -0      maven-plugins/release/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/release/xdocs/changes.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- changes.xml	29 Sep 2003 23:56:08 -0000	1.4
  +++ changes.xml	25 Feb 2004 22:34:46 -0000	1.5
  @@ -6,6 +6,12 @@
       <author email="dion@apache.org">dIon Gillard</author>
     </properties>
     <body>
  +    <release version="1.3-SNAPSHOT" date="in CVS">
  +      <action dev="bporter" type="add">
  +        Add POM transformer that updates currentVersion and the &lt;versions/&gt; element with a specified
  +        version and tag.
  +      </action>
  +    </release>
       <release version="1.2" date="2003-09-30">
         <action dev="jvanzyl" type="fix">
           Applied patch for <a href="http://jira.codehaus.org/secure/ViewIssue.jspa?id=11157">MAVEN-542</a>.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org