ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From darr...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant Ant1CompatTargetTask.java
Date Tue, 11 Jun 2002 05:31:33 GMT
darrell     2002/06/10 22:31:33

  Added:       ant1compat/src/java/org/apache/tools/ant
                        Ant1CompatTargetTask.java
  Log:
  Missed new file - oops.
  
  Revision  Changes    Path
  1.1                  jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/Ant1CompatTargetTask.java
  
  Index: Ant1CompatTargetTask.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.tools.ant;
  
  import org.apache.antlib.project.TargetTask;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * An Ant1 compatible version of >target/<, which allows
   * "if" and "unless" attributes on the target itself.
   *
   * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/11 05:31:33 $
   *
   * @todo Extract AbstractTargetTask from TargetTask and move to framework,
   *       so we can remove dependency between Ant1Compat and Project antlib.
   */
  public class Ant1CompatTargetTask
      extends TargetTask
  {
      private String m_ifCondition;
      private String m_unlessCondition;
  
      public void setIf( String ifCondition )
      {
          m_ifCondition = ifCondition;
      }
  
      public void setUnless( String unlessCondition )
      {
          m_unlessCondition = unlessCondition;
      }
  
  
      protected void executeContainedTasks()
              throws TaskException
      {
          getContext().debug( "Using custom target task." );
          if ( m_ifCondition != null )
          {
              getContext().debug( "Found if." );
              Object propVal = getContext().getProperty( m_ifCondition );
              if ( propVal == null )
              {
                  getContext().debug( "If prop not set" );
                  return;
              }
              getContext().debug( "If prop set." );
          }
  
          if ( m_unlessCondition != null )
          {
              getContext().debug( "Found unless." );
              Object propVal = getContext().getProperty( m_unlessCondition );
              if ( propVal != null )
              {
                  getContext().debug( "Unless prop set." );
                  return;
              }
              getContext().debug( "Unless prop not set." );
          }
          getContext().debug( "Executing tasks." );
          super.executeContainedTasks();
      }
  
  }
  
  
  

--
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