Browse Source

Started refactoring.

Made BuildException extend TaskException. Now BuildException is no longer a RuntimException and needs to be declared everywhere it could be thrown

Removed the constructors that took location info for BuildException. Location is something known about byt the container and the tasks them selves should not be worrying about that sort of thing

Removed a bunch of deprecated methods and features. Also moved all file handling utilities outside iof the Project class. To aid the transition I added a resolveFile method to the base ProjectComponent class.

480 odd compile errors left to clean up.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270158 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
7a3448dcea
100 changed files with 969 additions and 1661 deletions
  1. +68
    -55
      proposal/myrmidon/src/main/org/apache/tools/ant/AntClassLoader.java
  2. +0
    -37
      proposal/myrmidon/src/main/org/apache/tools/ant/BuildException.java
  3. +0
    -96
      proposal/myrmidon/src/main/org/apache/tools/ant/DesirableFilter.java
  4. +78
    -85
      proposal/myrmidon/src/main/org/apache/tools/ant/DirectoryScanner.java
  5. +9
    -8
      proposal/myrmidon/src/main/org/apache/tools/ant/FileScanner.java
  6. +154
    -134
      proposal/myrmidon/src/main/org/apache/tools/ant/IntrospectionHelper.java
  7. +18
    -17
      proposal/myrmidon/src/main/org/apache/tools/ant/Main.java
  8. +100
    -336
      proposal/myrmidon/src/main/org/apache/tools/ant/Project.java
  9. +7
    -0
      proposal/myrmidon/src/main/org/apache/tools/ant/ProjectComponent.java
  10. +58
    -52
      proposal/myrmidon/src/main/org/apache/tools/ant/ProjectHelper.java
  11. +2
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/RuntimeConfigurable.java
  12. +21
    -12
      proposal/myrmidon/src/main/org/apache/tools/ant/Target.java
  13. +2
    -0
      proposal/myrmidon/src/main/org/apache/tools/ant/Task.java
  14. +6
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/TaskAdapter.java
  15. +31
    -26
      proposal/myrmidon/src/main/org/apache/tools/ant/UnknownElement.java
  16. +10
    -9
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ant.java
  17. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
  18. +14
    -28
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java
  19. +3
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java
  20. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BZip2.java
  21. +4
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CVSPass.java
  22. +1
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CallTarget.java
  23. +16
    -16
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java
  24. +5
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Chmod.java
  25. +4
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
  26. +40
    -54
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Copy.java
  27. +13
    -11
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Cvs.java
  28. +5
    -11
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Definer.java
  29. +1
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Delete.java
  30. +1
    -8
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ear.java
  31. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Echo.java
  32. +5
    -18
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecTask.java
  33. +4
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Execute.java
  34. +2
    -11
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  35. +7
    -16
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  36. +2
    -7
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java
  37. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Filter.java
  38. +13
    -43
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
  39. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GUnzip.java
  40. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GZip.java
  41. +6
    -10
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Get.java
  42. +4
    -15
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Jar.java
  43. +14
    -47
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java
  44. +29
    -29
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java
  45. +8
    -15
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  46. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java
  47. +5
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Manifest.java
  48. +0
    -53
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
  49. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Mkdir.java
  50. +3
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Move.java
  51. +3
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Pack.java
  52. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Parallel.java
  53. +4
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Patch.java
  54. +4
    -17
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java
  55. +6
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Replace.java
  56. +6
    -5
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java
  57. +11
    -11
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  58. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SendEmail.java
  59. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sleep.java
  60. +24
    -77
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java
  61. +2
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Touch.java
  62. +5
    -21
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
  63. +5
    -5
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Unpack.java
  64. +1
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Untar.java
  65. +1
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java
  66. +1
    -7
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/War.java
  67. +19
    -47
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
  68. +5
    -17
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java
  69. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  70. +3
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java
  71. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java
  72. +0
    -17
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
  73. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java
  74. +0
    -7
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/defaults.properties
  75. +8
    -19
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
  76. +6
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java
  77. +6
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
  78. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ManifestFile.java
  79. +2
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java
  80. +3
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
  81. +4
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
  82. +4
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java
  83. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Script.java
  84. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java
  85. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java
  86. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java
  87. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
  88. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java
  89. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java
  90. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java
  91. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java
  92. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
  93. +3
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
  94. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java
  95. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java
  96. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java
  97. +2
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java
  98. +4
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
  99. +5
    -5
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java
  100. +12
    -12
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java

+ 68
- 55
proposal/myrmidon/src/main/org/apache/tools/ant/AntClassLoader.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant; package org.apache.tools.ant;

import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@@ -20,7 +21,9 @@ import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;


/** /**
* Used to load classes within ant with a different claspath from that used to * Used to load classes within ant with a different claspath from that used to
@@ -97,24 +100,25 @@ public class AntClassLoader extends ClassLoader implements BuildListener
* The project to which this class loader belongs. * The project to which this class loader belongs.
*/ */
private Project project; private Project project;

static static
{ {
try try
{ {
getProtectionDomain = Class.class.getMethod( "getProtectionDomain", new Class[0] );
getProtectionDomain = Class.class.getMethod( "getProtectionDomain", new Class[ 0 ] );
Class protectionDomain = Class.forName( "java.security.ProtectionDomain" ); Class protectionDomain = Class.forName( "java.security.ProtectionDomain" );
Class[] args = new Class[]{String.class, byte[].class, Integer.TYPE, Integer.TYPE, protectionDomain}; Class[] args = new Class[]{String.class, byte[].class, Integer.TYPE, Integer.TYPE, protectionDomain};
defineClassProtectionDomain = ClassLoader.class.getDeclaredMethod( "defineClass", args ); defineClassProtectionDomain = ClassLoader.class.getDeclaredMethod( "defineClass", args );


getContextClassLoader = Thread.class.getMethod( "getContextClassLoader", new Class[0] );
getContextClassLoader = Thread.class.getMethod( "getContextClassLoader", new Class[ 0 ] );
args = new Class[]{ClassLoader.class}; args = new Class[]{ClassLoader.class};
setContextClassLoader = Thread.class.getMethod( "setContextClassLoader", args ); setContextClassLoader = Thread.class.getMethod( "setContextClassLoader", args );
} }
catch( Exception e ) catch( Exception e )
{}
{
}
} }



/** /**
* Create a classloader for the given project using the classpath given. * Create a classloader for the given project using the classpath given.
* *
@@ -136,7 +140,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener
{ {
try try
{ {
addPathElement( ( String )pathElements[i] );
addPathElement( (String)pathElements[ i ] );
} }
catch( BuildException e ) catch( BuildException e )
{ {
@@ -169,7 +173,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener
addSystemPackageRoot( "javax" ); addSystemPackageRoot( "javax" );
} }



/** /**
* Create a classloader for the given project using the classpath given. * Create a classloader for the given project using the classpath given.
* *
@@ -243,17 +246,18 @@ public class AntClassLoader extends ClassLoader implements BuildListener
* current loader value for later resetting * current loader value for later resetting
*/ */
public void setThreadContextLoader() public void setThreadContextLoader()
throws TaskException
{ {
if( isContextLoaderSaved ) if( isContextLoaderSaved )
{ {
throw new BuildException( "Context loader has not been reset" );
throw new TaskException( "Context loader has not been reset" );
} }
if( getContextClassLoader != null && setContextClassLoader != null ) if( getContextClassLoader != null && setContextClassLoader != null )
{ {
try try
{ {
savedContextLoader savedContextLoader
= ( ClassLoader )getContextClassLoader.invoke( Thread.currentThread(), new Object[0] );
= (ClassLoader)getContextClassLoader.invoke( Thread.currentThread(), new Object[ 0 ] );
Object[] args = new Object[]{this}; Object[] args = new Object[]{this};
setContextClassLoader.invoke( Thread.currentThread(), args ); setContextClassLoader.invoke( Thread.currentThread(), args );
isContextLoaderSaved = true; isContextLoaderSaved = true;
@@ -261,11 +265,11 @@ public class AntClassLoader extends ClassLoader implements BuildListener
catch( InvocationTargetException ite ) catch( InvocationTargetException ite )
{ {
Throwable t = ite.getTargetException(); Throwable t = ite.getTargetException();
throw new BuildException( t.toString() );
throw new TaskException( t.toString() );
} }
catch( Exception e ) catch( Exception e )
{ {
throw new BuildException( e.toString() );
throw new TaskException( e.toString() );
} }
} }
} }
@@ -293,22 +297,22 @@ public class AntClassLoader extends ClassLoader implements BuildListener
if( url != null ) if( url != null )
{ {
log( "Resource " + name + " loaded from parent loader", log( "Resource " + name + " loaded from parent loader",
Project.MSG_DEBUG );
Project.MSG_DEBUG );


} }
else else
{ {
// try and load from this loader if the parent either didn't find // try and load from this loader if the parent either didn't find
// it or wasn't consulted. // it or wasn't consulted.
for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && url == null; )
for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && url == null; )
{ {
File pathComponent = ( File )e.nextElement();
File pathComponent = (File)e.nextElement();
url = getResourceURL( pathComponent, name ); url = getResourceURL( pathComponent, name );
if( url != null ) if( url != null )
{ {
log( "Resource " + name log( "Resource " + name
+ " loaded from ant loader", + " loaded from ant loader",
Project.MSG_DEBUG );
Project.MSG_DEBUG );
} }
} }
} }
@@ -321,7 +325,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener
if( url != null ) if( url != null )
{ {
log( "Resource " + name + " loaded from parent loader", log( "Resource " + name + " loaded from parent loader",
Project.MSG_DEBUG );
Project.MSG_DEBUG );
} }
} }


@@ -386,7 +390,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener
if( resourceStream == null ) if( resourceStream == null )
{ {
log( "Couldn't load ResourceStream for " + name, log( "Couldn't load ResourceStream for " + name,
Project.MSG_DEBUG );
Project.MSG_DEBUG );
} }


return resourceStream; return resourceStream;
@@ -403,7 +407,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener
loaderPackages.addElement( packageRoot + "." ); loaderPackages.addElement( packageRoot + "." );
} }



/** /**
* Add an element to the classpath to be searched * Add an element to the classpath to be searched
* *
@@ -414,8 +417,8 @@ public class AntClassLoader extends ClassLoader implements BuildListener
throws BuildException throws BuildException
{ {
File pathComponent File pathComponent
= project != null ? project.resolveFile( pathElement )
: new File( pathElement );
= project != null ? FileUtils.newFileUtils().resolveFile( project.getBaseDir(), pathElement )
: new File( pathElement );
pathComponents.addElement( pathComponent ); pathComponents.addElement( pathComponent );
} }


@@ -435,15 +438,17 @@ public class AntClassLoader extends ClassLoader implements BuildListener
cleanup(); cleanup();
} }


public void buildStarted( BuildEvent event ) { }
public void buildStarted( BuildEvent event )
{
}


public void cleanup() public void cleanup()
{ {
pathComponents = null; pathComponents = null;
project = null; project = null;
for( Enumeration e = zipFiles.elements(); e.hasMoreElements(); )
for( Enumeration e = zipFiles.elements(); e.hasMoreElements(); )
{ {
ZipFile zipFile = ( ZipFile )e.nextElement();
ZipFile zipFile = (ZipFile)e.nextElement();
try try
{ {
zipFile.close(); zipFile.close();
@@ -472,7 +477,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener
return findClassInComponents( name ); return findClassInComponents( name );
} }



/** /**
* Load a class through this class loader even if that class is available on * Load a class through this class loader even if that class is available on
* the parent classpath. This ensures that any classes which are loaded by * the parent classpath. This ensures that any classes which are loaded by
@@ -524,12 +528,15 @@ public class AntClassLoader extends ClassLoader implements BuildListener
return theClass; return theClass;
} }


public void messageLogged( BuildEvent event ) { }
public void messageLogged( BuildEvent event )
{
}


/** /**
* Reset the current thread's context loader to its original value * Reset the current thread's context loader to its original value
*/ */
public void resetThreadContextLoader() public void resetThreadContextLoader()
throws TaskException
{ {
if( isContextLoaderSaved && if( isContextLoaderSaved &&
getContextClassLoader != null && setContextClassLoader != null ) getContextClassLoader != null && setContextClassLoader != null )
@@ -544,22 +551,30 @@ public class AntClassLoader extends ClassLoader implements BuildListener
catch( InvocationTargetException ite ) catch( InvocationTargetException ite )
{ {
Throwable t = ite.getTargetException(); Throwable t = ite.getTargetException();
throw new BuildException( t.toString() );
throw new TaskException( t.toString() );
} }
catch( Exception e ) catch( Exception e )
{ {
throw new BuildException( e.toString() );
throw new TaskException( e.toString() );
} }
} }
} }


public void targetFinished( BuildEvent event ) { }
public void targetFinished( BuildEvent event )
{
}


public void targetStarted( BuildEvent event ) { }
public void targetStarted( BuildEvent event )
{
}


public void taskFinished( BuildEvent event ) { }
public void taskFinished( BuildEvent event )
{
}


public void taskStarted( BuildEvent event ) { }
public void taskStarted( BuildEvent event )
{
}


/** /**
* Returns an enumeration of URLs representing all the resources with the * Returns an enumeration of URLs representing all the resources with the
@@ -575,7 +590,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener
return new ResourceEnumeration( name ); return new ResourceEnumeration( name );
} }



/** /**
* Load a class with this class loader. This method will load a class. This * Load a class with this class loader. This method will load a class. This
* class attempts to load the class firstly using the parent class loader. * class attempts to load the class firstly using the parent class loader.
@@ -649,9 +663,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener
{ {
project.log( message, priority ); project.log( message, priority );
} }
// else {
// System.out.println(message);
// }
// else {
// System.out.println(message);
// }
} }


/** /**
@@ -680,7 +694,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener
{ {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
int bytesRead = -1; int bytesRead = -1;
byte[] buffer = new byte[BUFFER_SIZE];
byte[] buffer = new byte[ BUFFER_SIZE ];


while( ( bytesRead = stream.read( buffer, 0, BUFFER_SIZE ) ) != -1 ) while( ( bytesRead = stream.read( buffer, 0, BUFFER_SIZE ) ) != -1 )
{ {
@@ -696,20 +710,20 @@ public class AntClassLoader extends ClassLoader implements BuildListener
{ {
try try
{ {
Object domain = getProtectionDomain.invoke( Project.class, new Object[0] );
Object domain = getProtectionDomain.invoke( Project.class, new Object[ 0 ] );
Object[] args = new Object[]{classname, classData, new Integer( 0 ), new Integer( classData.length ), domain}; Object[] args = new Object[]{classname, classData, new Integer( 0 ), new Integer( classData.length ), domain};
return ( Class )defineClassProtectionDomain.invoke( this, args );
return (Class)defineClassProtectionDomain.invoke( this, args );
} }
catch( InvocationTargetException ite ) catch( InvocationTargetException ite )
{ {
Throwable t = ite.getTargetException(); Throwable t = ite.getTargetException();
if( t instanceof ClassFormatError ) if( t instanceof ClassFormatError )
{ {
throw ( ClassFormatError )t;
throw (ClassFormatError)t;
} }
else if( t instanceof NoClassDefFoundError ) else if( t instanceof NoClassDefFoundError )
{ {
throw ( NoClassDefFoundError )t;
throw (NoClassDefFoundError)t;
} }
else else
{ {
@@ -759,7 +773,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener
else else
{ {
// is the zip file in the cache // is the zip file in the cache
ZipFile zipFile = ( ZipFile )zipFiles.get( file );
ZipFile zipFile = (ZipFile)zipFiles.get( file );
if( zipFile == null ) if( zipFile == null )
{ {
zipFile = new ZipFile( file ); zipFile = new ZipFile( file );
@@ -775,7 +789,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener
catch( Exception e ) catch( Exception e )
{ {
log( "Ignoring Exception " + e.getClass().getName() + ": " + e.getMessage() + log( "Ignoring Exception " + e.getClass().getName() + ": " + e.getMessage() +
" reading resource " + resourceName + " from " + file, Project.MSG_VERBOSE );
" reading resource " + resourceName + " from " + file, Project.MSG_VERBOSE );
} }


return null; return null;
@@ -819,7 +833,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener
} }
else else
{ {
ZipFile zipFile = ( ZipFile )zipFiles.get( file );
ZipFile zipFile = (ZipFile)zipFiles.get( file );
if( zipFile == null ) if( zipFile == null )
{ {
zipFile = new ZipFile( file ); zipFile = new ZipFile( file );
@@ -855,9 +869,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener
// designated to use a specific loader first (this one or the parent one) // designated to use a specific loader first (this one or the parent one)
boolean useParentFirst = parentFirst; boolean useParentFirst = parentFirst;


for( Enumeration e = systemPackages.elements(); e.hasMoreElements(); )
for( Enumeration e = systemPackages.elements(); e.hasMoreElements(); )
{ {
String packageName = ( String )e.nextElement();
String packageName = (String)e.nextElement();
if( resourceName.startsWith( packageName ) ) if( resourceName.startsWith( packageName ) )
{ {
useParentFirst = true; useParentFirst = true;
@@ -865,9 +879,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener
} }
} }


for( Enumeration e = loaderPackages.elements(); e.hasMoreElements(); )
for( Enumeration e = loaderPackages.elements(); e.hasMoreElements(); )
{ {
String packageName = ( String )e.nextElement();
String packageName = (String)e.nextElement();
if( resourceName.startsWith( packageName ) ) if( resourceName.startsWith( packageName ) )
{ {
useParentFirst = false; useParentFirst = false;
@@ -899,7 +913,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener
} }
} }



/** /**
* Find a class on the given classpath. * Find a class on the given classpath.
* *
@@ -916,9 +929,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener
String classFilename = getClassFilename( name ); String classFilename = getClassFilename( name );
try try
{ {
for( Enumeration e = pathComponents.elements(); e.hasMoreElements(); )
for( Enumeration e = pathComponents.elements(); e.hasMoreElements(); )
{ {
File pathComponent = ( File )e.nextElement();
File pathComponent = (File)e.nextElement();
try try
{ {
stream = getResourceStream( pathComponent, classFilename ); stream = getResourceStream( pathComponent, classFilename );
@@ -946,7 +959,8 @@ public class AntClassLoader extends ClassLoader implements BuildListener
} }
} }
catch( IOException e ) catch( IOException e )
{}
{
}
} }
} }


@@ -969,7 +983,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener
} }
} }



/** /**
* Get a stream to read the requested resource name from this loader. * Get a stream to read the requested resource name from this loader.
* *
@@ -983,9 +996,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener
// class we want. // class we want.
InputStream stream = null; InputStream stream = null;


for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && stream == null; )
for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && stream == null; )
{ {
File pathComponent = ( File )e.nextElement();
File pathComponent = (File)e.nextElement();
stream = getResourceStream( pathComponent, name ); stream = getResourceStream( pathComponent, name );
} }
return stream; return stream;
@@ -1073,11 +1086,11 @@ public class AntClassLoader extends ClassLoader implements BuildListener
try try
{ {
File pathComponent File pathComponent
= ( File )pathComponents.elementAt( pathElementsIndex );
= (File)pathComponents.elementAt( pathElementsIndex );
url = getResourceURL( pathComponent, this.resourceName ); url = getResourceURL( pathComponent, this.resourceName );
pathElementsIndex++; pathElementsIndex++;
} }
catch( BuildException e )
catch( TaskException e )
{ {
// ignore path elements which are not valid relative to the project // ignore path elements which are not valid relative to the project
} }


+ 0
- 37
proposal/myrmidon/src/main/org/apache/tools/ant/BuildException.java View File

@@ -44,43 +44,6 @@ public class BuildException
super( msg, cause ); super( msg, cause );
} }


/**
* Constructs an exception with the given message and exception as a root
* cause and a location in a file.
*
* @param msg Description of or information about the exception.
* @param cause Exception that might have cause this one.
* @param location Location in the project file where the error occured.
*/
public BuildException( String msg, Throwable cause, Location location )
{
this( msg, cause );
this.location = location;
}

/**
* Constructs an exception with the given exception as a root cause.
*
* @param cause Exception that might have caused this one.
*/
public BuildException( Throwable cause )
{
super( cause.toString(), cause );
}

/**
* Constructs an exception with the given descriptive message and a location
* in a file.
*
* @param msg Description of or information about the exception.
* @param location Location in the project file where the error occured.
*/
public BuildException( String msg, Location location )
{
super( msg );
this.location = location;
}

/** /**
* Sets the file location where the error occured. * Sets the file location where the error occured.
* *


+ 0
- 96
proposal/myrmidon/src/main/org/apache/tools/ant/DesirableFilter.java View File

@@ -1,96 +0,0 @@
/*
* 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 file.
*/
package org.apache.tools.ant;
import java.io.File;
import java.io.FilenameFilter;


/**
* Filters filenames to determine whether or not the file is desirable.
*
* @author Jason Hunter [jhunter@servlets.com]
* @author james@x180.com
*/
public class DesirableFilter implements FilenameFilter
{

/**
* Test the given filename to determine whether or not it's desirable. This
* helps tasks filter temp files and files used by CVS.
*
* @param dir Description of Parameter
* @param name Description of Parameter
* @return Description of the Returned Value
*/

public boolean accept( File dir, String name )
{

// emacs save file
if( name.endsWith( "~" ) )
{
return false;
}

// emacs autosave file
if( name.startsWith( "#" ) && name.endsWith( "#" ) )
{
return false;
}

// openwindows text editor does this I think
if( name.startsWith( "%" ) && name.endsWith( "%" ) )
{
return false;
}

/*
* CVS stuff -- hopefully there won't be a case with
* an all cap file/dir named "CVS" that somebody wants
* to keep around...
*/
if( name.equals( "CVS" ) )
{
return false;
}

/*
* If we are going to ignore CVS might as well ignore
* this one as well...
*/
if( name.equals( ".cvsignore" ) )
{
return false;
}

// CVS merge autosaves.
if( name.startsWith( ".#" ) )
{
return false;
}

// SCCS/CSSC/TeamWare:
if( name.equals( "SCCS" ) )
{
return false;
}

// Visual Source Save
if( name.equals( "vssver.scc" ) )
{
return false;
}

// default
return true;
}
}





+ 78
- 85
proposal/myrmidon/src/main/org/apache/tools/ant/DirectoryScanner.java View File

@@ -6,9 +6,11 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant; package org.apache.tools.ant;

import java.io.File; import java.io.File;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector; import java.util.Vector;
import org.apache.myrmidon.api.TaskException;


/** /**
* Class for scanning a directory for files/directories that match a certain * Class for scanning a directory for files/directories that match a certain
@@ -105,7 +107,7 @@ public class DirectoryScanner implements FileScanner
"**/SCCS", "**/SCCS",
"**/SCCS/**", "**/SCCS/**",
"**/vssver.scc" "**/vssver.scc"
};
};


/** /**
* Have the Vectors holding our results been built by a slow scan? * Have the Vectors holding our results been built by a slow scan?
@@ -174,8 +176,9 @@ public class DirectoryScanner implements FileScanner
/** /**
* Constructor. * Constructor.
*/ */
public DirectoryScanner() { }

public DirectoryScanner()
{
}


/** /**
* Matches a string against a pattern. The pattern contains two special * Matches a string against a pattern. The pattern contains two special
@@ -192,7 +195,6 @@ public class DirectoryScanner implements FileScanner
return match( pattern, str, true ); return match( pattern, str, true );
} }



/** /**
* Matches a string against a pattern. The pattern contains two special * Matches a string against a pattern. The pattern contains two special
* characters: '*' which means zero or more characters, '?' which means one * characters: '*' which means zero or more characters, '?' which means one
@@ -217,7 +219,7 @@ public class DirectoryScanner implements FileScanner
boolean containsStar = false; boolean containsStar = false;
for( int i = 0; i < patArr.length; i++ ) for( int i = 0; i < patArr.length; i++ )
{ {
if( patArr[i] == '*' )
if( patArr[ i ] == '*' )
{ {
containsStar = true; containsStar = true;
break; break;
@@ -233,15 +235,15 @@ public class DirectoryScanner implements FileScanner
} }
for( int i = 0; i <= patIdxEnd; i++ ) for( int i = 0; i <= patIdxEnd; i++ )
{ {
ch = patArr[i];
ch = patArr[ i ];
if( ch != '?' ) if( ch != '?' )
{ {
if( isCaseSensitive && ch != strArr[i] )
if( isCaseSensitive && ch != strArr[ i ] )
{ {
return false;// Character mismatch return false;// Character mismatch
} }
if( !isCaseSensitive && Character.toUpperCase( ch ) != if( !isCaseSensitive && Character.toUpperCase( ch ) !=
Character.toUpperCase( strArr[i] ) )
Character.toUpperCase( strArr[ i ] ) )
{ {
return false;// Character mismatch return false;// Character mismatch
} }
@@ -256,16 +258,16 @@ public class DirectoryScanner implements FileScanner
} }


// Process characters before first star // Process characters before first star
while( ( ch = patArr[patIdxStart] ) != '*' && strIdxStart <= strIdxEnd )
while( ( ch = patArr[ patIdxStart ] ) != '*' && strIdxStart <= strIdxEnd )
{ {
if( ch != '?' ) if( ch != '?' )
{ {
if( isCaseSensitive && ch != strArr[strIdxStart] )
if( isCaseSensitive && ch != strArr[ strIdxStart ] )
{ {
return false;// Character mismatch return false;// Character mismatch
} }
if( !isCaseSensitive && Character.toUpperCase( ch ) != if( !isCaseSensitive && Character.toUpperCase( ch ) !=
Character.toUpperCase( strArr[strIdxStart] ) )
Character.toUpperCase( strArr[ strIdxStart ] ) )
{ {
return false;// Character mismatch return false;// Character mismatch
} }
@@ -279,7 +281,7 @@ public class DirectoryScanner implements FileScanner
// left in the pattern. If so, we succeeded. Otherwise failure. // left in the pattern. If so, we succeeded. Otherwise failure.
for( int i = patIdxStart; i <= patIdxEnd; i++ ) for( int i = patIdxStart; i <= patIdxEnd; i++ )
{ {
if( patArr[i] != '*' )
if( patArr[ i ] != '*' )
{ {
return false; return false;
} }
@@ -288,16 +290,16 @@ public class DirectoryScanner implements FileScanner
} }


// Process characters after last star // Process characters after last star
while( ( ch = patArr[patIdxEnd] ) != '*' && strIdxStart <= strIdxEnd )
while( ( ch = patArr[ patIdxEnd ] ) != '*' && strIdxStart <= strIdxEnd )
{ {
if( ch != '?' ) if( ch != '?' )
{ {
if( isCaseSensitive && ch != strArr[strIdxEnd] )
if( isCaseSensitive && ch != strArr[ strIdxEnd ] )
{ {
return false;// Character mismatch return false;// Character mismatch
} }
if( !isCaseSensitive && Character.toUpperCase( ch ) != if( !isCaseSensitive && Character.toUpperCase( ch ) !=
Character.toUpperCase( strArr[strIdxEnd] ) )
Character.toUpperCase( strArr[ strIdxEnd ] ) )
{ {
return false;// Character mismatch return false;// Character mismatch
} }
@@ -311,7 +313,7 @@ public class DirectoryScanner implements FileScanner
// left in the pattern. If so, we succeeded. Otherwise failure. // left in the pattern. If so, we succeeded. Otherwise failure.
for( int i = patIdxStart; i <= patIdxEnd; i++ ) for( int i = patIdxStart; i <= patIdxEnd; i++ )
{ {
if( patArr[i] != '*' )
if( patArr[ i ] != '*' )
{ {
return false; return false;
} }
@@ -326,7 +328,7 @@ public class DirectoryScanner implements FileScanner
int patIdxTmp = -1; int patIdxTmp = -1;
for( int i = patIdxStart + 1; i <= patIdxEnd; i++ ) for( int i = patIdxStart + 1; i <= patIdxEnd; i++ )
{ {
if( patArr[i] == '*' )
if( patArr[ i ] == '*' )
{ {
patIdxTmp = i; patIdxTmp = i;
break; break;
@@ -348,15 +350,15 @@ public class DirectoryScanner implements FileScanner
{ {
for( int j = 0; j < patLength; j++ ) for( int j = 0; j < patLength; j++ )
{ {
ch = patArr[patIdxStart + j + 1];
ch = patArr[ patIdxStart + j + 1 ];
if( ch != '?' ) if( ch != '?' )
{ {
if( isCaseSensitive && ch != strArr[strIdxStart + i + j] )
if( isCaseSensitive && ch != strArr[ strIdxStart + i + j ] )
{ {
continue strLoop; continue strLoop;
} }
if( !isCaseSensitive && Character.toUpperCase( ch ) != if( !isCaseSensitive && Character.toUpperCase( ch ) !=
Character.toUpperCase( strArr[strIdxStart + i + j] ) )
Character.toUpperCase( strArr[ strIdxStart + i + j ] ) )
{ {
continue strLoop; continue strLoop;
} }
@@ -380,7 +382,7 @@ public class DirectoryScanner implements FileScanner
// in the pattern. If so, we succeeded. Otherwise failure. // in the pattern. If so, we succeeded. Otherwise failure.
for( int i = patIdxStart; i <= patIdxEnd; i++ ) for( int i = patIdxStart; i <= patIdxEnd; i++ )
{ {
if( patArr[i] != '*' )
if( patArr[ i ] != '*' )
{ {
return false; return false;
} }
@@ -444,12 +446,12 @@ public class DirectoryScanner implements FileScanner
// up to first '**' // up to first '**'
while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd )
{ {
String patDir = ( String )patDirs.elementAt( patIdxStart );
String patDir = (String)patDirs.elementAt( patIdxStart );
if( patDir.equals( "**" ) ) if( patDir.equals( "**" ) )
{ {
break; break;
} }
if( !match( patDir, ( String )strDirs.elementAt( strIdxStart ), isCaseSensitive ) )
if( !match( patDir, (String)strDirs.elementAt( strIdxStart ), isCaseSensitive ) )
{ {
return false; return false;
} }
@@ -480,12 +482,12 @@ public class DirectoryScanner implements FileScanner
// up to last '**' // up to last '**'
while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd )
{ {
String patDir = ( String )patDirs.elementAt( patIdxEnd );
String patDir = (String)patDirs.elementAt( patIdxEnd );
if( patDir.equals( "**" ) ) if( patDir.equals( "**" ) )
{ {
break; break;
} }
if( !match( patDir, ( String )strDirs.elementAt( strIdxEnd ), isCaseSensitive ) )
if( !match( patDir, (String)strDirs.elementAt( strIdxEnd ), isCaseSensitive ) )
{ {
return false; return false;
} }
@@ -532,8 +534,8 @@ public class DirectoryScanner implements FileScanner
{ {
for( int j = 0; j < patLength; j++ ) for( int j = 0; j < patLength; j++ )
{ {
String subPat = ( String )patDirs.elementAt( patIdxStart + j + 1 );
String subStr = ( String )strDirs.elementAt( strIdxStart + i + j );
String subPat = (String)patDirs.elementAt( patIdxStart + j + 1 );
String subStr = (String)strDirs.elementAt( strIdxStart + i + j );
if( !match( subPat, subStr, isCaseSensitive ) ) if( !match( subPat, subStr, isCaseSensitive ) )
{ {
continue strLoop; continue strLoop;
@@ -564,7 +566,6 @@ public class DirectoryScanner implements FileScanner
return true; return true;
} }



/** /**
* Does the path match the start of this pattern up to the first "**". <p> * Does the path match the start of this pattern up to the first "**". <p>
* *
@@ -630,12 +631,12 @@ public class DirectoryScanner implements FileScanner
// up to first '**' // up to first '**'
while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd )
{ {
String patDir = ( String )patDirs.elementAt( patIdxStart );
String patDir = (String)patDirs.elementAt( patIdxStart );
if( patDir.equals( "**" ) ) if( patDir.equals( "**" ) )
{ {
break; break;
} }
if( !match( patDir, ( String )strDirs.elementAt( strIdxStart ), isCaseSensitive ) )
if( !match( patDir, (String)strDirs.elementAt( strIdxStart ), isCaseSensitive ) )
{ {
return false; return false;
} }
@@ -661,7 +662,6 @@ public class DirectoryScanner implements FileScanner
} }
} }



/** /**
* Sets the basedir for scanning. This is the directory that is scanned * Sets the basedir for scanning. This is the directory that is scanned
* recursively. All '/' and '\' characters are replaced by <code>File.separatorChar</code> * recursively. All '/' and '\' characters are replaced by <code>File.separatorChar</code>
@@ -674,7 +674,6 @@ public class DirectoryScanner implements FileScanner
setBasedir( new File( basedir.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ) ) ); setBasedir( new File( basedir.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ) ) );
} }



/** /**
* Sets the basedir for scanning. This is the directory that is scanned * Sets the basedir for scanning. This is the directory that is scanned
* recursively. * recursively.
@@ -686,7 +685,6 @@ public class DirectoryScanner implements FileScanner
this.basedir = basedir; this.basedir = basedir;
} }



/** /**
* Sets the case sensitivity of the file system * Sets the case sensitivity of the file system
* *
@@ -697,7 +695,6 @@ public class DirectoryScanner implements FileScanner
this.isCaseSensitive = isCaseSensitive; this.isCaseSensitive = isCaseSensitive;
} }



/** /**
* Sets the set of exclude patterns to use. All '/' and '\' characters are * Sets the set of exclude patterns to use. All '/' and '\' characters are
* replaced by <code>File.separatorChar</code>. So the separator used need * replaced by <code>File.separatorChar</code>. So the separator used need
@@ -715,16 +712,16 @@ public class DirectoryScanner implements FileScanner
} }
else else
{ {
this.excludes = new String[excludes.length];
this.excludes = new String[ excludes.length ];
for( int i = 0; i < excludes.length; i++ ) for( int i = 0; i < excludes.length; i++ )
{ {
String pattern; String pattern;
pattern = excludes[i].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
pattern = excludes[ i ].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
if( pattern.endsWith( File.separator ) ) if( pattern.endsWith( File.separator ) )
{ {
pattern += "**"; pattern += "**";
} }
this.excludes[i] = pattern;
this.excludes[ i ] = pattern;
} }
} }
} }
@@ -746,21 +743,20 @@ public class DirectoryScanner implements FileScanner
} }
else else
{ {
this.includes = new String[includes.length];
this.includes = new String[ includes.length ];
for( int i = 0; i < includes.length; i++ ) for( int i = 0; i < includes.length; i++ )
{ {
String pattern; String pattern;
pattern = includes[i].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
pattern = includes[ i ].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
if( pattern.endsWith( File.separator ) ) if( pattern.endsWith( File.separator ) )
{ {
pattern += "**"; pattern += "**";
} }
this.includes[i] = pattern;
this.includes[ i ] = pattern;
} }
} }
} }



/** /**
* Gets the basedir that is used for scanning. This is the directory that is * Gets the basedir that is used for scanning. This is the directory that is
* scanned recursively. * scanned recursively.
@@ -772,7 +768,6 @@ public class DirectoryScanner implements FileScanner
return basedir; return basedir;
} }



/** /**
* Get the names of the directories that matched at least one of the include * Get the names of the directories that matched at least one of the include
* patterns, an matched also at least one of the exclude patterns. The names * patterns, an matched also at least one of the exclude patterns. The names
@@ -781,18 +776,18 @@ public class DirectoryScanner implements FileScanner
* @return the names of the directories * @return the names of the directories
*/ */
public String[] getExcludedDirectories() public String[] getExcludedDirectories()
throws TaskException
{ {
slowScan(); slowScan();
int count = dirsExcluded.size(); int count = dirsExcluded.size();
String[] directories = new String[count];
String[] directories = new String[ count ];
for( int i = 0; i < count; i++ ) for( int i = 0; i < count; i++ )
{ {
directories[i] = ( String )dirsExcluded.elementAt( i );
directories[ i ] = (String)dirsExcluded.elementAt( i );
} }
return directories; return directories;
} }



/** /**
* Get the names of the files that matched at least one of the include * Get the names of the files that matched at least one of the include
* patterns, an matched also at least one of the exclude patterns. The names * patterns, an matched also at least one of the exclude patterns. The names
@@ -801,18 +796,18 @@ public class DirectoryScanner implements FileScanner
* @return the names of the files * @return the names of the files
*/ */
public String[] getExcludedFiles() public String[] getExcludedFiles()
throws TaskException
{ {
slowScan(); slowScan();
int count = filesExcluded.size(); int count = filesExcluded.size();
String[] files = new String[count];
String[] files = new String[ count ];
for( int i = 0; i < count; i++ ) for( int i = 0; i < count; i++ )
{ {
files[i] = ( String )filesExcluded.elementAt( i );
files[ i ] = (String)filesExcluded.elementAt( i );
} }
return files; return files;
} }



/** /**
* Get the names of the directories that matched at least one of the include * Get the names of the directories that matched at least one of the include
* patterns, an matched none of the exclude patterns. The names are relative * patterns, an matched none of the exclude patterns. The names are relative
@@ -823,15 +818,14 @@ public class DirectoryScanner implements FileScanner
public String[] getIncludedDirectories() public String[] getIncludedDirectories()
{ {
int count = dirsIncluded.size(); int count = dirsIncluded.size();
String[] directories = new String[count];
String[] directories = new String[ count ];
for( int i = 0; i < count; i++ ) for( int i = 0; i < count; i++ )
{ {
directories[i] = ( String )dirsIncluded.elementAt( i );
directories[ i ] = (String)dirsIncluded.elementAt( i );
} }
return directories; return directories;
} }



/** /**
* Get the names of the files that matched at least one of the include * Get the names of the files that matched at least one of the include
* patterns, and matched none of the exclude patterns. The names are * patterns, and matched none of the exclude patterns. The names are
@@ -842,15 +836,14 @@ public class DirectoryScanner implements FileScanner
public String[] getIncludedFiles() public String[] getIncludedFiles()
{ {
int count = filesIncluded.size(); int count = filesIncluded.size();
String[] files = new String[count];
String[] files = new String[ count ];
for( int i = 0; i < count; i++ ) for( int i = 0; i < count; i++ )
{ {
files[i] = ( String )filesIncluded.elementAt( i );
files[ i ] = (String)filesIncluded.elementAt( i );
} }
return files; return files;
} }



/** /**
* Get the names of the directories that matched at none of the include * Get the names of the directories that matched at none of the include
* patterns. The names are relative to the basedir. * patterns. The names are relative to the basedir.
@@ -858,18 +851,18 @@ public class DirectoryScanner implements FileScanner
* @return the names of the directories * @return the names of the directories
*/ */
public String[] getNotIncludedDirectories() public String[] getNotIncludedDirectories()
throws TaskException
{ {
slowScan(); slowScan();
int count = dirsNotIncluded.size(); int count = dirsNotIncluded.size();
String[] directories = new String[count];
String[] directories = new String[ count ];
for( int i = 0; i < count; i++ ) for( int i = 0; i < count; i++ )
{ {
directories[i] = ( String )dirsNotIncluded.elementAt( i );
directories[ i ] = (String)dirsNotIncluded.elementAt( i );
} }
return directories; return directories;
} }



/** /**
* Get the names of the files that matched at none of the include patterns. * Get the names of the files that matched at none of the include patterns.
* The names are relative to the basedir. * The names are relative to the basedir.
@@ -877,13 +870,14 @@ public class DirectoryScanner implements FileScanner
* @return the names of the files * @return the names of the files
*/ */
public String[] getNotIncludedFiles() public String[] getNotIncludedFiles()
throws TaskException
{ {
slowScan(); slowScan();
int count = filesNotIncluded.size(); int count = filesNotIncluded.size();
String[] files = new String[count];
String[] files = new String[ count ];
for( int i = 0; i < count; i++ ) for( int i = 0; i < count; i++ )
{ {
files[i] = ( String )filesNotIncluded.elementAt( i );
files[ i ] = (String)filesNotIncluded.elementAt( i );
} }
return files; return files;
} }
@@ -900,7 +894,6 @@ public class DirectoryScanner implements FileScanner
return everythingIncluded; return everythingIncluded;
} }



/** /**
* Adds the array with default exclusions to the current exclusions set. * Adds the array with default exclusions to the current exclusions set.
*/ */
@@ -908,25 +901,25 @@ public class DirectoryScanner implements FileScanner
{ {
int excludesLength = excludes == null ? 0 : excludes.length; int excludesLength = excludes == null ? 0 : excludes.length;
String[] newExcludes; String[] newExcludes;
newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length];
newExcludes = new String[ excludesLength + DEFAULTEXCLUDES.length ];
if( excludesLength > 0 ) if( excludesLength > 0 )
{ {
System.arraycopy( excludes, 0, newExcludes, 0, excludesLength ); System.arraycopy( excludes, 0, newExcludes, 0, excludesLength );
} }
for( int i = 0; i < DEFAULTEXCLUDES.length; i++ ) for( int i = 0; i < DEFAULTEXCLUDES.length; i++ )
{ {
newExcludes[i + excludesLength] = DEFAULTEXCLUDES[i].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
newExcludes[ i + excludesLength ] = DEFAULTEXCLUDES[ i ].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
} }
excludes = newExcludes; excludes = newExcludes;
} }



/** /**
* Scans the base directory for files that match at least one include * Scans the base directory for files that match at least one include
* pattern, and don't match any exclude patterns. * pattern, and don't match any exclude patterns.
* *
*/ */
public void scan() public void scan()
throws TaskException
{ {
if( basedir == null ) if( basedir == null )
{ {
@@ -935,23 +928,23 @@ public class DirectoryScanner implements FileScanner
if( !basedir.exists() ) if( !basedir.exists() )
{ {
throw new IllegalStateException( "basedir " + basedir throw new IllegalStateException( "basedir " + basedir
+ " does not exist" );
+ " does not exist" );
} }
if( !basedir.isDirectory() ) if( !basedir.isDirectory() )
{ {
throw new IllegalStateException( "basedir " + basedir throw new IllegalStateException( "basedir " + basedir
+ " is not a directory" );
+ " is not a directory" );
} }


if( includes == null ) if( includes == null )
{ {
// No includes supplied, so set it to 'matches all' // No includes supplied, so set it to 'matches all'
includes = new String[1];
includes[0] = "**";
includes = new String[ 1 ];
includes[ 0 ] = "**";
} }
if( excludes == null ) if( excludes == null )
{ {
excludes = new String[0];
excludes = new String[ 0 ];
} }


filesIncluded = new Vector(); filesIncluded = new Vector();
@@ -990,7 +983,7 @@ public class DirectoryScanner implements FileScanner
{ {
for( int i = 0; i < excludes.length; i++ ) for( int i = 0; i < excludes.length; i++ )
{ {
if( matchPath( excludes[i], name, isCaseSensitive ) )
if( matchPath( excludes[ i ], name, isCaseSensitive ) )
{ {
return true; return true;
} }
@@ -998,7 +991,6 @@ public class DirectoryScanner implements FileScanner
return false; return false;
} }



/** /**
* Tests whether a name matches against at least one include pattern. * Tests whether a name matches against at least one include pattern.
* *
@@ -1010,7 +1002,7 @@ public class DirectoryScanner implements FileScanner
{ {
for( int i = 0; i < includes.length; i++ ) for( int i = 0; i < includes.length; i++ )
{ {
if( matchPath( includes[i], name, isCaseSensitive ) )
if( matchPath( includes[ i ], name, isCaseSensitive ) )
{ {
return true; return true;
} }
@@ -1029,7 +1021,7 @@ public class DirectoryScanner implements FileScanner
{ {
for( int i = 0; i < includes.length; i++ ) for( int i = 0; i < includes.length; i++ )
{ {
if( matchPatternStart( includes[i], name, isCaseSensitive ) )
if( matchPatternStart( includes[ i ], name, isCaseSensitive ) )
{ {
return true; return true;
} }
@@ -1037,7 +1029,6 @@ public class DirectoryScanner implements FileScanner
return false; return false;
} }



/** /**
* Scans the passed dir for files and directories. Found files and * Scans the passed dir for files and directories. Found files and
* directories are placed in their respective collections, based on the * directories are placed in their respective collections, based on the
@@ -1056,6 +1047,7 @@ public class DirectoryScanner implements FileScanner
* @see #dirsExcluded * @see #dirsExcluded
*/ */
protected void scandir( File dir, String vpath, boolean fast ) protected void scandir( File dir, String vpath, boolean fast )
throws TaskException
{ {
String[] newfiles = dir.list(); String[] newfiles = dir.list();


@@ -1068,14 +1060,14 @@ public class DirectoryScanner implements FileScanner
* (2) an IO error occurred (why doesn't it throw an exception * (2) an IO error occurred (why doesn't it throw an exception
* then???) * then???)
*/ */
throw new BuildException( "IO error scanning directory "
+ dir.getAbsolutePath() );
throw new TaskException( "IO error scanning directory "
+ dir.getAbsolutePath() );
} }


for( int i = 0; i < newfiles.length; i++ ) for( int i = 0; i < newfiles.length; i++ )
{ {
String name = vpath + newfiles[i];
File file = new File( dir, newfiles[i] );
String name = vpath + newfiles[ i ];
File file = new File( dir, newfiles[ i ] );
if( file.isDirectory() ) if( file.isDirectory() )
{ {
if( isIncluded( name ) ) if( isIncluded( name ) )
@@ -1141,33 +1133,34 @@ public class DirectoryScanner implements FileScanner
* Returns immediately if a slow scan has already been requested. * Returns immediately if a slow scan has already been requested.
*/ */
protected void slowScan() protected void slowScan()
throws TaskException
{ {
if( haveSlowResults ) if( haveSlowResults )
{ {
return; return;
} }


String[] excl = new String[dirsExcluded.size()];
String[] excl = new String[ dirsExcluded.size() ];
dirsExcluded.copyInto( excl ); dirsExcluded.copyInto( excl );


String[] notIncl = new String[dirsNotIncluded.size()];
String[] notIncl = new String[ dirsNotIncluded.size() ];
dirsNotIncluded.copyInto( notIncl ); dirsNotIncluded.copyInto( notIncl );


for( int i = 0; i < excl.length; i++ ) for( int i = 0; i < excl.length; i++ )
{ {
if( !couldHoldIncluded( excl[i] ) )
if( !couldHoldIncluded( excl[ i ] ) )
{ {
scandir( new File( basedir, excl[i] ),
excl[i] + File.separator, false );
scandir( new File( basedir, excl[ i ] ),
excl[ i ] + File.separator, false );
} }
} }


for( int i = 0; i < notIncl.length; i++ ) for( int i = 0; i < notIncl.length; i++ )
{ {
if( !couldHoldIncluded( notIncl[i] ) )
if( !couldHoldIncluded( notIncl[ i ] ) )
{ {
scandir( new File( basedir, notIncl[i] ),
notIncl[i] + File.separator, false );
scandir( new File( basedir, notIncl[ i ] ),
notIncl[ i ] + File.separator, false );
} }
} }




+ 9
- 8
proposal/myrmidon/src/main/org/apache/tools/ant/FileScanner.java View File

@@ -6,13 +6,13 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant; package org.apache.tools.ant;

import java.io.File; import java.io.File;
import org.apache.myrmidon.api.TaskException;


/** /**
* An interface used to describe the actions required by any type of directory * An interface used to describe the actions required by any type of directory
* scanner. * scanner.
*
* @author RT
*/ */
public interface FileScanner public interface FileScanner
{ {
@@ -36,7 +36,7 @@ public interface FileScanner
* *
* @return the names of the directories * @return the names of the directories
*/ */
String[] getExcludedDirectories();
String[] getExcludedDirectories() throws TaskException;


/** /**
* Get the names of the files that matched at least one of the include * Get the names of the files that matched at least one of the include
@@ -45,7 +45,7 @@ public interface FileScanner
* *
* @return the names of the files * @return the names of the files
*/ */
String[] getExcludedFiles();
String[] getExcludedFiles() throws TaskException;


/** /**
* Get the names of the directories that matched at least one of the include * Get the names of the directories that matched at least one of the include
@@ -63,7 +63,7 @@ public interface FileScanner
* *
* @return the names of the files * @return the names of the files
*/ */
String[] getIncludedFiles();
String[] getIncludedFiles() throws TaskException;


/** /**
* Get the names of the directories that matched at none of the include * Get the names of the directories that matched at none of the include
@@ -71,7 +71,7 @@ public interface FileScanner
* *
* @return the names of the directories * @return the names of the directories
*/ */
String[] getNotIncludedDirectories();
String[] getNotIncludedDirectories() throws TaskException;


/** /**
* Get the names of the files that matched at none of the include patterns. * Get the names of the files that matched at none of the include patterns.
@@ -79,14 +79,15 @@ public interface FileScanner
* *
* @return the names of the files * @return the names of the files
*/ */
String[] getNotIncludedFiles();
String[] getNotIncludedFiles() throws TaskException;


/** /**
* Scans the base directory for files that match at least one include * Scans the base directory for files that match at least one include
* pattern, and don't match any exclude patterns. * pattern, and don't match any exclude patterns.
* *
*/ */
void scan();
void scan()
throws TaskException;


/** /**
* Sets the basedir for scanning. This is the directory that is scanned * Sets the basedir for scanning. This is the directory that is scanned


+ 154
- 134
proposal/myrmidon/src/main/org/apache/tools/ant/IntrospectionHelper.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant; package org.apache.tools.ant;

import java.io.File; import java.io.File;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@@ -13,8 +14,10 @@ import java.lang.reflect.Method;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Locale; import java.util.Locale;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;


/** /**
* Helper class that collects the methods a task or nested element holds to set * Helper class that collects the methods a task or nested element holds to set
@@ -66,6 +69,7 @@ public class IntrospectionHelper implements BuildListener
private Hashtable nestedTypes; private Hashtable nestedTypes;


private IntrospectionHelper( final Class bean ) private IntrospectionHelper( final Class bean )
throws TaskException
{ {
attributeTypes = new Hashtable(); attributeTypes = new Hashtable();
attributeSetters = new Hashtable(); attributeSetters = new Hashtable();
@@ -78,52 +82,52 @@ public class IntrospectionHelper implements BuildListener
Method[] methods = bean.getMethods(); Method[] methods = bean.getMethods();
for( int i = 0; i < methods.length; i++ ) for( int i = 0; i < methods.length; i++ )
{ {
final Method m = methods[i];
final Method m = methods[ i ];
final String name = m.getName(); final String name = m.getName();
Class returnType = m.getReturnType(); Class returnType = m.getReturnType();
Class[] args = m.getParameterTypes(); Class[] args = m.getParameterTypes();


// not really user settable properties on tasks // not really user settable properties on tasks
if( org.apache.tools.ant.Task.class.isAssignableFrom( bean ) if( org.apache.tools.ant.Task.class.isAssignableFrom( bean )
&& args.length == 1 &&
&& args.length == 1 &&
( (
( (
"setLocation".equals( name ) && org.apache.tools.ant.Location.class.equals( args[0] )
) || (
"setTaskType".equals( name ) && java.lang.String.class.equals( args[0] )
)
) )
"setLocation".equals( name ) && org.apache.tools.ant.Location.class.equals( args[ 0 ] )
) || (
"setTaskType".equals( name ) && java.lang.String.class.equals( args[ 0 ] )
)
) )
{ {
continue; continue;
} }


// hide addTask for TaskContainers // hide addTask for TaskContainers
if( org.apache.tools.ant.TaskContainer.class.isAssignableFrom( bean ) if( org.apache.tools.ant.TaskContainer.class.isAssignableFrom( bean )
&& args.length == 1 && "addTask".equals( name )
&& org.apache.tools.ant.Task.class.equals( args[0] ) )
&& args.length == 1 && "addTask".equals( name )
&& org.apache.tools.ant.Task.class.equals( args[ 0 ] ) )
{ {
continue; continue;
} }


if( "addText".equals( name ) if( "addText".equals( name )
&& java.lang.Void.TYPE.equals( returnType )
&& args.length == 1
&& java.lang.String.class.equals( args[0] ) )
&& java.lang.Void.TYPE.equals( returnType )
&& args.length == 1
&& java.lang.String.class.equals( args[ 0 ] ) )
{ {


addText = methods[i];
addText = methods[ i ];


} }
else if( name.startsWith( "set" ) else if( name.startsWith( "set" )
&& java.lang.Void.TYPE.equals( returnType )
&& args.length == 1
&& !args[0].isArray() )
&& java.lang.Void.TYPE.equals( returnType )
&& args.length == 1
&& !args[ 0 ].isArray() )
{ {


String propName = getPropertyName( name, "set" ); String propName = getPropertyName( name, "set" );
if( attributeSetters.get( propName ) != null ) if( attributeSetters.get( propName ) != null )
{ {
if( java.lang.String.class.equals( args[0] ) )
if( java.lang.String.class.equals( args[ 0 ] ) )
{ {
/* /*
* Ignore method m, as there is an overloaded * Ignore method m, as there is an overloaded
@@ -144,109 +148,109 @@ public class IntrospectionHelper implements BuildListener
* particular order. * particular order.
*/ */
} }
AttributeSetter as = createAttributeSetter( m, args[0] );
AttributeSetter as = createAttributeSetter( m, args[ 0 ] );
if( as != null ) if( as != null )
{ {
attributeTypes.put( propName, args[0] );
attributeTypes.put( propName, args[ 0 ] );
attributeSetters.put( propName, as ); attributeSetters.put( propName, as );
} }


} }
else if( name.startsWith( "create" ) else if( name.startsWith( "create" )
&& !returnType.isArray()
&& !returnType.isPrimitive()
&& args.length == 0 )
&& !returnType.isArray()
&& !returnType.isPrimitive()
&& args.length == 0 )
{ {


String propName = getPropertyName( name, "create" ); String propName = getPropertyName( name, "create" );
nestedTypes.put( propName, returnType ); nestedTypes.put( propName, returnType );
nestedCreators.put( propName, nestedCreators.put( propName,
new NestedCreator()
{
new NestedCreator()
{


public Object create( Object parent )
throws InvocationTargetException,
IllegalAccessException
{
public Object create( Object parent )
throws InvocationTargetException,
IllegalAccessException
{


return m.invoke( parent, new Object[]{} );
}
return m.invoke( parent, new Object[]{} );
}


} );
} );


} }
else if( name.startsWith( "addConfigured" ) else if( name.startsWith( "addConfigured" )
&& java.lang.Void.TYPE.equals( returnType )
&& args.length == 1
&& !java.lang.String.class.equals( args[0] )
&& !args[0].isArray()
&& !args[0].isPrimitive() )
&& java.lang.Void.TYPE.equals( returnType )
&& args.length == 1
&& !java.lang.String.class.equals( args[ 0 ] )
&& !args[ 0 ].isArray()
&& !args[ 0 ].isPrimitive() )
{ {


try try
{ {
final Constructor c = final Constructor c =
args[0].getConstructor( new Class[]{} );
args[ 0 ].getConstructor( new Class[]{} );
String propName = getPropertyName( name, "addConfigured" ); String propName = getPropertyName( name, "addConfigured" );
nestedTypes.put( propName, args[0] );
nestedTypes.put( propName, args[ 0 ] );
nestedCreators.put( propName, nestedCreators.put( propName,
new NestedCreator()
{
new NestedCreator()
{


public Object create( Object parent )
throws InvocationTargetException, IllegalAccessException, InstantiationException
{
public Object create( Object parent )
throws InvocationTargetException, IllegalAccessException, InstantiationException
{


Object o = c.newInstance( new Object[]{} );
return o;
}
Object o = c.newInstance( new Object[]{} );
return o;
}


} );
} );
nestedStorers.put( propName, nestedStorers.put( propName,
new NestedStorer()
{
new NestedStorer()
{


public void store( Object parent, Object child )
throws InvocationTargetException, IllegalAccessException, InstantiationException
{
public void store( Object parent, Object child )
throws InvocationTargetException, IllegalAccessException, InstantiationException
{


m.invoke( parent, new Object[]{child} );
}
m.invoke( parent, new Object[]{child} );
}


} );
} );
} }
catch( NoSuchMethodException nse ) catch( NoSuchMethodException nse )
{ {
} }
} }
else if( name.startsWith( "add" ) else if( name.startsWith( "add" )
&& java.lang.Void.TYPE.equals( returnType )
&& args.length == 1
&& !java.lang.String.class.equals( args[0] )
&& !args[0].isArray()
&& !args[0].isPrimitive() )
&& java.lang.Void.TYPE.equals( returnType )
&& args.length == 1
&& !java.lang.String.class.equals( args[ 0 ] )
&& !args[ 0 ].isArray()
&& !args[ 0 ].isPrimitive() )
{ {


try try
{ {
final Constructor c = final Constructor c =
args[0].getConstructor( new Class[]{} );
args[ 0 ].getConstructor( new Class[]{} );
String propName = getPropertyName( name, "add" ); String propName = getPropertyName( name, "add" );
nestedTypes.put( propName, args[0] );
nestedTypes.put( propName, args[ 0 ] );
nestedCreators.put( propName, nestedCreators.put( propName,
new NestedCreator()
{
new NestedCreator()
{


public Object create( Object parent )
throws InvocationTargetException, IllegalAccessException, InstantiationException
{
public Object create( Object parent )
throws InvocationTargetException, IllegalAccessException, InstantiationException
{


Object o = c.newInstance( new Object[]{} );
m.invoke( parent, new Object[]{o} );
return o;
}
Object o = c.newInstance( new Object[]{} );
m.invoke( parent, new Object[]{o} );
return o;
}


} );
} );
} }
catch( NoSuchMethodException nse ) catch( NoSuchMethodException nse )
{ {
@@ -263,7 +267,7 @@ public class IntrospectionHelper implements BuildListener
*/ */
public static synchronized IntrospectionHelper getHelper( Class c ) public static synchronized IntrospectionHelper getHelper( Class c )
{ {
IntrospectionHelper ih = ( IntrospectionHelper )helpers.get( c );
IntrospectionHelper ih = (IntrospectionHelper)helpers.get( c );
if( ih == null ) if( ih == null )
{ {
ih = new IntrospectionHelper( c ); ih = new IntrospectionHelper( c );
@@ -285,13 +289,13 @@ public class IntrospectionHelper implements BuildListener
String value ) String value )
throws BuildException throws BuildException
{ {
AttributeSetter as = ( AttributeSetter )attributeSetters.get( attributeName );
AttributeSetter as = (AttributeSetter)attributeSetters.get( attributeName );
if( as == null ) if( as == null )
{ {
String msg = getElementName( p, element ) + String msg = getElementName( p, element ) +
//String msg = "Class " + element.getClass().getName() +
//String msg = "Class " + element.getClass().getName() +
" doesn't support the \"" + attributeName + "\" attribute."; " doesn't support the \"" + attributeName + "\" attribute.";
throw new BuildException( msg );
throw new TaskException( msg );
} }
try try
{ {
@@ -300,16 +304,16 @@ public class IntrospectionHelper implements BuildListener
catch( IllegalAccessException ie ) catch( IllegalAccessException ie )
{ {
// impossible as getMethods should only return public methods // impossible as getMethods should only return public methods
throw new BuildException( ie );
throw new TaskException( ie.toString(), ie );
} }
catch( InvocationTargetException ite ) catch( InvocationTargetException ite )
{ {
Throwable t = ite.getTargetException(); Throwable t = ite.getTargetException();
if( t instanceof BuildException )
if( t instanceof TaskException )
{ {
throw ( BuildException )t;
throw (TaskException)t;
} }
throw new BuildException( t );
throw new TaskException( t.toString(), t );
} }
} }


@@ -318,17 +322,17 @@ public class IntrospectionHelper implements BuildListener
* *
* @param attributeName Description of Parameter * @param attributeName Description of Parameter
* @return The AttributeType value * @return The AttributeType value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
public Class getAttributeType( String attributeName ) public Class getAttributeType( String attributeName )
throws BuildException
throws TaskException
{ {
Class at = ( Class )attributeTypes.get( attributeName );
Class at = (Class)attributeTypes.get( attributeName );
if( at == null ) if( at == null )
{ {
String msg = "Class " + bean.getName() + String msg = "Class " + bean.getName() +
" doesn't support the \"" + attributeName + "\" attribute."; " doesn't support the \"" + attributeName + "\" attribute.";
throw new BuildException( msg );
throw new TaskException( msg );
} }
return at; return at;
} }
@@ -348,17 +352,17 @@ public class IntrospectionHelper implements BuildListener
* *
* @param elementName Description of Parameter * @param elementName Description of Parameter
* @return The ElementType value * @return The ElementType value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
public Class getElementType( String elementName ) public Class getElementType( String elementName )
throws BuildException
throws TaskException
{ {
Class nt = ( Class )nestedTypes.get( elementName );
Class nt = (Class)nestedTypes.get( elementName );
if( nt == null ) if( nt == null )
{ {
String msg = "Class " + bean.getName() + String msg = "Class " + bean.getName() +
" doesn't support the nested \"" + elementName + "\" element."; " doesn't support the nested \"" + elementName + "\" element.";
throw new BuildException( msg );
throw new TaskException( msg );
} }
return nt; return nt;
} }
@@ -381,13 +385,14 @@ public class IntrospectionHelper implements BuildListener
* @param text The feature to be added to the Text attribute * @param text The feature to be added to the Text attribute
*/ */
public void addText( Project project, Object element, String text ) public void addText( Project project, Object element, String text )
throws TaskException
{ {
if( addText == null ) if( addText == null )
{ {
String msg = getElementName( project, element ) + String msg = getElementName( project, element ) +
//String msg = "Class " + element.getClass().getName() +
//String msg = "Class " + element.getClass().getName() +
" doesn't support nested text data."; " doesn't support nested text data.";
throw new BuildException( msg );
throw new TaskException( msg );
} }
try try
{ {
@@ -396,16 +401,16 @@ public class IntrospectionHelper implements BuildListener
catch( IllegalAccessException ie ) catch( IllegalAccessException ie )
{ {
// impossible as getMethods should only return public methods // impossible as getMethods should only return public methods
throw new BuildException( ie );
throw new TaskException( ie.getMessage(), ie );
} }
catch( InvocationTargetException ite ) catch( InvocationTargetException ite )
{ {
Throwable t = ite.getTargetException(); Throwable t = ite.getTargetException();
if( t instanceof BuildException )
if( t instanceof TaskException )
{ {
throw ( BuildException )t;
throw (TaskException)t;
} }
throw new BuildException( t );
throw new TaskException( t.getMessage(), t );
} }
} }


@@ -419,7 +424,9 @@ public class IntrospectionHelper implements BuildListener
helpers.clear(); helpers.clear();
} }


public void buildStarted( BuildEvent event ) { }
public void buildStarted( BuildEvent event )
{
}


/** /**
* Creates a named nested element. * Creates a named nested element.
@@ -428,49 +435,51 @@ public class IntrospectionHelper implements BuildListener
* @param element Description of Parameter * @param element Description of Parameter
* @param elementName Description of Parameter * @param elementName Description of Parameter
* @return Description of the Returned Value * @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
public Object createElement( Project project, Object element, String elementName ) public Object createElement( Project project, Object element, String elementName )
throws BuildException
throws TaskException
{ {
NestedCreator nc = ( NestedCreator )nestedCreators.get( elementName );
NestedCreator nc = (NestedCreator)nestedCreators.get( elementName );
if( nc == null ) if( nc == null )
{ {
String msg = getElementName( project, element ) + String msg = getElementName( project, element ) +
" doesn't support the nested \"" + elementName + "\" element."; " doesn't support the nested \"" + elementName + "\" element.";
throw new BuildException( msg );
throw new TaskException( msg );
} }
try try
{ {
Object nestedElement = nc.create( element ); Object nestedElement = nc.create( element );
if( nestedElement instanceof ProjectComponent ) if( nestedElement instanceof ProjectComponent )
{ {
( ( ProjectComponent )nestedElement ).setProject( project );
( (ProjectComponent)nestedElement ).setProject( project );
} }
return nestedElement; return nestedElement;
} }
catch( IllegalAccessException ie ) catch( IllegalAccessException ie )
{ {
// impossible as getMethods should only return public methods // impossible as getMethods should only return public methods
throw new BuildException( ie );
throw new TaskException( ie.getMessage(), ie );
} }
catch( InstantiationException ine ) catch( InstantiationException ine )
{ {
// impossible as getMethods should only return public methods // impossible as getMethods should only return public methods
throw new BuildException( ine );
throw new TaskException( ine.getMessage(), ine );
} }
catch( InvocationTargetException ite ) catch( InvocationTargetException ite )
{ {
Throwable t = ite.getTargetException(); Throwable t = ite.getTargetException();
if( t instanceof BuildException )
if( t instanceof TaskException )
{ {
throw ( BuildException )t;
throw (TaskException)t;
} }
throw new BuildException( t );
throw new TaskException( t.getMessage(), t );
} }
} }


public void messageLogged( BuildEvent event ) { }
public void messageLogged( BuildEvent event )
{
}


/** /**
* Creates a named nested element. * Creates a named nested element.
@@ -479,16 +488,16 @@ public class IntrospectionHelper implements BuildListener
* @param element Description of Parameter * @param element Description of Parameter
* @param child Description of Parameter * @param child Description of Parameter
* @param elementName Description of Parameter * @param elementName Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
public void storeElement( Project project, Object element, Object child, String elementName ) public void storeElement( Project project, Object element, Object child, String elementName )
throws BuildException
throws TaskException
{ {
if( elementName == null ) if( elementName == null )
{ {
return; return;
} }
NestedStorer ns = ( NestedStorer )nestedStorers.get( elementName );
NestedStorer ns = (NestedStorer)nestedStorers.get( elementName );
if( ns == null ) if( ns == null )
{ {
return; return;
@@ -500,21 +509,21 @@ public class IntrospectionHelper implements BuildListener
catch( IllegalAccessException ie ) catch( IllegalAccessException ie )
{ {
// impossible as getMethods should only return public methods // impossible as getMethods should only return public methods
throw new BuildException( ie );
throw new TaskException( ie.getMessage(), ie );
} }
catch( InstantiationException ine ) catch( InstantiationException ine )
{ {
// impossible as getMethods should only return public methods // impossible as getMethods should only return public methods
throw new BuildException( ine );
throw new TaskException( ine.getMessage(), ine );
} }
catch( InvocationTargetException ite ) catch( InvocationTargetException ite )
{ {
Throwable t = ite.getTargetException(); Throwable t = ite.getTargetException();
if( t instanceof BuildException )
if( t instanceof TaskException )
{ {
throw ( BuildException )t;
throw (TaskException)t;
} }
throw new BuildException( t );
throw new TaskException( t.getMessage(), t );
} }
} }


@@ -528,13 +537,21 @@ public class IntrospectionHelper implements BuildListener
return addText != null; return addText != null;
} }


public void targetFinished( BuildEvent event ) { }
public void targetFinished( BuildEvent event )
{
}


public void targetStarted( BuildEvent event ) { }
public void targetStarted( BuildEvent event )
{
}


public void taskFinished( BuildEvent event ) { }
public void taskFinished( BuildEvent event )
{
}


public void taskStarted( BuildEvent event ) { }
public void taskStarted( BuildEvent event )
{
}


protected String getElementName( Project project, Object element ) protected String getElementName( Project project, Object element )
{ {
@@ -555,8 +572,8 @@ public class IntrospectionHelper implements BuildListener
Enumeration e = elements.keys(); Enumeration e = elements.keys();
while( e.hasMoreElements() ) while( e.hasMoreElements() )
{ {
String elementName = ( String )e.nextElement();
Class elementClass = ( Class )elements.get( elementName );
String elementName = (String)e.nextElement();
Class elementClass = (Class)elements.get( elementName );
if( element.getClass().equals( elementClass ) ) if( element.getClass().equals( elementClass ) )
{ {
return "The <" + elementName + "> " + typeName; return "The <" + elementName + "> " + typeName;
@@ -590,7 +607,8 @@ public class IntrospectionHelper implements BuildListener
* @return Description of the Returned Value * @return Description of the Returned Value
*/ */
private AttributeSetter createAttributeSetter( final Method m, private AttributeSetter createAttributeSetter( final Method m,
final Class arg )
final Class arg )
throws TaskException
{ {


// simplest case - setAttribute expects String // simplest case - setAttribute expects String
@@ -608,7 +626,7 @@ public class IntrospectionHelper implements BuildListener
// now for the primitive types, use their wrappers // now for the primitive types, use their wrappers
} }
else if( java.lang.Character.class.equals( arg ) else if( java.lang.Character.class.equals( arg )
|| java.lang.Character.TYPE.equals( arg ) )
|| java.lang.Character.TYPE.equals( arg ) )
{ {
return return
new AttributeSetter() new AttributeSetter()
@@ -702,7 +720,7 @@ public class IntrospectionHelper implements BuildListener
// in Project // in Project
} }
else if( java.lang.Boolean.class.equals( arg ) else if( java.lang.Boolean.class.equals( arg )
|| java.lang.Boolean.TYPE.equals( arg ) )
|| java.lang.Boolean.TYPE.equals( arg ) )
{ {
return return
new AttributeSetter() new AttributeSetter()
@@ -711,7 +729,7 @@ public class IntrospectionHelper implements BuildListener
throws InvocationTargetException, IllegalAccessException throws InvocationTargetException, IllegalAccessException
{ {
m.invoke( parent, m.invoke( parent,
new Boolean[]{new Boolean( Project.toBoolean( value ) )} );
new Boolean[]{new Boolean( Project.toBoolean( value ) )} );
} }


}; };
@@ -723,7 +741,7 @@ public class IntrospectionHelper implements BuildListener
new AttributeSetter() new AttributeSetter()
{ {
public void set( Project p, Object parent, String value ) public void set( Project p, Object parent, String value )
throws InvocationTargetException, IllegalAccessException, BuildException
throws InvocationTargetException, IllegalAccessException, TaskException
{ {
try try
{ {
@@ -731,7 +749,7 @@ public class IntrospectionHelper implements BuildListener
} }
catch( ClassNotFoundException ce ) catch( ClassNotFoundException ce )
{ {
throw new BuildException( ce );
throw new TaskException( ce.toString(), ce );
} }
} }
}; };
@@ -745,7 +763,9 @@ public class IntrospectionHelper implements BuildListener
public void set( Project p, Object parent, String value ) public void set( Project p, Object parent, String value )
throws InvocationTargetException, IllegalAccessException throws InvocationTargetException, IllegalAccessException
{ {
m.invoke( parent, new File[]{p.resolveFile( value )} );
final File file =
FileUtils.newFileUtils().resolveFile( p.getBaseDir(), value );
m.invoke( parent, new File[]{ file } );
} }


}; };
@@ -771,17 +791,17 @@ public class IntrospectionHelper implements BuildListener
new AttributeSetter() new AttributeSetter()
{ {
public void set( Project p, Object parent, String value ) public void set( Project p, Object parent, String value )
throws InvocationTargetException, IllegalAccessException, BuildException
throws InvocationTargetException, IllegalAccessException, TaskException
{ {
try try
{ {
org.apache.tools.ant.types.EnumeratedAttribute ea = ( org.apache.tools.ant.types.EnumeratedAttribute )arg.newInstance();
org.apache.tools.ant.types.EnumeratedAttribute ea = (org.apache.tools.ant.types.EnumeratedAttribute)arg.newInstance();
ea.setValue( value ); ea.setValue( value );
m.invoke( parent, new EnumeratedAttribute[]{ea} ); m.invoke( parent, new EnumeratedAttribute[]{ea} );
} }
catch( InstantiationException ie ) catch( InstantiationException ie )
{ {
throw new BuildException( ie );
throw new TaskException( ie.getMessage(), ie );
} }
} }
}; };
@@ -801,20 +821,20 @@ public class IntrospectionHelper implements BuildListener
{ {
public void set( Project p, Object parent, public void set( Project p, Object parent,
String value ) String value )
throws InvocationTargetException, IllegalAccessException, BuildException
throws InvocationTargetException, IllegalAccessException, TaskException
{ {
try try
{ {
Object attribute = c.newInstance( new String[]{value} ); Object attribute = c.newInstance( new String[]{value} );
if( attribute instanceof ProjectComponent ) if( attribute instanceof ProjectComponent )
{ {
( ( ProjectComponent )attribute ).setProject( p );
( (ProjectComponent)attribute ).setProject( p );
} }
m.invoke( parent, new Object[]{attribute} ); m.invoke( parent, new Object[]{attribute} );
} }
catch( InstantiationException ie ) catch( InstantiationException ie )
{ {
throw new BuildException( ie );
throw new TaskException( ie.getMessage(), ie );
} }
} }
}; };
@@ -831,7 +851,7 @@ public class IntrospectionHelper implements BuildListener
{ {
void set( Project p, Object parent, String value ) void set( Project p, Object parent, String value )
throws InvocationTargetException, IllegalAccessException, throws InvocationTargetException, IllegalAccessException,
BuildException;
TaskException;
} }


private interface NestedCreator private interface NestedCreator


+ 18
- 17
proposal/myrmidon/src/main/org/apache/tools/ant/Main.java View File

@@ -14,6 +14,7 @@ import java.io.PrintStream;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Properties; import java.util.Properties;
import java.util.Vector; import java.util.Vector;
import org.apache.myrmidon.api.TaskException;


/** /**
* Command line entry point into Ant. This class is entered via the cannonical * Command line entry point into Ant. This class is entered via the cannonical
@@ -97,7 +98,7 @@ public class Main
private File buildFile; private File buildFile;


protected Main( String[] args ) protected Main( String[] args )
throws BuildException
throws TaskException
{ {


String searchForThis = null; String searchForThis = null;
@@ -289,7 +290,7 @@ public class Main
if( !buildFile.exists() ) if( !buildFile.exists() )
{ {
System.out.println( "Buildfile: " + buildFile + " does not exist!" ); System.out.println( "Buildfile: " + buildFile + " does not exist!" );
throw new BuildException( "Build failed" );
throw new TaskException( "Build failed" );
} }


// make sure it's not a directory (this falls into the ultra // make sure it's not a directory (this falls into the ultra
@@ -298,14 +299,14 @@ public class Main
if( buildFile.isDirectory() ) if( buildFile.isDirectory() )
{ {
System.out.println( "What? Buildfile: " + buildFile + " is a dir!" ); System.out.println( "What? Buildfile: " + buildFile + " is a dir!" );
throw new BuildException( "Build failed" );
throw new TaskException( "Build failed" );
} }


readyToRun = true; readyToRun = true;
} }


public static synchronized String getAntVersion() public static synchronized String getAntVersion()
throws BuildException
throws TaskException
{ {
if( antVersion == null ) if( antVersion == null )
{ {
@@ -327,12 +328,12 @@ public class Main
} }
catch( IOException ioe ) catch( IOException ioe )
{ {
throw new BuildException( "Could not load the version information:"
throw new TaskException( "Could not load the version information:"
+ ioe.getMessage() ); + ioe.getMessage() );
} }
catch( NullPointerException npe ) catch( NullPointerException npe )
{ {
throw new BuildException( "Could not load the version information." );
throw new TaskException( "Could not load the version information." );
} }
} }
return antVersion; return antVersion;
@@ -388,7 +389,7 @@ public class Main
m.runBuild( coreLoader ); m.runBuild( coreLoader );
System.exit( 0 ); System.exit( 0 );
} }
catch( BuildException be )
catch( TaskException be )
{ {
if( m.err != System.err ) if( m.err != System.err )
{ {
@@ -569,7 +570,7 @@ public class Main
} }


private static void printVersion() private static void printVersion()
throws BuildException
throws TaskException
{ {
System.out.println( getAntVersion() ); System.out.println( getAntVersion() );
} }
@@ -591,7 +592,7 @@ public class Main
} }
catch( Throwable exc ) catch( Throwable exc )
{ {
throw new BuildException( "Unable to instantiate listener " + className, exc );
throw new TaskException( "Unable to instantiate listener " + className, exc );
} }
} }
} }
@@ -668,10 +669,10 @@ public class Main
* @param suffix Suffix filename to look for in parents. * @param suffix Suffix filename to look for in parents.
* @param start Description of Parameter * @param start Description of Parameter
* @return A handle to the build file * @return A handle to the build file
* @exception BuildException Failed to locate a build file
* @exception TaskException Failed to locate a build file
*/ */
private File findBuildFile( String start, String suffix ) private File findBuildFile( String start, String suffix )
throws BuildException
throws TaskException
{ {
if( msgOutputLevel >= Project.MSG_INFO ) if( msgOutputLevel >= Project.MSG_INFO )
{ {
@@ -691,7 +692,7 @@ public class Main
// complain that we can't find the build file. // complain that we can't find the build file.
if( parent == null ) if( parent == null )
{ {
throw new BuildException( "Could not locate a build file!" );
throw new TaskException( "Could not locate a build file!" );
} }


// refresh our file handle // refresh our file handle
@@ -705,10 +706,10 @@ public class Main
* Executes the build. * Executes the build.
* *
* @param coreLoader Description of Parameter * @param coreLoader Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
private void runBuild( ClassLoader coreLoader ) private void runBuild( ClassLoader coreLoader )
throws BuildException
throws TaskException
{ {


if( !readyToRun ) if( !readyToRun )
@@ -782,15 +783,15 @@ public class Main
} }
catch( NoClassDefFoundError ncdfe ) catch( NoClassDefFoundError ncdfe )
{ {
throw new BuildException( noParserMessage, ncdfe );
throw new TaskException( noParserMessage, ncdfe );
} }
catch( ClassNotFoundException cnfe ) catch( ClassNotFoundException cnfe )
{ {
throw new BuildException( noParserMessage, cnfe );
throw new TaskException( noParserMessage, cnfe );
} }
catch( NullPointerException npe ) catch( NullPointerException npe )
{ {
throw new BuildException( noParserMessage, npe );
throw new TaskException( noParserMessage, npe );
} }


if( projectHelp ) if( projectHelp )


+ 100
- 336
proposal/myrmidon/src/main/org/apache/tools/ant/Project.java
File diff suppressed because it is too large
View File


+ 7
- 0
proposal/myrmidon/src/main/org/apache/tools/ant/ProjectComponent.java View File

@@ -8,6 +8,8 @@
package org.apache.tools.ant; package org.apache.tools.ant;


import org.apache.myrmidon.api.AbstractTask; import org.apache.myrmidon.api.AbstractTask;
import org.apache.tools.ant.util.FileUtils;
import java.io.File;


/** /**
* Base class for components of a project, including tasks and data types. * Base class for components of a project, including tasks and data types.
@@ -43,6 +45,11 @@ public abstract class ProjectComponent
return project; return project;
} }


protected File resolveFile( final String name )
{
return FileUtils.newFileUtils().resolveFile( project.getBaseDir(), name );
}

/** /**
* Log a message with the default (INFO) priority. * Log a message with the default (INFO) priority.
* *


+ 58
- 52
proposal/myrmidon/src/main/org/apache/tools/ant/ProjectHelper.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant; package org.apache.tools.ant;

import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@@ -17,6 +18,8 @@ import java.util.Vector;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.util.FileUtils;
import org.xml.sax.AttributeList; import org.xml.sax.AttributeList;
import org.xml.sax.DocumentHandler; import org.xml.sax.DocumentHandler;
import org.xml.sax.HandlerBase; import org.xml.sax.HandlerBase;
@@ -64,10 +67,10 @@ public class ProjectHelper
* @param buf The feature to be added to the Text attribute * @param buf The feature to be added to the Text attribute
* @param start The feature to be added to the Text attribute * @param start The feature to be added to the Text attribute
* @param end The feature to be added to the Text attribute * @param end The feature to be added to the Text attribute
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
public static void addText( Project project, Object target, char[] buf, int start, int end ) public static void addText( Project project, Object target, char[] buf, int start, int end )
throws BuildException
throws TaskException
{ {
addText( project, target, new String( buf, start, end ) ); addText( project, target, new String( buf, start, end ) );
} }
@@ -78,10 +81,10 @@ public class ProjectHelper
* @param project The feature to be added to the Text attribute * @param project The feature to be added to the Text attribute
* @param target The feature to be added to the Text attribute * @param target The feature to be added to the Text attribute
* @param text The feature to be added to the Text attribute * @param text The feature to be added to the Text attribute
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
public static void addText( Project project, Object target, String text ) public static void addText( Project project, Object target, String text )
throws BuildException
throws TaskException
{ {


if( text == null || text.trim().length() == 0 ) if( text == null || text.trim().length() == 0 )
@@ -90,17 +93,17 @@ public class ProjectHelper
} }


if( target instanceof TaskAdapter ) if( target instanceof TaskAdapter )
target = ( ( TaskAdapter )target ).getProxy();
target = ( (TaskAdapter)target ).getProxy();


IntrospectionHelper.getHelper( target.getClass() ).addText( project, target, text ); IntrospectionHelper.getHelper( target.getClass() ).addText( project, target, text );
} }


public static void configure( Object target, AttributeList attrs, public static void configure( Object target, AttributeList attrs,
Project project ) Project project )
throws BuildException
throws TaskException
{ {
if( target instanceof TaskAdapter ) if( target instanceof TaskAdapter )
target = ( ( TaskAdapter )target ).getProxy();
target = ( (TaskAdapter)target ).getProxy();


IntrospectionHelper ih = IntrospectionHelper ih =
IntrospectionHelper.getHelper( target.getClass() ); IntrospectionHelper.getHelper( target.getClass() );
@@ -111,14 +114,14 @@ public class ProjectHelper
{ {
// reflect these into the target // reflect these into the target
String value = replaceProperties( project, attrs.getValue( i ), String value = replaceProperties( project, attrs.getValue( i ),
project.getProperties() );
project.getProperties() );
try try
{ {
ih.setAttribute( project, target, ih.setAttribute( project, target,
attrs.getName( i ).toLowerCase( Locale.US ), value );
attrs.getName( i ).toLowerCase( Locale.US ), value );


} }
catch( BuildException be )
catch( TaskException be )
{ {
// id attribute must be set externally // id attribute must be set externally
if( !attrs.getName( i ).equals( "id" ) ) if( !attrs.getName( i ).equals( "id" ) )
@@ -134,10 +137,10 @@ public class ProjectHelper
* *
* @param project Description of Parameter * @param project Description of Parameter
* @param buildFile Description of Parameter * @param buildFile Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
public static void configureProject( Project project, File buildFile ) public static void configureProject( Project project, File buildFile )
throws BuildException
throws TaskException
{ {
new ProjectHelper( project, buildFile ).parse(); new ProjectHelper( project, buildFile ).parse();
} }
@@ -151,10 +154,10 @@ public class ProjectHelper
* @param value Description of Parameter * @param value Description of Parameter
* @param fragments Description of Parameter * @param fragments Description of Parameter
* @param propertyRefs Description of Parameter * @param propertyRefs Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
public static void parsePropertyString( String value, Vector fragments, Vector propertyRefs ) public static void parsePropertyString( String value, Vector fragments, Vector propertyRefs )
throws BuildException
throws TaskException
{ {
int prev = 0; int prev = 0;
int pos; int pos;
@@ -180,8 +183,8 @@ public class ProjectHelper
int endName = value.indexOf( '}', pos ); int endName = value.indexOf( '}', pos );
if( endName < 0 ) if( endName < 0 )
{ {
throw new BuildException( "Syntax error in property: "
+ value );
throw new TaskException( "Syntax error in property: "
+ value );
} }
String propertyName = value.substring( pos + 2, endName ); String propertyName = value.substring( pos + 2, endName );
fragments.addElement( null ); fragments.addElement( null );
@@ -203,11 +206,11 @@ public class ProjectHelper
* @param value the string to be scanned for property references. * @param value the string to be scanned for property references.
* @param project Description of Parameter * @param project Description of Parameter
* @return Description of the Returned Value * @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
* @since 1.5 * @since 1.5
*/ */
public static String replaceProperties( Project project, String value ) public static String replaceProperties( Project project, String value )
throws BuildException
throws TaskException
{ {
return replaceProperties( project, value, project.getProperties() ); return replaceProperties( project, value, project.getProperties() );
} }
@@ -220,10 +223,10 @@ public class ProjectHelper
* @param project Description of Parameter * @param project Description of Parameter
* @param keys Description of Parameter * @param keys Description of Parameter
* @return Description of the Returned Value * @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
public static String replaceProperties( Project project, String value, Hashtable keys ) public static String replaceProperties( Project project, String value, Hashtable keys )
throws BuildException
throws TaskException
{ {
if( value == null ) if( value == null )
{ {
@@ -239,16 +242,16 @@ public class ProjectHelper
Enumeration j = propertyRefs.elements(); Enumeration j = propertyRefs.elements();
while( i.hasMoreElements() ) while( i.hasMoreElements() )
{ {
String fragment = ( String )i.nextElement();
String fragment = (String)i.nextElement();
if( fragment == null ) if( fragment == null )
{ {
String propertyName = ( String )j.nextElement();
String propertyName = (String)j.nextElement();
if( !keys.containsKey( propertyName ) ) if( !keys.containsKey( propertyName ) )
{ {
project.log( "Property ${" + propertyName + "} has not been set", Project.MSG_VERBOSE ); project.log( "Property ${" + propertyName + "} has not been set", Project.MSG_VERBOSE );
} }
fragment = ( keys.containsKey( propertyName ) ) ? ( String )keys.get( propertyName )
: "${" + propertyName + "}";
fragment = ( keys.containsKey( propertyName ) ) ? (String)keys.get( propertyName )
: "${" + propertyName + "}";
} }
sb.append( fragment ); sb.append( fragment );
} }
@@ -265,6 +268,7 @@ public class ProjectHelper
* @param tag Description of Parameter * @param tag Description of Parameter
*/ */
public static void storeChild( Project project, Object parent, Object child, String tag ) public static void storeChild( Project project, Object parent, Object child, String tag )
throws TaskException
{ {
IntrospectionHelper ih = IntrospectionHelper.getHelper( parent.getClass() ); IntrospectionHelper ih = IntrospectionHelper.getHelper( parent.getClass() );
ih.storeElement( project, parent, child, tag ); ih.storeElement( project, parent, child, tag );
@@ -302,10 +306,10 @@ public class ProjectHelper
/** /**
* Parses the project file. * Parses the project file.
* *
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
private void parse() private void parse()
throws BuildException
throws TaskException
{ {
FileInputStream inputStream = null; FileInputStream inputStream = null;
InputSource inputSource = null; InputSource inputSource = null;
@@ -329,7 +333,7 @@ public class ProjectHelper
} }
catch( ParserConfigurationException exc ) catch( ParserConfigurationException exc )
{ {
throw new BuildException( "Parser has not been configured correctly", exc );
throw new TaskException( "Parser has not been configured correctly", exc );
} }
catch( SAXParseException exc ) catch( SAXParseException exc )
{ {
@@ -339,7 +343,7 @@ public class ProjectHelper
Throwable t = exc.getException(); Throwable t = exc.getException();
if( t instanceof BuildException ) if( t instanceof BuildException )
{ {
BuildException be = ( BuildException )t;
BuildException be = (BuildException)t;
if( be.getLocation() == Location.UNKNOWN_LOCATION ) if( be.getLocation() == Location.UNKNOWN_LOCATION )
{ {
be.setLocation( location ); be.setLocation( location );
@@ -347,24 +351,24 @@ public class ProjectHelper
throw be; throw be;
} }


throw new BuildException( exc.getMessage(), t, location );
throw new BuildException( exc.getMessage(), t );
} }
catch( SAXException exc ) catch( SAXException exc )
{ {
Throwable t = exc.getException(); Throwable t = exc.getException();
if( t instanceof BuildException )
if( t instanceof TaskException )
{ {
throw ( BuildException )t;
throw (TaskException)t;
} }
throw new BuildException( exc.getMessage(), t );
throw new TaskException( exc.getMessage(), t );
} }
catch( FileNotFoundException exc ) catch( FileNotFoundException exc )
{ {
throw new BuildException( exc );
throw new TaskException( "Error", exc );
} }
catch( IOException exc ) catch( IOException exc )
{ {
throw new BuildException( "Error reading project file", exc );
throw new TaskException( "Error reading project file", exc );
} }
finally finally
{ {
@@ -434,7 +438,9 @@ public class ProjectHelper
* Called when this element and all elements nested into it have been * Called when this element and all elements nested into it have been
* handled. * handled.
*/ */
protected void finished() { }
protected void finished()
{
}
} }


/** /**
@@ -466,21 +472,21 @@ public class ProjectHelper
{ {
addText( project, element, buf, start, end ); addText( project, element, buf, start, end );
} }
catch( BuildException exc )
catch( TaskException exc )
{ {
throw new SAXParseException( exc.getMessage(), locator, exc ); throw new SAXParseException( exc.getMessage(), locator, exc );
} }
} }


public void init( String propType, AttributeList attrs ) public void init( String propType, AttributeList attrs )
throws SAXParseException
throws SAXParseException, TaskException
{ {
try try
{ {
element = project.createDataType( propType ); element = project.createDataType( propType );
if( element == null ) if( element == null )
{ {
throw new BuildException( "Unknown data type " + propType );
throw new TaskException( "Unknown data type " + propType );
} }


if( target != null ) if( target != null )
@@ -495,7 +501,7 @@ public class ProjectHelper
configureId( element, attrs ); configureId( element, attrs );
} }
} }
catch( BuildException exc )
catch( TaskException exc )
{ {
throw new SAXParseException( exc.getMessage(), locator, exc ); throw new SAXParseException( exc.getMessage(), locator, exc );
} }
@@ -530,7 +536,7 @@ public class ProjectHelper


if( parent instanceof TaskAdapter ) if( parent instanceof TaskAdapter )
{ {
this.parent = ( ( TaskAdapter )parent ).getProxy();
this.parent = ( (TaskAdapter)parent ).getProxy();
} }
else else
{ {
@@ -549,7 +555,7 @@ public class ProjectHelper
{ {
addText( project, child, buf, start, end ); addText( project, child, buf, start, end );
} }
catch( BuildException exc )
catch( TaskException exc )
{ {
throw new SAXParseException( exc.getMessage(), locator, exc ); throw new SAXParseException( exc.getMessage(), locator, exc );
} }
@@ -574,7 +580,7 @@ public class ProjectHelper
{ {
UnknownElement uc = new UnknownElement( elementName ); UnknownElement uc = new UnknownElement( elementName );
uc.setProject( project ); uc.setProject( project );
( ( UnknownElement )parent ).addChild( uc );
( (UnknownElement)parent ).addChild( uc );
child = uc; child = uc;
} }
else else
@@ -596,7 +602,7 @@ public class ProjectHelper
ih.storeElement( project, parent, child, elementName ); ih.storeElement( project, parent, child, elementName );
} }
} }
catch( BuildException exc )
catch( TaskException exc )
{ {
throw new SAXParseException( exc.getMessage(), locator, exc ); throw new SAXParseException( exc.getMessage(), locator, exc );
} }
@@ -609,7 +615,7 @@ public class ProjectHelper
{ {
// taskcontainer nested element can contain other tasks - no other // taskcontainer nested element can contain other tasks - no other
// nested elements possible // nested elements possible
new TaskHandler( this, ( TaskContainer )child, childWrapper, target ).init( name, attrs );
new TaskHandler( this, (TaskContainer)child, childWrapper, target ).init( name, attrs );
} }
else else
{ {
@@ -631,7 +637,7 @@ public class ProjectHelper
} }


public void init( String tag, AttributeList attrs ) public void init( String tag, AttributeList attrs )
throws SAXParseException
throws SAXParseException, TaskException
{ {
String def = null; String def = null;
String name = null; String name = null;
@@ -668,10 +674,10 @@ public class ProjectHelper
if( def == null ) if( def == null )
{ {
throw new SAXParseException( "The default attribute of project is required", throw new SAXParseException( "The default attribute of project is required",
locator );
locator );
} }


project.setDefaultTarget( def );
project.setDefault( def );


if( name != null ) if( name != null )
{ {
@@ -701,7 +707,7 @@ public class ProjectHelper
} }
else else
{ {
project.setBaseDir( project.resolveFile( baseDir, buildFileParent ) );
project.setBaseDir( FileUtils.newFileUtils().resolveFile( buildFileParent, baseDir ) );
} }
} }
} }
@@ -833,7 +839,7 @@ public class ProjectHelper
catch( FileNotFoundException fne ) catch( FileNotFoundException fne )
{ {
project.log( file.getAbsolutePath() + " could not be found", project.log( file.getAbsolutePath() + " could not be found",
Project.MSG_WARN );
Project.MSG_WARN );
} }
} }
// use default if not file or file not found // use default if not file or file not found
@@ -980,7 +986,7 @@ public class ProjectHelper
{ {
addText( project, task, buf, start, end ); addText( project, task, buf, start, end );
} }
catch( BuildException exc )
catch( TaskException exc )
{ {
throw new SAXParseException( exc.getMessage(), locator, exc ); throw new SAXParseException( exc.getMessage(), locator, exc );
} }
@@ -998,7 +1004,7 @@ public class ProjectHelper
{ {
task = project.createTask( tag ); task = project.createTask( tag );
} }
catch( BuildException e )
catch( TaskException e )
{ {
// swallow here, will be thrown again in // swallow here, will be thrown again in
// UnknownElement.maybeConfigure if the problem persists. // UnknownElement.maybeConfigure if the problem persists.
@@ -1041,7 +1047,7 @@ public class ProjectHelper
if( task instanceof TaskContainer ) if( task instanceof TaskContainer )
{ {
// task can contain other tasks - no other nested elements possible // task can contain other tasks - no other nested elements possible
new TaskHandler( this, ( TaskContainer )task, wrapper, target ).init( name, attrs );
new TaskHandler( this, (TaskContainer)task, wrapper, target ).init( name, attrs );
} }
else else
{ {


+ 2
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/RuntimeConfigurable.java View File

@@ -11,6 +11,7 @@ import java.util.Locale;
import java.util.Vector; import java.util.Vector;
import org.xml.sax.AttributeList; import org.xml.sax.AttributeList;
import org.xml.sax.helpers.AttributeListImpl; import org.xml.sax.helpers.AttributeListImpl;
import org.apache.myrmidon.api.TaskException;


/** /**
* Wrapper class that holds the attributes of a Task (or elements nested below * Wrapper class that holds the attributes of a Task (or elements nested below
@@ -102,7 +103,7 @@ public class RuntimeConfigurable
* @exception BuildException Description of Exception * @exception BuildException Description of Exception
*/ */
public void maybeConfigure( Project p ) public void maybeConfigure( Project p )
throws BuildException
throws TaskException
{ {
String id = null; String id = null;




+ 21
- 12
proposal/myrmidon/src/main/org/apache/tools/ant/Target.java View File

@@ -6,9 +6,11 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant; package org.apache.tools.ant;

import java.util.Enumeration; import java.util.Enumeration;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector; import java.util.Vector;
import org.apache.myrmidon.api.TaskException;


/** /**
* This class implements a target object with required parameters. * This class implements a target object with required parameters.
@@ -28,6 +30,7 @@ public class Target implements TaskContainer
private Project project; private Project project;


public void setDepends( String depS ) public void setDepends( String depS )
throws TaskException
{ {
if( depS.length() > 0 ) if( depS.length() > 0 )
{ {
@@ -40,9 +43,9 @@ public class Target implements TaskContainer
//Make sure the dependency is not empty string //Make sure the dependency is not empty string
if( token.equals( "" ) || token.equals( "," ) ) if( token.equals( "" ) || token.equals( "," ) )
{ {
throw new BuildException( "Syntax Error: Depend attribute " +
"for target \"" + getName() +
"\" has an empty string for dependency." );
throw new TaskException( "Syntax Error: Depend attribute " +
"for target \"" + getName() +
"\" has an empty string for dependency." );
} }


addDependency( token ); addDependency( token );
@@ -54,9 +57,9 @@ public class Target implements TaskContainer
token = tok.nextToken(); token = tok.nextToken();
if( !tok.hasMoreTokens() || !token.equals( "," ) ) if( !tok.hasMoreTokens() || !token.equals( "," ) )
{ {
throw new BuildException( "Syntax Error: Depend attribute " +
"for target \"" + getName() +
"\" ends with a , character" );
throw new TaskException( "Syntax Error: Depend attribute " +
"for target \"" + getName() +
"\" ends with a , character" );
} }
} }
} }
@@ -126,7 +129,7 @@ public class Target implements TaskContainer
} }
} }


Task[] retval = new Task[tasks.size()];
Task[] retval = new Task[ tasks.size() ];
tasks.copyInto( retval ); tasks.copyInto( retval );
return retval; return retval;
} }
@@ -139,6 +142,10 @@ public class Target implements TaskContainer
execute(); execute();
project.fireTargetFinished( this, null ); project.fireTargetFinished( this, null );
} }
catch( final TaskException te )
{
project.fireTargetFinished( this, te );
}
catch( RuntimeException exc ) catch( RuntimeException exc )
{ {
project.fireTargetFinished( this, exc ); project.fireTargetFinished( this, exc );
@@ -162,7 +169,7 @@ public class Target implements TaskContainer
} }


public void execute() public void execute()
throws BuildException
throws TaskException
{ {
if( testIfCondition() && testUnlessCondition() ) if( testIfCondition() && testUnlessCondition() )
{ {
@@ -172,12 +179,12 @@ public class Target implements TaskContainer
Object o = enum.nextElement(); Object o = enum.nextElement();
if( o instanceof Task ) if( o instanceof Task )
{ {
Task task = ( Task )o;
Task task = (Task)o;
task.perform(); task.perform();
} }
else else
{ {
RuntimeConfigurable r = ( RuntimeConfigurable )o;
RuntimeConfigurable r = (RuntimeConfigurable)o;
r.maybeConfigure( project ); r.maybeConfigure( project );
} }
} }
@@ -185,12 +192,12 @@ public class Target implements TaskContainer
else if( !testIfCondition() ) else if( !testIfCondition() )
{ {
project.log( this, "Skipped because property '" + this.ifCondition + "' not set.", project.log( this, "Skipped because property '" + this.ifCondition + "' not set.",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
} }
else else
{ {
project.log( this, "Skipped because property '" + this.unlessCondition + "' set.", project.log( this, "Skipped because property '" + this.unlessCondition + "' set.",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
} }
} }


@@ -209,6 +216,7 @@ public class Target implements TaskContainer
} }


private boolean testIfCondition() private boolean testIfCondition()
throws TaskException
{ {
if( "".equals( ifCondition ) ) if( "".equals( ifCondition ) )
{ {
@@ -220,6 +228,7 @@ public class Target implements TaskContainer
} }


private boolean testUnlessCondition() private boolean testUnlessCondition()
throws TaskException
{ {
if( "".equals( unlessCondition ) ) if( "".equals( unlessCondition ) )
{ {


+ 2
- 0
proposal/myrmidon/src/main/org/apache/tools/ant/Task.java View File

@@ -7,7 +7,9 @@
*/ */
package org.apache.tools.ant; package org.apache.tools.ant;


import java.io.File;
import org.apache.myrmidon.api.TaskException; import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.util.FileUtils;


public abstract class Task public abstract class Task
extends ProjectComponent extends ProjectComponent


+ 6
- 4
proposal/myrmidon/src/main/org/apache/tools/ant/TaskAdapter.java View File

@@ -8,6 +8,7 @@
package org.apache.tools.ant; package org.apache.tools.ant;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import org.apache.myrmidon.api.TaskException;




/** /**
@@ -33,6 +34,7 @@ public class TaskAdapter extends Task
* @param project Description of Parameter * @param project Description of Parameter
*/ */
public static void checkTaskClass( final Class taskClass, final Project project ) public static void checkTaskClass( final Class taskClass, final Project project )
throws TaskException
{ {
// don't have to check for interface, since then // don't have to check for interface, since then
// taskClass would be abstract too. // taskClass would be abstract too.
@@ -53,7 +55,7 @@ public class TaskAdapter extends Task
{ {
final String message = "No public execute() in " + taskClass; final String message = "No public execute() in " + taskClass;
project.log( message, Project.MSG_ERR ); project.log( message, Project.MSG_ERR );
throw new BuildException( message );
throw new TaskException( message );
} }
} }


@@ -100,7 +102,7 @@ public class TaskAdapter extends Task
{ {
log( "Error setting project in " + proxy.getClass(), log( "Error setting project in " + proxy.getClass(),
Project.MSG_ERR ); Project.MSG_ERR );
throw new BuildException( ex );
throw new BuildException( "Error", ex );
} }


Method executeM = null; Method executeM = null;
@@ -111,7 +113,7 @@ public class TaskAdapter extends Task
if( executeM == null ) if( executeM == null )
{ {
log( "No public execute() in " + proxy.getClass(), Project.MSG_ERR ); log( "No public execute() in " + proxy.getClass(), Project.MSG_ERR );
throw new BuildException( "No public execute() in " + proxy.getClass() );
throw new TaskException( "No public execute() in " + proxy.getClass() );
} }
executeM.invoke( proxy, null ); executeM.invoke( proxy, null );
return; return;
@@ -119,7 +121,7 @@ public class TaskAdapter extends Task
catch( Exception ex ) catch( Exception ex )
{ {
log( "Error in " + proxy.getClass(), Project.MSG_ERR ); log( "Error in " + proxy.getClass(), Project.MSG_ERR );
throw new BuildException( ex );
throw new BuildException( "Error", ex );
} }


} }


+ 31
- 26
proposal/myrmidon/src/main/org/apache/tools/ant/UnknownElement.java View File

@@ -6,7 +6,9 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant; package org.apache.tools.ant;

import java.util.Vector; import java.util.Vector;
import org.apache.myrmidon.api.TaskException;


/** /**
* Wrapper class that holds all information necessary to create a task or data * Wrapper class that holds all information necessary to create a task or data
@@ -57,7 +59,7 @@ public class UnknownElement extends Task
{ {
if( realThing != null && realThing instanceof Task ) if( realThing != null && realThing instanceof Task )
{ {
return ( Task )realThing;
return (Task)realThing;
} }
return null; return null;
} }
@@ -70,7 +72,7 @@ public class UnknownElement extends Task
public String getTaskName() public String getTaskName()
{ {
return realThing == null || !( realThing instanceof Task ) ? return realThing == null || !( realThing instanceof Task ) ?
super.getTaskName() : ( ( Task )realThing ).getTaskName();
super.getTaskName() : ( (Task)realThing ).getTaskName();
} }


/** /**
@@ -87,18 +89,19 @@ public class UnknownElement extends Task
* Called when the real task has been configured for the first time. * Called when the real task has been configured for the first time.
*/ */
public void execute() public void execute()
throws TaskException
{ {
if( realThing == null ) if( realThing == null )
{ {
// plain impossible to get here, maybeConfigure should // plain impossible to get here, maybeConfigure should
// have thrown an exception. // have thrown an exception.
throw new BuildException( "Could not create task of type: "
+ elementName, location );
throw new TaskException( "Could not create task of type: "
+ elementName );
} }


if( realThing instanceof Task ) if( realThing instanceof Task )
{ {
( ( Task )realThing ).perform();
( (Task)realThing ).perform();
} }
} }


@@ -109,14 +112,14 @@ public class UnknownElement extends Task
* @exception BuildException Description of Exception * @exception BuildException Description of Exception
*/ */
public void maybeConfigure() public void maybeConfigure()
throws BuildException
throws TaskException
{ {
realThing = makeObject( this, wrapper ); realThing = makeObject( this, wrapper );


wrapper.setProxy( realThing ); wrapper.setProxy( realThing );
if( realThing instanceof Task ) if( realThing instanceof Task )
{ {
( ( Task )realThing ).setRuntimeConfigurableWrapper( wrapper );
( (Task)realThing ).setRuntimeConfigurableWrapper( wrapper );
} }


handleChildren( realThing, wrapper ); handleChildren( realThing, wrapper );
@@ -137,19 +140,19 @@ public class UnknownElement extends Task
{ {
String lSep = System.getProperty( "line.separator" ); String lSep = System.getProperty( "line.separator" );
String msg = "Could not create " + what + " of type: " + elementName String msg = "Could not create " + what + " of type: " + elementName
+ "." + lSep
+ "Ant could not find the task or a class this" + lSep
+ "task relies upon." + lSep
+ "Common solutions are to use taskdef to declare" + lSep
+ "your task, or, if this is an optional task," + lSep
+ "to put the optional.jar and all required libraries of" + lSep
+ "this task in the lib directory of" + lSep
+ "your ant installation (ANT_HOME)." + lSep
+ "There is also the possibility that your build file " + lSep
+ "is written to work with a more recent version of ant " + lSep
+ "than the one you are using, in which case you have to " + lSep
+ "upgrade.";
return new BuildException( msg, location );
+ "." + lSep
+ "Ant could not find the task or a class this" + lSep
+ "task relies upon." + lSep
+ "Common solutions are to use taskdef to declare" + lSep
+ "your task, or, if this is an optional task," + lSep
+ "to put the optional.jar and all required libraries of" + lSep
+ "this task in the lib directory of" + lSep
+ "your ant installation (ANT_HOME)." + lSep
+ "There is also the possibility that your build file " + lSep
+ "is written to work with a more recent version of ant " + lSep
+ "than the one you are using, in which case you have to " + lSep
+ "upgrade.";
return new BuildException( msg );
} }


/** /**
@@ -162,12 +165,12 @@ public class UnknownElement extends Task
*/ */
protected void handleChildren( Object parent, protected void handleChildren( Object parent,
RuntimeConfigurable parentWrapper ) RuntimeConfigurable parentWrapper )
throws BuildException
throws TaskException
{ {


if( parent instanceof TaskAdapter ) if( parent instanceof TaskAdapter )
{ {
parent = ( ( TaskAdapter )parent ).getProxy();
parent = ( (TaskAdapter)parent ).getProxy();
} }


Class parentClass = parent.getClass(); Class parentClass = parent.getClass();
@@ -176,13 +179,13 @@ public class UnknownElement extends Task
for( int i = 0; i < children.size(); i++ ) for( int i = 0; i < children.size(); i++ )
{ {
RuntimeConfigurable childWrapper = parentWrapper.getChild( i ); RuntimeConfigurable childWrapper = parentWrapper.getChild( i );
UnknownElement child = ( UnknownElement )children.elementAt( i );
UnknownElement child = (UnknownElement)children.elementAt( i );
Object realChild = null; Object realChild = null;


if( parent instanceof TaskContainer ) if( parent instanceof TaskContainer )
{ {
realChild = makeTask( child, childWrapper, false ); realChild = makeTask( child, childWrapper, false );
( ( TaskContainer )parent ).addTask( ( Task )realChild );
( (TaskContainer)parent ).addTask( (Task)realChild );
} }
else else
{ {
@@ -192,14 +195,14 @@ public class UnknownElement extends Task
childWrapper.setProxy( realChild ); childWrapper.setProxy( realChild );
if( parent instanceof TaskContainer ) if( parent instanceof TaskContainer )
{ {
( ( Task )realChild ).setRuntimeConfigurableWrapper( childWrapper );
( (Task)realChild ).setRuntimeConfigurableWrapper( childWrapper );
} }


child.handleChildren( realChild, childWrapper ); child.handleChildren( realChild, childWrapper );


if( parent instanceof TaskContainer ) if( parent instanceof TaskContainer )
{ {
( ( Task )realChild ).maybeConfigure();
( (Task)realChild ).maybeConfigure();
} }
} }
} }
@@ -213,6 +216,7 @@ public class UnknownElement extends Task
* @return Description of the Returned Value * @return Description of the Returned Value
*/ */
protected Object makeObject( UnknownElement ue, RuntimeConfigurable w ) protected Object makeObject( UnknownElement ue, RuntimeConfigurable w )
throws TaskException
{ {
Object o = makeTask( ue, w, true ); Object o = makeTask( ue, w, true );
if( o == null ) if( o == null )
@@ -236,6 +240,7 @@ public class UnknownElement extends Task
*/ */
protected Task makeTask( UnknownElement ue, RuntimeConfigurable w, protected Task makeTask( UnknownElement ue, RuntimeConfigurable w,
boolean onTopLevel ) boolean onTopLevel )
throws TaskException
{ {
Task task = project.createTask( ue.getTag() ); Task task = project.createTask( ue.getTag() );
if( task == null && !onTopLevel ) if( task == null && !onTopLevel )


+ 10
- 9
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ant.java View File

@@ -22,6 +22,7 @@ import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;
import org.apache.myrmidon.api.TaskException;


/** /**
* Call Ant in a sub-project <pre> * Call Ant in a sub-project <pre>
@@ -178,10 +179,10 @@ public class Ant extends Task
/** /**
* Do the execution. * Do the execution.
* *
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
public void execute() public void execute()
throws BuildException
throws TaskException
{ {
try try
{ {
@@ -234,7 +235,7 @@ public class Ant extends Task
target.equals( this.getOwningTarget().getName() ) ) target.equals( this.getOwningTarget().getName() ) )
{ {


throw new BuildException( "ant task calling its own parent target" );
throw new TaskException( "ant task calling its own parent target" );
} }


newProject.executeTarget( target ); newProject.executeTarget( target );
@@ -283,10 +284,10 @@ public class Ant extends Task
* project. Also copy over all references that don't override existing * project. Also copy over all references that don't override existing
* references in the new project if inheritall has been requested. * references in the new project if inheritall has been requested.
* *
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
private void addReferences() private void addReferences()
throws BuildException
throws TaskException
{ {
Hashtable thisReferences = ( Hashtable )project.getReferences().clone(); Hashtable thisReferences = ( Hashtable )project.getReferences().clone();
Hashtable newReferences = newProject.getReferences(); Hashtable newReferences = newProject.getReferences();
@@ -299,7 +300,7 @@ public class Ant extends Task
String refid = ref.getRefId(); String refid = ref.getRefId();
if( refid == null ) if( refid == null )
{ {
throw new BuildException( "the refid attribute is required for reference elements" );
throw new TaskException( "the refid attribute is required for reference elements" );
} }
if( !thisReferences.containsKey( refid ) ) if( !thisReferences.containsKey( refid ) )
{ {
@@ -387,7 +388,7 @@ public class Ant extends Task
{ {
String msg = "Error setting new project instance for reference with id " String msg = "Error setting new project instance for reference with id "
+ oldKey; + oldKey;
throw new BuildException( msg, e2, location );
throw new TaskException( msg, e2, location );
} }
} }
newProject.addReference( newKey, copy ); newProject.addReference( newKey, copy );
@@ -482,10 +483,10 @@ public class Ant extends Task
* Override the properties in the new project with the one explicitly * Override the properties in the new project with the one explicitly
* defined as nested elements here. * defined as nested elements here.
* *
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/ */
private void overrideProperties() private void overrideProperties()
throws BuildException
throws TaskException
{ {
Enumeration e = properties.elements(); Enumeration e = properties.elements();
while( e.hasMoreElements() ) while( e.hasMoreElements() )


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/AntStructure.java View File

@@ -58,7 +58,7 @@ public class AntStructure extends Task


if( output == null ) if( output == null )
{ {
throw new BuildException( "output attribute is required", location );
throw new BuildException( "output attribute is required" );
} }


PrintWriter out = null; PrintWriter out = null;
@@ -106,7 +106,7 @@ public class AntStructure extends Task
catch( IOException ioe ) catch( IOException ioe )
{ {
throw new BuildException( "Error writing " + output.getAbsolutePath(), throw new BuildException( "Error writing " + output.getAbsolutePath(),
ioe, location );
ioe );
} }
finally finally
{ {


+ 14
- 28
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java View File

@@ -16,6 +16,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;
import org.apache.myrmidon.api.TaskException;


/** /**
* Will set the given property if the requested resource is available at * Will set the given property if the requested resource is available at
@@ -26,7 +27,9 @@ import org.apache.tools.ant.util.FileUtils;
* @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a> * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
*/ */


public class Available extends Task implements Condition
public class Available
extends Task
implements Condition
{ {
private String value = "true"; private String value = "true";
private String classname; private String classname;
@@ -77,22 +80,8 @@ public class Available extends Task implements Condition
this.resource = resource; this.resource = resource;
} }


/**
* @param type The new Type value
* @deprecated setType(String) is deprecated and is replaced with
* setType(Available.FileDir) to make Ant's Introspection mechanism do
* the work and also to encapsulate operations on the type in its own
* class.
*/
public void setType( String type )
{
log( "DEPRECATED - The setType(String) method has been deprecated."
+ " Use setType(Available.FileDir) instead." );
this.type = new FileDir();
this.type.setValue( type );
}


public void setType( FileDir type )
public void setType( FileDir type )
{ {
this.type = type; this.type = type;
} }
@@ -121,18 +110,18 @@ public class Available extends Task implements Condition
} }


public boolean eval() public boolean eval()
throws BuildException
throws TaskException
{ {
if( classname == null && file == null && resource == null ) if( classname == null && file == null && resource == null )
{ {
throw new BuildException( "At least one of (classname|file|resource) is required", location );
throw new BuildException( "At least one of (classname|file|resource) is required" );
} }


if( type != null ) if( type != null )
{ {
if( file == null ) if( file == null )
{ {
throw new BuildException( "The type attribute is only valid when specifying the file attribute." );
throw new TaskException( "The type attribute is only valid when specifying the file attribute." );
} }
} }


@@ -176,24 +165,21 @@ public class Available extends Task implements Condition
} }


public void execute() public void execute()
throws BuildException
throws TaskException
{ {
if( property == null ) if( property == null )
{ {
throw new BuildException( "property attribute is required", location );
throw new BuildException( "property attribute is required");
} }


if( eval() ) if( eval() )
{ {
String lSep = System.getProperty( "line.separator" ); String lSep = System.getProperty( "line.separator" );
if( null != project.getProperty( property ) )
if( null == project.getProperty( property ) )
{ {
log( "DEPRECATED - <available> used to overide an existing property. "
+ lSep
+ " Build writer should not reuse the same property name for "
+ lSep + "different values." );
this.project.setProperty( property, value );
} }
this.project.setProperty( property, value );
//else ignore
} }
} }


@@ -235,7 +221,7 @@ public class Available extends Task implements Condition
{ {
if( filepath == null ) if( filepath == null )
{ {
return checkFile( project.resolveFile( file ), file );
return checkFile( resolveFile( file ), file );
} }
else else
{ {


+ 3
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java View File

@@ -49,12 +49,12 @@ public class BUnzip2 extends Unpack
int b = bis.read(); int b = bis.read();
if( b != 'B' ) if( b != 'B' )
{ {
throw new BuildException( "Invalid bz2 file.", location );
throw new BuildException( "Invalid bz2 file." );
} }
b = bis.read(); b = bis.read();
if( b != 'Z' ) if( b != 'Z' )
{ {
throw new BuildException( "Invalid bz2 file.", location );
throw new BuildException( "Invalid bz2 file." );
} }
zIn = new CBZip2InputStream( bis ); zIn = new CBZip2InputStream( bis );
byte[] buffer = new byte[8 * 1024]; byte[] buffer = new byte[8 * 1024];
@@ -68,7 +68,7 @@ public class BUnzip2 extends Unpack
catch( IOException ioe ) catch( IOException ioe )
{ {
String msg = "Problem expanding bzip2 " + ioe.getMessage(); String msg = "Problem expanding bzip2 " + ioe.getMessage();
throw new BuildException( msg, ioe, location );
throw new BuildException( msg, ioe );
} }
finally finally
{ {


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BZip2.java View File

@@ -37,7 +37,7 @@ public class BZip2 extends Pack
catch( IOException ioe ) catch( IOException ioe )
{ {
String msg = "Problem creating bzip2 " + ioe.getMessage(); String msg = "Problem creating bzip2 " + ioe.getMessage();
throw new BuildException( msg, ioe, location );
throw new BuildException( msg, ioe );
} }
finally finally
{ {


+ 4
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CVSPass.java View File

@@ -14,6 +14,7 @@ import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.myrmidon.api.TaskException;


/** /**
* CVSLogin Adds an new entry to a CVS password file * CVSLogin Adds an new entry to a CVS password file
@@ -105,9 +106,9 @@ public class CVSPass extends Task
throws BuildException throws BuildException
{ {
if( cvsRoot == null ) if( cvsRoot == null )
throw new BuildException( "cvsroot is required" );
throw new TaskException( "cvsroot is required" );
if( password == null ) if( password == null )
throw new BuildException( "password is required" );
throw new TaskException( "password is required" );


log( "cvsRoot: " + cvsRoot, project.MSG_DEBUG ); log( "cvsRoot: " + cvsRoot, project.MSG_DEBUG );
log( "password: " + password, project.MSG_DEBUG ); log( "password: " + password, project.MSG_DEBUG );
@@ -147,7 +148,7 @@ public class CVSPass extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }


} }


+ 1
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CallTarget.java View File

@@ -77,8 +77,7 @@ public class CallTarget extends Task


if( subTarget == null ) if( subTarget == null )
{ {
throw new BuildException( "Attribute target is required.",
location );
throw new BuildException( "Attribute target is required." );
} }


callee.setDir( project.getBaseDir() ); callee.setDir( project.getBaseDir() );


+ 16
- 16
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java View File

@@ -25,6 +25,7 @@ import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.tools.ant.taskdefs.condition.Condition; import org.apache.tools.ant.taskdefs.condition.Condition;
import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.FileSet;
import org.apache.myrmidon.api.TaskException;


/** /**
* This task can be used to create checksums for files. It can also be used to * This task can be used to create checksums for files. It can also be used to
@@ -231,7 +232,7 @@ public class Checksum extends MatchingTask implements Condition
+ file.getAbsolutePath() + file.getAbsolutePath()
+ " to generate checksum for."; + " to generate checksum for.";
log( message ); log( message );
throw new BuildException( message, location );
throw new BuildException( message );
} }
} }
} }
@@ -328,7 +329,7 @@ public class Checksum extends MatchingTask implements Condition
} }
catch( Exception e ) catch( Exception e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
finally finally
{ {
@@ -366,19 +367,19 @@ public class Checksum extends MatchingTask implements Condition


if( file == null && filesets.size() == 0 ) if( file == null && filesets.size() == 0 )
{ {
throw new BuildException(
throw new TaskException(
"Specify at least one source - a file or a fileset." ); "Specify at least one source - a file or a fileset." );
} }


if( file != null && file.exists() && file.isDirectory() ) if( file != null && file.exists() && file.isDirectory() )
{ {
throw new BuildException(
throw new TaskException(
"Checksum cannot be generated for directories" ); "Checksum cannot be generated for directories" );
} }


if( property != null && fileext != null ) if( property != null && fileext != null )
{ {
throw new BuildException(
throw new TaskException(
"Property and FileExt cannot co-exist." ); "Property and FileExt cannot co-exist." );
} }


@@ -386,7 +387,7 @@ public class Checksum extends MatchingTask implements Condition
{ {
if( forceOverwrite ) if( forceOverwrite )
{ {
throw new BuildException(
throw new TaskException(
"ForceOverwrite cannot be used when Property is specified" ); "ForceOverwrite cannot be used when Property is specified" );
} }


@@ -394,7 +395,7 @@ public class Checksum extends MatchingTask implements Condition
{ {
if( filesets.size() > 0 ) if( filesets.size() > 0 )
{ {
throw new BuildException(
throw new TaskException(
"Multiple files cannot be used when Property is specified" ); "Multiple files cannot be used when Property is specified" );
} }
} }
@@ -402,7 +403,7 @@ public class Checksum extends MatchingTask implements Condition
{ {
if( filesets.size() > 1 ) if( filesets.size() > 1 )
{ {
throw new BuildException(
throw new TaskException(
"Multiple files cannot be used when Property is specified" ); "Multiple files cannot be used when Property is specified" );
} }
} }
@@ -415,13 +416,13 @@ public class Checksum extends MatchingTask implements Condition


if( verifyProperty != null && forceOverwrite ) if( verifyProperty != null && forceOverwrite )
{ {
throw new BuildException(
throw new TaskException(
"VerifyProperty and ForceOverwrite cannot co-exist." ); "VerifyProperty and ForceOverwrite cannot co-exist." );
} }


if( isCondition && forceOverwrite ) if( isCondition && forceOverwrite )
{ {
throw new BuildException(
throw new TaskException(
"ForceOverwrite cannot be used when conditions are being used." ); "ForceOverwrite cannot be used when conditions are being used." );
} }


@@ -431,7 +432,7 @@ public class Checksum extends MatchingTask implements Condition
} }
else if( fileext.trim().length() == 0 ) else if( fileext.trim().length() == 0 )
{ {
throw new BuildException(
throw new TaskException(
"File extension when specified must not be an empty string" ); "File extension when specified must not be an empty string" );
} }


@@ -444,11 +445,11 @@ public class Checksum extends MatchingTask implements Condition
} }
catch( NoSuchAlgorithmException noalgo ) catch( NoSuchAlgorithmException noalgo )
{ {
throw new BuildException( noalgo );
throw new TaskException( noalgo.toString(), noalgo );
} }
catch( NoSuchProviderException noprovider ) catch( NoSuchProviderException noprovider )
{ {
throw new BuildException( noprovider );
throw new TaskException( noprovider.toString(), noprovider );
} }
} }
else else
@@ -459,14 +460,13 @@ public class Checksum extends MatchingTask implements Condition
} }
catch( NoSuchAlgorithmException noalgo ) catch( NoSuchAlgorithmException noalgo )
{ {
throw new BuildException( noalgo );
throw new TaskException( noalgo.toString(), noalgo );
} }
} }


if( messageDigest == null ) if( messageDigest == null )
{ {
throw new BuildException( "Unable to create Message Digest",
location );
throw new BuildException( "Unable to create Message Digest" );
} }


addToIncludeFileMap( file ); addToIncludeFileMap( file );


+ 5
- 6
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Chmod.java View File

@@ -40,7 +40,7 @@ public class Chmod extends ExecuteOn


public void setCommand( String e ) public void setCommand( String e )
{ {
throw new BuildException( taskType + " doesn\'t support the command attribute", location );
throw new BuildException( taskType + " doesn\'t support the command attribute" );
} }


/** /**
@@ -75,7 +75,7 @@ public class Chmod extends ExecuteOn


public void setExecutable( String e ) public void setExecutable( String e )
{ {
throw new BuildException( taskType + " doesn\'t support the executable attribute", location );
throw new BuildException( taskType + " doesn\'t support the executable attribute" );
} }


public void setFile( File src ) public void setFile( File src )
@@ -106,7 +106,7 @@ public class Chmod extends ExecuteOn


public void setSkipEmptyFilesets( boolean skip ) public void setSkipEmptyFilesets( boolean skip )
{ {
throw new BuildException( taskType + " doesn\'t support the skipemptyfileset attribute", location );
throw new BuildException( taskType + " doesn\'t support the skipemptyfileset attribute" );
} }


/** /**
@@ -161,7 +161,7 @@ public class Chmod extends ExecuteOn
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( "Execute failed: " + e, e, location );
throw new BuildException( "Execute failed: " + e, e );
} }
finally finally
{ {
@@ -180,8 +180,7 @@ public class Chmod extends ExecuteOn
{ {
if( !havePerm ) if( !havePerm )
{ {
throw new BuildException( "Required attribute perm not set in chmod",
location );
throw new BuildException( "Required attribute perm not set in chmod" );
} }


if( defaultSetDefined && defaultSet.getDir( project ) != null ) if( defaultSetDefined && defaultSet.getDir( project ) != null )


+ 4
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java View File

@@ -9,6 +9,7 @@ package org.apache.tools.ant.taskdefs;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.condition.Condition; import org.apache.tools.ant.taskdefs.condition.Condition;
import org.apache.tools.ant.taskdefs.condition.ConditionBase; import org.apache.tools.ant.taskdefs.condition.ConditionBase;
import org.apache.myrmidon.api.TaskException;


/** /**
* &lt;condition&gt; task as a generalization of &lt;available&gt; and * &lt;condition&gt; task as a generalization of &lt;available&gt; and
@@ -57,15 +58,15 @@ public class ConditionTask extends ConditionBase
* @since 1.1 * @since 1.1
*/ */
public void execute() public void execute()
throws BuildException
throws TaskException
{ {
if( countConditions() > 1 ) if( countConditions() > 1 )
{ {
throw new BuildException( "You must not nest more than one condition into <condition>" );
throw new TaskException( "You must not nest more than one condition into <condition>" );
} }
if( countConditions() < 1 ) if( countConditions() < 1 )
{ {
throw new BuildException( "You must nest a condition into <condition>" );
throw new TaskException( "You must nest a condition into <condition>" );
} }
Condition c = ( Condition )getConditions().nextElement(); Condition c = ( Condition )getConditions().nextElement();
if( c.eval() ) if( c.eval() )


+ 40
- 54
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Copy.java View File

@@ -6,11 +6,13 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;

import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
@@ -120,19 +122,6 @@ public class Copy extends Task
this.forceOverwrite = overwrite; this.forceOverwrite = overwrite;
} }


/**
* Give the copied files the same last modified time as the original files.
*
* @param preserve The new PreserveLastModified value
* @deprecated setPreserveLastModified(String) has been deprecated and
* replaced with setPreserveLastModified(boolean) to consistently let
* the Introspection mechanism work.
*/
public void setPreserveLastModified( String preserve )
{
setPreserveLastModified( Project.toBoolean( preserve ) );
}

/** /**
* Give the copied files the same last modified time as the original files. * Give the copied files the same last modified time as the original files.
* *
@@ -213,8 +202,7 @@ public class Copy extends Task
{ {
if( mapperElement != null ) if( mapperElement != null )
{ {
throw new BuildException( "Cannot define more than one mapper",
location );
throw new BuildException( "Cannot define more than one mapper" );
} }
mapperElement = new Mapper( project ); mapperElement = new Mapper( project );
return mapperElement; return mapperElement;
@@ -226,7 +214,7 @@ public class Copy extends Task
* @exception BuildException Description of Exception * @exception BuildException Description of Exception
*/ */
public void execute() public void execute()
throws BuildException
throws TaskException
{ {
// make sure we don't have an illegal set of options // make sure we don't have an illegal set of options
validateAttributes(); validateAttributes();
@@ -249,22 +237,22 @@ public class Copy extends Task
else else
{ {
log( file + " omitted as " + destFile + " is up to date.", log( file + " omitted as " + destFile + " is up to date.",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
} }
} }
else else
{ {
String message = "Could not find file " String message = "Could not find file "
+ file.getAbsolutePath() + " to copy.";
+ file.getAbsolutePath() + " to copy.";
log( message ); log( message );
throw new BuildException( message );
throw new TaskException( message );
} }
} }


// deal with the filesets // deal with the filesets
for( int i = 0; i < filesets.size(); i++ ) for( int i = 0; i < filesets.size(); i++ )
{ {
FileSet fs = ( FileSet )filesets.elementAt( i );
FileSet fs = (FileSet)filesets.elementAt( i );
DirectoryScanner ds = fs.getDirectoryScanner( project ); DirectoryScanner ds = fs.getDirectoryScanner( project );
File fromDir = fs.getDir( project ); File fromDir = fs.getDir( project );


@@ -272,7 +260,7 @@ public class Copy extends Task
String[] srcDirs = ds.getIncludedDirectories(); String[] srcDirs = ds.getIncludedDirectories();
boolean isEverythingIncluded = ds.isEverythingIncluded(); boolean isEverythingIncluded = ds.isEverythingIncluded();
if( isEverythingIncluded if( isEverythingIncluded
&& !flatten && mapperElement == null )
&& !flatten && mapperElement == null )
{ {
completeDirMap.put( fromDir, destDir ); completeDirMap.put( fromDir, destDir );
} }
@@ -315,12 +303,12 @@ public class Copy extends Task
Vector v = new Vector(); Vector v = new Vector();
for( int i = 0; i < names.length; i++ ) for( int i = 0; i < names.length; i++ )
{ {
if( mapper.mapFileName( names[i] ) != null )
if( mapper.mapFileName( names[ i ] ) != null )
{ {
v.addElement( names[i] );
v.addElement( names[ i ] );
} }
} }
toCopy = new String[v.size()];
toCopy = new String[ v.size() ];
v.copyInto( toCopy ); v.copyInto( toCopy );
} }
else else
@@ -331,8 +319,8 @@ public class Copy extends Task


for( int i = 0; i < toCopy.length; i++ ) for( int i = 0; i < toCopy.length; i++ )
{ {
File src = new File( fromDir, toCopy[i] );
File dest = new File( toDir, mapper.mapFileName( toCopy[i] )[0] );
File src = new File( fromDir, toCopy[ i ] );
File dest = new File( toDir, mapper.mapFileName( toCopy[ i ] )[ 0 ] );
map.put( src.getAbsolutePath(), dest.getAbsolutePath() ); map.put( src.getAbsolutePath(), dest.getAbsolutePath() );
} }
} }
@@ -346,14 +334,14 @@ public class Copy extends Task
if( fileCopyMap.size() > 0 ) if( fileCopyMap.size() > 0 )
{ {
log( "Copying " + fileCopyMap.size() + log( "Copying " + fileCopyMap.size() +
" file" + ( fileCopyMap.size() == 1 ? "" : "s" ) +
" to " + destDir.getAbsolutePath() );
" file" + ( fileCopyMap.size() == 1 ? "" : "s" ) +
" to " + destDir.getAbsolutePath() );


Enumeration e = fileCopyMap.keys(); Enumeration e = fileCopyMap.keys();
while( e.hasMoreElements() ) while( e.hasMoreElements() )
{ {
String fromFile = ( String )e.nextElement();
String toFile = ( String )fileCopyMap.get( fromFile );
String fromFile = (String)e.nextElement();
String toFile = (String)fileCopyMap.get( fromFile );


if( fromFile.equals( toFile ) ) if( fromFile.equals( toFile ) )
{ {
@@ -370,18 +358,18 @@ public class Copy extends Task
{ {
executionFilters.addFilterSet( project.getGlobalFilterSet() ); executionFilters.addFilterSet( project.getGlobalFilterSet() );
} }
for( Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements(); )
for( Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements(); )
{ {
executionFilters.addFilterSet( ( FilterSet )filterEnum.nextElement() );
executionFilters.addFilterSet( (FilterSet)filterEnum.nextElement() );
} }
fileUtils.copyFile( fromFile, toFile, executionFilters, fileUtils.copyFile( fromFile, toFile, executionFilters,
forceOverwrite, preserveLastModified );
forceOverwrite, preserveLastModified );
} }
catch( IOException ioe ) catch( IOException ioe )
{ {
String msg = "Failed to copy " + fromFile + " to " + toFile String msg = "Failed to copy " + fromFile + " to " + toFile
+ " due to " + ioe.getMessage();
throw new BuildException( msg, ioe, location );
+ " due to " + ioe.getMessage();
throw new BuildException( msg, ioe );
} }
} }
} }
@@ -392,7 +380,7 @@ public class Copy extends Task
int count = 0; int count = 0;
while( e.hasMoreElements() ) while( e.hasMoreElements() )
{ {
File d = new File( ( String )e.nextElement() );
File d = new File( (String)e.nextElement() );
if( !d.exists() ) if( !d.exists() )
{ {
if( !d.mkdirs() ) if( !d.mkdirs() )
@@ -409,9 +397,9 @@ public class Copy extends Task
if( count > 0 ) if( count > 0 )
{ {
log( "Copied " + count + log( "Copied " + count +
" empty director" +
( count == 1 ? "y" : "ies" ) +
" to " + destDir.getAbsolutePath() );
" empty director" +
( count == 1 ? "y" : "ies" ) +
" to " + destDir.getAbsolutePath() );
} }
} }
} }
@@ -449,9 +437,9 @@ public class Copy extends Task
} }
} }


//************************************************************************
// protected and private methods
//************************************************************************
//************************************************************************
// protected and private methods
//************************************************************************


/** /**
* Ensure we have a consistent and legal set of attributes, and set any * Ensure we have a consistent and legal set of attributes, and set any
@@ -460,38 +448,38 @@ public class Copy extends Task
* @exception BuildException Description of Exception * @exception BuildException Description of Exception
*/ */
protected void validateAttributes() protected void validateAttributes()
throws BuildException
throws TaskException
{ {
if( file == null && filesets.size() == 0 ) if( file == null && filesets.size() == 0 )
{ {
throw new BuildException( "Specify at least one source - a file or a fileset." );
throw new TaskException( "Specify at least one source - a file or a fileset." );
} }


if( destFile != null && destDir != null ) if( destFile != null && destDir != null )
{ {
throw new BuildException( "Only one of tofile and todir may be set." );
throw new TaskException( "Only one of tofile and todir may be set." );
} }


if( destFile == null && destDir == null ) if( destFile == null && destDir == null )
{ {
throw new BuildException( "One of tofile or todir must be set." );
throw new TaskException( "One of tofile or todir must be set." );
} }


if( file != null && file.exists() && file.isDirectory() ) if( file != null && file.exists() && file.isDirectory() )
{ {
throw new BuildException( "Use a fileset to copy directories." );
throw new TaskException( "Use a fileset to copy directories." );
} }


if( destFile != null && filesets.size() > 0 ) if( destFile != null && filesets.size() > 0 )
{ {
if( filesets.size() > 1 ) if( filesets.size() > 1 )
{ {
throw new BuildException(
throw new TaskException(
"Cannot concatenate multiple files into a single file." ); "Cannot concatenate multiple files into a single file." );
} }
else else
{ {
FileSet fs = ( FileSet )filesets.elementAt( 0 );
FileSet fs = (FileSet)filesets.elementAt( 0 );
DirectoryScanner ds = fs.getDirectoryScanner( project ); DirectoryScanner ds = fs.getDirectoryScanner( project );
String[] srcFiles = ds.getIncludedFiles(); String[] srcFiles = ds.getIncludedFiles();


@@ -499,18 +487,18 @@ public class Copy extends Task
{ {
if( file == null ) if( file == null )
{ {
file = new File( srcFiles[0] );
file = new File( srcFiles[ 0 ] );
filesets.removeElementAt( 0 ); filesets.removeElementAt( 0 );
} }
else else
{ {
throw new BuildException(
throw new TaskException(
"Cannot concatenate multiple files into a single file." ); "Cannot concatenate multiple files into a single file." );
} }
} }
else else
{ {
throw new BuildException(
throw new TaskException(
"Cannot perform operation from directory to file." ); "Cannot perform operation from directory to file." );
} }
} }
@@ -520,7 +508,5 @@ public class Copy extends Task
{ {
destDir = new File( destFile.getParent() );// be 1.1 friendly destDir = new File( destFile.getParent() );// be 1.1 friendly
} }

} }

} }

+ 13
- 11
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Cvs.java View File

@@ -6,12 +6,14 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;

import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
@@ -120,7 +122,6 @@ public class Cvs extends Task
this.cvsRsh = rsh; this.cvsRsh = rsh;
} }



public void setDate( String p ) public void setDate( String p )
{ {
if( p != null && p.trim().length() > 0 ) if( p != null && p.trim().length() > 0 )
@@ -185,9 +186,8 @@ public class Cvs extends Task
} }
} }



public void execute() public void execute()
throws BuildException
throws TaskException
{ {


// XXX: we should use JCVS (www.ice.com/JCVS) instead of command line // XXX: we should use JCVS (www.ice.com/JCVS) instead of command line
@@ -252,7 +252,7 @@ public class Cvs extends Task
if( error == null && output == null ) if( error == null && output == null )
{ {
streamhandler = new LogStreamHandler( this, Project.MSG_INFO, streamhandler = new LogStreamHandler( this, Project.MSG_INFO,
Project.MSG_WARN );
Project.MSG_WARN );
} }
else else
{ {
@@ -264,7 +264,7 @@ public class Cvs extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new TaskException( e.toString(), e );
} }
} }
else else
@@ -279,7 +279,7 @@ public class Cvs extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new TaskException( e.toString(), e );
} }
} }
else else
@@ -290,7 +290,7 @@ public class Cvs extends Task
} }


Execute exe = new Execute( streamhandler, Execute exe = new Execute( streamhandler,
null );
null );


exe.setAntRun( project ); exe.setAntRun( project );
if( dest == null ) if( dest == null )
@@ -306,11 +306,11 @@ public class Cvs extends Task
* Throw an exception if cvs exited with error. (Iulian) * Throw an exception if cvs exited with error. (Iulian)
*/ */
if( failOnError && retCode != 0 ) if( failOnError && retCode != 0 )
throw new BuildException( "cvs exited with error code " + retCode );
throw new TaskException( "cvs exited with error code " + retCode );
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new TaskException( e.toString(), e );
} }
finally finally
{ {
@@ -321,7 +321,8 @@ public class Cvs extends Task
outputstream.close(); outputstream.close();
} }
catch( IOException e ) catch( IOException e )
{}
{
}
} }
if( error != null ) if( error != null )
{ {
@@ -330,7 +331,8 @@ public class Cvs extends Task
errorstream.close(); errorstream.close();
} }
catch( IOException e ) catch( IOException e )
{}
{
}
} }
} }
} }


+ 5
- 11
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Definer.java View File

@@ -72,12 +72,6 @@ public abstract class Definer extends Task
this.resource = res; this.resource = res;
} }


public void setReverseLoader( boolean reverseLoader )
{
this.reverseLoader = reverseLoader;
log( "The reverseloader attribute is DEPRECATED. It will be removed", Project.MSG_WARN );
}

public String getClassname() public String getClassname()
{ {
return value; return value;
@@ -120,13 +114,13 @@ public abstract class Definer extends Task
{ {
String msg = "You must not specify name or value " String msg = "You must not specify name or value "
+ "together with file or resource."; + "together with file or resource.";
throw new BuildException( msg, location );
throw new BuildException( msg );
} }


if( file != null && resource != null ) if( file != null && resource != null )
{ {
String msg = "You must not specify both, file and resource."; String msg = "You must not specify both, file and resource.";
throw new BuildException( msg, location );
throw new BuildException( msg );
} }


Properties props = new Properties(); Properties props = new Properties();
@@ -169,7 +163,7 @@ public abstract class Definer extends Task
} }
catch( IOException ex ) catch( IOException ex )
{ {
throw new BuildException( ex);
throw new BuildException( "Error", ex);
} }
} }
} }
@@ -189,13 +183,13 @@ public abstract class Definer extends Task
{ {
String msg = getTaskName() + " class " + value + String msg = getTaskName() + " class " + value +
" cannot be found"; " cannot be found";
throw new BuildException( msg, cnfe, location );
throw new BuildException( msg, cnfe );
} }
catch( NoClassDefFoundError ncdfe ) catch( NoClassDefFoundError ncdfe )
{ {
String msg = getTaskName() + " class " + value + String msg = getTaskName() + " class " + value +
" cannot be found"; " cannot be found";
throw new BuildException( msg, ncdfe, location );
throw new BuildException( msg, ncdfe );
} }
} }




+ 1
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Delete.java View File

@@ -242,8 +242,7 @@ public class Delete extends MatchingTask


if( quiet && failonerror ) if( quiet && failonerror )
{ {
throw new BuildException( "quiet and failonerror cannot both be set to true",
location );
throw new BuildException( "quiet and failonerror cannot both be set to true" );
} }


// delete the single file // delete the single file


+ 1
- 8
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ear.java View File

@@ -47,13 +47,6 @@ public class Ear extends Jar
super.addFileset( fs ); super.addFileset( fs );
} }


public void setEarfile( File earFile )
{
log( "DEPRECATED - The earfile attribute is deprecated. Use file attribute instead." );
setFile( earFile );
}


public void addArchives( ZipFileSet fs ) public void addArchives( ZipFileSet fs )
{ {
// We just set the prefix for this fileset, and pass it up. // We just set the prefix for this fileset, and pass it up.
@@ -80,7 +73,7 @@ public class Ear extends Jar
// If no webxml file is specified, it's an error. // If no webxml file is specified, it's an error.
if( deploymentDescriptor == null && !isInUpdateMode() ) if( deploymentDescriptor == null && !isInUpdateMode() )
{ {
throw new BuildException( "appxml attribute is required", location );
throw new BuildException( "appxml attribute is required" );
} }


super.initZipOutputStream( zOut ); super.initZipOutputStream( zOut );


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Echo.java View File

@@ -132,7 +132,7 @@ public class Echo extends Task
} }
catch( IOException ioe ) catch( IOException ioe )
{ {
throw new BuildException( ioe);
throw new BuildException( "Error", ioe);
} }
finally finally
{ {


+ 5
- 18
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecTask.java View File

@@ -52,19 +52,6 @@ public class ExecTask extends Task
private String outputprop; private String outputprop;
private String resultProperty; private String resultProperty;


/**
* The full commandline to execute, executable + arguments.
*
* @param cmdl The new Command value
*/
public void setCommand( Commandline cmdl )
{
log( "The command attribute is deprecated. " +
"Please use the executable attribute and nested arg elements.",
Project.MSG_WARN );
this.cmdl = cmdl;
}

/** /**
* The working directory of the process * The working directory of the process
* *
@@ -256,7 +243,7 @@ public class ExecTask extends Task
{ {
if( failOnError ) if( failOnError )
{ {
throw new BuildException( taskType + " returned: " + err, location );
throw new BuildException( taskType + " returned: " + err );
} }
else else
{ {
@@ -291,7 +278,7 @@ public class ExecTask extends Task
{ {
if( cmdl.getExecutable() == null ) if( cmdl.getExecutable() == null )
{ {
throw new BuildException( "no executable specified", location );
throw new BuildException( "no executable specified" );
} }
if( dir != null && !dir.exists() ) if( dir != null && !dir.exists() )
{ {
@@ -322,11 +309,11 @@ public class ExecTask extends Task
} }
catch( FileNotFoundException fne ) catch( FileNotFoundException fne )
{ {
throw new BuildException( "Cannot write to " + out, fne, location );
throw new BuildException( "Cannot write to " + out, fne );
} }
catch( IOException ioe ) catch( IOException ioe )
{ {
throw new BuildException( "Cannot write to " + out, ioe, location );
throw new BuildException( "Cannot write to " + out, ioe );
} }
} }
else if( outputprop != null ) else if( outputprop != null )
@@ -439,7 +426,7 @@ public class ExecTask extends Task
{ {
if( failIfExecFails ) if( failIfExecFails )
{ {
throw new BuildException( "Execute failed: " + e.toString(), e, location );
throw new BuildException( "Execute failed: " + e.toString(), e );
} }
else else
{ {


+ 4
- 4
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -259,12 +259,12 @@ public class Execute
int retval = exe.execute(); int retval = exe.execute();
if( retval != 0 ) if( retval != 0 )
{ {
throw new BuildException( cmdline[ 0 ] + " failed with return code " + retval, task.getLocation() );
throw new BuildException( cmdline[ 0 ] + " failed with return code " + retval );
} }
} }
catch( java.io.IOException exc ) catch( java.io.IOException exc )
{ {
throw new BuildException( "Could not launch " + cmdline[ 0 ] + ": " + exc, task.getLocation() );
throw new BuildException( "Could not launch " + cmdline[ 0 ] + ": " + exc );
} }
} }


@@ -806,7 +806,7 @@ public class Execute
{ {
throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" );
} }
String antRun = project.resolveFile( antHome + File.separator + _script ).toString();
String antRun = resolveFile( antHome + File.separator + _script ).toString();


// Build the command // Build the command
File commandDir = workingDir; File commandDir = workingDir;
@@ -871,7 +871,7 @@ public class Execute
{ {
throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" );
} }
String antRun = project.resolveFile( antHome + File.separator + _script ).toString();
String antRun = resolveFile( antHome + File.separator + _script ).toString();


// Build the command // Build the command
File commandDir = workingDir; File commandDir = workingDir;


+ 2
- 11
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java View File

@@ -37,15 +37,6 @@ public class ExecuteJava
this.javaCommand = javaCommand; this.javaCommand = javaCommand;
} }


/**
* All output (System.out as well as System.err) will be written to this
* Stream.
*
* @param out The new Output value
* @deprecated manage output at the task level
*/
public void setOutput( PrintStream out ) { }

public void setSystemProperties( CommandlineJava.SysProperties s ) public void setSystemProperties( CommandlineJava.SysProperties s )
{ {
sysProperties = s; sysProperties = s;
@@ -95,7 +86,7 @@ public class ExecuteJava
Throwable t = e.getTargetException(); Throwable t = e.getTargetException();
if( !( t instanceof SecurityException ) ) if( !( t instanceof SecurityException ) )
{ {
throw new BuildException( t );
throw new BuildException( "Error", t );
} }
else else
{ {
@@ -104,7 +95,7 @@ public class ExecuteJava
} }
catch( Exception e ) catch( Exception e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
finally finally
{ {


+ 7
- 16
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java View File

@@ -117,8 +117,7 @@ public class ExecuteOn extends ExecTask
{ {
if( mapperElement != null ) if( mapperElement != null )
{ {
throw new BuildException( "Cannot define more than one mapper",
location );
throw new BuildException( "Cannot define more than one mapper" );
} }
mapperElement = new Mapper( project ); mapperElement = new Mapper( project );
return mapperElement; return mapperElement;
@@ -134,8 +133,7 @@ public class ExecuteOn extends ExecTask
{ {
if( srcFilePos != null ) if( srcFilePos != null )
{ {
throw new BuildException( taskType + " doesn\'t support multiple srcfile elements.",
location );
throw new BuildException( taskType + " doesn\'t support multiple srcfile elements." );
} }
srcFilePos = cmdl.createMarker(); srcFilePos = cmdl.createMarker();
return srcFilePos; return srcFilePos;
@@ -151,8 +149,7 @@ public class ExecuteOn extends ExecTask
{ {
if( targetFilePos != null ) if( targetFilePos != null )
{ {
throw new BuildException( taskType + " doesn\'t support multiple targetfile elements.",
location );
throw new BuildException( taskType + " doesn\'t support multiple targetfile elements." );
} }
targetFilePos = cmdl.createMarker(); targetFilePos = cmdl.createMarker();
srcIsFirst = ( srcFilePos != null ); srcIsFirst = ( srcFilePos != null );
@@ -345,15 +342,10 @@ public class ExecuteOn extends ExecTask


protected void checkConfiguration() protected void checkConfiguration()
{ {
if( "execon".equals( taskName ) )
{
log( "!! execon is deprecated. Use apply instead. !!" );
}

super.checkConfiguration(); super.checkConfiguration();
if( filesets.size() == 0 ) if( filesets.size() == 0 )
{ {
throw new BuildException( "no filesets specified", location );
throw new BuildException( "no filesets specified" );
} }


if( targetFilePos != null || mapperElement != null if( targetFilePos != null || mapperElement != null
@@ -362,12 +354,11 @@ public class ExecuteOn extends ExecTask


if( mapperElement == null ) if( mapperElement == null )
{ {
throw new BuildException( "no mapper specified", location );
throw new BuildException( "no mapper specified" );
} }
if( mapperElement == null ) if( mapperElement == null )
{ {
throw new BuildException( "no dest attribute specified",
location );
throw new BuildException( "no dest attribute specified" );
} }
mapper = mapperElement.getImplementation(); mapper = mapperElement.getImplementation();
} }
@@ -448,7 +439,7 @@ public class ExecuteOn extends ExecTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( "Execute failed: " + e, e, location );
throw new BuildException( "Execute failed: " + e, e );
} }
finally finally
{ {


+ 2
- 7
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -98,11 +98,6 @@ public class Expand extends MatchingTask
public void execute() public void execute()
throws BuildException throws BuildException
{ {
if( "expand".equals( taskType ) )
{
log( "!! expand is deprecated. Use unzip instead. !!" );
}

if( source == null && filesets.size() == 0 ) if( source == null && filesets.size() == 0 )
{ {
throw new BuildException( "src attribute and/or filesets must be specified" ); throw new BuildException( "src attribute and/or filesets must be specified" );
@@ -116,7 +111,7 @@ public class Expand extends MatchingTask


if( dest.exists() && !dest.isDirectory() ) if( dest.exists() && !dest.isDirectory() )
{ {
throw new BuildException( "Dest must be a directory.", location );
throw new BuildException( "Dest must be a directory." );
} }


FileUtils fileUtils = FileUtils.newFileUtils(); FileUtils fileUtils = FileUtils.newFileUtils();
@@ -126,7 +121,7 @@ public class Expand extends MatchingTask
if( source.isDirectory() ) if( source.isDirectory() )
{ {
throw new BuildException( "Src must not be a directory." + throw new BuildException( "Src must not be a directory." +
" Use nested filesets instead.", location );
" Use nested filesets instead." );
} }
else else
{ {


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Filter.java View File

@@ -51,7 +51,7 @@ public class Filter extends Task


if( !isFiltersFromFile && !isSingleFilter ) if( !isFiltersFromFile && !isSingleFilter )
{ {
throw new BuildException( "both token and value parameters, or only a filtersFile parameter is required", location );
throw new BuildException( "both token and value parameters, or only a filtersFile parameter is required" );
} }


if( isSingleFilter ) if( isSingleFilter )


+ 13
- 43
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java View File

@@ -147,35 +147,6 @@ public class FixCRLF extends MatchingTask
} }
} }


/**
* Specify how carriage return (CR) characters are to be handled
*
* @param attr The new Cr value
* @deprecated use {@link #setEol setEol} instead.
*/
public void setCr( AddAsisRemove attr )
{
log( "DEPRECATED: The cr attribute has been deprecated,",
Project.MSG_WARN );
log( "Please us the eol attribute instead", Project.MSG_WARN );
String option = attr.getValue();
CrLf c = new CrLf();
if( option.equals( "remove" ) )
{
c.setValue( "lf" );
}
else if( option.equals( "asis" ) )
{
c.setValue( "asis" );
}
else
{
// must be "add"
c.setValue( "crlf" );
}
setEol( c );
}

/** /**
* Set the destination where the fixed files should be placed. Default is to * Set the destination where the fixed files should be placed. Default is to
* replace the original file. * replace the original file.
@@ -306,8 +277,7 @@ public class FixCRLF extends MatchingTask
{ {
if( tlength < 2 || tlength > 80 ) if( tlength < 2 || tlength > 80 )
{ {
throw new BuildException( "tablength must be between 2 and 80",
location );
throw new BuildException( "tablength must be between 2 and 80" );
} }
tablength = tlength; tablength = tlength;
StringBuffer sp = new StringBuffer(); StringBuffer sp = new StringBuffer();
@@ -522,7 +492,7 @@ public class FixCRLF extends MatchingTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
}// end of try-catch }// end of try-catch
} }
else else
@@ -581,7 +551,7 @@ public class FixCRLF extends MatchingTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
}// end of try-catch }// end of try-catch


}// end of else tabs == ADD }// end of else tabs == ADD
@@ -617,7 +587,7 @@ public class FixCRLF extends MatchingTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }


while( lines.hasMoreElements() ) while( lines.hasMoreElements() )
@@ -631,7 +601,7 @@ public class FixCRLF extends MatchingTask
} }
catch( NoSuchElementException e ) catch( NoSuchElementException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }


String lineString = line.getLineString(); String lineString = line.getLineString();
@@ -649,7 +619,7 @@ public class FixCRLF extends MatchingTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
}// end of try-catch }// end of try-catch


} }
@@ -721,7 +691,7 @@ public class FixCRLF extends MatchingTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }


lines.setState( LOOKING ); lines.setState( LOOKING );
@@ -744,7 +714,7 @@ public class FixCRLF extends MatchingTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
}// end of try-catch }// end of try-catch


}// end of while (lines.hasNext()) }// end of while (lines.hasNext())
@@ -763,7 +733,7 @@ public class FixCRLF extends MatchingTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
finally finally
{ {
@@ -773,7 +743,7 @@ public class FixCRLF extends MatchingTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }


@@ -841,7 +811,7 @@ public class FixCRLF extends MatchingTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
finally finally
{ {
@@ -914,7 +884,7 @@ public class FixCRLF extends MatchingTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }


@@ -1043,7 +1013,7 @@ public class FixCRLF extends MatchingTask
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GUnzip.java View File

@@ -56,7 +56,7 @@ public class GUnzip extends Unpack
catch( IOException ioe ) catch( IOException ioe )
{ {
String msg = "Problem expanding gzip " + ioe.getMessage(); String msg = "Problem expanding gzip " + ioe.getMessage();
throw new BuildException( msg, ioe, location );
throw new BuildException( msg, ioe );
} }
finally finally
{ {


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GZip.java View File

@@ -34,7 +34,7 @@ public class GZip extends Pack
catch( IOException ioe ) catch( IOException ioe )
{ {
String msg = "Problem creating gzip " + ioe.getMessage(); String msg = "Problem creating gzip " + ioe.getMessage();
throw new BuildException( msg, ioe, location );
throw new BuildException( msg, ioe );
} }
finally finally
{ {


+ 6
- 10
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Get.java View File

@@ -132,29 +132,26 @@ public class Get extends Task
{ {
if( source == null ) if( source == null )
{ {
throw new BuildException( "src attribute is required", location );
throw new BuildException( "src attribute is required" );
} }


if( dest == null ) if( dest == null )
{ {
throw new BuildException( "dest attribute is required", location );
throw new BuildException( "dest attribute is required" );
} }


if( dest.exists() && dest.isDirectory() ) if( dest.exists() && dest.isDirectory() )
{ {
throw new BuildException( "The specified destination is a directory",
location );
throw new BuildException( "The specified destination is a directory" );
} }


if( dest.exists() && !dest.canWrite() ) if( dest.exists() && !dest.canWrite() )
{ {
throw new BuildException( "Can't write to " + dest.getAbsolutePath(),
location );
throw new BuildException( "Can't write to " + dest.getAbsolutePath() );
} }


try try
{ {

log( "Getting: " + source ); log( "Getting: " + source );


//set the timestamp to the file date. //set the timestamp to the file date.
@@ -249,8 +246,7 @@ public class Get extends Task
log( "Can't get " + source + " to " + dest ); log( "Can't get " + source + " to " + dest );
if( ignoreErrors ) if( ignoreErrors )
return; return;
throw new BuildException( "Can't get " + source + " to " + dest,
location );
throw new BuildException( "Can't get " + source + " to " + dest );
} }


byte[] buffer = new byte[100 * 1024]; byte[] buffer = new byte[100 * 1024];
@@ -287,7 +283,7 @@ public class Get extends Task
log( "Error getting " + source + " to " + dest ); log( "Error getting " + source + " to " + dest );
if( ignoreErrors ) if( ignoreErrors )
return; return;
throw new BuildException( ioe);
throw new BuildException( "Error", ioe);
} }
} }




+ 4
- 15
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Jar.java View File

@@ -63,22 +63,11 @@ public class Jar extends Zip
index = flag; index = flag;
} }


/**
* @param jarFile The new Jarfile value
* @deprecated use setFile(File) instead.
*/
public void setJarfile( File jarFile )
{
log( "DEPRECATED - The jarfile attribute is deprecated. Use file attribute instead." );
setFile( jarFile );
}

public void setManifest( File manifestFile ) public void setManifest( File manifestFile )
{ {
if( !manifestFile.exists() ) if( !manifestFile.exists() )
{ {
throw new BuildException( "Manifest file: " + manifestFile + " does not exist.",
getLocation() );
throw new BuildException( "Manifest file: " + manifestFile + " does not exist." );
} }


this.manifestFile = manifestFile; this.manifestFile = manifestFile;
@@ -97,7 +86,7 @@ public class Jar extends Zip
catch( ManifestException e ) catch( ManifestException e )
{ {
log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR );
throw new BuildException( "Invalid Manifest: " + manifestFile, e, getLocation() );
throw new BuildException( "Invalid Manifest: " + manifestFile, e );
} }
catch( IOException e ) catch( IOException e )
{ {
@@ -262,7 +251,7 @@ public class Jar extends Zip
catch( ManifestException e ) catch( ManifestException e )
{ {
log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR );
throw new BuildException( "Invalid Manifest", e, getLocation() );
throw new BuildException( "Invalid Manifest", e );
} }
} }


@@ -391,7 +380,7 @@ public class Jar extends Zip
catch( ManifestException e ) catch( ManifestException e )
{ {
log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR );
throw new BuildException( "Invalid Manifest", e, getLocation() );
throw new BuildException( "Invalid Manifest", e );
} }
} }
} }

+ 14
- 47
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java View File

@@ -6,13 +6,13 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;

import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.Vector; import java.util.Vector;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ExitException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;
@@ -39,19 +39,6 @@ public class Java extends Task
private boolean failOnError = false; private boolean failOnError = false;
private File out; private File out;


/**
* Set the command line arguments for the class.
*
* @param s The new Args value
*/
public void setArgs( String s )
{
log( "The args attribute is deprecated. " +
"Please use nested arg elements.",
Project.MSG_WARN );
cmdl.createArgument().setLine( s );
}

/** /**
* Set the class name. * Set the class name.
* *
@@ -149,19 +136,6 @@ public class Java extends Task
cmdl.setVm( s ); cmdl.setVm( s );
} }


/**
* Set the command line arguments for the JVM.
*
* @param s The new Jvmargs value
*/
public void setJvmargs( String s )
{
log( "The jvmargs attribute is deprecated. " +
"Please use nested jvmarg elements.",
Project.MSG_WARN );
cmdl.createVmArgument().setLine( s );
}

/** /**
* -mx or -Xmx depending on VM version * -mx or -Xmx depending on VM version
* *
@@ -243,7 +217,7 @@ public class Java extends Task
{ {
if( failOnError ) if( failOnError )
{ {
throw new BuildException( "Java returned: " + err, location );
throw new BuildException( "Java returned: " + err );
} }
else else
{ {
@@ -290,16 +264,9 @@ public class Java extends Task
} }


log( "Running in same VM " + cmdl.getJavaCommand().toString(), log( "Running in same VM " + cmdl.getJavaCommand().toString(),
Project.MSG_VERBOSE );
try
{
run( cmdl );
return 0;
}
catch( ExitException ex )
{
return ex.getStatus();
}
Project.MSG_VERBOSE );
run( cmdl );
return 0;
} }
} }


@@ -342,7 +309,7 @@ public class Java extends Task
cmdj.setClassname( classname ); cmdj.setClassname( classname );
for( int i = 0; i < args.size(); i++ ) for( int i = 0; i < args.size(); i++ )
{ {
cmdj.createArgument().setValue( ( String )args.elementAt( i ) );
cmdj.createArgument().setValue( (String)args.elementAt( i ) );
} }
run( cmdj ); run( cmdj );
} }
@@ -370,7 +337,7 @@ public class Java extends Task
} }
catch( IOException io ) catch( IOException io )
{ {
throw new BuildException( io );
throw new BuildException( "Error", io );
} }
finally finally
{ {
@@ -403,8 +370,8 @@ public class Java extends Task
if( out == null ) if( out == null )
{ {
exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO, exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO,
Project.MSG_WARN ),
null );
Project.MSG_WARN ),
null );
} }
else else
{ {
@@ -420,8 +387,7 @@ public class Java extends Task
} }
else if( !dir.exists() || !dir.isDirectory() ) else if( !dir.exists() || !dir.isDirectory() )
{ {
throw new BuildException( dir.getAbsolutePath() + " is not a valid directory",
location );
throw new BuildException( dir.getAbsolutePath() + " is not a valid directory");
} }


exe.setWorkingDirectory( dir ); exe.setWorkingDirectory( dir );
@@ -433,12 +399,12 @@ public class Java extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }
catch( IOException io ) catch( IOException io )
{ {
throw new BuildException( io );
throw new BuildException( "Error", io );
} }
finally finally
{ {
@@ -449,7 +415,8 @@ public class Java extends Task
fos.close(); fos.close();
} }
catch( IOException io ) catch( IOException io )
{}
{
}
} }
} }
} }


+ 29
- 29
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -6,15 +6,16 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;

import java.io.File; import java.io.File;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Vector; import java.util.Vector;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter; import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter;
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory; import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.Reference;
@@ -57,9 +58,8 @@ import org.apache.tools.ant.util.SourceFileScanner;


public class Javac extends MatchingTask public class Javac extends MatchingTask
{ {

private final static String FAIL_MSG private final static String FAIL_MSG
= "Compile failed, messages should have been provided.";
= "Compile failed, messages should have been provided.";
private boolean debug = false; private boolean debug = false;
private boolean optimize = false; private boolean optimize = false;
private boolean deprecation = false; private boolean deprecation = false;
@@ -73,7 +73,7 @@ public class Javac extends MatchingTask
private Vector implementationSpecificArgs = new Vector(); private Vector implementationSpecificArgs = new Vector();


protected boolean failOnError = true; protected boolean failOnError = true;
protected File[] compileList = new File[0];
protected File[] compileList = new File[ 0 ];
private Path bootclasspath; private Path bootclasspath;
private Path compileClasspath; private Path compileClasspath;
private String debugLevel; private String debugLevel;
@@ -238,15 +238,15 @@ public class Javac extends MatchingTask
public void setFork( String f ) public void setFork( String f )
{ {
if( f.equalsIgnoreCase( "on" ) if( f.equalsIgnoreCase( "on" )
|| f.equalsIgnoreCase( "true" )
|| f.equalsIgnoreCase( "yes" ) )
|| f.equalsIgnoreCase( "true" )
|| f.equalsIgnoreCase( "yes" ) )
{ {
fork = "true"; fork = "true";
forkedExecutable = getSystemJavac(); forkedExecutable = getSystemJavac();
} }
else if( f.equalsIgnoreCase( "off" ) else if( f.equalsIgnoreCase( "off" )
|| f.equalsIgnoreCase( "false" )
|| f.equalsIgnoreCase( "no" ) )
|| f.equalsIgnoreCase( "false" )
|| f.equalsIgnoreCase( "no" ) )
{ {
fork = "false"; fork = "false";
forkedExecutable = null; forkedExecutable = null;
@@ -406,17 +406,17 @@ public class Javac extends MatchingTask
{ {
Vector args = new Vector(); Vector args = new Vector();
for( Enumeration enum = implementationSpecificArgs.elements(); for( Enumeration enum = implementationSpecificArgs.elements();
enum.hasMoreElements();
)
enum.hasMoreElements();
)
{ {
String[] curr = String[] curr =
( ( ImplementationSpecificArgument )enum.nextElement() ).getParts();
( (ImplementationSpecificArgument)enum.nextElement() ).getParts();
for( int i = 0; i < curr.length; i++ ) for( int i = 0; i < curr.length; i++ )
{ {
args.addElement( curr[i] );
args.addElement( curr[ i ] );
} }
} }
String[] res = new String[args.size()];
String[] res = new String[ args.size() ];
args.copyInto( res ); args.copyInto( res );
return res; return res;
} }
@@ -724,17 +724,17 @@ public class Javac extends MatchingTask


if( src == null ) if( src == null )
{ {
throw new BuildException( "srcdir attribute must be set!", location );
throw new BuildException( "srcdir attribute must be set!" );
} }
String[] list = src.list(); String[] list = src.list();
if( list.length == 0 ) if( list.length == 0 )
{ {
throw new BuildException( "srcdir attribute must be set!", location );
throw new BuildException( "srcdir attribute must be set!" );
} }


if( destDir != null && !destDir.isDirectory() ) if( destDir != null && !destDir.isDirectory() )
{ {
throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory", location );
throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory" );
} }


// scan source directories and dest directory to build up // scan source directories and dest directory to build up
@@ -742,10 +742,10 @@ public class Javac extends MatchingTask
resetFileLists(); resetFileLists();
for( int i = 0; i < list.length; i++ ) for( int i = 0; i < list.length; i++ )
{ {
File srcDir = ( File )project.resolveFile( list[i] );
File srcDir = (File)resolveFile( list[ i ] );
if( !srcDir.exists() ) if( !srcDir.exists() )
{ {
throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!", location );
throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!" );
} }


DirectoryScanner ds = this.getDirectoryScanner( srcDir ); DirectoryScanner ds = this.getDirectoryScanner( srcDir );
@@ -765,7 +765,7 @@ public class Javac extends MatchingTask
CompilerAdapter adapter = CompilerAdapterFactory.getCompiler( CompilerAdapter adapter = CompilerAdapterFactory.getCompiler(
compiler, this ); compiler, this );
log( "Compiling " + compileList.length + log( "Compiling " + compileList.length +
" source file"
" source file"
+ ( compileList.length == 1 ? "" : "s" ) + ( compileList.length == 1 ? "" : "s" )
+ ( destDir != null ? " to " + destDir : "" ) ); + ( destDir != null ? " to " + destDir : "" ) );


@@ -777,7 +777,7 @@ public class Javac extends MatchingTask
{ {
if( failOnError ) if( failOnError )
{ {
throw new BuildException( FAIL_MSG, location );
throw new BuildException( FAIL_MSG );
} }
else else
{ {
@@ -799,7 +799,7 @@ public class Javac extends MatchingTask
// PATH. // PATH.
java.io.File jExecutable = java.io.File jExecutable =
new java.io.File( System.getProperty( "java.home" ) + new java.io.File( System.getProperty( "java.home" ) +
"/../bin/javac" + extension );
"/../bin/javac" + extension );


if( jExecutable.exists() && !Os.isFamily( "netware" ) ) if( jExecutable.exists() && !Os.isFamily( "netware" ) )
{ {
@@ -837,7 +837,7 @@ public class Javac extends MatchingTask
*/ */
protected void resetFileLists() protected void resetFileLists()
{ {
compileList = new File[0];
compileList = new File[ 0 ];
} }


/** /**
@@ -858,12 +858,12 @@ public class Javac extends MatchingTask


if( newFiles.length > 0 ) if( newFiles.length > 0 )
{ {
File[] newCompileList = new File[compileList.length +
newFiles.length];
File[] newCompileList = new File[ compileList.length +
newFiles.length ];
System.arraycopy( compileList, 0, newCompileList, 0, System.arraycopy( compileList, 0, newCompileList, 0,
compileList.length );
compileList.length );
System.arraycopy( newFiles, 0, newCompileList, System.arraycopy( newFiles, 0, newCompileList,
compileList.length, newFiles.length );
compileList.length, newFiles.length );
compileList = newCompileList; compileList = newCompileList;
} }
} }
@@ -879,7 +879,7 @@ public class Javac extends MatchingTask
if( isJdkCompiler( compiler ) ) if( isJdkCompiler( compiler ) )
{ {
log( "Since fork is true, ignoring build.compiler setting.", log( "Since fork is true, ignoring build.compiler setting.",
Project.MSG_WARN );
Project.MSG_WARN );
compiler = "extJavac"; compiler = "extJavac";
} }
else else
@@ -915,7 +915,7 @@ public class Javac extends MatchingTask
* @author RT * @author RT
*/ */
public class ImplementationSpecificArgument public class ImplementationSpecificArgument
extends Commandline.Argument
extends Commandline.Argument
{ {


private String impl; private String impl;
@@ -933,7 +933,7 @@ public class Javac extends MatchingTask
} }
else else
{ {
return new String[0];
return new String[ 0 ];
} }
} }
} }


+ 8
- 15
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -318,7 +318,7 @@ public class Javadoc extends Task
{ {
throw new BuildException( linkOfflineError ); throw new BuildException( linkOfflineError );
} }
le.setPackagelistLoc( project.resolveFile( tok.nextToken() ) );
le.setPackagelistLoc( resolveFile( tok.nextToken() ) );
} }
} }


@@ -436,7 +436,7 @@ public class Javadoc extends Task
{ {
String f = tok.nextToken(); String f = tok.nextToken();
SourceFile sf = new SourceFile(); SourceFile sf = new SourceFile();
sf.setFile( project.resolveFile( f ) );
sf.setFile( resolveFile( f ) );
addSource( sf ); addSource( sf );
} }
} }
@@ -608,11 +608,6 @@ public class Javadoc extends Task
public void execute() public void execute()
throws BuildException throws BuildException
{ {
if( "javadoc2".equals( taskType ) )
{
log( "!! javadoc2 is deprecated. Use javadoc instead. !!" );
}

if( sourcePath == null ) if( sourcePath == null )
{ {
String msg = "sourcePath attribute must be set!"; String msg = "sourcePath attribute must be set!";
@@ -689,7 +684,7 @@ public class Javadoc extends Task
{ {
if( doclet.getName() == null ) if( doclet.getName() == null )
{ {
throw new BuildException( "The doclet name must be specified.", location );
throw new BuildException( "The doclet name must be specified." );
} }
else else
{ {
@@ -885,8 +880,7 @@ public class Javadoc extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( "Error creating temporary file",
e, location );
throw new BuildException( "Error creating temporary file", e );
} }
finally finally
{ {
@@ -923,12 +917,12 @@ public class Javadoc extends Task
int ret = exe.execute(); int ret = exe.execute();
if( ret != 0 && failOnError ) if( ret != 0 && failOnError )
{ {
throw new BuildException( "Javadoc returned " + ret, location );
throw new BuildException( "Javadoc returned " + ret );
} }
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( "Javadoc failed: " + e, e, location );
throw new BuildException( "Javadoc failed: " + e, e );
} }
finally finally
{ {
@@ -1117,7 +1111,7 @@ public class Javadoc extends Task


for( int j = 0; j < list.length; j++ ) for( int j = 0; j < list.length; j++ )
{ {
File source = project.resolveFile( list[j] );
File source = resolveFile( list[j] );
fs.setDir( source ); fs.setDir( source );


DirectoryScanner ds = fs.getDirectoryScanner( project ); DirectoryScanner ds = fs.getDirectoryScanner( project );
@@ -1160,8 +1154,7 @@ public class Javadoc extends Task
} }
catch( IOException ioex ) catch( IOException ioex )
{ {
throw new BuildException( "Error creating temporary file",
ioex, location );
throw new BuildException( "Error creating temporary file", ioex );
} }
finally finally
{ {


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java View File

@@ -42,7 +42,7 @@ public class LogStreamHandler extends PumpStreamHandler
catch( IOException e ) catch( IOException e )
{ {
// plain impossible // plain impossible
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }
} }

+ 5
- 6
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Manifest.java View File

@@ -320,12 +320,12 @@ public class Manifest extends Task
catch( ManifestException m ) catch( ManifestException m )
{ {
throw new BuildException( "Existing manifest " + manifestFile throw new BuildException( "Existing manifest " + manifestFile
+ " is invalid", m, location );
+ " is invalid", m );
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( "Failed to read " + manifestFile,
e, location );
throw new
BuildException( "Failed to read " + manifestFile, e );
} }
finally finally
{ {
@@ -347,7 +347,7 @@ public class Manifest extends Task
} }
catch( ManifestException m ) catch( ManifestException m )
{ {
throw new BuildException( "Manifest is invalid", m, location );
throw new BuildException( "Manifest is invalid", m );
} }


PrintWriter w = null; PrintWriter w = null;
@@ -358,8 +358,7 @@ public class Manifest extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( "Failed to write " + manifestFile,
e, location );
throw new BuildException( "Failed to write " + manifestFile e );
} }
finally finally
{ {


+ 0
- 53
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java View File

@@ -88,59 +88,6 @@ public abstract class MatchingTask extends Task
fileset.setIncludesfile( includesfile ); fileset.setIncludesfile( includesfile );
} }


/**
* List of filenames and directory names to not include. They should be
* either , or " " (space) separated. The ignored files will be logged.
*
* @param ignoreString the string containing the files to ignore.
*/
public void XsetIgnore( String ignoreString )
{
log( "The ignore attribute is deprecated." +
"Please use the excludes attribute.",
Project.MSG_WARN );
if( ignoreString != null && ignoreString.length() > 0 )
{
Vector tmpExcludes = new Vector();
StringTokenizer tok = new StringTokenizer( ignoreString, ", ", false );
while( tok.hasMoreTokens() )
{
createExclude().setName( "**/" + tok.nextToken().trim() + "/**" );
}
}
}

/**
* Set this to be the items in the base directory that you want to be
* included. You can also specify "*" for the items (ie: items="*") and it
* will include all the items in the base directory.
*
* @param itemString the string containing the files to include.
*/
public void XsetItems( String itemString )
{
log( "The items attribute is deprecated. " +
"Please use the includes attribute.",
Project.MSG_WARN );
if( itemString == null || itemString.equals( "*" )
|| itemString.equals( "." ) )
{
createInclude().setName( "**" );
}
else
{
StringTokenizer tok = new StringTokenizer( itemString, ", " );
while( tok.hasMoreTokens() )
{
String pattern = tok.nextToken().trim();
if( pattern.length() > 0 )
{
createInclude().setName( pattern + "/**" );
}
}
}
}

/** /**
* add a name entry on the exclude list * add a name entry on the exclude list
* *


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Mkdir.java View File

@@ -32,7 +32,7 @@ public class Mkdir extends Task
{ {
if( dir == null ) if( dir == null )
{ {
throw new BuildException( "dir attribute is required", location );
throw new BuildException( "dir attribute is required" );
} }


if( dir.isFile() ) if( dir.isFile() )
@@ -47,7 +47,7 @@ public class Mkdir extends Task
{ {
String msg = "Directory " + dir.getAbsolutePath() + " creation was not " + String msg = "Directory " + dir.getAbsolutePath() + " creation was not " +
"successful for an unknown reason"; "successful for an unknown reason";
throw new BuildException( msg, location );
throw new BuildException( msg );
} }
log( "Created dir: " + dir.getAbsolutePath() ); log( "Created dir: " + dir.getAbsolutePath() );
} }


+ 3
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Move.java View File

@@ -96,7 +96,7 @@ public class Move extends Copy
String msg = "Failed to rename dir " + fromDir String msg = "Failed to rename dir " + fromDir
+ " to " + toDir + " to " + toDir
+ " due to " + ioe.getMessage(); + " due to " + ioe.getMessage();
throw new BuildException( msg, ioe, location );
throw new BuildException( msg, ioe );
} }
} }
} }
@@ -135,7 +135,7 @@ public class Move extends Copy
String msg = "Failed to rename " + fromFile String msg = "Failed to rename " + fromFile
+ " to " + toFile + " to " + toFile
+ " due to " + ioe.getMessage(); + " due to " + ioe.getMessage();
throw new BuildException( msg, ioe, location );
throw new BuildException( msg, ioe );
} }


if( !moved ) if( !moved )
@@ -168,7 +168,7 @@ public class Move extends Copy
String msg = "Failed to copy " + fromFile + " to " String msg = "Failed to copy " + fromFile + " to "
+ toFile + toFile
+ " due to " + ioe.getMessage(); + " due to " + ioe.getMessage();
throw new BuildException( msg, ioe, location );
throw new BuildException( msg, ioe );
} }
} }
} }


+ 3
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Pack.java View File

@@ -64,18 +64,18 @@ public abstract class Pack extends Task
{ {
if( zipFile == null ) if( zipFile == null )
{ {
throw new BuildException( "zipfile attribute is required", location );
throw new BuildException( "zipfile attribute is required" );
} }


if( source == null ) if( source == null )
{ {
throw new BuildException( "src attribute is required", location );
throw new BuildException( "src attribute is required" );
} }


if( source.isDirectory() ) if( source.isDirectory() )
{ {
throw new BuildException( "Src attribute must not " + throw new BuildException( "Src attribute must not " +
"represent a directory!", location );
"represent a directory!" );
} }
} }




+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Parallel.java View File

@@ -117,12 +117,12 @@ public class Parallel extends Task
} }
else else
{ {
throw new BuildException( firstException );
throw new BuildException( "Error", firstException );
} }
} }
else if( numExceptions > 1 ) else if( numExceptions > 1 )
{ {
throw new BuildException( exceptionMessage.toString(), firstLocation );
throw new BuildException( exceptionMessage.toString() );
} }
} }




+ 4
- 6
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Patch.java View File

@@ -70,8 +70,7 @@ public class Patch extends Task
{ {
if( !file.exists() ) if( !file.exists() )
{ {
throw new BuildException( "patchfile " + file + " doesn\'t exist",
location );
throw new BuildException( "patchfile " + file + " doesn\'t exist" );
} }
cmd.createArgument().setValue( "-i" ); cmd.createArgument().setValue( "-i" );
cmd.createArgument().setFile( file ); cmd.createArgument().setFile( file );
@@ -118,7 +117,7 @@ public class Patch extends Task
{ {
if( num < 0 ) if( num < 0 )
{ {
throw new BuildException( "strip has to be >= 0", location );
throw new BuildException( "strip has to be >= 0" );
} }
cmd.createArgument().setValue( "-p" + num ); cmd.createArgument().setValue( "-p" + num );
} }
@@ -128,8 +127,7 @@ public class Patch extends Task
{ {
if( !havePatchfile ) if( !havePatchfile )
{ {
throw new BuildException( "patchfile argument is required",
location );
throw new BuildException( "patchfile argument is required" );
} }


Commandline toExecute = ( Commandline )cmd.clone(); Commandline toExecute = ( Commandline )cmd.clone();
@@ -150,7 +148,7 @@ public class Patch extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }




+ 4
- 17
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java View File

@@ -99,17 +99,6 @@ public class Property extends Task
this.resource = resource; this.resource = resource;
} }


/**
* @param userProperty The new UserProperty value
* @deprecated This was never a supported feature and has been deprecated
* without replacement
*/
public void setUserProperty( boolean userProperty )
{
log( "DEPRECATED: Ignoring request to set user property in Property task.",
Project.MSG_WARN );
}

public void setValue( String value ) public void setValue( String value )
{ {
this.value = value; this.value = value;
@@ -161,16 +150,14 @@ public class Property extends Task
{ {
if( value == null && ref == null ) if( value == null && ref == null )
{ {
throw new BuildException( "You must specify value, location or refid with the name attribute",
location );
throw new BuildException( "You must specify value, location or refid with the name attribute" );
} }
} }
else else
{ {
if( file == null && resource == null && env == null ) if( file == null && resource == null && env == null )
{ {
throw new BuildException( "You must specify file, resource or environment when not using the name attribute",
location );
throw new BuildException( "You must specify file, resource or environment when not using the name attribute" );
} }
} }


@@ -291,7 +278,7 @@ public class Property extends Task
} }
catch( IOException ex ) catch( IOException ex )
{ {
throw new BuildException( ex );
throw new BuildException( "Error", ex );
} }
} }


@@ -334,7 +321,7 @@ public class Property extends Task
} }
catch( IOException ex ) catch( IOException ex )
{ {
throw new BuildException( ex );
throw new BuildException( "Error", ex );
} }
} }




+ 6
- 6
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Replace.java View File

@@ -245,23 +245,23 @@ public class Replace extends MatchingTask
if( src == null && dir == null ) if( src == null && dir == null )
{ {
String message = "Either the file or the dir attribute " + "must be specified"; String message = "Either the file or the dir attribute " + "must be specified";
throw new BuildException( message, location );
throw new BuildException( message );
} }
if( propertyFile != null && !propertyFile.exists() ) if( propertyFile != null && !propertyFile.exists() )
{ {
String message = "Property file " + propertyFile.getPath() + " does not exist."; String message = "Property file " + propertyFile.getPath() + " does not exist.";
throw new BuildException( message, location );
throw new BuildException( message );
} }
if( token == null && replacefilters.size() == 0 ) if( token == null && replacefilters.size() == 0 )
{ {
String message = "Either token or a nested replacefilter " String message = "Either token or a nested replacefilter "
+ "must be specified"; + "must be specified";
throw new BuildException( message, location );
throw new BuildException( message);
} }
if( token != null && "".equals( token.getText() ) ) if( token != null && "".equals( token.getText() ) )
{ {
String message = "The token attribute must not be an empty string."; String message = "The token attribute must not be an empty string.";
throw new BuildException( message, location );
throw new BuildException( message );
} }
} }


@@ -293,7 +293,7 @@ public class Replace extends MatchingTask
{ {
if( !src.exists() ) if( !src.exists() )
{ {
throw new BuildException( "Replace: source file " + src.getPath() + " doesn't exist", location );
throw new BuildException( "Replace: source file " + src.getPath() + " doesn't exist" );
} }


File temp = fileUtils.createTempFile( "rep", ".tmp", File temp = fileUtils.createTempFile( "rep", ".tmp",
@@ -382,7 +382,7 @@ public class Replace extends MatchingTask
catch( IOException ioe ) catch( IOException ioe )
{ {
throw new BuildException( "IOException in " + src + " - " + throw new BuildException( "IOException in " + src + " - " +
ioe.getClass().getName() + ":" + ioe.getMessage(), ioe, location );
ioe.getClass().getName() + ":" + ioe.getMessage(), ioe );
} }
finally finally
{ {


+ 6
- 5
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java View File

@@ -20,6 +20,7 @@ import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.FileNameMapper;
import org.apache.tools.ant.util.SourceFileScanner; import org.apache.tools.ant.util.SourceFileScanner;
import org.apache.tools.ant.util.FileUtils;


/** /**
* Task to compile RMI stubs and skeletons. This task can take the following * Task to compile RMI stubs and skeletons. This task can take the following
@@ -518,11 +519,11 @@ public class Rmic extends MatchingTask
{ {
if( baseDir == null ) if( baseDir == null )
{ {
throw new BuildException( "base attribute must be set!", location );
throw new BuildException( "base attribute must be set!" );
} }
if( !baseDir.exists() ) if( !baseDir.exists() )
{ {
throw new BuildException( "base does not exist!", location );
throw new BuildException( "base does not exist!" );
} }


if( verify ) if( verify )
@@ -565,7 +566,7 @@ public class Rmic extends MatchingTask
// finally, lets execute the compiler!! // finally, lets execute the compiler!!
if( !adapter.execute() ) if( !adapter.execute() )
{ {
throw new BuildException( FAIL_MSG, location );
throw new BuildException( FAIL_MSG );
} }
} }


@@ -672,14 +673,14 @@ public class Rmic extends MatchingTask
File newFile = new File( sourceBaseFile, sourceFileName ); File newFile = new File( sourceBaseFile, sourceFileName );
try try
{ {
project.copyFile( oldFile, newFile, filtering );
FileUtils.newFileUtils().copyFile( oldFile, newFile, filtering );
oldFile.delete(); oldFile.delete();
} }
catch( IOException ioe ) catch( IOException ioe )
{ {
String msg = "Failed to copy " + oldFile + " to " + String msg = "Failed to copy " + oldFile + " to " +
newFile + " due to " + ioe.getMessage(); newFile + " due to " + ioe.getMessage();
throw new BuildException( msg, ioe, location );
throw new BuildException( msg, ioe );
} }
} }
} }


+ 11
- 11
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java View File

@@ -400,7 +400,7 @@ public class SQLExec extends Task
{ {
if( transactions.size() == 0 ) if( transactions.size() == 0 )
{ {
throw new BuildException( "Source file or fileset, transactions or sql statement must be set!", location );
throw new BuildException( "Source file or fileset, transactions or sql statement must be set!" );
} }
} }
else else
@@ -430,23 +430,23 @@ public class SQLExec extends Task


if( driver == null ) if( driver == null )
{ {
throw new BuildException( "Driver attribute must be set!", location );
throw new BuildException( "Driver attribute must be set!" );
} }
if( userId == null ) if( userId == null )
{ {
throw new BuildException( "User Id attribute must be set!", location );
throw new BuildException( "User Id attribute must be set!" );
} }
if( password == null ) if( password == null )
{ {
throw new BuildException( "Password attribute must be set!", location );
throw new BuildException( "Password attribute must be set!" );
} }
if( url == null ) if( url == null )
{ {
throw new BuildException( "Url attribute must be set!", location );
throw new BuildException( "Url attribute must be set!" );
} }
if( srcFile != null && !srcFile.exists() ) if( srcFile != null && !srcFile.exists() )
{ {
throw new BuildException( "Source file does not exist!", location );
throw new BuildException( "Source file does not exist!" );
} }
Driver driverInstance = null; Driver driverInstance = null;
// Load the driver using the // Load the driver using the
@@ -470,15 +470,15 @@ public class SQLExec extends Task
} }
catch( ClassNotFoundException e ) catch( ClassNotFoundException e )
{ {
throw new BuildException( "Class Not Found: JDBC driver " + driver + " could not be loaded", location );
throw new BuildException( "Class Not Found: JDBC driver " + driver + " could not be loaded" );
} }
catch( IllegalAccessException e ) catch( IllegalAccessException e )
{ {
throw new BuildException( "Illegal Access: JDBC driver " + driver + " could not be loaded", location );
throw new BuildException( "Illegal Access: JDBC driver " + driver + " could not be loaded" );
} }
catch( InstantiationException e ) catch( InstantiationException e )
{ {
throw new BuildException( "Instantiation Exception: JDBC driver " + driver + " could not be loaded", location );
throw new BuildException( "Instantiation Exception: JDBC driver " + driver + " could not be loaded" );
} }


try try
@@ -543,7 +543,7 @@ public class SQLExec extends Task
catch( SQLException ex ) catch( SQLException ex )
{} {}
} }
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
catch( SQLException e ) catch( SQLException e )
{ {
@@ -556,7 +556,7 @@ public class SQLExec extends Task
catch( SQLException ex ) catch( SQLException ex )
{} {}
} }
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
finally finally
{ {


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SendEmail.java View File

@@ -201,7 +201,7 @@ public class SendEmail extends Task


while( t.hasMoreTokens() ) while( t.hasMoreTokens() )
{ {
files.addElement( project.resolveFile( t.nextToken() ) );
files.addElement( resolveFile( t.nextToken() ) );
} }
} }


@@ -394,7 +394,7 @@ public class SendEmail extends Task
String err = "IO error sending mail " + ioe.toString(); String err = "IO error sending mail " + ioe.toString();
if( failOnError ) if( failOnError )
{ {
throw new BuildException( err, ioe, location );
throw new BuildException( err, ioe );
} }
else else
{ {


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sleep.java View File

@@ -141,7 +141,7 @@ public class Sleep extends Task
{ {
if( failOnError ) if( failOnError )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
else else
{ {


+ 24
- 77
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;

import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@@ -34,33 +35,6 @@ import org.apache.tools.tar.TarOutputStream;


public class Tar extends MatchingTask public class Tar extends MatchingTask
{ {

/**
* @deprecated Tar.WARN is deprecated and is replaced with
* Tar.TarLongFileMode.WARN
*/
public final static String WARN = "warn";
/**
* @deprecated Tar.FAIL is deprecated and is replaced with
* Tar.TarLongFileMode.FAIL
*/
public final static String FAIL = "fail";
/**
* @deprecated Tar.TRUNCATE is deprecated and is replaced with
* Tar.TarLongFileMode.TRUNCATE
*/
public final static String TRUNCATE = "truncate";
/**
* @deprecated Tar.GNU is deprecated and is replaced with
* Tar.TarLongFileMode.GNU
*/
public final static String GNU = "gnu";
/**
* @deprecated Tar.OMIT is deprecated and is replaced with
* Tar.TarLongFileMode.OMIT
*/
public final static String OMIT = "omit";

private TarLongFileMode longFileMode = new TarLongFileMode(); private TarLongFileMode longFileMode = new TarLongFileMode();


Vector filesets = new Vector(); Vector filesets = new Vector();
@@ -84,28 +58,6 @@ public class Tar extends MatchingTask
this.baseDir = baseDir; this.baseDir = baseDir;
} }


/**
* Set how to handle long files. Allowable values are truncate - paths are
* truncated to the maximum length fail - paths greater than the maximim
* cause a build exception warn - paths greater than the maximum cause a
* warning and GNU is used gnu - GNU extensions are used for any paths
* greater than the maximum. omit - paths greater than the maximum are
* omitted from the archive
*
* @param mode The new Longfile value
* @deprecated setLongFile(String) is deprecated and is replaced with
* setLongFile(Tar.TarLongFileMode) to make Ant's Introspection
* mechanism do the work and also to encapsulate operations on the mode
* in its own class.
*/
public void setLongfile( String mode )
{
log( "DEPRECATED - The setLongfile(String) method has been deprecated."
+ " Use setLongfile(Tar.TarLongFileMode) instead." );
this.longFileMode = new TarLongFileMode();
longFileMode.setValue( mode );
}

/** /**
* Set how to handle long files. Allowable values are truncate - paths are * Set how to handle long files. Allowable values are truncate - paths are
* truncated to the maximum length fail - paths greater than the maximim * truncated to the maximum length fail - paths greater than the maximim
@@ -121,7 +73,6 @@ public class Tar extends MatchingTask
this.longFileMode = mode; this.longFileMode = mode;
} }



/** /**
* This is the name/location of where to create the tar file. * This is the name/location of where to create the tar file.
* *
@@ -144,27 +95,24 @@ public class Tar extends MatchingTask
{ {
if( tarFile == null ) if( tarFile == null )
{ {
throw new BuildException( "tarfile attribute must be set!",
location );
throw new BuildException( "tarfile attribute must be set!" );
} }


if( tarFile.exists() && tarFile.isDirectory() ) if( tarFile.exists() && tarFile.isDirectory() )
{ {
throw new BuildException( "tarfile is a directory!",
location );
throw new BuildException( "tarfile is a directory!" );
} }


if( tarFile.exists() && !tarFile.canWrite() ) if( tarFile.exists() && !tarFile.canWrite() )
{ {
throw new BuildException( "Can not write to the specified tarfile!",
location );
throw new BuildException( "Can not write to the specified tarfile!" );
} }


if( baseDir != null ) if( baseDir != null )
{ {
if( !baseDir.exists() ) if( !baseDir.exists() )
{ {
throw new BuildException( "basedir does not exist!", location );
throw new BuildException( "basedir does not exist!" );
} }


// add the main fileset to the list of filesets to process. // add the main fileset to the list of filesets to process.
@@ -175,16 +123,15 @@ public class Tar extends MatchingTask


if( filesets.size() == 0 ) if( filesets.size() == 0 )
{ {
throw new BuildException( "You must supply either a basdir attribute or some nested filesets.",
location );
throw new BuildException( "You must supply either a basdir attribute or some nested filesets." );
} }


// check if tr is out of date with respect to each // check if tr is out of date with respect to each
// fileset // fileset
boolean upToDate = true; boolean upToDate = true;
for( Enumeration e = filesets.elements(); e.hasMoreElements(); )
for( Enumeration e = filesets.elements(); e.hasMoreElements(); )
{ {
TarFileSet fs = ( TarFileSet )e.nextElement();
TarFileSet fs = (TarFileSet)e.nextElement();
String[] files = fs.getFiles( project ); String[] files = fs.getFiles( project );


if( !archiveIsUpToDate( files ) ) if( !archiveIsUpToDate( files ) )
@@ -194,9 +141,9 @@ public class Tar extends MatchingTask


for( int i = 0; i < files.length; ++i ) for( int i = 0; i < files.length; ++i )
{ {
if( tarFile.equals( new File( fs.getDir( project ), files[i] ) ) )
if( tarFile.equals( new File( fs.getDir( project ), files[ i ] ) ) )
{ {
throw new BuildException( "A tar file cannot include itself", location );
throw new BuildException( "A tar file cannot include itself" );
} }
} }
} }
@@ -204,7 +151,7 @@ public class Tar extends MatchingTask
if( upToDate ) if( upToDate )
{ {
log( "Nothing to do: " + tarFile.getAbsolutePath() + " is up to date.", log( "Nothing to do: " + tarFile.getAbsolutePath() + " is up to date.",
Project.MSG_INFO );
Project.MSG_INFO );
return; return;
} }


@@ -231,14 +178,14 @@ public class Tar extends MatchingTask
} }


longWarningGiven = false; longWarningGiven = false;
for( Enumeration e = filesets.elements(); e.hasMoreElements(); )
for( Enumeration e = filesets.elements(); e.hasMoreElements(); )
{ {
TarFileSet fs = ( TarFileSet )e.nextElement();
TarFileSet fs = (TarFileSet)e.nextElement();
String[] files = fs.getFiles( project ); String[] files = fs.getFiles( project );
for( int i = 0; i < files.length; i++ ) for( int i = 0; i < files.length; i++ )
{ {
File f = new File( fs.getDir( project ), files[i] );
String name = files[i].replace( File.separatorChar, '/' );
File f = new File( fs.getDir( project ), files[ i ] );
String name = files[ i ].replace( File.separatorChar, '/' );
tarFile( f, tOut, name, fs ); tarFile( f, tOut, name, fs );
} }
} }
@@ -246,7 +193,7 @@ public class Tar extends MatchingTask
catch( IOException ioe ) catch( IOException ioe )
{ {
String msg = "Problem creating TAR: " + ioe.getMessage(); String msg = "Problem creating TAR: " + ioe.getMessage();
throw new BuildException( msg, ioe, location );
throw new BuildException( msg, ioe );
} }
finally finally
{ {
@@ -258,7 +205,8 @@ public class Tar extends MatchingTask
tOut.close(); tOut.close();
} }
catch( IOException e ) catch( IOException e )
{}
{
}
} }
} }
} }
@@ -300,7 +248,7 @@ public class Tar extends MatchingTask
else if( longFileMode.isWarnMode() ) else if( longFileMode.isWarnMode() )
{ {
log( "Entry: " + vPath + " longer than " + log( "Entry: " + vPath + " longer than " +
TarConstants.NAMELEN + " characters.", Project.MSG_WARN );
TarConstants.NAMELEN + " characters.", Project.MSG_WARN );
if( !longWarningGiven ) if( !longWarningGiven )
{ {
log( "Resulting tar file can only be processed successfully" log( "Resulting tar file can only be processed successfully"
@@ -312,7 +260,7 @@ public class Tar extends MatchingTask
{ {
throw new BuildException( throw new BuildException(
"Entry: " + vPath + " longer than " + "Entry: " + vPath + " longer than " +
TarConstants.NAMELEN + "characters.", location );
TarConstants.NAMELEN + "characters." );
} }
} }


@@ -332,13 +280,13 @@ public class Tar extends MatchingTask
{ {
fIn = new FileInputStream( file ); fIn = new FileInputStream( file );


byte[] buffer = new byte[8 * 1024];
byte[] buffer = new byte[ 8 * 1024 ];
int count = 0; int count = 0;
do do
{ {
tOut.write( buffer, 0, count ); tOut.write( buffer, 0, count );
count = fIn.read( buffer, 0, buffer.length ); count = fIn.read( buffer, 0, buffer.length );
}while ( count != -1 );
} while( count != -1 );
} }


tOut.closeEntry(); tOut.closeEntry();
@@ -359,7 +307,6 @@ public class Tar extends MatchingTask
private String userName = ""; private String userName = "";
private String groupName = ""; private String groupName = "";



public TarFileSet( FileSet fileset ) public TarFileSet( FileSet fileset )
{ {
super( fileset ); super( fileset );
@@ -399,10 +346,10 @@ public class Tar extends MatchingTask
DirectoryScanner ds = getDirectoryScanner( p ); DirectoryScanner ds = getDirectoryScanner( p );
String[] directories = ds.getIncludedDirectories(); String[] directories = ds.getIncludedDirectories();
String[] filesPerSe = ds.getIncludedFiles(); String[] filesPerSe = ds.getIncludedFiles();
files = new String[directories.length + filesPerSe.length];
files = new String[ directories.length + filesPerSe.length ];
System.arraycopy( directories, 0, files, 0, directories.length ); System.arraycopy( directories, 0, files, 0, directories.length );
System.arraycopy( filesPerSe, 0, files, directories.length, System.arraycopy( filesPerSe, 0, files, directories.length,
filesPerSe.length );
filesPerSe.length );
} }


return files; return files;


+ 2
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Touch.java View File

@@ -121,7 +121,7 @@ public class Touch extends Task
} }
catch( ParseException pe ) catch( ParseException pe )
{ {
throw new BuildException( pe.getMessage(), pe, location );
throw new BuildException( pe.getMessage(), pe );
} }
} }


@@ -149,8 +149,7 @@ public class Touch extends Task
} }
catch( IOException ioe ) catch( IOException ioe )
{ {
throw new BuildException( "Could not create " + file, ioe,
location );
throw new BuildException( "Could not create " + file, ioe );
} }
} }
} }


+ 5
- 21
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tstamp.java View File

@@ -79,7 +79,7 @@ public class Tstamp extends Task
} }
catch( Exception e ) catch( Exception e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }


@@ -165,7 +165,7 @@ public class Tstamp extends Task
country = st.nextToken(); country = st.nextToken();
if( st.hasMoreElements() ) if( st.hasMoreElements() )
{ {
throw new BuildException( "bad locale format", getLocation() );
throw new BuildException( "bad locale format" );
} }
} }
} }
@@ -176,7 +176,7 @@ public class Tstamp extends Task
} }
catch( NoSuchElementException e ) catch( NoSuchElementException e )
{ {
throw new BuildException( "bad locale format", e, getLocation() );
throw new BuildException( "bad locale format", e );
} }
} }


@@ -200,22 +200,6 @@ public class Tstamp extends Task
timeZone = TimeZone.getTimeZone( id ); timeZone = TimeZone.getTimeZone( id );
} }


/**
* @param unit The new Unit value
* @deprecated setUnit(String) is deprecated and is replaced with
* setUnit(Tstamp.Unit) to make Ant's Introspection mechanism do
* the work and also to encapsulate operations on the unit in its
* own class.
*/
public void setUnit( String unit )
{
log( "DEPRECATED - The setUnit(String) method has been deprecated."
+ " Use setUnit(Tstamp.Unit) instead." );
Unit u = new Unit();
u.setValue( unit );
field = u.getCalendarField();
}

public void setUnit( Unit unit ) public void setUnit( Unit unit )
{ {
field = unit.getCalendarField(); field = unit.getCalendarField();
@@ -225,12 +209,12 @@ public class Tstamp extends Task
{ {
if( propertyName == null ) if( propertyName == null )
{ {
throw new BuildException( "property attribute must be provided", location );
throw new BuildException( "property attribute must be provided" );
} }


if( pattern == null ) if( pattern == null )
{ {
throw new BuildException( "pattern attribute must be provided", location );
throw new BuildException( "pattern attribute must be provided" );
} }


SimpleDateFormat sdf; SimpleDateFormat sdf;


+ 5
- 5
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Unpack.java View File

@@ -24,12 +24,12 @@ public abstract class Unpack extends Task


public void setDest( String dest ) public void setDest( String dest )
{ {
this.dest = project.resolveFile( dest );
this.dest = resolveFile( dest );
} }


public void setSrc( String src ) public void setSrc( String src )
{ {
source = project.resolveFile( src );
source = resolveFile( src );
} }


public void execute() public void execute()
@@ -65,17 +65,17 @@ public abstract class Unpack extends Task
{ {
if( source == null ) if( source == null )
{ {
throw new BuildException( "No Src for gunzip specified", location );
throw new BuildException( "No Src for gunzip specified" );
} }


if( !source.exists() ) if( !source.exists() )
{ {
throw new BuildException( "Src doesn't exist", location );
throw new BuildException( "Src doesn't exist" );
} }


if( source.isDirectory() ) if( source.isDirectory() )
{ {
throw new BuildException( "Cannot expand a directory", location );
throw new BuildException( "Cannot expand a directory" );
} }


if( dest == null ) if( dest == null )


+ 1
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Untar.java View File

@@ -46,8 +46,7 @@ public class Untar extends Expand
} }
catch( IOException ioe ) catch( IOException ioe )
{ {
throw new BuildException( "Error while expanding " + srcF.getPath(),
ioe, location );
throw new BuildException( "Error while expanding " + srcF.getPath(), ioe );
} }
finally finally
{ {


+ 1
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java View File

@@ -94,8 +94,7 @@ public class UpToDate extends MatchingTask implements Condition
{ {
if( mapperElement != null ) if( mapperElement != null )
{ {
throw new BuildException( "Cannot define more than one mapper",
location );
throw new BuildException( "Cannot define more than one mapper" );
} }
mapperElement = new Mapper( project ); mapperElement = new Mapper( project );
return mapperElement; return mapperElement;


+ 1
- 7
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/War.java View File

@@ -32,12 +32,6 @@ public class War extends Jar
emptyBehavior = "create"; emptyBehavior = "create";
} }


public void setWarfile( File warFile )
{
log( "DEPRECATED - The warfile attribute is deprecated. Use file attribute instead." );
setFile( warFile );
}

public void setWebxml( File descr ) public void setWebxml( File descr )
{ {
deploymentDescriptor = descr; deploymentDescriptor = descr;
@@ -89,7 +83,7 @@ public class War extends Jar
// If no webxml file is specified, it's an error. // If no webxml file is specified, it's an error.
if( deploymentDescriptor == null && !isInUpdateMode() ) if( deploymentDescriptor == null && !isInUpdateMode() )
{ {
throw new BuildException( "webxml attribute is required", location );
throw new BuildException( "webxml attribute is required" );
} }


super.initZipOutputStream( zOut ); super.initZipOutputStream( zOut );


+ 19
- 47
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -6,6 +6,7 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;

import java.io.File; import java.io.File;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Vector; import java.util.Vector;
@@ -17,7 +18,6 @@ import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;



/** /**
* A Task to process via XSLT a set of XML documents. This is useful for * A Task to process via XSLT a set of XML documents. This is useful for
* building views of XML based documentation. arguments: * building views of XML based documentation. arguments:
@@ -169,7 +169,6 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
this.outputtype = type; this.outputtype = type;
} }



public void setProcessor( String processor ) public void setProcessor( String processor )
{ {
this.processor = processor; this.processor = processor;
@@ -222,12 +221,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger


if( xslFile == null ) if( xslFile == null )
{ {
throw new BuildException( "no stylesheet specified", location );
throw new BuildException( "no stylesheet specified" );
} }


if( baseDir == null ) if( baseDir == null )
{ {
baseDir = project.resolveFile( "." );
baseDir = resolveFile( "." );
} }


liaison = getLiaison(); liaison = getLiaison();
@@ -235,25 +234,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
// check if liaison wants to log errors using us as logger // check if liaison wants to log errors using us as logger
if( liaison instanceof XSLTLoggerAware ) if( liaison instanceof XSLTLoggerAware )
{ {
( ( XSLTLoggerAware )liaison ).setLogger( this );
( (XSLTLoggerAware)liaison ).setLogger( this );
} }


log( "Using " + liaison.getClass().toString(), Project.MSG_VERBOSE ); log( "Using " + liaison.getClass().toString(), Project.MSG_VERBOSE );


File stylesheet = project.resolveFile( xslFile );
if( !stylesheet.exists() )
{
stylesheet = fileUtils.resolveFile( baseDir, xslFile );
/*
* shouldn't throw out deprecation warnings before we know,
* the wrong version has been used.
*/
if( stylesheet.exists() )
{
log( "DEPRECATED - the style attribute should be relative to the project\'s" );
log( " basedir, not the tasks\'s basedir." );
}
}
File stylesheet = resolveFile( xslFile );


// if we have an in file and out then process them // if we have an in file and out then process them
if( inFile != null && outFile != null ) if( inFile != null && outFile != null )
@@ -279,16 +265,16 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
list = scanner.getIncludedFiles(); list = scanner.getIncludedFiles();
for( int i = 0; i < list.length; ++i ) for( int i = 0; i < list.length; ++i )
{ {
process( baseDir, list[i], destDir, stylesheet );
process( baseDir, list[ i ], destDir, stylesheet );
} }


// Process all the directoried marked for styling // Process all the directoried marked for styling
dirs = scanner.getIncludedDirectories(); dirs = scanner.getIncludedDirectories();
for( int j = 0; j < dirs.length; ++j ) for( int j = 0; j < dirs.length; ++j )
{ {
list = new File( baseDir, dirs[j] ).list();
list = new File( baseDir, dirs[ j ] ).list();
for( int i = 0; i < list.length; ++i ) for( int i = 0; i < list.length; ++i )
process( baseDir, list[i], destDir, stylesheet );
process( baseDir, list[ i ], destDir, stylesheet );
} }
} }


@@ -306,7 +292,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
} }
catch( Exception e ) catch( Exception e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }
else else
@@ -338,7 +324,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
e4.printStackTrace(); e4.printStackTrace();
e3.printStackTrace(); e3.printStackTrace();
e2.printStackTrace(); e2.printStackTrace();
throw new BuildException( e1 );
throw new BuildException( "Error", e1 );
} }
} }
} }
@@ -367,16 +353,16 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
{ {
log( "Loading stylesheet " + stylesheet, Project.MSG_INFO ); log( "Loading stylesheet " + stylesheet, Project.MSG_INFO );
liaison.setStylesheet( stylesheet ); liaison.setStylesheet( stylesheet );
for( Enumeration e = params.elements(); e.hasMoreElements(); )
for( Enumeration e = params.elements(); e.hasMoreElements(); )
{ {
Param p = ( Param )e.nextElement();
Param p = (Param)e.nextElement();
liaison.addParam( p.getName(), p.getExpression() ); liaison.addParam( p.getName(), p.getExpression() );
} }
} }
catch( Exception ex ) catch( Exception ex )
{ {
log( "Failed to read stylesheet " + stylesheet, Project.MSG_INFO ); log( "Failed to read stylesheet " + stylesheet, Project.MSG_INFO );
throw new BuildException( ex );
throw new BuildException( "Error", ex );
} }
} }


@@ -389,7 +375,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
if( !directory.mkdirs() ) if( !directory.mkdirs() )
{ {
throw new BuildException( "Unable to create directory: " throw new BuildException( "Unable to create directory: "
+ directory.getAbsolutePath() );
+ directory.getAbsolutePath() );
} }
} }
} }
@@ -471,7 +457,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
outFile.delete(); outFile.delete();
} }


throw new BuildException( ex );
throw new BuildException( "Error", ex );
} }


}//-- processXML }//-- processXML
@@ -500,7 +486,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
log( "Failed to process " + inFile, Project.MSG_INFO ); log( "Failed to process " + inFile, Project.MSG_INFO );
if( outFile != null ) if( outFile != null )
outFile.delete(); outFile.delete();
throw new BuildException( ex );
throw new BuildException( "Error", ex );
} }
} }


@@ -518,31 +504,17 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
{ {
final Class clazz = final Class clazz =
loadClass( "org.apache.tools.ant.taskdefs.optional.TraXLiaison" ); loadClass( "org.apache.tools.ant.taskdefs.optional.TraXLiaison" );
liaison = ( XSLTLiaison )clazz.newInstance();
}
else if( proc.equals( "xslp" ) )
{
log( "DEPRECATED - xslp processor is deprecated. Use trax or xalan instead." );
final Class clazz =
loadClass( "org.apache.tools.ant.taskdefs.optional.XslpLiaison" );
liaison = ( XSLTLiaison )clazz.newInstance();
liaison = (XSLTLiaison)clazz.newInstance();
} }
else if( proc.equals( "xalan" ) ) else if( proc.equals( "xalan" ) )
{ {
final Class clazz = final Class clazz =
loadClass( "org.apache.tools.ant.taskdefs.optional.XalanLiaison" ); loadClass( "org.apache.tools.ant.taskdefs.optional.XalanLiaison" );
liaison = ( XSLTLiaison )clazz.newInstance();
}
else if( proc.equals( "adaptx" ) )
{
log( "DEPRECATED - adaptx processor is deprecated. Use trax or xalan instead." );
final Class clazz =
loadClass( "org.apache.tools.ant.taskdefs.optional.AdaptxLiaison" );
liaison = ( XSLTLiaison )clazz.newInstance();
liaison = (XSLTLiaison)clazz.newInstance();
} }
else else
{ {
liaison = ( XSLTLiaison )loadClass( proc ).newInstance();
liaison = (XSLTLiaison)loadClass( proc ).newInstance();
} }
} }




+ 5
- 17
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -184,18 +184,6 @@ public class Zip extends MatchingTask
emptyBehavior = we.getValue(); emptyBehavior = we.getValue();
} }


/**
* This is the name/location of where to create the .zip file.
*
* @param zipFile The new Zipfile value
* @deprecated Use setFile() instead
*/
public void setZipfile( File zipFile )
{
log( "DEPRECATED - The zipfile attribute is deprecated. Use file attribute instead." );
setFile( zipFile );
}

/** /**
* Are we updating an existing archive? * Are we updating an existing archive?
* *
@@ -383,7 +371,7 @@ public class Zip extends MatchingTask
} }
} }


throw new BuildException( msg, ioe, location );
throw new BuildException( msg, ioe );
} }
finally finally
{ {
@@ -439,7 +427,7 @@ public class Zip extends MatchingTask
else if( emptyBehavior.equals( "fail" ) ) else if( emptyBehavior.equals( "fail" ) )
{ {
throw new BuildException( "Cannot create " + archiveType + " archive " + zipFile + throw new BuildException( "Cannot create " + archiveType + " archive " + zipFile +
": no files were included.", location );
": no files were included." );
} }
else else
{ {
@@ -453,7 +441,7 @@ public class Zip extends MatchingTask
{ {
if( files[i].equals( zipFile ) ) if( files[i].equals( zipFile ) )
{ {
throw new BuildException( "A zip file cannot include itself", location );
throw new BuildException( "A zip file cannot include itself" );
} }
} }


@@ -741,7 +729,7 @@ public class Zip extends MatchingTask
} }
catch( IOException ioe ) catch( IOException ioe )
{ {
throw new BuildException( "Could not create empty ZIP archive", ioe, location );
throw new BuildException( "Could not create empty ZIP archive", ioe );
} }
return true; return true;
} }
@@ -858,7 +846,7 @@ public class Zip extends MatchingTask
{ {
if( file.equals( zipFile ) ) if( file.equals( zipFile ) )
{ {
throw new BuildException( "A zip file cannot include itself", location );
throw new BuildException( "A zip file cannot include itself" );
} }


FileInputStream fIn = new FileInputStream( file ); FileInputStream fIn = new FileInputStream( file );


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -414,7 +414,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( "Error creating temporary file", e, location );
throw new BuildException( "Error creating temporary file", e );
} }
finally finally
{ {
@@ -448,7 +448,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( "Error running " + args[0] throw new BuildException( "Error running " + args[0]
+ " compiler", e, location );
+ " compiler", e );
} }
} }
finally finally


+ 3
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java View File

@@ -52,7 +52,7 @@ public class Javac12 extends DefaultCompilerAdapter
{ {
throw new BuildException( "Cannot use classic compiler, as it is not available" + throw new BuildException( "Cannot use classic compiler, as it is not available" +
" A common solution is to set the environment variable" + " A common solution is to set the environment variable" +
" JAVA_HOME to your jdk directory.", location );
" JAVA_HOME to your jdk directory." );
} }
catch( Exception ex ) catch( Exception ex )
{ {
@@ -62,7 +62,7 @@ public class Javac12 extends DefaultCompilerAdapter
} }
else else
{ {
throw new BuildException( "Error starting classic compiler: ", ex, location );
throw new BuildException( "Error starting classic compiler: ", ex );
} }
} }
finally finally
@@ -74,7 +74,7 @@ public class Javac12 extends DefaultCompilerAdapter
catch( IOException e ) catch( IOException e )
{ {
// plain impossible // plain impossible
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }
} }


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java View File

@@ -55,7 +55,7 @@ public class Javac13 extends DefaultCompilerAdapter
} }
else else
{ {
throw new BuildException( "Error starting modern compiler", ex, location );
throw new BuildException( "Error starting modern compiler", ex );
} }
} }
} }


+ 0
- 17
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java View File

@@ -131,23 +131,6 @@ public class Jikes extends DefaultCompilerAdapter
cmd.createArgument().setValue( "+E" ); cmd.createArgument().setValue( "+E" );
} }


/**
* Jikes issues more warnings that javac, for example, when you have
* files in your classpath that don't exist. As this is often the case,
* these warning can be pretty annoying.
*/
String warningsProperty = project.getProperty( "build.compiler.warnings" );
if( warningsProperty != null )
{
attributes.log( "!! the build.compiler.warnings property is deprecated. !!",
Project.MSG_WARN );
attributes.log( "!! Use the nowarn attribute instead. !!",
Project.MSG_WARN );
if( !Project.toBoolean( warningsProperty ) )
{
cmd.createArgument().setValue( "-nowarn" );
}
}
if( attributes.getNowarn() ) if( attributes.getNowarn() )
{ {
/* /*


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java View File

@@ -42,7 +42,7 @@ public class Kjc extends DefaultCompilerAdapter
{ {
throw new BuildException( "Cannot use kjc compiler, as it is not available" + throw new BuildException( "Cannot use kjc compiler, as it is not available" +
" A common solution is to set the environment variable" + " A common solution is to set the environment variable" +
" CLASSPATH to your kjc archive (kjc.jar).", location );
" CLASSPATH to your kjc archive (kjc.jar)." );
} }
catch( Exception ex ) catch( Exception ex )
{ {
@@ -52,7 +52,7 @@ public class Kjc extends DefaultCompilerAdapter
} }
else else
{ {
throw new BuildException( "Error starting kjc compiler: ", ex, location );
throw new BuildException( "Error starting kjc compiler: ", ex );
} }
} }
} }


+ 0
- 7
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/defaults.properties View File

@@ -132,10 +132,3 @@ jspc=org.apache.tools.ant.taskdefs.optional.jsp.JspC
replaceregexp=org.apache.tools.ant.taskdefs.optional.ReplaceRegExp replaceregexp=org.apache.tools.ant.taskdefs.optional.ReplaceRegExp
translate=org.apache.tools.ant.taskdefs.optional.i18n.Translate translate=org.apache.tools.ant.taskdefs.optional.i18n.Translate


# deprecated ant tasks (kept for back compatibility)
javadoc2=org.apache.tools.ant.taskdefs.Javadoc
#compileTask=org.apache.tools.ant.taskdefs.CompileTask
copydir=org.apache.tools.ant.taskdefs.Copydir
copyfile=org.apache.tools.ant.taskdefs.Copyfile
deltree=org.apache.tools.ant.taskdefs.Deltree
rename=org.apache.tools.ant.taskdefs.Rename

+ 8
- 19
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java View File

@@ -6,13 +6,13 @@
* the LICENSE file. * the LICENSE file.
*/ */
package org.apache.tools.ant.taskdefs.optional; package org.apache.tools.ant.taskdefs.optional;

import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ExitException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Execute; import org.apache.tools.ant.taskdefs.Execute;
@@ -20,7 +20,6 @@ import org.apache.tools.ant.taskdefs.ExecuteJava;
import org.apache.tools.ant.taskdefs.LogStreamHandler; import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.Environment;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;


/** /**
@@ -128,7 +127,7 @@ public class ANTLR extends Task
int err = run( commandline.getCommandline() ); int err = run( commandline.getCommandline() );
if( err == 1 ) if( err == 1 )
{ {
throw new BuildException( "ANTLR returned: " + err, location );
throw new BuildException( "ANTLR returned: " + err );
} }
} }
else else
@@ -136,17 +135,7 @@ public class ANTLR extends Task
ExecuteJava exe = new ExecuteJava(); ExecuteJava exe = new ExecuteJava();
exe.setJavaCommand( commandline.getJavaCommand() ); exe.setJavaCommand( commandline.getJavaCommand() );
exe.setClasspath( commandline.getClasspath() ); exe.setClasspath( commandline.getClasspath() );
try
{
exe.execute( project );
}
catch( ExitException e )
{
if( e.getStatus() != 0 )
{
throw new BuildException( "ANTLR returned: " + e.getStatus(), location );
}
}
exe.execute( project );
} }
} }
} }
@@ -183,7 +172,7 @@ public class ANTLR extends Task
int pling = u.indexOf( "!" ); int pling = u.indexOf( "!" );
String jarName = u.substring( 9, pling ); String jarName = u.substring( 9, pling );
log( "Implicitly adding " + jarName + " to classpath", log( "Implicitly adding " + jarName + " to classpath",
Project.MSG_DEBUG );
Project.MSG_DEBUG );
createClasspath().setLocation( new File( ( new File( jarName ) ).getAbsolutePath() ) ); createClasspath().setLocation( new File( ( new File( jarName ) ).getAbsolutePath() ) );
} }
else if( u.startsWith( "file:" ) ) else if( u.startsWith( "file:" ) )
@@ -191,13 +180,13 @@ public class ANTLR extends Task
int tail = u.indexOf( resource ); int tail = u.indexOf( resource );
String dirName = u.substring( 5, tail ); String dirName = u.substring( 5, tail );
log( "Implicitly adding " + dirName + " to classpath", log( "Implicitly adding " + dirName + " to classpath",
Project.MSG_DEBUG );
Project.MSG_DEBUG );
createClasspath().setLocation( new File( ( new File( dirName ) ).getAbsolutePath() ) ); createClasspath().setLocation( new File( ( new File( dirName ) ).getAbsolutePath() ) );
} }
else else
{ {
log( "Don\'t know how to handle resource URL " + u, log( "Don\'t know how to handle resource URL " + u,
Project.MSG_DEBUG );
Project.MSG_DEBUG );
} }
} }
else else
@@ -247,7 +236,7 @@ public class ANTLR extends Task
throws BuildException throws BuildException
{ {
Execute exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO, Execute exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO,
Project.MSG_WARN ), null );
Project.MSG_WARN ), null );
exe.setAntRun( project ); exe.setAntRun( project );
if( workingdir != null ) if( workingdir != null )
{ {
@@ -260,7 +249,7 @@ public class ANTLR extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }




+ 6
- 6
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java View File

@@ -897,27 +897,27 @@ public class IContract extends MatchingTask
{ {
if( srcDir == null ) if( srcDir == null )
{ {
throw new BuildException( "srcdir attribute must be set!", location );
throw new BuildException( "srcdir attribute must be set!" );
} }
if( !srcDir.exists() ) if( !srcDir.exists() )
{ {
throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!", location );
throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!");
} }
if( instrumentDir == null ) if( instrumentDir == null )
{ {
throw new BuildException( "instrumentdir attribute must be set!", location );
throw new BuildException( "instrumentdir attribute must be set!");
} }
if( repositoryDir == null ) if( repositoryDir == null )
{ {
throw new BuildException( "repositorydir attribute must be set!", location );
throw new BuildException( "repositorydir attribute must be set!" );
} }
if( updateIcontrol == true && classDir == null ) if( updateIcontrol == true && classDir == null )
{ {
throw new BuildException( "classdir attribute must be specified when updateicontrol=true!", location );
throw new BuildException( "classdir attribute must be specified when updateicontrol=true!" );
} }
if( updateIcontrol == true && controlFile == null ) if( updateIcontrol == true && controlFile == null )
{ {
throw new BuildException( "controlfile attribute must be specified when updateicontrol=true!", location );
throw new BuildException( "controlfile attribute must be specified when updateicontrol=true!" );
} }
} }




+ 6
- 6
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java View File

@@ -238,23 +238,23 @@ public class Javah extends Task


if( ( cls == null ) && ( classes.size() == 0 ) ) if( ( cls == null ) && ( classes.size() == 0 ) )
{ {
throw new BuildException( "class attribute must be set!", location );
throw new BuildException( "class attribute must be set!" );
} }


if( ( cls != null ) && ( classes.size() > 0 ) ) if( ( cls != null ) && ( classes.size() > 0 ) )
{ {
throw new BuildException( "set class attribute or class element, not both.", location );
throw new BuildException( "set class attribute or class element, not both." );
} }


if( destDir != null ) if( destDir != null )
{ {
if( !destDir.isDirectory() ) if( !destDir.isDirectory() )
{ {
throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory", location );
throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory" );
} }
if( outputFile != null ) if( outputFile != null )
{ {
throw new BuildException( "destdir and outputFile are mutually exclusive", location );
throw new BuildException( "destdir and outputFile are mutually exclusive");
} }
} }


@@ -381,7 +381,7 @@ public class Javah extends Task
{ {
if( !old ) if( !old )
{ {
throw new BuildException( "stubs only available in old mode.", location );
throw new BuildException( "stubs only available in old mode." );
} }
cmd.createArgument().setValue( "-stubs" ); cmd.createArgument().setValue( "-stubs" );
} }
@@ -442,7 +442,7 @@ public class Javah extends Task
} }
else else
{ {
throw new BuildException( "Error starting javah: ", ex, location );
throw new BuildException( "Error starting javah: ", ex );
} }
} }
} }


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ManifestFile.java View File

@@ -161,7 +161,7 @@ public class ManifestFile extends Task
{ {
if( !checkParam( manifestFile ) ) if( !checkParam( manifestFile ) )
{ {
throw new BuildException( "file token must not be null.", location );
throw new BuildException( "file token must not be null." );
} }
} }




+ 2
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java View File

@@ -100,8 +100,7 @@ public class Native2Ascii extends MatchingTask
{ {
if( mapper != null ) if( mapper != null )
{ {
throw new BuildException( "Cannot define more than one mapper",
location );
throw new BuildException( "Cannot define more than one mapper" );
} }
mapper = new Mapper( project ); mapper = new Mapper( project );
return mapper; return mapper;
@@ -118,7 +117,7 @@ public class Native2Ascii extends MatchingTask
// default srcDir to basedir // default srcDir to basedir
if( srcDir == null ) if( srcDir == null )
{ {
srcDir = project.resolveFile( "." );
srcDir = resolveFile( "." );
} }


// Require destDir // Require destDir


+ 3
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java View File

@@ -19,6 +19,7 @@ import netrexx.lang.Rexx;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.taskdefs.MatchingTask;


/** /**
@@ -586,7 +587,7 @@ public class NetRexxC extends MatchingTask
System.getProperty( "path.separator" ), false ); System.getProperty( "path.separator" ), false );
while( tok.hasMoreTokens() ) while( tok.hasMoreTokens() )
{ {
File f = project.resolveFile( tok.nextToken() );
File f = resolveFile( tok.nextToken() );


if( f.exists() ) if( f.exists() )
{ {
@@ -619,7 +620,7 @@ public class NetRexxC extends MatchingTask
String toFile = ( String )filecopyList.get( fromFile ); String toFile = ( String )filecopyList.get( fromFile );
try try
{ {
project.copyFile( fromFile, toFile );
FileUtils.newFileUtils().copyFile( fromFile, toFile );
} }
catch( IOException ioe ) catch( IOException ioe )
{ {


+ 4
- 4
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java View File

@@ -204,7 +204,7 @@ public class PropertyFile extends Task
{ {
if( !checkParam( m_propertyfile ) ) if( !checkParam( m_propertyfile ) )
{ {
throw new BuildException( "file token must not be null.", location );
throw new BuildException( "file token must not be null." );
} }
} }


@@ -293,16 +293,16 @@ public class PropertyFile extends Task
catch( InvocationTargetException ite ) catch( InvocationTargetException ite )
{ {
Throwable t = ite.getTargetException(); Throwable t = ite.getTargetException();
throw new BuildException( t );
throw new BuildException( "Error", t );
} }
catch( IllegalAccessException iae ) catch( IllegalAccessException iae )
{ {
// impossible // impossible
throw new BuildException( iae );
throw new BuildException( "Error", iae );
} }
catch( IOException ioe ) catch( IOException ioe )
{ {
throw new BuildException( ioe );
throw new BuildException( "Error", ioe );
} }
finally finally
{ {


+ 4
- 4
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java View File

@@ -102,7 +102,7 @@ public class Rpm extends Task
{ {
if( ( sf == null ) || ( sf.trim().equals( "" ) ) ) if( ( sf == null ) || ( sf.trim().equals( "" ) ) )
{ {
throw new BuildException( "You must specify a spec file", location );
throw new BuildException( "You must specify a spec file" );
} }
this.specFile = sf; this.specFile = sf;
} }
@@ -160,7 +160,7 @@ public class Rpm extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }
else else
@@ -175,7 +175,7 @@ public class Rpm extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }
else else
@@ -200,7 +200,7 @@ public class Rpm extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
finally finally
{ {


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Script.java View File

@@ -59,7 +59,7 @@ public class Script extends Task
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }


script += new String( data ); script += new String( data );
@@ -121,7 +121,7 @@ public class Script extends Task
t = te; t = te;
} }
} }
throw new BuildException( t );
throw new BuildException( "Error", t );
} }
} }




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java View File

@@ -127,7 +127,7 @@ public class CCMCheck extends Continuus
if( result != 0 ) if( result != 0 )
{ {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException( msg, location );
throw new BuildException( msg );
} }
} }




+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java View File

@@ -280,7 +280,7 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler
if( result != 0 ) if( result != 0 )
{ {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException( msg, location );
throw new BuildException( msg );
} }


//create task ok, set this task as the default one //create task ok, set this task as the default one
@@ -295,7 +295,7 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler
if( result != 0 ) if( result != 0 )
{ {
String msg = "Failed executing: " + commandLine2.toString(); String msg = "Failed executing: " + commandLine2.toString();
throw new BuildException( msg, location );
throw new BuildException( msg);
} }


} }


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java View File

@@ -133,7 +133,7 @@ public class CCMReconfigure extends Continuus
if( result != 0 ) if( result != 0 )
{ {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException( msg, location );
throw new BuildException( msg );
} }
} }




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java View File

@@ -120,7 +120,7 @@ public abstract class Continuus extends Task
} }
catch( java.io.IOException e ) catch( java.io.IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java View File

@@ -348,7 +348,7 @@ public class CCCheckin extends ClearCase
if( result != 0 ) if( result != 0 )
{ {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException( msg, location );
throw new BuildException( msg );
} }
} }




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java View File

@@ -435,7 +435,7 @@ public class CCCheckout extends ClearCase
if( result != 0 ) if( result != 0 )
{ {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException( msg, location );
throw new BuildException( msg );
} }
} }




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java View File

@@ -139,7 +139,7 @@ public class CCUnCheckout extends ClearCase
if( result != 0 ) if( result != 0 )
{ {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException( msg, location );
throw new BuildException( msg );
} }
} }




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java View File

@@ -352,7 +352,7 @@ public class CCUpdate extends ClearCase
if( result != 0 ) if( result != 0 )
{ {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException( msg, location );
throw new BuildException( msg );
} }
} }




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java View File

@@ -116,7 +116,7 @@ public abstract class ClearCase extends Task
} }
catch( java.io.IOException e ) catch( java.io.IOException e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }




+ 3
- 3
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java View File

@@ -201,7 +201,7 @@ public class Depend extends MatchingTask
String[] srcPathList = srcPath.list(); String[] srcPathList = srcPath.list();
if( srcPathList.length == 0 ) if( srcPathList.length == 0 )
{ {
throw new BuildException( "srcdir attribute must be set!", location );
throw new BuildException( "srcdir attribute must be set!" );
} }


if( destPath == null ) if( destPath == null )
@@ -261,7 +261,7 @@ public class Depend extends MatchingTask
outOfDateClasses = new Hashtable(); outOfDateClasses = new Hashtable();
for( int i = 0; i < srcPathList.length; i++ ) for( int i = 0; i < srcPathList.length; i++ )
{ {
File srcDir = ( File )project.resolveFile( srcPathList[i] );
File srcDir = ( File )resolveFile( srcPathList[i] );
if( srcDir.exists() ) if( srcDir.exists() )
{ {
DirectoryScanner ds = this.getDirectoryScanner( srcDir ); DirectoryScanner ds = this.getDirectoryScanner( srcDir );
@@ -310,7 +310,7 @@ public class Depend extends MatchingTask
} }
catch( Exception e ) catch( Exception e )
{ {
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }




+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java View File

@@ -649,7 +649,7 @@ public class CSharp
throws BuildException throws BuildException
{ {
if( _srcDir == null ) if( _srcDir == null )
_srcDir = project.resolveFile( "." );
_srcDir = resolveFile( "." );


NetCommand command = new NetCommand( this, "CSC", csc_exe_name ); NetCommand command = new NetCommand( this, "CSC", csc_exe_name );
command.setFailOnError( getFailFailOnError() ); command.setFailOnError( getFailFailOnError() );


+ 1
- 1
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java View File

@@ -310,7 +310,7 @@ public class Ilasm
throws BuildException throws BuildException
{ {
if( _srcDir == null ) if( _srcDir == null )
_srcDir = project.resolveFile( "." );
_srcDir = resolveFile( "." );


//get dependencies list. //get dependencies list.
DirectoryScanner scanner = super.getDirectoryScanner( _srcDir ); DirectoryScanner scanner = super.getDirectoryScanner( _srcDir );


+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java View File

@@ -158,7 +158,7 @@ public class NetCommand
{ {
if( _failOnError ) if( _failOnError )
{ {
throw new BuildException( _title + " returned: " + err, _owner.getLocation() );
throw new BuildException( _title + " returned: " + err );
} }
else else
{ {
@@ -168,7 +168,7 @@ public class NetCommand
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( _title + " failed: " + e, e, _owner.getLocation() );
throw new BuildException( _title + " failed: " + e, e );
} }
} }




+ 2
- 2
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java View File

@@ -396,13 +396,13 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exec
if( result != 0 ) if( result != 0 )
{ {
String msg = "Failed executing java2iiop (ret code is " + result + ")"; String msg = "Failed executing java2iiop (ret code is " + result + ")";
throw new BuildException( msg, getTask().getLocation() );
throw new BuildException( msg );
} }
} }
catch( java.io.IOException e ) catch( java.io.IOException e )
{ {
log( "java2iiop exception :" + e.getMessage(), Project.MSG_ERR ); log( "java2iiop exception :" + e.getMessage(), Project.MSG_ERR );
throw new BuildException( e );
throw new BuildException( "Error", e );
} }
} }




+ 4
- 6
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java View File

@@ -307,7 +307,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool
{ {
String msg = "A valid destination directory must be specified " String msg = "A valid destination directory must be specified "
+ "using the \"destdir\" attribute."; + "using the \"destdir\" attribute.";
throw new BuildException( msg, getLocation() );
throw new BuildException( msg );
} }
} }


@@ -859,8 +859,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool
in = new FileInputStream( config.manifest ); in = new FileInputStream( config.manifest );
if( in == null ) if( in == null )
{ {
throw new BuildException( "Could not find manifest file: " + config.manifest,
getLocation() );
throw new BuildException( "Could not find manifest file: " + config.manifest );
} }
} }
else else
@@ -869,8 +868,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool
in = this.getClass().getResourceAsStream( defaultManifest ); in = this.getClass().getResourceAsStream( defaultManifest );
if( in == null ) if( in == null )
{ {
throw new BuildException( "Could not find default manifest: " + defaultManifest,
getLocation() );
throw new BuildException( "Could not find default manifest: " + defaultManifest );
} }
} }


@@ -878,7 +876,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool
} }
catch( IOException e ) catch( IOException e )
{ {
throw new BuildException( "Unable to read manifest", e, getLocation() );
throw new BuildException( "Unable to read manifest", e );
} }
finally finally
{ {


+ 5
- 5
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java View File

@@ -218,7 +218,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool
+ " descriptor should be prepended with the JAR " + " descriptor should be prepended with the JAR "
+ "name or it should be specified using the " + "name or it should be specified using the "
+ "attribute \"basejarname\" in the \"ejbjar\" task."; + "attribute \"basejarname\" in the \"ejbjar\" task.";
throw new BuildException( msg, getLocation() );
throw new BuildException( msg );
} }


File iasDescriptor = new File( getConfig().descriptorDir, File iasDescriptor = new File( getConfig().descriptorDir,
@@ -227,14 +227,14 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool
{ {
String msg = "The iAS-specific EJB descriptor (" String msg = "The iAS-specific EJB descriptor ("
+ iasDescriptor + ") was not found."; + iasDescriptor + ") was not found.";
throw new BuildException( msg, getLocation() );
throw new BuildException( msg );
} }


if( ( iashome != null ) && ( !iashome.isDirectory() ) ) if( ( iashome != null ) && ( !iashome.isDirectory() ) )
{ {
String msg = "If \"iashome\" is specified, it must be a valid " String msg = "If \"iashome\" is specified, it must be a valid "
+ "directory (it was set to " + iashome + ")."; + "directory (it was set to " + iashome + ").";
throw new BuildException( msg, getLocation() );
throw new BuildException( msg );
} }
} }


@@ -287,7 +287,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool
catch( IPlanetEjbc.EjbcException e ) catch( IPlanetEjbc.EjbcException e )
{ {
throw new BuildException( "An error has occurred while trying to " throw new BuildException( "An error has occurred while trying to "
+ "execute the iAS ejbc utility", e, getLocation() );
+ "execute the iAS ejbc utility", e );
} }


displayName = ejbc.getDisplayName(); displayName = ejbc.getDisplayName();
@@ -313,7 +313,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool
if( !cmpFile.exists() ) if( !cmpFile.exists() )
{ {
throw new BuildException( "The CMP descriptor file (" throw new BuildException( "The CMP descriptor file ("
+ cmpFile + ") could not be found.", getLocation() );
+ cmpFile + ") could not be found." );
} }
files.put( cmpDescriptors[i], cmpFile ); files.put( cmpDescriptors[i], cmpFile );
} }


+ 12
- 12
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java View File

@@ -229,12 +229,12 @@ public class IPlanetEjbcTask extends Task
catch( SAXException e ) catch( SAXException e )
{ {
String msg = "Unable to create a SAXParser: " + e.getMessage(); String msg = "Unable to create a SAXParser: " + e.getMessage();
throw new BuildException( msg, e, location );
throw new BuildException( msg, e );
} }
catch( ParserConfigurationException e ) catch( ParserConfigurationException e )
{ {
String msg = "Unable to create a SAXParser: " + e.getMessage(); String msg = "Unable to create a SAXParser: " + e.getMessage();
throw new BuildException( msg, e, location );
throw new BuildException( msg, e );
} }


return saxParser; return saxParser;
@@ -253,46 +253,46 @@ public class IPlanetEjbcTask extends Task
{ {
String msg = "The standard EJB descriptor must be specified using " String msg = "The standard EJB descriptor must be specified using "
+ "the \"ejbdescriptor\" attribute."; + "the \"ejbdescriptor\" attribute.";
throw new BuildException( msg, location );
throw new BuildException( msg );
} }
if( ( !ejbdescriptor.exists() ) || ( !ejbdescriptor.isFile() ) ) if( ( !ejbdescriptor.exists() ) || ( !ejbdescriptor.isFile() ) )
{ {
String msg = "The standard EJB descriptor (" + ejbdescriptor String msg = "The standard EJB descriptor (" + ejbdescriptor
+ ") was not found or isn't a file."; + ") was not found or isn't a file.";
throw new BuildException( msg, location );
throw new BuildException( msg );
} }


if( iasdescriptor == null ) if( iasdescriptor == null )
{ {
String msg = "The iAS-speific XML descriptor must be specified using" String msg = "The iAS-speific XML descriptor must be specified using"
+ " the \"iasdescriptor\" attribute."; + " the \"iasdescriptor\" attribute.";
throw new BuildException( msg, location );
throw new BuildException( msg );
} }
if( ( !iasdescriptor.exists() ) || ( !iasdescriptor.isFile() ) ) if( ( !iasdescriptor.exists() ) || ( !iasdescriptor.isFile() ) )
{ {
String msg = "The iAS-specific XML descriptor (" + iasdescriptor String msg = "The iAS-specific XML descriptor (" + iasdescriptor
+ ") was not found or isn't a file."; + ") was not found or isn't a file.";
throw new BuildException( msg, location );
throw new BuildException( msg );
} }


if( dest == null ) if( dest == null )
{ {
String msg = "The destination directory must be specified using " String msg = "The destination directory must be specified using "
+ "the \"dest\" attribute."; + "the \"dest\" attribute.";
throw new BuildException( msg, location );
throw new BuildException( msg );
} }
if( ( !dest.exists() ) || ( !dest.isDirectory() ) ) if( ( !dest.exists() ) || ( !dest.isDirectory() ) )
{ {
String msg = "The destination directory (" + dest + ") was not " String msg = "The destination directory (" + dest + ") was not "
+ "found or isn't a directory."; + "found or isn't a directory.";
throw new BuildException( msg, location );
throw new BuildException( msg );
} }


if( ( iashome != null ) && ( !iashome.isDirectory() ) ) if( ( iashome != null ) && ( !iashome.isDirectory() ) )
{ {
String msg = "If \"iashome\" is specified, it must be a valid " String msg = "If \"iashome\" is specified, it must be a valid "
+ "directory (it was set to " + iashome + ")."; + "directory (it was set to " + iashome + ").";
throw new BuildException( msg, getLocation() );
throw new BuildException( msg );
} }
} }


@@ -327,19 +327,19 @@ public class IPlanetEjbcTask extends Task
{ {
String msg = "An IOException occurred while trying to read the XML " String msg = "An IOException occurred while trying to read the XML "
+ "descriptor file: " + e.getMessage(); + "descriptor file: " + e.getMessage();
throw new BuildException( msg, e, location );
throw new BuildException( msg, e );
} }
catch( SAXException e ) catch( SAXException e )
{ {
String msg = "A SAXException occurred while trying to read the XML " String msg = "A SAXException occurred while trying to read the XML "
+ "descriptor file: " + e.getMessage(); + "descriptor file: " + e.getMessage();
throw new BuildException( msg, e, location );
throw new BuildException( msg, e );
} }
catch( IPlanetEjbc.EjbcException e ) catch( IPlanetEjbc.EjbcException e )
{ {
String msg = "An exception occurred while trying to run the ejbc " String msg = "An exception occurred while trying to run the ejbc "
+ "utility: " + e.getMessage(); + "utility: " + e.getMessage();
throw new BuildException( msg, e, location );
throw new BuildException( msg, e );
} }
} }
} }

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save