You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2002/02/28 23:37:25 UTC

cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/executor AbstractExecutor.java Executor.java ProjectExecutor.java

jvanzyl     02/02/28 14:37:25

  Added:       src/java/org/apache/maven/executor AbstractExecutor.java
                        Executor.java ProjectExecutor.java
  Log:
  A package that represents your basic bean that execute()'s something. The
  executors are not fully decoupled from Ant as the base class provides some
  ant features so that the TaskAdapter can be used but the subclasses are
  just beans now and don't have any direct ant references apart from using
  utilties like the directory scanner (which should probably go to the commons
  as it is very useful).
  
  Revision  Changes    Path
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/executor/AbstractExecutor.java
  
  Index: AbstractExecutor.java
  ===================================================================
  package org.apache.maven.executor;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 apache@apache.org.
   *
   * 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/>.
   */
  
  import org.apache.tools.ant.Project;
  
  /**
   * This class will allow all subclasses to be used by the
   * TaskAdapter that comes with Ant. A more standard bean,
   * a class that doesn't extend Task, can be used by Ant
   * as long a setProject() and execute() method are
   * available.
   *
   * @author <a href="jason@zenplex.com">Jason van Zyl</a>
   * @version $Id: AbstractExecutor.java,v 1.1 2002/02/28 22:37:25 jvanzyl Exp $
   */
  public abstract class AbstractExecutor
      implements Executor
  {
      /**
       * Ant project.
       */
      private Project project;
  
      /**
       * Set Ant project.
       */
      public void setProject(Project project)
      {
          this.project = project;
      }        
  
      /**
       * Get Ant project.
       */
      public Project getProject()
      {
          return project;
      }        
  
      /**
       * When used as an Ant task the Ant logging
       * mechanism will be used.
       */
      public void log(String message)
      {
          project.log(message);
      }        
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/executor/Executor.java
  
  Index: Executor.java
  ===================================================================
  package org.apache.maven.executor;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 apache@apache.org.
   *
   * 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/>.
   */
  
  /**
   * A simple interface that executor beans can implement so that they
   * can be used by adapters like the ant TaskAdapter.
   *
   * @author <a href="jason@zenplex.com">Jason van Zyl</a>
   * @version $Id: Executor.java,v 1.1 2002/02/28 22:37:25 jvanzyl Exp $
   */
  public interface Executor
  {
      public void execute() 
          throws Exception;
  
      public void log(String message);
  }
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/executor/ProjectExecutor.java
  
  Index: ProjectExecutor.java
  ===================================================================
  package org.apache.maven.executor;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 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 apache@apache.org.
   *
   * 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/>.
   */
  
  import java.io.File;
  
  import org.apache.tools.ant.BuildException;
  
  import org.apache.maven.MavenUtils;
  import org.apache.maven.project.Project;
  
  import org.apache.stratum.xo.Mapper;
  
  /**
   * An executor that uses the Template Method pattern to alleviate the
   * burden subclasses having to create the Maven project object and
   * simply allow the subclass to manipulate the Maven project object
   * in any desired fashion.
   *
   * @author <a href="jason@zenplex.com">Jason van Zyl</a>
   * @version $Id: ProjectExecutor.java,v 1.1 2002/02/28 22:37:25 jvanzyl Exp $
   */
  public abstract class ProjectExecutor
      extends AbstractExecutor
  {
      /**
       * Project descriptor.
       */
      protected File projectDescriptor;
  
      /**
       * Project
       */
      protected Project mavenProject;
  
      /**
       * Set the project descriptor file. This file must exist.
       */
      public void setProjectDescriptor (File projectDescriptor)
      {
          this.projectDescriptor = projectDescriptor;
      }
  
      /**
       * Get the project using the set project descriptor
       */
      protected void getMavenProject()
          throws Exception
      {
          if (projectDescriptor == null)
          {
              throw new Exception("The projectDescriptor property must be set.");
          }            
          
          mavenProject = MavenUtils.getProject(projectDescriptor);
      }
  
      /**
       * Execute the task.
       *
       * @throws BuildException
       */
      public void execute()
          throws Exception
      {
          getMavenProject();
          doExecute();        
      }        
  
      /**
       * Method to override in subclasses that make use of the maven project
       * object created by getProject()
       */
      public abstract void doExecute()
          throws Exception;
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>