werken      2002/06/13 21:34:01

  Modified:    .        jars.list project.xml
               src/bin  core-plugin.jelly driver.jelly plugins.jelly
               src/java/org/apache/maven/app Maven.java
  Added:       src/java/org/apache/maven/app UnknownGoalException.java
  Log:
  Moving actual attain-goal loop back into Java from jellyscript.
  
  Revision  Changes    Path
  1.23      +2 -2      jakarta-turbine-maven/jars.list
  
  Index: jars.list
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/jars.list,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- jars.list 14 Jun 2002 03:41:31 -0000      1.22
  +++ jars.list 14 Jun 2002 04:34:00 -0000      1.23
  @@ -33,7 +33,6 @@
   commons-digester-1.2.jar
   commons-graph-0.8.jar
   commons-io-0.1.jar
  -commons-jelly-1.0-dev.20020613.091851.jar
   commons-jexl-1.0-dev.jar
   commons-lang-1.0-dev.jar
   commons-logging-1.0.jar
  @@ -47,6 +46,7 @@
   regexp-1.2.jar
   velocity-1.4-dev.jar
   velocity-dvsl-0.43.jar
  -werkz-1.0-dev.20020613.091536.jar
   xercesImpl-2.0.0.jar
   xmlParserAPIs-2.0.0.jar
  +werkz-1.0-dev.20020613.091536.jar
  +commons-jelly-1.0-dev.20020614.035258.jar
  
  
  
  1.112     +6 -1      jakarta-turbine-maven/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/project.xml,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- project.xml       14 Jun 2002 03:41:31 -0000      1.111
  +++ project.xml       14 Jun 2002 04:34:00 -0000      1.112
  @@ -312,8 +312,13 @@
   
       <dependency>
         <id>commons-jelly</id>
  -      <version>1.0-dev.20020613.091851</version>
  +      <version>1.0-dev.20020614.035258</version>
         <url>http://jakarta.apache.org/commons/sandbox/jelly/</url>
  +    </dependency>
  +
  +    <dependency>
  +      <id>werkz</id>
  +      <version>1.0-dev.20020613.091536</version>
       </dependency>
   
       <dependency>
  
  
  
  1.3       +17 -18    jakarta-turbine-maven/src/bin/core-plugin.jelly
  
  Index: core-plugin.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/bin/core-plugin.jelly,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- core-plugin.jelly 13 Jun 2002 21:37:33 -0000      1.2
  +++ core-plugin.jelly 14 Jun 2002 04:34:01 -0000      1.3
  @@ -1,51 +1,50 @@
   
   <jelly
       trim="true"
  -    xmlns:werkz="jelly:werkz"
       xmlns:ant="jelly:ant"
  -    xmlns="jelly:core">
  +    xmlns="jelly:jeez">
   
  -    <werkz:project>
  -        <werkz:goal
  +    <project>
  +        <goal
             name="maven:env">
   
  -        <ant:echo>
  +        <echo>
             <whitespace>
              maven.home = <expr value="${maven.home}"/>
               maven.bin = <expr value="${maven.bin}"/>
                 basedir = <expr value="${basedir}"/>
             </whitespace>
  -        </ant:echo>
  +        </echo>
   
  -        </werkz:goal>
  +        </goal>
   
  -        <werkz:goal 
  +        <goal 
             name="maven:prepare-source">
   
  -        </werkz:goal>
  +        </goal>
   
  -        <werkz:goal 
  +        <goal 
             name="maven:compile" 
             prereqs="maven:prepare-source">
   
  -        </werkz:goal>
  +        </goal>
   
  -        <werkz:goal
  +        <goal
             name="maven:compile-test">
   
  -        </werkz:goal>
  +        </goal>
   
  -        <werkz:goal
  +        <goal
             name="maven:test"
             prereqs="maven:compile-test">
     
  -        </werkz:goal>
  +        </goal>
   
  -        <werkz:goal 
  +        <goal 
             name="maven:jar" 
             prereqs="maven:compile, maven:test">
  -        </werkz:goal>
  +        </goal>
   
  -    </werkz:project>
  +    </project>
   
   </jelly>
  
  
  
  1.4       +3 -11     jakarta-turbine-maven/src/bin/driver.jelly
  
  Index: driver.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/bin/driver.jelly,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- driver.jelly      13 Jun 2002 21:37:33 -0000      1.3
  +++ driver.jelly      14 Jun 2002 04:34:01 -0000      1.4
  @@ -1,21 +1,13 @@
   
   <jelly
       trim="true"
  -    xmlns:werkz="jelly:werkz"
  -    xmlns:ant="jelly:ant"
  -    xmlns="jelly:core">
  +    xmlns="jelly:jeez">
   
  -    <werkz:project>
  +    <project>
   
         <include uri="init.jelly"/>
         <include uri="plugins.jelly"/>
   
  -      <werkz:attain>
  -          <forEach var="goal" items="${goals}">
  -              <werkz:attainGoal name="${goal}"/>
  -          </forEach>
  -      </werkz:attain>
  -
  -    </werkz:project>
  +    </project>
   
   </jelly>
  
  
  
  1.3       +1 -1      jakarta-turbine-maven/src/bin/plugins.jelly
  
  Index: plugins.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/bin/plugins.jelly,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- plugins.jelly     13 Jun 2002 21:37:33 -0000      1.2
  +++ plugins.jelly     14 Jun 2002 04:34:01 -0000      1.3
  @@ -1,7 +1,7 @@
   
   <jelly
       trim="true"
  -    xmlns="jelly:core">
  +    xmlns="jelly:jeez">
   
       <include uri="core-plugin.jelly"/>
   
  
  
  
  1.4       +112 -21   jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java
  
  Index: Maven.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Maven.java        14 Jun 2002 02:00:25 -0000      1.3
  +++ Maven.java        14 Jun 2002 04:34:01 -0000      1.4
  @@ -70,7 +70,12 @@
   import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.parser.XMLParser;
  -import org.apache.commons.jelly.tags.ant.AntTagLibrary;
  +import org.apache.commons.jelly.tags.jeez.JeezTagLibrary;
  +import org.apache.commons.jelly.tags.werkz.JellySession;
  +
  +import com.werken.werkz.Goal;
  +import com.werken.werkz.Session;
  +import com.werken.werkz.UnattainableGoalException;
   
   import java.io.File;
   import java.io.FileInputStream;
  @@ -81,6 +86,7 @@
   import java.util.List;
   import java.util.Properties;
   import java.util.Enumeration;
  +import java.util.Iterator;
   
   /** Command-line entry-point to maven.
    *
  @@ -274,7 +280,7 @@
        *
        *  @param args The command-line arguments.
        */
  -    public void initialize(String[] args) throws Exception {
  +    public boolean initialize(String[] args) throws Exception {
   
           // General premise:
           //
  @@ -288,10 +294,12 @@
           } catch (ParseException e) {
               System.err.println( e.getLocalizedMessage() );
               displayHelp();
  -            return;
  +            return false;
           }
           
  -        processCommandLine();
  +        if ( ! processCommandLine() ) {
  +            return false;
  +        }
   
           log.debug( this.toString() );
   
  @@ -301,6 +309,8 @@
   
           loadMavenProject();
           initializeJelly();
  +
  +        return true;
       }
   
       /** Retrieve the Jelly context.
  @@ -340,10 +350,19 @@
                                          getDir() );
   
           MavenAntProject antProject = initializeAntProject( this.jellyContext );
  -        AntTagLibrary antTagLib = new AntTagLibrary( antProject );
   
  -        this.jellyContext.registerTagLibrary( "jelly:ant",
  -                                              antTagLib );
  +        this.jellyContext.setVariable( "org.apache.commons.jelly.ant.Project",
  +                                       antProject );
  +
  +        // AntTagLibrary antTagLib = new AntTagLibrary( antProject );
  +        // this.jellyContext.registerTagLibrary( "jelly:ant",
  +        // antTagLib );
  +
  +        JeezTagLibrary jeezTagLib = new JeezTagLibrary( antProject );
  +
  +        this.jellyContext.registerTagLibrary( "jelly:jeez",
  +                                              jeezTagLib );
  +
   
           if ( hasProjectBuildFile() ) {
               this.jellyContext.setVariable( "maven.project.buildFile.url",
  @@ -374,6 +393,12 @@
        */
       void run() throws Exception {
   
  +        List goalNames   = getGoalNames();
  +
  +        if ( goalNames.isEmpty() ) {
  +            return;
  +        }
  +            
           Writer writer = new BufferedWriter(new OutputStreamWriter(System.out));
           Script script = compileScript();
           XMLOutput output = XMLOutput.createXMLOutput(writer);
  @@ -381,8 +406,39 @@
           JellyContext context = getJellyContext();
   
           context.setVariable("goals", getGoalNames() );
  +
           script.run(context, output);
   
  +        com.werken.werkz.Project werkzProject =
  +            (com.werken.werkz.Project) context.getVariable( 
"org.apache.commons.jelly.werkz.Project" );
  +
  +        Iterator goalNameIter = goalNames.iterator();
  +        String   eachGoalName = null;
  +        
  +        Goal eachGoal = null;
  +
  +        while ( goalNameIter.hasNext() ) {
  +            
  +            eachGoalName = (String) goalNameIter.next();
  +            
  +            eachGoal = werkzProject.getGoal( eachGoalName );
  +            
  +            if ( eachGoal == null ) {
  +                throw new UnknownGoalException( eachGoalName );
  +            }
  +        }
  +
  +        goalNameIter = goalNames.iterator();
  +
  +        Session session = new JellySession( output );
  +
  +        while ( goalNameIter.hasNext() ) {
  +            eachGoalName = (String) goalNameIter.next();
  +            werkzProject.attainGoal( eachGoalName,
  +                                     session );
  +        }
  +
  +        writer.flush();
           writer.close();
       }
   
  @@ -410,7 +466,8 @@
       public void displayHelp() {
           HelpFormatter format = new HelpFormatter();
           
  -        format.printHelp( "maven [options] [gaol [goal2 [goal3] ...]]", "Options:", 
this.options, "\n" );
  +        format.printHelp( "maven [options] [gaol [goal2 [goal3] ...]]", 
"\nOptions:", this.options, "\n" );
  +        System.out.println("");
       }
   
       /** Parse the command-line.
  @@ -448,13 +505,13 @@
   
       /** Process the command-line.
        */
  -    void processCommandLine()
  +    boolean processCommandLine()
       {
           CommandLine cli = getCli();
   
           if ( cli.hasOption( 'h' ) ) {
               displayHelp();
  -            return;
  +            return false;
           }
   
           if ( cli.hasOption( 'd' ) ) {
  @@ -472,10 +529,40 @@
           loadPropertiesChain();
   
           if ( cli.hasOption( 'D' ) ) {
  -            // cache command-line specified properties.
  +            String[] defStrs = cli.getOptionValues( 'D' );
  +
  +            for ( int i = 0 ; i < defStrs.length ; ++i ) {
  +                setCliProperty( defStrs[i] );
  +            }
           }
   
           this.goalNames = cli.getArgList();
  +
  +        return true;
  +    }
  +
  +    /** Set a property based upon a commandline
  +     *  <code>name=value</code> string.
  +     *
  +     *  @param defStr The <code>name=value</code> string.
  +     */
  +    void setCliProperty(String defStr) {
  +
  +        String name  = null;
  +        String value = null;
  +        int equalLoc = defStr.indexOf( "=" );
  +
  +        if ( equalLoc <= 0 ) {
  +            name  = defStr.trim();
  +            value = "true";
  +        } else {
  +            name = defStr.substring( 0,
  +                                     equalLoc ).trim();
  +            value = defStr.substring( equalLoc+1 ).trim();
  +        }
  +
  +        this.properties.put( name,
  +                             value );
       }
   
       /** Load the maven project descriptor.
  @@ -568,15 +655,13 @@
        *  @param args The command-line arguments.
        */
       public static void main(String[] args) {
  -        // log.info( "maven: intelligent projects" );
  -
  -        System.out.println( "            maven: intelligent projects" );
  -        System.out.println( "" );
   
           Maven maven = new Maven();
   
           try {
  -            maven.initialize( args );
  +            if ( ! maven.initialize( args ) ) {
  +                return;
  +            }
           } catch (Exception e) {
               System.err.println( "Error initializing: " + e.getLocalizedMessage() );
               e.printStackTrace();
  @@ -585,6 +670,10 @@
   
           Project mavenProject = maven.getMavenProject();
   
  +        System.out.println( "" );
  +        System.out.println( "            maven: intelligent projects" );
  +        System.out.println( "" );
  +
           System.out.println( "project-directory: "
                               + maven.getDir() );
           System.out.println( "          project: "
  @@ -596,12 +685,14 @@
   
           System.out.println( "" );
   
  -        try
  -        {
  +        try {
               maven.run();
  -        }
  -        catch (Exception e)
  -        {
  +        } catch (UnknownGoalException e) {
  +            System.err.println( "BUILD FAILED" );
  +            System.err.println( "Goal \"" + e.getGoalName() + "\" does not exist in 
this project." );
  +            System.err.println( "" );
  +            return;
  +        } catch (Exception e) {
               e.printStackTrace();
           }
       }
  
  
  
  1.1                  
jakarta-turbine-maven/src/java/org/apache/maven/app/UnknownGoalException.java
  
  Index: UnknownGoalException.java
  ===================================================================
  package org.apache.maven.app;
  
  /* ====================================================================
   * 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 Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", 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/>.
   *
   * ====================================================================
   */
  
  /** Indicates an attempt to access an unknown werkz goal.
   *
   *  @author <a href="mailto:[EMAIL PROTECTED]";>bob mcwhirter</a>
   */
  public class UnknownGoalException extends Exception {
  
      /** Name of unknown goal. */
      private String goalName;
      
      /** Construct with an unknown goal name.
       *
       *  @param goalName The name of the unknown goal.
       */
      public UnknownGoalException(String goalName) {
          super( "Unknown goal \"" + goalName + "\"" );
          this.goalName = goalName;
      }
  
      /** Retrieve the unknown goal name.
       *
       *  @return The name of the unknown goal.
       */
      public String getGoalName() {
          return this.goalName;
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to