You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2003/02/11 23:01:14 UTC
cvs commit: jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/jelly AbstractTransformerTag.java SnapshotVersionTransformerTag.java ReleaseTagLibrary.java ResolveSnapshotsTag.java
jvanzyl 2003/02/11 14:01:13
Modified: src/plugins-build/release plugin.jelly
src/plugins-build/release/src/main/org/apache/maven/release
PomNodeSelector.java SnapshotResolver.java
src/plugins-build/release/src/main/org/apache/maven/release/jelly
ReleaseTagLibrary.java ResolveSnapshotsTag.java
Added: src/plugins-build/release/src/main/org/apache/maven/release
SnapshotVersionTransformer.java
src/plugins-build/release/src/main/org/apache/maven/release/jelly
AbstractTransformerTag.java
SnapshotVersionTransformerTag.java
Log:
o Adding POM editor that graduates snapshot plugin versions.
Revision Changes Path
1.15 +9 -0 jakarta-turbine-maven/src/plugins-build/release/plugin.jelly
Index: plugin.jelly
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/release/plugin.jelly,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- plugin.jelly 11 Feb 2003 13:22:37 -0000 1.14
+++ plugin.jelly 11 Feb 2003 22:01:12 -0000 1.15
@@ -105,6 +105,15 @@
</goal>
+ <goal name="convert-snapshots-auto">
+
+ <r:increment-snapshot-version
+ transformer="transformer"
+ transformations="transformations"/>
+ ${transformer.transformNodes()}
+ ${transformer.write()}
+ </goal>
+
<!--
|
| Validate the POM for a release. This consists of:
1.2 +7 -13 jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/PomNodeSelector.java
Index: PomNodeSelector.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/PomNodeSelector.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PomNodeSelector.java 9 Feb 2003 17:04:45 -0000 1.1
+++ PomNodeSelector.java 11 Feb 2003 22:01:12 -0000 1.2
@@ -55,21 +55,15 @@
*
* ====================================================================
*/
+
import org.dom4j.Document;
-import org.dom4j.Node;
import org.dom4j.io.SAXReader;
-
import org.jaxen.XPath;
-import org.jaxen.XPathSyntaxException;
-import org.jaxen.JaxenException;
-
import org.jaxen.dom4j.Dom4jXPath;
import java.io.File;
-
import java.util.ArrayList;
import java.util.List;
-import java.util.Iterator;
/**
* This is a simple POM manipulator that doesn't take into account any sort of
@@ -112,16 +106,16 @@
{
this.xpathExpression = xpathExpression;
}
-
+
public String getXpathExpression()
{
return xpathExpression;
- }
+ }
/**
* Sets the nodes attribute of the PomManipulator object
*/
- public void setNodes(List nodes)
+ public void setNodes( List nodes )
{
this.nodes = nodes;
}
@@ -137,12 +131,12 @@
public void setPom( File pom )
{
this.pom = pom;
- }
+ }
public File getPom()
{
return pom;
- }
+ }
/**
* Update the snapshot version identifiers with actual timestamp versions
@@ -161,6 +155,6 @@
// So we can get any information we need, and alter anything we need to before writing
// the dom4j document back out.
XPath xpath = new Dom4jXPath( getXpathExpression() );
- setNodes(xpath.selectNodes(doc));
+ setNodes( xpath.selectNodes( doc ) );
}
}
1.11 +2 -2 jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/SnapshotResolver.java
Index: SnapshotResolver.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/SnapshotResolver.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SnapshotResolver.java 11 Feb 2003 15:40:21 -0000 1.10
+++ SnapshotResolver.java 11 Feb 2003 22:01:12 -0000 1.11
@@ -57,8 +57,8 @@
*/
import org.apache.commons.io.FileUtils;
-import org.apache.maven.util.HttpUtils;
import org.apache.maven.MavenConstants;
+import org.apache.maven.util.HttpUtils;
import org.dom4j.Node;
import java.io.File;
1.1 jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/SnapshotVersionTransformer.java
Index: SnapshotVersionTransformer.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 MavenSession" 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 MavenSession", 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.dom4j.Node;
/**
*
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
*
* @version $Id: SnapshotVersionTransformer.java,v 1.1 2003/02/11 22:01:12 jvanzyl Exp $
*/
public class SnapshotVersionTransformer
extends AbstractPomTransformer
{
// -------------------------------------------------------------------------
// Accessors
// -------------------------------------------------------------------------
public String selectNodesXPathExpression()
{
return "/project";
}
public String selectNodeXPath()
{
return "currentVersion";
}
public String getNodeContent( Node node )
throws Exception
{
String currentVersion = node.selectSingleNode( selectNodeXPath() ).getText();
int i = currentVersion.indexOf( "-SNAPSHOT" );
if ( i > 0 )
{
currentVersion = currentVersion.substring( 0, i - 1 );
}
return currentVersion;
}
public void transformNode( Node node )
throws Exception
{
Node currentVersion = node.selectSingleNode( selectNodeXPath() );
currentVersion.setText( getNodeContent( node ) );
}
public Node getTransformedNode( Node node )
throws Exception
{
Node transformedNode = (Node) node.clone();
Node currentVersion = transformedNode.selectSingleNode( selectNodeXPath() );
currentVersion.setText( getNodeContent( transformedNode ) );
return transformedNode;
}
}
1.3 +2 -1 jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/jelly/ReleaseTagLibrary.java
Index: ReleaseTagLibrary.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/jelly/ReleaseTagLibrary.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ReleaseTagLibrary.java 11 Feb 2003 02:40:41 -0000 1.2
+++ ReleaseTagLibrary.java 11 Feb 2003 22:01:13 -0000 1.3
@@ -18,5 +18,6 @@
public ReleaseTagLibrary()
{
registerTag( "resolve-snapshots", ResolveSnapshotsTag.class );
+ registerTag( "increment-snapshot-version", SnapshotVersionTransformerTag.class );
}
}
1.4 +4 -29 jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/jelly/ResolveSnapshotsTag.java
Index: ResolveSnapshotsTag.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/jelly/ResolveSnapshotsTag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ResolveSnapshotsTag.java 11 Feb 2003 05:07:27 -0000 1.3
+++ ResolveSnapshotsTag.java 11 Feb 2003 22:01:13 -0000 1.4
@@ -56,41 +56,16 @@
* ====================================================================
*/
-import org.apache.commons.jelly.TagSupport;
-import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.JellyTagException;
-import org.apache.maven.release.SnapshotResolver;
-import org.apache.maven.project.Project;
+import org.apache.commons.jelly.XMLOutput;
import org.apache.maven.MavenConstants;
+import org.apache.maven.project.Project;
+import org.apache.maven.release.SnapshotResolver;
public class ResolveSnapshotsTag
- extends TagSupport
+ extends AbstractTransformerTag
{
private SnapshotResolver snapshotResolver;
-
- private String transformer;
-
- private String transformations;
-
- public void setTransformations( String transformations )
- {
- this.transformations = transformations;
- }
-
- public String getTransformations()
- {
- return transformations;
- }
-
- public void setTransformer( String transformer )
- {
- this.transformer = transformer;
- }
-
- public String getTransformer()
- {
- return transformer;
- }
public void doTag( XMLOutput output )
throws JellyTagException
1.1 jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/jelly/AbstractTransformerTag.java
Index: AbstractTransformerTag.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 MavenSession" 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 MavenSession", 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.TagSupport;
import org.apache.commons.jelly.XMLOutput;
public abstract class AbstractTransformerTag
extends TagSupport
{
private String transformer;
private String transformations;
public void setTransformations( String transformations )
{
this.transformations = transformations;
}
public String getTransformations()
{
return transformations;
}
public void setTransformer( String transformer )
{
this.transformer = transformer;
}
public String getTransformer()
{
return transformer;
}
public abstract void doTag( XMLOutput output )
throws JellyTagException;
}
1.1 jakarta-turbine-maven/src/plugins-build/release/src/main/org/apache/maven/release/jelly/SnapshotVersionTransformerTag.java
Index: SnapshotVersionTransformerTag.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 MavenSession" 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 MavenSession", 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.SnapshotVersionTransformer;
public class SnapshotVersionTransformerTag
extends AbstractTransformerTag
{
private SnapshotVersionTransformer transformer;
public void doTag( XMLOutput output )
throws JellyTagException
{
Project project = (Project) context.getVariable( MavenConstants.MAVEN_POM );
transformer = new SnapshotVersionTransformer();
transformer.setProject( project.getFile() );
transformer.setVariables( project.getContext().getVariables() );
transformer.setOutputFile( project.getFile() );
context.setVariable( getTransformer(), transformer );
context.setVariable( getTransformations(), transformer.getTransformations() );
}
}