werken 2002/06/12 10:09:41
Modified: jelly build.xml
jelly/src/java/org/apache/commons/jelly/tags/ant
TaskTag.java
jelly/src/java/org/apache/commons/jelly/tags/werkz
GoalTag.java PreGoalTag.java
jelly/src/test/org/apache/commons/jelly/werkz example.jelly
Log:
* Improved handling of the <ant:echo> tag.
* Integrated a prereq attribute on <goal>, like ant's depend attr on <target>.
* Made example spiffy.
Revision Changes Path
1.45 +1 -1 jakarta-commons-sandbox/jelly/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.xml,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- build.xml 12 Jun 2002 16:26:00 -0000 1.44
+++ build.xml 12 Jun 2002 17:09:41 -0000 1.45
@@ -345,8 +345,8 @@
<java classname="org.apache.commons.jelly.Jelly" fork="yes">
<classpath refid="callback.classpath"/>
<arg value="src/test/org/apache/commons/jelly/werkz/example.jelly"/>
- <arg value="compile"/>
<arg value="test"/>
+ <arg value="compile"/>
</java>
</target>
1.7 +15 -5
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/TaskTag.java
Index: TaskTag.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/TaskTag.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TaskTag.java 5 Jun 2002 17:14:38 -0000 1.6
+++ TaskTag.java 12 Jun 2002 17:09:41 -0000 1.7
@@ -71,6 +71,7 @@
import org.apache.tools.ant.Task;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.taskdefs.Echo;
/**
* A tag which invokes an Ant Task
@@ -97,11 +98,20 @@
task.init();
- // run the body first to configure the task via nested
- getBody().run(context, output);
-
- // task.execute();
- task.perform();
+ if ( "echo".equals( task.getTaskName() ) )
+ {
+ Echo echoTask = (Echo) task;
+
+ echoTask.addText( getBodyText() );
+ echoTask.perform();
+ echoTask.setMessage( "" );
+ }
+ else
+ {
+ // run the body first to configure the task via nested
+ getBody().run(context, output);
+ task.perform();
+ }
}
// TaskSource interface
1.2 +55 -15
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/GoalTag.java
Index: GoalTag.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/GoalTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GoalTag.java 12 Jun 2002 06:07:29 -0000 1.1
+++ GoalTag.java 12 Jun 2002 17:09:41 -0000 1.2
@@ -58,10 +58,14 @@
package org.apache.commons.jelly.tags.werkz;
-import com.werken.werkz.DefaultGoal;
+import com.werken.werkz.Goal;
+import com.werken.werkz.Action;
+import com.werken.werkz.DefaultAction;
+import com.werken.werkz.CyclicGoalChainException;
import java.util.Iterator;
import java.util.List;
+import java.util.StringTokenizer;
import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.XMLOutput;
@@ -83,6 +87,8 @@
/** the name of the target */
private String name;
+
+ private String prereqs;
public GoalTag() {
}
@@ -99,20 +105,20 @@
log.debug("doTag(..):" + name);
- // lets register a new goal...
- DefaultGoal goal = new DefaultGoal(name) {
- public void performAction() throws Exception {
- // lets run the body
- log.debug("Running target: " + name);
- getBody().run(context, output);
- }
- public boolean requiresAction() {
- return true;
- }
- };
- getProject().addGoal(goal);
- }
+ Goal goal = getProject().getGoal( getName(),
+ true );
+
+ addPrereqs( goal );
+ Action action = new DefaultAction() {
+ public void performAction() throws Exception {
+ log.debug("Running action of target: " + getName() );
+ getBody().run(context, output);
+ }
+ };
+
+ goal.setAction( action );
+ }
// Properties
@@ -130,5 +136,39 @@
public void setName(String name) {
log.debug("setName(" + name + ")" );
this.name = name;
+ }
+
+ public void setPrereqs(String prereqs) {
+ this.prereqs = prereqs;
+ }
+
+ public String getPrereqs() {
+ return this.prereqs;
+ }
+
+
+ protected void addPrereqs(Goal goal) throws CyclicGoalChainException
+ {
+ String prereqs = getPrereqs();
+
+ if ( prereqs == null )
+ {
+ return;
+ }
+
+ StringTokenizer tokens = new StringTokenizer( getPrereqs(),
+ "," );
+
+ String eachToken = null;
+ Goal eachPrereq = null;
+
+ while ( tokens.hasMoreTokens() )
+ {
+ eachToken = tokens.nextToken().trim();
+
+ eachPrereq = getProject().getGoal( eachToken, true );
+
+ goal.addPrerequisite( eachPrereq );
+ }
}
}
1.2 +2 -2
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/PreGoalTag.java
Index: PreGoalTag.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/PreGoalTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PreGoalTag.java 12 Jun 2002 06:07:29 -0000 1.1
+++ PreGoalTag.java 12 Jun 2002 17:09:41 -0000 1.2
@@ -93,7 +93,7 @@
new PreGoalCallback() {
public void firePreGoal(Goal goal) throws Exception {
// lets run the body
- log.info( "Running pre target: " + getName() );
+ log.debug( "Running pre target: " + getName() );
getBody().run( context, output);
}
}
1.4 +13 -6
jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/werkz/example.jelly
Index: example.jelly
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/werkz/example.jelly,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- example.jelly 12 Jun 2002 06:07:29 -0000 1.3
+++ example.jelly 12 Jun 2002 17:09:41 -0000 1.4
@@ -4,15 +4,15 @@
<!-- the following could be in the mediator of Maven -->
<werkz:goal name="init">
- <echo message="Initializing the project!"/>
+ <echo message="Running init goal's action"/>
</werkz:goal>
- <werkz:goal name="compile">
- <echo message="About to compile the project!"/>
+ <werkz:goal name="compile" prereqs="init">
+ <echo message="Running compile goal's action"/>
</werkz:goal>
- <werkz:goal name="test">
- <echo message="About to run the tests!"/>
+ <werkz:goal name="test" prereqs="init,compile">
+ <echo message="Running test goal's action"/>
</werkz:goal>
@@ -24,8 +24,15 @@
<!-- call all the targets made on the command line -->
<werkz:attain>
+ <echo>-------------------------------------</echo>
+ <echo>jelly+werkz+ant-taskdefs</echo>
+ <echo>-------------------------------------</echo>
<j:forEach var="arg" items="${args}" begin="1">
- <werkz:attainGoal name="${arg}"/>
+ <echo>begin target [<j:expr value="${arg}"/>]</echo>
+ <echo>-------------------------------------</echo>
+ <werkz:attainGoal name="${arg}"/>
+ <echo>end target [<j:expr value="${arg}"/>]</echo>
+ <echo>-------------------------------------</echo>
</j:forEach>
</werkz:attain>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>