ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project AbstractAntTask.java AntCallTask.java AntParam.java AntTask.java Resources.properties
Date Fri, 03 May 2002 10:34:03 GMT
donaldp     02/05/03 03:34:02

  Modified:    antlib/src/java/org/apache/antlib/core Resources.properties
               antlib/src/java/org/apache/antlib/project
                        Resources.properties
  Added:       antlib/src/java/org/apache/antlib/project
                        AbstractAntTask.java AntCallTask.java AntParam.java
                        AntTask.java
  Removed:     antlib/src/java/org/apache/antlib/core AbstractAntTask.java
                        AntCallTask.java AntParam.java AntTask.java
  Log:
  Move the AntCall stuff into the project antlib as thats where it will belong
  in the future.
  
  Revision  Changes    Path
  1.3       +1 -8      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/core/Resources.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Resources.properties	28 Apr 2002 05:04:48 -0000	1.2
  +++ Resources.properties	3 May 2002 10:34:02 -0000	1.3
  @@ -31,11 +31,4 @@
   trycatch.missing-second.error=Missing <catch/> or <finally/> elements from
<try-catch/> task.
   
   filetokenset.not-a-file.error=File {0} does not exist, or is not a file.
  -filetokenset.read-tokens.error=Could not read tokens from {0}.
  -
  -param.noname.error=Missing name from parameter.
  -param.novalue.error=Missing value from parameter "{0}".
  -
  -antcall.invalid-project.error=Project-reference "{0}" not found.
  -
  -project.no-project-element.error=Project file must be enclosed in project element.
  +filetokenset.read-tokens.error=Could not read tokens from {0}.
  \ No newline at end of file
  
  
  
  1.4       +8 -1      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/Resources.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Resources.properties	3 May 2002 09:26:13 -0000	1.3
  +++ Resources.properties	3 May 2002 10:34:02 -0000	1.4
  @@ -6,4 +6,11 @@
   typelib.missing-library.error=Missing library attribute from typelib statement.
   typelib.missing-name.error=Specified role ("{0}") but missing name from typelib statement.
   typelib.missing-role.error=Specified name ("{0}") but missing role from typelib statement.
  -typelib.no-deploy.error=Could not import types from Type Library "{0}".
  \ No newline at end of file
  +typelib.no-deploy.error=Could not import types from Type Library "{0}".
  +
  +param.noname.error=Missing name from parameter.
  +param.novalue.error=Missing value from parameter "{0}".
  +
  +antcall.invalid-project.error=Project-reference "{0}" not found.
  +
  +project.no-project-element.error=Project file must be enclosed in project element.
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AbstractAntTask.java
  
  Index: AbstractAntTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.project;
  
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.ExecuteTarget;
  
  /**
   * Abstract base class for Tasks which execute targets.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/03 10:34:02 $
   */
  public abstract class AbstractAntTask
      extends AbstractTask
  {
      private final ExecuteTarget m_exe = new ExecuteTarget();
  
      /**
       * Specify whether should inherit properties in sub-build.
       *
       * @param inheritAll true to inherit else false
       */
      public void setInheritAll( final boolean inheritAll )
      {
          m_exe.setInheritAll( inheritAll );
      }
  
      /**
       * set the target to process. If none is defined it will
       * execute the default target of the build file
       */
      public void setTarget( final String target )
      {
          m_exe.setTarget( target );
      }
  
      /**
       * Add a parameter to processing of build file.
       *
       * @param param the parameter
       */
      public void addParam( final AntParam param )
          throws TaskException
      {
          param.validate();
          m_exe.getParameters().put( param.getName(), param.getValue() );
      }
  
      /**
       * Execute the specified build, with specified parameters.
       *
       * @throws TaskException if an error occurs.
       */
      public void execute()
          throws TaskException
      {
          prepare( m_exe );
          m_exe.execute( getContext() );
      }
  
      /**
       * Prepares for execution, and sets the project containing the target
       * to be executed.   Subclasses will override this method to provide
       * different means of obtaining a project to execute.
       */
      protected abstract void prepare( ExecuteTarget exe )
          throws TaskException;
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AntCallTask.java
  
  Index: AntCallTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.project;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.interfaces.oldmodel.Project;
  import org.apache.myrmidon.framework.ExecuteTarget;
  
  /**
   * A task which executes a target in the current project,
   * or a referenced project.
   *
   * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/03 10:34:02 $
   * @ant.task name="ant-call"
   */
  public class AntCallTask
      extends AbstractAntTask
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( AntCallTask.class );
  
      private String m_project;
  
      /**
       * Specifies the project to execute. If not specified, the current
       * project is used.
       * @param project the name of the Project to execute.
       */
      public void setProject( String project )
      {
          m_project = project;
      }
  
      /**
       * Get/create/build the project which will be executed.
       */
      protected void prepare( final ExecuteTarget exe ) throws TaskException
      {
          final Project currentProject =
              (Project)getContext().getService( Project.class );
  
          // By default, use the current project.
          Project referencedProject = currentProject;
  
          if( m_project != null )
          {
              referencedProject = currentProject.getProject( m_project );
              if( referencedProject == null )
              {
                  final String message =
                      REZ.getString( "antcall.invalid-project.error" );
                  throw new TaskException( message );
              }
          }
  
          exe.setProject( referencedProject );
      }
  }
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AntParam.java
  
  Index: AntParam.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.project;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * Simple holder for parameters.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/03 10:34:02 $
   * @todo Refactor this and all the other parameter, sysproperty,
   *   property etc into a single class in framework
   */
  public class AntParam
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( AntParam.class );
  
      private String m_name;
      private Object m_value;
  
      /**
       * Set the name of the parameter.
       *
       * @param name the name of parameter
       */
      public void setName( final String name )
      {
          m_name = name;
      }
  
      /**
       * Set the value of the parameter.
       *
       * @param value the parameter value
       */
      public void setValue( final Object value )
      {
          m_value = value;
      }
  
      /**
       * Retrieve name of parameter.
       *
       * @return the name of parameter.
       */
      public String getName()
      {
          return m_name;
      }
  
      /**
       * Retrieve the value of parameter.
       *
       * @return the value of parameter.
       */
      public Object getValue()
      {
          return m_value;
      }
  
      /**
       * Make sure that neither the name or the value
       * is null.
       */
      public void validate()
          throws TaskException
      {
          if( null == m_name )
          {
              final String message = REZ.getString( "param.noname.error" );
              throw new TaskException( message );
          }
          else if( null == m_value )
          {
              final String message =
                  REZ.getString( "param.novalue.error", m_name );
              throw new TaskException( message );
          }
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AntTask.java
  
  Index: AntTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.antlib.project;
  
  import java.io.File;
  import org.apache.myrmidon.framework.ExecuteTarget;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * Executes a target in a named build file.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.task name="ant"
   */
  public class AntTask
      extends AbstractAntTask
  {
      /**
       * Default build file.
       */
      private static final String DEFAULT_BUILD_FILE = "build.ant";
  
      /**
       * The build file which to execute. If not set defaults to
       * using "build.ant" in the basedir of current project.
       */
      private File m_file;
  
      /**
       * The "type" of the build file. By default this is null which
       * means the type will be determined by the build file extension.
       */
      private String m_type;
  
      /**
       * set the build file to process.
       *
       * @param file the build file
       */
      public void setFile( final File file )
      {
          m_file = file;
      }
  
      /**
       * set the type of build file.
       *
       * @param type the type of build file
       */
      public void setType( final String type )
      {
          m_type = type;
      }
  
      /**
       * Prepares for executing the target.
       */
      protected void prepare( final ExecuteTarget exe )
          throws TaskException
      {
          if( null == m_file )
          {
              m_file = getContext().resolveFile( DEFAULT_BUILD_FILE );
          }
  
          exe.setProjectFile( m_file, m_type );
      }
  }
  
  
  

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


Mime
View raw message