commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wer...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/werkz example.jelly
Date Wed, 12 Jun 2002 22:01:09 GMT
werken      2002/06/12 15:01:07

  Modified:    jelly    project.xml
               jelly/src/java/org/apache/commons/jelly/tags/werkz
                        AttainGoalTag.java AttainTag.java ProjectTag.java
               jelly/src/test/org/apache/commons/jelly/werkz example.jelly
  Added:       jelly/src/java/org/apache/commons/jelly/tags/werkz
                        JellyBuildListener.java JellySession.java
  Log:
  Working with ant's outputting.
  
  Jellywerkz now pretty much produces output not unlike ant's.
  
  Revision  Changes    Path
  1.18      +1 -1      jakarta-commons-sandbox/jelly/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- project.xml	12 Jun 2002 20:23:11 -0000	1.17
  +++ project.xml	12 Jun 2002 22:01:07 -0000	1.18
  @@ -145,7 +145,7 @@
       <dependency>
         <id>werkz</id>
         <type>required</type>
  -      <version>1.0-build-1</version>
  +      <version>1.0-build-2</version>
       </dependency>
       
       <!-- 
  
  
  
  1.3       +2 -3      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/AttainGoalTag.java
  
  Index: AttainGoalTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/AttainGoalTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AttainGoalTag.java	12 Jun 2002 20:12:46 -0000	1.2
  +++ AttainGoalTag.java	12 Jun 2002 22:01:07 -0000	1.3
  @@ -98,7 +98,7 @@
           Session session = null;
   
           if ( attainTag == null ) {
  -            session = new Session();
  +            session = new JellySession( output );
           } else {
               session = attainTag.getSession();
           }
  @@ -111,7 +111,6 @@
   
           project.attainGoal( getName(),
                               session );
  -        
       }
       
       // Properties
  
  
  
  1.2       +2 -3      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/AttainTag.java
  
  Index: AttainTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/AttainTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttainTag.java	12 Jun 2002 06:07:29 -0000	1.1
  +++ AttainTag.java	12 Jun 2002 22:01:07 -0000	1.2
  @@ -83,7 +83,6 @@
       
       public AttainTag() {
           log.debug( "ctor()" );
  -        this.session = new Session();
       }
   
       // Tag interface
  @@ -94,7 +93,7 @@
        * then run all the current targets
        */
       public void doTag(final XMLOutput output) throws Exception {
  -        this.session.clear();
  +        this.session = new JellySession( output );
           
           getBody().run(context, output);
       }
  
  
  
  1.7       +9 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/ProjectTag.java
  
  Index: ProjectTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/ProjectTag.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ProjectTag.java	12 Jun 2002 19:28:08 -0000	1.6
  +++ ProjectTag.java	12 Jun 2002 22:01:07 -0000	1.7
  @@ -67,6 +67,7 @@
   import org.apache.commons.jelly.JellyException;
   import org.apache.commons.jelly.TagSupport;
   import org.apache.commons.jelly.XMLOutput;
  +import org.apache.commons.jelly.tags.ant.AntTagLibrary;
   
   /** 
    * The root tag of a Project definition.
  @@ -110,6 +111,14 @@
       public void doTag(XMLOutput output) throws Exception {       
           // force project to be lazily constructed        
           getProject(); 
  +
  +        AntTagLibrary ant = (AntTagLibrary) context.getTagLibrary( "jelly:ant" );
  +
  +        org.apache.tools.ant.Project antProject = ant.getProject();
  +
  +        antProject.getBuildListeners().clear();
  +
  +        antProject.addBuildListener( new JellyBuildListener( output ) );
           
           getBody().run(context, output);
       }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/JellyBuildListener.java
  
  Index: JellyBuildListener.java
  ===================================================================
  
  package org.apache.commons.jelly.tags.werkz;
  
  import org.apache.commons.jelly.XMLOutput;
  
  import org.apache.tools.ant.BuildListener;
  import org.apache.tools.ant.BuildEvent;
  
  import org.xml.sax.SAXException;
  
  import java.util.Stack;
  
  public class JellyBuildListener implements BuildListener
  {
      private XMLOutput out;
  
      private Stack taskStack;
  
      public JellyBuildListener(XMLOutput out) {
          this.taskStack = new Stack();
          this.out = out;
      }
  
      public void buildFinished(BuildEvent event) {
  
      }
  
      public void buildStarted(BuildEvent event) {
  
      }
  
      public void messageLogged(BuildEvent event) {
  
          try
          {
              if ( this.taskStack.isEmpty() )
              {
                  out.write( event.getMessage() + "\n" );
              }
              else
              {
                  out.write( "    [" + this.taskStack.peek() + "] " + event.getMessage() +
"\n" );
              }
          }
          catch (SAXException e)
          {
              // ignore
          }
      }
  
      public void targetFinished(BuildEvent event) {
      }
  
      public void targetStarted(BuildEvent event) {
      }
  
      public void taskFinished(BuildEvent event) {
          this.taskStack.pop();
      }
  
      public void taskStarted(BuildEvent event) {
          this.taskStack.push( event.getTask().getTaskName() );
      }
  
  }
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/JellySession.java
  
  Index: JellySession.java
  ===================================================================
  
  package org.apache.commons.jelly.tags.werkz;
  
  import org.apache.commons.jelly.XMLOutput;
  
  import org.xml.sax.SAXException;
  
  import com.werken.werkz.Session;
  
  public class JellySession extends Session
  {
      private XMLOutput out;
  
      public JellySession(XMLOutput out)
      {
          this.out = out;
      }
  
      public void info(String message)
      {
          try
          {
              this.out.write( message + "\n" );
          }
          catch (SAXException e)
          {
              // ignore
          }
      }
  
      public void warn(String message)
      {
          try
          {
              this.out.write( message + "\n" );
          }
          catch (SAXException e)
          {
              // ignore
          }
      }
  
      public void error(String message)
      {
          try
          {
              this.out.write( message + "\n" );
          }
          catch (SAXException e)
          {
              // ignore
          }
      }
  }
  
  
  
  1.7       +7 -16     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- example.jelly	12 Jun 2002 19:47:05 -0000	1.6
  +++ example.jelly	12 Jun 2002 22:01:07 -0000	1.7
  @@ -1,5 +1,8 @@
   <?xml version="1.0"?>
  -<werkz:project xmlns:j="jelly:core" xmlns="jelly:ant" xmlns:werkz="jelly:werkz">
  +<werkz:project 
  +       xmlns="jelly:ant" 
  +       xmlns:j="jelly:core" 
  +       xmlns:werkz="jelly:werkz">
   
     <werkz:goal name="compile" prereqs="init">
       <echo message="Running compile goal's action"/>
  @@ -22,21 +25,9 @@
     <!-- 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">
  -
  -  	       <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>
  +    <j:forEach var="arg" items="${args}" begin="1">
  +      <werkz:attainGoal name="${arg}"/> 
  +    </j:forEach>
   
     </werkz:attain>
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message