Browse Source

Start simplifying so that metrics task does not complain as much

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271408 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
6e89cb024f
1 changed files with 52 additions and 37 deletions
  1. +52
    -37
      proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java

+ 52
- 37
proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java View File

@@ -372,19 +372,7 @@ public class DefaultProjectBuilder
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 @@ public class DefaultProjectBuilder
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 @@ public class DefaultProjectBuilder

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 )


Loading…
Cancel
Save