donaldp     02/02/18 01:02:10

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/components/builder
                        DefaultProjectBuilder.java
  Log:
  Start simplifying so that metrics task does not complain as much
  
  Revision  Changes    Path
  1.32      +53 -38    
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java
  
  Index: DefaultProjectBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- DefaultProjectBuilder.java        14 Feb 2002 10:53:53 -0000      1.31
  +++ DefaultProjectBuilder.java        18 Feb 2002 09:02:10 -0000      1.32
  @@ -34,7 +34,7 @@
    * Default implementation to construct project from a build file.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
  - * @version $Revision: 1.31 $ $Date: 2002/02/14 10:53:53 $
  + * @version $Revision: 1.32 $ $Date: 2002/02/18 09:02:10 $
    */
   public class DefaultProjectBuilder
       extends AbstractLogEnabled
  @@ -372,19 +372,7 @@
           final String ifCondition = target.getAttribute( "if", null );
           final String unlessCondition = target.getAttribute( "unless", null );
   
  -        if( null == name )
  -        {
  -            final String message =
  -                REZ.getString( "ant.target-noname.error", 
target.getLocation() );
  -            throw new Exception( message );
  -        }
  -
  -        if( !validName( name ) )
  -        {
  -            final String message =
  -                REZ.getString( "ant.target-bad-name.error", 
target.getLocation() );
  -            throw new Exception( message );
  -        }
  +        verifyName( name, target );
   
           if( getLogger().isDebugEnabled() )
           {
  @@ -392,34 +380,34 @@
               getLogger().debug( message );
           }
   
  -        if( null != ifCondition && null != unlessCondition )
  +        final String[] dependencies = buildDependsList( depends, target );
  +        final Condition condition = buildCondition( ifCondition, 
unlessCondition, target );
  +        final Target defaultTarget =
  +            new Target( condition, target.getChildren(), dependencies );
  +
  +        //add target to project
  +        project.addTarget( name, defaultTarget );
  +    }
  +
  +    private void verifyName( final String name, final Configuration target ) 
throws Exception
  +    {
  +        if( null == name )
           {
               final String message =
  -                REZ.getString( "ant.target-bad-logic.error", 
target.getLocation() );
  +                REZ.getString( "ant.target-noname.error", 
target.getLocation() );
               throw new Exception( message );
           }
   
  -        Condition condition = null;
  -
  -        if( null != ifCondition )
  -        {
  -            if( getLogger().isDebugEnabled() )
  -            {
  -                final String message = REZ.getString( 
"ant.target-if.notice", ifCondition );
  -                getLogger().debug( message );
  -            }
  -            condition = new Condition( true, ifCondition );
  -        }
  -        else if( null != unlessCondition )
  +        if( !validName( name ) )
           {
  -            if( getLogger().isDebugEnabled() )
  -            {
  -                final String message = REZ.getString( 
"ant.target-unless.notice", unlessCondition );
  -                getLogger().debug( message );
  -            }
  -            condition = new Condition( false, unlessCondition );
  +            final String message =
  +                REZ.getString( "ant.target-bad-name.error", 
target.getLocation() );
  +            throw new Exception( message );
           }
  +    }
   
  +    private String[] buildDependsList( final String depends, final 
Configuration target ) throws Exception
  +    {
           String[] dependencies = null;
   
           //apply depends attribute
  @@ -451,12 +439,39 @@
   
               dependencies = (String[])dependsList.toArray( new String[ 0 ] );
           }
  +        return dependencies;
  +    }
   
  -        final Target defaultTarget =
  -            new Target( condition, target.getChildren(), dependencies );
  +    private Condition buildCondition( final String ifCondition, final String 
unlessCondition, final Configuration target ) throws Exception
  +    {
  +        if( null != ifCondition && null != unlessCondition )
  +        {
  +            final String message =
  +                REZ.getString( "ant.target-bad-logic.error", 
target.getLocation() );
  +            throw new Exception( message );
  +        }
   
  -        //add target to project
  -        project.addTarget( name, defaultTarget );
  +        Condition condition = null;
  +
  +        if( null != ifCondition )
  +        {
  +            if( getLogger().isDebugEnabled() )
  +            {
  +                final String message = REZ.getString( 
"ant.target-if.notice", ifCondition );
  +                getLogger().debug( message );
  +            }
  +            condition = new Condition( true, ifCondition );
  +        }
  +        else if( null != unlessCondition )
  +        {
  +            if( getLogger().isDebugEnabled() )
  +            {
  +                final String message = REZ.getString( 
"ant.target-unless.notice", unlessCondition );
  +                getLogger().debug( message );
  +            }
  +            condition = new Condition( false, unlessCondition );
  +        }
  +        return condition;
       }
   
       protected boolean validName( final String name )
  
  
  

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

Reply via email to