Browse Source

BuildException -> TaskException

Removed uneeded imports.

Processed code through style formatter.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270166 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
b8c50342ca
100 changed files with 1628 additions and 1530 deletions
  1. +26
    -24
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
  2. +15
    -15
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java
  3. +15
    -10
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java
  4. +5
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BZip2.java
  5. +6
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CVSPass.java
  6. +32
    -31
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java
  7. +8
    -9
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Chmod.java
  8. +4
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
  9. +6
    -7
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Copy.java
  10. +0
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Cvs.java
  11. +32
    -32
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Delete.java
  12. +35
    -34
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/DependSet.java
  13. +6
    -7
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ear.java
  14. +7
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Echo.java
  15. +27
    -25
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecTask.java
  16. +9
    -10
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Execute.java
  17. +9
    -8
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  18. +47
    -47
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  19. +1
    -0
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteStreamHandler.java
  20. +8
    -7
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java
  21. +5
    -5
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Exit.java
  22. +26
    -23
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java
  23. +5
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Filter.java
  24. +170
    -174
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
  25. +11
    -7
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GUnzip.java
  26. +5
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GZip.java
  27. +20
    -19
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GenerateKey.java
  28. +41
    -43
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Get.java
  29. +10
    -7
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Input.java
  30. +28
    -21
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Jar.java
  31. +25
    -25
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java
  32. +9
    -9
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java
  33. +56
    -49
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  34. +2
    -5
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java
  35. +4
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java
  36. +65
    -60
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Manifest.java
  37. +0
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ManifestException.java
  38. +3
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
  39. +6
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Mkdir.java
  40. +36
    -35
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Move.java
  41. +9
    -8
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Pack.java
  42. +19
    -20
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Parallel.java
  43. +12
    -11
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Patch.java
  44. +17
    -16
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
  45. +3
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ProcessDestroyer.java
  46. +0
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java
  47. +12
    -10
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
  48. +12
    -11
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Recorder.java
  49. +5
    -5
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java
  50. +40
    -39
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Replace.java
  51. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java
  52. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  53. +19
    -15
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SendEmail.java
  54. +7
    -7
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sequential.java
  55. +15
    -14
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SignJar.java
  56. +14
    -21
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sleep.java
  57. +6
    -5
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/StreamPumper.java
  58. +10
    -10
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java
  59. +21
    -20
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Touch.java
  60. +12
    -11
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
  61. +12
    -9
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Unpack.java
  62. +7
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Untar.java
  63. +13
    -13
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java
  64. +9
    -8
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/WaitFor.java
  65. +6
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/War.java
  66. +1
    -0
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java
  67. +22
    -22
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
  68. +69
    -66
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java
  69. +4
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java
  70. +16
    -13
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
  71. +19
    -18
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  72. +5
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java
  73. +11
    -10
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java
  74. +8
    -8
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java
  75. +4
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java
  76. +4
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
  77. +3
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java
  78. +12
    -11
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java
  79. +4
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java
  80. +4
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/And.java
  81. +1
    -1
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/Condition.java
  82. +3
    -2
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
  83. +4
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java
  84. +6
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
  85. +4
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java
  86. +6
    -5
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/Not.java
  87. +4
    -3
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
  88. +5
    -4
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
  89. +14
    -14
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
  90. +18
    -17
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  91. +51
    -37
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java
  92. +25
    -22
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
  93. +33
    -36
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ManifestFile.java
  94. +25
    -21
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java
  95. +32
    -32
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
  96. +39
    -38
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
  97. +31
    -26
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
  98. +12
    -9
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java
  99. +15
    -14
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Script.java
  100. +7
    -6
      proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/StyleBook.java

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

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

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
@@ -16,7 +17,7 @@ import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.IntrospectionHelper;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.TaskContainer;
@@ -31,7 +32,6 @@ import org.apache.tools.ant.types.EnumeratedAttribute;

public class AntStructure extends Task
{

private final String lSep = System.getProperty( "line.separator" );

private final String BOOLEAN = "%boolean;";
@@ -53,12 +53,12 @@ public class AntStructure extends Task
}

public void execute()
throws BuildException
throws TaskException
{

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

PrintWriter out = null;
@@ -80,24 +80,24 @@ public class AntStructure extends Task
}

printHead( out, project.getTaskDefinitions().keys(),
project.getDataTypeDefinitions().keys() );
project.getDataTypeDefinitions().keys() );

printTargetDecl( out );

Enumeration dataTypes = project.getDataTypeDefinitions().keys();
while( dataTypes.hasMoreElements() )
{
String typeName = ( String )dataTypes.nextElement();
String typeName = (String)dataTypes.nextElement();
printElementDecl( out, typeName,
( Class )project.getDataTypeDefinitions().get( typeName ) );
(Class)project.getDataTypeDefinitions().get( typeName ) );
}

Enumeration tasks = project.getTaskDefinitions().keys();
while( tasks.hasMoreElements() )
{
String taskName = ( String )tasks.nextElement();
String taskName = (String)tasks.nextElement();
printElementDecl( out, taskName,
( Class )project.getTaskDefinitions().get( taskName ) );
(Class)project.getTaskDefinitions().get( taskName ) );
}

printTail( out );
@@ -105,8 +105,8 @@ public class AntStructure extends Task
}
catch( IOException ioe )
{
throw new BuildException( "Error writing " + output.getAbsolutePath(),
ioe );
throw new TaskException( "Error writing " + output.getAbsolutePath(),
ioe );
}
finally
{
@@ -152,7 +152,7 @@ public class AntStructure extends Task
{
for( int i = 0; i < s.length; i++ )
{
if( !isNmtoken( s[i] ) )
if( !isNmtoken( s[ i ] ) )
{
return false;
}
@@ -161,7 +161,7 @@ public class AntStructure extends Task
}

private void printElementDecl( PrintWriter out, String name, Class element )
throws BuildException
throws TaskException
{

if( visited.containsKey( name ) )
@@ -213,7 +213,7 @@ public class AntStructure extends Task
Enumeration enum = ih.getNestedElements();
while( enum.hasMoreElements() )
{
v.addElement( ( String )enum.nextElement() );
v.addElement( (String)enum.nextElement() );
}

if( v.isEmpty() )
@@ -247,7 +247,7 @@ public class AntStructure extends Task
enum = ih.getAttributes();
while( enum.hasMoreElements() )
{
String attrName = ( String )enum.nextElement();
String attrName = (String)enum.nextElement();
if( "id".equals( attrName ) )
continue;

@@ -267,11 +267,11 @@ public class AntStructure extends Task
try
{
EnumeratedAttribute ea =
( EnumeratedAttribute )type.newInstance();
(EnumeratedAttribute)type.newInstance();
String[] values = ea.getValues();
if( values == null
|| values.length == 0
|| !areNmtokens( values ) )
|| values.length == 0
|| !areNmtokens( values ) )
{
sb.append( "CDATA " );
}
@@ -284,7 +284,7 @@ public class AntStructure extends Task
{
sb.append( " | " );
}
sb.append( values[i] );
sb.append( values[ i ] );
}
sb.append( ") " );
}
@@ -309,11 +309,11 @@ public class AntStructure extends Task

for( int i = 0; i < v.size(); i++ )
{
String nestedName = ( String )v.elementAt( i );
String nestedName = (String)v.elementAt( i );
if( !"#PCDATA".equals( nestedName ) &&
!TASKS.equals( nestedName ) &&
!TYPES.equals( nestedName )
)
)
{
printElementDecl( out, nestedName, ih.getElementType( nestedName ) );
}
@@ -329,7 +329,7 @@ public class AntStructure extends Task
boolean first = true;
while( tasks.hasMoreElements() )
{
String taskName = ( String )tasks.nextElement();
String taskName = (String)tasks.nextElement();
if( !first )
{
out.print( " | " );
@@ -345,7 +345,7 @@ public class AntStructure extends Task
first = true;
while( types.hasMoreElements() )
{
String typeName = ( String )types.nextElement();
String typeName = (String)types.nextElement();
if( !first )
{
out.print( " | " );
@@ -370,7 +370,9 @@ public class AntStructure extends Task
out.println( "" );
}

private void printTail( PrintWriter out ) { }
private void printTail( PrintWriter out )
{
}

private void printTargetDecl( PrintWriter out )
{


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

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

import java.io.File;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.condition.Condition;
@@ -16,7 +17,6 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
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
@@ -80,8 +80,7 @@ public class Available
this.resource = resource;
}


public void setType( FileDir type )
public void setType( FileDir type )
{
this.type = type;
}
@@ -114,7 +113,7 @@ public class Available
{
if( classname == null && file == null && resource == null )
{
throw new BuildException( "At least one of (classname|file|resource) is required" );
throw new TaskException( "At least one of (classname|file|resource) is required" );
}

if( type != null )
@@ -169,7 +168,7 @@ public class Available
{
if( property == null )
{
throw new BuildException( "property attribute is required");
throw new TaskException( "property attribute is required" );
}

if( eval() )
@@ -218,6 +217,7 @@ public class Available
}

private boolean checkFile()
throws TaskException
{
if( filepath == null )
{
@@ -228,7 +228,7 @@ public class Available
String[] paths = filepath.list();
for( int i = 0; i < paths.length; ++i )
{
log( "Searching " + paths[i], Project.MSG_DEBUG );
log( "Searching " + paths[ i ], Project.MSG_DEBUG );
/*
* filepath can be a list of directory and/or
* file names (gen'd via <fileset>)
@@ -242,11 +242,11 @@ public class Available
* simple name specified == parent of parent dir + name
*
*/
File path = new File( paths[i] );
File path = new File( paths[ i ] );

// ** full-pathname specified == path in list
// ** simple name specified == path in list
if( path.exists() && file.equals( paths[i] ) )
if( path.exists() && file.equals( paths[ i ] ) )
{
if( type == null )
{
@@ -254,13 +254,13 @@ public class Available
return true;
}
else if( type.isDir()
&& path.isDirectory() )
&& path.isDirectory() )
{
log( "Found directory: " + path, Project.MSG_VERBOSE );
return true;
}
else if( type.isFile()
&& path.isFile() )
&& path.isFile() )
{
log( "Found file: " + path, Project.MSG_VERBOSE );
return true;
@@ -273,7 +273,7 @@ public class Available
File parent = fileUtils.getParentFile( path );
// ** full-pathname specified == parent dir of path in list
if( parent != null && parent.exists()
&& file.equals( parent.getAbsolutePath() ) )
&& file.equals( parent.getAbsolutePath() ) )
{
if( type == null )
{
@@ -293,7 +293,7 @@ public class Available
if( path.exists() && path.isDirectory() )
{
if( checkFile( new File( path, file ),
file + " in " + path ) )
file + " in " + path ) )
{
return true;
}
@@ -303,7 +303,7 @@ public class Available
if( parent != null && parent.exists() )
{
if( checkFile( new File( parent, file ),
file + " in " + parent ) )
file + " in " + parent ) )
{
return true;
}
@@ -316,7 +316,7 @@ public class Available
if( grandParent != null && grandParent.exists() )
{
if( checkFile( new File( grandParent, file ),
file + " in " + grandParent ) )
file + " in " + grandParent ) )
{
return true;
}


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

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

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.bzip2.CBZip2InputStream;

/**
@@ -49,26 +50,26 @@ public class BUnzip2 extends Unpack
int b = bis.read();
if( b != 'B' )
{
throw new BuildException( "Invalid bz2 file." );
throw new TaskException( "Invalid bz2 file." );
}
b = bis.read();
if( b != 'Z' )
{
throw new BuildException( "Invalid bz2 file." );
throw new TaskException( "Invalid bz2 file." );
}
zIn = new CBZip2InputStream( bis );
byte[] buffer = new byte[8 * 1024];
byte[] buffer = new byte[ 8 * 1024 ];
int count = 0;
do
{
out.write( buffer, 0, count );
count = zIn.read( buffer, 0, buffer.length );
}while ( count != -1 );
} while( count != -1 );
}
catch( IOException ioe )
{
String msg = "Problem expanding bzip2 " + ioe.getMessage();
throw new BuildException( msg, ioe );
throw new TaskException( msg, ioe );
}
finally
{
@@ -79,7 +80,8 @@ public class BUnzip2 extends Unpack
bis.close();
}
catch( IOException ioex )
{}
{
}
}
if( fis != null )
{
@@ -88,7 +90,8 @@ public class BUnzip2 extends Unpack
fis.close();
}
catch( IOException ioex )
{}
{
}
}
if( out != null )
{
@@ -97,7 +100,8 @@ public class BUnzip2 extends Unpack
out.close();
}
catch( IOException ioex )
{}
{
}
}
if( zIn != null )
{
@@ -106,7 +110,8 @@ public class BUnzip2 extends Unpack
zIn.close();
}
catch( IOException ioex )
{}
{
}
}
}
}


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

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

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Pack;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.bzip2.CBZip2OutputStream;

/**
@@ -37,7 +37,7 @@ public class BZip2 extends Pack
catch( IOException ioe )
{
String msg = "Problem creating bzip2 " + ioe.getMessage();
throw new BuildException( msg, ioe );
throw new TaskException( msg, ioe );
}
finally
{
@@ -49,7 +49,8 @@ public class BZip2 extends Pack
zOut.close();
}
catch( IOException e )
{}
{
}
}
}
}


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

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

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;

/**
* CVSLogin Adds an new entry to a CVS password file
@@ -100,10 +100,10 @@ public class CVSPass extends Task
/**
* Does the work.
*
* @exception BuildException if someting goes wrong with the build
* @exception TaskException if someting goes wrong with the build
*/
public final void execute()
throws BuildException
throws TaskException
{
if( cvsRoot == null )
throw new TaskException( "cvsroot is required" );
@@ -148,7 +148,7 @@ public class CVSPass extends Task
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}

}
@@ -158,7 +158,7 @@ public class CVSPass extends Task
StringBuffer buf = new StringBuffer();
for( int i = 0; i < password.length(); i++ )
{
buf.append( shifts[password.charAt( i )] );
buf.append( shifts[ password.charAt( i ) ] );
}
return buf.toString();
}


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

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

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -19,13 +20,11 @@ import java.security.NoSuchProviderException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.tools.ant.taskdefs.condition.Condition;
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
@@ -169,10 +168,10 @@ public class Checksum extends MatchingTask implements Condition
*
* @return Returns true if the checksum verification test passed, false
* otherwise.
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public boolean eval()
throws BuildException
throws TaskException
{
isCondition = true;
return validateAndExecute();
@@ -181,16 +180,16 @@ public class Checksum extends MatchingTask implements Condition
/**
* Calculate the checksum(s).
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
boolean value = validateAndExecute();
if( verifyProperty != null )
{
project.setNewProperty( verifyProperty,
new Boolean( value ).toString() );
new Boolean( value ).toString() );
}
}

@@ -198,10 +197,10 @@ public class Checksum extends MatchingTask implements Condition
* Add key-value pair to the hashtable upon which to later operate upon.
*
* @param file The feature to be added to the ToIncludeFileMap attribute
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void addToIncludeFileMap( File file )
throws BuildException
throws TaskException
{
if( file != null )
{
@@ -218,7 +217,7 @@ public class Checksum extends MatchingTask implements Condition
else
{
log( file + " omitted as " + dest + " is up to date.",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
}
}
else
@@ -229,10 +228,10 @@ public class Checksum extends MatchingTask implements Condition
else
{
String message = "Could not find file "
+ file.getAbsolutePath()
+ " to generate checksum for.";
+ file.getAbsolutePath()
+ " to generate checksum for.";
log( message );
throw new BuildException( message );
throw new TaskException( message );
}
}
}
@@ -241,27 +240,27 @@ public class Checksum extends MatchingTask implements Condition
* Generate checksum(s) using the message digest created earlier.
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private boolean generateChecksums()
throws BuildException
throws TaskException
{
boolean checksumMatches = true;
FileInputStream fis = null;
FileOutputStream fos = null;
try
{
for( Enumeration e = includeFileMap.keys(); e.hasMoreElements(); )
for( Enumeration e = includeFileMap.keys(); e.hasMoreElements(); )
{
messageDigest.reset();
File src = ( File )e.nextElement();
File src = (File)e.nextElement();
if( !isCondition )
{
log( "Calculating " + algorithm + " checksum for " + src );
}
fis = new FileInputStream( src );
DigestInputStream dis = new DigestInputStream( fis,
messageDigest );
messageDigest );
while( dis.read() != -1 )
;
dis.close();
@@ -271,7 +270,7 @@ public class Checksum extends MatchingTask implements Condition
String checksum = "";
for( int i = 0; i < fileDigest.length; i++ )
{
String hexStr = Integer.toHexString( 0x00ff & fileDigest[i] );
String hexStr = Integer.toHexString( 0x00ff & fileDigest[ i ] );
if( hexStr.length() < 2 )
{
checksum += "0";
@@ -282,7 +281,7 @@ public class Checksum extends MatchingTask implements Condition
Object destination = includeFileMap.get( src );
if( destination instanceof java.lang.String )
{
String prop = ( String )destination;
String prop = (String)destination;
if( isCondition )
{
checksumMatches = checksum.equals( property );
@@ -296,7 +295,7 @@ public class Checksum extends MatchingTask implements Condition
{
if( isCondition )
{
File existingFile = ( File )destination;
File existingFile = (File)destination;
if( existingFile.exists() &&
existingFile.length() == checksum.length() )
{
@@ -318,7 +317,7 @@ public class Checksum extends MatchingTask implements Condition
}
else
{
File dest = ( File )destination;
File dest = (File)destination;
fos = new FileOutputStream( dest );
fos.write( checksum.getBytes() );
fos.close();
@@ -329,7 +328,7 @@ public class Checksum extends MatchingTask implements Condition
}
catch( Exception e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
finally
{
@@ -340,7 +339,8 @@ public class Checksum extends MatchingTask implements Condition
fis.close();
}
catch( IOException e )
{}
{
}
}
if( fos != null )
{
@@ -349,7 +349,8 @@ public class Checksum extends MatchingTask implements Condition
fos.close();
}
catch( IOException e )
{}
{
}
}
}
return checksumMatches;
@@ -359,10 +360,10 @@ public class Checksum extends MatchingTask implements Condition
* Validate attributes and get down to business.
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private boolean validateAndExecute()
throws BuildException
throws TaskException
{

if( file == null && filesets.size() == 0 )
@@ -466,7 +467,7 @@ public class Checksum extends MatchingTask implements Condition

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

addToIncludeFileMap( file );
@@ -474,12 +475,12 @@ public class Checksum extends MatchingTask implements Condition
int sizeofFileSet = filesets.size();
for( int i = 0; i < sizeofFileSet; i++ )
{
FileSet fs = ( FileSet )filesets.elementAt( i );
FileSet fs = (FileSet)filesets.elementAt( i );
DirectoryScanner ds = fs.getDirectoryScanner( project );
String[] srcFiles = ds.getIncludedFiles();
for( int j = 0; j < srcFiles.length; j++ )
{
File src = new File( fs.getDir( project ), srcFiles[j] );
File src = new File( fs.getDir( project ), srcFiles[ j ] );
addToIncludeFileMap( src );
}
}


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

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

import java.io.File;
import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet;


/**
* Chmod equivalent for unix-like environments.
*
@@ -40,7 +40,7 @@ public class Chmod extends ExecuteOn

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

/**
@@ -72,10 +72,9 @@ public class Chmod extends ExecuteOn
defaultSet.setExcludes( excludes );
}


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

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

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

/**
@@ -143,7 +142,7 @@ public class Chmod extends ExecuteOn
}

public void execute()
throws BuildException
throws TaskException
{
if( defaultSetDefined || defaultSet.getDir( project ) == null )
{
@@ -161,7 +160,7 @@ public class Chmod extends ExecuteOn
}
catch( IOException e )
{
throw new BuildException( "Execute failed: " + e, e );
throw new TaskException( "Execute failed: " + e, e );
}
finally
{
@@ -180,7 +179,7 @@ public class Chmod extends ExecuteOn
{
if( !havePerm )
{
throw new BuildException( "Required attribute perm not set in chmod" );
throw new TaskException( "Required attribute perm not set in chmod" );
}

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


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

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

import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.taskdefs.condition.Condition;
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
@@ -54,7 +54,7 @@ public class ConditionTask extends ConditionBase
/**
* See whether our nested condition holds and set the property.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
* @since 1.1
*/
public void execute()
@@ -68,7 +68,7 @@ public class ConditionTask extends ConditionBase
{
throw new TaskException( "You must nest a condition into <condition>" );
}
Condition c = ( Condition )getConditions().nextElement();
Condition c = (Condition)getConditions().nextElement();
if( c.eval() )
{
getProject().setNewProperty( property, value );


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

@@ -13,7 +13,6 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
@@ -195,14 +194,14 @@ public class Copy extends Task
* Defines the FileNameMapper to use (nested mapper element).
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public Mapper createMapper()
throws BuildException
throws TaskException
{
if( mapperElement != null )
{
throw new BuildException( "Cannot define more than one mapper" );
throw new TaskException( "Cannot define more than one mapper" );
}
mapperElement = new Mapper( project );
return mapperElement;
@@ -211,7 +210,7 @@ public class Copy extends Task
/**
* Performs the copy operation.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws TaskException
@@ -369,7 +368,7 @@ public class Copy extends Task
{
String msg = "Failed to copy " + fromFile + " to " + toFile
+ " due to " + ioe.getMessage();
throw new BuildException( msg, ioe );
throw new TaskException( msg, ioe );
}
}
}
@@ -445,7 +444,7 @@ public class Copy extends Task
* Ensure we have a consistent and legal set of attributes, and set any
* internal flags necessary based on different combinations of attributes.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected void validateAttributes()
throws TaskException


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

@@ -14,7 +14,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline;
@@ -189,7 +188,6 @@ public class Cvs extends Task
public void execute()
throws TaskException
{

// XXX: we should use JCVS (www.ice.com/JCVS) instead of command line
// execution so that we don't rely on having native CVS stuff around (SM)



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

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

import java.io.File;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
@@ -109,7 +110,6 @@ public class Delete extends MatchingTask
this.file = file;
}


/**
* Used to delete empty directories.
*
@@ -225,10 +225,10 @@ public class Delete extends MatchingTask
/**
* Delete the file(s).
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
if( usedMatchingTask )
{
@@ -237,12 +237,12 @@ public class Delete extends MatchingTask

if( file == null && dir == null && filesets.size() == 0 )
{
throw new BuildException( "At least one of the file or dir attributes, or a fileset element, must be set." );
throw new TaskException( "At least one of the file or dir attributes, or a fileset element, must be set." );
}

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

// delete the single file
@@ -262,17 +262,17 @@ public class Delete extends MatchingTask
{
String message = "Unable to delete file " + file.getAbsolutePath();
if( failonerror )
throw new BuildException( message );
throw new TaskException( message );
else
log( message,
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
}
}
}
else
{
log( "Could not find file " + file.getAbsolutePath() + " to delete.",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
}
}

@@ -295,7 +295,7 @@ public class Delete extends MatchingTask
// delete the files in the filesets
for( int i = 0; i < filesets.size(); i++ )
{
FileSet fs = ( FileSet )filesets.elementAt( i );
FileSet fs = (FileSet)filesets.elementAt( i );
try
{
DirectoryScanner ds = fs.getDirectoryScanner( project );
@@ -303,7 +303,7 @@ public class Delete extends MatchingTask
String[] dirs = ds.getIncludedDirectories();
removeFiles( fs.getDir( project ), files, dirs );
}
catch( BuildException be )
catch( TaskException be )
{
// directory doesn't exist or is not readable
if( failonerror )
@@ -313,7 +313,7 @@ public class Delete extends MatchingTask
else
{
log( be.getMessage(),
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
}
}
}
@@ -328,7 +328,7 @@ public class Delete extends MatchingTask
String[] dirs = ds.getIncludedDirectories();
removeFiles( dir, files, dirs );
}
catch( BuildException be )
catch( TaskException be )
{
// directory doesn't exist or is not readable
if( failonerror )
@@ -338,24 +338,24 @@ public class Delete extends MatchingTask
else
{
log( be.getMessage(),
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
}
}
}
}

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

protected void removeDir( File d )
{
String[] list = d.list();
if( list == null )
list = new String[0];
list = new String[ 0 ];
for( int i = 0; i < list.length; i++ )
{
String s = list[i];
String s = list[ i ];
File f = new File( d, s );
if( f.isDirectory() )
{
@@ -368,10 +368,10 @@ public class Delete extends MatchingTask
{
String message = "Unable to delete file " + f.getAbsolutePath();
if( failonerror )
throw new BuildException( message );
throw new TaskException( message );
else
log( message,
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
}
}
}
@@ -380,10 +380,10 @@ public class Delete extends MatchingTask
{
String message = "Unable to delete directory " + dir.getAbsolutePath();
if( failonerror )
throw new BuildException( message );
throw new TaskException( message );
else
log( message,
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
}
}

@@ -402,16 +402,16 @@ public class Delete extends MatchingTask
log( "Deleting " + files.length + " files from " + d.getAbsolutePath() );
for( int j = 0; j < files.length; j++ )
{
File f = new File( d, files[j] );
File f = new File( d, files[ j ] );
log( "Deleting " + f.getAbsolutePath(), verbosity );
if( !f.delete() )
{
String message = "Unable to delete file " + f.getAbsolutePath();
if( failonerror )
throw new BuildException( message );
throw new TaskException( message );
else
log( message,
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
}
}
}
@@ -421,7 +421,7 @@ public class Delete extends MatchingTask
int dirCount = 0;
for( int j = dirs.length - 1; j >= 0; j-- )
{
File dir = new File( d, dirs[j] );
File dir = new File( d, dirs[ j ] );
String[] dirFiles = dir.list();
if( dirFiles == null || dirFiles.length == 0 )
{
@@ -429,12 +429,12 @@ public class Delete extends MatchingTask
if( !dir.delete() )
{
String message = "Unable to delete directory "
+ dir.getAbsolutePath();
+ dir.getAbsolutePath();
if( failonerror )
throw new BuildException( message );
throw new TaskException( message );
else
log( message,
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
quiet ? Project.MSG_VERBOSE : Project.MSG_WARN );
}
else
{
@@ -446,8 +446,8 @@ public class Delete extends MatchingTask
if( dirCount > 0 )
{
log( "Deleted " + dirCount + " director" +
( dirCount == 1 ? "y" : "ies" ) +
" from " + d.getAbsolutePath() );
( dirCount == 1 ? "y" : "ies" ) +
" from " + d.getAbsolutePath() );
}
}
}


+ 35
- 34
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/DependSet.java View File

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

import java.io.File;
import java.util.Date;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.types.FileList;
import org.apache.tools.ant.types.FileSet;

@@ -72,7 +73,9 @@ public class DependSet extends MatchingTask
/**
* Creates a new DependSet Task.
*/
public DependSet() { }
public DependSet()
{
}

/**
* Nested &lt;srcfilelist&gt; element.
@@ -117,21 +120,19 @@ public class DependSet extends MatchingTask
/**
* Executes the task.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/

public void execute()
throws BuildException
throws TaskException
{

if( ( sourceFileSets.size() == 0 ) && ( sourceFileLists.size() == 0 ) )
{
throw new BuildException( "At least one <srcfileset> or <srcfilelist> element must be set" );
throw new TaskException( "At least one <srcfileset> or <srcfilelist> element must be set" );
}

if( ( targetFileSets.size() == 0 ) && ( targetFileLists.size() == 0 ) )
{
throw new BuildException( "At least one <targetfileset> or <targetfilelist> element must be set" );
throw new TaskException( "At least one <targetfileset> or <targetfilelist> element must be set" );
}

long now = ( new Date() ).getTime();
@@ -153,20 +154,20 @@ public class DependSet extends MatchingTask
while( enumTargetSets.hasMoreElements() )
{

FileSet targetFS = ( FileSet )enumTargetSets.nextElement();
FileSet targetFS = (FileSet)enumTargetSets.nextElement();
DirectoryScanner targetDS = targetFS.getDirectoryScanner( project );
String[] targetFiles = targetDS.getIncludedFiles();

for( int i = 0; i < targetFiles.length; i++ )
{

File dest = new File( targetFS.getDir( project ), targetFiles[i] );
File dest = new File( targetFS.getDir( project ), targetFiles[ i ] );
allTargets.addElement( dest );

if( dest.lastModified() > now )
{
log( "Warning: " + targetFiles[i] + " modified in the future.",
Project.MSG_WARN );
log( "Warning: " + targetFiles[ i ] + " modified in the future.",
Project.MSG_WARN );
}
}
}
@@ -179,16 +180,16 @@ public class DependSet extends MatchingTask
while( enumTargetLists.hasMoreElements() )
{

FileList targetFL = ( FileList )enumTargetLists.nextElement();
FileList targetFL = (FileList)enumTargetLists.nextElement();
String[] targetFiles = targetFL.getFiles( project );

for( int i = 0; i < targetFiles.length; i++ )
{

File dest = new File( targetFL.getDir( project ), targetFiles[i] );
File dest = new File( targetFL.getDir( project ), targetFiles[ i ] );
if( !dest.exists() )
{
log( targetFiles[i] + " does not exist.", Project.MSG_VERBOSE );
log( targetFiles[ i ] + " does not exist.", Project.MSG_VERBOSE );
upToDate = false;
continue;
}
@@ -198,8 +199,8 @@ public class DependSet extends MatchingTask
}
if( dest.lastModified() > now )
{
log( "Warning: " + targetFiles[i] + " modified in the future.",
Project.MSG_WARN );
log( "Warning: " + targetFiles[ i ] + " modified in the future.",
Project.MSG_WARN );
}
}
}
@@ -213,29 +214,29 @@ public class DependSet extends MatchingTask
while( upToDate && enumSourceSets.hasMoreElements() )
{

FileSet sourceFS = ( FileSet )enumSourceSets.nextElement();
FileSet sourceFS = (FileSet)enumSourceSets.nextElement();
DirectoryScanner sourceDS = sourceFS.getDirectoryScanner( project );
String[] sourceFiles = sourceDS.getIncludedFiles();

for( int i = 0; upToDate && i < sourceFiles.length; i++ )
{
File src = new File( sourceFS.getDir( project ), sourceFiles[i] );
File src = new File( sourceFS.getDir( project ), sourceFiles[ i ] );

if( src.lastModified() > now )
{
log( "Warning: " + sourceFiles[i] + " modified in the future.",
Project.MSG_WARN );
log( "Warning: " + sourceFiles[ i ] + " modified in the future.",
Project.MSG_WARN );
}

Enumeration enumTargets = allTargets.elements();
while( upToDate && enumTargets.hasMoreElements() )
{

File dest = ( File )enumTargets.nextElement();
File dest = (File)enumTargets.nextElement();
if( src.lastModified() > dest.lastModified() )
{
log( dest.getPath() + " is out of date with respect to " +
sourceFiles[i], Project.MSG_VERBOSE );
sourceFiles[ i ], Project.MSG_VERBOSE );
upToDate = false;

}
@@ -253,23 +254,23 @@ public class DependSet extends MatchingTask
while( upToDate && enumSourceLists.hasMoreElements() )
{

FileList sourceFL = ( FileList )enumSourceLists.nextElement();
FileList sourceFL = (FileList)enumSourceLists.nextElement();
String[] sourceFiles = sourceFL.getFiles( project );

int i = 0;
do
{
File src = new File( sourceFL.getDir( project ), sourceFiles[i] );
File src = new File( sourceFL.getDir( project ), sourceFiles[ i ] );

if( src.lastModified() > now )
{
log( "Warning: " + sourceFiles[i] + " modified in the future.",
Project.MSG_WARN );
log( "Warning: " + sourceFiles[ i ] + " modified in the future.",
Project.MSG_WARN );
}

if( !src.exists() )
{
log( sourceFiles[i] + " does not exist.", Project.MSG_VERBOSE );
log( sourceFiles[ i ] + " does not exist.", Project.MSG_VERBOSE );
upToDate = false;
break;
}
@@ -278,26 +279,26 @@ public class DependSet extends MatchingTask
while( upToDate && enumTargets.hasMoreElements() )
{

File dest = ( File )enumTargets.nextElement();
File dest = (File)enumTargets.nextElement();

if( src.lastModified() > dest.lastModified() )
{
log( dest.getPath() + " is out of date with respect to " +
sourceFiles[i], Project.MSG_VERBOSE );
sourceFiles[ i ], Project.MSG_VERBOSE );
upToDate = false;

}
}
}while ( upToDate && ( ++i < sourceFiles.length ) );
} while( upToDate && ( ++i < sourceFiles.length ) );
}
}

if( !upToDate )
{
log( "Deleting all target files. ", Project.MSG_VERBOSE );
for( Enumeration e = allTargets.elements(); e.hasMoreElements(); )
for( Enumeration e = allTargets.elements(); e.hasMoreElements(); )
{
File fileToRemove = ( File )e.nextElement();
File fileToRemove = (File)e.nextElement();
log( "Deleting file " + fileToRemove.getAbsolutePath(), Project.MSG_VERBOSE );
fileToRemove.delete();
}


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

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

import java.io.File;
import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.ZipFileSet;
import org.apache.tools.zip.ZipOutputStream;


/**
* Creates a EAR archive. Based on WAR task
*
@@ -37,7 +37,7 @@ public class Ear extends Jar
{
deploymentDescriptor = descr;
if( !deploymentDescriptor.exists() )
throw new BuildException( "Deployment descriptor: " + deploymentDescriptor + " does not exist." );
throw new TaskException( "Deployment descriptor: " + deploymentDescriptor + " does not exist." );

// Create a ZipFileSet for this file, and pass it up.
ZipFileSet fs = new ZipFileSet();
@@ -66,14 +66,13 @@ public class Ear extends Jar
super.cleanUp();
}


protected void initZipOutputStream( ZipOutputStream zOut )
throws IOException, BuildException
throws IOException, TaskException
{
// If no webxml file is specified, it's an error.
if( deploymentDescriptor == null && !isInUpdateMode() )
{
throw new BuildException( "appxml attribute is required" );
throw new TaskException( "appxml attribute is required" );
}

super.initZipOutputStream( zOut );
@@ -91,7 +90,7 @@ public class Ear extends Jar
if( deploymentDescriptor == null || !deploymentDescriptor.equals( file ) || descriptorAdded )
{
log( "Warning: selected " + archiveType + " files include a META-INF/application.xml which will be ignored " +
"(please use appxml attribute to " + archiveType + " task)", Project.MSG_WARN );
"(please use appxml attribute to " + archiveType + " task)", Project.MSG_WARN );
}
else
{


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

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

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.EnumeratedAttribute;

@@ -113,10 +113,10 @@ public class Echo extends Task
/**
* Does the work.
*
* @exception BuildException if someting goes wrong with the build
* @exception TaskException if someting goes wrong with the build
*/
public void execute()
throws BuildException
throws TaskException
{
if( file == null )
{
@@ -132,7 +132,7 @@ public class Echo extends Task
}
catch( IOException ioe )
{
throw new BuildException( "Error", ioe);
throw new TaskException( "Error", ioe );
}
finally
{
@@ -143,7 +143,8 @@ public class Echo extends Task
out.close();
}
catch( IOException ioex )
{}
{
}
}
}
}


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

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

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -13,7 +14,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.StringReader;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline;
@@ -83,7 +84,7 @@ public class ExecTask extends Task
}

/**
* Throw a BuildException if process returns non 0.
* Throw a TaskException if process returns non 0.
*
* @param fail The new Failonerror value
*/
@@ -189,10 +190,10 @@ public class ExecTask extends Task
/**
* Do the work.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
checkConfiguration();
if( isValidOs() )
@@ -243,7 +244,7 @@ public class ExecTask extends Task
{
if( failOnError )
{
throw new BuildException( taskType + " returned: " + err );
throw new TaskException( taskType + " returned: " + err );
}
else
{
@@ -271,22 +272,22 @@ public class ExecTask extends Task
/**
* Has the user set all necessary attributes?
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected void checkConfiguration()
throws BuildException
throws TaskException
{
if( cmdl.getExecutable() == null )
{
throw new BuildException( "no executable specified" );
throw new TaskException( "no executable specified" );
}
if( dir != null && !dir.exists() )
{
throw new BuildException( "The directory you specified does not exist" );
throw new TaskException( "The directory you specified does not exist" );
}
if( dir != null && !dir.isDirectory() )
{
throw new BuildException( "The directory you specified is not a directory" );
throw new TaskException( "The directory you specified is not a directory" );
}
}

@@ -294,10 +295,10 @@ public class ExecTask extends Task
* Create the StreamHandler to use with our Execute instance.
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected ExecuteStreamHandler createHandler()
throws BuildException
throws TaskException
{
if( out != null )
{
@@ -309,11 +310,11 @@ public class ExecTask extends Task
}
catch( FileNotFoundException fne )
{
throw new BuildException( "Cannot write to " + out, fne );
throw new TaskException( "Cannot write to " + out, fne );
}
catch( IOException ioe )
{
throw new BuildException( "Cannot write to " + out, ioe );
throw new TaskException( "Cannot write to " + out, ioe );
}
}
else if( outputprop != null )
@@ -325,7 +326,7 @@ public class ExecTask extends Task
else
{
return new LogStreamHandler( this,
Project.MSG_INFO, Project.MSG_WARN );
Project.MSG_INFO, Project.MSG_WARN );
}
}

@@ -333,10 +334,10 @@ public class ExecTask extends Task
* Create the Watchdog to kill a runaway process.
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected ExecuteWatchdog createWatchdog()
throws BuildException
throws TaskException
{
if( timeout == null )
return null;
@@ -356,7 +357,8 @@ public class ExecTask extends Task
baos.close();
}
catch( IOException io )
{}
{
}
}

/**
@@ -378,10 +380,10 @@ public class ExecTask extends Task
* Create an Execute instance with the correct working directory set.
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected Execute prepareExec()
throws BuildException
throws TaskException
{
// default directory to the project's base directory
if( dir == null )
@@ -398,8 +400,8 @@ public class ExecTask extends Task
{
for( int i = 0; i < environment.length; i++ )
{
log( "Setting environment variable: " + environment[i],
Project.MSG_VERBOSE );
log( "Setting environment variable: " + environment[ i ],
Project.MSG_VERBOSE );
}
}
exe.setNewenvironment( newEnvironment );
@@ -412,10 +414,10 @@ public class ExecTask extends Task
* by subclasses
*
* @param exe Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected void runExec( Execute exe )
throws BuildException
throws TaskException
{
exe.setCommandline( cmdl.getCommandline() );
try
@@ -426,7 +428,7 @@ public class ExecTask extends Task
{
if( failIfExecFails )
{
throw new BuildException( "Execute failed: " + e.toString(), e );
throw new TaskException( "Execute failed: " + e.toString(), e );
}
else
{


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

@@ -18,11 +18,10 @@ import java.util.Locale;
import java.util.Vector;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.util.FileUtils;

/**
* Runs an external program.
@@ -245,10 +244,10 @@ public class Execute
*
* @param task The task that the command is part of. Used for logging
* @param cmdline The command to execute.
* @throws BuildException if the command does not return 0.
* @throws TaskException if the command does not return 0.
*/
public static void runCommand( Task task, String[] cmdline )
throws BuildException
throws TaskException
{
try
{
@@ -261,12 +260,12 @@ public class Execute
int retval = exe.execute();
if( retval != 0 )
{
throw new BuildException( cmdline[ 0 ] + " failed with return code " + retval );
throw new TaskException( cmdline[ 0 ] + " failed with return code " + retval );
}
}
catch( java.io.IOException exc )
{
throw new BuildException( "Could not launch " + cmdline[ 0 ] + ": " + exc );
throw new TaskException( "Could not launch " + cmdline[ 0 ] + ": " + exc );
}
}

@@ -322,10 +321,10 @@ public class Execute
* Set the name of the antRun script using the project's value.
*
* @param project the current project.
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void setAntRun( Project project )
throws BuildException
throws TaskException
{
this.project = project;
}
@@ -707,13 +706,13 @@ public class Execute
}
else
{
throw new BuildException( "Unable to execute command", realexc );
throw new TaskException( "Unable to execute command", realexc );
}
}
catch( Exception exc )
{
// IllegalAccess, IllegalArgument, ClassCast
throw new BuildException( "Unable to execute command", exc );
throw new TaskException( "Unable to execute command", exc );
}
}
}


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

@@ -6,11 +6,11 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.CommandlineJava;
@@ -20,6 +20,7 @@ import org.apache.tools.ant.types.Path;
* @author thomas.haas@softwired-inc.com
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/

public class ExecuteJava
{

@@ -43,7 +44,7 @@ public class ExecuteJava
}

public void execute( Project project )
throws BuildException
throws TaskException
{
final String classname = javaCommand.getExecutable();
final Object[] argument = {javaCommand.getArguments()};
@@ -75,27 +76,27 @@ public class ExecuteJava
}
catch( NullPointerException e )
{
throw new BuildException( "Could not find main() method in " + classname );
throw new TaskException( "Could not find main() method in " + classname );
}
catch( ClassNotFoundException e )
{
throw new BuildException( "Could not find " + classname + ". Make sure you have it in your classpath" );
throw new TaskException( "Could not find " + classname + ". Make sure you have it in your classpath" );
}
catch( InvocationTargetException e )
{
Throwable t = e.getTargetException();
if( !( t instanceof SecurityException ) )
{
throw new BuildException( "Error", t );
throw new TaskException( "Error", t );
}
else
{
throw ( SecurityException )t;
throw (SecurityException)t;
}
}
catch( Exception e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
finally
{


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

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

import java.io.File;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;
@@ -55,7 +56,6 @@ public class ExecuteOn extends ExecTask
this.destDir = destDir;
}


/**
* Shall the command work on all specified files in parallel?
*
@@ -110,14 +110,14 @@ public class ExecuteOn extends ExecTask
* Defines the FileNameMapper to use (nested mapper element).
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public Mapper createMapper()
throws BuildException
throws TaskException
{
if( mapperElement != null )
{
throw new BuildException( "Cannot define more than one mapper" );
throw new TaskException( "Cannot define more than one mapper" );
}
mapperElement = new Mapper( project );
return mapperElement;
@@ -133,7 +133,7 @@ public class ExecuteOn extends ExecTask
{
if( srcFilePos != null )
{
throw new BuildException( taskType + " doesn\'t support multiple srcfile elements." );
throw new TaskException( taskType + " doesn\'t support multiple srcfile elements." );
}
srcFilePos = cmdl.createMarker();
return srcFilePos;
@@ -149,7 +149,7 @@ public class ExecuteOn extends ExecTask
{
if( targetFilePos != null )
{
throw new BuildException( taskType + " doesn\'t support multiple targetfile elements." );
throw new TaskException( taskType + " doesn\'t support multiple targetfile elements." );
}
targetFilePos = cmdl.createMarker();
srcIsFirst = ( srcFilePos != null );
@@ -171,7 +171,7 @@ public class ExecuteOn extends ExecTask
Hashtable addedFiles = new Hashtable();
for( int i = 0; i < srcFiles.length; i++ )
{
String[] subTargets = mapper.mapFileName( srcFiles[i] );
String[] subTargets = mapper.mapFileName( srcFiles[ i ] );
if( subTargets != null )
{
for( int j = 0; j < subTargets.length; j++ )
@@ -180,11 +180,11 @@ public class ExecuteOn extends ExecTask
if( !relative )
{
name =
( new File( destDir, subTargets[j] ) ).getAbsolutePath();
( new File( destDir, subTargets[ j ] ) ).getAbsolutePath();
}
else
{
name = subTargets[j];
name = subTargets[ j ];
}
if( !addedFiles.contains( name ) )
{
@@ -195,11 +195,11 @@ public class ExecuteOn extends ExecTask
}
}
}
String[] targetFiles = new String[targets.size()];
String[] targetFiles = new String[ targets.size() ];
targets.copyInto( targetFiles );

String[] orig = cmdl.getCommandline();
String[] result = new String[orig.length + srcFiles.length + targetFiles.length];
String[] result = new String[ orig.length + srcFiles.length + targetFiles.length ];

int srcIndex = orig.length;
if( srcFilePos != null )
@@ -212,7 +212,7 @@ public class ExecuteOn extends ExecTask
int targetIndex = targetFilePos.getPosition();

if( srcIndex < targetIndex
|| ( srcIndex == targetIndex && srcIsFirst ) )
|| ( srcIndex == targetIndex && srcIsFirst ) )
{

// 0 --> srcIndex
@@ -220,18 +220,18 @@ public class ExecuteOn extends ExecTask

// srcIndex --> targetIndex
System.arraycopy( orig, srcIndex, result,
srcIndex + srcFiles.length,
targetIndex - srcIndex );
srcIndex + srcFiles.length,
targetIndex - srcIndex );

// targets are already absolute file names
System.arraycopy( targetFiles, 0, result,
targetIndex + srcFiles.length,
targetFiles.length );
targetIndex + srcFiles.length,
targetFiles.length );

// targetIndex --> end
System.arraycopy( orig, targetIndex, result,
targetIndex + srcFiles.length + targetFiles.length,
orig.length - targetIndex );
targetIndex + srcFiles.length + targetFiles.length,
orig.length - targetIndex );
}
else
{
@@ -240,18 +240,18 @@ public class ExecuteOn extends ExecTask

// targets are already absolute file names
System.arraycopy( targetFiles, 0, result,
targetIndex,
targetFiles.length );
targetIndex,
targetFiles.length );

// targetIndex --> srcIndex
System.arraycopy( orig, targetIndex, result,
targetIndex + targetFiles.length,
srcIndex - targetIndex );
targetIndex + targetFiles.length,
srcIndex - targetIndex );

// srcIndex --> end
System.arraycopy( orig, srcIndex, result,
srcIndex + srcFiles.length + targetFiles.length,
orig.length - srcIndex );
srcIndex + srcFiles.length + targetFiles.length,
orig.length - srcIndex );
srcIndex += targetFiles.length;
}

@@ -263,8 +263,8 @@ public class ExecuteOn extends ExecTask
System.arraycopy( orig, 0, result, 0, srcIndex );
// srcIndex --> end
System.arraycopy( orig, srcIndex, result,
srcIndex + srcFiles.length,
orig.length - srcIndex );
srcIndex + srcFiles.length,
orig.length - srcIndex );

}

@@ -273,12 +273,12 @@ public class ExecuteOn extends ExecTask
{
if( !relative )
{
result[srcIndex + i] =
( new File( baseDirs[i], srcFiles[i] ) ).getAbsolutePath();
result[ srcIndex + i ] =
( new File( baseDirs[ i ], srcFiles[ i ] ) ).getAbsolutePath();
}
else
{
result[srcIndex + i] = srcFiles[i];
result[ srcIndex + i ] = srcFiles[ i ];
}
}
return result;
@@ -310,7 +310,7 @@ public class ExecuteOn extends ExecTask
{
SourceFileScanner sfs = new SourceFileScanner( this );
return sfs.restrict( ds.getIncludedDirectories(), baseDir, destDir,
mapper );
mapper );
}
else
{
@@ -332,7 +332,7 @@ public class ExecuteOn extends ExecTask
{
SourceFileScanner sfs = new SourceFileScanner( this );
return sfs.restrict( ds.getIncludedFiles(), baseDir, destDir,
mapper );
mapper );
}
else
{
@@ -345,27 +345,27 @@ public class ExecuteOn extends ExecTask
super.checkConfiguration();
if( filesets.size() == 0 )
{
throw new BuildException( "no filesets specified" );
throw new TaskException( "no filesets specified" );
}

if( targetFilePos != null || mapperElement != null
|| destDir != null )
|| destDir != null )
{

if( mapperElement == null )
{
throw new BuildException( "no mapper specified" );
throw new TaskException( "no mapper specified" );
}
if( mapperElement == null )
{
throw new BuildException( "no dest attribute specified" );
throw new TaskException( "no dest attribute specified" );
}
mapper = mapperElement.getImplementation();
}
}

protected void runExec( Execute exe )
throws BuildException
throws TaskException
{
try
{
@@ -374,7 +374,7 @@ public class ExecuteOn extends ExecTask
Vector baseDirs = new Vector();
for( int i = 0; i < filesets.size(); i++ )
{
FileSet fs = ( FileSet )filesets.elementAt( i );
FileSet fs = (FileSet)filesets.elementAt( i );
File base = fs.getDir( project );
DirectoryScanner ds = fs.getDirectoryScanner( project );

@@ -383,7 +383,7 @@ public class ExecuteOn extends ExecTask
String[] s = getFiles( base, ds );
for( int j = 0; j < s.length; j++ )
{
fileNames.addElement( s[j] );
fileNames.addElement( s[ j ] );
baseDirs.addElement( base );
}
}
@@ -394,7 +394,7 @@ public class ExecuteOn extends ExecTask
;
for( int j = 0; j < s.length; j++ )
{
fileNames.addElement( s[j] );
fileNames.addElement( s[ j ] );
baseDirs.addElement( base );
}
}
@@ -408,13 +408,13 @@ public class ExecuteOn extends ExecTask

if( !parallel )
{
String[] s = new String[fileNames.size()];
String[] s = new String[ fileNames.size() ];
fileNames.copyInto( s );
for( int j = 0; j < s.length; j++ )
{
String[] command = getCommandline( s[j], base );
String[] command = getCommandline( s[ j ], base );
log( "Executing " + Commandline.toString( command ),
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
exe.setCommandline( command );
runExecute( exe );
}
@@ -425,13 +425,13 @@ public class ExecuteOn extends ExecTask

if( parallel && ( fileNames.size() > 0 || !skipEmpty ) )
{
String[] s = new String[fileNames.size()];
String[] s = new String[ fileNames.size() ];
fileNames.copyInto( s );
File[] b = new File[baseDirs.size()];
File[] b = new File[ baseDirs.size() ];
baseDirs.copyInto( b );
String[] command = getCommandline( s, b );
log( "Executing " + Commandline.toString( command ),
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
exe.setCommandline( command );
runExecute( exe );
}
@@ -439,7 +439,7 @@ public class ExecuteOn extends ExecTask
}
catch( IOException e )
{
throw new BuildException( "Execute failed: " + e, e );
throw new TaskException( "Execute failed: " + e, e );
}
finally
{


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

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

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;


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

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

import org.apache.myrmidon.api.TaskException;

/**
* Destroys a process running for too long. For example: <pre>
@@ -84,16 +85,16 @@ public class ExecuteWatchdog implements Runnable
* been terminated either by 'error', timeout or manual intervention.
* Information will be discarded once a new process is ran.
*
* @throws BuildException a wrapped exception over the one that was silently
* @throws TaskException a wrapped exception over the one that was silently
* swallowed and stored during the process run.
*/
public void checkException()
throws BuildException
throws TaskException
{
if( caught != null )
{
throw new BuildException( "Exception in ExecuteWatchdog.run: "
+ caught.getMessage(), caught );
throw new TaskException( "Exception in ExecuteWatchdog.run: "
+ caught.getMessage(), caught );
}
}

@@ -108,7 +109,6 @@ public class ExecuteWatchdog implements Runnable
return killedProcess;
}


/**
* Watches the process and terminates it, if it runs for to long.
*/
@@ -127,7 +127,8 @@ public class ExecuteWatchdog implements Runnable
wait( until - now );
}
catch( InterruptedException e )
{}
{
}
}

// if we are here, either someone stopped the watchdog,


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

@@ -6,8 +6,8 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ProjectHelper;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;

/**
@@ -46,17 +46,17 @@ public class Exit extends Task
}

public void execute()
throws BuildException
throws TaskException
{
if( testIfCondition() && testUnlessCondition() )
{
if( message != null && message.length() > 0 )
{
throw new BuildException( message );
throw new TaskException( message );
}
else
{
throw new BuildException( "No message" );
throw new TaskException( "No message" );
}
}
}


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

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -16,7 +17,7 @@ import java.util.Date;
import java.util.Vector;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
@@ -93,25 +94,25 @@ public class Expand extends MatchingTask
/**
* Do the work.
*
* @exception BuildException Thrown in unrecoverable error.
* @exception TaskException Thrown in unrecoverable error.
*/
public void execute()
throws BuildException
throws TaskException
{
if( source == null && filesets.size() == 0 )
{
throw new BuildException( "src attribute and/or filesets must be specified" );
throw new TaskException( "src attribute and/or filesets must be specified" );
}

if( dest == null )
{
throw new BuildException(
throw new TaskException(
"Dest attribute must be specified" );
}

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

FileUtils fileUtils = FileUtils.newFileUtils();
@@ -120,8 +121,8 @@ public class Expand extends MatchingTask
{
if( source.isDirectory() )
{
throw new BuildException( "Src must not be a directory." +
" Use nested filesets instead." );
throw new TaskException( "Src must not be a directory." +
" Use nested filesets instead." );
}
else
{
@@ -132,14 +133,14 @@ public class Expand extends MatchingTask
{
for( int j = 0; j < filesets.size(); j++ )
{
FileSet fs = ( FileSet )filesets.elementAt( j );
FileSet fs = (FileSet)filesets.elementAt( j );
DirectoryScanner ds = fs.getDirectoryScanner( project );
File fromDir = fs.getDir( project );

String[] files = ds.getIncludedFiles();
for( int i = 0; i < files.length; ++i )
{
File file = new File( fromDir, files[i] );
File file = new File( fromDir, files[ i ] );
expandFile( fileUtils, file, dest );
}
}
@@ -161,16 +162,16 @@ public class Expand extends MatchingTask
while( ( ze = zis.getNextEntry() ) != null )
{
extractFile( fileUtils, srcF, dir, zis,
ze.getName(),
new Date( ze.getTime() ),
ze.isDirectory() );
ze.getName(),
new Date( ze.getTime() ),
ze.isDirectory() );
}

log( "expand complete", Project.MSG_VERBOSE );
}
catch( IOException ioe )
{
throw new BuildException( "Error while expanding " + srcF.getPath(), ioe );
throw new TaskException( "Error while expanding " + srcF.getPath(), ioe );
}
finally
{
@@ -181,7 +182,8 @@ public class Expand extends MatchingTask
zis.close();
}
catch( IOException e )
{}
{
}
}
}
}
@@ -199,13 +201,13 @@ public class Expand extends MatchingTask
boolean included = false;
for( int v = 0; v < patternsets.size(); v++ )
{
PatternSet p = ( PatternSet )patternsets.elementAt( v );
PatternSet p = (PatternSet)patternsets.elementAt( v );
String[] incls = p.getIncludePatterns( project );
if( incls != null )
{
for( int w = 0; w < incls.length; w++ )
{
boolean isIncl = DirectoryScanner.match( incls[w], name );
boolean isIncl = DirectoryScanner.match( incls[ w ], name );
if( isIncl )
{
included = true;
@@ -218,7 +220,7 @@ public class Expand extends MatchingTask
{
for( int w = 0; w < excls.length; w++ )
{
boolean isExcl = DirectoryScanner.match( excls[w], name );
boolean isExcl = DirectoryScanner.match( excls[ w ], name );
if( isExcl )
{
included = false;
@@ -238,15 +240,15 @@ public class Expand extends MatchingTask
try
{
if( !overwrite && f.exists()
&& f.lastModified() >= entryDate.getTime() )
&& f.lastModified() >= entryDate.getTime() )
{
log( "Skipping " + f + " as it is up-to-date",
Project.MSG_DEBUG );
Project.MSG_DEBUG );
return;
}

log( "expanding " + entryName + " to " + f,
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
// create intermediary directories - sometimes zip don't add them
File dirF = fileUtils.getParentFile( f );
dirF.mkdirs();
@@ -257,7 +259,7 @@ public class Expand extends MatchingTask
}
else
{
byte[] buffer = new byte[1024];
byte[] buffer = new byte[ 1024 ];
int length = 0;
FileOutputStream fos = null;
try
@@ -282,7 +284,8 @@ public class Expand extends MatchingTask
fos.close();
}
catch( IOException e )
{}
{
}
}
}
}


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

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

import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;

@@ -44,14 +45,14 @@ public class Filter extends Task
}

public void execute()
throws BuildException
throws TaskException
{
boolean isFiltersFromFile = filtersFile != null && token == null && value == null;
boolean isSingleFilter = filtersFile == null && token != null && value != null;

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

if( isSingleFilter )
@@ -66,7 +67,7 @@ public class Filter extends Task
}

protected void readFilters()
throws BuildException
throws TaskException
{
log( "Reading filters from " + filtersFile, Project.MSG_VERBOSE );
project.getGlobalFilterSet().readFiltersFromFile( filtersFile );


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

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

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -20,7 +21,7 @@ import java.io.Reader;
import java.io.Writer;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.EnumeratedAttribute;
@@ -192,7 +193,6 @@ public class FixCRLF extends MatchingTask
}
}


/**
* Specify how EndOfLine characters are to be handled
*
@@ -270,14 +270,14 @@ public class FixCRLF extends MatchingTask
* Specify tab length in characters
*
* @param tlength specify the length of tab in spaces,
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void setTablength( int tlength )
throws BuildException
throws TaskException
{
if( tlength < 2 || tlength > 80 )
{
throw new BuildException( "tablength must be between 2 and 80" );
throw new TaskException( "tablength must be between 2 and 80" );
}
tablength = tlength;
StringBuffer sp = new StringBuffer();
@@ -291,53 +291,53 @@ public class FixCRLF extends MatchingTask
/**
* Executes the task.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
// first off, make sure that we've got a srcdir and destdir

if( srcDir == null )
{
throw new BuildException( "srcdir attribute must be set!" );
throw new TaskException( "srcdir attribute must be set!" );
}
if( !srcDir.exists() )
{
throw new BuildException( "srcdir does not exist!" );
throw new TaskException( "srcdir does not exist!" );
}
if( !srcDir.isDirectory() )
{
throw new BuildException( "srcdir is not a directory!" );
throw new TaskException( "srcdir is not a directory!" );
}
if( destDir != null )
{
if( !destDir.exists() )
{
throw new BuildException( "destdir does not exist!" );
throw new TaskException( "destdir does not exist!" );
}
if( !destDir.isDirectory() )
{
throw new BuildException( "destdir is not a directory!" );
throw new TaskException( "destdir is not a directory!" );
}
}

// log options used
log( "options:" +
" eol=" +
( eol == ASIS ? "asis" : eol == CR ? "cr" : eol == LF ? "lf" : "crlf" ) +
" tab=" + ( tabs == TABS ? "add" : tabs == ASIS ? "asis" : "remove" ) +
" eof=" + ( ctrlz == ADD ? "add" : ctrlz == ASIS ? "asis" : "remove" ) +
" tablength=" + tablength +
" encoding=" + ( encoding == null ? "default" : encoding ),
Project.MSG_VERBOSE );
" eol=" +
( eol == ASIS ? "asis" : eol == CR ? "cr" : eol == LF ? "lf" : "crlf" ) +
" tab=" + ( tabs == TABS ? "add" : tabs == ASIS ? "asis" : "remove" ) +
" eof=" + ( ctrlz == ADD ? "add" : ctrlz == ASIS ? "asis" : "remove" ) +
" tablength=" + tablength +
" encoding=" + ( encoding == null ? "default" : encoding ),
Project.MSG_VERBOSE );

DirectoryScanner ds = super.getDirectoryScanner( srcDir );
String[] files = ds.getIncludedFiles();

for( int i = 0; i < files.length; i++ )
{
processFile( files[i] );
processFile( files[ i ] );
}
}

@@ -353,10 +353,9 @@ public class FixCRLF extends MatchingTask
throws IOException
{
return ( encoding == null ) ? new FileReader( f )
: new InputStreamReader( new FileInputStream( f ), encoding );
: new InputStreamReader( new FileInputStream( f ), encoding );
}


/**
* Scan a BufferLine forward from the 'next' pointer for the end of a
* character constant. Set 'lookahead' pointer to the character following
@@ -364,10 +363,10 @@ public class FixCRLF extends MatchingTask
*
* @param bufline Description of Parameter
* @param terminator Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void endOfCharConst( OneLiner.BufferLine bufline, char terminator )
throws BuildException
throws TaskException
{
int ptr = bufline.getNext();
int eol = bufline.length();
@@ -389,7 +388,7 @@ public class FixCRLF extends MatchingTask
}
}// end of while (ptr < eol)
// Must have fallen through to the end of the line
throw new BuildException( "endOfCharConst: unterminated char constant" );
throw new TaskException( "endOfCharConst: unterminated char constant" );
}

/**
@@ -400,10 +399,10 @@ public class FixCRLF extends MatchingTask
* next eol character.
*
* @param bufline Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void nextStateChange( OneLiner.BufferLine bufline )
throws BuildException
throws TaskException
{
int eol = bufline.length();
int ptr = bufline.getNext();
@@ -411,33 +410,33 @@ public class FixCRLF extends MatchingTask
// Look for next single or double quote, double slash or slash star
while( ptr < eol )
{
switch ( bufline.getChar( ptr++ ) )
switch( bufline.getChar( ptr++ ) )
{
case '\'':
bufline.setState( IN_CHAR_CONST );
bufline.setLookahead( --ptr );
return;
case '\"':
bufline.setState( IN_STR_CONST );
bufline.setLookahead( --ptr );
return;
case '/':
if( ptr < eol )
{
if( bufline.getChar( ptr ) == '*' )
{
bufline.setState( IN_MULTI_COMMENT );
bufline.setLookahead( --ptr );
return;
}
else if( bufline.getChar( ptr ) == '/' )
case '\'':
bufline.setState( IN_CHAR_CONST );
bufline.setLookahead( --ptr );
return;
case '\"':
bufline.setState( IN_STR_CONST );
bufline.setLookahead( --ptr );
return;
case '/':
if( ptr < eol )
{
bufline.setState( IN_SINGLE_COMMENT );
bufline.setLookahead( --ptr );
return;
if( bufline.getChar( ptr ) == '*' )
{
bufline.setState( IN_MULTI_COMMENT );
bufline.setLookahead( --ptr );
return;
}
else if( bufline.getChar( ptr ) == '/' )
{
bufline.setState( IN_SINGLE_COMMENT );
bufline.setLookahead( --ptr );
return;
}
}
}
break;
break;
}// end of switch (bufline.getChar(ptr++))

}// end of while (ptr < eol)
@@ -445,7 +444,6 @@ public class FixCRLF extends MatchingTask
bufline.setLookahead( ptr );
}


/**
* Process a BufferLine string which is not part of of a string constant.
* The start position of the string is given by the 'next' field. Sets the
@@ -472,7 +470,7 @@ public class FixCRLF extends MatchingTask
// process sequences of white space
// first convert all tabs to spaces
linebuf.setLength( 0 );
while( ( nextTab = line.indexOf( ( int )'\t', place ) ) >= 0 )
while( ( nextTab = line.indexOf( (int)'\t', place ) ) >= 0 )
{
linebuf.append( line.substring( place, nextTab ) );// copy to the TAB
col += nextTab - place;
@@ -492,7 +490,7 @@ public class FixCRLF extends MatchingTask
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}// end of try-catch
}
else
@@ -519,9 +517,9 @@ public class FixCRLF extends MatchingTask
; nextStop += tablength )
{
for( tabCol = nextStop;
--tabCol - placediff >= place
&& linestring.charAt( tabCol - placediff ) == ' '
; )
--tabCol - placediff >= place
&& linestring.charAt( tabCol - placediff ) == ' '
; )
{
;// Loop for the side-effects
}
@@ -551,7 +549,7 @@ public class FixCRLF extends MatchingTask
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}// end of try-catch

}// end of else tabs == ADD
@@ -562,9 +560,8 @@ public class FixCRLF extends MatchingTask

}


private void processFile( String file )
throws BuildException
throws TaskException
{
File srcFile = new File( srcDir, file );
File destD = destDir == null ? srcDir : destDir;
@@ -582,12 +579,12 @@ public class FixCRLF extends MatchingTask
{
tmpFile = fileUtils.createTempFile( "fixcrlf", "", destD );
Writer writer = ( encoding == null ) ? new FileWriter( tmpFile )
: new OutputStreamWriter( new FileOutputStream( tmpFile ), encoding );
: new OutputStreamWriter( new FileOutputStream( tmpFile ), encoding );
outWriter = new BufferedWriter( writer );
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}

while( lines.hasMoreElements() )
@@ -597,11 +594,11 @@ public class FixCRLF extends MatchingTask

try
{
line = ( OneLiner.BufferLine )lines.nextElement();
line = (OneLiner.BufferLine)lines.nextElement();
}
catch( NoSuchElementException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}

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

}
@@ -630,78 +627,78 @@ public class FixCRLF extends MatchingTask
while( ( ptr = line.getNext() ) < linelen )
{

switch ( lines.getState() )
switch( lines.getState() )
{

case NOTJAVA:
notInConstant( line, line.length(), outWriter );
break;
case IN_MULTI_COMMENT:
if( ( endComment =
lineString.indexOf( "*/", line.getNext() )
) >= 0 )
{
// End of multiLineComment on this line
endComment += 2;// Include the end token
lines.setState( LOOKING );
}
else
{
endComment = linelen;
}

notInConstant( line, endComment, outWriter );
break;
case IN_SINGLE_COMMENT:
notInConstant( line, line.length(), outWriter );
lines.setState( LOOKING );
break;
case IN_CHAR_CONST:
case IN_STR_CONST:
// Got here from LOOKING by finding an opening "\'"
// next points to that quote character.
// Find the end of the constant. Watch out for
// backslashes. Literal tabs are left unchanged, and
// the column is adjusted accordingly.

int begin = line.getNext();
char terminator = ( lines.getState() == IN_STR_CONST
? '\"'
: '\'' );
endOfCharConst( line, terminator );
while( line.getNext() < line.getLookahead() )
{
if( line.getNextCharInc() == '\t' )
case NOTJAVA:
notInConstant( line, line.length(), outWriter );
break;
case IN_MULTI_COMMENT:
if( ( endComment =
lineString.indexOf( "*/", line.getNext() )
) >= 0 )
{
line.setColumn(
line.getColumn() +
tablength -
line.getColumn() % tablength );
// End of multiLineComment on this line
endComment += 2;// Include the end token
lines.setState( LOOKING );
}
else
{
line.incColumn();
endComment = linelen;
}

notInConstant( line, endComment, outWriter );
break;
case IN_SINGLE_COMMENT:
notInConstant( line, line.length(), outWriter );
lines.setState( LOOKING );
break;
case IN_CHAR_CONST:
case IN_STR_CONST:
// Got here from LOOKING by finding an opening "\'"
// next points to that quote character.
// Find the end of the constant. Watch out for
// backslashes. Literal tabs are left unchanged, and
// the column is adjusted accordingly.

int begin = line.getNext();
char terminator = ( lines.getState() == IN_STR_CONST
? '\"'
: '\'' );
endOfCharConst( line, terminator );
while( line.getNext() < line.getLookahead() )
{
if( line.getNextCharInc() == '\t' )
{
line.setColumn(
line.getColumn() +
tablength -
line.getColumn() % tablength );
}
else
{
line.incColumn();
}
}

// Now output the substring
try
{
outWriter.write( line.substring( begin, line.getNext() ) );
}
}

// Now output the substring
try
{
outWriter.write( line.substring( begin, line.getNext() ) );
}
catch( IOException e )
{
throw new BuildException( "Error", e );
}

lines.setState( LOOKING );

break;

case LOOKING:
nextStateChange( line );
notInConstant( line, line.getLookahead(), outWriter );
break;
catch( IOException e )
{
throw new TaskException( "Error", e );
}

lines.setState( LOOKING );

break;

case LOOKING:
nextStateChange( line );
notInConstant( line, line.getLookahead(), outWriter );
break;
}// end of switch (state)

}// end of while (line.getNext() < linelen)
@@ -714,7 +711,7 @@ public class FixCRLF extends MatchingTask
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}// end of try-catch

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

@@ -756,7 +753,7 @@ public class FixCRLF extends MatchingTask
}
catch( IOException e )
{
throw new BuildException( "Unable to close source file " + srcFile );
throw new TaskException( "Unable to close source file " + srcFile );
}

if( destFile.exists() )
@@ -768,28 +765,28 @@ public class FixCRLF extends MatchingTask
log( destFile + " is being written", Project.MSG_DEBUG );
if( !destFile.delete() )
{
throw new BuildException( "Unable to delete "
+ destFile );
throw new TaskException( "Unable to delete "
+ destFile );
}
if( !tmpFile.renameTo( destFile ) )
{
throw new BuildException(
throw new TaskException(
"Failed to transform " + srcFile
+ " to " + destFile
+ ". Couldn't rename temporary file: "
+ tmpFile );
+ " to " + destFile
+ ". Couldn't rename temporary file: "
+ tmpFile );
}

}
else
{// destination is equal to temp file
log( destFile +
" is not written, as the contents are identical",
Project.MSG_DEBUG );
" is not written, as the contents are identical",
Project.MSG_DEBUG );
if( !tmpFile.delete() )
{
throw new BuildException( "Unable to delete "
+ tmpFile );
throw new TaskException( "Unable to delete "
+ tmpFile );
}
}
}
@@ -798,11 +795,11 @@ public class FixCRLF extends MatchingTask
log( "destFile does not exist", Project.MSG_DEBUG );
if( !tmpFile.renameTo( destFile ) )
{
throw new BuildException(
throw new TaskException(
"Failed to transform " + srcFile
+ " to " + destFile
+ ". Couldn't rename temporary file: "
+ tmpFile );
+ " to " + destFile
+ ". Couldn't rename temporary file: "
+ tmpFile );
}
}

@@ -811,7 +808,7 @@ public class FixCRLF extends MatchingTask
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
finally
{
@@ -860,7 +857,6 @@ public class FixCRLF extends MatchingTask
}
}


class OneLiner implements Enumeration
{

@@ -874,7 +870,7 @@ public class FixCRLF extends MatchingTask
private BufferedReader reader;

public OneLiner( File srcFile )
throws BuildException
throws TaskException
{
try
{
@@ -884,7 +880,7 @@ public class FixCRLF extends MatchingTask
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
}

@@ -931,7 +927,7 @@ public class FixCRLF extends MatchingTask
}

protected void nextLine()
throws BuildException
throws TaskException
{
int ch = -1;
int eolcount = 0;
@@ -944,7 +940,7 @@ public class FixCRLF extends MatchingTask
ch = reader.read();
while( ch != -1 && ch != '\r' && ch != '\n' )
{
line.append( ( char )ch );
line.append( (char)ch );
ch = reader.read();
}

@@ -955,32 +951,32 @@ public class FixCRLF extends MatchingTask
return;
}

switch ( ( char )ch )
switch( (char)ch )
{
case '\r':
// Check for \r, \r\n and \r\r\n
// Regard \r\r not followed by \n as two lines
++eolcount;
eolStr.append( '\r' );
switch ( ( char )( ch = reader.read() ) )
{
case '\r':
if( ( char )( ch = reader.read() ) == '\n' )
// Check for \r, \r\n and \r\r\n
// Regard \r\r not followed by \n as two lines
++eolcount;
eolStr.append( '\r' );
switch( (char)( ch = reader.read() ) )
{
eolcount += 2;
eolStr.append( "\r\n" );
}
case '\r':
if( (char)( ch = reader.read() ) == '\n' )
{
eolcount += 2;
eolStr.append( "\r\n" );
}
break;
case '\n':
++eolcount;
eolStr.append( '\n' );
break;
}// end of switch ((char)(ch = reader.read()))
break;
case '\n':
++eolcount;
eolStr.append( '\n' );
break;
}// end of switch ((char)(ch = reader.read()))
break;
case '\n':
++eolcount;
eolStr.append( '\n' );
break;
}// end of switch ((char) ch)

// if at eolcount == 0 and trailing characters of string
@@ -1013,7 +1009,7 @@ public class FixCRLF extends MatchingTask
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
}

@@ -1026,7 +1022,7 @@ public class FixCRLF extends MatchingTask
private String line;

public BufferLine( String line, String eolStr )
throws BuildException
throws TaskException
{
next = 0;
column = 0;


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

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

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;

/**
* Expands a file that has been compressed with the GZIP algorithm. Normally
@@ -45,18 +46,18 @@ public class GUnzip extends Unpack
out = new FileOutputStream( dest );
fis = new FileInputStream( source );
zIn = new GZIPInputStream( fis );
byte[] buffer = new byte[8 * 1024];
byte[] buffer = new byte[ 8 * 1024 ];
int count = 0;
do
{
out.write( buffer, 0, count );
count = zIn.read( buffer, 0, buffer.length );
}while ( count != -1 );
} while( count != -1 );
}
catch( IOException ioe )
{
String msg = "Problem expanding gzip " + ioe.getMessage();
throw new BuildException( msg, ioe );
throw new TaskException( msg, ioe );
}
finally
{
@@ -67,7 +68,8 @@ public class GUnzip extends Unpack
fis.close();
}
catch( IOException ioex )
{}
{
}
}
if( out != null )
{
@@ -76,7 +78,8 @@ public class GUnzip extends Unpack
out.close();
}
catch( IOException ioex )
{}
{
}
}
if( zIn != null )
{
@@ -85,7 +88,8 @@ public class GUnzip extends Unpack
zIn.close();
}
catch( IOException ioex )
{}
{
}
}
}
}


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

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

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPOutputStream;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Pack;
import org.apache.myrmidon.api.TaskException;

/**
* Compresses a file with the GZIP algorithm. Normally used to compress
@@ -34,7 +34,7 @@ public class GZip extends Pack
catch( IOException ioe )
{
String msg = "Problem creating gzip " + ioe.getMessage();
throw new BuildException( msg, ioe );
throw new TaskException( msg, ioe );
}
finally
{
@@ -46,7 +46,8 @@ public class GZip extends Pack
zOut.close();
}
catch( IOException e )
{}
{
}
}
}
}


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

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

import java.util.Enumeration;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline;
@@ -51,8 +52,8 @@ public class GenerateKey extends Task
{
if( null != expandedDname )
{
throw new BuildException( "It is not possible to specify dname both " +
"as attribute and element." );
throw new TaskException( "It is not possible to specify dname both " +
"as attribute and element." );
}
this.dname = dname;
}
@@ -68,7 +69,7 @@ public class GenerateKey extends Task
}

public void setKeysize( final String keysize )
throws BuildException
throws TaskException
{
try
{
@@ -76,7 +77,7 @@ public class GenerateKey extends Task
}
catch( final NumberFormatException nfe )
{
throw new BuildException( "KeySize attribute should be a integer" );
throw new TaskException( "KeySize attribute should be a integer" );
}
}

@@ -101,7 +102,7 @@ public class GenerateKey extends Task
}

public void setValidity( final String validity )
throws BuildException
throws TaskException
{
try
{
@@ -109,7 +110,7 @@ public class GenerateKey extends Task
}
catch( final NumberFormatException nfe )
{
throw new BuildException( "Validity attribute should be a integer" );
throw new TaskException( "Validity attribute should be a integer" );
}
}

@@ -119,43 +120,43 @@ public class GenerateKey extends Task
}

public DistinguishedName createDname()
throws BuildException
throws TaskException
{
if( null != expandedDname )
{
throw new BuildException( "DName sub-element can only be specified once." );
throw new TaskException( "DName sub-element can only be specified once." );
}
if( null != dname )
{
throw new BuildException( "It is not possible to specify dname both " +
"as attribute and element." );
throw new TaskException( "It is not possible to specify dname both " +
"as attribute and element." );
}
expandedDname = new DistinguishedName();
return expandedDname;
}

public void execute()
throws BuildException
throws TaskException
{
if( project.getJavaVersion().equals( Project.JAVA_1_1 ) )
{
throw new BuildException( "The genkey task is only available on JDK" +
" versions 1.2 or greater" );
throw new TaskException( "The genkey task is only available on JDK" +
" versions 1.2 or greater" );
}

if( null == alias )
{
throw new BuildException( "alias attribute must be set" );
throw new TaskException( "alias attribute must be set" );
}

if( null == storepass )
{
throw new BuildException( "storepass attribute must be set" );
throw new TaskException( "storepass attribute must be set" );
}

if( null == dname && null == expandedDname )
{
throw new BuildException( "dname must be set" );
throw new TaskException( "dname must be set" );
}

final StringBuffer sb = new StringBuffer();
@@ -246,7 +247,7 @@ public class GenerateKey extends Task
}

log( "Generating Key for " + alias );
final ExecTask cmd = ( ExecTask )project.createTask( "exec" );
final ExecTask cmd = (ExecTask)project.createTask( "exec" );
cmd.setCommand( new Commandline( sb.toString() ) );
cmd.setFailonerror( true );
cmd.setTaskName( getTaskName() );
@@ -311,7 +312,7 @@ public class GenerateKey extends Task
}
firstPass = false;

final DnameParam param = ( DnameParam )params.elementAt( i );
final DnameParam param = (DnameParam)params.elementAt( i );
sb.append( encode( param.getName() ) );
sb.append( '=' );
sb.append( encode( param.getValue() ) );


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

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

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -14,7 +15,7 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;

@@ -100,7 +101,6 @@ public class Get extends Task
}
}


/**
* Username for basic auth.
*
@@ -121,33 +121,32 @@ public class Get extends Task
verbose = v;
}


/**
* Does the work.
*
* @exception BuildException Thrown in unrecoverable error.
* @exception TaskException Thrown in unrecoverable error.
*/
public void execute()
throws BuildException
throws TaskException
{
if( source == null )
{
throw new BuildException( "src attribute is required" );
throw new TaskException( "src attribute is required" );
}

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

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

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

try
@@ -187,7 +186,7 @@ public class Get extends Task
try
{
sun.misc.BASE64Encoder encoder =
( sun.misc.BASE64Encoder )Class.forName( "sun.misc.BASE64Encoder" ).newInstance();
(sun.misc.BASE64Encoder)Class.forName( "sun.misc.BASE64Encoder" ).newInstance();
encoding = encoder.encode( up.getBytes() );

}
@@ -204,7 +203,7 @@ public class Get extends Task
//next test for a 304 result (HTTP only)
if( connection instanceof HttpURLConnection )
{
HttpURLConnection httpConnection = ( HttpURLConnection )connection;
HttpURLConnection httpConnection = (HttpURLConnection)connection;
if( httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED )
{
//not modified so no file download. just return instead
@@ -246,10 +245,10 @@ public class Get extends Task
log( "Can't get " + source + " to " + dest );
if( ignoreErrors )
return;
throw new BuildException( "Can't get " + source + " to " + dest );
throw new TaskException( "Can't get " + source + " to " + dest );
}

byte[] buffer = new byte[100 * 1024];
byte[] buffer = new byte[ 100 * 1024 ];
int length;

while( ( length = is.read( buffer ) ) >= 0 )
@@ -283,7 +282,7 @@ public class Get extends Task
log( "Error getting " + source + " to " + dest );
if( ignoreErrors )
return;
throw new BuildException( "Error", ioe);
throw new TaskException( "Error", ioe );
}
}

@@ -294,16 +293,16 @@ public class Get extends Task
* @param timemillis Description of Parameter
* @return true if it succeeded. False means that this is a java1.1 system
* and that file times can not be set
* @exception BuildException Thrown in unrecoverable error. Likely this
* @exception TaskException Thrown in unrecoverable error. Likely this
* comes from file access failures.
*/
protected boolean touchFile( File file, long timemillis )
throws BuildException
throws TaskException
{

if( project.getJavaVersion() != Project.JAVA_1_1 )
{
Touch touch = ( Touch )project.createTask( "touch" );
Touch touch = (Touch)project.createTask( "touch" );
touch.setOwningTarget( target );
touch.setTaskName( getTaskName() );
touch.setLocation( getLocation() );
@@ -330,14 +329,13 @@ public class Get extends Task

public final char[] alphabet = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8 to 15
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16 to 23
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24 to 31
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32 to 39
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40 to 47
'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48 to 55
'4', '5', '6', '7', '8', '9', '+', '/'};// 56 to 63

'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8 to 15
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16 to 23
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24 to 31
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32 to 39
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40 to 47
'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48 to 55
'4', '5', '6', '7', '8', '9', '+', '/'};// 56 to 63

public String encode( String s )
{
@@ -350,7 +348,7 @@ public class Get extends Task
int bits6;

char[] out
= new char[( ( octetString.length - 1 ) / 3 + 1 ) * 4];
= new char[ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];

int outIndex = 0;
int i = 0;
@@ -358,46 +356,46 @@ public class Get extends Task
while( ( i + 3 ) <= octetString.length )
{
// store the octets
bits24 = ( octetString[i++] & 0xFF ) << 16;
bits24 |= ( octetString[i++] & 0xFF ) << 8;
bits24 = ( octetString[ i++ ] & 0xFF ) << 16;
bits24 |= ( octetString[ i++ ] & 0xFF ) << 8;

bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out[outIndex++] = alphabet[bits6];
out[ outIndex++ ] = alphabet[ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out[outIndex++] = alphabet[bits6];
out[ outIndex++ ] = alphabet[ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out[outIndex++] = alphabet[bits6];
out[ outIndex++ ] = alphabet[ bits6 ];
bits6 = ( bits24 & 0x0000003F );
out[outIndex++] = alphabet[bits6];
out[ outIndex++ ] = alphabet[ bits6 ];
}

if( octetString.length - i == 2 )
{
// store the octets
bits24 = ( octetString[i] & 0xFF ) << 16;
bits24 |= ( octetString[i + 1] & 0xFF ) << 8;
bits24 = ( octetString[ i ] & 0xFF ) << 16;
bits24 |= ( octetString[ i + 1 ] & 0xFF ) << 8;
bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out[outIndex++] = alphabet[bits6];
out[ outIndex++ ] = alphabet[ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out[outIndex++] = alphabet[bits6];
out[ outIndex++ ] = alphabet[ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out[outIndex++] = alphabet[bits6];
out[ outIndex++ ] = alphabet[ bits6 ];

// padding
out[outIndex++] = '=';
out[ outIndex++ ] = '=';
}
else if( octetString.length - i == 1 )
{
// store the octets
bits24 = ( octetString[i] & 0xFF ) << 16;
bits24 = ( octetString[ i ] & 0xFF ) << 16;
bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out[outIndex++] = alphabet[bits6];
out[ outIndex++ ] = alphabet[ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out[outIndex++] = alphabet[bits6];
out[ outIndex++ ] = alphabet[ bits6 ];

// padding
out[outIndex++] = '=';
out[outIndex++] = '=';
out[ outIndex++ ] = '=';
out[ outIndex++ ] = '=';
}

return new String( out );


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

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.tools.ant.*;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;

/**
* Ant task to read input line from console.
@@ -29,7 +30,9 @@ public class Input extends Task
/**
* No arg constructor.
*/
public Input() { }
public Input()
{
}

/**
* Defines the name of a property to be created from input. Behaviour is
@@ -90,10 +93,10 @@ public class Input extends Task
/**
* Actual test method executed by jakarta-ant.
*
* @exception BuildException
* @exception TaskException
*/
public void execute()
throws BuildException
throws TaskException
{
Vector accept = null;
if( validargs != null )
@@ -123,7 +126,7 @@ public class Input extends Task
}
catch( IOException e )
{
throw new BuildException( "Failed to read input from Console.", e );
throw new TaskException( "Failed to read input from Console.", e );
}
}
// not quite the original intention of this task but for the sake
@@ -132,7 +135,7 @@ public class Input extends Task
{
if( accept != null && ( !accept.contains( input ) ) )
{
throw new BuildException( "Invalid input please reenter." );
throw new TaskException( "Invalid input please reenter." );
}
}
// adopted from org.apache.tools.ant.taskdefs.Property


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

@@ -6,10 +6,19 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs;
import java.io.*;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.FileScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.ZipFileSet;
@@ -67,7 +76,7 @@ public class Jar extends Zip
{
if( !manifestFile.exists() )
{
throw new BuildException( "Manifest file: " + manifestFile + " does not exist." );
throw new TaskException( "Manifest file: " + manifestFile + " does not exist." );
}

this.manifestFile = manifestFile;
@@ -86,11 +95,11 @@ public class Jar extends Zip
catch( ManifestException e )
{
log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR );
throw new BuildException( "Invalid Manifest: " + manifestFile, e );
throw new TaskException( "Invalid Manifest: " + manifestFile, e );
}
catch( IOException e )
{
throw new BuildException( "Unable to read manifest file: " + manifestFile, e );
throw new TaskException( "Unable to read manifest file: " + manifestFile, e );
}
finally
{
@@ -111,7 +120,7 @@ public class Jar extends Zip
public void setWhenempty( WhenEmpty we )
{
log( "JARs are never empty, they contain at least a manifest file",
Project.MSG_WARN );
Project.MSG_WARN );
}

public void addConfiguredManifest( Manifest newManifest )
@@ -139,10 +148,10 @@ public class Jar extends Zip
* @param zipFile intended archive file (may or may not exist)
* @return true if nothing need be done (may have done something already);
* false if archive creation should proceed
* @exception BuildException if it likes
* @exception TaskException if it likes
*/
protected boolean isUpToDate( FileScanner[] scanners, File zipFile )
throws BuildException
throws TaskException
{
// need to handle manifest as a special check
if( buildFileManifest || manifestFile == null )
@@ -172,7 +181,7 @@ public class Jar extends Zip
{
// any problems and we will rebuild
log( "Updating jar since cannot read current jar manifest: " + e.getClass().getName() + e.getMessage(),
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
return false;
}
finally
@@ -213,7 +222,7 @@ public class Jar extends Zip
}

protected void finalizeZipOutputStream( ZipOutputStream zOut )
throws IOException, BuildException
throws IOException, TaskException
{
if( index )
{
@@ -222,7 +231,7 @@ public class Jar extends Zip
}

protected void initZipOutputStream( ZipOutputStream zOut )
throws IOException, BuildException
throws IOException, TaskException
{
try
{
@@ -232,9 +241,9 @@ public class Jar extends Zip
{
execManifest.merge( manifest );
}
for( Enumeration e = execManifest.getWarnings(); e.hasMoreElements(); )
for( Enumeration e = execManifest.getWarnings(); e.hasMoreElements(); )
{
log( "Manifest warning: " + ( String )e.nextElement(), Project.MSG_WARN );
log( "Manifest warning: " + (String)e.nextElement(), Project.MSG_WARN );
}

zipDir( null, zOut, "META-INF/" );
@@ -251,7 +260,7 @@ public class Jar extends Zip
catch( ManifestException e )
{
log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR );
throw new BuildException( "Invalid Manifest", e );
throw new TaskException( "Invalid Manifest", e );
}
}

@@ -265,7 +274,7 @@ public class Jar extends Zip
if( vPath.equalsIgnoreCase( "META-INF/MANIFEST.MF" ) )
{
log( "Warning: selected " + archiveType + " files include a META-INF/MANIFEST.MF which will be ignored " +
"(please use manifest attribute to " + archiveType + " task)", Project.MSG_WARN );
"(please use manifest attribute to " + archiveType + " task)", Project.MSG_WARN );
}
else
{
@@ -287,7 +296,7 @@ public class Jar extends Zip
}
catch( IOException e )
{
throw new BuildException( "Unable to read manifest file: ", e );
throw new TaskException( "Unable to read manifest file: ", e );
}
}
else
@@ -325,7 +334,7 @@ public class Jar extends Zip
Enumeration enum = addedDirs.keys();
while( enum.hasMoreElements() )
{
String dir = ( String )enum.nextElement();
String dir = (String)enum.nextElement();

// try to be smart, not to be fooled by a weird directory name
// @fixme do we need to check for directories starting by ./ ?
@@ -352,8 +361,6 @@ public class Jar extends Zip
super.zipFile( bais, zOut, INDEX_NAME, System.currentTimeMillis() );
}



/**
* Handle situation when we encounter a manifest file If we haven't been
* given one, we use this one. If we have, we merge the manifest in,
@@ -380,7 +387,7 @@ public class Jar extends Zip
catch( ManifestException e )
{
log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR );
throw new BuildException( "Invalid Manifest", e );
throw new TaskException( "Invalid Manifest", e );
}
}
}

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

@@ -12,7 +12,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline;
@@ -43,14 +43,14 @@ public class Java extends Task
* Set the class name.
*
* @param s The new Classname value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void setClassname( String s )
throws BuildException
throws TaskException
{
if( cmdl.getJar() != null )
{
throw new BuildException( "Cannot use 'jar' and 'classname' attributes in same command" );
throw new TaskException( "Cannot use 'jar' and 'classname' attributes in same command" );
}
cmdl.setClassname( s );
}
@@ -86,7 +86,7 @@ public class Java extends Task
}

/**
* Throw a BuildException if process returns non 0.
* Throw a TaskException if process returns non 0.
*
* @param fail The new Failonerror value
*/
@@ -114,14 +114,14 @@ public class Java extends Task
* set the jar name...
*
* @param jarfile The new Jar value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void setJar( File jarfile )
throws BuildException
throws TaskException
{
if( cmdl.getClassname() != null )
{
throw new BuildException( "Cannot use 'jar' and 'classname' attributes in same command." );
throw new TaskException( "Cannot use 'jar' and 'classname' attributes in same command." );
}
cmdl.setJar( jarfile.getAbsolutePath() );
}
@@ -207,17 +207,17 @@ public class Java extends Task
/**
* Do the execution.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
int err = -1;
if( ( err = executeJava() ) != 0 )
{
if( failOnError )
{
throw new BuildException( "Java returned: " + err );
throw new TaskException( "Java returned: " + err );
}
else
{
@@ -231,19 +231,19 @@ public class Java extends Task
*
* @return the return code from the execute java class if it was executed in
* a separate VM (fork = "yes").
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public int executeJava()
throws BuildException
throws TaskException
{
String classname = cmdl.getClassname();
if( classname == null && cmdl.getJar() == null )
{
throw new BuildException( "Classname must not be null." );
throw new TaskException( "Classname must not be null." );
}
if( !fork && cmdl.getJar() != null )
{
throw new BuildException( "Cannot execute a jar in non-forked mode. Please set fork='true'. " );
throw new TaskException( "Cannot execute a jar in non-forked mode. Please set fork='true'. " );
}

if( fork )
@@ -300,10 +300,10 @@ public class Java extends Task
*
* @param classname Description of Parameter
* @param args Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected void run( String classname, Vector args )
throws BuildException
throws TaskException
{
CommandlineJava cmdj = new CommandlineJava();
cmdj.setClassname( classname );
@@ -319,10 +319,10 @@ public class Java extends Task
* line application.
*
* @param command Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void run( CommandlineJava command )
throws BuildException
throws TaskException
{
ExecuteJava exe = new ExecuteJava();
exe.setJavaCommand( command.getJavaCommand() );
@@ -337,7 +337,7 @@ public class Java extends Task
}
catch( IOException io )
{
throw new BuildException( "Error", io );
throw new TaskException( "Error", io );
}
finally
{
@@ -358,10 +358,10 @@ public class Java extends Task
*
* @param command Description of Parameter
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private int run( String[] command )
throws BuildException
throws TaskException
{
FileOutputStream fos = null;
try
@@ -387,7 +387,7 @@ public class Java extends Task
}
else if( !dir.exists() || !dir.isDirectory() )
{
throw new BuildException( dir.getAbsolutePath() + " is not a valid directory");
throw new TaskException( dir.getAbsolutePath() + " is not a valid directory" );
}

exe.setWorkingDirectory( dir );
@@ -399,12 +399,12 @@ public class Java extends Task
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
}
catch( IOException io )
{
throw new BuildException( "Error", io );
throw new TaskException( "Error", io );
}
finally
{


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

@@ -10,8 +10,8 @@ package org.apache.tools.ant.taskdefs;
import java.io.File;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter;
@@ -221,7 +221,7 @@ public class Javac extends MatchingTask
}

/**
* Throw a BuildException if compilation fails
* Throw a TaskException if compilation fails
*
* @param fail The new Failonerror value
*/
@@ -715,26 +715,26 @@ public class Javac extends MatchingTask
/**
* Executes the task.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
// first off, make sure that we've got a srcdir

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

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

// scan source directories and dest directory to build up
@@ -745,7 +745,7 @@ public class Javac extends MatchingTask
File srcDir = (File)resolveFile( list[ i ] );
if( !srcDir.exists() )
{
throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!" );
throw new TaskException( "srcdir \"" + srcDir.getPath() + "\" does not exist!" );
}

DirectoryScanner ds = this.getDirectoryScanner( srcDir );
@@ -777,7 +777,7 @@ public class Javac extends MatchingTask
{
if( failOnError )
{
throw new BuildException( FAIL_MSG );
throw new TaskException( FAIL_MSG );
}
else
{


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

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

import java.io.File;
import java.io.FileWriter;
import java.io.FilenameFilter;
@@ -14,12 +15,11 @@ import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.Task;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.FileSet;
@@ -100,6 +100,7 @@ public class Javadoc extends Task
}

public void setAdditionalparam( String add )
throws TaskException
{
cmd.createArgument().setLine( add );
}
@@ -300,6 +301,7 @@ public class Javadoc extends Task
}

public void setLinkoffline( String src )
throws TaskException
{
if( !javadoc1 )
{
@@ -309,14 +311,14 @@ public class Javadoc extends Task
"a package-list file location separated by a space";
if( src.trim().length() == 0 )
{
throw new BuildException( linkOfflineError );
throw new TaskException( linkOfflineError );
}
StringTokenizer tok = new StringTokenizer( src, " ", false );
le.setHref( tok.nextToken() );

if( !tok.hasMoreTokens() )
{
throw new BuildException( linkOfflineError );
throw new TaskException( linkOfflineError );
}
le.setPackagelistLoc( resolveFile( tok.nextToken() ) );
}
@@ -430,6 +432,7 @@ public class Javadoc extends Task
}

public void setSourcefiles( String src )
throws TaskException
{
StringTokenizer tok = new StringTokenizer( src, "," );
while( tok.hasMoreTokens() )
@@ -606,12 +609,12 @@ public class Javadoc extends Task
}

public void execute()
throws BuildException
throws TaskException
{
if( sourcePath == null )
{
String msg = "sourcePath attribute must be set!";
throw new BuildException( msg );
throw new TaskException( msg );
}

log( "Generating Javadoc", Project.MSG_INFO );
@@ -637,10 +640,10 @@ public class Javadoc extends Task
cmd.createArgument().setValue( expand( bottom.getText() ) );
}

Commandline toExecute = ( Commandline )cmd.clone();
Commandline toExecute = (Commandline)cmd.clone();
toExecute.setExecutable( getJavadocExecutableName() );

// ------------------------------------------------ general javadoc arguments
// ------------------------------------------------ general javadoc arguments
if( classpath == null )
classpath = Path.systemClasspath;
else
@@ -657,7 +660,7 @@ public class Javadoc extends Task
{
toExecute.createArgument().setValue( "-classpath" );
toExecute.createArgument().setValue( sourcePath.toString() +
System.getProperty( "path.separator" ) + classpath.toString() );
System.getProperty( "path.separator" ) + classpath.toString() );
}

if( version && doclet == null )
@@ -670,13 +673,13 @@ public class Javadoc extends Task
if( destDir == null )
{
String msg = "destDir attribute must be set!";
throw new BuildException( msg );
throw new TaskException( msg );
}
}

// --------------------------------- javadoc2 arguments for default doclet
// --------------------------------- javadoc2 arguments for default doclet

// XXX: how do we handle a custom doclet?
// XXX: how do we handle a custom doclet?

if( !javadoc1 )
{
@@ -684,7 +687,7 @@ public class Javadoc extends Task
{
if( doclet.getName() == null )
{
throw new BuildException( "The doclet name must be specified." );
throw new TaskException( "The doclet name must be specified." );
}
else
{
@@ -695,12 +698,12 @@ public class Javadoc extends Task
toExecute.createArgument().setValue( "-docletpath" );
toExecute.createArgument().setPath( doclet.getPath() );
}
for( Enumeration e = doclet.getParams(); e.hasMoreElements(); )
for( Enumeration e = doclet.getParams(); e.hasMoreElements(); )
{
DocletParam param = ( DocletParam )e.nextElement();
DocletParam param = (DocletParam)e.nextElement();
if( param.getName() == null )
{
throw new BuildException( "Doclet parameters must have a name" );
throw new TaskException( "Doclet parameters must have a name" );
}

toExecute.createArgument().setValue( param.getName() );
@@ -720,13 +723,13 @@ public class Javadoc extends Task
// add the links arguments
if( links.size() != 0 )
{
for( Enumeration e = links.elements(); e.hasMoreElements(); )
for( Enumeration e = links.elements(); e.hasMoreElements(); )
{
LinkArgument la = ( LinkArgument )e.nextElement();
LinkArgument la = (LinkArgument)e.nextElement();

if( la.getHref() == null )
{
throw new BuildException( "Links must provide the URL to the external class documentation." );
throw new TaskException( "Links must provide the URL to the external class documentation." );
}

if( la.isLinkOffline() )
@@ -734,8 +737,8 @@ public class Javadoc extends Task
File packageListLocation = la.getPackagelistLoc();
if( packageListLocation == null )
{
throw new BuildException( "The package list location for link " + la.getHref() +
" must be provided because the link is offline" );
throw new TaskException( "The package list location for link " + la.getHref() +
" must be provided because the link is offline" );
}
File packageList = new File( packageListLocation, "package-list" );
if( packageList.exists() )
@@ -747,7 +750,7 @@ public class Javadoc extends Task
else
{
log( "Warning: No package list was found at " + packageListLocation,
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
}
}
else
@@ -790,14 +793,14 @@ public class Javadoc extends Task
// add the group arguments
if( groups.size() != 0 )
{
for( Enumeration e = groups.elements(); e.hasMoreElements(); )
for( Enumeration e = groups.elements(); e.hasMoreElements(); )
{
GroupArgument ga = ( GroupArgument )e.nextElement();
GroupArgument ga = (GroupArgument)e.nextElement();
String title = ga.getTitle();
String packages = ga.getPackages();
if( title == null || packages == null )
{
throw new BuildException( "The title and packages must be specified for group elements." );
throw new TaskException( "The title and packages must be specified for group elements." );
}
toExecute.createArgument().setValue( "-group" );
toExecute.createArgument().setValue( expand( title ) );
@@ -814,7 +817,7 @@ public class Javadoc extends Task
Enumeration enum = packageNames.elements();
while( enum.hasMoreElements() )
{
PackageName pn = ( PackageName )enum.nextElement();
PackageName pn = (PackageName)enum.nextElement();
String name = pn.getName().trim();
if( name.endsWith( ".*" ) )
{
@@ -832,7 +835,7 @@ public class Javadoc extends Task
enum = excludePackageNames.elements();
while( enum.hasMoreElements() )
{
PackageName pn = ( PackageName )enum.nextElement();
PackageName pn = (PackageName)enum.nextElement();
excludePackages.addElement( pn.getName().trim() );
}
}
@@ -859,13 +862,13 @@ public class Javadoc extends Task
toExecute.createArgument().setValue( "@" + tmpList.getAbsolutePath() );
}
srcListWriter = new PrintWriter( new FileWriter( tmpList.getAbsolutePath(),
true ) );
true ) );
}

Enumeration enum = sourceFiles.elements();
while( enum.hasMoreElements() )
{
SourceFile sf = ( SourceFile )enum.nextElement();
SourceFile sf = (SourceFile)enum.nextElement();
String sourceFileName = sf.getFile().getAbsolutePath();
if( useExternalFile )
{
@@ -880,7 +883,7 @@ public class Javadoc extends Task
}
catch( IOException e )
{
throw new BuildException( "Error creating temporary file", e );
throw new TaskException( "Error creating temporary file", e );
}
finally
{
@@ -917,12 +920,12 @@ public class Javadoc extends Task
int ret = exe.execute();
if( ret != 0 && failOnError )
{
throw new BuildException( "Javadoc returned " + ret );
throw new TaskException( "Javadoc returned " + ret );
}
}
catch( IOException e )
{
throw new BuildException( "Javadoc failed: " + e, e );
throw new TaskException( "Javadoc failed: " + e, e );
}
finally
{
@@ -941,7 +944,8 @@ public class Javadoc extends Task
err.close();
}
catch( IOException e )
{}
{
}
}
}

@@ -967,7 +971,7 @@ public class Javadoc extends Task
// so we need to fall back to assuming javadoc is somewhere on the
// PATH.
File jdocExecutable = new File( System.getProperty( "java.home" ) +
"/../bin/javadoc" + extension );
"/../bin/javadoc" + extension );

if( jdocExecutable.exists() && !Os.isFamily( "netware" ) )
{
@@ -978,7 +982,7 @@ public class Javadoc extends Task
if( !Os.isFamily( "netware" ) )
{
log( "Unable to locate " + jdocExecutable.getAbsolutePath() +
". Using \"javadoc\" instead.", Project.MSG_VERBOSE );
". Using \"javadoc\" instead.", Project.MSG_VERBOSE );
}
return "javadoc";
}
@@ -1012,13 +1016,12 @@ public class Javadoc extends Task
else
{
project.log( this,
"Warning: Leaving out empty argument '" + key + "'",
Project.MSG_WARN );
"Warning: Leaving out empty argument '" + key + "'",
Project.MSG_WARN );
}
}
}


private void addArgIf( boolean b, String arg )
{
if( b )
@@ -1039,6 +1042,7 @@ public class Javadoc extends Task
*/
private void evaluatePackages( Commandline toExecute, Path sourcePath,
Vector packages, Vector excludePackages )
throws TaskException
{
log( "Source path = " + sourcePath.toString(), Project.MSG_VERBOSE );
StringBuffer msg = new StringBuffer( "Packages = " );
@@ -1068,7 +1072,7 @@ public class Javadoc extends Task

String[] list = sourcePath.list();
if( list == null )
list = new String[0];
list = new String[ 0 ];

FileSet fs = new FileSet();
fs.setDefaultexcludes( useDefaultExcludes );
@@ -1076,7 +1080,7 @@ public class Javadoc extends Task
Enumeration e = packages.elements();
while( e.hasMoreElements() )
{
String pkg = ( String )e.nextElement();
String pkg = (String)e.nextElement();
pkg = pkg.replace( '.', '/' );
if( pkg.endsWith( "*" ) )
{
@@ -1089,7 +1093,7 @@ public class Javadoc extends Task
e = excludePackages.elements();
while( e.hasMoreElements() )
{
String pkg = ( String )e.nextElement();
String pkg = (String)e.nextElement();
pkg = pkg.replace( '.', '/' );
if( pkg.endsWith( "*" ) )
{
@@ -1111,7 +1115,7 @@ public class Javadoc extends Task

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

DirectoryScanner ds = fs.getDirectoryScanner( project );
@@ -1119,7 +1123,7 @@ public class Javadoc extends Task

for( int i = 0; i < packageDirs.length; i++ )
{
File pd = new File( source, packageDirs[i] );
File pd = new File( source, packageDirs[ i ] );
String[] files = pd.list(
new FilenameFilter()
{
@@ -1135,7 +1139,7 @@ public class Javadoc extends Task

if( files.length > 0 )
{
String pkgDir = packageDirs[i].replace( '/', '.' ).replace( '\\', '.' );
String pkgDir = packageDirs[ i ].replace( '/', '.' ).replace( '\\', '.' );
if( !addedPackages.contains( pkgDir ) )
{
if( useExternalFile )
@@ -1154,7 +1158,7 @@ public class Javadoc extends Task
}
catch( IOException ioex )
{
throw new BuildException( "Error creating temporary file", ioex );
throw new TaskException( "Error creating temporary file", ioex );
}
finally
{
@@ -1323,7 +1327,9 @@ public class Javadoc extends Task
private Vector packages = new Vector( 3 );
private Html title;

public GroupArgument() { }
public GroupArgument()
{
}

public void setPackages( String src )
{
@@ -1380,7 +1386,9 @@ public class Javadoc extends Task
private String href;
private File packagelistLoc;

public LinkArgument() { }
public LinkArgument()
{
}

public void setHref( String hr )
{
@@ -1428,7 +1436,6 @@ public class Javadoc extends Task
super( Javadoc.this, level );
}


protected void logFlush()
{
if( queuedLine != null )


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

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

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;


/**
* Logs each line written to this stream to the log system of ant. Tries to be
* smart about line separators.<br>
@@ -47,7 +47,6 @@ public class LogOutputStream extends OutputStream
return level;
}


/**
* Writes all remaining
*
@@ -61,7 +60,6 @@ public class LogOutputStream extends OutputStream
super.close();
}


/**
* Write the data to the buffer and flush the buffer, if a line separator is
* detected.
@@ -72,7 +70,7 @@ public class LogOutputStream extends OutputStream
public void write( int cc )
throws IOException
{
final byte c = ( byte )cc;
final byte c = (byte)cc;
if( ( c == '\n' ) || ( c == '\r' ) )
{
if( !skip )
@@ -83,7 +81,6 @@ public class LogOutputStream extends OutputStream
skip = ( c == '\r' );
}


/**
* Converts the buffer to a string and sends it to <code>processLine</code>
*/


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

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

import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;

/**
@@ -28,7 +29,7 @@ public class LogStreamHandler extends PumpStreamHandler
public LogStreamHandler( Task task, int outlevel, int errlevel )
{
super( new LogOutputStream( task, outlevel ),
new LogOutputStream( task, errlevel ) );
new LogOutputStream( task, errlevel ) );
}

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

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

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

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -20,7 +21,7 @@ import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.EnumeratedAttribute;

@@ -134,7 +135,7 @@ public class Manifest extends Task
if( !sectionName.getName().equalsIgnoreCase( ATTRIBUTE_NAME ) )
{
throw new ManifestException( "Manifest sections should start with a \"" + ATTRIBUTE_NAME +
"\" attribute and not \"" + sectionName.getName() + "\"" );
"\" attribute and not \"" + sectionName.getName() + "\"" );
}
nextSectionName = sectionName.getValue();
}
@@ -157,10 +158,10 @@ public class Manifest extends Task
* Construct a manifest from Ant's default manifest file.
*
* @return The DefaultManifest value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public static Manifest getDefaultManifest()
throws BuildException
throws TaskException
{
try
{
@@ -168,7 +169,7 @@ public class Manifest extends Task
InputStream in = Manifest.class.getResourceAsStream( s );
if( in == null )
{
throw new BuildException( "Could not find default manifest: " + s );
throw new TaskException( "Could not find default manifest: " + s );
}
try
{
@@ -181,11 +182,11 @@ public class Manifest extends Task
}
catch( ManifestException e )
{
throw new BuildException( "Default manifest is invalid !!" );
throw new TaskException( "Default manifest is invalid !!" );
}
catch( IOException e )
{
throw new BuildException( "Unable to read default manifest", e );
throw new TaskException( "Unable to read default manifest", e );
}
}

@@ -218,16 +219,16 @@ public class Manifest extends Task
{
Vector warnings = new Vector();

for( Enumeration e2 = mainSection.getWarnings(); e2.hasMoreElements(); )
for( Enumeration e2 = mainSection.getWarnings(); e2.hasMoreElements(); )
{
warnings.addElement( e2.nextElement() );
}

// create a vector and add in the warnings for all the sections
for( Enumeration e = sections.elements(); e.hasMoreElements(); )
for( Enumeration e = sections.elements(); e.hasMoreElements(); )
{
Section section = ( Section )e.nextElement();
for( Enumeration e2 = section.getWarnings(); e2.hasMoreElements(); )
Section section = (Section)e.nextElement();
for( Enumeration e2 = section.getWarnings(); e2.hasMoreElements(); )
{
warnings.addElement( e2.nextElement() );
}
@@ -247,7 +248,7 @@ public class Manifest extends Task
{
if( section.getName() == null )
{
throw new BuildException( "Sections must have a name" );
throw new TaskException( "Sections must have a name" );
}
sections.put( section.getName().toLowerCase(), section );
}
@@ -259,7 +260,7 @@ public class Manifest extends Task
return false;
}

Manifest rhsManifest = ( Manifest )rhs;
Manifest rhsManifest = (Manifest)rhs;
if( manifestVersion == null )
{
if( rhsManifest.manifestVersion != null )
@@ -281,10 +282,10 @@ public class Manifest extends Task
return false;
}

for( Enumeration e = sections.elements(); e.hasMoreElements(); )
for( Enumeration e = sections.elements(); e.hasMoreElements(); )
{
Section section = ( Section )e.nextElement();
Section rhsSection = ( Section )rhsManifest.sections.get( section.getName().toLowerCase() );
Section section = (Section)e.nextElement();
Section rhsSection = (Section)rhsManifest.sections.get( section.getName().toLowerCase() );
if( !section.equals( rhsSection ) )
{
return false;
@@ -297,14 +298,14 @@ public class Manifest extends Task
/**
* Create or update the Manifest when used as a task.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
if( manifestFile == null )
{
throw new BuildException( "the file attribute is required" );
throw new TaskException( "the file attribute is required" );
}

Manifest toWrite = getDefaultManifest();
@@ -319,13 +320,13 @@ public class Manifest extends Task
}
catch( ManifestException m )
{
throw new BuildException( "Existing manifest " + manifestFile
+ " is invalid", m );
throw new TaskException( "Existing manifest " + manifestFile
+ " is invalid", m );
}
catch( IOException e )
{
throw new
BuildException( "Failed to read " + manifestFile, e );
TaskException( "Failed to read " + manifestFile, e );
}
finally
{
@@ -336,7 +337,8 @@ public class Manifest extends Task
f.close();
}
catch( IOException e )
{}
{
}
}
}
}
@@ -347,7 +349,7 @@ public class Manifest extends Task
}
catch( ManifestException m )
{
throw new BuildException( "Manifest is invalid", m );
throw new TaskException( "Manifest is invalid", m );
}

PrintWriter w = null;
@@ -358,7 +360,8 @@ public class Manifest extends Task
}
catch( IOException e )
{
throw new BuildException( "Failed to write " + manifestFile e );
throw new TaskException( "Failed to write " + manifestFile
e );
}
finally
{
@@ -384,11 +387,11 @@ public class Manifest extends Task
manifestVersion = other.manifestVersion;
}
mainSection.merge( other.mainSection );
for( Enumeration e = other.sections.keys(); e.hasMoreElements(); )
for( Enumeration e = other.sections.keys(); e.hasMoreElements(); )
{
String sectionName = ( String )e.nextElement();
Section ourSection = ( Section )sections.get( sectionName );
Section otherSection = ( Section )other.sections.get( sectionName );
String sectionName = (String)e.nextElement();
Section ourSection = (Section)sections.get( sectionName );
Section otherSection = (Section)other.sections.get( sectionName );
if( ourSection == null )
{
sections.put( sectionName.toLowerCase(), otherSection );
@@ -450,9 +453,9 @@ public class Manifest extends Task
}
}

for( Enumeration e = sections.elements(); e.hasMoreElements(); )
for( Enumeration e = sections.elements(); e.hasMoreElements(); )
{
Section section = ( Section )e.nextElement();
Section section = (Section)e.nextElement();
section.write( writer );
}
}
@@ -477,7 +480,9 @@ public class Manifest extends Task
/**
* Construct an empty attribute
*/
public Attribute() { }
public Attribute()
{
}

/**
* Construct an attribute by parsing a line from the Manifest
@@ -564,7 +569,7 @@ public class Manifest extends Task
return false;
}

Attribute rhsAttribute = ( Attribute )rhs;
Attribute rhsAttribute = (Attribute)rhs;
return ( name != null && rhsAttribute.name != null &&
name.toLowerCase().equals( rhsAttribute.name.toLowerCase() ) &&
value != null && value.equals( rhsAttribute.value ) );
@@ -584,7 +589,7 @@ public class Manifest extends Task
if( index == -1 )
{
throw new ManifestException( "Manifest line \"" + line + "\" is not valid as it does not " +
"contain a name and a value separated by ': ' " );
"contain a name and a value separated by ': ' " );
}
name = line.substring( 0, index );
value = line.substring( index + 2 );
@@ -681,14 +686,14 @@ public class Manifest extends Task
}
if( attribute instanceof Attribute )
{
return ( ( Attribute )attribute ).getValue();
return ( (Attribute)attribute ).getValue();
}
else
{
String value = "";
for( Enumeration e = ( ( Vector )attribute ).elements(); e.hasMoreElements(); )
for( Enumeration e = ( (Vector)attribute ).elements(); e.hasMoreElements(); )
{
Attribute classpathAttribute = ( Attribute )e.nextElement();
Attribute classpathAttribute = (Attribute)e.nextElement();
value += classpathAttribute.getValue() + " ";
}
return value.trim();
@@ -724,20 +729,20 @@ public class Manifest extends Task
{
if( attribute.getName() == null || attribute.getValue() == null )
{
throw new BuildException( "Attributes must have name and value" );
throw new TaskException( "Attributes must have name and value" );
}
if( attribute.getName().equalsIgnoreCase( ATTRIBUTE_NAME ) )
{
warnings.addElement( "\"" + ATTRIBUTE_NAME + "\" attributes should not occur in the " +
"main section and must be the first element in all " +
"other sections: \"" + attribute.getName() + ": " + attribute.getValue() + "\"" );
"main section and must be the first element in all " +
"other sections: \"" + attribute.getName() + ": " + attribute.getValue() + "\"" );
return attribute.getValue();
}

if( attribute.getName().toLowerCase().startsWith( ATTRIBUTE_FROM.toLowerCase() ) )
{
warnings.addElement( "Manifest attributes should not start with \"" +
ATTRIBUTE_FROM + "\" in \"" + attribute.getName() + ": " + attribute.getValue() + "\"" );
ATTRIBUTE_FROM + "\" in \"" + attribute.getName() + ": " + attribute.getValue() + "\"" );
}
else
{
@@ -745,7 +750,7 @@ public class Manifest extends Task
String attributeName = attribute.getName().toLowerCase();
if( attributeName.equals( ATTRIBUTE_CLASSPATH ) )
{
Vector classpathAttrs = ( Vector )attributes.get( attributeName );
Vector classpathAttrs = (Vector)attributes.get( attributeName );
if( classpathAttrs == null )
{
classpathAttrs = new Vector();
@@ -756,7 +761,7 @@ public class Manifest extends Task
else if( attributes.containsKey( attributeName ) )
{
throw new ManifestException( "The attribute \"" + attribute.getName() + "\" may not " +
"occur more than once in the same section" );
"occur more than once in the same section" );
}
else
{
@@ -772,8 +777,8 @@ public class Manifest extends Task
String check = addAttributeAndCheck( attribute );
if( check != null )
{
throw new BuildException( "Specify the section name using the \"name\" attribute of the <section> element rather " +
"than using a \"Name\" manifest attribute" );
throw new TaskException( "Specify the section name using the \"name\" attribute of the <section> element rather " +
"than using a \"Name\" manifest attribute" );
}
}

@@ -784,16 +789,16 @@ public class Manifest extends Task
return false;
}

Section rhsSection = ( Section )rhs;
Section rhsSection = (Section)rhs;
if( attributes.size() != rhsSection.attributes.size() )
{
return false;
}

for( Enumeration e = attributes.elements(); e.hasMoreElements(); )
for( Enumeration e = attributes.elements(); e.hasMoreElements(); )
{
Attribute attribute = ( Attribute )e.nextElement();
Attribute rshAttribute = ( Attribute )rhsSection.attributes.get( attribute.getName().toLowerCase() );
Attribute attribute = (Attribute)e.nextElement();
Attribute rshAttribute = (Attribute)rhsSection.attributes.get( attribute.getName().toLowerCase() );
if( !attribute.equals( rshAttribute ) )
{
return false;
@@ -818,16 +823,16 @@ public class Manifest extends Task
throw new ManifestException( "Unable to merge sections with different names" );
}

for( Enumeration e = section.attributes.keys(); e.hasMoreElements(); )
for( Enumeration e = section.attributes.keys(); e.hasMoreElements(); )
{
String attributeName = ( String )e.nextElement();
String attributeName = (String)e.nextElement();
if( attributeName.equals( ATTRIBUTE_CLASSPATH ) &&
attributes.containsKey( attributeName ) )
{
// classpath entries are vetors which are merged
Vector classpathAttrs = ( Vector )section.attributes.get( attributeName );
Vector ourClasspathAttrs = ( Vector )attributes.get( attributeName );
for( Enumeration e2 = classpathAttrs.elements(); e2.hasMoreElements(); )
Vector classpathAttrs = (Vector)section.attributes.get( attributeName );
Vector ourClasspathAttrs = (Vector)attributes.get( attributeName );
for( Enumeration e2 = classpathAttrs.elements(); e2.hasMoreElements(); )
{
ourClasspathAttrs.addElement( e2.nextElement() );
}
@@ -840,7 +845,7 @@ public class Manifest extends Task
}

// add in the warnings
for( Enumeration e = section.warnings.elements(); e.hasMoreElements(); )
for( Enumeration e = section.warnings.elements(); e.hasMoreElements(); )
{
warnings.addElement( e.nextElement() );
}
@@ -924,20 +929,20 @@ public class Manifest extends Task
Attribute nameAttr = new Attribute( ATTRIBUTE_NAME, name );
nameAttr.write( writer );
}
for( Enumeration e = attributes.elements(); e.hasMoreElements(); )
for( Enumeration e = attributes.elements(); e.hasMoreElements(); )
{
Object object = e.nextElement();
if( object instanceof Attribute )
{
Attribute attribute = ( Attribute )object;
Attribute attribute = (Attribute)object;
attribute.write( writer );
}
else
{
Vector attrList = ( Vector )object;
for( Enumeration e2 = attrList.elements(); e2.hasMoreElements(); )
Vector attrList = (Vector)object;
for( Enumeration e2 = attrList.elements(); e2.hasMoreElements(); )
{
Attribute attribute = ( Attribute )e2.nextElement();
Attribute attribute = (Attribute)e2.nextElement();
attribute.write( writer );
}
}


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

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



/**
* Exception thrown indicating problems in a JAR Manifest
*


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

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

import java.io.File;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet;
@@ -145,6 +144,7 @@ public abstract class MatchingTask extends Task
* @return The DirectoryScanner value
*/
protected DirectoryScanner getDirectoryScanner( File baseDir )
throws TaskException
{
fileset.setDir( baseDir );
fileset.setDefaultexcludes( useDefaultExcludes );


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

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

import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;


/**
* Creates a given directory.
*
@@ -28,16 +28,16 @@ public class Mkdir extends Task
}

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

if( dir.isFile() )
{
throw new BuildException( "Unable to create directory as a file already exists with that name: " + dir.getAbsolutePath() );
throw new TaskException( "Unable to create directory as a file already exists with that name: " + dir.getAbsolutePath() );
}

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


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

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

import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.FilterSet;
@@ -53,7 +54,7 @@ public class Move extends Copy

for( int i = 0; i < list.length; i++ )
{
String s = list[i];
String s = list[ i ];
File f = new File( d, s );
if( f.isDirectory() )
{
@@ -61,19 +62,19 @@ public class Move extends Copy
}
else
{
throw new BuildException( "UNEXPECTED ERROR - The file " + f.getAbsolutePath() + " should not exist!" );
throw new TaskException( "UNEXPECTED ERROR - The file " + f.getAbsolutePath() + " should not exist!" );
}
}
log( "Deleting directory " + d.getAbsolutePath(), verbosity );
if( !d.delete() )
{
throw new BuildException( "Unable to delete directory " + d.getAbsolutePath() );
throw new TaskException( "Unable to delete directory " + d.getAbsolutePath() );
}
}

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

protected void doFileOperations()
{
@@ -83,33 +84,33 @@ public class Move extends Copy
Enumeration e = completeDirMap.keys();
while( e.hasMoreElements() )
{
File fromDir = ( File )e.nextElement();
File toDir = ( File )completeDirMap.get( fromDir );
File fromDir = (File)e.nextElement();
File toDir = (File)completeDirMap.get( fromDir );
try
{
log( "Attempting to rename dir: " + fromDir +
" to " + toDir, verbosity );
" to " + toDir, verbosity );
renameFile( fromDir, toDir, filtering, forceOverwrite );
}
catch( IOException ioe )
{
String msg = "Failed to rename dir " + fromDir
+ " to " + toDir
+ " due to " + ioe.getMessage();
throw new BuildException( msg, ioe );
+ " to " + toDir
+ " due to " + ioe.getMessage();
throw new TaskException( msg, ioe );
}
}
}
if( fileCopyMap.size() > 0 )
{// files to move
log( "Moving " + fileCopyMap.size() + " files to " +
destDir.getAbsolutePath() );
destDir.getAbsolutePath() );

Enumeration e = fileCopyMap.keys();
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 ) )
{
@@ -127,15 +128,15 @@ public class Move extends Copy
try
{
log( "Attempting to rename: " + fromFile +
" to " + toFile, verbosity );
" to " + toFile, verbosity );
moved = renameFile( f, d, filtering, forceOverwrite );
}
catch( IOException ioe )
{
String msg = "Failed to rename " + fromFile
+ " to " + toFile
+ " due to " + ioe.getMessage();
throw new BuildException( msg, ioe );
+ " to " + toFile
+ " due to " + ioe.getMessage();
throw new TaskException( msg, ioe );
}

if( !moved )
@@ -149,26 +150,26 @@ public class Move extends Copy
{
executionFilters.addFilterSet( project.getGlobalFilterSet() );
}
for( Enumeration filterEnum = getFilterSets().elements(); filterEnum.hasMoreElements(); )
for( Enumeration filterEnum = getFilterSets().elements(); filterEnum.hasMoreElements(); )
{
executionFilters.addFilterSet( ( FilterSet )filterEnum.nextElement() );
executionFilters.addFilterSet( (FilterSet)filterEnum.nextElement() );
}
getFileUtils().copyFile( f, d, executionFilters,
forceOverwrite );
forceOverwrite );

f = new File( fromFile );
if( !f.delete() )
{
throw new BuildException( "Unable to delete file "
+ f.getAbsolutePath() );
throw new TaskException( "Unable to delete file "
+ f.getAbsolutePath() );
}
}
catch( IOException ioe )
{
String msg = "Failed to copy " + fromFile + " to "
+ toFile
+ " due to " + ioe.getMessage();
throw new BuildException( msg, ioe );
+ toFile
+ " due to " + ioe.getMessage();
throw new TaskException( msg, ioe );
}
}
}
@@ -181,7 +182,7 @@ public class Move extends Copy
int count = 0;
while( e.hasMoreElements() )
{
File d = new File( ( String )e.nextElement() );
File d = new File( (String)e.nextElement() );
if( !d.exists() )
{
if( !d.mkdirs() )
@@ -206,7 +207,7 @@ public class Move extends Copy
Enumeration e = filesets.elements();
while( e.hasMoreElements() )
{
FileSet fs = ( FileSet )e.nextElement();
FileSet fs = (FileSet)e.nextElement();
File dir = fs.getDir( project );

if( okToDelete( dir ) )
@@ -231,7 +232,7 @@ public class Move extends Copy

for( int i = 0; i < list.length; i++ )
{
String s = list[i];
String s = list[ i ];
File f = new File( d, s );
if( f.isDirectory() )
{
@@ -260,12 +261,12 @@ public class Move extends Copy
* @param filtering Description of Parameter
* @param overwrite Description of Parameter
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
* @throws IOException
*/
protected boolean renameFile( File sourceFile, File destFile,
boolean filtering, boolean overwrite )
throws IOException, BuildException
throws IOException, TaskException
{

boolean renamed = true;
@@ -287,8 +288,8 @@ public class Move extends Copy
{
if( !destFile.delete() )
{
throw new BuildException( "Unable to remove existing file "
+ destFile );
throw new TaskException( "Unable to remove existing file "
+ destFile );
}
}
renamed = sourceFile.renameTo( destFile );


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

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

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;

/**
@@ -37,7 +38,7 @@ public abstract class Pack extends Task
}

public void execute()
throws BuildException
throws TaskException
{
validate();
log( "Building: " + zipFile.getAbsolutePath() );
@@ -64,30 +65,30 @@ public abstract class Pack extends Task
{
if( zipFile == null )
{
throw new BuildException( "zipfile attribute is required" );
throw new TaskException( "zipfile attribute is required" );
}

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

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

private void zipFile( InputStream in, OutputStream zOut )
throws IOException
{
byte[] buffer = new byte[8 * 1024];
byte[] buffer = new byte[ 8 * 1024 ];
int count = 0;
do
{
zOut.write( buffer, 0, count );
count = in.read( buffer, 0, buffer.length );
}while ( count != -1 );
} while( count != -1 );
}
}

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

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

import java.util.Enumeration;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Location;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.TaskContainer;


/**
* Implements a multi threaded task execution. <p>
*
@@ -23,7 +23,7 @@ import org.apache.tools.ant.TaskContainer;
* @author <a href="mailto:conor@apache.org">Conor MacNeill </a>
*/
public class Parallel extends Task
implements TaskContainer
implements TaskContainer
{

/**
@@ -31,17 +31,16 @@ public class Parallel extends Task
*/
private Vector nestedTasks = new Vector();


/**
* Add a nested task to execute parallel (asynchron). <p>
*
*
*
* @param nestedTask Nested task to be executed in parallel
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void addTask( Task nestedTask )
throws BuildException
throws TaskException
{
nestedTasks.addElement( nestedTask );
}
@@ -50,23 +49,23 @@ public class Parallel extends Task
* Block execution until the specified time or for a specified amount of
* milliseconds and if defined, execute the wait status.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
TaskThread[] threads = new TaskThread[nestedTasks.size()];
TaskThread[] threads = new TaskThread[ nestedTasks.size() ];
int threadNumber = 0;
for( Enumeration e = nestedTasks.elements(); e.hasMoreElements(); threadNumber++ )
{
Task nestedTask = ( Task )e.nextElement();
threads[threadNumber] = new TaskThread( threadNumber, nestedTask );
Task nestedTask = (Task)e.nextElement();
threads[ threadNumber ] = new TaskThread( threadNumber, nestedTask );
}

// now start all threads
for( int i = 0; i < threads.length; ++i )
{
threads[i].start();
threads[ i ].start();
}

// now join to all the threads
@@ -74,7 +73,7 @@ public class Parallel extends Task
{
try
{
threads[i].join();
threads[ i ].join();
}
catch( InterruptedException ie )
{
@@ -91,7 +90,7 @@ public class Parallel extends Task
;
for( int i = 0; i < threads.length; ++i )
{
Throwable t = threads[i].getException();
Throwable t = threads[ i ].getException();
if( t != null )
{
numExceptions++;
@@ -99,10 +98,10 @@ public class Parallel extends Task
{
firstException = t;
}
if( t instanceof BuildException &&
if( t instanceof TaskException &&
firstLocation == Location.UNKNOWN_LOCATION )
{
firstLocation = ( ( BuildException )t ).getLocation();
firstLocation = ( (TaskException)t ).getLocation();
}
exceptionMessage.append( lSep );
exceptionMessage.append( t.getMessage() );
@@ -111,18 +110,18 @@ public class Parallel extends Task

if( numExceptions == 1 )
{
if( firstException instanceof BuildException )
if( firstException instanceof TaskException )
{
throw ( BuildException )firstException;
throw (TaskException)firstException;
}
else
{
throw new BuildException( "Error", firstException );
throw new TaskException( "Error", firstException );
}
}
else if( numExceptions > 1 )
{
throw new BuildException( exceptionMessage.toString() );
throw new TaskException( exceptionMessage.toString() );
}
}



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

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

import java.io.File;
import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline;
@@ -70,7 +71,7 @@ public class Patch extends Task
{
if( !file.exists() )
{
throw new BuildException( "patchfile " + file + " doesn\'t exist" );
throw new TaskException( "patchfile " + file + " doesn\'t exist" );
}
cmd.createArgument().setValue( "-i" );
cmd.createArgument().setFile( file );
@@ -110,27 +111,27 @@ public class Patch extends Task
* patch's <i>-p</i> option.
*
* @param num The new Strip value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void setStrip( int num )
throws BuildException
throws TaskException
{
if( num < 0 )
{
throw new BuildException( "strip has to be >= 0" );
throw new TaskException( "strip has to be >= 0" );
}
cmd.createArgument().setValue( "-p" + num );
}

public void execute()
throws BuildException
throws TaskException
{
if( !havePatchfile )
{
throw new BuildException( "patchfile argument is required" );
throw new TaskException( "patchfile argument is required" );
}

Commandline toExecute = ( Commandline )cmd.clone();
Commandline toExecute = (Commandline)cmd.clone();
toExecute.setExecutable( "patch" );

if( originalFile != null )
@@ -139,8 +140,8 @@ public class Patch extends Task
}

Execute exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO,
Project.MSG_WARN ),
null );
Project.MSG_WARN ),
null );
exe.setCommandline( toExecute.getCommandline() );
try
{
@@ -148,7 +149,7 @@ public class Patch extends Task
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
}



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

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

import java.io.File;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
@@ -96,7 +97,7 @@ public class PathConvert extends Task
if( !targetOS.equals( "windows" ) && !target.equals( "unix" ) &&
!targetOS.equals( "netware" ) )
{
throw new BuildException( "targetos must be one of 'unix', 'netware', or 'windows'" );
throw new TaskException( "targetos must be one of 'unix', 'netware', or 'windows'" );
}

// Currently, we deal with only two path formats: Unix and Windows
@@ -153,10 +154,10 @@ public class PathConvert extends Task
/**
* Do the execution.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{

// If we are a reference, the create a Path from the reference
@@ -172,12 +173,12 @@ public class PathConvert extends Task
}
else if( obj instanceof FileSet )
{
FileSet fs = ( FileSet )obj;
FileSet fs = (FileSet)obj;
path.addFileset( fs );
}
else
{
throw new BuildException( "'refid' does not refer to a path or fileset" );
throw new TaskException( "'refid' does not refer to a path or fileset" );
}
}

@@ -206,7 +207,7 @@ public class PathConvert extends Task

for( int i = 0; i < elems.length; i++ )
{
String elem = elems[i];
String elem = elems[ i ];

elem = mapElement( elem );// Apply the path prefix map

@@ -249,7 +250,7 @@ public class PathConvert extends Task

for( int i = 0; i < size; i++ )
{
MapEntry entry = ( MapEntry )prefixMap.elementAt( i );
MapEntry entry = (MapEntry)prefixMap.elementAt( i );
String newElem = entry.apply( elem );

// Note I'm using "!=" to see if we got a new object back from
@@ -272,30 +273,30 @@ public class PathConvert extends Task
*
* @return Description of the Returned Value
*/
private BuildException noChildrenAllowed()
private TaskException noChildrenAllowed()
{
return new BuildException( "You must not specify nested PATH elements when using refid" );
return new TaskException( "You must not specify nested PATH elements when using refid" );
}

/**
* Validate that all our parameters have been properly initialized.
*
* @throws BuildException if something is not setup properly
* @throws TaskException if something is not setup properly
*/
private void validateSetup()
throws BuildException
throws TaskException
{

if( path == null )
throw new BuildException( "You must specify a path to convert" );
throw new TaskException( "You must specify a path to convert" );

if( property == null )
throw new BuildException( "You must specify a property" );
throw new TaskException( "You must specify a property" );

// Must either have a target OS or both a dirSep and pathSep

if( targetOS == null && pathSep == null && dirSep == null )
throw new BuildException( "You must specify at least one of targetOS, dirSep, or pathSep" );
throw new TaskException( "You must specify at least one of targetOS, dirSep, or pathSep" );

// Determine the separator strings. The dirsep and pathsep attributes
// override the targetOS settings.
@@ -367,7 +368,7 @@ public class PathConvert extends Task
{
if( from == null || to == null )
{
throw new BuildException( "Both 'from' and 'to' must be set in a map entry" );
throw new TaskException( "Both 'from' and 'to' must be set in a map entry" );
}

// If we're on windows, then do the comparison ignoring case


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

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

import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.Vector;
@@ -16,7 +17,7 @@ import java.util.Vector;
* @author <a href="mailto:mnewcomb@tacintel.com">Michael Newcomb</a>
*/
class ProcessDestroyer
extends Thread
extends Thread
{

private Vector processes = new Vector();
@@ -83,7 +84,7 @@ class ProcessDestroyer
Enumeration e = processes.elements();
while( e.hasMoreElements() )
{
( ( Process )e.nextElement() ).destroy();
( (Process)e.nextElement() ).destroy();
}
}
}


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

@@ -16,7 +16,6 @@ import java.util.Properties;
import java.util.Vector;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.Task;


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

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

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -41,28 +42,26 @@ public class PumpStreamHandler implements ExecuteStreamHandler
this( System.out, System.err );
}


public void setProcessErrorStream( InputStream is )
{
createProcessErrorPump( is, err );
}


public void setProcessInputStream( OutputStream os ) { }
public void setProcessInputStream( OutputStream os )
{
}

public void setProcessOutputStream( InputStream is )
{
createProcessOutputPump( is, out );
}


public void start()
{
inputThread.start();
errorThread.start();
}


public void stop()
{
try
@@ -70,25 +69,29 @@ public class PumpStreamHandler implements ExecuteStreamHandler
inputThread.join();
}
catch( InterruptedException e )
{}
{
}
try
{
errorThread.join();
}
catch( InterruptedException e )
{}
{
}
try
{
err.flush();
}
catch( IOException e )
{}
{
}
try
{
out.flush();
}
catch( IOException e )
{}
{
}
}

protected OutputStream getErr()
@@ -111,7 +114,6 @@ public class PumpStreamHandler implements ExecuteStreamHandler
inputThread = createPump( is, os );
}


/**
* Creates a stream pumper to copy the given input stream to the given
* output stream.


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

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

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Hashtable;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.EnumeratedAttribute;
@@ -133,16 +134,16 @@ public class Recorder extends Task
/**
* The main execution.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
if( filename == null )
throw new BuildException( "No filename specified" );
throw new TaskException( "No filename specified" );

getProject().log( "setting a recorder for name " + filename,
Project.MSG_DEBUG );
Project.MSG_DEBUG );

// get the recorder entry
RecorderEntry recorder = getRecorder( filename, getProject() );
@@ -158,10 +159,10 @@ public class Recorder extends Task
* @param name Description of Parameter
* @param proj Description of Parameter
* @return The Recorder value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected RecorderEntry getRecorder( String name, Project proj )
throws BuildException
throws TaskException
{
Object o = recorderEntries.get( name );
RecorderEntry entry;
@@ -187,15 +188,15 @@ public class Recorder extends Task
}
catch( IOException ioe )
{
throw new BuildException( "Problems creating a recorder entry",
ioe );
throw new TaskException( "Problems creating a recorder entry",
ioe );
}
proj.addBuildListener( entry );
recorderEntries.put( name, entry );
}
else
{
entry = ( RecorderEntry )o;
entry = (RecorderEntry)o;
}
return entry;
}
@@ -228,7 +229,7 @@ public class Recorder extends Task
public static class VerbosityLevelChoices extends EnumeratedAttribute
{
private final static String[] values = {"error", "warn", "info",
"verbose", "debug"};
"verbose", "debug"};

public String[] getValues()
{


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

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

import java.io.PrintStream;
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildLogger;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.StringUtils;


/**
* This is a class that represents a recorder. This is the listener to the build
* process.
@@ -66,14 +66,14 @@ public class RecorderEntry implements BuildLogger
if( minutes > 0 )
{
return Long.toString( minutes ) + " minute"
+ ( minutes == 1 ? " " : "s " )
+ Long.toString( seconds % 60 ) + " second"
+ ( seconds % 60 == 1 ? "" : "s" );
+ ( minutes == 1 ? " " : "s " )
+ Long.toString( seconds % 60 ) + " second"
+ ( seconds % 60 == 1 ? "" : "s" );
}
else
{
return Long.toString( seconds ) + " second"
+ ( seconds % 60 == 1 ? "" : "s" );
+ ( seconds % 60 == 1 ? "" : "s" );
}

}


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

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

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -21,7 +22,7 @@ import java.io.Reader;
import java.io.Writer;
import java.util.Properties;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.FileUtils;
@@ -59,7 +60,6 @@ public class Replace extends MatchingTask
private int fileCount;
private int replaceCount;


/**
* Set the source files path when using matching tasks.
*
@@ -80,7 +80,6 @@ public class Replace extends MatchingTask
this.encoding = encoding;
}


/**
* Set the source file.
*
@@ -133,7 +132,7 @@ public class Replace extends MatchingTask
}

public Properties getProperties( File propertyFile )
throws BuildException
throws TaskException
{
Properties properties = new Properties();

@@ -144,12 +143,12 @@ public class Replace extends MatchingTask
catch( FileNotFoundException e )
{
String message = "Property file (" + propertyFile.getPath() + ") not found.";
throw new BuildException( message );
throw new TaskException( message );
}
catch( IOException e )
{
String message = "Property file (" + propertyFile.getPath() + ") cannot be loaded.";
throw new BuildException( message );
throw new TaskException( message );
}

return properties;
@@ -194,10 +193,10 @@ public class Replace extends MatchingTask
/**
* Do the execution.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
validateAttributes();

@@ -222,7 +221,7 @@ public class Replace extends MatchingTask

for( int i = 0; i < srcs.length; i++ )
{
File file = new File( dir, srcs[i] );
File file = new File( dir, srcs[ i ] );
processFile( file );
}
}
@@ -236,47 +235,47 @@ public class Replace extends MatchingTask
/**
* Validate attributes provided for this task in .xml build file.
*
* @exception BuildException if any supplied attribute is invalid or any
* @exception TaskException if any supplied attribute is invalid or any
* mandatory attribute is missing
*/
public void validateAttributes()
throws BuildException
throws TaskException
{
if( src == null && dir == null )
{
String message = "Either the file or the dir attribute " + "must be specified";
throw new BuildException( message );
throw new TaskException( message );
}
if( propertyFile != null && !propertyFile.exists() )
{
String message = "Property file " + propertyFile.getPath() + " does not exist.";
throw new BuildException( message );
throw new TaskException( message );
}
if( token == null && replacefilters.size() == 0 )
{
String message = "Either token or a nested replacefilter "
+ "must be specified";
throw new BuildException( message);
+ "must be specified";
throw new TaskException( message );
}
if( token != null && "".equals( token.getText() ) )
{
String message = "The token attribute must not be an empty string.";
throw new BuildException( message );
throw new TaskException( message );
}
}

/**
* Validate nested elements.
*
* @exception BuildException if any supplied attribute is invalid or any
* @exception TaskException if any supplied attribute is invalid or any
* mandatory attribute is missing
*/
public void validateReplacefilters()
throws BuildException
throws TaskException
{
for( int i = 0; i < replacefilters.size(); i++ )
{
Replacefilter element = ( Replacefilter )replacefilters.elementAt( i );
Replacefilter element = (Replacefilter)replacefilters.elementAt( i );
element.validate();
}
}
@@ -286,27 +285,27 @@ public class Replace extends MatchingTask
* on a temporary file which then replaces the original file.
*
* @param src the source file
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void processFile( File src )
throws BuildException
throws TaskException
{
if( !src.exists() )
{
throw new BuildException( "Replace: source file " + src.getPath() + " doesn't exist" );
throw new TaskException( "Replace: source file " + src.getPath() + " doesn't exist" );
}

File temp = fileUtils.createTempFile( "rep", ".tmp",
fileUtils.getParentFile( src ) );
fileUtils.getParentFile( src ) );

Reader reader = null;
Writer writer = null;
try
{
reader = encoding == null ? new FileReader( src )
: new InputStreamReader( new FileInputStream( src ), encoding );
: new InputStreamReader( new FileInputStream( src ), encoding );
writer = encoding == null ? new FileWriter( temp )
: new OutputStreamWriter( new FileOutputStream( temp ), encoding );
: new OutputStreamWriter( new FileOutputStream( temp ), encoding );

BufferedReader br = new BufferedReader( reader );
BufferedWriter bw = new BufferedWriter( writer );
@@ -316,7 +315,7 @@ public class Replace extends MatchingTask
// when multibyte characters exist in the source file
// but then again, it might be smaller than needed on
// platforms like Windows where length can't be trusted
int fileLengthInBytes = ( int )( src.length() );
int fileLengthInBytes = (int)( src.length() );
StringBuffer tmpBuf = new StringBuffer( fileLengthInBytes );
int readChar = 0;
int totread = 0;
@@ -327,7 +326,7 @@ public class Replace extends MatchingTask
{
break;
}
tmpBuf.append( ( char )readChar );
tmpBuf.append( (char)readChar );
totread++;
}

@@ -381,8 +380,8 @@ public class Replace extends MatchingTask
}
catch( IOException ioe )
{
throw new BuildException( "IOException in " + src + " - " +
ioe.getClass().getName() + ":" + ioe.getMessage(), ioe );
throw new TaskException( "IOException in " + src + " - " +
ioe.getClass().getName() + ":" + ioe.getMessage(), ioe );
}
finally
{
@@ -393,7 +392,8 @@ public class Replace extends MatchingTask
reader.close();
}
catch( IOException e )
{}
{
}
}
if( writer != null )
{
@@ -402,7 +402,8 @@ public class Replace extends MatchingTask
writer.close();
}
catch( IOException e )
{}
{
}
}
if( temp != null )
{
@@ -418,7 +419,7 @@ public class Replace extends MatchingTask

for( int i = 0; i < replacefilters.size(); i++ )
{
Replacefilter filter = ( Replacefilter )replacefilters.elementAt( i );
Replacefilter filter = (Replacefilter)replacefilters.elementAt( i );

//for each found token, replace with value
log( "Replacing in " + filename + ": " + filter.getToken() + " --> " + filter.getReplaceValue(), Project.MSG_VERBOSE );
@@ -518,7 +519,7 @@ public class Replace extends MatchingTask
{
if( property != null )
{
return ( String )properties.getProperty( property );
return (String)properties.getProperty( property );
}
else if( value != null )
{
@@ -546,26 +547,26 @@ public class Replace extends MatchingTask
}

public void validate()
throws BuildException
throws TaskException
{
//Validate mandatory attributes
if( token == null )
{
String message = "token is a mandatory attribute " + "of replacefilter.";
throw new BuildException( message );
throw new TaskException( message );
}

if( "".equals( token ) )
{
String message = "The token attribute must not be an empty string.";
throw new BuildException( message );
throw new TaskException( message );
}

//value and property are mutually exclusive attributes
if( ( value != null ) && ( property != null ) )
{
String message = "Either value or property " + "can be specified, but a replacefilter " + "element cannot have both.";
throw new BuildException( message );
throw new TaskException( message );
}

if( ( property != null ) )
@@ -574,7 +575,7 @@ public class Replace extends MatchingTask
if( propertyFile == null )
{
String message = "The replacefilter's property attribute " + "can only be used with the replacetask's " + "propertyFile attribute.";
throw new BuildException( message );
throw new TaskException( message );
}

//Make sure property exists in property file
@@ -582,7 +583,7 @@ public class Replace extends MatchingTask
properties.getProperty( property ) == null )
{
String message = "property \"" + property + "\" was not found in " + propertyFile.getPath();
throw new BuildException( message );
throw new TaskException( message );
}
}
}


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

@@ -681,7 +681,7 @@ public class Rmic extends MatchingTask
{
String msg = "Failed to copy " + oldFile + " to " +
newFile + " due to " + ioe.getMessage();
newFile + " due to " + ioe.getMessage();
newFile + " due to " + ioe.getMessage();
throw new TaskException( msg, ioe );
}
}


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

@@ -30,6 +30,7 @@ import java.util.Enumeration;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
@@ -38,7 +39,6 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
import org.apache.myrmidon.api.TaskException;

/**
* Reads in a text file containing SQL statements seperated with semicolons and


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

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

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -14,7 +15,7 @@ import java.io.PrintStream;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.mail.MailMessage;
@@ -173,11 +174,12 @@ public class SendEmail extends Task
private String subject;
private String toList;


/**
* Creates new SendEmail
*/
public SendEmail() { }
public SendEmail()
{
}

/**
* Sets the FailOnError attribute of the MimeMail object
@@ -196,6 +198,7 @@ public class SendEmail extends Task
* @param filenames Filenames to include as the message body of this email.
*/
public void setFiles( String filenames )
throws TaskException
{
StringTokenizer t = new StringTokenizer( filenames, ", " );

@@ -279,10 +282,10 @@ public class SendEmail extends Task
/**
* Executes this build task.
*
* @throws BuildException if there is an error during task execution.
* @throws TaskException if there is an error during task execution.
*/
public void execute()
throws BuildException
throws TaskException
{
try
{
@@ -295,7 +298,7 @@ public class SendEmail extends Task
}
else
{
throw new BuildException( "Attribute \"from\" is required." );
throw new TaskException( "Attribute \"from\" is required." );
}

if( toList != null )
@@ -309,7 +312,7 @@ public class SendEmail extends Task
}
else
{
throw new BuildException( "Attribute \"toList\" is required." );
throw new TaskException( "Attribute \"toList\" is required." );
}

if( subject != null )
@@ -321,15 +324,15 @@ public class SendEmail extends Task
{
PrintStream out = mailMessage.getPrintStream();

for( Enumeration e = files.elements(); e.hasMoreElements(); )
for( Enumeration e = files.elements(); e.hasMoreElements(); )
{
File file = ( File )e.nextElement();
File file = (File)e.nextElement();

if( file.exists() && file.canRead() )
{
int bufsize = 1024;
int length;
byte[] buf = new byte[bufsize];
byte[] buf = new byte[ bufsize ];
if( includefilenames )
{
String filename = file.getName();
@@ -364,15 +367,16 @@ public class SendEmail extends Task
in.close();
}
catch( IOException ioe )
{}
{
}
}
}

}
else
{
throw new BuildException( "File \"" + file.getName()
+ "\" does not exist or is not readable." );
throw new TaskException( "File \"" + file.getName()
+ "\" does not exist or is not readable." );
}
}
}
@@ -383,7 +387,7 @@ public class SendEmail extends Task
}
else
{
throw new BuildException( "Attribute \"file\" or \"message\" is required." );
throw new TaskException( "Attribute \"file\" or \"message\" is required." );
}

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


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

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

import java.util.Enumeration;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.TaskContainer;


/**
* Implements a single threaded task execution. <p>
*
@@ -21,7 +21,7 @@ import org.apache.tools.ant.TaskContainer;
* @author Thomas Christen <a href="mailto:chr@active.ch">chr@active.ch</a>
*/
public class Sequential extends Task
implements TaskContainer
implements TaskContainer
{

/**
@@ -46,14 +46,14 @@ public class Sequential extends Task
/**
* Execute all nestedTasks.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
for( Enumeration e = nestedTasks.elements(); e.hasMoreElements(); )
for( Enumeration e = nestedTasks.elements(); e.hasMoreElements(); )
{
Task nestedTask = ( Task )e.nextElement();
Task nestedTask = (Task)e.nextElement();
nestedTask.perform();
}
}


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

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

import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
@@ -133,13 +134,12 @@ public class SignJar extends Task
filesets.addElement( set );
}


public void execute()
throws BuildException
throws TaskException
{
if( null == jar && null == filesets )
{
throw new BuildException( "jar must be set through jar attribute or nested filesets" );
throw new TaskException( "jar must be set through jar attribute or nested filesets" );
}
if( null != jar )
{
@@ -153,12 +153,12 @@ public class SignJar extends Task
// deal with the filesets
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 );
String[] jarFiles = ds.getIncludedFiles();
for( int j = 0; j < jarFiles.length; j++ )
{
doOneJar( new File( fs.getDir( project ), jarFiles[j] ), null );
doOneJar( new File( fs.getDir( project ), jarFiles[ j ] ), null );
}
}
}
@@ -182,7 +182,7 @@ public class SignJar extends Task
Enumeration entries = jarFile.entries();
while( entries.hasMoreElements() )
{
String name = ( ( ZipEntry )entries.nextElement() ).getName();
String name = ( (ZipEntry)entries.nextElement() ).getName();
if( name.startsWith( SIG_START ) && name.endsWith( SIG_END ) )
{
return true;
@@ -193,7 +193,7 @@ public class SignJar extends Task
else
{
return jarFile.getEntry( SIG_START + alias.toUpperCase() +
SIG_END ) != null;
SIG_END ) != null;
}
}
catch( IOException e )
@@ -209,7 +209,8 @@ public class SignJar extends Task
jarFile.close();
}
catch( IOException e )
{}
{
}
}
}
}
@@ -245,21 +246,21 @@ public class SignJar extends Task
}

private void doOneJar( File jarSource, File jarTarget )
throws BuildException
throws TaskException
{
if( project.getJavaVersion().equals( Project.JAVA_1_1 ) )
{
throw new BuildException( "The signjar task is only available on JDK versions 1.2 or greater" );
throw new TaskException( "The signjar task is only available on JDK versions 1.2 or greater" );
}

if( null == alias )
{
throw new BuildException( "alias attribute must be set" );
throw new TaskException( "alias attribute must be set" );
}

if( null == storepass )
{
throw new BuildException( "storepass attribute must be set" );
throw new TaskException( "storepass attribute must be set" );
}

if( isUpToDate( jarSource, jarTarget ) )
@@ -267,7 +268,7 @@ public class SignJar extends Task

final StringBuffer sb = new StringBuffer();

final ExecTask cmd = ( ExecTask )project.createTask( "exec" );
final ExecTask cmd = (ExecTask)project.createTask( "exec" );
cmd.setExecutable( "jarsigner" );

if( null != keystore )


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

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

import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;

@@ -41,12 +42,12 @@ public class Sleep extends Task
*/
private int milliseconds = 0;


/**
* Creates new instance
*/
public Sleep() { }

public Sleep()
{
}

/**
* Sets the FailOnError attribute of the MimeMail object
@@ -58,7 +59,6 @@ public class Sleep extends Task
this.failOnError = failOnError;
}


/**
* Sets the Hours attribute of the Sleep object
*
@@ -69,7 +69,6 @@ public class Sleep extends Task
this.hours = hours;
}


/**
* Sets the Milliseconds attribute of the Sleep object
*
@@ -80,7 +79,6 @@ public class Sleep extends Task
this.milliseconds = milliseconds;
}


/**
* Sets the Minutes attribute of the Sleep object
*
@@ -91,7 +89,6 @@ public class Sleep extends Task
this.minutes = minutes;
}


/**
* Sets the Seconds attribute of the Sleep object
*
@@ -102,7 +99,6 @@ public class Sleep extends Task
this.seconds = seconds;
}


/**
* sleep for a period of time
*
@@ -119,29 +115,28 @@ public class Sleep extends Task
}
}


/**
* Executes this build task. throws org.apache.tools.ant.BuildException if
* Executes this build task. throws org.apache.tools.ant.TaskException if
* there is an error during task execution.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
try
{
validate();
long sleepTime = getSleepTime();
log( "sleeping for " + sleepTime + " milliseconds",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
doSleep( sleepTime );
}
catch( Exception e )
{
if( failOnError )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
else
{
@@ -151,23 +146,21 @@ public class Sleep extends Task
}
}


/**
* verify parameters
*
* @throws BuildException if something is invalid
* @throws TaskException if something is invalid
*/
public void validate()
throws BuildException
throws TaskException
{
long sleepTime = getSleepTime();
if( getSleepTime() < 0 )
{
throw new BuildException( "Negative sleep periods are not supported" );
throw new TaskException( "Negative sleep periods are not supported" );
}
}


/**
* return time to sleep
*
@@ -176,7 +169,7 @@ public class Sleep extends Task

private long getSleepTime()
{
return ( ( ( ( long )hours * 60 ) + minutes ) * 60 + seconds ) * 1000 + milliseconds;
return ( ( ( (long)hours * 60 ) + minutes ) * 60 + seconds ) * 1000 + milliseconds;
}

}


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

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

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -26,7 +27,6 @@ public class StreamPumper implements Runnable
private InputStream is;
private OutputStream os;


/**
* Create a new stream pumper.
*
@@ -39,14 +39,13 @@ public class StreamPumper implements Runnable
this.os = os;
}


/**
* Copies data from the input stream to the output stream. Terminates as
* soon as the input stream is closed or an error occurs.
*/
public void run()
{
final byte[] buf = new byte[SIZE];
final byte[] buf = new byte[ SIZE ];

int length;
try
@@ -59,10 +58,12 @@ public class StreamPumper implements Runnable
Thread.sleep( SLEEP );
}
catch( InterruptedException e )
{}
{
}
}
}
catch( IOException e )
{}
{
}
}
}

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

@@ -13,7 +13,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.EnumeratedAttribute;
@@ -91,28 +91,28 @@ public class Tar extends MatchingTask
}

public void execute()
throws BuildException
throws TaskException
{
if( tarFile == null )
{
throw new BuildException( "tarfile attribute must be set!" );
throw new TaskException( "tarfile attribute must be set!" );
}

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

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

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

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

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

// check if tr is out of date with respect to each
@@ -143,7 +143,7 @@ public class Tar extends MatchingTask
{
if( tarFile.equals( new File( fs.getDir( project ), files[ i ] ) ) )
{
throw new BuildException( "A tar file cannot include itself" );
throw new TaskException( "A tar file cannot include itself" );
}
}
}
@@ -193,7 +193,7 @@ public class Tar extends MatchingTask
catch( IOException ioe )
{
String msg = "Problem creating TAR: " + ioe.getMessage();
throw new BuildException( msg, ioe );
throw new TaskException( msg, ioe );
}
finally
{
@@ -258,7 +258,7 @@ public class Tar extends MatchingTask
}
else if( longFileMode.isFailMode() )
{
throw new BuildException(
throw new TaskException(
"Entry: " + vPath + " longer than " +
TarConstants.NAMELEN + "characters." );
}


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

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

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -13,7 +14,7 @@ import java.text.DateFormat;
import java.text.ParseException;
import java.util.Locale;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
@@ -89,39 +90,39 @@ public class Touch extends Task
/**
* Execute the touch operation.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
if( file == null && filesets.size() == 0 )
{
throw
new BuildException( "Specify at least one source - a file or a fileset." );
new TaskException( "Specify at least one source - a file or a fileset." );
}

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

if( dateTime != null )
{
DateFormat df = DateFormat.getDateTimeInstance( DateFormat.SHORT,
DateFormat.SHORT,
Locale.US );
DateFormat.SHORT,
Locale.US );
try
{
setMillis( df.parse( dateTime ).getTime() );
if( millis < 0 )
{
throw new BuildException( "Date of " + dateTime
+ " results in negative milliseconds value relative to epoch (January 1, 1970, 00:00:00 GMT)." );
throw new TaskException( "Date of " + dateTime
+ " results in negative milliseconds value relative to epoch (January 1, 1970, 00:00:00 GMT)." );
}
}
catch( ParseException pe )
{
throw new BuildException( pe.getMessage(), pe );
throw new TaskException( pe.getMessage(), pe );
}
}

@@ -131,10 +132,10 @@ public class Touch extends Task
/**
* Does the actual work. Entry point for Untar and Expand as well.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected void touch()
throws BuildException
throws TaskException
{
if( file != null )
{
@@ -144,12 +145,12 @@ public class Touch extends Task
try
{
FileOutputStream fos = new FileOutputStream( file );
fos.write( new byte[0] );
fos.write( new byte[ 0 ] );
fos.close();
}
catch( IOException ioe )
{
throw new BuildException( "Could not create " + file, ioe );
throw new TaskException( "Could not create " + file, ioe );
}
}
}
@@ -157,7 +158,7 @@ public class Touch extends Task
if( millis >= 0 && project.getJavaVersion() == Project.JAVA_1_1 )
{
log( "modification time of files cannot be set in JDK 1.1",
Project.MSG_WARN );
Project.MSG_WARN );
return;
}

@@ -176,7 +177,7 @@ public class Touch extends Task
// deal with the filesets
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 );
File fromDir = fs.getDir( project );

@@ -185,12 +186,12 @@ public class Touch extends Task

for( int j = 0; j < srcFiles.length; j++ )
{
touch( new File( fromDir, srcFiles[j] ) );
touch( new File( fromDir, srcFiles[ j ] ) );
}

for( int j = 0; j < srcDirs.length; j++ )
{
touch( new File( fromDir, srcDirs[j] ) );
touch( new File( fromDir, srcDirs[ j ] ) );
}
}

@@ -201,11 +202,11 @@ public class Touch extends Task
}

protected void touch( File file )
throws BuildException
throws TaskException
{
if( !file.canWrite() )
{
throw new BuildException( "Can not change modification date of read-only file " + file );
throw new TaskException( "Can not change modification date of read-only file " + file );
}

if( project.getJavaVersion() == Project.JAVA_1_1 )


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

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

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@@ -16,7 +17,7 @@ import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.TimeZone;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Location;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
@@ -54,7 +55,7 @@ public class Tstamp extends Task
}

public void execute()
throws BuildException
throws TaskException
{
try
{
@@ -72,14 +73,14 @@ public class Tstamp extends Task
Enumeration i = customFormats.elements();
while( i.hasMoreElements() )
{
CustomFormat cts = ( CustomFormat )i.nextElement();
CustomFormat cts = (CustomFormat)i.nextElement();
cts.execute( project, d, location );
}

}
catch( Exception e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
}

@@ -104,14 +105,14 @@ public class Tstamp extends Task
WEEK,
MONTH,
YEAR
};
};

private Hashtable calendarFields = new Hashtable();

public Unit()
{
calendarFields.put( MILLISECOND,
new Integer( Calendar.MILLISECOND ) );
new Integer( Calendar.MILLISECOND ) );
calendarFields.put( SECOND, new Integer( Calendar.SECOND ) );
calendarFields.put( MINUTE, new Integer( Calendar.MINUTE ) );
calendarFields.put( HOUR, new Integer( Calendar.HOUR_OF_DAY ) );
@@ -124,7 +125,7 @@ public class Tstamp extends Task
public int getCalendarField()
{
String key = getValue().toLowerCase();
Integer i = ( Integer )calendarFields.get( key );
Integer i = (Integer)calendarFields.get( key );
return i.intValue();
}

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

@@ -209,12 +210,12 @@ public class Tstamp extends Task
{
if( propertyName == null )
{
throw new BuildException( "property attribute must be provided" );
throw new TaskException( "property attribute must be provided" );
}

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

SimpleDateFormat sdf;


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

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

import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;

/**
@@ -23,17 +24,19 @@ public abstract class Unpack extends Task
protected File source;

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

public void setSrc( String src )
throws TaskException
{
source = resolveFile( src );
}

public void execute()
throws BuildException
throws TaskException
{
validate();
extract();
@@ -48,11 +51,11 @@ public abstract class Unpack extends Task
String sourceName = source.getName();
int len = sourceName.length();
if( defaultExtension != null
&& len > defaultExtension.length()
&& defaultExtension.equalsIgnoreCase( sourceName.substring( len - defaultExtension.length() ) ) )
&& len > defaultExtension.length()
&& defaultExtension.equalsIgnoreCase( sourceName.substring( len - defaultExtension.length() ) ) )
{
dest = new File( dest, sourceName.substring( 0,
len - defaultExtension.length() ) );
len - defaultExtension.length() ) );
}
else
{
@@ -61,21 +64,21 @@ public abstract class Unpack extends Task
}

private void validate()
throws BuildException
throws TaskException
{
if( source == null )
{
throw new BuildException( "No Src for gunzip specified" );
throw new TaskException( "No Src for gunzip specified" );
}

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

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

if( dest == null )


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

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

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Date;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.tar.TarEntry;
@@ -38,15 +38,15 @@ public class Untar extends Expand
while( ( te = tis.getNextEntry() ) != null )
{
extractFile( fileUtils, srcF, dir, tis,
te.getName(),
te.getModTime(), te.isDirectory() );
te.getName(),
te.getModTime(), te.isDirectory() );
}
log( "expand complete", Project.MSG_VERBOSE );

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


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

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

import java.io.File;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.condition.Condition;
@@ -87,14 +88,14 @@ public class UpToDate extends MatchingTask implements Condition
* Defines the FileNameMapper to use (nested mapper element).
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public Mapper createMapper()
throws BuildException
throws TaskException
{
if( mapperElement != null )
{
throw new BuildException( "Cannot define more than one mapper" );
throw new TaskException( "Cannot define more than one mapper" );
}
mapperElement = new Mapper( project );
return mapperElement;
@@ -109,12 +110,12 @@ public class UpToDate extends MatchingTask implements Condition
{
if( sourceFileSets.size() == 0 )
{
throw new BuildException( "At least one <srcfiles> element must be set" );
throw new TaskException( "At least one <srcfiles> element must be set" );
}

if( _targetFile == null && mapperElement == null )
{
throw new BuildException( "The targetfile attribute or a nested mapper element must be set" );
throw new TaskException( "The targetfile attribute or a nested mapper element must be set" );
}

// if not there then it can't be up to date
@@ -125,23 +126,22 @@ public class UpToDate extends MatchingTask implements Condition
boolean upToDate = true;
while( upToDate && enum.hasMoreElements() )
{
FileSet fs = ( FileSet )enum.nextElement();
FileSet fs = (FileSet)enum.nextElement();
DirectoryScanner ds = fs.getDirectoryScanner( project );
upToDate = upToDate && scanDir( fs.getDir( project ),
ds.getIncludedFiles() );
ds.getIncludedFiles() );
}
return upToDate;
}


/**
* Sets property to true if target files have a more recent timestamp than
* each of the corresponding source files.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
boolean upToDate = eval();
if( upToDate )
@@ -150,12 +150,12 @@ public class UpToDate extends MatchingTask implements Condition
if( mapperElement == null )
{
log( "File \"" + _targetFile.getAbsolutePath() + "\" is up to date.",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
}
else
{
log( "All target files have been up to date.",
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );
}
}
}


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

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

import java.util.Hashtable;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.taskdefs.condition.Condition;
import org.apache.tools.ant.taskdefs.condition.ConditionBase;
import org.apache.tools.ant.types.EnumeratedAttribute;
@@ -96,20 +97,20 @@ public class WaitFor extends ConditionBase
* Check repeatedly for the specified conditions until they become true or
* the timeout expires.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
if( countConditions() > 1 )
{
throw new BuildException( "You must not nest more than one condition into <waitfor>" );
throw new TaskException( "You must not nest more than one condition into <waitfor>" );
}
if( countConditions() < 1 )
{
throw new BuildException( "You must nest a condition into <waitfor>" );
throw new TaskException( "You must nest a condition into <waitfor>" );
}
Condition c = ( Condition )getConditions().nextElement();
Condition c = (Condition)getConditions().nextElement();

maxWaitMillis *= maxWaitMultiplier;
checkEveryMillis *= checkEveryMultiplier;
@@ -149,7 +150,7 @@ public class WaitFor extends ConditionBase

private final static String[] units = {
MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK
};
};

private Hashtable timeTable = new Hashtable();

@@ -166,7 +167,7 @@ public class WaitFor extends ConditionBase
public long getMultiplier()
{
String key = getValue().toLowerCase();
Long l = ( Long )timeTable.get( key );
Long l = (Long)timeTable.get( key );
return l.longValue();
}



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

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

import java.io.File;
import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.ZipFileSet;
import org.apache.tools.zip.ZipOutputStream;


/**
* Creates a WAR archive.
*
@@ -36,7 +36,7 @@ public class War extends Jar
{
deploymentDescriptor = descr;
if( !deploymentDescriptor.exists() )
throw new BuildException( "Deployment descriptor: " + deploymentDescriptor + " does not exist." );
throw new TaskException( "Deployment descriptor: " + deploymentDescriptor + " does not exist." );

// Create a ZipFileSet for this file, and pass it up.
ZipFileSet fs = new ZipFileSet();
@@ -78,12 +78,12 @@ public class War extends Jar
}

protected void initZipOutputStream( ZipOutputStream zOut )
throws IOException, BuildException
throws IOException, TaskException
{
// If no webxml file is specified, it's an error.
if( deploymentDescriptor == null && !isInUpdateMode() )
{
throw new BuildException( "webxml attribute is required" );
throw new TaskException( "webxml attribute is required" );
}

super.initZipOutputStream( zOut );
@@ -101,7 +101,7 @@ public class War extends Jar
if( deploymentDescriptor == null || !deploymentDescriptor.equals( file ) || descriptorAdded )
{
log( "Warning: selected " + archiveType + " files include a WEB-INF/web.xml which will be ignored " +
"(please use webxml attribute to " + archiveType + " task)", Project.MSG_WARN );
"(please use webxml attribute to " + archiveType + " task)", Project.MSG_WARN );
}
else
{


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

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

import java.io.File;

/**


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

@@ -10,8 +10,8 @@ package org.apache.tools.ant.taskdefs;
import java.io.File;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
@@ -209,11 +209,11 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
/**
* Executes the task.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/

public void execute()
throws BuildException
throws TaskException
{
DirectoryScanner scanner;
String[] list;
@@ -221,7 +221,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger

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

if( baseDir == null )
@@ -256,7 +256,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
if( destDir == null )
{
String msg = "destdir attributes must be set!";
throw new BuildException( msg );
throw new TaskException( msg );
}
scanner = getDirectoryScanner( baseDir );
log( "Transforming into " + destDir, Project.MSG_INFO );
@@ -292,7 +292,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
}
catch( Exception e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
}
else
@@ -324,7 +324,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
e4.printStackTrace();
e3.printStackTrace();
e2.printStackTrace();
throw new BuildException( "Error", e1 );
throw new TaskException( "Error", e1 );
}
}
}
@@ -338,10 +338,10 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
* Loads the stylesheet and set xsl:param parameters.
*
* @param stylesheet Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected void configureLiaison( File stylesheet )
throws BuildException
throws TaskException
{
if( stylesheetLoaded )
{
@@ -362,20 +362,20 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
catch( Exception ex )
{
log( "Failed to read stylesheet " + stylesheet, Project.MSG_INFO );
throw new BuildException( "Error", ex );
throw new TaskException( "Error", ex );
}
}

private void ensureDirectoryFor( File targetFile )
throws BuildException
throws TaskException
{
File directory = new File( targetFile.getParent() );
if( !directory.exists() )
{
if( !directory.mkdirs() )
{
throw new BuildException( "Unable to create directory: "
+ directory.getAbsolutePath() );
throw new TaskException( "Unable to create directory: "
+ directory.getAbsolutePath() );
}
}
}
@@ -412,11 +412,11 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
* @param xmlFile Description of Parameter
* @param destDir Description of Parameter
* @param stylesheet Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void process( File baseDir, String xmlFile, File destDir,
File stylesheet )
throws BuildException
throws TaskException
{

String fileExt = targetExtension;
@@ -457,13 +457,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
outFile.delete();
}

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

}//-- processXML

private void process( File inFile, File outFile, File stylesheet )
throws BuildException
throws TaskException
{
try
{
@@ -486,7 +486,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
log( "Failed to process " + inFile, Project.MSG_INFO );
if( outFile != null )
outFile.delete();
throw new BuildException( "Error", ex );
throw new TaskException( "Error", ex );
}
}

@@ -534,18 +534,18 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger
}

public String getExpression()
throws BuildException
throws TaskException
{
if( expression == null )
throw new BuildException( "Expression attribute is missing." );
throw new TaskException( "Expression attribute is missing." );
return expression;
}

public String getName()
throws BuildException
throws TaskException
{
if( name == null )
throw new BuildException( "Name attribute is missing." );
throw new TaskException( "Name attribute is missing." );
return name;
}
}


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

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

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -19,7 +20,7 @@ import java.util.Stack;
import java.util.Vector;
import java.util.zip.CRC32;
import java.util.zip.ZipInputStream;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.FileScanner;
import org.apache.tools.ant.Project;
@@ -71,14 +72,14 @@ public class Zip extends MatchingTask

protected static String[][] grabFileNames( FileScanner[] scanners )
{
String[][] result = new String[scanners.length][];
String[][] result = new String[ scanners.length ][];
for( int i = 0; i < scanners.length; i++ )
{
String[] files = scanners[i].getIncludedFiles();
String[] dirs = scanners[i].getIncludedDirectories();
result[i] = new String[files.length + dirs.length];
System.arraycopy( files, 0, result[i], 0, files.length );
System.arraycopy( dirs, 0, result[i], files.length, dirs.length );
String[] files = scanners[ i ].getIncludedFiles();
String[] dirs = scanners[ i ].getIncludedDirectories();
result[ i ] = new String[ files.length + dirs.length ];
System.arraycopy( files, 0, result[ i ], 0, files.length );
System.arraycopy( dirs, 0, result[ i ], files.length, dirs.length );
}
return result;
}
@@ -94,11 +95,11 @@ public class Zip extends MatchingTask
Vector files = new Vector();
for( int i = 0; i < fileNames.length; i++ )
{
File thisBaseDir = scanners[i].getBasedir();
for( int j = 0; j < fileNames[i].length; j++ )
files.addElement( new File( thisBaseDir, fileNames[i][j] ) );
File thisBaseDir = scanners[ i ].getBasedir();
for( int j = 0; j < fileNames[ i ].length; j++ )
files.addElement( new File( thisBaseDir, fileNames[ i ][ j ] ) );
}
File[] toret = new File[files.size()];
File[] toret = new File[ files.size() ];
files.copyInto( toret );
return toret;
}
@@ -216,17 +217,17 @@ public class Zip extends MatchingTask
}

public void execute()
throws BuildException
throws TaskException
{
if( baseDir == null && filesets.size() == 0 && "zip".equals( archiveType ) )
{
throw new BuildException( "basedir attribute must be set, or at least " +
"one fileset must be given!" );
throw new TaskException( "basedir attribute must be set, or at least " +
"one fileset must be given!" );
}

if( zipFile == null )
{
throw new BuildException( "You must specify the " + archiveType + " file to create!" );
throw new TaskException( "You must specify the " + archiveType + " file to create!" );
}

// Renamed version of original file, if it exists
@@ -240,18 +241,18 @@ public class Zip extends MatchingTask
{
FileUtils fileUtils = FileUtils.newFileUtils();
renamedFile = fileUtils.createTempFile( "zip", ".tmp",
fileUtils.getParentFile( zipFile ) );
fileUtils.getParentFile( zipFile ) );

try
{
if( !zipFile.renameTo( renamedFile ) )
{
throw new BuildException( "Unable to rename old file to temporary file" );
throw new TaskException( "Unable to rename old file to temporary file" );
}
}
catch( SecurityException e )
{
throw new BuildException( "Not allowed to rename old file to temporary file" );
throw new TaskException( "Not allowed to rename old file to temporary file" );
}
}

@@ -263,11 +264,11 @@ public class Zip extends MatchingTask
}
for( int i = 0; i < filesets.size(); i++ )
{
FileSet fs = ( FileSet )filesets.elementAt( i );
FileSet fs = (FileSet)filesets.elementAt( i );
dss.addElement( fs.getDirectoryScanner( project ) );
}
int dssSize = dss.size();
FileScanner[] scanners = new FileScanner[dssSize];
FileScanner[] scanners = new FileScanner[ dssSize ];
dss.copyInto( scanners );

// quick exit if the target is up to date
@@ -319,7 +320,7 @@ public class Zip extends MatchingTask
{
exclusionPattern.append( "," );
}
exclusionPattern.append( ( String )addedFiles.elementAt( i ) );
exclusionPattern.append( (String)addedFiles.elementAt( i ) );
}
oldFiles.setExcludes( exclusionPattern.toString() );
Vector tmp = new Vector();
@@ -371,7 +372,7 @@ public class Zip extends MatchingTask
}
}

throw new BuildException( msg, ioe );
throw new TaskException( msg, ioe );
}
finally
{
@@ -384,7 +385,7 @@ public class Zip extends MatchingTask
if( !renamedFile.delete() )
{
log( "Warning: unable to delete temporary file " +
renamedFile.getName(), Project.MSG_WARN );
renamedFile.getName(), Project.MSG_WARN );
}
}
}
@@ -400,7 +401,6 @@ public class Zip extends MatchingTask
return addingNewFiles;
}


/**
* Check whether the archive is up-to-date; and handle behavior for empty
* archives.
@@ -409,10 +409,10 @@ public class Zip extends MatchingTask
* @param zipFile intended archive file (may or may not exist)
* @return true if nothing need be done (may have done something already);
* false if archive creation should proceed
* @exception BuildException if it likes
* @exception TaskException if it likes
*/
protected boolean isUpToDate( FileScanner[] scanners, File zipFile )
throws BuildException
throws TaskException
{
String[][] fileNames = grabFileNames( scanners );
File[] files = grabFiles( scanners, fileNames );
@@ -421,13 +421,13 @@ public class Zip extends MatchingTask
if( emptyBehavior.equals( "skip" ) )
{
log( "Warning: skipping " + archiveType + " archive " + zipFile +
" because no files were included.", Project.MSG_WARN );
" because no files were included.", Project.MSG_WARN );
return true;
}
else if( emptyBehavior.equals( "fail" ) )
{
throw new BuildException( "Cannot create " + archiveType + " archive " + zipFile +
": no files were included." );
throw new TaskException( "Cannot create " + archiveType + " archive " + zipFile +
": no files were included." );
}
else
{
@@ -439,9 +439,9 @@ public class Zip extends MatchingTask
{
for( int i = 0; i < files.length; ++i )
{
if( files[i].equals( zipFile ) )
if( files[ i ].equals( zipFile ) )
{
throw new BuildException( "A zip file cannot include itself" );
throw new TaskException( "A zip file cannot include itself" );
}
}

@@ -453,8 +453,8 @@ public class Zip extends MatchingTask
mm.setTo( zipFile.getAbsolutePath() );
for( int i = 0; i < scanners.length; i++ )
{
if( sfs.restrict( fileNames[i], scanners[i].getBasedir(), null,
mm ).length > 0 )
if( sfs.restrict( fileNames[ i ], scanners[ i ].getBasedir(), null,
mm ).length > 0 )
{
return false;
}
@@ -480,21 +480,21 @@ public class Zip extends MatchingTask
throws IOException
{
if( prefix.length() > 0 && fullpath.length() > 0 )
throw new BuildException( "Both prefix and fullpath attributes may not be set on the same fileset." );
throw new TaskException( "Both prefix and fullpath attributes may not be set on the same fileset." );

File thisBaseDir = scanner.getBasedir();

// directories that matched include patterns
String[] dirs = scanner.getIncludedDirectories();
if( dirs.length > 0 && fullpath.length() > 0 )
throw new BuildException( "fullpath attribute may only be specified for filesets that specify a single file." );
throw new TaskException( "fullpath attribute may only be specified for filesets that specify a single file." );
for( int i = 0; i < dirs.length; i++ )
{
if( "".equals( dirs[i] ) )
if( "".equals( dirs[ i ] ) )
{
continue;
}
String name = dirs[i].replace( File.separatorChar, '/' );
String name = dirs[ i ].replace( File.separatorChar, '/' );
if( !name.endsWith( "/" ) )
{
name += "/";
@@ -505,10 +505,10 @@ public class Zip extends MatchingTask
// files that matched include patterns
String[] files = scanner.getIncludedFiles();
if( files.length > 1 && fullpath.length() > 0 )
throw new BuildException( "fullpath attribute may only be specified for filesets that specify a single file." );
throw new TaskException( "fullpath attribute may only be specified for filesets that specify a single file." );
for( int i = 0; i < files.length; i++ )
{
File f = new File( thisBaseDir, files[i] );
File f = new File( thisBaseDir, files[ i ] );
if( fullpath.length() > 0 )
{
// Add this file at the specified location.
@@ -518,7 +518,7 @@ public class Zip extends MatchingTask
else
{
// Add this file with the specified prefix.
String name = files[i].replace( File.separatorChar, '/' );
String name = files[ i ].replace( File.separatorChar, '/' );
addParentDirs( thisBaseDir, name, zOut, prefix );
zipFile( f, zOut, prefix + name );
}
@@ -539,21 +539,21 @@ public class Zip extends MatchingTask
// Add each fileset in the Vector.
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 );

String prefix = "";
String fullpath = "";
if( fs instanceof ZipFileSet )
{
ZipFileSet zfs = ( ZipFileSet )fs;
ZipFileSet zfs = (ZipFileSet)fs;
prefix = zfs.getPrefix();
fullpath = zfs.getFullpath();
}

if( prefix.length() > 0
&& !prefix.endsWith( "/" )
&& !prefix.endsWith( "\\" ) )
&& !prefix.endsWith( "/" )
&& !prefix.endsWith( "\\" ) )
{
prefix += "/";
}
@@ -571,9 +571,9 @@ public class Zip extends MatchingTask
}

if( fs instanceof ZipFileSet
&& ( ( ZipFileSet )fs ).getSrc() != null )
&& ( (ZipFileSet)fs ).getSrc() != null )
{
addZipEntries( ( ZipFileSet )fs, ds, zOut, prefix, fullpath );
addZipEntries( (ZipFileSet)fs, ds, zOut, prefix, fullpath );
}
else
{
@@ -601,7 +601,7 @@ public class Zip extends MatchingTask
Stack directories = new Stack();
int slashPos = entry.length();

while( ( slashPos = entry.lastIndexOf( ( int )'/', slashPos - 1 ) ) != -1 )
while( ( slashPos = entry.lastIndexOf( (int)'/', slashPos - 1 ) ) != -1 )
{
String dir = entry.substring( 0, slashPos + 1 );
if( addedDirs.get( prefix + dir ) != null )
@@ -613,7 +613,7 @@ public class Zip extends MatchingTask

while( !directories.isEmpty() )
{
String dir = ( String )directories.pop();
String dir = (String)directories.pop();
File f = null;
if( baseDir != null )
{
@@ -633,9 +633,9 @@ public class Zip extends MatchingTask
throws IOException
{
if( prefix.length() > 0 && fullpath.length() > 0 )
throw new BuildException( "Both prefix and fullpath attributes may not be set on the same fileset." );
throw new TaskException( "Both prefix and fullpath attributes may not be set on the same fileset." );

ZipScanner zipScanner = ( ZipScanner )ds;
ZipScanner zipScanner = (ZipScanner)ds;
File zipSrc = fs.getSrc();

ZipEntry entry;
@@ -714,11 +714,11 @@ public class Zip extends MatchingTask
try
{
// Cf. PKZIP specification.
byte[] empty = new byte[22];
empty[0] = 80;// P
empty[1] = 75;// K
empty[2] = 5;
empty[3] = 6;
byte[] empty = new byte[ 22 ];
empty[ 0 ] = 80;// P
empty[ 1 ] = 75;// K
empty[ 2 ] = 5;
empty[ 3 ] = 6;
// remainder zeros
os.write( empty );
}
@@ -729,16 +729,20 @@ public class Zip extends MatchingTask
}
catch( IOException ioe )
{
throw new BuildException( "Could not create empty ZIP archive", ioe );
throw new TaskException( "Could not create empty ZIP archive", ioe );
}
return true;
}

protected void finalizeZipOutputStream( ZipOutputStream zOut )
throws IOException, BuildException { }
throws IOException, TaskException
{
}

protected void initZipOutputStream( ZipOutputStream zOut )
throws IOException, BuildException { }
throws IOException, TaskException
{
}

protected void zipDir( File dir, ZipOutputStream zOut, String vPath )
throws IOException
@@ -797,7 +801,7 @@ public class Zip extends MatchingTask
// Store data into a byte[]
ByteArrayOutputStream bos = new ByteArrayOutputStream();

byte[] buffer = new byte[8 * 1024];
byte[] buffer = new byte[ 8 * 1024 ];
int count = 0;
do
{
@@ -805,21 +809,21 @@ public class Zip extends MatchingTask
cal.update( buffer, 0, count );
bos.write( buffer, 0, count );
count = in.read( buffer, 0, buffer.length );
}while ( count != -1 );
} while( count != -1 );
in = new ByteArrayInputStream( bos.toByteArray() );

}
else
{
in.mark( Integer.MAX_VALUE );
byte[] buffer = new byte[8 * 1024];
byte[] buffer = new byte[ 8 * 1024 ];
int count = 0;
do
{
size += count;
cal.update( buffer, 0, count );
count = in.read( buffer, 0, buffer.length );
}while ( count != -1 );
} while( count != -1 );
in.reset();
}
ze.setSize( size );
@@ -828,7 +832,7 @@ public class Zip extends MatchingTask

zOut.putNextEntry( ze );

byte[] buffer = new byte[8 * 1024];
byte[] buffer = new byte[ 8 * 1024 ];
int count = 0;
do
{
@@ -837,7 +841,7 @@ public class Zip extends MatchingTask
zOut.write( buffer, 0, count );
}
count = in.read( buffer, 0, buffer.length );
}while ( count != -1 );
} while( count != -1 );
addedFiles.addElement( vPath );
}

@@ -846,7 +850,7 @@ public class Zip extends MatchingTask
{
if( file.equals( zipFile ) )
{
throw new BuildException( "A zip file cannot include itself" );
throw new TaskException( "A zip file cannot include itself" );
}

FileInputStream fIn = new FileInputStream( file );
@@ -860,7 +864,6 @@ public class Zip extends MatchingTask
}
}


/**
* Possible behaviors when there are no matching files for the task.
*


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

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

import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.taskdefs.Javac;

/**
@@ -36,8 +37,8 @@ public interface CompilerAdapter
* Executes the task.
*
* @return has the compilation been successful
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
boolean execute()
throws BuildException;
throws TaskException;
}

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

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

import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;

@@ -21,7 +22,9 @@ public class CompilerAdapterFactory
/**
* This is a singlton -- can't create instances!!
*/
private CompilerAdapterFactory() { }
private CompilerAdapterFactory()
{
}

/**
* Based on the parameter passed in, this method creates the necessary
@@ -45,11 +48,11 @@ public class CompilerAdapterFactory
* classname of the compiler's adapter.
* @param task a task to log through.
* @return The Compiler value
* @throws BuildException if the compiler type could not be resolved into a
* @throws TaskException if the compiler type could not be resolved into a
* compiler adapter.
*/
public static CompilerAdapter getCompiler( String compilerType, Task task )
throws BuildException
throws TaskException
{
/*
* If I've done things right, this should be the extent of the
@@ -81,7 +84,7 @@ public class CompilerAdapterFactory
catch( ClassNotFoundException cnfe )
{
task.log( "Modern compiler is not available - using "
+ "classic compiler", Project.MSG_WARN );
+ "classic compiler", Project.MSG_WARN );
return new Javac12();
}
return new Javac13();
@@ -113,32 +116,32 @@ public class CompilerAdapterFactory
*
* @param className The fully qualified classname to be created.
* @return Description of the Returned Value
* @throws BuildException This is the fit that is thrown if className isn't
* @throws TaskException This is the fit that is thrown if className isn't
* an instance of CompilerAdapter.
*/
private static CompilerAdapter resolveClassName( String className )
throws BuildException
throws TaskException
{
try
{
Class c = Class.forName( className );
Object o = c.newInstance();
return ( CompilerAdapter )o;
return (CompilerAdapter)o;
}
catch( ClassNotFoundException cnfe )
{
throw new BuildException( className + " can\'t be found.", cnfe );
throw new TaskException( className + " can\'t be found.", cnfe );
}
catch( ClassCastException cce )
{
throw new BuildException( className + " isn\'t the classname of "
+ "a compiler adapter.", cce );
throw new TaskException( className + " isn\'t the classname of "
+ "a compiler adapter.", cce );
}
catch( Throwable t )
{
// for all other possibilities
throw new BuildException( className + " caused an interesting "
+ "exception.", t );
throw new TaskException( className + " caused an interesting "
+ "exception.", t );
}
}



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

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

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Location;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.Javac;
import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;

@@ -140,7 +140,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
if( !attributes.isForkedJavac() )
{
attributes.log( "Since fork is false, ignoring memoryInitialSize setting.",
Project.MSG_WARN );
Project.MSG_WARN );
}
else
{
@@ -153,7 +153,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
if( !attributes.isForkedJavac() )
{
attributes.log( "Since fork is false, ignoring memoryMaximumSize setting.",
Project.MSG_WARN );
Project.MSG_WARN );
}
else
{
@@ -229,8 +229,8 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
if( debug )
{
if( useDebugLevel
&& Project.getJavaVersion() != Project.JAVA_1_0
&& Project.getJavaVersion() != Project.JAVA_1_1 )
&& Project.getJavaVersion() != Project.JAVA_1_0
&& Project.getJavaVersion() != Project.JAVA_1_1 )
{

String debugLevel = attributes.getDebugLevel();
@@ -271,7 +271,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
else
{
attributes.log( "depend attribute is not supported by the modern compiler",
Project.MSG_WARN );
Project.MSG_WARN );
}
}

@@ -405,16 +405,16 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
out = new PrintWriter( new FileWriter( tmpFile ) );
for( int i = firstFileName; i < args.length; i++ )
{
out.println( args[i] );
out.println( args[ i ] );
}
out.flush();
commandArray = new String[firstFileName + 1];
commandArray = new String[ firstFileName + 1 ];
System.arraycopy( args, 0, commandArray, 0, firstFileName );
commandArray[firstFileName] = "@" + tmpFile.getAbsolutePath();
commandArray[ firstFileName ] = "@" + tmpFile.getAbsolutePath();
}
catch( IOException e )
{
throw new BuildException( "Error creating temporary file", e );
throw new TaskException( "Error creating temporary file", e );
}
finally
{
@@ -425,7 +425,8 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
out.close();
}
catch( Throwable t )
{}
{
}
}
}
}
@@ -437,8 +438,8 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
try
{
Execute exe = new Execute( new LogStreamHandler( attributes,
Project.MSG_INFO,
Project.MSG_WARN ) );
Project.MSG_INFO,
Project.MSG_WARN ) );
exe.setAntRun( project );
exe.setWorkingDirectory( project.getBaseDir() );
exe.setCommandline( commandArray );
@@ -447,8 +448,8 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
}
catch( IOException e )
{
throw new BuildException( "Error running " + args[0]
+ " compiler", e );
throw new TaskException( "Error running " + args[ 0 ]
+ " compiler", e );
}
}
finally
@@ -469,7 +470,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter
protected void logAndAddFilesToCompile( Commandline cmd )
{
attributes.log( "Compilation args: " + cmd.toString(),
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );

StringBuffer niceSourceList = new StringBuffer( "File" );
if( compileList.length != 1 )
@@ -482,7 +483,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter

for( int i = 0; i < compileList.length; i++ )
{
String arg = compileList[i].getAbsolutePath();
String arg = compileList[ i ].getAbsolutePath();
cmd.createArgument().setValue( arg );
niceSourceList.append( " " + arg + lSep );
}


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

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

import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;
@@ -24,11 +25,11 @@ public class Gcj extends DefaultCompilerAdapter
* Performs a compile using the gcj compiler.
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
* @author tora@debian.org
*/
public boolean execute()
throws BuildException
throws TaskException
{
Commandline cmd;
attributes.log( "Using gcj compiler", Project.MSG_VERBOSE );
@@ -76,7 +77,7 @@ public class Gcj extends DefaultCompilerAdapter

if( destDir.mkdirs() )
{
throw new BuildException( "Can't make output directories. Maybe permission is wrong. " );
throw new TaskException( "Can't make output directories. Maybe permission is wrong. " );
}
;
}


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

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

import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.LogOutputStream;
import org.apache.tools.ant.types.Commandline;
@@ -29,7 +30,7 @@ public class Javac12 extends DefaultCompilerAdapter
{

public boolean execute()
throws BuildException
throws TaskException
{
attributes.log( "Using classic compiler", Project.MSG_VERBOSE );
Commandline cmd = setupJavacCommand( true );
@@ -45,24 +46,24 @@ public class Javac12 extends DefaultCompilerAdapter

// Call the compile() method
Method compile = c.getMethod( "compile", new Class[]{String[].class} );
Boolean ok = ( Boolean )compile.invoke( compiler, new Object[]{cmd.getArguments()} );
Boolean ok = (Boolean)compile.invoke( compiler, new Object[]{cmd.getArguments()} );
return ok.booleanValue();
}
catch( ClassNotFoundException ex )
{
throw new BuildException( "Cannot use classic compiler, as it is not available" +
" A common solution is to set the environment variable" +
" JAVA_HOME to your jdk directory." );
throw new TaskException( "Cannot use classic compiler, as it is not available" +
" A common solution is to set the environment variable" +
" JAVA_HOME to your jdk directory." );
}
catch( Exception ex )
{
if( ex instanceof BuildException )
if( ex instanceof TaskException )
{
throw ( BuildException )ex;
throw (TaskException)ex;
}
else
{
throw new BuildException( "Error starting classic compiler: ", ex );
throw new TaskException( "Error starting classic compiler: ", ex );
}
}
finally
@@ -74,7 +75,7 @@ public class Javac12 extends DefaultCompilerAdapter
catch( IOException e )
{
// plain impossible
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
}
}


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

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

import java.lang.reflect.Method;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;


/**
* The implementation of the javac compiler for JDK 1.3 This is primarily a
* cut-and-paste from the original javac task before it was refactored.
@@ -31,7 +31,7 @@ public class Javac13 extends DefaultCompilerAdapter
private final static int MODERN_COMPILER_SUCCESS = 0;

public boolean execute()
throws BuildException
throws TaskException
{
attributes.log( "Using modern compiler", Project.MSG_VERBOSE );
Commandline cmd = setupModernJavacCommand();
@@ -42,20 +42,20 @@ public class Javac13 extends DefaultCompilerAdapter
Class c = Class.forName( "com.sun.tools.javac.Main" );
Object compiler = c.newInstance();
Method compile = c.getMethod( "compile",
new Class[]{( new String[]{} ).getClass()} );
int result = ( ( Integer )compile.invoke
new Class[]{( new String[]{} ).getClass()} );
int result = ( (Integer)compile.invoke
( compiler, new Object[]{cmd.getArguments()} ) ).intValue();
return ( result == MODERN_COMPILER_SUCCESS );
}
catch( Exception ex )
{
if( ex instanceof BuildException )
if( ex instanceof TaskException )
{
throw ( BuildException )ex;
throw (TaskException)ex;
}
else
{
throw new BuildException( "Error starting modern compiler", ex );
throw new TaskException( "Error starting modern compiler", ex );
}
}
}


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

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

import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;

@@ -22,10 +23,10 @@ public class JavacExternal extends DefaultCompilerAdapter
* Performs a compile using the Javac externally.
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public boolean execute()
throws BuildException
throws TaskException
{
attributes.log( "Using external javac compiler", Project.MSG_VERBOSE );



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

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

import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;
@@ -32,11 +33,11 @@ public class Jikes extends DefaultCompilerAdapter
* been successfully tested with jikes >1.10
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
* @author skanthak@muehlheim.de
*/
public boolean execute()
throws BuildException
throws TaskException
{
attributes.log( "Using jikes compiler", Project.MSG_VERBOSE );



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

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

import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;
@@ -25,7 +26,7 @@ public class Jvc extends DefaultCompilerAdapter
{

public boolean execute()
throws BuildException
throws TaskException
{
attributes.log( "Using jvc compiler", Project.MSG_VERBOSE );



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

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

import java.lang.reflect.Method;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;
@@ -22,7 +23,7 @@ public class Kjc extends DefaultCompilerAdapter
{

public boolean execute()
throws BuildException
throws TaskException
{
attributes.log( "Using kjc compiler", Project.MSG_VERBOSE );
Commandline cmd = setupKjcCommand();
@@ -33,26 +34,26 @@ public class Kjc extends DefaultCompilerAdapter

// Call the compile() method
Method compile = c.getMethod( "compile",
new Class[]{String[].class} );
Boolean ok = ( Boolean )compile.invoke( null,
new Object[]{cmd.getArguments()} );
new Class[]{String[].class} );
Boolean ok = (Boolean)compile.invoke( null,
new Object[]{cmd.getArguments()} );
return ok.booleanValue();
}
catch( ClassNotFoundException ex )
{
throw new BuildException( "Cannot use kjc compiler, as it is not available" +
" A common solution is to set the environment variable" +
" CLASSPATH to your kjc archive (kjc.jar)." );
throw new TaskException( "Cannot use kjc compiler, as it is not available" +
" A common solution is to set the environment variable" +
" CLASSPATH to your kjc archive (kjc.jar)." );
}
catch( Exception ex )
{
if( ex instanceof BuildException )
if( ex instanceof TaskException )
{
throw ( BuildException )ex;
throw (TaskException)ex;
}
else
{
throw new BuildException( "Error starting kjc compiler: ", ex );
throw new TaskException( "Error starting kjc compiler: ", ex );
}
}
}


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

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

import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;

@@ -23,11 +24,11 @@ public class Sj extends DefaultCompilerAdapter
* Performs a compile using the sj compiler from Symantec.
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
* @author don@bea.com
*/
public boolean execute()
throws BuildException
throws TaskException
{
attributes.log( "Using symantec java compiler", Project.MSG_VERBOSE );



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

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

import java.util.Enumeration;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;

/**
* &lt;and&gt; condition container. <p>
@@ -22,12 +23,12 @@ public class And extends ConditionBase implements Condition
{

public boolean eval()
throws BuildException
throws TaskException
{
Enumeration enum = getConditions();
while( enum.hasMoreElements() )
{
Condition c = ( Condition )enum.nextElement();
Condition c = (Condition)enum.nextElement();
if( !c.eval() )
{
return false;


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

@@ -21,7 +21,7 @@ public interface Condition
* Is this condition true?
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
boolean eval()
throws TaskException;


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

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

import java.util.Enumeration;
import java.util.NoSuchElementException;
import java.util.Vector;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.taskdefs.Available;
import org.apache.tools.ant.taskdefs.Checksum;
import org.apache.tools.ant.taskdefs.UpToDate;
import org.apache.myrmidon.framework.Os;

/**
* Baseclass for the &lt;condition&gt; task as well as several conditions -
@@ -201,7 +202,7 @@ public abstract class ConditionBase extends ProjectComponent

if( o instanceof ProjectComponent )
{
( ( ProjectComponent )o ).setProject( getProject() );
( (ProjectComponent)o ).setProject( getProject() );
}
return o;
}


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

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

import org.apache.myrmidon.api.TaskException;

/**
* Simple String comparison condition.
@@ -30,11 +31,11 @@ public class Equals implements Condition
}

public boolean eval()
throws BuildException
throws TaskException
{
if( arg1 == null || arg2 == null )
{
throw new BuildException( "both arg1 and arg2 are required in equals" );
throw new TaskException( "both arg1 and arg2 are required in equals" );
}
return arg1.equals( arg2 );
}


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

@@ -6,12 +6,12 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.condition;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectComponent;

@@ -31,11 +31,11 @@ public class Http extends ProjectComponent implements Condition
}

public boolean eval()
throws BuildException
throws TaskException
{
if( spec == null )
{
throw new BuildException( "No url specified in HTTP task" );
throw new TaskException( "No url specified in HTTP task" );
}
log( "Checking for " + spec, Project.MSG_VERBOSE );
try
@@ -46,7 +46,7 @@ public class Http extends ProjectComponent implements Condition
URLConnection conn = url.openConnection();
if( conn instanceof HttpURLConnection )
{
HttpURLConnection http = ( HttpURLConnection )conn;
HttpURLConnection http = (HttpURLConnection)conn;
int code = http.getResponseCode();
log( "Result code for " + spec + " was " + code, Project.MSG_VERBOSE );
if( code > 0 && code < 500 )
@@ -66,7 +66,7 @@ public class Http extends ProjectComponent implements Condition
}
catch( MalformedURLException e )
{
throw new BuildException( "Badly formed URL: " + spec, e );
throw new TaskException( "Badly formed URL: " + spec, e );
}
return true;
}


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

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

import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.ProjectComponent;

/**
@@ -25,11 +26,11 @@ public class IsSet extends ProjectComponent implements Condition
}

public boolean eval()
throws BuildException
throws TaskException
{
if( property == null )
{
throw new BuildException( "No property specified for isset condition" );
throw new TaskException( "No property specified for isset condition" );
}

return getProject().getProperty( property ) != null;


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

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

import org.apache.myrmidon.api.TaskException;

/**
* &lt;not&gt; condition. Evaluates to true if the single condition nested into
@@ -19,17 +20,17 @@ public class Not extends ConditionBase implements Condition
{

public boolean eval()
throws BuildException
throws TaskException
{
if( countConditions() > 1 )
{
throw new BuildException( "You must not nest more than one condition into <not>" );
throw new TaskException( "You must not nest more than one condition into <not>" );
}
if( countConditions() < 1 )
{
throw new BuildException( "You must nest a condition into <not>" );
throw new TaskException( "You must nest a condition into <not>" );
}
return !( ( Condition )getConditions().nextElement() ).eval();
return !( (Condition)getConditions().nextElement() ).eval();
}

}

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

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

import java.util.Enumeration;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;

/**
* &lt;or&gt; condition container. <p>
@@ -22,12 +23,12 @@ public class Or extends ConditionBase implements Condition
{

public boolean eval()
throws BuildException
throws TaskException
{
Enumeration enum = getConditions();
while( enum.hasMoreElements() )
{
Condition c = ( Condition )enum.nextElement();
Condition c = (Condition)enum.nextElement();
if( c.eval() )
{
return true;


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

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

import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectComponent;

@@ -33,15 +34,15 @@ public class Socket extends ProjectComponent implements Condition
}

public boolean eval()
throws BuildException
throws TaskException
{
if( server == null )
{
throw new BuildException( "No server specified in Socket task" );
throw new TaskException( "No server specified in Socket task" );
}
if( port == 0 )
{
throw new BuildException( "No port specified in Socket task" );
throw new TaskException( "No port specified in Socket task" );
}
log( "Checking for listener at " + server + ":" + port, Project.MSG_VERBOSE );
try


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

@@ -12,7 +12,7 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Execute;
@@ -110,7 +110,7 @@ public class ANTLR extends Task
}

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

@@ -127,7 +127,7 @@ public class ANTLR extends Task
int err = run( commandline.getCommandline() );
if( err == 1 )
{
throw new BuildException( "ANTLR returned: " + err );
throw new TaskException( "ANTLR returned: " + err );
}
}
else
@@ -144,10 +144,10 @@ public class ANTLR extends Task
* Adds the jars or directories containing Antlr this should make the forked
* JVM work without having to specify it directly.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void init()
throws BuildException
throws TaskException
{
addClasspathEntry( "/antlr/Tool.class" );
}
@@ -196,7 +196,7 @@ public class ANTLR extends Task
}

private File getGeneratedFile()
throws BuildException
throws TaskException
{
String generatedFileName = null;
try
@@ -216,11 +216,11 @@ public class ANTLR extends Task
}
catch( Exception e )
{
throw new BuildException( "Unable to determine generated class", e );
throw new TaskException( "Unable to determine generated class", e );
}
if( generatedFileName == null )
{
throw new BuildException( "Unable to determine generated class" );
throw new TaskException( "Unable to determine generated class" );
}
return new File( outputDirectory, generatedFileName + ".java" );
}
@@ -230,10 +230,10 @@ public class ANTLR extends Task
*
* @param command Description of Parameter
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private int run( String[] command )
throws BuildException
throws TaskException
{
Execute exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO,
Project.MSG_WARN ), null );
@@ -249,16 +249,16 @@ public class ANTLR extends Task
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
}

private void validateAttributes()
throws BuildException
throws TaskException
{
if( target == null || !target.isFile() )
{
throw new BuildException( "Invalid target: " + target );
throw new TaskException( "Invalid target: " + target );
}

// if no output directory is specified, used the target's directory
@@ -269,7 +269,7 @@ public class ANTLR extends Task
}
if( !outputDirectory.isDirectory() )
{
throw new BuildException( "Invalid output directory: " + outputDirectory );
throw new TaskException( "Invalid output directory: " + outputDirectory );
}
}
}

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

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

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -13,17 +14,16 @@ import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.ExecTask;
import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.myrmidon.framework.Os;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.util.FileUtils;


/**
* Create a CAB archive.
*
@@ -106,7 +106,7 @@ public class Cab extends MatchingTask
}

public void execute()
throws BuildException
throws TaskException
{

checkConfiguration();
@@ -144,7 +144,7 @@ public class Cab extends MatchingTask
catch( IOException ex )
{
String msg = "Problem creating " + cabFile + " " + ex.getMessage();
throw new BuildException( msg );
throw new TaskException( msg );
}
}
else
@@ -178,7 +178,7 @@ public class Cab extends MatchingTask
catch( IOException ioe )
{
String msg = "Problem creating " + cabFile + " " + ioe.getMessage();
throw new BuildException( msg );
throw new TaskException( msg );
}
}
}
@@ -189,10 +189,10 @@ public class Cab extends MatchingTask
* traditional include parameters.
*
* @return The FileList value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected Vector getFileList()
throws BuildException
throws TaskException
{
Vector files = new Vector();

@@ -206,7 +206,7 @@ public class Cab extends MatchingTask
// get files from filesets
for( int i = 0; i < filesets.size(); i++ )
{
FileSet fs = ( FileSet )filesets.elementAt( i );
FileSet fs = (FileSet)filesets.elementAt( i );
if( fs != null )
{
appendFiles( files, fs.getDirectoryScanner( project ) );
@@ -248,7 +248,7 @@ public class Cab extends MatchingTask

for( int i = 0; i < dsfiles.length; i++ )
{
files.addElement( dsfiles[i] );
files.addElement( dsfiles[ i ] );
}
}

@@ -258,19 +258,19 @@ public class Cab extends MatchingTask
* for side-effects to me...
*/
protected void checkConfiguration()
throws BuildException
throws TaskException
{
if( baseDir == null )
{
throw new BuildException( "basedir attribute must be set!" );
throw new TaskException( "basedir attribute must be set!" );
}
if( !baseDir.exists() )
{
throw new BuildException( "basedir does not exist!" );
throw new TaskException( "basedir does not exist!" );
}
if( cabFile == null )
{
throw new BuildException( "cabfile attribute must be set!" );
throw new TaskException( "cabfile attribute must be set!" );
}
}

@@ -281,6 +281,7 @@ public class Cab extends MatchingTask
* @return Description of the Returned Value
*/
protected Commandline createCommand( File listFile )
throws TaskException
{
Commandline command = new Commandline();
command.setExecutable( "cabarc" );
@@ -310,12 +311,12 @@ public class Cab extends MatchingTask
* appears in the logs to be the same task as this one.
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
protected ExecTask createExec()
throws BuildException
throws TaskException
{
ExecTask exec = ( ExecTask )project.createTask( "exec" );
ExecTask exec = (ExecTask)project.createTask( "exec" );
exec.setOwningTarget( this.getOwningTarget() );
exec.setTaskName( this.getTaskName() );
exec.setDescription( this.getDescription() );


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

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -13,8 +14,8 @@ import java.io.IOException;
import java.io.PrintStream;
import java.util.Date;
import java.util.Properties;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
@@ -682,10 +683,10 @@ public class IContract extends MatchingTask
/**
* Executes the task
*
* @exception BuildException if the instrumentation fails
* @exception TaskException if the instrumentation fails
*/
public void execute()
throws BuildException
throws TaskException
{
preconditions();
scan();
@@ -720,7 +721,7 @@ public class IContract extends MatchingTask
// Prepare the directories for iContract. iContract will make them if they
// don't exist, but for some reason I don't know, it will complain about the REP files
// afterwards
Mkdir mkdir = ( Mkdir )project.createTask( "mkdir" );
Mkdir mkdir = (Mkdir)project.createTask( "mkdir" );
mkdir.setDir( instrumentDir );
mkdir.execute();
mkdir.setDir( buildDir );
@@ -737,25 +738,25 @@ public class IContract extends MatchingTask
classpathHelper.modify( baseClasspath );

// Create the classpath required to compile the sourcefiles BEFORE instrumentation
Path beforeInstrumentationClasspath = ( ( Path )baseClasspath.clone() );
Path beforeInstrumentationClasspath = ( (Path)baseClasspath.clone() );
beforeInstrumentationClasspath.append( new Path( getProject(), srcDir.getAbsolutePath() ) );

// Create the classpath required to compile the sourcefiles AFTER instrumentation
Path afterInstrumentationClasspath = ( ( Path )baseClasspath.clone() );
Path afterInstrumentationClasspath = ( (Path)baseClasspath.clone() );
afterInstrumentationClasspath.append( new Path( getProject(), instrumentDir.getAbsolutePath() ) );
afterInstrumentationClasspath.append( new Path( getProject(), repositoryDir.getAbsolutePath() ) );
afterInstrumentationClasspath.append( new Path( getProject(), srcDir.getAbsolutePath() ) );
afterInstrumentationClasspath.append( new Path( getProject(), buildDir.getAbsolutePath() ) );

// Create the classpath required to automatically compile the repository files
Path repositoryClasspath = ( ( Path )baseClasspath.clone() );
Path repositoryClasspath = ( (Path)baseClasspath.clone() );
repositoryClasspath.append( new Path( getProject(), instrumentDir.getAbsolutePath() ) );
repositoryClasspath.append( new Path( getProject(), srcDir.getAbsolutePath() ) );
repositoryClasspath.append( new Path( getProject(), repositoryDir.getAbsolutePath() ) );
repositoryClasspath.append( new Path( getProject(), buildDir.getAbsolutePath() ) );

// Create the classpath required for iContract itself
Path iContractClasspath = ( ( Path )baseClasspath.clone() );
Path iContractClasspath = ( (Path)baseClasspath.clone() );
iContractClasspath.append( new Path( getProject(), System.getProperty( "java.home" ) + File.separator + ".." + File.separator + "lib" + File.separator + "tools.jar" ) );
iContractClasspath.append( new Path( getProject(), srcDir.getAbsolutePath() ) );
iContractClasspath.append( new Path( getProject(), repositoryDir.getAbsolutePath() ) );
@@ -763,7 +764,7 @@ public class IContract extends MatchingTask
iContractClasspath.append( new Path( getProject(), buildDir.getAbsolutePath() ) );

// Create a forked java process
Java iContract = ( Java )project.createTask( "java" );
Java iContract = (Java)project.createTask( "java" );
iContract.setTaskName( getTaskName() );
iContract.setFork( true );
iContract.setClassname( "com.reliablesystems.iContract.Tool" );
@@ -784,7 +785,7 @@ public class IContract extends MatchingTask
args.append( "@" ).append( targets.getAbsolutePath() );
iContract.createArg().setLine( args.toString() );

//System.out.println( "JAVA -classpath " + iContractClasspath + " com.reliablesystems.iContract.Tool " + args.toString() );
//System.out.println( "JAVA -classpath " + iContractClasspath + " com.reliablesystems.iContract.Tool " + args.toString() );

// update iControlProperties if it's set.
if( updateIcontrol )
@@ -825,7 +826,7 @@ public class IContract extends MatchingTask
log( classpath.toString() );
log( "If you don't have the iContract jar, go get it at http://www.reliable-systems.com/tools/" );
}
throw new BuildException( "iContract instrumentation failed. Code=" + result );
throw new TaskException( "iContract instrumentation failed. Code=" + result );
}

}
@@ -835,7 +836,6 @@ public class IContract extends MatchingTask
}
}


/**
* Creates the -m option based on the values of controlFile, pre, post and
* invariant.
@@ -890,34 +890,34 @@ public class IContract extends MatchingTask
/**
* Checks that the required attributes are set.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void preconditions()
throws BuildException
throws TaskException
{
if( srcDir == null )
{
throw new BuildException( "srcdir attribute must be set!" );
throw new TaskException( "srcdir attribute must be set!" );
}
if( !srcDir.exists() )
{
throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!");
throw new TaskException( "srcdir \"" + srcDir.getPath() + "\" does not exist!" );
}
if( instrumentDir == null )
{
throw new BuildException( "instrumentdir attribute must be set!");
throw new TaskException( "instrumentdir attribute must be set!" );
}
if( repositoryDir == null )
{
throw new BuildException( "repositorydir attribute must be set!" );
throw new TaskException( "repositorydir attribute must be set!" );
}
if( updateIcontrol == true && classDir == null )
{
throw new BuildException( "classdir attribute must be specified when updateicontrol=true!" );
throw new TaskException( "classdir attribute must be specified when updateicontrol=true!" );
}
if( updateIcontrol == true && controlFile == null )
{
throw new BuildException( "controlfile attribute must be specified when updateicontrol=true!" );
throw new TaskException( "controlfile attribute must be specified when updateicontrol=true!" );
}
}

@@ -929,10 +929,10 @@ public class IContract extends MatchingTask
* Also creates a temporary file with a list of the source files, that will
* be deleted upon exit.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void scan()
throws BuildException
throws TaskException
{
long now = ( new Date() ).getTime();

@@ -965,20 +965,20 @@ public class IContract extends MatchingTask
}
for( int i = 0; i < files.length; i++ )
{
File srcFile = new File( srcDir, files[i] );
if( files[i].endsWith( ".java" ) )
File srcFile = new File( srcDir, files[ i ] );
if( files[ i ].endsWith( ".java" ) )
{
// print the target, while we're at here. (Only if generatetarget=true).
if( targetPrinter != null )
{
targetPrinter.println( srcFile.getAbsolutePath() );
}
File classFile = new File( buildDir, files[i].substring( 0, files[i].indexOf( ".java" ) ) + ".class" );
File classFile = new File( buildDir, files[ i ].substring( 0, files[ i ].indexOf( ".java" ) ) + ".class" );

if( srcFile.lastModified() > now )
{
log( "Warning: file modified in the future: " +
files[i], Project.MSG_WARN );
files[ i ], Project.MSG_WARN );
}

if( !classFile.exists() || srcFile.lastModified() > classFile.lastModified() )
@@ -996,7 +996,7 @@ public class IContract extends MatchingTask
}
catch( IOException e )
{
throw new BuildException( "Could not create target file:" + e.getMessage() );
throw new TaskException( "Could not create target file:" + e.getMessage() );
}

// also, check controlFile timestamp
@@ -1012,8 +1012,8 @@ public class IContract extends MatchingTask
files = ds.getIncludedFiles();
for( int i = 0; i < files.length; i++ )
{
File srcFile = new File( srcDir, files[i] );
if( files[i].endsWith( ".class" ) )
File srcFile = new File( srcDir, files[ i ] );
if( files[ i ].endsWith( ".class" ) )
{
if( controlFileTime > srcFile.lastModified() )
{
@@ -1031,7 +1031,7 @@ public class IContract extends MatchingTask
}
catch( Throwable t )
{
throw new BuildException( "Got an interesting exception:" + t.getMessage() );
throw new TaskException( "Got an interesting exception:" + t.getMessage() );
}
}

@@ -1053,7 +1053,9 @@ public class IContract extends MatchingTask
}

// dummy implementation. Never called
public void setJavac( Javac javac ) { }
public void setJavac( Javac javac )
{
}

public boolean execute()
{
@@ -1082,9 +1084,13 @@ public class IContract extends MatchingTask
*/
private class IContractPresenceDetector implements BuildListener
{
public void buildFinished( BuildEvent event ) { }
public void buildFinished( BuildEvent event )
{
}

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

public void messageLogged( BuildEvent event )
{
@@ -1094,12 +1100,20 @@ public class IContract extends MatchingTask
}
}

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 )
{
}
}
}

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

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

import java.io.File;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline;
@@ -229,32 +230,32 @@ public class Javah extends Task
/**
* Executes the task.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{
// first off, make sure that we've got a srcdir

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

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

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

@@ -290,7 +291,7 @@ public class Javah extends Task
{
int n = 0;
log( "Compilation args: " + cmd.toString(),
Project.MSG_VERBOSE );
Project.MSG_VERBOSE );

StringBuffer niceClassList = new StringBuffer();
if( cls != null )
@@ -308,7 +309,7 @@ public class Javah extends Task
Enumeration enum = classes.elements();
while( enum.hasMoreElements() )
{
ClassArgument arg = ( ClassArgument )enum.nextElement();
ClassArgument arg = (ClassArgument)enum.nextElement();
String aClass = arg.getName();
cmd.createArgument().setValue( aClass );
niceClassList.append( " " + aClass + lSep );
@@ -381,7 +382,7 @@ public class Javah extends Task
{
if( !old )
{
throw new BuildException( "stubs only available in old mode." );
throw new TaskException( "stubs only available in old mode." );
}
cmd.createArgument().setValue( "-stubs" );
}
@@ -402,11 +403,11 @@ public class Javah extends Task
* Peforms a compile using the classic compiler that shipped with JDK 1.1
* and 1.2.
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/

private void doClassicCompile()
throws BuildException
throws TaskException
{
Commandline cmd = setupJavahCommand();

@@ -416,7 +417,7 @@ public class Javah extends Task
* sun.tools.javac.Main compiler =
* new sun.tools.javac.Main(new LogOutputStream(this, Project.MSG_WARN), "javac");
* if (!compiler.compile(cmd.getArguments())) {
* throw new BuildException("Compile failed");
* throw new TaskException("Compile failed");
* }
*/
try
@@ -429,20 +430,20 @@ public class Javah extends Task
com.sun.tools.javah.Main main = new com.sun.tools.javah.Main( cmd.getArguments() );
main.run();
}
//catch (ClassNotFoundException ex) {
// throw new BuildException("Cannot use javah because it is not available"+
// " A common solution is to set the environment variable"+
// " JAVA_HOME to your jdk directory.", location);
//}
//catch (ClassNotFoundException ex) {
// throw new TaskException("Cannot use javah because it is not available"+
// " A common solution is to set the environment variable"+
// " JAVA_HOME to your jdk directory.", location);
//}
catch( Exception ex )
{
if( ex instanceof BuildException )
if( ex instanceof TaskException )
{
throw ( BuildException )ex;
throw (TaskException)ex;
}
else
{
throw new BuildException( "Error starting javah: ", ex );
throw new TaskException( "Error starting javah: ", ex );
}
}
}
@@ -451,7 +452,9 @@ public class Javah extends Task
{
private String name;

public ClassArgument() { }
public ClassArgument()
{
}

public void setName( String name )
{


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

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -17,10 +18,9 @@ import java.util.Enumeration;
import java.util.ListIterator;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;


/**
* Task for creating a manifest file for a jar archiv. use: <pre>
* <taskdef name="manifest" classname="ManifestFile"/>
@@ -86,10 +86,10 @@ public class ManifestFile extends Task
/**
* execute task
*
* @exception BuildException : Failure in building
* @exception TaskException : Failure in building
*/
public void execute()
throws BuildException
throws TaskException
{
checkParameters();
if( isUpdate( currentMethod ) )
@@ -111,7 +111,6 @@ public class ManifestFile extends Task
return method.equals( REPLACEALL_.toUpperCase() );
}


private boolean isUpdate( String method )
{
return method.equals( UPDATE_.toUpperCase() );
@@ -125,7 +124,6 @@ public class ManifestFile extends Task
entry.addTo( container );
}


private StringBuffer buildBuffer()
{
StringBuffer buffer = new StringBuffer();
@@ -134,10 +132,10 @@ public class ManifestFile extends Task

while( iterator.hasNext() )
{
Entry entry = ( Entry )iterator.next();
Entry entry = (Entry)iterator.next();

String key = ( String )entry.getKey();
String value = ( String )entry.getValue();
String key = (String)entry.getKey();
String value = (String)entry.getValue();
String entry_string = key + keyValueSeparator + value;

buffer.append( entry_string + this.newLine );
@@ -157,33 +155,33 @@ public class ManifestFile extends Task
}

private void checkParameters()
throws BuildException
throws TaskException
{
if( !checkParam( manifestFile ) )
{
throw new BuildException( "file token must not be null." );
throw new TaskException( "file token must not be null." );
}
}

/**
* adding entries to a container
*
* @exception BuildException
* @exception TaskException
*/
private void executeOperation()
throws BuildException
throws TaskException
{
Enumeration enum = entries.elements();

while( enum.hasMoreElements() )
{
Entry entry = ( Entry )enum.nextElement();
Entry entry = (Entry)enum.nextElement();
entry.addTo( container );
}
}

private void readFile()
throws BuildException
throws TaskException
{

if( manifestFile.exists() )
@@ -207,32 +205,31 @@ public class ManifestFile extends Task
stop = true;
}
else
buffer.append( ( char )c );
buffer.append( (char)c );
}
fis.close();
StringTokenizer lineTokens = getLineTokens( buffer );
while( lineTokens.hasMoreElements() )
{
String currentLine = ( String )lineTokens.nextElement();
String currentLine = (String)lineTokens.nextElement();
addLine( currentLine );
}
}
catch( FileNotFoundException fnfe )
{
throw new BuildException( "File not found exception " + fnfe.toString() );
throw new TaskException( "File not found exception " + fnfe.toString() );
}
catch( IOException ioe )
{
throw new BuildException( "Unknown input/output exception " + ioe.toString() );
throw new TaskException( "Unknown input/output exception " + ioe.toString() );
}
}
}

}


private void writeFile()
throws BuildException
throws TaskException
{
try
{
@@ -248,7 +245,7 @@ public class ManifestFile extends Task

for( int i = 0; i < size; i++ )
{
fos.write( ( char )buffer.charAt( i ) );
fos.write( (char)buffer.charAt( i ) );
}

fos.flush();
@@ -256,13 +253,13 @@ public class ManifestFile extends Task
}
else
{
throw new BuildException( "Can't create manifest file" );
throw new TaskException( "Can't create manifest file" );
}

}
catch( IOException ioe )
{
throw new BuildException( "An input/ouput error occured" + ioe.toString() );
throw new TaskException( "An input/ouput error occured" + ioe.toString() );
}
}

@@ -275,7 +272,9 @@ public class ManifestFile extends Task
private String val = null;
private String key = null;

public Entry() { }
public Entry()
{
}

public void setValue( String value )
{
@@ -298,8 +297,8 @@ public class ManifestFile extends Task

try
{
Entry e1 = ( Entry )o1;
Entry e2 = ( Entry )o2;
Entry e1 = (Entry)o1;
Entry e2 = (Entry)o2;

String key_1 = e1.getKey();
String key_2 = e2.getKey();
@@ -313,21 +312,19 @@ public class ManifestFile extends Task
return result;
}


public boolean equals( Object obj )
{
Entry ent = new Entry();
boolean result = false;
int res = ent.compare( this, ( Entry )obj );
int res = ent.compare( this, (Entry)obj );
if( res == 0 )
result = true;

return result;
}


protected void addTo( EntryContainer container )
throws BuildException
throws TaskException
{
checkFormat();
split();
@@ -335,12 +332,12 @@ public class ManifestFile extends Task
}

private void checkFormat()
throws BuildException
throws TaskException
{

if( value == null )
{
throw new BuildException( "no argument for value" );
throw new TaskException( "no argument for value" );
}

StringTokenizer st = new StringTokenizer( value, ManifestFile.keyValueSeparator );
@@ -348,15 +345,15 @@ public class ManifestFile extends Task

if( size < 2 )
{
throw new BuildException( "value has not the format of a manifest entry" );
throw new TaskException( "value has not the format of a manifest entry" );
}
}

private void split()
{
StringTokenizer st = new StringTokenizer( value, ManifestFile.keyValueSeparator );
key = ( String )st.nextElement();
val = ( String )st.nextElement();
key = (String)st.nextElement();
val = (String)st.nextElement();
}

}


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

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

import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.MatchingTask;
@@ -34,7 +35,6 @@ public class Native2Ascii extends MatchingTask

private Mapper mapper;


/**
* Set the destination dirctory to place converted files into.
*
@@ -93,21 +93,21 @@ public class Native2Ascii extends MatchingTask
* Defines the FileNameMapper to use (nested mapper element).
*
* @return Description of the Returned Value
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public Mapper createMapper()
throws BuildException
throws TaskException
{
if( mapper != null )
{
throw new BuildException( "Cannot define more than one mapper" );
throw new TaskException( "Cannot define more than one mapper" );
}
mapper = new Mapper( project );
return mapper;
}

public void execute()
throws BuildException
throws TaskException
{

Commandline baseCmd = null;// the common portion of our cmd line
@@ -123,7 +123,7 @@ public class Native2Ascii extends MatchingTask
// Require destDir
if( destDir == null )
{
throw new BuildException( "The dest attribute must be set." );
throw new TaskException( "The dest attribute must be set." );
}

// if src and dest dirs are the same, require the extension
@@ -131,8 +131,8 @@ public class Native2Ascii extends MatchingTask
// include a file with the same extension, but ....
if( srcDir.equals( destDir ) && extension == null && mapper == null )
{
throw new BuildException( "The ext attribute or a mapper must be set if"
+ " src and dest dirs are the same." );
throw new TaskException( "The ext attribute or a mapper must be set if"
+ " src and dest dirs are the same." );
}

FileNameMapper m = null;
@@ -162,11 +162,11 @@ public class Native2Ascii extends MatchingTask
return;
}
String message = "Converting " + count + " file"
+ ( count != 1 ? "s" : "" ) + " from ";
+ ( count != 1 ? "s" : "" ) + " from ";
log( message + srcDir + " to " + destDir );
for( int i = 0; i < files.length; i++ )
{
convert( files[i], m.mapFileName( files[i] )[0] );
convert( files[ i ], m.mapFileName( files[ i ] )[ 0 ] );
}
}

@@ -175,10 +175,10 @@ public class Native2Ascii extends MatchingTask
*
* @param srcName Description of Parameter
* @param destName Description of Parameter
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void convert( String srcName, String destName )
throws BuildException
throws TaskException
{

Commandline cmd = new Commandline();// Command line to run
@@ -207,8 +207,8 @@ public class Native2Ascii extends MatchingTask
// Make sure we're not about to clobber something
if( srcFile.equals( destFile ) )
{
throw new BuildException( "file " + srcFile
+ " would overwrite its self" );
throw new TaskException( "file " + srcFile
+ " would overwrite its self" );
}

// Make intermediate directories if needed
@@ -220,26 +220,30 @@ public class Native2Ascii extends MatchingTask

if( ( !parentFile.exists() ) && ( !parentFile.mkdirs() ) )
{
throw new BuildException( "cannot create parent directory "
+ parentName );
throw new TaskException( "cannot create parent directory "
+ parentName );
}
}

log( "converting " + srcName, Project.MSG_VERBOSE );
sun.tools.native2ascii.Main n2a
= new sun.tools.native2ascii.Main();
= new sun.tools.native2ascii.Main();
if( !n2a.convert( cmd.getArguments() ) )
{
throw new BuildException( "conversion failed" );
throw new TaskException( "conversion failed" );
}
}

private class ExtMapper implements FileNameMapper
{

public void setFrom( String s ) { }
public void setFrom( String s )
{
}

public void setTo( String s ) { }
public void setTo( String s )
{
}

public String[] mapFileName( String fileName )
{


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

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

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
@@ -16,11 +17,11 @@ import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Vector;
import netrexx.lang.Rexx;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
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.util.FileUtils;

/**
* Task to compile NetRexx source files. This task can take the following
@@ -113,7 +114,6 @@ public class NetRexxC extends MatchingTask
private boolean time;
private boolean utf8;


/**
* Set whether literals are treated as binary, rather than NetRexx types
*
@@ -263,7 +263,6 @@ public class NetRexxC extends MatchingTask
this.java = java;
}


/**
* Sets whether the generated java source file should be kept after
* compilation. The generated files will have an extension of .java.keep,
@@ -392,7 +391,6 @@ public class NetRexxC extends MatchingTask
this.strictprops = strictprops;
}


/**
* Whether the compiler should force catching of exceptions by explicitly
* named types
@@ -438,15 +436,15 @@ public class NetRexxC extends MatchingTask
public void setTrace( String trace )
{
if( trace.equalsIgnoreCase( "trace" )
|| trace.equalsIgnoreCase( "trace1" )
|| trace.equalsIgnoreCase( "trace2" )
|| trace.equalsIgnoreCase( "notrace" ) )
|| trace.equalsIgnoreCase( "trace1" )
|| trace.equalsIgnoreCase( "trace2" )
|| trace.equalsIgnoreCase( "notrace" ) )
{
this.trace = trace;
}
else
{
throw new BuildException( "Unknown trace value specified: '" + trace + "'" );
throw new TaskException( "Unknown trace value specified: '" + trace + "'" );
}
}

@@ -475,16 +473,16 @@ public class NetRexxC extends MatchingTask
/**
* Executes the task, i.e. does the actual compiler call
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
public void execute()
throws BuildException
throws TaskException
{

// first off, make sure that we've got a srcdir and destdir
if( srcDir == null || destDir == null )
{
throw new BuildException( "srcDir and destDir attributes must be set!" );
throw new TaskException( "srcDir and destDir attributes must be set!" );
}

// scan source and dest dirs to build up both copy lists and
@@ -515,6 +513,7 @@ public class NetRexxC extends MatchingTask
* @return The CompileClasspath value
*/
private String getCompileClasspath()
throws TaskException
{
StringBuffer classpath = new StringBuffer();

@@ -567,7 +566,7 @@ public class NetRexxC extends MatchingTask
options.addElement( "-" + trace );
options.addElement( utf8 ? "-utf8" : "-noutf8" );
options.addElement( "-" + verbose );
String[] results = new String[options.size()];
String[] results = new String[ options.size() ];
options.copyInto( results );
return results;
}
@@ -582,9 +581,10 @@ public class NetRexxC extends MatchingTask
* @param source - source classpath to get file objects.
*/
private void addExistingToClasspath( StringBuffer target, String source )
throws TaskException
{
StringTokenizer tok = new StringTokenizer( source,
System.getProperty( "path.separator" ), false );
System.getProperty( "path.separator" ), false );
while( tok.hasMoreTokens() )
{
File f = resolveFile( tok.nextToken() );
@@ -597,7 +597,7 @@ public class NetRexxC extends MatchingTask
else
{
log( "Dropping from classpath: " +
f.getAbsolutePath(), Project.MSG_VERBOSE );
f.getAbsolutePath(), Project.MSG_VERBOSE );
}
}

@@ -616,8 +616,8 @@ public class NetRexxC extends MatchingTask
Enumeration enum = filecopyList.keys();
while( enum.hasMoreElements() )
{
String fromFile = ( String )enum.nextElement();
String toFile = ( String )filecopyList.get( fromFile );
String fromFile = (String)enum.nextElement();
String toFile = (String)filecopyList.get( fromFile );
try
{
FileUtils.newFileUtils().copyFile( fromFile, toFile );
@@ -625,8 +625,8 @@ public class NetRexxC extends MatchingTask
catch( IOException ioe )
{
String msg = "Failed to copy " + fromFile + " to " + toFile
+ " due to " + ioe.getMessage();
throw new BuildException( msg, ioe );
+ " due to " + ioe.getMessage();
throw new TaskException( msg, ioe );
}
}
}
@@ -635,10 +635,10 @@ public class NetRexxC extends MatchingTask
/**
* Peforms a copmile using the NetRexx 1.1.x compiler
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void doNetRexxCompile()
throws BuildException
throws TaskException
{
log( "Using NetRexx compiler", Project.MSG_VERBOSE );
String classpath = getCompileClasspath();
@@ -648,30 +648,30 @@ public class NetRexxC extends MatchingTask
// create an array of strings for input to the compiler: one array
// comes from the compile options, the other from the compileList
String[] compileOptionsArray = getCompileOptionsAsArray();
String[] fileListArray = new String[compileList.size()];
String[] fileListArray = new String[ compileList.size() ];
Enumeration e = compileList.elements();
int j = 0;
while( e.hasMoreElements() )
{
fileListArray[j] = ( String )e.nextElement();
fileListArray[ j ] = (String)e.nextElement();
j++;
}
// create a single array of arguments for the compiler
String compileArgs[] = new String[compileOptionsArray.length + fileListArray.length];
String compileArgs[] = new String[ compileOptionsArray.length + fileListArray.length ];
for( int i = 0; i < compileOptionsArray.length; i++ )
{
compileArgs[i] = compileOptionsArray[i];
compileArgs[ i ] = compileOptionsArray[ i ];
}
for( int i = 0; i < fileListArray.length; i++ )
{
compileArgs[i + compileOptionsArray.length] = fileListArray[i];
compileArgs[ i + compileOptionsArray.length ] = fileListArray[ i ];
}

// print nice output about what we are doing for the log
compileOptions.append( "Compilation args: " );
for( int i = 0; i < compileOptionsArray.length; i++ )
{
compileOptions.append( compileOptionsArray[i] );
compileOptions.append( compileOptionsArray[ i ] );
compileOptions.append( " " );
}
log( compileOptions.toString(), Project.MSG_VERBOSE );
@@ -704,7 +704,7 @@ public class NetRexxC extends MatchingTask
{// 1 is warnings from real NetRexxC
log( out.toString(), Project.MSG_ERR );
String msg = "Compile failed, messages should have been provided.";
throw new BuildException( msg );
throw new TaskException( msg );
}
else if( rc == 1 )
{
@@ -736,9 +736,9 @@ public class NetRexxC extends MatchingTask
{
for( int i = 0; i < files.length; i++ )
{
File srcFile = new File( srcDir, files[i] );
File destFile = new File( destDir, files[i] );
String filename = files[i];
File srcFile = new File( srcDir, files[ i ] );
File destFile = new File( destDir, files[ i ] );
String filename = files[ i ];
// if it's a non source file, copy it if a later date than the
// dest
// if it's a source file, see if the destination class file
@@ -747,7 +747,7 @@ public class NetRexxC extends MatchingTask
{
File classFile =
new File( destDir,
filename.substring( 0, filename.lastIndexOf( '.' ) ) + ".class" );
filename.substring( 0, filename.lastIndexOf( '.' ) ) + ".class" );

if( !compile || srcFile.lastModified() > classFile.lastModified() )
{


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

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

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
@@ -25,7 +26,7 @@ import java.util.Enumeration;
import java.util.GregorianCalendar;
import java.util.Properties;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.EnumeratedAttribute;

@@ -178,7 +179,7 @@ public class PropertyFile extends Task
* Methods
*/
public void execute()
throws BuildException
throws TaskException
{
checkParameters();
readFile();
@@ -200,26 +201,26 @@ public class PropertyFile extends Task
}

private void checkParameters()
throws BuildException
throws TaskException
{
if( !checkParam( m_propertyfile ) )
{
throw new BuildException( "file token must not be null." );
throw new TaskException( "file token must not be null." );
}
}

private void executeOperation()
throws BuildException
throws TaskException
{
for( Enumeration e = entries.elements(); e.hasMoreElements(); )
for( Enumeration e = entries.elements(); e.hasMoreElements(); )
{
Entry entry = ( Entry )e.nextElement();
Entry entry = (Entry)e.nextElement();
entry.executeOn( m_properties );
}
}

private void readFile()
throws BuildException
throws TaskException
{
// Create the PropertyFile
m_properties = new Properties();
@@ -246,7 +247,7 @@ public class PropertyFile extends Task
else
{
log( "Creating new property file: " +
m_propertyfile.getAbsolutePath() );
m_propertyfile.getAbsolutePath() );
FileOutputStream out = null;
try
{
@@ -264,12 +265,12 @@ public class PropertyFile extends Task
}
catch( IOException ioe )
{
throw new BuildException( ioe.toString() );
throw new TaskException( ioe.toString() );
}
}

private void writeFile()
throws BuildException
throws TaskException
{
BufferedOutputStream bos = null;
try
@@ -279,10 +280,10 @@ public class PropertyFile extends Task
// Properties.store is not available in JDK 1.1
Method m =
Properties.class.getMethod( "store",
new Class[]{
OutputStream.class,
String.class}
);
new Class[]{
OutputStream.class,
String.class}
);
m.invoke( m_properties, new Object[]{bos, m_comment} );

}
@@ -293,16 +294,16 @@ public class PropertyFile extends Task
catch( InvocationTargetException ite )
{
Throwable t = ite.getTargetException();
throw new BuildException( "Error", t );
throw new TaskException( "Error", t );
}
catch( IllegalAccessException iae )
{
// impossible
throw new BuildException( "Error", iae );
throw new TaskException( "Error", iae );
}
catch( IOException ioe )
{
throw new BuildException( "Error", ioe );
throw new TaskException( "Error", ioe );
}
finally
{
@@ -313,7 +314,8 @@ public class PropertyFile extends Task
bos.close();
}
catch( IOException ioex )
{}
{
}
}
}
}
@@ -385,7 +387,7 @@ public class PropertyFile extends Task
}

protected void executeOn( Properties props )
throws BuildException
throws TaskException
{
checkParameters();

@@ -394,19 +396,19 @@ public class PropertyFile extends Task
{
if( m_type == Type.INTEGER_TYPE )
{
executeInteger( ( String )props.get( m_key ) );
executeInteger( (String)props.get( m_key ) );
}
else if( m_type == Type.DATE_TYPE )
{
executeDate( ( String )props.get( m_key ) );
executeDate( (String)props.get( m_key ) );
}
else if( m_type == Type.STRING_TYPE )
{
executeString( ( String )props.get( m_key ) );
executeString( (String)props.get( m_key ) );
}
else
{
throw new BuildException( "Unknown operation type: " + m_type + "" );
throw new TaskException( "Unknown operation type: " + m_type + "" );
}
}
catch( NullPointerException npe )
@@ -423,28 +425,28 @@ public class PropertyFile extends Task
/**
* Check if parameter combinations can be supported
*
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void checkParameters()
throws BuildException
throws TaskException
{
if( m_type == Type.STRING_TYPE &&
m_operation == Operation.DECREMENT_OPER )
{
throw new BuildException( "- is not suported for string properties (key:" + m_key + ")" );
throw new TaskException( "- is not suported for string properties (key:" + m_key + ")" );
}
if( m_value == null && m_default == null )
{
throw new BuildException( "value and/or default must be specified (key:" + m_key + ")" );
throw new TaskException( "value and/or default must be specified (key:" + m_key + ")" );
}
if( m_key == null )
{
throw new BuildException( "key is mandatory" );
throw new TaskException( "key is mandatory" );
}
if( m_type == Type.STRING_TYPE &&
m_pattern != null )
{
throw new BuildException( "pattern is not suported for string properties (key:" + m_key + ")" );
throw new TaskException( "pattern is not suported for string properties (key:" + m_key + ")" );
}
}

@@ -454,10 +456,10 @@ public class PropertyFile extends Task
* @param oldValue the current value read from the property file or
* <code>null</code> if the <code>key</code> was not contained in
* the property file.
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void executeDate( String oldValue )
throws BuildException
throws TaskException
{
GregorianCalendar value = new GregorianCalendar();
GregorianCalendar newValue = new GregorianCalendar();
@@ -577,23 +579,22 @@ public class PropertyFile extends Task
}
}


/**
* Handle operations for type <code>int</code>.
*
* @param oldValue the current value read from the property file or
* <code>null</code> if the <code>key</code> was not contained in
* the property file.
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void executeInteger( String oldValue )
throws BuildException
throws TaskException
{
int value = 0;
int newValue = 0;

DecimalFormat fmt = ( m_pattern != null ) ? new DecimalFormat( m_pattern )
: new DecimalFormat();
: new DecimalFormat();

if( oldValue != null )
{
@@ -674,10 +675,10 @@ public class PropertyFile extends Task
* @param oldValue the current value read from the property file or
* <code>null</code> if the <code>key</code> was not contained in
* the property file.
* @exception BuildException Description of Exception
* @exception TaskException Description of Exception
*/
private void executeString( String oldValue )
throws BuildException
throws TaskException
{
String value = "";
String newValue = "";


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

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

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -14,9 +15,8 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.PrintWriter;
import java.util.Random;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
@@ -117,18 +117,20 @@ public class ReplaceRegExp extends Task
}

public void setMatch( String match )
throws TaskException
{
if( regex != null )
throw new BuildException( "Only one regular expression is allowed" );
throw new TaskException( "Only one regular expression is allowed" );

regex = new RegularExpression();
regex.setPattern( match );
}

public void setReplace( String replace )
throws TaskException
{
if( subs != null )
throw new BuildException( "Only one substitution expression is allowed" );
throw new TaskException( "Only one substitution expression is allowed" );

subs = new Substitution();
subs.setExpression( replace );
@@ -140,33 +142,35 @@ public class ReplaceRegExp extends Task
}

public RegularExpression createRegularExpression()
throws TaskException
{
if( regex != null )
throw new BuildException( "Only one regular expression is allowed." );
throw new TaskException( "Only one regular expression is allowed." );

regex = new RegularExpression();
return regex;
}

public Substitution createSubstitution()
throws TaskException
{
if( subs != null )
throw new BuildException( "Only one substitution expression is allowed" );
throw new TaskException( "Only one substitution expression is allowed" );

subs = new Substitution();
return subs;
}

public void execute()
throws BuildException
throws TaskException
{
if( regex == null )
throw new BuildException( "No expression to match." );
throw new TaskException( "No expression to match." );
if( subs == null )
throw new BuildException( "Nothing to replace expression with." );
throw new TaskException( "Nothing to replace expression with." );

if( file != null && filesets.size() > 0 )
throw new BuildException( "You cannot supply the 'file' attribute and filesets at the same time." );
throw new TaskException( "You cannot supply the 'file' attribute and filesets at the same time." );

int options = 0;

@@ -191,25 +195,25 @@ public class ReplaceRegExp extends Task
catch( IOException e )
{
log( "An error occurred processing file: '" + file.getAbsolutePath() + "': " + e.toString(),
Project.MSG_ERR );
Project.MSG_ERR );
}
}
else if( file != null )
{
log( "The following file is missing: '" + file.getAbsolutePath() + "'",
Project.MSG_ERR );
Project.MSG_ERR );
}

int sz = filesets.size();
for( int i = 0; i < sz; i++ )
{
FileSet fs = ( FileSet )( filesets.elementAt( i ) );
FileSet fs = (FileSet)( filesets.elementAt( i ) );
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );

String files[] = ds.getIncludedFiles();
for( int j = 0; j < files.length; j++ )
{
File f = new File( files[j] );
File f = new File( files[ j ] );
if( f.exists() )
{
try
@@ -219,19 +223,18 @@ public class ReplaceRegExp extends Task
catch( Exception e )
{
log( "An error occurred processing file: '" + f.getAbsolutePath() + "': " + e.toString(),
Project.MSG_ERR );
Project.MSG_ERR );
}
}
else
{
log( "The following file is missing: '" + file.getAbsolutePath() + "'",
Project.MSG_ERR );
Project.MSG_ERR );
}
}
}
}


protected String doReplace( RegularExpression r,
Substitution s,
String input,
@@ -276,11 +279,11 @@ public class ReplaceRegExp extends Task
boolean changes = false;

log( "Replacing pattern '" + regex.getPattern( project ) + "' with '" + subs.getExpression( project ) +
"' in '" + f.getPath() + "'" +
( byline ? " by line" : "" ) +
( flags.length() > 0 ? " with flags: '" + flags + "'" : "" ) +
".",
Project.MSG_WARN );
"' in '" + f.getPath() + "'" +
( byline ? " by line" : "" ) +
( flags.length() > 0 ? " with flags: '" + flags + "'" : "" ) +
".",
Project.MSG_WARN );

if( byline )
{
@@ -299,8 +302,8 @@ public class ReplaceRegExp extends Task
}
else
{
int flen = ( int )( f.length() );
char tmpBuf[] = new char[flen];
int flen = (int)( f.length() );
char tmpBuf[] = new char[ flen ];
int numread = 0;
int totread = 0;
while( numread != -1 && totread < flen )
@@ -342,7 +345,8 @@ public class ReplaceRegExp extends Task
r.close();
}
catch( Exception e )
{}
{
}
;

try
@@ -351,7 +355,8 @@ public class ReplaceRegExp extends Task
r.close();
}
catch( Exception e )
{}
{
}
;
}
}


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

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

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Execute;
@@ -102,7 +103,7 @@ public class Rpm extends Task
{
if( ( sf == null ) || ( sf.trim().equals( "" ) ) )
{
throw new BuildException( "You must specify a spec file" );
throw new TaskException( "You must specify a spec file" );
}
this.specFile = sf;
}
@@ -113,7 +114,7 @@ public class Rpm extends Task
}

public void execute()
throws BuildException
throws TaskException
{

Commandline toExecute = new Commandline();
@@ -148,7 +149,7 @@ public class Rpm extends Task
if( error == null && output == null )
{
streamhandler = new LogStreamHandler( this, Project.MSG_INFO,
Project.MSG_WARN );
Project.MSG_WARN );
}
else
{
@@ -160,7 +161,7 @@ public class Rpm extends Task
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
}
else
@@ -175,7 +176,7 @@ public class Rpm extends Task
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
}
else
@@ -200,7 +201,7 @@ public class Rpm extends Task
}
catch( IOException e )
{
throw new BuildException( "Error", e );
throw new TaskException( "Error", e );
}
finally
{
@@ -211,7 +212,8 @@ public class Rpm extends Task
outputstream.close();
}
catch( IOException e )
{}
{
}
}
if( error != null )
{
@@ -220,7 +222,8 @@ public class Rpm extends Task
errorstream.close();
}
catch( IOException e )
{}
{
}
}
}
}


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

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

import com.ibm.bsf.BSFException;
import com.ibm.bsf.BSFManager;
import java.io.File;
@@ -13,7 +14,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;

/**
@@ -46,10 +47,10 @@ public class Script extends Task
{
File file = new File( fileName );
if( !file.exists() )
throw new BuildException( "file " + fileName + " not found." );
throw new TaskException( "file " + fileName + " not found." );

int count = ( int )file.length();
byte data[] = new byte[count];
int count = (int)file.length();
byte data[] = new byte[ count ];

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

script += new String( data );
@@ -78,10 +79,10 @@ public class Script extends Task
/**
* Do the work.
*
* @exception BuildException if someting goes wrong with the build
* @exception TaskException if someting goes wrong with the build
*/
public void execute()
throws BuildException
throws TaskException
{
try
{
@@ -96,9 +97,9 @@ public class Script extends Task

BSFManager manager = new BSFManager();

for( Enumeration e = beans.keys(); e.hasMoreElements(); )
for( Enumeration e = beans.keys(); e.hasMoreElements(); )
{
String key = ( String )e.nextElement();
String key = (String)e.nextElement();
Object value = beans.get( key );
manager.declareBean( key, value, value.getClass() );
}
@@ -112,16 +113,16 @@ public class Script extends Task
Throwable te = be.getTargetException();
if( te != null )
{
if( te instanceof BuildException )
if( te instanceof TaskException )
{
throw ( BuildException )te;
throw (TaskException)te;
}
else
{
t = te;
}
}
throw new BuildException( "Error", t );
throw new TaskException( "Error", t );
}
}

@@ -132,9 +133,9 @@ public class Script extends Task
*/
private void addBeans( Hashtable dictionary )
{
for( Enumeration e = dictionary.keys(); e.hasMoreElements(); )
for( Enumeration e = dictionary.keys(); e.hasMoreElements(); )
{
String key = ( String )e.nextElement();
String key = (String)e.nextElement();

boolean isValid = key.length() > 0 &&
Character.isJavaIdentifierStart( key.charAt( 0 ) );


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

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

import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.taskdefs.Java;

/**
@@ -18,7 +19,7 @@ import org.apache.tools.ant.taskdefs.Java;
* B&ouml;rger</a>
*/
public class StyleBook
extends Java
extends Java
{
protected File m_book;
protected String m_loaderConfig;
@@ -53,22 +54,22 @@ public class StyleBook
}

public void execute()
throws BuildException
throws TaskException
{

if( null == m_targetDirectory )
{
throw new BuildException( "TargetDirectory attribute not set." );
throw new TaskException( "TargetDirectory attribute not set." );
}

if( null == m_skinDirectory )
{
throw new BuildException( "SkinDirectory attribute not set." );
throw new TaskException( "SkinDirectory attribute not set." );
}

if( null == m_book )
{
throw new BuildException( "book attribute not set." );
throw new TaskException( "book attribute not set." );
}

createArg().setValue( "targetDirectory=" + m_targetDirectory );


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

Loading…
Cancel
Save