Index: src/java/main/org/apache/maven/jelly/tags/maven/MavenTag.java
===================================================================
RCS file: /home/cvspublic/maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/Attic/MavenTag.java,v
retrieving revision 1.14
diff -u -r1.14 MavenTag.java
--- src/java/main/org/apache/maven/jelly/tags/maven/MavenTag.java 5 May 2004 13:05:51 -0000 1.14
+++ src/java/main/org/apache/maven/jelly/tags/maven/MavenTag.java 7 Dec 2004 15:16:46 -0000
@@ -28,7 +28,9 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* A way of running maven as a Jelly tag
@@ -51,6 +53,9 @@
/** whether to ignore exceptions */
private boolean ignoreFailures;
+
+ /** map of context variables */
+ private Map contextVariableMap = new HashMap();
/**
* Process the tag. Set up a new maven instance with the same maven home
@@ -65,6 +70,9 @@
{
checkAttribute( getDescriptor(), "descriptor" );
+ clearContextVariables();
+ invokeBody(output);
+
Project project = null;
try
{
@@ -79,7 +87,7 @@
goalList.addAll( MavenUtils.getGoalListFromCsv( getGoals() ) );
}
- getMavenContext().getMavenSession().attainGoals( project, goalList );
+ attainGoals( project, goalList );
}
catch ( Exception e )
{
@@ -103,6 +111,35 @@
}
}
+ /**
+ * Clears the map of context variables held for this tag
+ */
+ public final void clearContextVariables() {
+ contextVariableMap.clear();
+ }
+
+ /**
+ * Puts the supplied context variable into the map
+ * @param name the name of the variable
+ * @param value the value of the variable
+ */
+ public final void putContextVariable(String name, Object value) {
+ contextVariableMap.put(name, value);
+ }
+
+ /**
+ * Attains the supplied list of goals on the supplied project
+ * @param project the project to use
+ * @param goalList the goals to attain
+ * @throws Exception
+ * @todo don't throw exception
+ */
+ public final void attainGoals(Project project, List goalList)
+ throws Exception {
+ getMavenContext().getMavenSession().attainGoals( project, goalList,
+ contextVariableMap );
+ }
+
// ------------------------------------------------------------
// A C C E S S O R S
// ------------------------------------------------------------
Index: src/java/main/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java
===================================================================
RCS file: /home/cvspublic/maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/Attic/MavenTagLibrary.java,v
retrieving revision 1.16
diff -u -r1.16 MavenTagLibrary.java
--- src/java/main/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java 5 May 2004 13:05:51 -0000 1.16
+++ src/java/main/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java 7 Dec 2004 15:16:47 -0000
@@ -40,6 +40,7 @@
registerTag( "maven", MavenTag.class );
registerTag( "pom", PomTag.class );
registerTag( "reactor", ReactorTag.class );
+ registerTag( "contextVariable", ContextVariableTag.class);
registerTag( "concat", ConcatTag.class );
registerTag( "input", InputTag.class );
registerTag( "makeAbsolutePath", MakeAbsolutePathTag.class );
Index: src/java/main/org/apache/maven/jelly/tags/maven/ReactorTag.java
===================================================================
RCS file: /home/cvspublic/maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/Attic/ReactorTag.java,v
retrieving revision 1.40.2.1
diff -u -r1.40.2.1 ReactorTag.java
--- src/java/main/org/apache/maven/jelly/tags/maven/ReactorTag.java 6 Nov 2004 07:26:33 -0000 1.40.2.1
+++ src/java/main/org/apache/maven/jelly/tags/maven/ReactorTag.java 7 Dec 2004 15:17:03 -0000
@@ -313,6 +313,9 @@
throw new MissingAttributeException( "glob|includes|projectList" );
}
+ clearContextVariables();
+ invokeBody(output);
+
log.info( "Starting the reactor..." );
List sortedProjects = null;
@@ -365,7 +368,7 @@
{
if ( !collectOnly )
{
- getMavenContext().getMavenSession().attainGoals( project, goalList );
+ attainGoals( project, goalList );
}
}
catch ( Exception e )
Index: src/java/main/org/apache/maven/jelly/tags/maven/ContextVariableTag.java
===================================================================
RCS file: src/java/main/org/apache/maven/jelly/tags/maven/ContextVariableTag.java
diff -N src/java/main/org/apache/maven/jelly/tags/maven/ContextVariableTag.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/java/main/org/apache/maven/jelly/tags/maven/ContextVariableTag.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,74 @@
+package org.apache.maven.jelly.tags.maven;
+
+/* ====================================================================
+ * 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.MissingAttributeException;
+import org.apache.commons.jelly.XMLOutput;
+import org.apache.maven.jelly.tags.BaseTagSupport;
+
+/**
+ * A Maven Jelly tag that provides a context variable to the ancestor MavenTag
+ * (and therefore ReactorTag as that extends MavenTag).
+ *
+ * @author Kris Brown
+ */
+public class ContextVariableTag
+ extends BaseTagSupport
+{
+ private String var;
+
+ private Object value;
+
+ public void setVar( String var )
+ {
+ this.var = var;
+ }
+
+ public void setValue( Object value )
+ {
+ this.value = value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
+ */
+ public void doTag( XMLOutput output )
+ throws MissingAttributeException, JellyTagException
+ {
+ checkAttribute( var, "var" );
+
+ checkAttribute( value, "value" );
+
+ MavenTag tag = getAncestorMavenTag();
+ tag.putContextVariable(var, value);
+ }
+
+ /**
+ * @return the ancestor MavenTag
+ */
+ protected MavenTag getAncestorMavenTag() throws JellyTagException {
+ MavenTag tag = (MavenTag) findAncestorWithClass(
+ new Class[] {MavenTag.class, ReactorTag.class});
+ if ( tag == null ) {
+ throw new JellyTagException( " must be " +
+ "inside or " );
+ }
+ return tag;
+ }
+}