PR: MPSCM-76

Make scm plugin independent of release plugin.
Imported all classes and the release:transform tag (now: scm:transform).


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@374214 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
ltheussl 2006-02-02 00:34:18 +00:00
parent 49bc6a0800
commit a330f613b0
16 changed files with 1295 additions and 3 deletions

View File

@ -21,13 +21,14 @@
<project
xmlns:j="jelly:core"
xmlns:i="jelly:interaction"
xmlns:r="release:transform"
xmlns:t="scm:transform"
xmlns:c="changes:transform"
xmlns:define="jelly:define"
xmlns:ant="jelly:ant"
xmlns:scm="scm"
xmlns:util="jelly:util"
xmlns:maven="jelly:maven">
xmlns:maven="jelly:maven"
xmlns:r="jelly:org.apache.maven.plugins.scm.release.jelly.ReleaseTagLibrary">
<define:taglib uri="scm">
<define:jellybean
@ -68,6 +69,27 @@
</define:taglib>
<define:taglib uri="scm: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>
<!-- Set default encoding if not set. -->
<j:if test="${encoding == null}">
<j:set var="encoding" value="${maven.docs.outputencoding}" />
</j:if>
${transformer.transformNodes()}
${transformer.write(encoding)}
</j:if>
</define:tag>
</define:taglib>
<goal name="scm:find-connection">
<j:set var="scmConnection" value="${maven.scm.url}" />
<j:if test="${scmConnection == null}">
@ -298,7 +320,7 @@
<!-- TODO: verify that the name is valid for a tag -->
<!-- Update project.xml -->
<r:release-version version="${version_name}" tag="${tag_name}" />
<t:release-version version="${version_name}" tag="${tag_name}" />
<!-- Update changes.xml if it exists -->
<j:set var="changesFilename" value="${maven.docs.src}/changes.xml" />

View File

@ -99,13 +99,62 @@
<role>Java Developer</role>
</roles>
</developer>
<developer>
<name>Lukas Theussl</name>
<id>ltheussl</id>
<email>ltheussl@apache.org</email>
<roles>
<role>Developer</role>
</roles>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>maven</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
<artifactId>commons-jelly-tags-interaction</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.0</version>
<properties>
<comment>
This library is already loaded by maven's core. Be careful to use the same version number as in the core.
</comment>
</properties>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
<artifactId>commons-jelly</artifactId>
<version>1.0</version>
<properties>
<comment>
This library is already loaded by maven's core. Be careful to use the same version number as in the core.
</comment>
</properties>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.4</version>
<url>http://www.dom4j.org/</url>
<properties>
<comment>
This library is already loaded by maven's core. Be careful to use the same version number as in the core.
</comment>
</properties>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.0-FCS-full</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-container-default</artifactId>

View File

@ -0,0 +1,353 @@
package org.apache.maven.plugins.scm.release;
/* ====================================================================
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.dom4j.Document;
import org.dom4j.Namespace;
import org.dom4j.Node;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.jaxen.XPath;
import org.jaxen.dom4j.Dom4jXPath;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.XMLFilterImpl;
/**
* This is the base class for any tool that attempts to transform fields
* in the POM. Currently we are using the XML form of the POM and using Jaxen
* but eventually we will be able to perform the same transformations on
* POM beans. Jaxen needs to be modified and some serious cleanup needs to
* go on in Maven internally, but this will serve as a start. An attempt is
* made to make this tool GUI friendly.
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
*
* @version $Id$
*/
public abstract class AbstractPomTransformer
implements PomTransformer
{
/** POM document */
private File project;
/** Dom4j document. */
private Document document;
/** Output file. */
private File outputFile;
/** Properties used in transformNode */
private Map variables;
/** Nodes selected for transformation using xpath. */
private List selectedNodes;
private List transformations;
// -------------------------------------------------------------------------
// Accessors
// -------------------------------------------------------------------------
/**
*
* @return
*/
public Map getVariables()
{
return variables;
}
/**
*
* @param variables
*/
public void setVariables( Map variables )
{
this.variables = variables;
}
/**
*
* @param project
*/
public void setProject( File project )
{
this.project = project;
}
/**
*
* @return
*/
public File getProject()
{
return project;
}
/**
*
* @return
*/
public Document getDocument()
{
return document;
}
/**
*
* @param document
*/
public void setDocument( Document document )
{
this.document = document;
}
/**
*
* @return
*/
public File getOutputFile()
{
return outputFile;
}
/**
*
* @param outputFile
*/
public void setOutputFile( File outputFile )
{
this.outputFile = outputFile;
}
/**
*
* @return
*/
public List getSelectedNodes()
{
if ( selectedNodes == null )
{
try
{
selectNodes();
}
catch ( Exception e )
{
// do nothing.
}
}
return selectedNodes;
}
/**
*
* @param selectedNodes
*/
public void setSelectedNodes( List selectedNodes )
{
this.selectedNodes = selectedNodes;
}
/**
*
* @return
*/
public int getSelectedNodeCount()
{
return getSelectedNodes().size();
}
/**
*
* @return
*/
public List getTransformations()
{
if ( transformations == null )
{
createTransformations();
}
return transformations;
}
/**
*
*/
public void createTransformations()
{
transformations = new ArrayList();
for ( Iterator i = getSelectedNodes().iterator(); i.hasNext(); )
{
Object o = i.next();
if ( o instanceof Node )
{
Transformation transformation = new Transformation( this );
transformation.setNode( (Node) o );
transformations.add( transformation );
}
}
}
/**
* This is the automated way of transforming the nodes if there is
* no user interaction involved.
*
* @throws Exception If an error occurs while transforming the nodes.
*/
public void transformNodes()
throws Exception
{
for ( Iterator i = getSelectedNodes().iterator(); i.hasNext(); )
{
Object o = i.next();
if ( o instanceof Node )
{
transformNode( (Node) o );
}
}
}
// ----------------------------------------------------------------------
// Implementation
// ----------------------------------------------------------------------
/**
*
* @return
*/
public abstract String selectNodesXPathExpression();
/**
*
* @param node
* @throws Exception
*/
public abstract void transformNode( Node node )
throws Exception;
/**
* Update the snapshot version identifiers with actual timestamp versions
* and write out the POM in its updated form.
*
* @throws Exception
*/
public void selectNodes()
throws Exception
{
SAXReader reader = new SAXReader();
// make xpath expressions worh with poms with or without namespace
reader.setXMLFilter( new XMLFilterImpl()
{
public void endElement( String uri, String localName, String qName )
throws SAXException
{
super.endElement( "", localName, "" );
}
public void startElement( String uri, String localName, String qName, Attributes atts )
throws SAXException
{
super.startElement( "", localName, "", atts );
}
} );
setDocument( reader.read( getProject() ) );
// The selecting nodes with the xpath expression will give us a list
// of dependencies elements where the version element is equal to 'SNAPSHOT'.
// 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( selectNodesXPathExpression() );
setSelectedNodes( xpath.selectNodes( getDocument() ) );
}
/**
*
* @throws Exception
*/
public void write()
throws Exception
{
write( null );
}
/**
*
* @throws Exception
*/
public void write( String encoding )
throws Exception
{
OutputStream os = null;
if ( getOutputFile() != null )
{
// Backup the original first.
FileUtils.copyFile( getOutputFile(), new File( getOutputFile() + ".backup" ) );
// Now hand of the os.
os = new FileOutputStream( getOutputFile() );
}
else
{
os = new PrintStream( System.out );
}
OutputFormat format = new OutputFormat();
format.setIndentSize( 2 );
format.setNewlines( true );
format.setTrimText( true );
if ( encoding != null )
{
format.setEncoding( encoding );
}
XMLWriter writer = new XMLWriter( format )
{
protected boolean isNamespaceDeclaration( Namespace ns )
{
// this will filter out empty namespaces, only the correct POM ns is allowed
return "http://maven.apache.org/POM/3.0.0".equals( ns.getURI() );
}
};
writer.setOutputStream( os );
writer.write( getDocument() );
writer.flush();
writer.close();
}
}

View File

@ -0,0 +1,121 @@
package org.apache.maven.plugins.scm.release;
/* ====================================================================
* Copyright 2001-2004 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.dom4j.Document;
import org.dom4j.io.SAXReader;
import org.jaxen.XPath;
import org.jaxen.dom4j.Dom4jXPath;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* This is a simple POM manipulator that doesn't take into account any sort of
* POM inheritance. When the interpolation and inheritance is cleaned up in the
* Maven we will be able to serialize a POM directly with greater ease. But we
* may stick with this Jaxen solution anyway because it's so easy. Just turn the
* POM in memory into a Dom4j document and perform the same operation as we are
* here.
*/
public class PomNodeSelector
{
/**
* POM document
*/
private File pom;
/**
* Xpath expression.
*/
private String xpathExpression;
/**
* Snapshot dependencies found.
*/
private List nodes;
/**
* Constructor.
*/
public PomNodeSelector()
{
nodes = new ArrayList();
}
// -------------------------------------------------------------------------
// Accessors
// -------------------------------------------------------------------------
public void setXpathExpression( String xpathExpression )
{
this.xpathExpression = xpathExpression;
}
public String getXpathExpression()
{
return xpathExpression;
}
/**
* Sets the nodes attribute of the PomManipulator object
*/
public void setNodes( List nodes )
{
this.nodes = nodes;
}
/**
* Gets the nodes attribute of the PomManipulator object
*/
public List getNodes()
{
return nodes;
}
public void setPom( File pom )
{
this.pom = pom;
}
public File getPom()
{
return pom;
}
/**
* Update the snapshot version identifiers with actual timestamp versions
* and write out the POM in its updated form.
*
* @throws Exception
*/
public void execute()
throws Exception
{
SAXReader reader = new SAXReader();
Document doc = reader.read( getPom() );
// The selecting nodes with the xpath expression will give us a list
// of dependencies elements where the version element is equal to 'SNAPSHOT'.
// 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 ) );
}
}

View File

@ -0,0 +1,36 @@
package org.apache.maven.plugins.scm.release;
/* ====================================================================
* Copyright 2001-2004 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.dom4j.Node;
/**
*
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
*
* @version $Id$
*/
public interface PomTransformer
{
public void transformNode( Node node )
throws Exception;
public Node getTransformedNode( Node node )
throws Exception;
}

View File

@ -0,0 +1,142 @@
package org.apache.maven.plugins.scm.release;
/* ====================================================================
* Copyright 2001-2004 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.commons.io.FileUtils;
import org.apache.maven.MavenConstants;
import org.apache.maven.project.Project;
import org.apache.maven.util.HttpUtils;
import org.dom4j.Node;
import java.io.File;
import java.util.Iterator;
/**
*
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
*
* @version $Id$
*/
public class SnapshotResolver
extends AbstractPomTransformer
{
// -------------------------------------------------------------------------
// Accessors
// -------------------------------------------------------------------------
public String selectNodesXPathExpression()
{
return "/project/dependencies/dependency[version='SNAPSHOT']";
}
public String selectNodeXPath()
{
return "version";
}
public String getNodeContent( Node node )
throws Exception
{
String timestampVersion = "SNAPSHOT";
Node idNode = node.selectSingleNode( "id" );
String groupId;
String artifactId;
String artifactType = "jar";
if ( idNode != null )
{
groupId = idNode.getText();
artifactId = groupId;
}
else
{
Node artifactIdNode = node.selectSingleNode( "artifactId" );
Node groupIdNode = node.selectSingleNode( "groupId" );
groupId = groupIdNode.getText();
artifactId = artifactIdNode.getText();
}
Node typeIdNode = node.selectSingleNode( "type" );
if ( typeIdNode != null )
{
artifactType = typeIdNode.getText();
}
// Now we need to attempt to find the the actual timestamp
// version for this dependency.
// Variables are being stored as ConstantExpressions ...
Project project = (Project) getVariables().get( MavenConstants.MAVEN_POM );
File snapshotVersionFile = new File( getProject().getParentFile(), artifactId + "-snapshot-version" );
for ( Iterator i = project.getContext().getMavenRepoRemote().iterator(); i.hasNext(); )
{
String remoteRepo = (String) i.next();
String url = remoteRepo + "/" + groupId + "/" + artifactType + "s/" + artifactId + "-snapshot-version";
try
{
HttpUtils.getFile( url,
snapshotVersionFile,
true, // ignore errors
false, // use timestamps
(String) getVariables().get( MavenConstants.PROXY_HOST ), // proxy host
(String) getVariables().get( MavenConstants.PROXY_PORT ), // proxy port
(String) getVariables().get( MavenConstants.PROXY_USERNAME ), // proxy user name
(String) getVariables().get( MavenConstants.PROXY_PASSWORD ) // proxy password
);
}
catch ( Exception e )
{
// Either doesn't exist, or we have a network problem. In
// either event we can't update the version field.
System.out.println( "Can't retrieve snapshot version file: " + e.getLocalizedMessage() );
}
if ( snapshotVersionFile.exists() )
{
timestampVersion = FileUtils.readFileToString( snapshotVersionFile, null );
}
}
return timestampVersion;
}
public void transformNode( Node node )
throws Exception
{
Node version = node.selectSingleNode( selectNodeXPath() );
version.setText( getNodeContent( node ) );
}
public Node getTransformedNode( Node node )
throws Exception
{
Node transformedNode = (Node) node.clone();
Node version = transformedNode.selectSingleNode( selectNodeXPath() );
version.setText( getNodeContent( transformedNode ) );
return transformedNode;
}
}

View File

@ -0,0 +1,76 @@
package org.apache.maven.plugins.scm.release;
/* ====================================================================
* Copyright 2001-2004 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.dom4j.Node;
/**
*
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
*
* @version $Id$
*/
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 );
}
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;
}
}

View File

@ -0,0 +1,95 @@
package org.apache.maven.plugins.scm.release;
/* ====================================================================
* Copyright 2001-2004 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.dom4j.Node;
/**
*
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
*
* @version $Id$
*/
public class Transformation
{
/** Pom Transformer associated with this transformation. */
private PomTransformer pomTransformer;
/** Node to transform. */
private Node node;
public Transformation( PomTransformer pomTransformer )
{
this.pomTransformer = pomTransformer;
}
// ----------------------------------------------------------------------
// Accessors
// ----------------------------------------------------------------------
/**
*
* @return
*/
public Node getNode()
{
return node;
}
/**
*
* @param node
*/
public void setNode( Node node )
{
this.node = node;
}
/**
*
* @throws Exception
*/
public void transform()
throws Exception
{
pomTransformer.transformNode( node );
}
/**
*
* @return
* @throws Exception
*/
public String getBeforeTransformation()
throws Exception
{
return getNode().asXML();
}
/**
*
* @return
* @throws Exception
*/
public String getAfterTransformation()
throws Exception
{
return pomTransformer.getTransformedNode( getNode() ).asXML();
}
}

View File

@ -0,0 +1,129 @@
package org.apache.maven.plugins.scm.release;
/* ====================================================================
* Copyright 2001-2004 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.dom4j.Element;
import org.dom4j.Node;
/**
*
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*
* @version $Id$
*/
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
{
Element project = ( Element ) node;
Node currentVersion = node.selectSingleNode( "currentVersion" );
if ( currentVersion != null )
{
currentVersion.setText( version );
}
else
{
project.addElement( "currentVersion" ).addText( version );
}
Element version = ( Element ) node.selectSingleNode( "versions/version[tag='" + tag + "']" );
if ( version != null )
{
// tag exists - overwrite
Node id = version.selectSingleNode( "id" );
if ( id != null )
{
id.setText( this.version );
}
else
{
version.addElement( "id" ).addText( this.version );
}
Node name = version.selectSingleNode( "name" );
if ( name != null )
{
name.setText( this.version );
}
else
{
version.addElement( "name" ).addText( this.version );
}
}
else
{
// tag doesn't exist - add
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 );
if ( node == null )
{
return true;
}
Node currentVersion = node.selectSingleNode( "currentVersion" );
if ( currentVersion == null || !currentVersion.getText().equals( version ))
{
return true;
}
Node v = node.selectSingleNode( "versions/version[tag='" + tag + "' and id='" + version + "' and name='" + version + "']" );
return ( v == null );
}
}

View File

@ -0,0 +1,53 @@
package org.apache.maven.plugins.scm.release.jelly;
/* ====================================================================
* Copyright 2001-2004 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.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;
}

View File

@ -0,0 +1,41 @@
package org.apache.maven.plugins.scm.release.jelly;
/* ====================================================================
* Copyright 2001-2004 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.commons.jelly.tags.core.CoreTagLibrary;
/**
* Release tag library.
*
* @author <a href="jason@zenplex.com">Jason van Zyl</a>
* @version $Id$
*/
public class ReleaseTagLibrary
extends CoreTagLibrary
{
/**
* Create an instance of the {@link ReleaseTagLibrary}, registering related
* tag libraries
*/
public ReleaseTagLibrary()
{
registerTag( "resolve-snapshots", ResolveSnapshotsTag.class );
registerTag( "increment-snapshot-version", SnapshotVersionTransformerTag.class );
registerTag( "release-version", VersionTransformerTag.class );
}
}

View File

@ -0,0 +1,44 @@
package org.apache.maven.plugins.scm.release.jelly;
/* ====================================================================
* Copyright 2001-2004 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.commons.jelly.JellyTagException;
import org.apache.commons.jelly.XMLOutput;
import org.apache.maven.MavenConstants;
import org.apache.maven.project.Project;
import org.apache.maven.plugins.scm.release.SnapshotResolver;
public class ResolveSnapshotsTag
extends AbstractTransformerTag
{
private SnapshotResolver snapshotResolver;
public void doTag( XMLOutput output )
throws JellyTagException
{
Project project = (Project) context.getVariable( MavenConstants.MAVEN_POM );
snapshotResolver = new SnapshotResolver();
snapshotResolver.setProject( project.getFile() );
snapshotResolver.setVariables( project.getContext().getVariables() );
snapshotResolver.setOutputFile( project.getFile() );
context.setVariable( getTransformer(), snapshotResolver );
context.setVariable( getTransformations(), snapshotResolver.getTransformations() );
}
}

View File

@ -0,0 +1,44 @@
package org.apache.maven.plugins.scm.release.jelly;
/* ====================================================================
* Copyright 2001-2004 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.commons.jelly.JellyTagException;
import org.apache.commons.jelly.XMLOutput;
import org.apache.maven.MavenConstants;
import org.apache.maven.project.Project;
import org.apache.maven.plugins.scm.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() );
}
}

View File

@ -0,0 +1,68 @@
package org.apache.maven.plugins.scm.release.jelly;
/* ====================================================================
* Copyright 2001-2004 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.commons.jelly.JellyTagException;
import org.apache.commons.jelly.XMLOutput;
import org.apache.maven.MavenConstants;
import org.apache.maven.project.Project;
import org.apache.maven.plugins.scm.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() );
}
}

View File

@ -0,0 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<body>
<p>
Jelly tags used by org.apache.maven.plugins.scm.release.
These classes have originally been imported from the deprecated
Maven Release Plugin.
</p>
</body>
</html>

View File

@ -0,0 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<body>
<p>
Utility classes for preparing a release. These classes have originally
been imported from the deprecated Maven Release Plugin.
</p>
</body>
</html>