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-ffa450edef68master
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| @@ -16,7 +17,7 @@ import java.io.UnsupportedEncodingException; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.IntrospectionHelper; | import org.apache.tools.ant.IntrospectionHelper; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.TaskContainer; | import org.apache.tools.ant.TaskContainer; | ||||
| @@ -31,7 +32,6 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||||
| public class AntStructure extends Task | public class AntStructure extends Task | ||||
| { | { | ||||
| private final String lSep = System.getProperty( "line.separator" ); | private final String lSep = System.getProperty( "line.separator" ); | ||||
| private final String BOOLEAN = "%boolean;"; | private final String BOOLEAN = "%boolean;"; | ||||
| @@ -53,12 +53,12 @@ public class AntStructure extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( output == null ) | if( output == null ) | ||||
| { | { | ||||
| throw new BuildException( "output attribute is required" ); | |||||
| throw new TaskException( "output attribute is required" ); | |||||
| } | } | ||||
| PrintWriter out = null; | PrintWriter out = null; | ||||
| @@ -80,24 +80,24 @@ public class AntStructure extends Task | |||||
| } | } | ||||
| printHead( out, project.getTaskDefinitions().keys(), | printHead( out, project.getTaskDefinitions().keys(), | ||||
| project.getDataTypeDefinitions().keys() ); | |||||
| project.getDataTypeDefinitions().keys() ); | |||||
| printTargetDecl( out ); | printTargetDecl( out ); | ||||
| Enumeration dataTypes = project.getDataTypeDefinitions().keys(); | Enumeration dataTypes = project.getDataTypeDefinitions().keys(); | ||||
| while( dataTypes.hasMoreElements() ) | while( dataTypes.hasMoreElements() ) | ||||
| { | { | ||||
| String typeName = ( String )dataTypes.nextElement(); | |||||
| String typeName = (String)dataTypes.nextElement(); | |||||
| printElementDecl( out, typeName, | printElementDecl( out, typeName, | ||||
| ( Class )project.getDataTypeDefinitions().get( typeName ) ); | |||||
| (Class)project.getDataTypeDefinitions().get( typeName ) ); | |||||
| } | } | ||||
| Enumeration tasks = project.getTaskDefinitions().keys(); | Enumeration tasks = project.getTaskDefinitions().keys(); | ||||
| while( tasks.hasMoreElements() ) | while( tasks.hasMoreElements() ) | ||||
| { | { | ||||
| String taskName = ( String )tasks.nextElement(); | |||||
| String taskName = (String)tasks.nextElement(); | |||||
| printElementDecl( out, taskName, | printElementDecl( out, taskName, | ||||
| ( Class )project.getTaskDefinitions().get( taskName ) ); | |||||
| (Class)project.getTaskDefinitions().get( taskName ) ); | |||||
| } | } | ||||
| printTail( out ); | printTail( out ); | ||||
| @@ -105,8 +105,8 @@ public class AntStructure extends Task | |||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| throw new BuildException( "Error writing " + output.getAbsolutePath(), | |||||
| ioe ); | |||||
| throw new TaskException( "Error writing " + output.getAbsolutePath(), | |||||
| ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -152,7 +152,7 @@ public class AntStructure extends Task | |||||
| { | { | ||||
| for( int i = 0; i < s.length; i++ ) | for( int i = 0; i < s.length; i++ ) | ||||
| { | { | ||||
| if( !isNmtoken( s[i] ) ) | |||||
| if( !isNmtoken( s[ i ] ) ) | |||||
| { | { | ||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -161,7 +161,7 @@ public class AntStructure extends Task | |||||
| } | } | ||||
| private void printElementDecl( PrintWriter out, String name, Class element ) | private void printElementDecl( PrintWriter out, String name, Class element ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( visited.containsKey( name ) ) | if( visited.containsKey( name ) ) | ||||
| @@ -213,7 +213,7 @@ public class AntStructure extends Task | |||||
| Enumeration enum = ih.getNestedElements(); | Enumeration enum = ih.getNestedElements(); | ||||
| while( enum.hasMoreElements() ) | while( enum.hasMoreElements() ) | ||||
| { | { | ||||
| v.addElement( ( String )enum.nextElement() ); | |||||
| v.addElement( (String)enum.nextElement() ); | |||||
| } | } | ||||
| if( v.isEmpty() ) | if( v.isEmpty() ) | ||||
| @@ -247,7 +247,7 @@ public class AntStructure extends Task | |||||
| enum = ih.getAttributes(); | enum = ih.getAttributes(); | ||||
| while( enum.hasMoreElements() ) | while( enum.hasMoreElements() ) | ||||
| { | { | ||||
| String attrName = ( String )enum.nextElement(); | |||||
| String attrName = (String)enum.nextElement(); | |||||
| if( "id".equals( attrName ) ) | if( "id".equals( attrName ) ) | ||||
| continue; | continue; | ||||
| @@ -267,11 +267,11 @@ public class AntStructure extends Task | |||||
| try | try | ||||
| { | { | ||||
| EnumeratedAttribute ea = | EnumeratedAttribute ea = | ||||
| ( EnumeratedAttribute )type.newInstance(); | |||||
| (EnumeratedAttribute)type.newInstance(); | |||||
| String[] values = ea.getValues(); | String[] values = ea.getValues(); | ||||
| if( values == null | if( values == null | ||||
| || values.length == 0 | |||||
| || !areNmtokens( values ) ) | |||||
| || values.length == 0 | |||||
| || !areNmtokens( values ) ) | |||||
| { | { | ||||
| sb.append( "CDATA " ); | sb.append( "CDATA " ); | ||||
| } | } | ||||
| @@ -284,7 +284,7 @@ public class AntStructure extends Task | |||||
| { | { | ||||
| sb.append( " | " ); | sb.append( " | " ); | ||||
| } | } | ||||
| sb.append( values[i] ); | |||||
| sb.append( values[ i ] ); | |||||
| } | } | ||||
| sb.append( ") " ); | sb.append( ") " ); | ||||
| } | } | ||||
| @@ -309,11 +309,11 @@ public class AntStructure extends Task | |||||
| for( int i = 0; i < v.size(); i++ ) | for( int i = 0; i < v.size(); i++ ) | ||||
| { | { | ||||
| String nestedName = ( String )v.elementAt( i ); | |||||
| String nestedName = (String)v.elementAt( i ); | |||||
| if( !"#PCDATA".equals( nestedName ) && | if( !"#PCDATA".equals( nestedName ) && | ||||
| !TASKS.equals( nestedName ) && | !TASKS.equals( nestedName ) && | ||||
| !TYPES.equals( nestedName ) | !TYPES.equals( nestedName ) | ||||
| ) | |||||
| ) | |||||
| { | { | ||||
| printElementDecl( out, nestedName, ih.getElementType( nestedName ) ); | printElementDecl( out, nestedName, ih.getElementType( nestedName ) ); | ||||
| } | } | ||||
| @@ -329,7 +329,7 @@ public class AntStructure extends Task | |||||
| boolean first = true; | boolean first = true; | ||||
| while( tasks.hasMoreElements() ) | while( tasks.hasMoreElements() ) | ||||
| { | { | ||||
| String taskName = ( String )tasks.nextElement(); | |||||
| String taskName = (String)tasks.nextElement(); | |||||
| if( !first ) | if( !first ) | ||||
| { | { | ||||
| out.print( " | " ); | out.print( " | " ); | ||||
| @@ -345,7 +345,7 @@ public class AntStructure extends Task | |||||
| first = true; | first = true; | ||||
| while( types.hasMoreElements() ) | while( types.hasMoreElements() ) | ||||
| { | { | ||||
| String typeName = ( String )types.nextElement(); | |||||
| String typeName = (String)types.nextElement(); | |||||
| if( !first ) | if( !first ) | ||||
| { | { | ||||
| out.print( " | " ); | out.print( " | " ); | ||||
| @@ -370,7 +370,9 @@ public class AntStructure extends Task | |||||
| out.println( "" ); | out.println( "" ); | ||||
| } | } | ||||
| private void printTail( PrintWriter out ) { } | |||||
| private void printTail( PrintWriter out ) | |||||
| { | |||||
| } | |||||
| private void printTargetDecl( PrintWriter out ) | private void printTargetDecl( PrintWriter out ) | ||||
| { | { | ||||
| @@ -6,9 +6,10 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.taskdefs.condition.Condition; | 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.Path; | ||||
| import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * Will set the given property if the requested resource is available at | * Will set the given property if the requested resource is available at | ||||
| @@ -80,8 +80,7 @@ public class Available | |||||
| this.resource = resource; | this.resource = resource; | ||||
| } | } | ||||
| public void setType( FileDir type ) | |||||
| public void setType( FileDir type ) | |||||
| { | { | ||||
| this.type = type; | this.type = type; | ||||
| } | } | ||||
| @@ -114,7 +113,7 @@ public class Available | |||||
| { | { | ||||
| if( classname == null && file == null && resource == null ) | if( classname == null && file == null && resource == null ) | ||||
| { | { | ||||
| throw new BuildException( "At least one of (classname|file|resource) is required" ); | |||||
| throw new TaskException( "At least one of (classname|file|resource) is required" ); | |||||
| } | } | ||||
| if( type != null ) | if( type != null ) | ||||
| @@ -169,7 +168,7 @@ public class Available | |||||
| { | { | ||||
| if( property == null ) | if( property == null ) | ||||
| { | { | ||||
| throw new BuildException( "property attribute is required"); | |||||
| throw new TaskException( "property attribute is required" ); | |||||
| } | } | ||||
| if( eval() ) | if( eval() ) | ||||
| @@ -218,6 +217,7 @@ public class Available | |||||
| } | } | ||||
| private boolean checkFile() | private boolean checkFile() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( filepath == null ) | if( filepath == null ) | ||||
| { | { | ||||
| @@ -228,7 +228,7 @@ public class Available | |||||
| String[] paths = filepath.list(); | String[] paths = filepath.list(); | ||||
| for( int i = 0; i < paths.length; ++i ) | 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 | * filepath can be a list of directory and/or | ||||
| * file names (gen'd via <fileset>) | * file names (gen'd via <fileset>) | ||||
| @@ -242,11 +242,11 @@ public class Available | |||||
| * simple name specified == parent of parent dir + name | * 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 | // ** full-pathname specified == path in list | ||||
| // ** simple name 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 ) | if( type == null ) | ||||
| { | { | ||||
| @@ -254,13 +254,13 @@ public class Available | |||||
| return true; | return true; | ||||
| } | } | ||||
| else if( type.isDir() | else if( type.isDir() | ||||
| && path.isDirectory() ) | |||||
| && path.isDirectory() ) | |||||
| { | { | ||||
| log( "Found directory: " + path, Project.MSG_VERBOSE ); | log( "Found directory: " + path, Project.MSG_VERBOSE ); | ||||
| return true; | return true; | ||||
| } | } | ||||
| else if( type.isFile() | else if( type.isFile() | ||||
| && path.isFile() ) | |||||
| && path.isFile() ) | |||||
| { | { | ||||
| log( "Found file: " + path, Project.MSG_VERBOSE ); | log( "Found file: " + path, Project.MSG_VERBOSE ); | ||||
| return true; | return true; | ||||
| @@ -273,7 +273,7 @@ public class Available | |||||
| File parent = fileUtils.getParentFile( path ); | File parent = fileUtils.getParentFile( path ); | ||||
| // ** full-pathname specified == parent dir of path in list | // ** full-pathname specified == parent dir of path in list | ||||
| if( parent != null && parent.exists() | if( parent != null && parent.exists() | ||||
| && file.equals( parent.getAbsolutePath() ) ) | |||||
| && file.equals( parent.getAbsolutePath() ) ) | |||||
| { | { | ||||
| if( type == null ) | if( type == null ) | ||||
| { | { | ||||
| @@ -293,7 +293,7 @@ public class Available | |||||
| if( path.exists() && path.isDirectory() ) | if( path.exists() && path.isDirectory() ) | ||||
| { | { | ||||
| if( checkFile( new File( path, file ), | if( checkFile( new File( path, file ), | ||||
| file + " in " + path ) ) | |||||
| file + " in " + path ) ) | |||||
| { | { | ||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -303,7 +303,7 @@ public class Available | |||||
| if( parent != null && parent.exists() ) | if( parent != null && parent.exists() ) | ||||
| { | { | ||||
| if( checkFile( new File( parent, file ), | if( checkFile( new File( parent, file ), | ||||
| file + " in " + parent ) ) | |||||
| file + " in " + parent ) ) | |||||
| { | { | ||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -316,7 +316,7 @@ public class Available | |||||
| if( grandParent != null && grandParent.exists() ) | if( grandParent != null && grandParent.exists() ) | ||||
| { | { | ||||
| if( checkFile( new File( grandParent, file ), | if( checkFile( new File( grandParent, file ), | ||||
| file + " in " + grandParent ) ) | |||||
| file + " in " + grandParent ) ) | |||||
| { | { | ||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -6,11 +6,12 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.bzip2.CBZip2InputStream; | import org.apache.tools.bzip2.CBZip2InputStream; | ||||
| /** | /** | ||||
| @@ -49,26 +50,26 @@ public class BUnzip2 extends Unpack | |||||
| int b = bis.read(); | int b = bis.read(); | ||||
| if( b != 'B' ) | if( b != 'B' ) | ||||
| { | { | ||||
| throw new BuildException( "Invalid bz2 file." ); | |||||
| throw new TaskException( "Invalid bz2 file." ); | |||||
| } | } | ||||
| b = bis.read(); | b = bis.read(); | ||||
| if( b != 'Z' ) | if( b != 'Z' ) | ||||
| { | { | ||||
| throw new BuildException( "Invalid bz2 file." ); | |||||
| throw new TaskException( "Invalid bz2 file." ); | |||||
| } | } | ||||
| zIn = new CBZip2InputStream( bis ); | zIn = new CBZip2InputStream( bis ); | ||||
| byte[] buffer = new byte[8 * 1024]; | |||||
| byte[] buffer = new byte[ 8 * 1024 ]; | |||||
| int count = 0; | int count = 0; | ||||
| do | do | ||||
| { | { | ||||
| out.write( buffer, 0, count ); | out.write( buffer, 0, count ); | ||||
| count = zIn.read( buffer, 0, buffer.length ); | count = zIn.read( buffer, 0, buffer.length ); | ||||
| }while ( count != -1 ); | |||||
| } while( count != -1 ); | |||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "Problem expanding bzip2 " + ioe.getMessage(); | String msg = "Problem expanding bzip2 " + ioe.getMessage(); | ||||
| throw new BuildException( msg, ioe ); | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -79,7 +80,8 @@ public class BUnzip2 extends Unpack | |||||
| bis.close(); | bis.close(); | ||||
| } | } | ||||
| catch( IOException ioex ) | catch( IOException ioex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( fis != null ) | if( fis != null ) | ||||
| { | { | ||||
| @@ -88,7 +90,8 @@ public class BUnzip2 extends Unpack | |||||
| fis.close(); | fis.close(); | ||||
| } | } | ||||
| catch( IOException ioex ) | catch( IOException ioex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( out != null ) | if( out != null ) | ||||
| { | { | ||||
| @@ -97,7 +100,8 @@ public class BUnzip2 extends Unpack | |||||
| out.close(); | out.close(); | ||||
| } | } | ||||
| catch( IOException ioex ) | catch( IOException ioex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( zIn != null ) | if( zIn != null ) | ||||
| { | { | ||||
| @@ -106,7 +110,8 @@ public class BUnzip2 extends Unpack | |||||
| zIn.close(); | zIn.close(); | ||||
| } | } | ||||
| catch( IOException ioex ) | catch( IOException ioex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,11 +6,11 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | 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; | import org.apache.tools.bzip2.CBZip2OutputStream; | ||||
| /** | /** | ||||
| @@ -37,7 +37,7 @@ public class BZip2 extends Pack | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "Problem creating bzip2 " + ioe.getMessage(); | String msg = "Problem creating bzip2 " + ioe.getMessage(); | ||||
| throw new BuildException( msg, ioe ); | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -49,7 +49,8 @@ public class BZip2 extends Pack | |||||
| zOut.close(); | zOut.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,15 +6,15 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.PrintWriter; | 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.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.Task; | |||||
| /** | /** | ||||
| * CVSLogin Adds an new entry to a CVS password file | * CVSLogin Adds an new entry to a CVS password file | ||||
| @@ -100,10 +100,10 @@ public class CVSPass extends Task | |||||
| /** | /** | ||||
| * Does the work. | * 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() | public final void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( cvsRoot == null ) | if( cvsRoot == null ) | ||||
| throw new TaskException( "cvsroot is required" ); | throw new TaskException( "cvsroot is required" ); | ||||
| @@ -148,7 +148,7 @@ public class CVSPass extends Task | |||||
| } | } | ||||
| catch( IOException e ) | 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(); | StringBuffer buf = new StringBuffer(); | ||||
| for( int i = 0; i < password.length(); i++ ) | for( int i = 0; i < password.length(); i++ ) | ||||
| { | { | ||||
| buf.append( shifts[password.charAt( i )] ); | |||||
| buf.append( shifts[ password.charAt( i ) ] ); | |||||
| } | } | ||||
| return buf.toString(); | return buf.toString(); | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| @@ -19,13 +20,11 @@ import java.security.NoSuchProviderException; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | |||||
| import org.apache.tools.ant.taskdefs.condition.Condition; | import org.apache.tools.ant.taskdefs.condition.Condition; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * This task can be used to create checksums for files. It can also be used to | * This task can be used to create checksums for files. It can also be used to | ||||
| @@ -169,10 +168,10 @@ public class Checksum extends MatchingTask implements Condition | |||||
| * | * | ||||
| * @return Returns true if the checksum verification test passed, false | * @return Returns true if the checksum verification test passed, false | ||||
| * otherwise. | * otherwise. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public boolean eval() | public boolean eval() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| isCondition = true; | isCondition = true; | ||||
| return validateAndExecute(); | return validateAndExecute(); | ||||
| @@ -181,16 +180,16 @@ public class Checksum extends MatchingTask implements Condition | |||||
| /** | /** | ||||
| * Calculate the checksum(s). | * Calculate the checksum(s). | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| boolean value = validateAndExecute(); | boolean value = validateAndExecute(); | ||||
| if( verifyProperty != null ) | if( verifyProperty != null ) | ||||
| { | { | ||||
| project.setNewProperty( verifyProperty, | 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. | * Add key-value pair to the hashtable upon which to later operate upon. | ||||
| * | * | ||||
| * @param file The feature to be added to the ToIncludeFileMap attribute | * @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 ) | private void addToIncludeFileMap( File file ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( file != null ) | if( file != null ) | ||||
| { | { | ||||
| @@ -218,7 +217,7 @@ public class Checksum extends MatchingTask implements Condition | |||||
| else | else | ||||
| { | { | ||||
| log( file + " omitted as " + dest + " is up to date.", | log( file + " omitted as " + dest + " is up to date.", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -229,10 +228,10 @@ public class Checksum extends MatchingTask implements Condition | |||||
| else | else | ||||
| { | { | ||||
| String message = "Could not find file " | String message = "Could not find file " | ||||
| + file.getAbsolutePath() | |||||
| + " to generate checksum for."; | |||||
| + file.getAbsolutePath() | |||||
| + " to generate checksum for."; | |||||
| log( message ); | 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. | * Generate checksum(s) using the message digest created earlier. | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private boolean generateChecksums() | private boolean generateChecksums() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| boolean checksumMatches = true; | boolean checksumMatches = true; | ||||
| FileInputStream fis = null; | FileInputStream fis = null; | ||||
| FileOutputStream fos = null; | FileOutputStream fos = null; | ||||
| try | try | ||||
| { | { | ||||
| for( Enumeration e = includeFileMap.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = includeFileMap.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| messageDigest.reset(); | messageDigest.reset(); | ||||
| File src = ( File )e.nextElement(); | |||||
| File src = (File)e.nextElement(); | |||||
| if( !isCondition ) | if( !isCondition ) | ||||
| { | { | ||||
| log( "Calculating " + algorithm + " checksum for " + src ); | log( "Calculating " + algorithm + " checksum for " + src ); | ||||
| } | } | ||||
| fis = new FileInputStream( src ); | fis = new FileInputStream( src ); | ||||
| DigestInputStream dis = new DigestInputStream( fis, | DigestInputStream dis = new DigestInputStream( fis, | ||||
| messageDigest ); | |||||
| messageDigest ); | |||||
| while( dis.read() != -1 ) | while( dis.read() != -1 ) | ||||
| ; | ; | ||||
| dis.close(); | dis.close(); | ||||
| @@ -271,7 +270,7 @@ public class Checksum extends MatchingTask implements Condition | |||||
| String checksum = ""; | String checksum = ""; | ||||
| for( int i = 0; i < fileDigest.length; i++ ) | 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 ) | if( hexStr.length() < 2 ) | ||||
| { | { | ||||
| checksum += "0"; | checksum += "0"; | ||||
| @@ -282,7 +281,7 @@ public class Checksum extends MatchingTask implements Condition | |||||
| Object destination = includeFileMap.get( src ); | Object destination = includeFileMap.get( src ); | ||||
| if( destination instanceof java.lang.String ) | if( destination instanceof java.lang.String ) | ||||
| { | { | ||||
| String prop = ( String )destination; | |||||
| String prop = (String)destination; | |||||
| if( isCondition ) | if( isCondition ) | ||||
| { | { | ||||
| checksumMatches = checksum.equals( property ); | checksumMatches = checksum.equals( property ); | ||||
| @@ -296,7 +295,7 @@ public class Checksum extends MatchingTask implements Condition | |||||
| { | { | ||||
| if( isCondition ) | if( isCondition ) | ||||
| { | { | ||||
| File existingFile = ( File )destination; | |||||
| File existingFile = (File)destination; | |||||
| if( existingFile.exists() && | if( existingFile.exists() && | ||||
| existingFile.length() == checksum.length() ) | existingFile.length() == checksum.length() ) | ||||
| { | { | ||||
| @@ -318,7 +317,7 @@ public class Checksum extends MatchingTask implements Condition | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| File dest = ( File )destination; | |||||
| File dest = (File)destination; | |||||
| fos = new FileOutputStream( dest ); | fos = new FileOutputStream( dest ); | ||||
| fos.write( checksum.getBytes() ); | fos.write( checksum.getBytes() ); | ||||
| fos.close(); | fos.close(); | ||||
| @@ -329,7 +328,7 @@ public class Checksum extends MatchingTask implements Condition | |||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -340,7 +339,8 @@ public class Checksum extends MatchingTask implements Condition | |||||
| fis.close(); | fis.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( fos != null ) | if( fos != null ) | ||||
| { | { | ||||
| @@ -349,7 +349,8 @@ public class Checksum extends MatchingTask implements Condition | |||||
| fos.close(); | fos.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| return checksumMatches; | return checksumMatches; | ||||
| @@ -359,10 +360,10 @@ public class Checksum extends MatchingTask implements Condition | |||||
| * Validate attributes and get down to business. | * Validate attributes and get down to business. | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private boolean validateAndExecute() | private boolean validateAndExecute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( file == null && filesets.size() == 0 ) | if( file == null && filesets.size() == 0 ) | ||||
| @@ -466,7 +467,7 @@ public class Checksum extends MatchingTask implements Condition | |||||
| if( messageDigest == null ) | if( messageDigest == null ) | ||||
| { | { | ||||
| throw new BuildException( "Unable to create Message Digest" ); | |||||
| throw new TaskException( "Unable to create Message Digest" ); | |||||
| } | } | ||||
| addToIncludeFileMap( file ); | addToIncludeFileMap( file ); | ||||
| @@ -474,12 +475,12 @@ public class Checksum extends MatchingTask implements Condition | |||||
| int sizeofFileSet = filesets.size(); | int sizeofFileSet = filesets.size(); | ||||
| for( int i = 0; i < sizeofFileSet; i++ ) | for( int i = 0; i < sizeofFileSet; i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )filesets.elementAt( i ); | |||||
| FileSet fs = (FileSet)filesets.elementAt( i ); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| String[] srcFiles = ds.getIncludedFiles(); | String[] srcFiles = ds.getIncludedFiles(); | ||||
| for( int j = 0; j < srcFiles.length; j++ ) | 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 ); | addToIncludeFileMap( src ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,14 +6,14 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.myrmidon.framework.Os; | import org.apache.myrmidon.framework.Os; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.PatternSet; | import org.apache.tools.ant.types.PatternSet; | ||||
| /** | /** | ||||
| * Chmod equivalent for unix-like environments. | * Chmod equivalent for unix-like environments. | ||||
| * | * | ||||
| @@ -40,7 +40,7 @@ public class Chmod extends ExecuteOn | |||||
| public void setCommand( String e ) | public void setCommand( String e ) | ||||
| { | { | ||||
| throw new BuildException( taskType + " doesn\'t support the command attribute" ); | |||||
| throw new TaskException( taskType + " doesn\'t support the command attribute" ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -72,10 +72,9 @@ public class Chmod extends ExecuteOn | |||||
| defaultSet.setExcludes( excludes ); | defaultSet.setExcludes( excludes ); | ||||
| } | } | ||||
| public void setExecutable( String e ) | 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 ) | public void setFile( File src ) | ||||
| @@ -106,7 +105,7 @@ public class Chmod extends ExecuteOn | |||||
| public void setSkipEmptyFilesets( boolean skip ) | public void setSkipEmptyFilesets( boolean skip ) | ||||
| { | { | ||||
| throw new BuildException( taskType + " doesn\'t support the skipemptyfileset attribute" ); | |||||
| throw new TaskException( taskType + " doesn\'t support the skipemptyfileset attribute" ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -143,7 +142,7 @@ public class Chmod extends ExecuteOn | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( defaultSetDefined || defaultSet.getDir( project ) == null ) | if( defaultSetDefined || defaultSet.getDir( project ) == null ) | ||||
| { | { | ||||
| @@ -161,7 +160,7 @@ public class Chmod extends ExecuteOn | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Execute failed: " + e, e ); | |||||
| throw new TaskException( "Execute failed: " + e, e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -180,7 +179,7 @@ public class Chmod extends ExecuteOn | |||||
| { | { | ||||
| if( !havePerm ) | 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 ) | if( defaultSetDefined && defaultSet.getDir( project ) != null ) | ||||
| @@ -6,10 +6,10 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | 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.Condition; | ||||
| import org.apache.tools.ant.taskdefs.condition.ConditionBase; | import org.apache.tools.ant.taskdefs.condition.ConditionBase; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * <condition> task as a generalization of <available> and | * <condition> task as a generalization of <available> and | ||||
| @@ -54,7 +54,7 @@ public class ConditionTask extends ConditionBase | |||||
| /** | /** | ||||
| * See whether our nested condition holds and set the property. | * See whether our nested condition holds and set the property. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| * @since 1.1 | * @since 1.1 | ||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| @@ -68,7 +68,7 @@ public class ConditionTask extends ConditionBase | |||||
| { | { | ||||
| throw new TaskException( "You must nest a condition into <condition>" ); | throw new TaskException( "You must nest a condition into <condition>" ); | ||||
| } | } | ||||
| Condition c = ( Condition )getConditions().nextElement(); | |||||
| Condition c = (Condition)getConditions().nextElement(); | |||||
| if( c.eval() ) | if( c.eval() ) | ||||
| { | { | ||||
| getProject().setNewProperty( property, value ); | getProject().setNewProperty( property, value ); | ||||
| @@ -13,7 +13,6 @@ import java.util.Enumeration; | |||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -195,14 +194,14 @@ public class Copy extends Task | |||||
| * Defines the FileNameMapper to use (nested mapper element). | * Defines the FileNameMapper to use (nested mapper element). | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public Mapper createMapper() | public Mapper createMapper() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( mapperElement != null ) | 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 ); | mapperElement = new Mapper( project ); | ||||
| return mapperElement; | return mapperElement; | ||||
| @@ -211,7 +210,7 @@ public class Copy extends Task | |||||
| /** | /** | ||||
| * Performs the copy operation. | * Performs the copy operation. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws TaskException | throws TaskException | ||||
| @@ -369,7 +368,7 @@ public class Copy extends Task | |||||
| { | { | ||||
| String msg = "Failed to copy " + fromFile + " to " + toFile | String msg = "Failed to copy " + fromFile + " to " + toFile | ||||
| + " due to " + ioe.getMessage(); | + " 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 | * Ensure we have a consistent and legal set of attributes, and set any | ||||
| * internal flags necessary based on different combinations of attributes. | * internal flags necessary based on different combinations of attributes. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected void validateAttributes() | protected void validateAttributes() | ||||
| throws TaskException | throws TaskException | ||||
| @@ -14,7 +14,6 @@ import java.io.IOException; | |||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -189,7 +188,6 @@ public class Cvs extends Task | |||||
| public void execute() | public void execute() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| // XXX: we should use JCVS (www.ice.com/JCVS) instead of command line | // XXX: we should use JCVS (www.ice.com/JCVS) instead of command line | ||||
| // execution so that we don't rely on having native CVS stuff around (SM) | // execution so that we don't rely on having native CVS stuff around (SM) | ||||
| @@ -6,9 +6,10 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Vector; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| @@ -109,7 +110,6 @@ public class Delete extends MatchingTask | |||||
| this.file = file; | this.file = file; | ||||
| } | } | ||||
| /** | /** | ||||
| * Used to delete empty directories. | * Used to delete empty directories. | ||||
| * | * | ||||
| @@ -225,10 +225,10 @@ public class Delete extends MatchingTask | |||||
| /** | /** | ||||
| * Delete the file(s). | * Delete the file(s). | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( usedMatchingTask ) | if( usedMatchingTask ) | ||||
| { | { | ||||
| @@ -237,12 +237,12 @@ public class Delete extends MatchingTask | |||||
| if( file == null && dir == null && filesets.size() == 0 ) | 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 ) | 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 | // delete the single file | ||||
| @@ -262,17 +262,17 @@ public class Delete extends MatchingTask | |||||
| { | { | ||||
| String message = "Unable to delete file " + file.getAbsolutePath(); | String message = "Unable to delete file " + file.getAbsolutePath(); | ||||
| if( failonerror ) | if( failonerror ) | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| else | else | ||||
| log( message, | log( message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN ); | |||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| log( "Could not find file " + file.getAbsolutePath() + " to delete.", | 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 | // delete the files in the filesets | ||||
| for( int i = 0; i < filesets.size(); i++ ) | for( int i = 0; i < filesets.size(); i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )filesets.elementAt( i ); | |||||
| FileSet fs = (FileSet)filesets.elementAt( i ); | |||||
| try | try | ||||
| { | { | ||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| @@ -303,7 +303,7 @@ public class Delete extends MatchingTask | |||||
| String[] dirs = ds.getIncludedDirectories(); | String[] dirs = ds.getIncludedDirectories(); | ||||
| removeFiles( fs.getDir( project ), files, dirs ); | removeFiles( fs.getDir( project ), files, dirs ); | ||||
| } | } | ||||
| catch( BuildException be ) | |||||
| catch( TaskException be ) | |||||
| { | { | ||||
| // directory doesn't exist or is not readable | // directory doesn't exist or is not readable | ||||
| if( failonerror ) | if( failonerror ) | ||||
| @@ -313,7 +313,7 @@ public class Delete extends MatchingTask | |||||
| else | else | ||||
| { | { | ||||
| log( be.getMessage(), | 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(); | String[] dirs = ds.getIncludedDirectories(); | ||||
| removeFiles( dir, files, dirs ); | removeFiles( dir, files, dirs ); | ||||
| } | } | ||||
| catch( BuildException be ) | |||||
| catch( TaskException be ) | |||||
| { | { | ||||
| // directory doesn't exist or is not readable | // directory doesn't exist or is not readable | ||||
| if( failonerror ) | if( failonerror ) | ||||
| @@ -338,24 +338,24 @@ public class Delete extends MatchingTask | |||||
| else | else | ||||
| { | { | ||||
| log( be.getMessage(), | 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 ) | protected void removeDir( File d ) | ||||
| { | { | ||||
| String[] list = d.list(); | String[] list = d.list(); | ||||
| if( list == null ) | if( list == null ) | ||||
| list = new String[0]; | |||||
| list = new String[ 0 ]; | |||||
| for( int i = 0; i < list.length; i++ ) | for( int i = 0; i < list.length; i++ ) | ||||
| { | { | ||||
| String s = list[i]; | |||||
| String s = list[ i ]; | |||||
| File f = new File( d, s ); | File f = new File( d, s ); | ||||
| if( f.isDirectory() ) | if( f.isDirectory() ) | ||||
| { | { | ||||
| @@ -368,10 +368,10 @@ public class Delete extends MatchingTask | |||||
| { | { | ||||
| String message = "Unable to delete file " + f.getAbsolutePath(); | String message = "Unable to delete file " + f.getAbsolutePath(); | ||||
| if( failonerror ) | if( failonerror ) | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| else | else | ||||
| log( message, | 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(); | String message = "Unable to delete directory " + dir.getAbsolutePath(); | ||||
| if( failonerror ) | if( failonerror ) | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| else | else | ||||
| log( message, | 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() ); | log( "Deleting " + files.length + " files from " + d.getAbsolutePath() ); | ||||
| for( int j = 0; j < files.length; j++ ) | 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 ); | log( "Deleting " + f.getAbsolutePath(), verbosity ); | ||||
| if( !f.delete() ) | if( !f.delete() ) | ||||
| { | { | ||||
| String message = "Unable to delete file " + f.getAbsolutePath(); | String message = "Unable to delete file " + f.getAbsolutePath(); | ||||
| if( failonerror ) | if( failonerror ) | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| else | else | ||||
| log( message, | 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; | int dirCount = 0; | ||||
| for( int j = dirs.length - 1; j >= 0; j-- ) | 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(); | String[] dirFiles = dir.list(); | ||||
| if( dirFiles == null || dirFiles.length == 0 ) | if( dirFiles == null || dirFiles.length == 0 ) | ||||
| { | { | ||||
| @@ -429,12 +429,12 @@ public class Delete extends MatchingTask | |||||
| if( !dir.delete() ) | if( !dir.delete() ) | ||||
| { | { | ||||
| String message = "Unable to delete directory " | String message = "Unable to delete directory " | ||||
| + dir.getAbsolutePath(); | |||||
| + dir.getAbsolutePath(); | |||||
| if( failonerror ) | if( failonerror ) | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| else | else | ||||
| log( message, | log( message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN ); | |||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -446,8 +446,8 @@ public class Delete extends MatchingTask | |||||
| if( dirCount > 0 ) | if( dirCount > 0 ) | ||||
| { | { | ||||
| log( "Deleted " + dirCount + " director" + | log( "Deleted " + dirCount + " director" + | ||||
| ( dirCount == 1 ? "y" : "ies" ) + | |||||
| " from " + d.getAbsolutePath() ); | |||||
| ( dirCount == 1 ? "y" : "ies" ) + | |||||
| " from " + d.getAbsolutePath() ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,14 +6,15 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | 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.FileList; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| @@ -72,7 +73,9 @@ public class DependSet extends MatchingTask | |||||
| /** | /** | ||||
| * Creates a new DependSet Task. | * Creates a new DependSet Task. | ||||
| */ | */ | ||||
| public DependSet() { } | |||||
| public DependSet() | |||||
| { | |||||
| } | |||||
| /** | /** | ||||
| * Nested <srcfilelist> element. | * Nested <srcfilelist> element. | ||||
| @@ -117,21 +120,19 @@ public class DependSet extends MatchingTask | |||||
| /** | /** | ||||
| * Executes the task. | * Executes the task. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( ( sourceFileSets.size() == 0 ) && ( sourceFileLists.size() == 0 ) ) | 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 ) ) | 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(); | long now = ( new Date() ).getTime(); | ||||
| @@ -153,20 +154,20 @@ public class DependSet extends MatchingTask | |||||
| while( enumTargetSets.hasMoreElements() ) | while( enumTargetSets.hasMoreElements() ) | ||||
| { | { | ||||
| FileSet targetFS = ( FileSet )enumTargetSets.nextElement(); | |||||
| FileSet targetFS = (FileSet)enumTargetSets.nextElement(); | |||||
| DirectoryScanner targetDS = targetFS.getDirectoryScanner( project ); | DirectoryScanner targetDS = targetFS.getDirectoryScanner( project ); | ||||
| String[] targetFiles = targetDS.getIncludedFiles(); | String[] targetFiles = targetDS.getIncludedFiles(); | ||||
| for( int i = 0; i < targetFiles.length; i++ ) | 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 ); | allTargets.addElement( dest ); | ||||
| if( dest.lastModified() > now ) | 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() ) | while( enumTargetLists.hasMoreElements() ) | ||||
| { | { | ||||
| FileList targetFL = ( FileList )enumTargetLists.nextElement(); | |||||
| FileList targetFL = (FileList)enumTargetLists.nextElement(); | |||||
| String[] targetFiles = targetFL.getFiles( project ); | String[] targetFiles = targetFL.getFiles( project ); | ||||
| for( int i = 0; i < targetFiles.length; i++ ) | 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() ) | if( !dest.exists() ) | ||||
| { | { | ||||
| log( targetFiles[i] + " does not exist.", Project.MSG_VERBOSE ); | |||||
| log( targetFiles[ i ] + " does not exist.", Project.MSG_VERBOSE ); | |||||
| upToDate = false; | upToDate = false; | ||||
| continue; | continue; | ||||
| } | } | ||||
| @@ -198,8 +199,8 @@ public class DependSet extends MatchingTask | |||||
| } | } | ||||
| if( dest.lastModified() > now ) | 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() ) | while( upToDate && enumSourceSets.hasMoreElements() ) | ||||
| { | { | ||||
| FileSet sourceFS = ( FileSet )enumSourceSets.nextElement(); | |||||
| FileSet sourceFS = (FileSet)enumSourceSets.nextElement(); | |||||
| DirectoryScanner sourceDS = sourceFS.getDirectoryScanner( project ); | DirectoryScanner sourceDS = sourceFS.getDirectoryScanner( project ); | ||||
| String[] sourceFiles = sourceDS.getIncludedFiles(); | String[] sourceFiles = sourceDS.getIncludedFiles(); | ||||
| for( int i = 0; upToDate && i < sourceFiles.length; i++ ) | 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 ) | 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(); | Enumeration enumTargets = allTargets.elements(); | ||||
| while( upToDate && enumTargets.hasMoreElements() ) | while( upToDate && enumTargets.hasMoreElements() ) | ||||
| { | { | ||||
| File dest = ( File )enumTargets.nextElement(); | |||||
| File dest = (File)enumTargets.nextElement(); | |||||
| if( src.lastModified() > dest.lastModified() ) | if( src.lastModified() > dest.lastModified() ) | ||||
| { | { | ||||
| log( dest.getPath() + " is out of date with respect to " + | log( dest.getPath() + " is out of date with respect to " + | ||||
| sourceFiles[i], Project.MSG_VERBOSE ); | |||||
| sourceFiles[ i ], Project.MSG_VERBOSE ); | |||||
| upToDate = false; | upToDate = false; | ||||
| } | } | ||||
| @@ -253,23 +254,23 @@ public class DependSet extends MatchingTask | |||||
| while( upToDate && enumSourceLists.hasMoreElements() ) | while( upToDate && enumSourceLists.hasMoreElements() ) | ||||
| { | { | ||||
| FileList sourceFL = ( FileList )enumSourceLists.nextElement(); | |||||
| FileList sourceFL = (FileList)enumSourceLists.nextElement(); | |||||
| String[] sourceFiles = sourceFL.getFiles( project ); | String[] sourceFiles = sourceFL.getFiles( project ); | ||||
| int i = 0; | int i = 0; | ||||
| do | do | ||||
| { | { | ||||
| File src = new File( sourceFL.getDir( project ), sourceFiles[i] ); | |||||
| File src = new File( sourceFL.getDir( project ), sourceFiles[ i ] ); | |||||
| if( src.lastModified() > now ) | 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() ) | if( !src.exists() ) | ||||
| { | { | ||||
| log( sourceFiles[i] + " does not exist.", Project.MSG_VERBOSE ); | |||||
| log( sourceFiles[ i ] + " does not exist.", Project.MSG_VERBOSE ); | |||||
| upToDate = false; | upToDate = false; | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -278,26 +279,26 @@ public class DependSet extends MatchingTask | |||||
| while( upToDate && enumTargets.hasMoreElements() ) | while( upToDate && enumTargets.hasMoreElements() ) | ||||
| { | { | ||||
| File dest = ( File )enumTargets.nextElement(); | |||||
| File dest = (File)enumTargets.nextElement(); | |||||
| if( src.lastModified() > dest.lastModified() ) | if( src.lastModified() > dest.lastModified() ) | ||||
| { | { | ||||
| log( dest.getPath() + " is out of date with respect to " + | log( dest.getPath() + " is out of date with respect to " + | ||||
| sourceFiles[i], Project.MSG_VERBOSE ); | |||||
| sourceFiles[ i ], Project.MSG_VERBOSE ); | |||||
| upToDate = false; | upToDate = false; | ||||
| } | } | ||||
| } | } | ||||
| }while ( upToDate && ( ++i < sourceFiles.length ) ); | |||||
| } while( upToDate && ( ++i < sourceFiles.length ) ); | |||||
| } | } | ||||
| } | } | ||||
| if( !upToDate ) | if( !upToDate ) | ||||
| { | { | ||||
| log( "Deleting all target files. ", Project.MSG_VERBOSE ); | 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 ); | log( "Deleting file " + fileToRemove.getAbsolutePath(), Project.MSG_VERBOSE ); | ||||
| fileToRemove.delete(); | fileToRemove.delete(); | ||||
| } | } | ||||
| @@ -6,14 +6,14 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.ZipFileSet; | import org.apache.tools.ant.types.ZipFileSet; | ||||
| import org.apache.tools.zip.ZipOutputStream; | import org.apache.tools.zip.ZipOutputStream; | ||||
| /** | /** | ||||
| * Creates a EAR archive. Based on WAR task | * Creates a EAR archive. Based on WAR task | ||||
| * | * | ||||
| @@ -37,7 +37,7 @@ public class Ear extends Jar | |||||
| { | { | ||||
| deploymentDescriptor = descr; | deploymentDescriptor = descr; | ||||
| if( !deploymentDescriptor.exists() ) | 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. | // Create a ZipFileSet for this file, and pass it up. | ||||
| ZipFileSet fs = new ZipFileSet(); | ZipFileSet fs = new ZipFileSet(); | ||||
| @@ -66,14 +66,13 @@ public class Ear extends Jar | |||||
| super.cleanUp(); | super.cleanUp(); | ||||
| } | } | ||||
| protected void initZipOutputStream( ZipOutputStream zOut ) | protected void initZipOutputStream( ZipOutputStream zOut ) | ||||
| throws IOException, BuildException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| // If no webxml file is specified, it's an error. | // If no webxml file is specified, it's an error. | ||||
| if( deploymentDescriptor == null && !isInUpdateMode() ) | if( deploymentDescriptor == null && !isInUpdateMode() ) | ||||
| { | { | ||||
| throw new BuildException( "appxml attribute is required" ); | |||||
| throw new TaskException( "appxml attribute is required" ); | |||||
| } | } | ||||
| super.initZipOutputStream( zOut ); | super.initZipOutputStream( zOut ); | ||||
| @@ -91,7 +90,7 @@ public class Ear extends Jar | |||||
| if( deploymentDescriptor == null || !deploymentDescriptor.equals( file ) || descriptorAdded ) | if( deploymentDescriptor == null || !deploymentDescriptor.equals( file ) || descriptorAdded ) | ||||
| { | { | ||||
| log( "Warning: selected " + archiveType + " files include a META-INF/application.xml which will be ignored " + | 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 | else | ||||
| { | { | ||||
| @@ -6,12 +6,12 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | 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.Project; | ||||
| import org.apache.tools.ant.ProjectHelper; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| @@ -113,10 +113,10 @@ public class Echo extends Task | |||||
| /** | /** | ||||
| * Does the work. | * Does the work. | ||||
| * | * | ||||
| * @exception BuildException if someting goes wrong with the build | |||||
| * @exception TaskException if someting goes wrong with the build | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( file == null ) | if( file == null ) | ||||
| { | { | ||||
| @@ -132,7 +132,7 @@ public class Echo extends Task | |||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| throw new BuildException( "Error", ioe); | |||||
| throw new TaskException( "Error", ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -143,7 +143,8 @@ public class Echo extends Task | |||||
| out.close(); | out.close(); | ||||
| } | } | ||||
| catch( IOException ioex ) | catch( IOException ioex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -13,7 +14,7 @@ import java.io.FileNotFoundException; | |||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.StringReader; | 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.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -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 | * @param fail The new Failonerror value | ||||
| */ | */ | ||||
| @@ -189,10 +190,10 @@ public class ExecTask extends Task | |||||
| /** | /** | ||||
| * Do the work. | * Do the work. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| checkConfiguration(); | checkConfiguration(); | ||||
| if( isValidOs() ) | if( isValidOs() ) | ||||
| @@ -243,7 +244,7 @@ public class ExecTask extends Task | |||||
| { | { | ||||
| if( failOnError ) | if( failOnError ) | ||||
| { | { | ||||
| throw new BuildException( taskType + " returned: " + err ); | |||||
| throw new TaskException( taskType + " returned: " + err ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -271,22 +272,22 @@ public class ExecTask extends Task | |||||
| /** | /** | ||||
| * Has the user set all necessary attributes? | * Has the user set all necessary attributes? | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected void checkConfiguration() | protected void checkConfiguration() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( cmdl.getExecutable() == null ) | if( cmdl.getExecutable() == null ) | ||||
| { | { | ||||
| throw new BuildException( "no executable specified" ); | |||||
| throw new TaskException( "no executable specified" ); | |||||
| } | } | ||||
| if( dir != null && !dir.exists() ) | 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() ) | 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. | * Create the StreamHandler to use with our Execute instance. | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected ExecuteStreamHandler createHandler() | protected ExecuteStreamHandler createHandler() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( out != null ) | if( out != null ) | ||||
| { | { | ||||
| @@ -309,11 +310,11 @@ public class ExecTask extends Task | |||||
| } | } | ||||
| catch( FileNotFoundException fne ) | catch( FileNotFoundException fne ) | ||||
| { | { | ||||
| throw new BuildException( "Cannot write to " + out, fne ); | |||||
| throw new TaskException( "Cannot write to " + out, fne ); | |||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| throw new BuildException( "Cannot write to " + out, ioe ); | |||||
| throw new TaskException( "Cannot write to " + out, ioe ); | |||||
| } | } | ||||
| } | } | ||||
| else if( outputprop != null ) | else if( outputprop != null ) | ||||
| @@ -325,7 +326,7 @@ public class ExecTask extends Task | |||||
| else | else | ||||
| { | { | ||||
| return new LogStreamHandler( this, | 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. | * Create the Watchdog to kill a runaway process. | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected ExecuteWatchdog createWatchdog() | protected ExecuteWatchdog createWatchdog() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( timeout == null ) | if( timeout == null ) | ||||
| return null; | return null; | ||||
| @@ -356,7 +357,8 @@ public class ExecTask extends Task | |||||
| baos.close(); | baos.close(); | ||||
| } | } | ||||
| catch( IOException io ) | catch( IOException io ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -378,10 +380,10 @@ public class ExecTask extends Task | |||||
| * Create an Execute instance with the correct working directory set. | * Create an Execute instance with the correct working directory set. | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected Execute prepareExec() | protected Execute prepareExec() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| // default directory to the project's base directory | // default directory to the project's base directory | ||||
| if( dir == null ) | if( dir == null ) | ||||
| @@ -398,8 +400,8 @@ public class ExecTask extends Task | |||||
| { | { | ||||
| for( int i = 0; i < environment.length; i++ ) | 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 ); | exe.setNewenvironment( newEnvironment ); | ||||
| @@ -412,10 +414,10 @@ public class ExecTask extends Task | |||||
| * by subclasses | * by subclasses | ||||
| * | * | ||||
| * @param exe Description of Parameter | * @param exe Description of Parameter | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected void runExec( Execute exe ) | protected void runExec( Execute exe ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| exe.setCommandline( cmdl.getCommandline() ); | exe.setCommandline( cmdl.getCommandline() ); | ||||
| try | try | ||||
| @@ -426,7 +428,7 @@ public class ExecTask extends Task | |||||
| { | { | ||||
| if( failIfExecFails ) | if( failIfExecFails ) | ||||
| { | { | ||||
| throw new BuildException( "Execute failed: " + e.toString(), e ); | |||||
| throw new TaskException( "Execute failed: " + e.toString(), e ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -18,11 +18,10 @@ import java.util.Locale; | |||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.myrmidon.framework.Os; | import org.apache.myrmidon.framework.Os; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| * Runs an external program. | * 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 task The task that the command is part of. Used for logging | ||||
| * @param cmdline The command to execute. | * @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 ) | public static void runCommand( Task task, String[] cmdline ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -261,12 +260,12 @@ public class Execute | |||||
| int retval = exe.execute(); | int retval = exe.execute(); | ||||
| if( retval != 0 ) | if( retval != 0 ) | ||||
| { | { | ||||
| throw new BuildException( cmdline[ 0 ] + " failed with return code " + retval ); | |||||
| throw new TaskException( cmdline[ 0 ] + " failed with return code " + retval ); | |||||
| } | } | ||||
| } | } | ||||
| catch( java.io.IOException exc ) | catch( java.io.IOException exc ) | ||||
| { | { | ||||
| throw new BuildException( "Could not launch " + cmdline[ 0 ] + ": " + exc ); | |||||
| 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. | * Set the name of the antRun script using the project's value. | ||||
| * | * | ||||
| * @param project the current project. | * @param project the current project. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setAntRun( Project project ) | public void setAntRun( Project project ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| this.project = project; | this.project = project; | ||||
| } | } | ||||
| @@ -707,13 +706,13 @@ public class Execute | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( "Unable to execute command", realexc ); | |||||
| throw new TaskException( "Unable to execute command", realexc ); | |||||
| } | } | ||||
| } | } | ||||
| catch( Exception exc ) | catch( Exception exc ) | ||||
| { | { | ||||
| // IllegalAccess, IllegalArgument, ClassCast | // IllegalAccess, IllegalArgument, ClassCast | ||||
| throw new BuildException( "Unable to execute command", exc ); | |||||
| throw new TaskException( "Unable to execute command", exc ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,11 +6,11 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.PrintStream; | |||||
| import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| @@ -20,6 +20,7 @@ import org.apache.tools.ant.types.Path; | |||||
| * @author thomas.haas@softwired-inc.com | * @author thomas.haas@softwired-inc.com | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| */ | */ | ||||
| public class ExecuteJava | public class ExecuteJava | ||||
| { | { | ||||
| @@ -43,7 +44,7 @@ public class ExecuteJava | |||||
| } | } | ||||
| public void execute( Project project ) | public void execute( Project project ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| final String classname = javaCommand.getExecutable(); | final String classname = javaCommand.getExecutable(); | ||||
| final Object[] argument = {javaCommand.getArguments()}; | final Object[] argument = {javaCommand.getArguments()}; | ||||
| @@ -75,27 +76,27 @@ public class ExecuteJava | |||||
| } | } | ||||
| catch( NullPointerException e ) | 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 ) | 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 ) | catch( InvocationTargetException e ) | ||||
| { | { | ||||
| Throwable t = e.getTargetException(); | Throwable t = e.getTargetException(); | ||||
| if( !( t instanceof SecurityException ) ) | if( !( t instanceof SecurityException ) ) | ||||
| { | { | ||||
| throw new BuildException( "Error", t ); | |||||
| throw new TaskException( "Error", t ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw ( SecurityException )t; | |||||
| throw (SecurityException)t; | |||||
| } | } | ||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -6,11 +6,12 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Vector; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -55,7 +56,6 @@ public class ExecuteOn extends ExecTask | |||||
| this.destDir = destDir; | this.destDir = destDir; | ||||
| } | } | ||||
| /** | /** | ||||
| * Shall the command work on all specified files in parallel? | * 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). | * Defines the FileNameMapper to use (nested mapper element). | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public Mapper createMapper() | public Mapper createMapper() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( mapperElement != null ) | 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 ); | mapperElement = new Mapper( project ); | ||||
| return mapperElement; | return mapperElement; | ||||
| @@ -133,7 +133,7 @@ public class ExecuteOn extends ExecTask | |||||
| { | { | ||||
| if( srcFilePos != null ) | 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(); | srcFilePos = cmdl.createMarker(); | ||||
| return srcFilePos; | return srcFilePos; | ||||
| @@ -149,7 +149,7 @@ public class ExecuteOn extends ExecTask | |||||
| { | { | ||||
| if( targetFilePos != null ) | 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(); | targetFilePos = cmdl.createMarker(); | ||||
| srcIsFirst = ( srcFilePos != null ); | srcIsFirst = ( srcFilePos != null ); | ||||
| @@ -171,7 +171,7 @@ public class ExecuteOn extends ExecTask | |||||
| Hashtable addedFiles = new Hashtable(); | Hashtable addedFiles = new Hashtable(); | ||||
| for( int i = 0; i < srcFiles.length; i++ ) | for( int i = 0; i < srcFiles.length; i++ ) | ||||
| { | { | ||||
| String[] subTargets = mapper.mapFileName( srcFiles[i] ); | |||||
| String[] subTargets = mapper.mapFileName( srcFiles[ i ] ); | |||||
| if( subTargets != null ) | if( subTargets != null ) | ||||
| { | { | ||||
| for( int j = 0; j < subTargets.length; j++ ) | for( int j = 0; j < subTargets.length; j++ ) | ||||
| @@ -180,11 +180,11 @@ public class ExecuteOn extends ExecTask | |||||
| if( !relative ) | if( !relative ) | ||||
| { | { | ||||
| name = | name = | ||||
| ( new File( destDir, subTargets[j] ) ).getAbsolutePath(); | |||||
| ( new File( destDir, subTargets[ j ] ) ).getAbsolutePath(); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| name = subTargets[j]; | |||||
| name = subTargets[ j ]; | |||||
| } | } | ||||
| if( !addedFiles.contains( name ) ) | 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 ); | targets.copyInto( targetFiles ); | ||||
| String[] orig = cmdl.getCommandline(); | 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; | int srcIndex = orig.length; | ||||
| if( srcFilePos != null ) | if( srcFilePos != null ) | ||||
| @@ -212,7 +212,7 @@ public class ExecuteOn extends ExecTask | |||||
| int targetIndex = targetFilePos.getPosition(); | int targetIndex = targetFilePos.getPosition(); | ||||
| if( srcIndex < targetIndex | if( srcIndex < targetIndex | ||||
| || ( srcIndex == targetIndex && srcIsFirst ) ) | |||||
| || ( srcIndex == targetIndex && srcIsFirst ) ) | |||||
| { | { | ||||
| // 0 --> srcIndex | // 0 --> srcIndex | ||||
| @@ -220,18 +220,18 @@ public class ExecuteOn extends ExecTask | |||||
| // srcIndex --> targetIndex | // srcIndex --> targetIndex | ||||
| System.arraycopy( orig, srcIndex, result, | System.arraycopy( orig, srcIndex, result, | ||||
| srcIndex + srcFiles.length, | |||||
| targetIndex - srcIndex ); | |||||
| srcIndex + srcFiles.length, | |||||
| targetIndex - srcIndex ); | |||||
| // targets are already absolute file names | // targets are already absolute file names | ||||
| System.arraycopy( targetFiles, 0, result, | System.arraycopy( targetFiles, 0, result, | ||||
| targetIndex + srcFiles.length, | |||||
| targetFiles.length ); | |||||
| targetIndex + srcFiles.length, | |||||
| targetFiles.length ); | |||||
| // targetIndex --> end | // targetIndex --> end | ||||
| System.arraycopy( orig, targetIndex, result, | System.arraycopy( orig, targetIndex, result, | ||||
| targetIndex + srcFiles.length + targetFiles.length, | |||||
| orig.length - targetIndex ); | |||||
| targetIndex + srcFiles.length + targetFiles.length, | |||||
| orig.length - targetIndex ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -240,18 +240,18 @@ public class ExecuteOn extends ExecTask | |||||
| // targets are already absolute file names | // targets are already absolute file names | ||||
| System.arraycopy( targetFiles, 0, result, | System.arraycopy( targetFiles, 0, result, | ||||
| targetIndex, | |||||
| targetFiles.length ); | |||||
| targetIndex, | |||||
| targetFiles.length ); | |||||
| // targetIndex --> srcIndex | // targetIndex --> srcIndex | ||||
| System.arraycopy( orig, targetIndex, result, | System.arraycopy( orig, targetIndex, result, | ||||
| targetIndex + targetFiles.length, | |||||
| srcIndex - targetIndex ); | |||||
| targetIndex + targetFiles.length, | |||||
| srcIndex - targetIndex ); | |||||
| // srcIndex --> end | // srcIndex --> end | ||||
| System.arraycopy( orig, srcIndex, result, | System.arraycopy( orig, srcIndex, result, | ||||
| srcIndex + srcFiles.length + targetFiles.length, | |||||
| orig.length - srcIndex ); | |||||
| srcIndex + srcFiles.length + targetFiles.length, | |||||
| orig.length - srcIndex ); | |||||
| srcIndex += targetFiles.length; | srcIndex += targetFiles.length; | ||||
| } | } | ||||
| @@ -263,8 +263,8 @@ public class ExecuteOn extends ExecTask | |||||
| System.arraycopy( orig, 0, result, 0, srcIndex ); | System.arraycopy( orig, 0, result, 0, srcIndex ); | ||||
| // srcIndex --> end | // srcIndex --> end | ||||
| System.arraycopy( orig, srcIndex, result, | 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 ) | if( !relative ) | ||||
| { | { | ||||
| result[srcIndex + i] = | |||||
| ( new File( baseDirs[i], srcFiles[i] ) ).getAbsolutePath(); | |||||
| result[ srcIndex + i ] = | |||||
| ( new File( baseDirs[ i ], srcFiles[ i ] ) ).getAbsolutePath(); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| result[srcIndex + i] = srcFiles[i]; | |||||
| result[ srcIndex + i ] = srcFiles[ i ]; | |||||
| } | } | ||||
| } | } | ||||
| return result; | return result; | ||||
| @@ -310,7 +310,7 @@ public class ExecuteOn extends ExecTask | |||||
| { | { | ||||
| SourceFileScanner sfs = new SourceFileScanner( this ); | SourceFileScanner sfs = new SourceFileScanner( this ); | ||||
| return sfs.restrict( ds.getIncludedDirectories(), baseDir, destDir, | return sfs.restrict( ds.getIncludedDirectories(), baseDir, destDir, | ||||
| mapper ); | |||||
| mapper ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -332,7 +332,7 @@ public class ExecuteOn extends ExecTask | |||||
| { | { | ||||
| SourceFileScanner sfs = new SourceFileScanner( this ); | SourceFileScanner sfs = new SourceFileScanner( this ); | ||||
| return sfs.restrict( ds.getIncludedFiles(), baseDir, destDir, | return sfs.restrict( ds.getIncludedFiles(), baseDir, destDir, | ||||
| mapper ); | |||||
| mapper ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -345,27 +345,27 @@ public class ExecuteOn extends ExecTask | |||||
| super.checkConfiguration(); | super.checkConfiguration(); | ||||
| if( filesets.size() == 0 ) | if( filesets.size() == 0 ) | ||||
| { | { | ||||
| throw new BuildException( "no filesets specified" ); | |||||
| throw new TaskException( "no filesets specified" ); | |||||
| } | } | ||||
| if( targetFilePos != null || mapperElement != null | if( targetFilePos != null || mapperElement != null | ||||
| || destDir != null ) | |||||
| || destDir != null ) | |||||
| { | { | ||||
| if( mapperElement == null ) | if( mapperElement == null ) | ||||
| { | { | ||||
| throw new BuildException( "no mapper specified" ); | |||||
| throw new TaskException( "no mapper specified" ); | |||||
| } | } | ||||
| if( mapperElement == null ) | if( mapperElement == null ) | ||||
| { | { | ||||
| throw new BuildException( "no dest attribute specified" ); | |||||
| throw new TaskException( "no dest attribute specified" ); | |||||
| } | } | ||||
| mapper = mapperElement.getImplementation(); | mapper = mapperElement.getImplementation(); | ||||
| } | } | ||||
| } | } | ||||
| protected void runExec( Execute exe ) | protected void runExec( Execute exe ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -374,7 +374,7 @@ public class ExecuteOn extends ExecTask | |||||
| Vector baseDirs = new Vector(); | Vector baseDirs = new Vector(); | ||||
| for( int i = 0; i < filesets.size(); i++ ) | for( int i = 0; i < filesets.size(); i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )filesets.elementAt( i ); | |||||
| FileSet fs = (FileSet)filesets.elementAt( i ); | |||||
| File base = fs.getDir( project ); | File base = fs.getDir( project ); | ||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| @@ -383,7 +383,7 @@ public class ExecuteOn extends ExecTask | |||||
| String[] s = getFiles( base, ds ); | String[] s = getFiles( base, ds ); | ||||
| for( int j = 0; j < s.length; j++ ) | for( int j = 0; j < s.length; j++ ) | ||||
| { | { | ||||
| fileNames.addElement( s[j] ); | |||||
| fileNames.addElement( s[ j ] ); | |||||
| baseDirs.addElement( base ); | baseDirs.addElement( base ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -394,7 +394,7 @@ public class ExecuteOn extends ExecTask | |||||
| ; | ; | ||||
| for( int j = 0; j < s.length; j++ ) | for( int j = 0; j < s.length; j++ ) | ||||
| { | { | ||||
| fileNames.addElement( s[j] ); | |||||
| fileNames.addElement( s[ j ] ); | |||||
| baseDirs.addElement( base ); | baseDirs.addElement( base ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -408,13 +408,13 @@ public class ExecuteOn extends ExecTask | |||||
| if( !parallel ) | if( !parallel ) | ||||
| { | { | ||||
| String[] s = new String[fileNames.size()]; | |||||
| String[] s = new String[ fileNames.size() ]; | |||||
| fileNames.copyInto( s ); | fileNames.copyInto( s ); | ||||
| for( int j = 0; j < s.length; j++ ) | 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 ), | log( "Executing " + Commandline.toString( command ), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| exe.setCommandline( command ); | exe.setCommandline( command ); | ||||
| runExecute( exe ); | runExecute( exe ); | ||||
| } | } | ||||
| @@ -425,13 +425,13 @@ public class ExecuteOn extends ExecTask | |||||
| if( parallel && ( fileNames.size() > 0 || !skipEmpty ) ) | if( parallel && ( fileNames.size() > 0 || !skipEmpty ) ) | ||||
| { | { | ||||
| String[] s = new String[fileNames.size()]; | |||||
| String[] s = new String[ fileNames.size() ]; | |||||
| fileNames.copyInto( s ); | fileNames.copyInto( s ); | ||||
| File[] b = new File[baseDirs.size()]; | |||||
| File[] b = new File[ baseDirs.size() ]; | |||||
| baseDirs.copyInto( b ); | baseDirs.copyInto( b ); | ||||
| String[] command = getCommandline( s, b ); | String[] command = getCommandline( s, b ); | ||||
| log( "Executing " + Commandline.toString( command ), | log( "Executing " + Commandline.toString( command ), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| exe.setCommandline( command ); | exe.setCommandline( command ); | ||||
| runExecute( exe ); | runExecute( exe ); | ||||
| } | } | ||||
| @@ -439,7 +439,7 @@ public class ExecuteOn extends ExecTask | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Execute failed: " + e, e ); | |||||
| throw new TaskException( "Execute failed: " + e, e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | 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> | * 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. | * been terminated either by 'error', timeout or manual intervention. | ||||
| * Information will be discarded once a new process is ran. | * 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. | * swallowed and stored during the process run. | ||||
| */ | */ | ||||
| public void checkException() | public void checkException() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( caught != null ) | 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; | return killedProcess; | ||||
| } | } | ||||
| /** | /** | ||||
| * Watches the process and terminates it, if it runs for to long. | * Watches the process and terminates it, if it runs for to long. | ||||
| */ | */ | ||||
| @@ -127,7 +127,8 @@ public class ExecuteWatchdog implements Runnable | |||||
| wait( until - now ); | wait( until - now ); | ||||
| } | } | ||||
| catch( InterruptedException e ) | catch( InterruptedException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| // if we are here, either someone stopped the watchdog, | // if we are here, either someone stopped the watchdog, | ||||
| @@ -6,8 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | 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; | import org.apache.tools.ant.Task; | ||||
| /** | /** | ||||
| @@ -46,17 +46,17 @@ public class Exit extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( testIfCondition() && testUnlessCondition() ) | if( testIfCondition() && testUnlessCondition() ) | ||||
| { | { | ||||
| if( message != null && message.length() > 0 ) | if( message != null && message.length() > 0 ) | ||||
| { | { | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( "No message" ); | |||||
| throw new TaskException( "No message" ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| @@ -16,7 +17,7 @@ import java.util.Date; | |||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import java.util.zip.ZipEntry; | import java.util.zip.ZipEntry; | ||||
| import java.util.zip.ZipInputStream; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| @@ -93,25 +94,25 @@ public class Expand extends MatchingTask | |||||
| /** | /** | ||||
| * Do the work. | * Do the work. | ||||
| * | * | ||||
| * @exception BuildException Thrown in unrecoverable error. | |||||
| * @exception TaskException Thrown in unrecoverable error. | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( source == null && filesets.size() == 0 ) | if( source == null && filesets.size() == 0 ) | ||||
| { | { | ||||
| throw new BuildException( "src attribute and/or filesets must be specified" ); | |||||
| throw new TaskException( "src attribute and/or filesets must be specified" ); | |||||
| } | } | ||||
| if( dest == null ) | if( dest == null ) | ||||
| { | { | ||||
| throw new BuildException( | |||||
| throw new TaskException( | |||||
| "Dest attribute must be specified" ); | "Dest attribute must be specified" ); | ||||
| } | } | ||||
| if( dest.exists() && !dest.isDirectory() ) | 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(); | FileUtils fileUtils = FileUtils.newFileUtils(); | ||||
| @@ -120,8 +121,8 @@ public class Expand extends MatchingTask | |||||
| { | { | ||||
| if( source.isDirectory() ) | 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 | else | ||||
| { | { | ||||
| @@ -132,14 +133,14 @@ public class Expand extends MatchingTask | |||||
| { | { | ||||
| for( int j = 0; j < filesets.size(); j++ ) | 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 ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| File fromDir = fs.getDir( project ); | File fromDir = fs.getDir( project ); | ||||
| String[] files = ds.getIncludedFiles(); | String[] files = ds.getIncludedFiles(); | ||||
| for( int i = 0; i < files.length; ++i ) | 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 ); | expandFile( fileUtils, file, dest ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -161,16 +162,16 @@ public class Expand extends MatchingTask | |||||
| while( ( ze = zis.getNextEntry() ) != null ) | while( ( ze = zis.getNextEntry() ) != null ) | ||||
| { | { | ||||
| extractFile( fileUtils, srcF, dir, zis, | 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 ); | log( "expand complete", Project.MSG_VERBOSE ); | ||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| throw new BuildException( "Error while expanding " + srcF.getPath(), ioe ); | |||||
| throw new TaskException( "Error while expanding " + srcF.getPath(), ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -181,7 +182,8 @@ public class Expand extends MatchingTask | |||||
| zis.close(); | zis.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -199,13 +201,13 @@ public class Expand extends MatchingTask | |||||
| boolean included = false; | boolean included = false; | ||||
| for( int v = 0; v < patternsets.size(); v++ ) | 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 ); | String[] incls = p.getIncludePatterns( project ); | ||||
| if( incls != null ) | if( incls != null ) | ||||
| { | { | ||||
| for( int w = 0; w < incls.length; w++ ) | for( int w = 0; w < incls.length; w++ ) | ||||
| { | { | ||||
| boolean isIncl = DirectoryScanner.match( incls[w], name ); | |||||
| boolean isIncl = DirectoryScanner.match( incls[ w ], name ); | |||||
| if( isIncl ) | if( isIncl ) | ||||
| { | { | ||||
| included = true; | included = true; | ||||
| @@ -218,7 +220,7 @@ public class Expand extends MatchingTask | |||||
| { | { | ||||
| for( int w = 0; w < excls.length; w++ ) | for( int w = 0; w < excls.length; w++ ) | ||||
| { | { | ||||
| boolean isExcl = DirectoryScanner.match( excls[w], name ); | |||||
| boolean isExcl = DirectoryScanner.match( excls[ w ], name ); | |||||
| if( isExcl ) | if( isExcl ) | ||||
| { | { | ||||
| included = false; | included = false; | ||||
| @@ -238,15 +240,15 @@ public class Expand extends MatchingTask | |||||
| try | try | ||||
| { | { | ||||
| if( !overwrite && f.exists() | if( !overwrite && f.exists() | ||||
| && f.lastModified() >= entryDate.getTime() ) | |||||
| && f.lastModified() >= entryDate.getTime() ) | |||||
| { | { | ||||
| log( "Skipping " + f + " as it is up-to-date", | log( "Skipping " + f + " as it is up-to-date", | ||||
| Project.MSG_DEBUG ); | |||||
| Project.MSG_DEBUG ); | |||||
| return; | return; | ||||
| } | } | ||||
| log( "expanding " + entryName + " to " + f, | log( "expanding " + entryName + " to " + f, | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| // create intermediary directories - sometimes zip don't add them | // create intermediary directories - sometimes zip don't add them | ||||
| File dirF = fileUtils.getParentFile( f ); | File dirF = fileUtils.getParentFile( f ); | ||||
| dirF.mkdirs(); | dirF.mkdirs(); | ||||
| @@ -257,7 +259,7 @@ public class Expand extends MatchingTask | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| byte[] buffer = new byte[1024]; | |||||
| byte[] buffer = new byte[ 1024 ]; | |||||
| int length = 0; | int length = 0; | ||||
| FileOutputStream fos = null; | FileOutputStream fos = null; | ||||
| try | try | ||||
| @@ -282,7 +284,8 @@ public class Expand extends MatchingTask | |||||
| fos.close(); | fos.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,8 +6,9 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -44,14 +45,14 @@ public class Filter extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| boolean isFiltersFromFile = filtersFile != null && token == null && value == null; | boolean isFiltersFromFile = filtersFile != null && token == null && value == null; | ||||
| boolean isSingleFilter = filtersFile == null && token != null && value != null; | boolean isSingleFilter = filtersFile == null && token != null && value != null; | ||||
| if( !isFiltersFromFile && !isSingleFilter ) | 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 ) | if( isSingleFilter ) | ||||
| @@ -66,7 +67,7 @@ public class Filter extends Task | |||||
| } | } | ||||
| protected void readFilters() | protected void readFilters() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| log( "Reading filters from " + filtersFile, Project.MSG_VERBOSE ); | log( "Reading filters from " + filtersFile, Project.MSG_VERBOSE ); | ||||
| project.getGlobalFilterSet().readFiltersFromFile( filtersFile ); | project.getGlobalFilterSet().readFiltersFromFile( filtersFile ); | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -20,7 +21,7 @@ import java.io.Reader; | |||||
| import java.io.Writer; | import java.io.Writer; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.NoSuchElementException; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| @@ -192,7 +193,6 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Specify how EndOfLine characters are to be handled | * Specify how EndOfLine characters are to be handled | ||||
| * | * | ||||
| @@ -270,14 +270,14 @@ public class FixCRLF extends MatchingTask | |||||
| * Specify tab length in characters | * Specify tab length in characters | ||||
| * | * | ||||
| * @param tlength specify the length of tab in spaces, | * @param tlength specify the length of tab in spaces, | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setTablength( int tlength ) | public void setTablength( int tlength ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( tlength < 2 || tlength > 80 ) | 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; | tablength = tlength; | ||||
| StringBuffer sp = new StringBuffer(); | StringBuffer sp = new StringBuffer(); | ||||
| @@ -291,53 +291,53 @@ public class FixCRLF extends MatchingTask | |||||
| /** | /** | ||||
| * Executes the task. | * Executes the task. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| // first off, make sure that we've got a srcdir and destdir | // first off, make sure that we've got a srcdir and destdir | ||||
| if( srcDir == null ) | if( srcDir == null ) | ||||
| { | { | ||||
| throw new BuildException( "srcdir attribute must be set!" ); | |||||
| throw new TaskException( "srcdir attribute must be set!" ); | |||||
| } | } | ||||
| if( !srcDir.exists() ) | if( !srcDir.exists() ) | ||||
| { | { | ||||
| throw new BuildException( "srcdir does not exist!" ); | |||||
| throw new TaskException( "srcdir does not exist!" ); | |||||
| } | } | ||||
| if( !srcDir.isDirectory() ) | if( !srcDir.isDirectory() ) | ||||
| { | { | ||||
| throw new BuildException( "srcdir is not a directory!" ); | |||||
| throw new TaskException( "srcdir is not a directory!" ); | |||||
| } | } | ||||
| if( destDir != null ) | if( destDir != null ) | ||||
| { | { | ||||
| if( !destDir.exists() ) | if( !destDir.exists() ) | ||||
| { | { | ||||
| throw new BuildException( "destdir does not exist!" ); | |||||
| throw new TaskException( "destdir does not exist!" ); | |||||
| } | } | ||||
| if( !destDir.isDirectory() ) | if( !destDir.isDirectory() ) | ||||
| { | { | ||||
| throw new BuildException( "destdir is not a directory!" ); | |||||
| throw new TaskException( "destdir is not a directory!" ); | |||||
| } | } | ||||
| } | } | ||||
| // log options used | // log options used | ||||
| log( "options:" + | 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 ); | DirectoryScanner ds = super.getDirectoryScanner( srcDir ); | ||||
| String[] files = ds.getIncludedFiles(); | String[] files = ds.getIncludedFiles(); | ||||
| for( int i = 0; i < files.length; i++ ) | 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 | throws IOException | ||||
| { | { | ||||
| return ( encoding == null ) ? new FileReader( f ) | 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 | * Scan a BufferLine forward from the 'next' pointer for the end of a | ||||
| * character constant. Set 'lookahead' pointer to the character following | * character constant. Set 'lookahead' pointer to the character following | ||||
| @@ -364,10 +363,10 @@ public class FixCRLF extends MatchingTask | |||||
| * | * | ||||
| * @param bufline Description of Parameter | * @param bufline Description of Parameter | ||||
| * @param terminator 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 ) | private void endOfCharConst( OneLiner.BufferLine bufline, char terminator ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| int ptr = bufline.getNext(); | int ptr = bufline.getNext(); | ||||
| int eol = bufline.length(); | int eol = bufline.length(); | ||||
| @@ -389,7 +388,7 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| }// end of while (ptr < eol) | }// end of while (ptr < eol) | ||||
| // Must have fallen through to the end of the line | // 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. | * next eol character. | ||||
| * | * | ||||
| * @param bufline Description of Parameter | * @param bufline Description of Parameter | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void nextStateChange( OneLiner.BufferLine bufline ) | private void nextStateChange( OneLiner.BufferLine bufline ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| int eol = bufline.length(); | int eol = bufline.length(); | ||||
| int ptr = bufline.getNext(); | 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 | // Look for next single or double quote, double slash or slash star | ||||
| while( ptr < eol ) | 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 switch (bufline.getChar(ptr++)) | ||||
| }// end of while (ptr < eol) | }// end of while (ptr < eol) | ||||
| @@ -445,7 +444,6 @@ public class FixCRLF extends MatchingTask | |||||
| bufline.setLookahead( ptr ); | bufline.setLookahead( ptr ); | ||||
| } | } | ||||
| /** | /** | ||||
| * Process a BufferLine string which is not part of of a string constant. | * 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 | * 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 | // process sequences of white space | ||||
| // first convert all tabs to spaces | // first convert all tabs to spaces | ||||
| linebuf.setLength( 0 ); | 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 | linebuf.append( line.substring( place, nextTab ) );// copy to the TAB | ||||
| col += nextTab - place; | col += nextTab - place; | ||||
| @@ -492,7 +490,7 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| }// end of try-catch | }// end of try-catch | ||||
| } | } | ||||
| else | else | ||||
| @@ -519,9 +517,9 @@ public class FixCRLF extends MatchingTask | |||||
| ; nextStop += tablength ) | ; nextStop += tablength ) | ||||
| { | { | ||||
| for( tabCol = nextStop; | for( tabCol = nextStop; | ||||
| --tabCol - placediff >= place | |||||
| && linestring.charAt( tabCol - placediff ) == ' ' | |||||
| ; ) | |||||
| --tabCol - placediff >= place | |||||
| && linestring.charAt( tabCol - placediff ) == ' ' | |||||
| ; ) | |||||
| { | { | ||||
| ;// Loop for the side-effects | ;// Loop for the side-effects | ||||
| } | } | ||||
| @@ -551,7 +549,7 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| }// end of try-catch | }// end of try-catch | ||||
| }// end of else tabs == ADD | }// end of else tabs == ADD | ||||
| @@ -562,9 +560,8 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| private void processFile( String file ) | private void processFile( String file ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| File srcFile = new File( srcDir, file ); | File srcFile = new File( srcDir, file ); | ||||
| File destD = destDir == null ? srcDir : destDir; | File destD = destDir == null ? srcDir : destDir; | ||||
| @@ -582,12 +579,12 @@ public class FixCRLF extends MatchingTask | |||||
| { | { | ||||
| tmpFile = fileUtils.createTempFile( "fixcrlf", "", destD ); | tmpFile = fileUtils.createTempFile( "fixcrlf", "", destD ); | ||||
| Writer writer = ( encoding == null ) ? new FileWriter( tmpFile ) | Writer writer = ( encoding == null ) ? new FileWriter( tmpFile ) | ||||
| : new OutputStreamWriter( new FileOutputStream( tmpFile ), encoding ); | |||||
| : new OutputStreamWriter( new FileOutputStream( tmpFile ), encoding ); | |||||
| outWriter = new BufferedWriter( writer ); | outWriter = new BufferedWriter( writer ); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| while( lines.hasMoreElements() ) | while( lines.hasMoreElements() ) | ||||
| @@ -597,11 +594,11 @@ public class FixCRLF extends MatchingTask | |||||
| try | try | ||||
| { | { | ||||
| line = ( OneLiner.BufferLine )lines.nextElement(); | |||||
| line = (OneLiner.BufferLine)lines.nextElement(); | |||||
| } | } | ||||
| catch( NoSuchElementException e ) | catch( NoSuchElementException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| String lineString = line.getLineString(); | String lineString = line.getLineString(); | ||||
| @@ -619,7 +616,7 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| }// end of try-catch | }// end of try-catch | ||||
| } | } | ||||
| @@ -630,78 +627,78 @@ public class FixCRLF extends MatchingTask | |||||
| while( ( ptr = line.getNext() ) < linelen ) | 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 | 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 switch (state) | ||||
| }// end of while (line.getNext() < linelen) | }// end of while (line.getNext() < linelen) | ||||
| @@ -714,7 +711,7 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| }// end of try-catch | }// end of try-catch | ||||
| }// end of while (lines.hasNext()) | }// end of while (lines.hasNext()) | ||||
| @@ -733,7 +730,7 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -743,7 +740,7 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| catch( IOException e ) | 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 ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Unable to close source file " + srcFile ); | |||||
| throw new TaskException( "Unable to close source file " + srcFile ); | |||||
| } | } | ||||
| if( destFile.exists() ) | if( destFile.exists() ) | ||||
| @@ -768,28 +765,28 @@ public class FixCRLF extends MatchingTask | |||||
| log( destFile + " is being written", Project.MSG_DEBUG ); | log( destFile + " is being written", Project.MSG_DEBUG ); | ||||
| if( !destFile.delete() ) | if( !destFile.delete() ) | ||||
| { | { | ||||
| throw new BuildException( "Unable to delete " | |||||
| + destFile ); | |||||
| throw new TaskException( "Unable to delete " | |||||
| + destFile ); | |||||
| } | } | ||||
| if( !tmpFile.renameTo( destFile ) ) | if( !tmpFile.renameTo( destFile ) ) | ||||
| { | { | ||||
| throw new BuildException( | |||||
| throw new TaskException( | |||||
| "Failed to transform " + srcFile | "Failed to transform " + srcFile | ||||
| + " to " + destFile | |||||
| + ". Couldn't rename temporary file: " | |||||
| + tmpFile ); | |||||
| + " to " + destFile | |||||
| + ". Couldn't rename temporary file: " | |||||
| + tmpFile ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| {// destination is equal to temp file | {// destination is equal to temp file | ||||
| log( destFile + | 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() ) | 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 ); | log( "destFile does not exist", Project.MSG_DEBUG ); | ||||
| if( !tmpFile.renameTo( destFile ) ) | if( !tmpFile.renameTo( destFile ) ) | ||||
| { | { | ||||
| throw new BuildException( | |||||
| throw new TaskException( | |||||
| "Failed to transform " + srcFile | "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 ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -860,7 +857,6 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| } | } | ||||
| class OneLiner implements Enumeration | class OneLiner implements Enumeration | ||||
| { | { | ||||
| @@ -874,7 +870,7 @@ public class FixCRLF extends MatchingTask | |||||
| private BufferedReader reader; | private BufferedReader reader; | ||||
| public OneLiner( File srcFile ) | public OneLiner( File srcFile ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -884,7 +880,7 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| catch( IOException e ) | 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() | protected void nextLine() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| int ch = -1; | int ch = -1; | ||||
| int eolcount = 0; | int eolcount = 0; | ||||
| @@ -944,7 +940,7 @@ public class FixCRLF extends MatchingTask | |||||
| ch = reader.read(); | ch = reader.read(); | ||||
| while( ch != -1 && ch != '\r' && ch != '\n' ) | while( ch != -1 && ch != '\r' && ch != '\n' ) | ||||
| { | { | ||||
| line.append( ( char )ch ); | |||||
| line.append( (char)ch ); | |||||
| ch = reader.read(); | ch = reader.read(); | ||||
| } | } | ||||
| @@ -955,32 +951,32 @@ public class FixCRLF extends MatchingTask | |||||
| return; | 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': | 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; | break; | ||||
| case '\n': | case '\n': | ||||
| ++eolcount; | ++eolcount; | ||||
| eolStr.append( '\n' ); | eolStr.append( '\n' ); | ||||
| break; | break; | ||||
| }// end of switch ((char)(ch = reader.read())) | |||||
| break; | |||||
| case '\n': | |||||
| ++eolcount; | |||||
| eolStr.append( '\n' ); | |||||
| break; | |||||
| }// end of switch ((char) ch) | }// end of switch ((char) ch) | ||||
| // if at eolcount == 0 and trailing characters of string | // if at eolcount == 0 and trailing characters of string | ||||
| @@ -1013,7 +1009,7 @@ public class FixCRLF extends MatchingTask | |||||
| } | } | ||||
| catch( IOException e ) | 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; | private String line; | ||||
| public BufferLine( String line, String eolStr ) | public BufferLine( String line, String eolStr ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| next = 0; | next = 0; | ||||
| column = 0; | column = 0; | ||||
| @@ -6,11 +6,12 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.zip.GZIPInputStream; | 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 | * 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 ); | out = new FileOutputStream( dest ); | ||||
| fis = new FileInputStream( source ); | fis = new FileInputStream( source ); | ||||
| zIn = new GZIPInputStream( fis ); | zIn = new GZIPInputStream( fis ); | ||||
| byte[] buffer = new byte[8 * 1024]; | |||||
| byte[] buffer = new byte[ 8 * 1024 ]; | |||||
| int count = 0; | int count = 0; | ||||
| do | do | ||||
| { | { | ||||
| out.write( buffer, 0, count ); | out.write( buffer, 0, count ); | ||||
| count = zIn.read( buffer, 0, buffer.length ); | count = zIn.read( buffer, 0, buffer.length ); | ||||
| }while ( count != -1 ); | |||||
| } while( count != -1 ); | |||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "Problem expanding gzip " + ioe.getMessage(); | String msg = "Problem expanding gzip " + ioe.getMessage(); | ||||
| throw new BuildException( msg, ioe ); | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -67,7 +68,8 @@ public class GUnzip extends Unpack | |||||
| fis.close(); | fis.close(); | ||||
| } | } | ||||
| catch( IOException ioex ) | catch( IOException ioex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( out != null ) | if( out != null ) | ||||
| { | { | ||||
| @@ -76,7 +78,8 @@ public class GUnzip extends Unpack | |||||
| out.close(); | out.close(); | ||||
| } | } | ||||
| catch( IOException ioex ) | catch( IOException ioex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( zIn != null ) | if( zIn != null ) | ||||
| { | { | ||||
| @@ -85,7 +88,8 @@ public class GUnzip extends Unpack | |||||
| zIn.close(); | zIn.close(); | ||||
| } | } | ||||
| catch( IOException ioex ) | catch( IOException ioex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,11 +6,11 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.zip.GZIPOutputStream; | 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 | * Compresses a file with the GZIP algorithm. Normally used to compress | ||||
| @@ -34,7 +34,7 @@ public class GZip extends Pack | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "Problem creating gzip " + ioe.getMessage(); | String msg = "Problem creating gzip " + ioe.getMessage(); | ||||
| throw new BuildException( msg, ioe ); | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -46,7 +46,8 @@ public class GZip extends Pack | |||||
| zOut.close(); | zOut.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,9 +6,10 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | 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.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -51,8 +52,8 @@ public class GenerateKey extends Task | |||||
| { | { | ||||
| if( null != expandedDname ) | 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; | this.dname = dname; | ||||
| } | } | ||||
| @@ -68,7 +69,7 @@ public class GenerateKey extends Task | |||||
| } | } | ||||
| public void setKeysize( final String keysize ) | public void setKeysize( final String keysize ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -76,7 +77,7 @@ public class GenerateKey extends Task | |||||
| } | } | ||||
| catch( final NumberFormatException nfe ) | 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 ) | public void setValidity( final String validity ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -109,7 +110,7 @@ public class GenerateKey extends Task | |||||
| } | } | ||||
| catch( final NumberFormatException nfe ) | 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() | public DistinguishedName createDname() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( null != expandedDname ) | 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 ) | 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(); | expandedDname = new DistinguishedName(); | ||||
| return expandedDname; | return expandedDname; | ||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( project.getJavaVersion().equals( Project.JAVA_1_1 ) ) | 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 ) | if( null == alias ) | ||||
| { | { | ||||
| throw new BuildException( "alias attribute must be set" ); | |||||
| throw new TaskException( "alias attribute must be set" ); | |||||
| } | } | ||||
| if( null == storepass ) | if( null == storepass ) | ||||
| { | { | ||||
| throw new BuildException( "storepass attribute must be set" ); | |||||
| throw new TaskException( "storepass attribute must be set" ); | |||||
| } | } | ||||
| if( null == dname && null == expandedDname ) | if( null == dname && null == expandedDname ) | ||||
| { | { | ||||
| throw new BuildException( "dname must be set" ); | |||||
| throw new TaskException( "dname must be set" ); | |||||
| } | } | ||||
| final StringBuffer sb = new StringBuffer(); | final StringBuffer sb = new StringBuffer(); | ||||
| @@ -246,7 +247,7 @@ public class GenerateKey extends Task | |||||
| } | } | ||||
| log( "Generating Key for " + alias ); | 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.setCommand( new Commandline( sb.toString() ) ); | ||||
| cmd.setFailonerror( true ); | cmd.setFailonerror( true ); | ||||
| cmd.setTaskName( getTaskName() ); | cmd.setTaskName( getTaskName() ); | ||||
| @@ -311,7 +312,7 @@ public class GenerateKey extends Task | |||||
| } | } | ||||
| firstPass = false; | firstPass = false; | ||||
| final DnameParam param = ( DnameParam )params.elementAt( i ); | |||||
| final DnameParam param = (DnameParam)params.elementAt( i ); | |||||
| sb.append( encode( param.getName() ) ); | sb.append( encode( param.getName() ) ); | ||||
| sb.append( '=' ); | sb.append( '=' ); | ||||
| sb.append( encode( param.getValue() ) ); | sb.append( encode( param.getValue() ) ); | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -14,7 +15,7 @@ import java.net.HttpURLConnection; | |||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.net.URLConnection; | import java.net.URLConnection; | ||||
| import java.util.Date; | 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.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -100,7 +101,6 @@ public class Get extends Task | |||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Username for basic auth. | * Username for basic auth. | ||||
| * | * | ||||
| @@ -121,33 +121,32 @@ public class Get extends Task | |||||
| verbose = v; | verbose = v; | ||||
| } | } | ||||
| /** | /** | ||||
| * Does the work. | * Does the work. | ||||
| * | * | ||||
| * @exception BuildException Thrown in unrecoverable error. | |||||
| * @exception TaskException Thrown in unrecoverable error. | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( source == null ) | if( source == null ) | ||||
| { | { | ||||
| throw new BuildException( "src attribute is required" ); | |||||
| throw new TaskException( "src attribute is required" ); | |||||
| } | } | ||||
| if( dest == null ) | if( dest == null ) | ||||
| { | { | ||||
| throw new BuildException( "dest attribute is required" ); | |||||
| throw new TaskException( "dest attribute is required" ); | |||||
| } | } | ||||
| if( dest.exists() && dest.isDirectory() ) | 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() ) | if( dest.exists() && !dest.canWrite() ) | ||||
| { | { | ||||
| throw new BuildException( "Can't write to " + dest.getAbsolutePath() ); | |||||
| throw new TaskException( "Can't write to " + dest.getAbsolutePath() ); | |||||
| } | } | ||||
| try | try | ||||
| @@ -187,7 +186,7 @@ public class Get extends Task | |||||
| try | try | ||||
| { | { | ||||
| sun.misc.BASE64Encoder encoder = | 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() ); | encoding = encoder.encode( up.getBytes() ); | ||||
| } | } | ||||
| @@ -204,7 +203,7 @@ public class Get extends Task | |||||
| //next test for a 304 result (HTTP only) | //next test for a 304 result (HTTP only) | ||||
| if( connection instanceof HttpURLConnection ) | if( connection instanceof HttpURLConnection ) | ||||
| { | { | ||||
| HttpURLConnection httpConnection = ( HttpURLConnection )connection; | |||||
| HttpURLConnection httpConnection = (HttpURLConnection)connection; | |||||
| if( httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED ) | if( httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED ) | ||||
| { | { | ||||
| //not modified so no file download. just return instead | //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 ); | log( "Can't get " + source + " to " + dest ); | ||||
| if( ignoreErrors ) | if( ignoreErrors ) | ||||
| return; | 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; | int length; | ||||
| while( ( length = is.read( buffer ) ) >= 0 ) | while( ( length = is.read( buffer ) ) >= 0 ) | ||||
| @@ -283,7 +282,7 @@ public class Get extends Task | |||||
| log( "Error getting " + source + " to " + dest ); | log( "Error getting " + source + " to " + dest ); | ||||
| if( ignoreErrors ) | if( ignoreErrors ) | ||||
| return; | return; | ||||
| throw new BuildException( "Error", ioe); | |||||
| throw new TaskException( "Error", ioe ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -294,16 +293,16 @@ public class Get extends Task | |||||
| * @param timemillis Description of Parameter | * @param timemillis Description of Parameter | ||||
| * @return true if it succeeded. False means that this is a java1.1 system | * @return true if it succeeded. False means that this is a java1.1 system | ||||
| * and that file times can not be set | * 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. | * comes from file access failures. | ||||
| */ | */ | ||||
| protected boolean touchFile( File file, long timemillis ) | protected boolean touchFile( File file, long timemillis ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( project.getJavaVersion() != Project.JAVA_1_1 ) | if( project.getJavaVersion() != Project.JAVA_1_1 ) | ||||
| { | { | ||||
| Touch touch = ( Touch )project.createTask( "touch" ); | |||||
| Touch touch = (Touch)project.createTask( "touch" ); | |||||
| touch.setOwningTarget( target ); | touch.setOwningTarget( target ); | ||||
| touch.setTaskName( getTaskName() ); | touch.setTaskName( getTaskName() ); | ||||
| touch.setLocation( getLocation() ); | touch.setLocation( getLocation() ); | ||||
| @@ -330,14 +329,13 @@ public class Get extends Task | |||||
| public final char[] alphabet = { | public final char[] alphabet = { | ||||
| 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7 | '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 ) | public String encode( String s ) | ||||
| { | { | ||||
| @@ -350,7 +348,7 @@ public class Get extends Task | |||||
| int bits6; | int bits6; | ||||
| char[] out | char[] out | ||||
| = new char[( ( octetString.length - 1 ) / 3 + 1 ) * 4]; | |||||
| = new char[ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ]; | |||||
| int outIndex = 0; | int outIndex = 0; | ||||
| int i = 0; | int i = 0; | ||||
| @@ -358,46 +356,46 @@ public class Get extends Task | |||||
| while( ( i + 3 ) <= octetString.length ) | while( ( i + 3 ) <= octetString.length ) | ||||
| { | { | ||||
| // store the octets | // 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; | bits6 = ( bits24 & 0x00FC0000 ) >> 18; | ||||
| out[outIndex++] = alphabet[bits6]; | |||||
| out[ outIndex++ ] = alphabet[ bits6 ]; | |||||
| bits6 = ( bits24 & 0x0003F000 ) >> 12; | bits6 = ( bits24 & 0x0003F000 ) >> 12; | ||||
| out[outIndex++] = alphabet[bits6]; | |||||
| out[ outIndex++ ] = alphabet[ bits6 ]; | |||||
| bits6 = ( bits24 & 0x00000FC0 ) >> 6; | bits6 = ( bits24 & 0x00000FC0 ) >> 6; | ||||
| out[outIndex++] = alphabet[bits6]; | |||||
| out[ outIndex++ ] = alphabet[ bits6 ]; | |||||
| bits6 = ( bits24 & 0x0000003F ); | bits6 = ( bits24 & 0x0000003F ); | ||||
| out[outIndex++] = alphabet[bits6]; | |||||
| out[ outIndex++ ] = alphabet[ bits6 ]; | |||||
| } | } | ||||
| if( octetString.length - i == 2 ) | if( octetString.length - i == 2 ) | ||||
| { | { | ||||
| // store the octets | // 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; | bits6 = ( bits24 & 0x00FC0000 ) >> 18; | ||||
| out[outIndex++] = alphabet[bits6]; | |||||
| out[ outIndex++ ] = alphabet[ bits6 ]; | |||||
| bits6 = ( bits24 & 0x0003F000 ) >> 12; | bits6 = ( bits24 & 0x0003F000 ) >> 12; | ||||
| out[outIndex++] = alphabet[bits6]; | |||||
| out[ outIndex++ ] = alphabet[ bits6 ]; | |||||
| bits6 = ( bits24 & 0x00000FC0 ) >> 6; | bits6 = ( bits24 & 0x00000FC0 ) >> 6; | ||||
| out[outIndex++] = alphabet[bits6]; | |||||
| out[ outIndex++ ] = alphabet[ bits6 ]; | |||||
| // padding | // padding | ||||
| out[outIndex++] = '='; | |||||
| out[ outIndex++ ] = '='; | |||||
| } | } | ||||
| else if( octetString.length - i == 1 ) | else if( octetString.length - i == 1 ) | ||||
| { | { | ||||
| // store the octets | // store the octets | ||||
| bits24 = ( octetString[i] & 0xFF ) << 16; | |||||
| bits24 = ( octetString[ i ] & 0xFF ) << 16; | |||||
| bits6 = ( bits24 & 0x00FC0000 ) >> 18; | bits6 = ( bits24 & 0x00FC0000 ) >> 18; | ||||
| out[outIndex++] = alphabet[bits6]; | |||||
| out[ outIndex++ ] = alphabet[ bits6 ]; | |||||
| bits6 = ( bits24 & 0x0003F000 ) >> 12; | bits6 = ( bits24 & 0x0003F000 ) >> 12; | ||||
| out[outIndex++] = alphabet[bits6]; | |||||
| out[ outIndex++ ] = alphabet[ bits6 ]; | |||||
| // padding | // padding | ||||
| out[outIndex++] = '='; | |||||
| out[outIndex++] = '='; | |||||
| out[ outIndex++ ] = '='; | |||||
| out[ outIndex++ ] = '='; | |||||
| } | } | ||||
| return new String( out ); | return new String( out ); | ||||
| @@ -6,13 +6,14 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | 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. | * Ant task to read input line from console. | ||||
| @@ -29,7 +30,9 @@ public class Input extends Task | |||||
| /** | /** | ||||
| * No arg constructor. | * No arg constructor. | ||||
| */ | */ | ||||
| public Input() { } | |||||
| public Input() | |||||
| { | |||||
| } | |||||
| /** | /** | ||||
| * Defines the name of a property to be created from input. Behaviour is | * 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. | * Actual test method executed by jakarta-ant. | ||||
| * | * | ||||
| * @exception BuildException | |||||
| * @exception TaskException | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Vector accept = null; | Vector accept = null; | ||||
| if( validargs != null ) | if( validargs != null ) | ||||
| @@ -123,7 +126,7 @@ public class Input extends Task | |||||
| } | } | ||||
| catch( IOException e ) | 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 | // 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 ) ) ) | 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 | // adopted from org.apache.tools.ant.taskdefs.Property | ||||
| @@ -6,10 +6,19 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | 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.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.FileScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.ZipFileSet; | import org.apache.tools.ant.types.ZipFileSet; | ||||
| @@ -67,7 +76,7 @@ public class Jar extends Zip | |||||
| { | { | ||||
| if( !manifestFile.exists() ) | if( !manifestFile.exists() ) | ||||
| { | { | ||||
| throw new BuildException( "Manifest file: " + manifestFile + " does not exist." ); | |||||
| throw new TaskException( "Manifest file: " + manifestFile + " does not exist." ); | |||||
| } | } | ||||
| this.manifestFile = manifestFile; | this.manifestFile = manifestFile; | ||||
| @@ -86,11 +95,11 @@ public class Jar extends Zip | |||||
| catch( ManifestException e ) | catch( ManifestException e ) | ||||
| { | { | ||||
| log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); | log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); | ||||
| throw new BuildException( "Invalid Manifest: " + manifestFile, e ); | |||||
| throw new TaskException( "Invalid Manifest: " + manifestFile, e ); | |||||
| } | } | ||||
| catch( IOException 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 | finally | ||||
| { | { | ||||
| @@ -111,7 +120,7 @@ public class Jar extends Zip | |||||
| public void setWhenempty( WhenEmpty we ) | public void setWhenempty( WhenEmpty we ) | ||||
| { | { | ||||
| log( "JARs are never empty, they contain at least a manifest file", | log( "JARs are never empty, they contain at least a manifest file", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| } | } | ||||
| public void addConfiguredManifest( Manifest newManifest ) | public void addConfiguredManifest( Manifest newManifest ) | ||||
| @@ -139,10 +148,10 @@ public class Jar extends Zip | |||||
| * @param zipFile intended archive file (may or may not exist) | * @param zipFile intended archive file (may or may not exist) | ||||
| * @return true if nothing need be done (may have done something already); | * @return true if nothing need be done (may have done something already); | ||||
| * false if archive creation should proceed | * false if archive creation should proceed | ||||
| * @exception BuildException if it likes | |||||
| * @exception TaskException if it likes | |||||
| */ | */ | ||||
| protected boolean isUpToDate( FileScanner[] scanners, File zipFile ) | protected boolean isUpToDate( FileScanner[] scanners, File zipFile ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| // need to handle manifest as a special check | // need to handle manifest as a special check | ||||
| if( buildFileManifest || manifestFile == null ) | if( buildFileManifest || manifestFile == null ) | ||||
| @@ -172,7 +181,7 @@ public class Jar extends Zip | |||||
| { | { | ||||
| // any problems and we will rebuild | // any problems and we will rebuild | ||||
| log( "Updating jar since cannot read current jar manifest: " + e.getClass().getName() + e.getMessage(), | log( "Updating jar since cannot read current jar manifest: " + e.getClass().getName() + e.getMessage(), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| return false; | return false; | ||||
| } | } | ||||
| finally | finally | ||||
| @@ -213,7 +222,7 @@ public class Jar extends Zip | |||||
| } | } | ||||
| protected void finalizeZipOutputStream( ZipOutputStream zOut ) | protected void finalizeZipOutputStream( ZipOutputStream zOut ) | ||||
| throws IOException, BuildException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| if( index ) | if( index ) | ||||
| { | { | ||||
| @@ -222,7 +231,7 @@ public class Jar extends Zip | |||||
| } | } | ||||
| protected void initZipOutputStream( ZipOutputStream zOut ) | protected void initZipOutputStream( ZipOutputStream zOut ) | ||||
| throws IOException, BuildException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -232,9 +241,9 @@ public class Jar extends Zip | |||||
| { | { | ||||
| execManifest.merge( manifest ); | 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/" ); | zipDir( null, zOut, "META-INF/" ); | ||||
| @@ -251,7 +260,7 @@ public class Jar extends Zip | |||||
| catch( ManifestException e ) | catch( ManifestException e ) | ||||
| { | { | ||||
| log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); | log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); | ||||
| throw new BuildException( "Invalid Manifest", e ); | |||||
| throw new TaskException( "Invalid Manifest", e ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -265,7 +274,7 @@ public class Jar extends Zip | |||||
| if( vPath.equalsIgnoreCase( "META-INF/MANIFEST.MF" ) ) | if( vPath.equalsIgnoreCase( "META-INF/MANIFEST.MF" ) ) | ||||
| { | { | ||||
| log( "Warning: selected " + archiveType + " files include a META-INF/MANIFEST.MF which will be ignored " + | 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 | else | ||||
| { | { | ||||
| @@ -287,7 +296,7 @@ public class Jar extends Zip | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Unable to read manifest file: ", e ); | |||||
| throw new TaskException( "Unable to read manifest file: ", e ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -325,7 +334,7 @@ public class Jar extends Zip | |||||
| Enumeration enum = addedDirs.keys(); | Enumeration enum = addedDirs.keys(); | ||||
| while( enum.hasMoreElements() ) | 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 | // try to be smart, not to be fooled by a weird directory name | ||||
| // @fixme do we need to check for directories starting by ./ ? | // @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() ); | super.zipFile( bais, zOut, INDEX_NAME, System.currentTimeMillis() ); | ||||
| } | } | ||||
| /** | /** | ||||
| * Handle situation when we encounter a manifest file If we haven't been | * 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, | * 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 ) | catch( ManifestException e ) | ||||
| { | { | ||||
| log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); | log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); | ||||
| throw new BuildException( "Invalid Manifest", e ); | |||||
| throw new TaskException( "Invalid Manifest", e ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -12,7 +12,7 @@ import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -43,14 +43,14 @@ public class Java extends Task | |||||
| * Set the class name. | * Set the class name. | ||||
| * | * | ||||
| * @param s The new Classname value | * @param s The new Classname value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setClassname( String s ) | public void setClassname( String s ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( cmdl.getJar() != null ) | 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 ); | 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 | * @param fail The new Failonerror value | ||||
| */ | */ | ||||
| @@ -114,14 +114,14 @@ public class Java extends Task | |||||
| * set the jar name... | * set the jar name... | ||||
| * | * | ||||
| * @param jarfile The new Jar value | * @param jarfile The new Jar value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setJar( File jarfile ) | public void setJar( File jarfile ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( cmdl.getClassname() != null ) | 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() ); | cmdl.setJar( jarfile.getAbsolutePath() ); | ||||
| } | } | ||||
| @@ -207,17 +207,17 @@ public class Java extends Task | |||||
| /** | /** | ||||
| * Do the execution. | * Do the execution. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| int err = -1; | int err = -1; | ||||
| if( ( err = executeJava() ) != 0 ) | if( ( err = executeJava() ) != 0 ) | ||||
| { | { | ||||
| if( failOnError ) | if( failOnError ) | ||||
| { | { | ||||
| throw new BuildException( "Java returned: " + err ); | |||||
| throw new TaskException( "Java returned: " + err ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -231,19 +231,19 @@ public class Java extends Task | |||||
| * | * | ||||
| * @return the return code from the execute java class if it was executed in | * @return the return code from the execute java class if it was executed in | ||||
| * a separate VM (fork = "yes"). | * a separate VM (fork = "yes"). | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public int executeJava() | public int executeJava() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| String classname = cmdl.getClassname(); | String classname = cmdl.getClassname(); | ||||
| if( classname == null && cmdl.getJar() == null ) | 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 ) | 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 ) | if( fork ) | ||||
| @@ -300,10 +300,10 @@ public class Java extends Task | |||||
| * | * | ||||
| * @param classname Description of Parameter | * @param classname Description of Parameter | ||||
| * @param args 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 ) | protected void run( String classname, Vector args ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| CommandlineJava cmdj = new CommandlineJava(); | CommandlineJava cmdj = new CommandlineJava(); | ||||
| cmdj.setClassname( classname ); | cmdj.setClassname( classname ); | ||||
| @@ -319,10 +319,10 @@ public class Java extends Task | |||||
| * line application. | * line application. | ||||
| * | * | ||||
| * @param command Description of Parameter | * @param command Description of Parameter | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void run( CommandlineJava command ) | private void run( CommandlineJava command ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| ExecuteJava exe = new ExecuteJava(); | ExecuteJava exe = new ExecuteJava(); | ||||
| exe.setJavaCommand( command.getJavaCommand() ); | exe.setJavaCommand( command.getJavaCommand() ); | ||||
| @@ -337,7 +337,7 @@ public class Java extends Task | |||||
| } | } | ||||
| catch( IOException io ) | catch( IOException io ) | ||||
| { | { | ||||
| throw new BuildException( "Error", io ); | |||||
| throw new TaskException( "Error", io ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -358,10 +358,10 @@ public class Java extends Task | |||||
| * | * | ||||
| * @param command Description of Parameter | * @param command Description of Parameter | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private int run( String[] command ) | private int run( String[] command ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| FileOutputStream fos = null; | FileOutputStream fos = null; | ||||
| try | try | ||||
| @@ -387,7 +387,7 @@ public class Java extends Task | |||||
| } | } | ||||
| else if( !dir.exists() || !dir.isDirectory() ) | else if( !dir.exists() || !dir.isDirectory() ) | ||||
| { | { | ||||
| throw new BuildException( dir.getAbsolutePath() + " is not a valid directory"); | |||||
| throw new TaskException( dir.getAbsolutePath() + " is not a valid directory" ); | |||||
| } | } | ||||
| exe.setWorkingDirectory( dir ); | exe.setWorkingDirectory( dir ); | ||||
| @@ -399,12 +399,12 @@ public class Java extends Task | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| } | } | ||||
| catch( IOException io ) | catch( IOException io ) | ||||
| { | { | ||||
| throw new BuildException( "Error", io ); | |||||
| throw new TaskException( "Error", io ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -10,8 +10,8 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.myrmidon.framework.Os; | import org.apache.myrmidon.framework.Os; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter; | import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter; | ||||
| @@ -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 | * @param fail The new Failonerror value | ||||
| */ | */ | ||||
| @@ -715,26 +715,26 @@ public class Javac extends MatchingTask | |||||
| /** | /** | ||||
| * Executes the task. | * Executes the task. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| // first off, make sure that we've got a srcdir | // first off, make sure that we've got a srcdir | ||||
| if( src == null ) | if( src == null ) | ||||
| { | { | ||||
| throw new BuildException( "srcdir attribute must be set!" ); | |||||
| throw new TaskException( "srcdir attribute must be set!" ); | |||||
| } | } | ||||
| String[] list = src.list(); | String[] list = src.list(); | ||||
| if( list.length == 0 ) | if( list.length == 0 ) | ||||
| { | { | ||||
| throw new BuildException( "srcdir attribute must be set!" ); | |||||
| throw new TaskException( "srcdir attribute must be set!" ); | |||||
| } | } | ||||
| if( destDir != null && !destDir.isDirectory() ) | if( destDir != null && !destDir.isDirectory() ) | ||||
| { | { | ||||
| throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory" ); | |||||
| throw new TaskException( "destination directory \"" + destDir + "\" does not exist or is not a directory" ); | |||||
| } | } | ||||
| // scan source directories and dest directory to build up | // scan source directories and dest directory to build up | ||||
| @@ -745,7 +745,7 @@ public class Javac extends MatchingTask | |||||
| File srcDir = (File)resolveFile( list[ i ] ); | File srcDir = (File)resolveFile( list[ i ] ); | ||||
| if( !srcDir.exists() ) | 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 ); | DirectoryScanner ds = this.getDirectoryScanner( srcDir ); | ||||
| @@ -777,7 +777,7 @@ public class Javac extends MatchingTask | |||||
| { | { | ||||
| if( failOnError ) | if( failOnError ) | ||||
| { | { | ||||
| throw new BuildException( FAIL_MSG ); | |||||
| throw new TaskException( FAIL_MSG ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.FilenameFilter; | import java.io.FilenameFilter; | ||||
| @@ -14,12 +15,11 @@ import java.io.PrintWriter; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.ProjectHelper; | |||||
| import org.apache.tools.ant.Task; | 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.Commandline; | ||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| @@ -100,6 +100,7 @@ public class Javadoc extends Task | |||||
| } | } | ||||
| public void setAdditionalparam( String add ) | public void setAdditionalparam( String add ) | ||||
| throws TaskException | |||||
| { | { | ||||
| cmd.createArgument().setLine( add ); | cmd.createArgument().setLine( add ); | ||||
| } | } | ||||
| @@ -300,6 +301,7 @@ public class Javadoc extends Task | |||||
| } | } | ||||
| public void setLinkoffline( String src ) | public void setLinkoffline( String src ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( !javadoc1 ) | if( !javadoc1 ) | ||||
| { | { | ||||
| @@ -309,14 +311,14 @@ public class Javadoc extends Task | |||||
| "a package-list file location separated by a space"; | "a package-list file location separated by a space"; | ||||
| if( src.trim().length() == 0 ) | if( src.trim().length() == 0 ) | ||||
| { | { | ||||
| throw new BuildException( linkOfflineError ); | |||||
| throw new TaskException( linkOfflineError ); | |||||
| } | } | ||||
| StringTokenizer tok = new StringTokenizer( src, " ", false ); | StringTokenizer tok = new StringTokenizer( src, " ", false ); | ||||
| le.setHref( tok.nextToken() ); | le.setHref( tok.nextToken() ); | ||||
| if( !tok.hasMoreTokens() ) | if( !tok.hasMoreTokens() ) | ||||
| { | { | ||||
| throw new BuildException( linkOfflineError ); | |||||
| throw new TaskException( linkOfflineError ); | |||||
| } | } | ||||
| le.setPackagelistLoc( resolveFile( tok.nextToken() ) ); | le.setPackagelistLoc( resolveFile( tok.nextToken() ) ); | ||||
| } | } | ||||
| @@ -430,6 +432,7 @@ public class Javadoc extends Task | |||||
| } | } | ||||
| public void setSourcefiles( String src ) | public void setSourcefiles( String src ) | ||||
| throws TaskException | |||||
| { | { | ||||
| StringTokenizer tok = new StringTokenizer( src, "," ); | StringTokenizer tok = new StringTokenizer( src, "," ); | ||||
| while( tok.hasMoreTokens() ) | while( tok.hasMoreTokens() ) | ||||
| @@ -606,12 +609,12 @@ public class Javadoc extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( sourcePath == null ) | if( sourcePath == null ) | ||||
| { | { | ||||
| String msg = "sourcePath attribute must be set!"; | String msg = "sourcePath attribute must be set!"; | ||||
| throw new BuildException( msg ); | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| log( "Generating Javadoc", Project.MSG_INFO ); | log( "Generating Javadoc", Project.MSG_INFO ); | ||||
| @@ -637,10 +640,10 @@ public class Javadoc extends Task | |||||
| cmd.createArgument().setValue( expand( bottom.getText() ) ); | cmd.createArgument().setValue( expand( bottom.getText() ) ); | ||||
| } | } | ||||
| Commandline toExecute = ( Commandline )cmd.clone(); | |||||
| Commandline toExecute = (Commandline)cmd.clone(); | |||||
| toExecute.setExecutable( getJavadocExecutableName() ); | toExecute.setExecutable( getJavadocExecutableName() ); | ||||
| // ------------------------------------------------ general javadoc arguments | |||||
| // ------------------------------------------------ general javadoc arguments | |||||
| if( classpath == null ) | if( classpath == null ) | ||||
| classpath = Path.systemClasspath; | classpath = Path.systemClasspath; | ||||
| else | else | ||||
| @@ -657,7 +660,7 @@ public class Javadoc extends Task | |||||
| { | { | ||||
| toExecute.createArgument().setValue( "-classpath" ); | toExecute.createArgument().setValue( "-classpath" ); | ||||
| toExecute.createArgument().setValue( sourcePath.toString() + | toExecute.createArgument().setValue( sourcePath.toString() + | ||||
| System.getProperty( "path.separator" ) + classpath.toString() ); | |||||
| System.getProperty( "path.separator" ) + classpath.toString() ); | |||||
| } | } | ||||
| if( version && doclet == null ) | if( version && doclet == null ) | ||||
| @@ -670,13 +673,13 @@ public class Javadoc extends Task | |||||
| if( destDir == null ) | if( destDir == null ) | ||||
| { | { | ||||
| String msg = "destDir attribute must be set!"; | 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 ) | if( !javadoc1 ) | ||||
| { | { | ||||
| @@ -684,7 +687,7 @@ public class Javadoc extends Task | |||||
| { | { | ||||
| if( doclet.getName() == null ) | if( doclet.getName() == null ) | ||||
| { | { | ||||
| throw new BuildException( "The doclet name must be specified." ); | |||||
| throw new TaskException( "The doclet name must be specified." ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -695,12 +698,12 @@ public class Javadoc extends Task | |||||
| toExecute.createArgument().setValue( "-docletpath" ); | toExecute.createArgument().setValue( "-docletpath" ); | ||||
| toExecute.createArgument().setPath( doclet.getPath() ); | 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 ) | 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() ); | toExecute.createArgument().setValue( param.getName() ); | ||||
| @@ -720,13 +723,13 @@ public class Javadoc extends Task | |||||
| // add the links arguments | // add the links arguments | ||||
| if( links.size() != 0 ) | 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 ) | 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() ) | if( la.isLinkOffline() ) | ||||
| @@ -734,8 +737,8 @@ public class Javadoc extends Task | |||||
| File packageListLocation = la.getPackagelistLoc(); | File packageListLocation = la.getPackagelistLoc(); | ||||
| if( packageListLocation == null ) | 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" ); | File packageList = new File( packageListLocation, "package-list" ); | ||||
| if( packageList.exists() ) | if( packageList.exists() ) | ||||
| @@ -747,7 +750,7 @@ public class Javadoc extends Task | |||||
| else | else | ||||
| { | { | ||||
| log( "Warning: No package list was found at " + packageListLocation, | log( "Warning: No package list was found at " + packageListLocation, | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -790,14 +793,14 @@ public class Javadoc extends Task | |||||
| // add the group arguments | // add the group arguments | ||||
| if( groups.size() != 0 ) | 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 title = ga.getTitle(); | ||||
| String packages = ga.getPackages(); | String packages = ga.getPackages(); | ||||
| if( title == null || packages == null ) | 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( "-group" ); | ||||
| toExecute.createArgument().setValue( expand( title ) ); | toExecute.createArgument().setValue( expand( title ) ); | ||||
| @@ -814,7 +817,7 @@ public class Javadoc extends Task | |||||
| Enumeration enum = packageNames.elements(); | Enumeration enum = packageNames.elements(); | ||||
| while( enum.hasMoreElements() ) | while( enum.hasMoreElements() ) | ||||
| { | { | ||||
| PackageName pn = ( PackageName )enum.nextElement(); | |||||
| PackageName pn = (PackageName)enum.nextElement(); | |||||
| String name = pn.getName().trim(); | String name = pn.getName().trim(); | ||||
| if( name.endsWith( ".*" ) ) | if( name.endsWith( ".*" ) ) | ||||
| { | { | ||||
| @@ -832,7 +835,7 @@ public class Javadoc extends Task | |||||
| enum = excludePackageNames.elements(); | enum = excludePackageNames.elements(); | ||||
| while( enum.hasMoreElements() ) | while( enum.hasMoreElements() ) | ||||
| { | { | ||||
| PackageName pn = ( PackageName )enum.nextElement(); | |||||
| PackageName pn = (PackageName)enum.nextElement(); | |||||
| excludePackages.addElement( pn.getName().trim() ); | excludePackages.addElement( pn.getName().trim() ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -859,13 +862,13 @@ public class Javadoc extends Task | |||||
| toExecute.createArgument().setValue( "@" + tmpList.getAbsolutePath() ); | toExecute.createArgument().setValue( "@" + tmpList.getAbsolutePath() ); | ||||
| } | } | ||||
| srcListWriter = new PrintWriter( new FileWriter( tmpList.getAbsolutePath(), | srcListWriter = new PrintWriter( new FileWriter( tmpList.getAbsolutePath(), | ||||
| true ) ); | |||||
| true ) ); | |||||
| } | } | ||||
| Enumeration enum = sourceFiles.elements(); | Enumeration enum = sourceFiles.elements(); | ||||
| while( enum.hasMoreElements() ) | while( enum.hasMoreElements() ) | ||||
| { | { | ||||
| SourceFile sf = ( SourceFile )enum.nextElement(); | |||||
| SourceFile sf = (SourceFile)enum.nextElement(); | |||||
| String sourceFileName = sf.getFile().getAbsolutePath(); | String sourceFileName = sf.getFile().getAbsolutePath(); | ||||
| if( useExternalFile ) | if( useExternalFile ) | ||||
| { | { | ||||
| @@ -880,7 +883,7 @@ public class Javadoc extends Task | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error creating temporary file", e ); | |||||
| throw new TaskException( "Error creating temporary file", e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -917,12 +920,12 @@ public class Javadoc extends Task | |||||
| int ret = exe.execute(); | int ret = exe.execute(); | ||||
| if( ret != 0 && failOnError ) | if( ret != 0 && failOnError ) | ||||
| { | { | ||||
| throw new BuildException( "Javadoc returned " + ret ); | |||||
| throw new TaskException( "Javadoc returned " + ret ); | |||||
| } | } | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Javadoc failed: " + e, e ); | |||||
| throw new TaskException( "Javadoc failed: " + e, e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -941,7 +944,8 @@ public class Javadoc extends Task | |||||
| err.close(); | err.close(); | ||||
| } | } | ||||
| catch( IOException e ) | 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 | // so we need to fall back to assuming javadoc is somewhere on the | ||||
| // PATH. | // PATH. | ||||
| File jdocExecutable = new File( System.getProperty( "java.home" ) + | File jdocExecutable = new File( System.getProperty( "java.home" ) + | ||||
| "/../bin/javadoc" + extension ); | |||||
| "/../bin/javadoc" + extension ); | |||||
| if( jdocExecutable.exists() && !Os.isFamily( "netware" ) ) | if( jdocExecutable.exists() && !Os.isFamily( "netware" ) ) | ||||
| { | { | ||||
| @@ -978,7 +982,7 @@ public class Javadoc extends Task | |||||
| if( !Os.isFamily( "netware" ) ) | if( !Os.isFamily( "netware" ) ) | ||||
| { | { | ||||
| log( "Unable to locate " + jdocExecutable.getAbsolutePath() + | log( "Unable to locate " + jdocExecutable.getAbsolutePath() + | ||||
| ". Using \"javadoc\" instead.", Project.MSG_VERBOSE ); | |||||
| ". Using \"javadoc\" instead.", Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| return "javadoc"; | return "javadoc"; | ||||
| } | } | ||||
| @@ -1012,13 +1016,12 @@ public class Javadoc extends Task | |||||
| else | else | ||||
| { | { | ||||
| project.log( this, | 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 ) | private void addArgIf( boolean b, String arg ) | ||||
| { | { | ||||
| if( b ) | if( b ) | ||||
| @@ -1039,6 +1042,7 @@ public class Javadoc extends Task | |||||
| */ | */ | ||||
| private void evaluatePackages( Commandline toExecute, Path sourcePath, | private void evaluatePackages( Commandline toExecute, Path sourcePath, | ||||
| Vector packages, Vector excludePackages ) | Vector packages, Vector excludePackages ) | ||||
| throws TaskException | |||||
| { | { | ||||
| log( "Source path = " + sourcePath.toString(), Project.MSG_VERBOSE ); | log( "Source path = " + sourcePath.toString(), Project.MSG_VERBOSE ); | ||||
| StringBuffer msg = new StringBuffer( "Packages = " ); | StringBuffer msg = new StringBuffer( "Packages = " ); | ||||
| @@ -1068,7 +1072,7 @@ public class Javadoc extends Task | |||||
| String[] list = sourcePath.list(); | String[] list = sourcePath.list(); | ||||
| if( list == null ) | if( list == null ) | ||||
| list = new String[0]; | |||||
| list = new String[ 0 ]; | |||||
| FileSet fs = new FileSet(); | FileSet fs = new FileSet(); | ||||
| fs.setDefaultexcludes( useDefaultExcludes ); | fs.setDefaultexcludes( useDefaultExcludes ); | ||||
| @@ -1076,7 +1080,7 @@ public class Javadoc extends Task | |||||
| Enumeration e = packages.elements(); | Enumeration e = packages.elements(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| String pkg = ( String )e.nextElement(); | |||||
| String pkg = (String)e.nextElement(); | |||||
| pkg = pkg.replace( '.', '/' ); | pkg = pkg.replace( '.', '/' ); | ||||
| if( pkg.endsWith( "*" ) ) | if( pkg.endsWith( "*" ) ) | ||||
| { | { | ||||
| @@ -1089,7 +1093,7 @@ public class Javadoc extends Task | |||||
| e = excludePackages.elements(); | e = excludePackages.elements(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| String pkg = ( String )e.nextElement(); | |||||
| String pkg = (String)e.nextElement(); | |||||
| pkg = pkg.replace( '.', '/' ); | pkg = pkg.replace( '.', '/' ); | ||||
| if( pkg.endsWith( "*" ) ) | if( pkg.endsWith( "*" ) ) | ||||
| { | { | ||||
| @@ -1111,7 +1115,7 @@ public class Javadoc extends Task | |||||
| for( int j = 0; j < list.length; j++ ) | for( int j = 0; j < list.length; j++ ) | ||||
| { | { | ||||
| File source = resolveFile( list[j] ); | |||||
| File source = resolveFile( list[ j ] ); | |||||
| fs.setDir( source ); | fs.setDir( source ); | ||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| @@ -1119,7 +1123,7 @@ public class Javadoc extends Task | |||||
| for( int i = 0; i < packageDirs.length; i++ ) | 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( | String[] files = pd.list( | ||||
| new FilenameFilter() | new FilenameFilter() | ||||
| { | { | ||||
| @@ -1135,7 +1139,7 @@ public class Javadoc extends Task | |||||
| if( files.length > 0 ) | if( files.length > 0 ) | ||||
| { | { | ||||
| String pkgDir = packageDirs[i].replace( '/', '.' ).replace( '\\', '.' ); | |||||
| String pkgDir = packageDirs[ i ].replace( '/', '.' ).replace( '\\', '.' ); | |||||
| if( !addedPackages.contains( pkgDir ) ) | if( !addedPackages.contains( pkgDir ) ) | ||||
| { | { | ||||
| if( useExternalFile ) | if( useExternalFile ) | ||||
| @@ -1154,7 +1158,7 @@ public class Javadoc extends Task | |||||
| } | } | ||||
| catch( IOException ioex ) | catch( IOException ioex ) | ||||
| { | { | ||||
| throw new BuildException( "Error creating temporary file", ioex ); | |||||
| throw new TaskException( "Error creating temporary file", ioex ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -1323,7 +1327,9 @@ public class Javadoc extends Task | |||||
| private Vector packages = new Vector( 3 ); | private Vector packages = new Vector( 3 ); | ||||
| private Html title; | private Html title; | ||||
| public GroupArgument() { } | |||||
| public GroupArgument() | |||||
| { | |||||
| } | |||||
| public void setPackages( String src ) | public void setPackages( String src ) | ||||
| { | { | ||||
| @@ -1380,7 +1386,9 @@ public class Javadoc extends Task | |||||
| private String href; | private String href; | ||||
| private File packagelistLoc; | private File packagelistLoc; | ||||
| public LinkArgument() { } | |||||
| public LinkArgument() | |||||
| { | |||||
| } | |||||
| public void setHref( String hr ) | public void setHref( String hr ) | ||||
| { | { | ||||
| @@ -1428,7 +1436,6 @@ public class Javadoc extends Task | |||||
| super( Javadoc.this, level ); | super( Javadoc.this, level ); | ||||
| } | } | ||||
| protected void logFlush() | protected void logFlush() | ||||
| { | { | ||||
| if( queuedLine != null ) | if( queuedLine != null ) | ||||
| @@ -6,13 +6,13 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| /** | /** | ||||
| * Logs each line written to this stream to the log system of ant. Tries to be | * Logs each line written to this stream to the log system of ant. Tries to be | ||||
| * smart about line separators.<br> | * smart about line separators.<br> | ||||
| @@ -47,7 +47,6 @@ public class LogOutputStream extends OutputStream | |||||
| return level; | return level; | ||||
| } | } | ||||
| /** | /** | ||||
| * Writes all remaining | * Writes all remaining | ||||
| * | * | ||||
| @@ -61,7 +60,6 @@ public class LogOutputStream extends OutputStream | |||||
| super.close(); | super.close(); | ||||
| } | } | ||||
| /** | /** | ||||
| * Write the data to the buffer and flush the buffer, if a line separator is | * Write the data to the buffer and flush the buffer, if a line separator is | ||||
| * detected. | * detected. | ||||
| @@ -72,7 +70,7 @@ public class LogOutputStream extends OutputStream | |||||
| public void write( int cc ) | public void write( int cc ) | ||||
| throws IOException | throws IOException | ||||
| { | { | ||||
| final byte c = ( byte )cc; | |||||
| final byte c = (byte)cc; | |||||
| if( ( c == '\n' ) || ( c == '\r' ) ) | if( ( c == '\n' ) || ( c == '\r' ) ) | ||||
| { | { | ||||
| if( !skip ) | if( !skip ) | ||||
| @@ -83,7 +81,6 @@ public class LogOutputStream extends OutputStream | |||||
| skip = ( c == '\r' ); | skip = ( c == '\r' ); | ||||
| } | } | ||||
| /** | /** | ||||
| * Converts the buffer to a string and sends it to <code>processLine</code> | * Converts the buffer to a string and sends it to <code>processLine</code> | ||||
| */ | */ | ||||
| @@ -6,8 +6,9 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| /** | /** | ||||
| @@ -28,7 +29,7 @@ public class LogStreamHandler extends PumpStreamHandler | |||||
| public LogStreamHandler( Task task, int outlevel, int errlevel ) | public LogStreamHandler( Task task, int outlevel, int errlevel ) | ||||
| { | { | ||||
| super( new LogOutputStream( task, outlevel ), | super( new LogOutputStream( task, outlevel ), | ||||
| new LogOutputStream( task, errlevel ) ); | |||||
| new LogOutputStream( task, errlevel ) ); | |||||
| } | } | ||||
| public void stop() | public void stop() | ||||
| @@ -42,7 +43,7 @@ public class LogStreamHandler extends PumpStreamHandler | |||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| // plain impossible | // plain impossible | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| @@ -20,7 +21,7 @@ import java.io.UnsupportedEncodingException; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| @@ -134,7 +135,7 @@ public class Manifest extends Task | |||||
| if( !sectionName.getName().equalsIgnoreCase( ATTRIBUTE_NAME ) ) | if( !sectionName.getName().equalsIgnoreCase( ATTRIBUTE_NAME ) ) | ||||
| { | { | ||||
| throw new ManifestException( "Manifest sections should start with a \"" + 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(); | nextSectionName = sectionName.getValue(); | ||||
| } | } | ||||
| @@ -157,10 +158,10 @@ public class Manifest extends Task | |||||
| * Construct a manifest from Ant's default manifest file. | * Construct a manifest from Ant's default manifest file. | ||||
| * | * | ||||
| * @return The DefaultManifest value | * @return The DefaultManifest value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public static Manifest getDefaultManifest() | public static Manifest getDefaultManifest() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -168,7 +169,7 @@ public class Manifest extends Task | |||||
| InputStream in = Manifest.class.getResourceAsStream( s ); | InputStream in = Manifest.class.getResourceAsStream( s ); | ||||
| if( in == null ) | if( in == null ) | ||||
| { | { | ||||
| throw new BuildException( "Could not find default manifest: " + s ); | |||||
| throw new TaskException( "Could not find default manifest: " + s ); | |||||
| } | } | ||||
| try | try | ||||
| { | { | ||||
| @@ -181,11 +182,11 @@ public class Manifest extends Task | |||||
| } | } | ||||
| catch( ManifestException e ) | catch( ManifestException e ) | ||||
| { | { | ||||
| throw new BuildException( "Default manifest is invalid !!" ); | |||||
| throw new TaskException( "Default manifest is invalid !!" ); | |||||
| } | } | ||||
| catch( IOException e ) | 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(); | Vector warnings = new Vector(); | ||||
| for( Enumeration e2 = mainSection.getWarnings(); e2.hasMoreElements(); ) | |||||
| for( Enumeration e2 = mainSection.getWarnings(); e2.hasMoreElements(); ) | |||||
| { | { | ||||
| warnings.addElement( e2.nextElement() ); | warnings.addElement( e2.nextElement() ); | ||||
| } | } | ||||
| // create a vector and add in the warnings for all the sections | // 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() ); | warnings.addElement( e2.nextElement() ); | ||||
| } | } | ||||
| @@ -247,7 +248,7 @@ public class Manifest extends Task | |||||
| { | { | ||||
| if( section.getName() == null ) | 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 ); | sections.put( section.getName().toLowerCase(), section ); | ||||
| } | } | ||||
| @@ -259,7 +260,7 @@ public class Manifest extends Task | |||||
| return false; | return false; | ||||
| } | } | ||||
| Manifest rhsManifest = ( Manifest )rhs; | |||||
| Manifest rhsManifest = (Manifest)rhs; | |||||
| if( manifestVersion == null ) | if( manifestVersion == null ) | ||||
| { | { | ||||
| if( rhsManifest.manifestVersion != null ) | if( rhsManifest.manifestVersion != null ) | ||||
| @@ -281,10 +282,10 @@ public class Manifest extends Task | |||||
| return false; | 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 ) ) | if( !section.equals( rhsSection ) ) | ||||
| { | { | ||||
| return false; | return false; | ||||
| @@ -297,14 +298,14 @@ public class Manifest extends Task | |||||
| /** | /** | ||||
| * Create or update the Manifest when used as a task. | * Create or update the Manifest when used as a task. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( manifestFile == null ) | if( manifestFile == null ) | ||||
| { | { | ||||
| throw new BuildException( "the file attribute is required" ); | |||||
| throw new TaskException( "the file attribute is required" ); | |||||
| } | } | ||||
| Manifest toWrite = getDefaultManifest(); | Manifest toWrite = getDefaultManifest(); | ||||
| @@ -319,13 +320,13 @@ public class Manifest extends Task | |||||
| } | } | ||||
| catch( ManifestException m ) | catch( ManifestException m ) | ||||
| { | { | ||||
| throw new BuildException( "Existing manifest " + manifestFile | |||||
| + " is invalid", m ); | |||||
| throw new TaskException( "Existing manifest " + manifestFile | |||||
| + " is invalid", m ); | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new | throw new | ||||
| BuildException( "Failed to read " + manifestFile, e ); | |||||
| TaskException( "Failed to read " + manifestFile, e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -336,7 +337,8 @@ public class Manifest extends Task | |||||
| f.close(); | f.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -347,7 +349,7 @@ public class Manifest extends Task | |||||
| } | } | ||||
| catch( ManifestException m ) | catch( ManifestException m ) | ||||
| { | { | ||||
| throw new BuildException( "Manifest is invalid", m ); | |||||
| throw new TaskException( "Manifest is invalid", m ); | |||||
| } | } | ||||
| PrintWriter w = null; | PrintWriter w = null; | ||||
| @@ -358,7 +360,8 @@ public class Manifest extends Task | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Failed to write " + manifestFile e ); | |||||
| throw new TaskException( "Failed to write " + manifestFile | |||||
| e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -384,11 +387,11 @@ public class Manifest extends Task | |||||
| manifestVersion = other.manifestVersion; | manifestVersion = other.manifestVersion; | ||||
| } | } | ||||
| mainSection.merge( other.mainSection ); | 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 ) | if( ourSection == null ) | ||||
| { | { | ||||
| sections.put( sectionName.toLowerCase(), otherSection ); | 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 ); | section.write( writer ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -477,7 +480,9 @@ public class Manifest extends Task | |||||
| /** | /** | ||||
| * Construct an empty attribute | * Construct an empty attribute | ||||
| */ | */ | ||||
| public Attribute() { } | |||||
| public Attribute() | |||||
| { | |||||
| } | |||||
| /** | /** | ||||
| * Construct an attribute by parsing a line from the Manifest | * Construct an attribute by parsing a line from the Manifest | ||||
| @@ -564,7 +569,7 @@ public class Manifest extends Task | |||||
| return false; | return false; | ||||
| } | } | ||||
| Attribute rhsAttribute = ( Attribute )rhs; | |||||
| Attribute rhsAttribute = (Attribute)rhs; | |||||
| return ( name != null && rhsAttribute.name != null && | return ( name != null && rhsAttribute.name != null && | ||||
| name.toLowerCase().equals( rhsAttribute.name.toLowerCase() ) && | name.toLowerCase().equals( rhsAttribute.name.toLowerCase() ) && | ||||
| value != null && value.equals( rhsAttribute.value ) ); | value != null && value.equals( rhsAttribute.value ) ); | ||||
| @@ -584,7 +589,7 @@ public class Manifest extends Task | |||||
| if( index == -1 ) | if( index == -1 ) | ||||
| { | { | ||||
| throw new ManifestException( "Manifest line \"" + line + "\" is not valid as it does not " + | 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 ); | name = line.substring( 0, index ); | ||||
| value = line.substring( index + 2 ); | value = line.substring( index + 2 ); | ||||
| @@ -681,14 +686,14 @@ public class Manifest extends Task | |||||
| } | } | ||||
| if( attribute instanceof Attribute ) | if( attribute instanceof Attribute ) | ||||
| { | { | ||||
| return ( ( Attribute )attribute ).getValue(); | |||||
| return ( (Attribute)attribute ).getValue(); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| String value = ""; | 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() + " "; | value += classpathAttribute.getValue() + " "; | ||||
| } | } | ||||
| return value.trim(); | return value.trim(); | ||||
| @@ -724,20 +729,20 @@ public class Manifest extends Task | |||||
| { | { | ||||
| if( attribute.getName() == null || attribute.getValue() == null ) | 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 ) ) | if( attribute.getName().equalsIgnoreCase( ATTRIBUTE_NAME ) ) | ||||
| { | { | ||||
| warnings.addElement( "\"" + ATTRIBUTE_NAME + "\" attributes should not occur in the " + | 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(); | return attribute.getValue(); | ||||
| } | } | ||||
| if( attribute.getName().toLowerCase().startsWith( ATTRIBUTE_FROM.toLowerCase() ) ) | if( attribute.getName().toLowerCase().startsWith( ATTRIBUTE_FROM.toLowerCase() ) ) | ||||
| { | { | ||||
| warnings.addElement( "Manifest attributes should not start with \"" + | warnings.addElement( "Manifest attributes should not start with \"" + | ||||
| ATTRIBUTE_FROM + "\" in \"" + attribute.getName() + ": " + attribute.getValue() + "\"" ); | |||||
| ATTRIBUTE_FROM + "\" in \"" + attribute.getName() + ": " + attribute.getValue() + "\"" ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -745,7 +750,7 @@ public class Manifest extends Task | |||||
| String attributeName = attribute.getName().toLowerCase(); | String attributeName = attribute.getName().toLowerCase(); | ||||
| if( attributeName.equals( ATTRIBUTE_CLASSPATH ) ) | if( attributeName.equals( ATTRIBUTE_CLASSPATH ) ) | ||||
| { | { | ||||
| Vector classpathAttrs = ( Vector )attributes.get( attributeName ); | |||||
| Vector classpathAttrs = (Vector)attributes.get( attributeName ); | |||||
| if( classpathAttrs == null ) | if( classpathAttrs == null ) | ||||
| { | { | ||||
| classpathAttrs = new Vector(); | classpathAttrs = new Vector(); | ||||
| @@ -756,7 +761,7 @@ public class Manifest extends Task | |||||
| else if( attributes.containsKey( attributeName ) ) | else if( attributes.containsKey( attributeName ) ) | ||||
| { | { | ||||
| throw new ManifestException( "The attribute \"" + attribute.getName() + "\" may not " + | 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 | else | ||||
| { | { | ||||
| @@ -772,8 +777,8 @@ public class Manifest extends Task | |||||
| String check = addAttributeAndCheck( attribute ); | String check = addAttributeAndCheck( attribute ); | ||||
| if( check != null ) | 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; | return false; | ||||
| } | } | ||||
| Section rhsSection = ( Section )rhs; | |||||
| Section rhsSection = (Section)rhs; | |||||
| if( attributes.size() != rhsSection.attributes.size() ) | if( attributes.size() != rhsSection.attributes.size() ) | ||||
| { | { | ||||
| return false; | 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 ) ) | if( !attribute.equals( rshAttribute ) ) | ||||
| { | { | ||||
| return false; | return false; | ||||
| @@ -818,16 +823,16 @@ public class Manifest extends Task | |||||
| throw new ManifestException( "Unable to merge sections with different names" ); | 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 ) && | if( attributeName.equals( ATTRIBUTE_CLASSPATH ) && | ||||
| attributes.containsKey( attributeName ) ) | attributes.containsKey( attributeName ) ) | ||||
| { | { | ||||
| // classpath entries are vetors which are merged | // 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() ); | ourClasspathAttrs.addElement( e2.nextElement() ); | ||||
| } | } | ||||
| @@ -840,7 +845,7 @@ public class Manifest extends Task | |||||
| } | } | ||||
| // add in the warnings | // add in the warnings | ||||
| for( Enumeration e = section.warnings.elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = section.warnings.elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| warnings.addElement( e.nextElement() ); | warnings.addElement( e.nextElement() ); | ||||
| } | } | ||||
| @@ -924,20 +929,20 @@ public class Manifest extends Task | |||||
| Attribute nameAttr = new Attribute( ATTRIBUTE_NAME, name ); | Attribute nameAttr = new Attribute( ATTRIBUTE_NAME, name ); | ||||
| nameAttr.write( writer ); | nameAttr.write( writer ); | ||||
| } | } | ||||
| for( Enumeration e = attributes.elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = attributes.elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| Object object = e.nextElement(); | Object object = e.nextElement(); | ||||
| if( object instanceof Attribute ) | if( object instanceof Attribute ) | ||||
| { | { | ||||
| Attribute attribute = ( Attribute )object; | |||||
| Attribute attribute = (Attribute)object; | |||||
| attribute.write( writer ); | attribute.write( writer ); | ||||
| } | } | ||||
| else | 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 ); | attribute.write( writer ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -7,8 +7,6 @@ | |||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| /** | /** | ||||
| * Exception thrown indicating problems in a JAR Manifest | * Exception thrown indicating problems in a JAR Manifest | ||||
| * | * | ||||
| @@ -6,11 +6,10 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.StringTokenizer; | |||||
| import java.util.Vector; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.PatternSet; | import org.apache.tools.ant.types.PatternSet; | ||||
| @@ -145,6 +144,7 @@ public abstract class MatchingTask extends Task | |||||
| * @return The DirectoryScanner value | * @return The DirectoryScanner value | ||||
| */ | */ | ||||
| protected DirectoryScanner getDirectoryScanner( File baseDir ) | protected DirectoryScanner getDirectoryScanner( File baseDir ) | ||||
| throws TaskException | |||||
| { | { | ||||
| fileset.setDir( baseDir ); | fileset.setDir( baseDir ); | ||||
| fileset.setDefaultexcludes( useDefaultExcludes ); | fileset.setDefaultexcludes( useDefaultExcludes ); | ||||
| @@ -6,11 +6,11 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| /** | /** | ||||
| * Creates a given directory. | * Creates a given directory. | ||||
| * | * | ||||
| @@ -28,16 +28,16 @@ public class Mkdir extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( dir == null ) | if( dir == null ) | ||||
| { | { | ||||
| throw new BuildException( "dir attribute is required" ); | |||||
| throw new TaskException( "dir attribute is required" ); | |||||
| } | } | ||||
| if( dir.isFile() ) | 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() ) | if( !dir.exists() ) | ||||
| @@ -47,7 +47,7 @@ public class Mkdir extends Task | |||||
| { | { | ||||
| String msg = "Directory " + dir.getAbsolutePath() + " creation was not " + | String msg = "Directory " + dir.getAbsolutePath() + " creation was not " + | ||||
| "successful for an unknown reason"; | "successful for an unknown reason"; | ||||
| throw new BuildException( msg ); | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| log( "Created dir: " + dir.getAbsolutePath() ); | log( "Created dir: " + dir.getAbsolutePath() ); | ||||
| } | } | ||||
| @@ -6,10 +6,11 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.FilterSet; | import org.apache.tools.ant.types.FilterSet; | ||||
| @@ -53,7 +54,7 @@ public class Move extends Copy | |||||
| for( int i = 0; i < list.length; i++ ) | for( int i = 0; i < list.length; i++ ) | ||||
| { | { | ||||
| String s = list[i]; | |||||
| String s = list[ i ]; | |||||
| File f = new File( d, s ); | File f = new File( d, s ); | ||||
| if( f.isDirectory() ) | if( f.isDirectory() ) | ||||
| { | { | ||||
| @@ -61,19 +62,19 @@ public class Move extends Copy | |||||
| } | } | ||||
| else | 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 ); | log( "Deleting directory " + d.getAbsolutePath(), verbosity ); | ||||
| if( !d.delete() ) | 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() | protected void doFileOperations() | ||||
| { | { | ||||
| @@ -83,33 +84,33 @@ public class Move extends Copy | |||||
| Enumeration e = completeDirMap.keys(); | Enumeration e = completeDirMap.keys(); | ||||
| while( e.hasMoreElements() ) | 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 | try | ||||
| { | { | ||||
| log( "Attempting to rename dir: " + fromDir + | log( "Attempting to rename dir: " + fromDir + | ||||
| " to " + toDir, verbosity ); | |||||
| " to " + toDir, verbosity ); | |||||
| renameFile( fromDir, toDir, filtering, forceOverwrite ); | renameFile( fromDir, toDir, filtering, forceOverwrite ); | ||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "Failed to rename dir " + fromDir | 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 ) | if( fileCopyMap.size() > 0 ) | ||||
| {// files to move | {// files to move | ||||
| log( "Moving " + fileCopyMap.size() + " files to " + | log( "Moving " + fileCopyMap.size() + " files to " + | ||||
| destDir.getAbsolutePath() ); | |||||
| destDir.getAbsolutePath() ); | |||||
| Enumeration e = fileCopyMap.keys(); | Enumeration e = fileCopyMap.keys(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| String fromFile = ( String )e.nextElement(); | |||||
| String toFile = ( String )fileCopyMap.get( fromFile ); | |||||
| String fromFile = (String)e.nextElement(); | |||||
| String toFile = (String)fileCopyMap.get( fromFile ); | |||||
| if( fromFile.equals( toFile ) ) | if( fromFile.equals( toFile ) ) | ||||
| { | { | ||||
| @@ -127,15 +128,15 @@ public class Move extends Copy | |||||
| try | try | ||||
| { | { | ||||
| log( "Attempting to rename: " + fromFile + | log( "Attempting to rename: " + fromFile + | ||||
| " to " + toFile, verbosity ); | |||||
| " to " + toFile, verbosity ); | |||||
| moved = renameFile( f, d, filtering, forceOverwrite ); | moved = renameFile( f, d, filtering, forceOverwrite ); | ||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "Failed to rename " + fromFile | 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 ) | if( !moved ) | ||||
| @@ -149,26 +150,26 @@ public class Move extends Copy | |||||
| { | { | ||||
| executionFilters.addFilterSet( project.getGlobalFilterSet() ); | 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, | getFileUtils().copyFile( f, d, executionFilters, | ||||
| forceOverwrite ); | |||||
| forceOverwrite ); | |||||
| f = new File( fromFile ); | f = new File( fromFile ); | ||||
| if( !f.delete() ) | if( !f.delete() ) | ||||
| { | { | ||||
| throw new BuildException( "Unable to delete file " | |||||
| + f.getAbsolutePath() ); | |||||
| throw new TaskException( "Unable to delete file " | |||||
| + f.getAbsolutePath() ); | |||||
| } | } | ||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "Failed to copy " + fromFile + " to " | 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; | int count = 0; | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| File d = new File( ( String )e.nextElement() ); | |||||
| File d = new File( (String)e.nextElement() ); | |||||
| if( !d.exists() ) | if( !d.exists() ) | ||||
| { | { | ||||
| if( !d.mkdirs() ) | if( !d.mkdirs() ) | ||||
| @@ -206,7 +207,7 @@ public class Move extends Copy | |||||
| Enumeration e = filesets.elements(); | Enumeration e = filesets.elements(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )e.nextElement(); | |||||
| FileSet fs = (FileSet)e.nextElement(); | |||||
| File dir = fs.getDir( project ); | File dir = fs.getDir( project ); | ||||
| if( okToDelete( dir ) ) | if( okToDelete( dir ) ) | ||||
| @@ -231,7 +232,7 @@ public class Move extends Copy | |||||
| for( int i = 0; i < list.length; i++ ) | for( int i = 0; i < list.length; i++ ) | ||||
| { | { | ||||
| String s = list[i]; | |||||
| String s = list[ i ]; | |||||
| File f = new File( d, s ); | File f = new File( d, s ); | ||||
| if( f.isDirectory() ) | if( f.isDirectory() ) | ||||
| { | { | ||||
| @@ -260,12 +261,12 @@ public class Move extends Copy | |||||
| * @param filtering Description of Parameter | * @param filtering Description of Parameter | ||||
| * @param overwrite Description of Parameter | * @param overwrite Description of Parameter | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| * @throws IOException | * @throws IOException | ||||
| */ | */ | ||||
| protected boolean renameFile( File sourceFile, File destFile, | protected boolean renameFile( File sourceFile, File destFile, | ||||
| boolean filtering, boolean overwrite ) | boolean filtering, boolean overwrite ) | ||||
| throws IOException, BuildException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| boolean renamed = true; | boolean renamed = true; | ||||
| @@ -287,8 +288,8 @@ public class Move extends Copy | |||||
| { | { | ||||
| if( !destFile.delete() ) | 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 ); | renamed = sourceFile.renameTo( destFile ); | ||||
| @@ -6,12 +6,13 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| /** | /** | ||||
| @@ -37,7 +38,7 @@ public abstract class Pack extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| validate(); | validate(); | ||||
| log( "Building: " + zipFile.getAbsolutePath() ); | log( "Building: " + zipFile.getAbsolutePath() ); | ||||
| @@ -64,30 +65,30 @@ public abstract class Pack extends Task | |||||
| { | { | ||||
| if( zipFile == null ) | if( zipFile == null ) | ||||
| { | { | ||||
| throw new BuildException( "zipfile attribute is required" ); | |||||
| throw new TaskException( "zipfile attribute is required" ); | |||||
| } | } | ||||
| if( source == null ) | if( source == null ) | ||||
| { | { | ||||
| throw new BuildException( "src attribute is required" ); | |||||
| throw new TaskException( "src attribute is required" ); | |||||
| } | } | ||||
| if( source.isDirectory() ) | 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 ) | private void zipFile( InputStream in, OutputStream zOut ) | ||||
| throws IOException | throws IOException | ||||
| { | { | ||||
| byte[] buffer = new byte[8 * 1024]; | |||||
| byte[] buffer = new byte[ 8 * 1024 ]; | |||||
| int count = 0; | int count = 0; | ||||
| do | do | ||||
| { | { | ||||
| zOut.write( buffer, 0, count ); | zOut.write( buffer, 0, count ); | ||||
| count = in.read( buffer, 0, buffer.length ); | count = in.read( buffer, 0, buffer.length ); | ||||
| }while ( count != -1 ); | |||||
| } while( count != -1 ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,14 +6,14 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | 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.Location; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.TaskContainer; | import org.apache.tools.ant.TaskContainer; | ||||
| /** | /** | ||||
| * Implements a multi threaded task execution. <p> | * 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> | * @author <a href="mailto:conor@apache.org">Conor MacNeill </a> | ||||
| */ | */ | ||||
| public class Parallel extends Task | public class Parallel extends Task | ||||
| implements TaskContainer | |||||
| implements TaskContainer | |||||
| { | { | ||||
| /** | /** | ||||
| @@ -31,17 +31,16 @@ public class Parallel extends Task | |||||
| */ | */ | ||||
| private Vector nestedTasks = new Vector(); | private Vector nestedTasks = new Vector(); | ||||
| /** | /** | ||||
| * Add a nested task to execute parallel (asynchron). <p> | * Add a nested task to execute parallel (asynchron). <p> | ||||
| * | * | ||||
| * | * | ||||
| * | * | ||||
| * @param nestedTask Nested task to be executed in parallel | * @param nestedTask Nested task to be executed in parallel | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void addTask( Task nestedTask ) | public void addTask( Task nestedTask ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| nestedTasks.addElement( nestedTask ); | nestedTasks.addElement( nestedTask ); | ||||
| } | } | ||||
| @@ -50,23 +49,23 @@ public class Parallel extends Task | |||||
| * Block execution until the specified time or for a specified amount of | * Block execution until the specified time or for a specified amount of | ||||
| * milliseconds and if defined, execute the wait status. | * milliseconds and if defined, execute the wait status. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| TaskThread[] threads = new TaskThread[nestedTasks.size()]; | |||||
| TaskThread[] threads = new TaskThread[ nestedTasks.size() ]; | |||||
| int threadNumber = 0; | int threadNumber = 0; | ||||
| for( Enumeration e = nestedTasks.elements(); e.hasMoreElements(); threadNumber++ ) | 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 | // now start all threads | ||||
| for( int i = 0; i < threads.length; ++i ) | for( int i = 0; i < threads.length; ++i ) | ||||
| { | { | ||||
| threads[i].start(); | |||||
| threads[ i ].start(); | |||||
| } | } | ||||
| // now join to all the threads | // now join to all the threads | ||||
| @@ -74,7 +73,7 @@ public class Parallel extends Task | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| threads[i].join(); | |||||
| threads[ i ].join(); | |||||
| } | } | ||||
| catch( InterruptedException ie ) | catch( InterruptedException ie ) | ||||
| { | { | ||||
| @@ -91,7 +90,7 @@ public class Parallel extends Task | |||||
| ; | ; | ||||
| for( int i = 0; i < threads.length; ++i ) | for( int i = 0; i < threads.length; ++i ) | ||||
| { | { | ||||
| Throwable t = threads[i].getException(); | |||||
| Throwable t = threads[ i ].getException(); | |||||
| if( t != null ) | if( t != null ) | ||||
| { | { | ||||
| numExceptions++; | numExceptions++; | ||||
| @@ -99,10 +98,10 @@ public class Parallel extends Task | |||||
| { | { | ||||
| firstException = t; | firstException = t; | ||||
| } | } | ||||
| if( t instanceof BuildException && | |||||
| if( t instanceof TaskException && | |||||
| firstLocation == Location.UNKNOWN_LOCATION ) | firstLocation == Location.UNKNOWN_LOCATION ) | ||||
| { | { | ||||
| firstLocation = ( ( BuildException )t ).getLocation(); | |||||
| firstLocation = ( (TaskException)t ).getLocation(); | |||||
| } | } | ||||
| exceptionMessage.append( lSep ); | exceptionMessage.append( lSep ); | ||||
| exceptionMessage.append( t.getMessage() ); | exceptionMessage.append( t.getMessage() ); | ||||
| @@ -111,18 +110,18 @@ public class Parallel extends Task | |||||
| if( numExceptions == 1 ) | if( numExceptions == 1 ) | ||||
| { | { | ||||
| if( firstException instanceof BuildException ) | |||||
| if( firstException instanceof TaskException ) | |||||
| { | { | ||||
| throw ( BuildException )firstException; | |||||
| throw (TaskException)firstException; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( "Error", firstException ); | |||||
| throw new TaskException( "Error", firstException ); | |||||
| } | } | ||||
| } | } | ||||
| else if( numExceptions > 1 ) | else if( numExceptions > 1 ) | ||||
| { | { | ||||
| throw new BuildException( exceptionMessage.toString() ); | |||||
| throw new TaskException( exceptionMessage.toString() ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,9 +6,10 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -70,7 +71,7 @@ public class Patch extends Task | |||||
| { | { | ||||
| if( !file.exists() ) | 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().setValue( "-i" ); | ||||
| cmd.createArgument().setFile( file ); | cmd.createArgument().setFile( file ); | ||||
| @@ -110,27 +111,27 @@ public class Patch extends Task | |||||
| * patch's <i>-p</i> option. | * patch's <i>-p</i> option. | ||||
| * | * | ||||
| * @param num The new Strip value | * @param num The new Strip value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setStrip( int num ) | public void setStrip( int num ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( num < 0 ) | if( num < 0 ) | ||||
| { | { | ||||
| throw new BuildException( "strip has to be >= 0" ); | |||||
| throw new TaskException( "strip has to be >= 0" ); | |||||
| } | } | ||||
| cmd.createArgument().setValue( "-p" + num ); | cmd.createArgument().setValue( "-p" + num ); | ||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( !havePatchfile ) | 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" ); | toExecute.setExecutable( "patch" ); | ||||
| if( originalFile != null ) | if( originalFile != null ) | ||||
| @@ -139,8 +140,8 @@ public class Patch extends Task | |||||
| } | } | ||||
| Execute exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO, | Execute exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO, | ||||
| Project.MSG_WARN ), | |||||
| null ); | |||||
| Project.MSG_WARN ), | |||||
| null ); | |||||
| exe.setCommandline( toExecute.getCommandline() ); | exe.setCommandline( toExecute.getCommandline() ); | ||||
| try | try | ||||
| { | { | ||||
| @@ -148,7 +149,7 @@ public class Patch extends Task | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,9 +6,10 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Vector; | 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.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| @@ -96,7 +97,7 @@ public class PathConvert extends Task | |||||
| if( !targetOS.equals( "windows" ) && !target.equals( "unix" ) && | if( !targetOS.equals( "windows" ) && !target.equals( "unix" ) && | ||||
| !targetOS.equals( "netware" ) ) | !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 | // Currently, we deal with only two path formats: Unix and Windows | ||||
| @@ -153,10 +154,10 @@ public class PathConvert extends Task | |||||
| /** | /** | ||||
| * Do the execution. | * Do the execution. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| // If we are a reference, the create a Path from the reference | // 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 ) | else if( obj instanceof FileSet ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )obj; | |||||
| FileSet fs = (FileSet)obj; | |||||
| path.addFileset( fs ); | path.addFileset( fs ); | ||||
| } | } | ||||
| else | 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++ ) | for( int i = 0; i < elems.length; i++ ) | ||||
| { | { | ||||
| String elem = elems[i]; | |||||
| String elem = elems[ i ]; | |||||
| elem = mapElement( elem );// Apply the path prefix map | elem = mapElement( elem );// Apply the path prefix map | ||||
| @@ -249,7 +250,7 @@ public class PathConvert extends Task | |||||
| for( int i = 0; i < size; i++ ) | for( int i = 0; i < size; i++ ) | ||||
| { | { | ||||
| MapEntry entry = ( MapEntry )prefixMap.elementAt( i ); | |||||
| MapEntry entry = (MapEntry)prefixMap.elementAt( i ); | |||||
| String newElem = entry.apply( elem ); | String newElem = entry.apply( elem ); | ||||
| // Note I'm using "!=" to see if we got a new object back from | // 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 | * @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. | * 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() | private void validateSetup() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( path == null ) | 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 ) | 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 | // Must either have a target OS or both a dirSep and pathSep | ||||
| if( targetOS == null && pathSep == null && dirSep == null ) | 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 | // Determine the separator strings. The dirsep and pathsep attributes | ||||
| // override the targetOS settings. | // override the targetOS settings. | ||||
| @@ -367,7 +368,7 @@ public class PathConvert extends Task | |||||
| { | { | ||||
| if( from == null || to == null ) | 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 | // If we're on windows, then do the comparison ignoring case | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -16,7 +17,7 @@ import java.util.Vector; | |||||
| * @author <a href="mailto:mnewcomb@tacintel.com">Michael Newcomb</a> | * @author <a href="mailto:mnewcomb@tacintel.com">Michael Newcomb</a> | ||||
| */ | */ | ||||
| class ProcessDestroyer | class ProcessDestroyer | ||||
| extends Thread | |||||
| extends Thread | |||||
| { | { | ||||
| private Vector processes = new Vector(); | private Vector processes = new Vector(); | ||||
| @@ -83,7 +84,7 @@ class ProcessDestroyer | |||||
| Enumeration e = processes.elements(); | Enumeration e = processes.elements(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| ( ( Process )e.nextElement() ).destroy(); | |||||
| ( (Process)e.nextElement() ).destroy(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -16,7 +16,6 @@ import java.util.Properties; | |||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.ProjectHelper; | import org.apache.tools.ant.ProjectHelper; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| @@ -41,28 +42,26 @@ public class PumpStreamHandler implements ExecuteStreamHandler | |||||
| this( System.out, System.err ); | this( System.out, System.err ); | ||||
| } | } | ||||
| public void setProcessErrorStream( InputStream is ) | public void setProcessErrorStream( InputStream is ) | ||||
| { | { | ||||
| createProcessErrorPump( is, err ); | createProcessErrorPump( is, err ); | ||||
| } | } | ||||
| public void setProcessInputStream( OutputStream os ) { } | |||||
| public void setProcessInputStream( OutputStream os ) | |||||
| { | |||||
| } | |||||
| public void setProcessOutputStream( InputStream is ) | public void setProcessOutputStream( InputStream is ) | ||||
| { | { | ||||
| createProcessOutputPump( is, out ); | createProcessOutputPump( is, out ); | ||||
| } | } | ||||
| public void start() | public void start() | ||||
| { | { | ||||
| inputThread.start(); | inputThread.start(); | ||||
| errorThread.start(); | errorThread.start(); | ||||
| } | } | ||||
| public void stop() | public void stop() | ||||
| { | { | ||||
| try | try | ||||
| @@ -70,25 +69,29 @@ public class PumpStreamHandler implements ExecuteStreamHandler | |||||
| inputThread.join(); | inputThread.join(); | ||||
| } | } | ||||
| catch( InterruptedException e ) | catch( InterruptedException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| try | try | ||||
| { | { | ||||
| errorThread.join(); | errorThread.join(); | ||||
| } | } | ||||
| catch( InterruptedException e ) | catch( InterruptedException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| try | try | ||||
| { | { | ||||
| err.flush(); | err.flush(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| try | try | ||||
| { | { | ||||
| out.flush(); | out.flush(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| protected OutputStream getErr() | protected OutputStream getErr() | ||||
| @@ -111,7 +114,6 @@ public class PumpStreamHandler implements ExecuteStreamHandler | |||||
| inputThread = createPump( is, os ); | inputThread = createPump( is, os ); | ||||
| } | } | ||||
| /** | /** | ||||
| * Creates a stream pumper to copy the given input stream to the given | * Creates a stream pumper to copy the given input stream to the given | ||||
| * output stream. | * output stream. | ||||
| @@ -6,11 +6,12 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.util.Hashtable; | 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.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| @@ -133,16 +134,16 @@ public class Recorder extends Task | |||||
| /** | /** | ||||
| * The main execution. | * The main execution. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( filename == null ) | if( filename == null ) | ||||
| throw new BuildException( "No filename specified" ); | |||||
| throw new TaskException( "No filename specified" ); | |||||
| getProject().log( "setting a recorder for name " + filename, | getProject().log( "setting a recorder for name " + filename, | ||||
| Project.MSG_DEBUG ); | |||||
| Project.MSG_DEBUG ); | |||||
| // get the recorder entry | // get the recorder entry | ||||
| RecorderEntry recorder = getRecorder( filename, getProject() ); | RecorderEntry recorder = getRecorder( filename, getProject() ); | ||||
| @@ -158,10 +159,10 @@ public class Recorder extends Task | |||||
| * @param name Description of Parameter | * @param name Description of Parameter | ||||
| * @param proj Description of Parameter | * @param proj Description of Parameter | ||||
| * @return The Recorder value | * @return The Recorder value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected RecorderEntry getRecorder( String name, Project proj ) | protected RecorderEntry getRecorder( String name, Project proj ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Object o = recorderEntries.get( name ); | Object o = recorderEntries.get( name ); | ||||
| RecorderEntry entry; | RecorderEntry entry; | ||||
| @@ -187,15 +188,15 @@ public class Recorder extends Task | |||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| throw new BuildException( "Problems creating a recorder entry", | |||||
| ioe ); | |||||
| throw new TaskException( "Problems creating a recorder entry", | |||||
| ioe ); | |||||
| } | } | ||||
| proj.addBuildListener( entry ); | proj.addBuildListener( entry ); | ||||
| recorderEntries.put( name, entry ); | recorderEntries.put( name, entry ); | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| entry = ( RecorderEntry )o; | |||||
| entry = (RecorderEntry)o; | |||||
| } | } | ||||
| return entry; | return entry; | ||||
| } | } | ||||
| @@ -228,7 +229,7 @@ public class Recorder extends Task | |||||
| public static class VerbosityLevelChoices extends EnumeratedAttribute | public static class VerbosityLevelChoices extends EnumeratedAttribute | ||||
| { | { | ||||
| private final static String[] values = {"error", "warn", "info", | private final static String[] values = {"error", "warn", "info", | ||||
| "verbose", "debug"}; | |||||
| "verbose", "debug"}; | |||||
| public String[] getValues() | public String[] getValues() | ||||
| { | { | ||||
| @@ -6,13 +6,13 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import org.apache.tools.ant.BuildEvent; | import org.apache.tools.ant.BuildEvent; | ||||
| import org.apache.tools.ant.BuildLogger; | import org.apache.tools.ant.BuildLogger; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.util.StringUtils; | import org.apache.tools.ant.util.StringUtils; | ||||
| /** | /** | ||||
| * This is a class that represents a recorder. This is the listener to the build | * This is a class that represents a recorder. This is the listener to the build | ||||
| * process. | * process. | ||||
| @@ -66,14 +66,14 @@ public class RecorderEntry implements BuildLogger | |||||
| if( minutes > 0 ) | if( minutes > 0 ) | ||||
| { | { | ||||
| return Long.toString( minutes ) + " minute" | 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 | else | ||||
| { | { | ||||
| return Long.toString( seconds ) + " second" | return Long.toString( seconds ) + " second" | ||||
| + ( seconds % 60 == 1 ? "" : "s" ); | |||||
| + ( seconds % 60 == 1 ? "" : "s" ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -21,7 +22,7 @@ import java.io.Reader; | |||||
| import java.io.Writer; | import java.io.Writer; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import java.util.Vector; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -59,7 +60,6 @@ public class Replace extends MatchingTask | |||||
| private int fileCount; | private int fileCount; | ||||
| private int replaceCount; | private int replaceCount; | ||||
| /** | /** | ||||
| * Set the source files path when using matching tasks. | * Set the source files path when using matching tasks. | ||||
| * | * | ||||
| @@ -80,7 +80,6 @@ public class Replace extends MatchingTask | |||||
| this.encoding = encoding; | this.encoding = encoding; | ||||
| } | } | ||||
| /** | /** | ||||
| * Set the source file. | * Set the source file. | ||||
| * | * | ||||
| @@ -133,7 +132,7 @@ public class Replace extends MatchingTask | |||||
| } | } | ||||
| public Properties getProperties( File propertyFile ) | public Properties getProperties( File propertyFile ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Properties properties = new Properties(); | Properties properties = new Properties(); | ||||
| @@ -144,12 +143,12 @@ public class Replace extends MatchingTask | |||||
| catch( FileNotFoundException e ) | catch( FileNotFoundException e ) | ||||
| { | { | ||||
| String message = "Property file (" + propertyFile.getPath() + ") not found."; | String message = "Property file (" + propertyFile.getPath() + ") not found."; | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| String message = "Property file (" + propertyFile.getPath() + ") cannot be loaded."; | String message = "Property file (" + propertyFile.getPath() + ") cannot be loaded."; | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| return properties; | return properties; | ||||
| @@ -194,10 +193,10 @@ public class Replace extends MatchingTask | |||||
| /** | /** | ||||
| * Do the execution. | * Do the execution. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| validateAttributes(); | validateAttributes(); | ||||
| @@ -222,7 +221,7 @@ public class Replace extends MatchingTask | |||||
| for( int i = 0; i < srcs.length; i++ ) | for( int i = 0; i < srcs.length; i++ ) | ||||
| { | { | ||||
| File file = new File( dir, srcs[i] ); | |||||
| File file = new File( dir, srcs[ i ] ); | |||||
| processFile( file ); | processFile( file ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -236,47 +235,47 @@ public class Replace extends MatchingTask | |||||
| /** | /** | ||||
| * Validate attributes provided for this task in .xml build file. | * 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 | * mandatory attribute is missing | ||||
| */ | */ | ||||
| public void validateAttributes() | public void validateAttributes() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( src == null && dir == null ) | if( src == null && dir == null ) | ||||
| { | { | ||||
| String message = "Either the file or the dir attribute " + "must be specified"; | String message = "Either the file or the dir attribute " + "must be specified"; | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| if( propertyFile != null && !propertyFile.exists() ) | if( propertyFile != null && !propertyFile.exists() ) | ||||
| { | { | ||||
| String message = "Property file " + propertyFile.getPath() + " does not exist."; | String message = "Property file " + propertyFile.getPath() + " does not exist."; | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| if( token == null && replacefilters.size() == 0 ) | if( token == null && replacefilters.size() == 0 ) | ||||
| { | { | ||||
| String message = "Either token or a nested replacefilter " | String message = "Either token or a nested replacefilter " | ||||
| + "must be specified"; | |||||
| throw new BuildException( message); | |||||
| + "must be specified"; | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| if( token != null && "".equals( token.getText() ) ) | if( token != null && "".equals( token.getText() ) ) | ||||
| { | { | ||||
| String message = "The token attribute must not be an empty string."; | String message = "The token attribute must not be an empty string."; | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Validate nested elements. | * 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 | * mandatory attribute is missing | ||||
| */ | */ | ||||
| public void validateReplacefilters() | public void validateReplacefilters() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| for( int i = 0; i < replacefilters.size(); i++ ) | for( int i = 0; i < replacefilters.size(); i++ ) | ||||
| { | { | ||||
| Replacefilter element = ( Replacefilter )replacefilters.elementAt( i ); | |||||
| Replacefilter element = (Replacefilter)replacefilters.elementAt( i ); | |||||
| element.validate(); | element.validate(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -286,27 +285,27 @@ public class Replace extends MatchingTask | |||||
| * on a temporary file which then replaces the original file. | * on a temporary file which then replaces the original file. | ||||
| * | * | ||||
| * @param src the source file | * @param src the source file | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void processFile( File src ) | private void processFile( File src ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( !src.exists() ) | 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", | File temp = fileUtils.createTempFile( "rep", ".tmp", | ||||
| fileUtils.getParentFile( src ) ); | |||||
| fileUtils.getParentFile( src ) ); | |||||
| Reader reader = null; | Reader reader = null; | ||||
| Writer writer = null; | Writer writer = null; | ||||
| try | try | ||||
| { | { | ||||
| reader = encoding == null ? new FileReader( src ) | reader = encoding == null ? new FileReader( src ) | ||||
| : new InputStreamReader( new FileInputStream( src ), encoding ); | |||||
| : new InputStreamReader( new FileInputStream( src ), encoding ); | |||||
| writer = encoding == null ? new FileWriter( temp ) | writer = encoding == null ? new FileWriter( temp ) | ||||
| : new OutputStreamWriter( new FileOutputStream( temp ), encoding ); | |||||
| : new OutputStreamWriter( new FileOutputStream( temp ), encoding ); | |||||
| BufferedReader br = new BufferedReader( reader ); | BufferedReader br = new BufferedReader( reader ); | ||||
| BufferedWriter bw = new BufferedWriter( writer ); | BufferedWriter bw = new BufferedWriter( writer ); | ||||
| @@ -316,7 +315,7 @@ public class Replace extends MatchingTask | |||||
| // when multibyte characters exist in the source file | // when multibyte characters exist in the source file | ||||
| // but then again, it might be smaller than needed on | // but then again, it might be smaller than needed on | ||||
| // platforms like Windows where length can't be trusted | // platforms like Windows where length can't be trusted | ||||
| int fileLengthInBytes = ( int )( src.length() ); | |||||
| int fileLengthInBytes = (int)( src.length() ); | |||||
| StringBuffer tmpBuf = new StringBuffer( fileLengthInBytes ); | StringBuffer tmpBuf = new StringBuffer( fileLengthInBytes ); | ||||
| int readChar = 0; | int readChar = 0; | ||||
| int totread = 0; | int totread = 0; | ||||
| @@ -327,7 +326,7 @@ public class Replace extends MatchingTask | |||||
| { | { | ||||
| break; | break; | ||||
| } | } | ||||
| tmpBuf.append( ( char )readChar ); | |||||
| tmpBuf.append( (char)readChar ); | |||||
| totread++; | totread++; | ||||
| } | } | ||||
| @@ -381,8 +380,8 @@ public class Replace extends MatchingTask | |||||
| } | } | ||||
| catch( IOException ioe ) | 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 | finally | ||||
| { | { | ||||
| @@ -393,7 +392,8 @@ public class Replace extends MatchingTask | |||||
| reader.close(); | reader.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( writer != null ) | if( writer != null ) | ||||
| { | { | ||||
| @@ -402,7 +402,8 @@ public class Replace extends MatchingTask | |||||
| writer.close(); | writer.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( temp != null ) | if( temp != null ) | ||||
| { | { | ||||
| @@ -418,7 +419,7 @@ public class Replace extends MatchingTask | |||||
| for( int i = 0; i < replacefilters.size(); i++ ) | 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 | //for each found token, replace with value | ||||
| log( "Replacing in " + filename + ": " + filter.getToken() + " --> " + filter.getReplaceValue(), Project.MSG_VERBOSE ); | log( "Replacing in " + filename + ": " + filter.getToken() + " --> " + filter.getReplaceValue(), Project.MSG_VERBOSE ); | ||||
| @@ -518,7 +519,7 @@ public class Replace extends MatchingTask | |||||
| { | { | ||||
| if( property != null ) | if( property != null ) | ||||
| { | { | ||||
| return ( String )properties.getProperty( property ); | |||||
| return (String)properties.getProperty( property ); | |||||
| } | } | ||||
| else if( value != null ) | else if( value != null ) | ||||
| { | { | ||||
| @@ -546,26 +547,26 @@ public class Replace extends MatchingTask | |||||
| } | } | ||||
| public void validate() | public void validate() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| //Validate mandatory attributes | //Validate mandatory attributes | ||||
| if( token == null ) | if( token == null ) | ||||
| { | { | ||||
| String message = "token is a mandatory attribute " + "of replacefilter."; | String message = "token is a mandatory attribute " + "of replacefilter."; | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| if( "".equals( token ) ) | if( "".equals( token ) ) | ||||
| { | { | ||||
| String message = "The token attribute must not be an empty string."; | String message = "The token attribute must not be an empty string."; | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| //value and property are mutually exclusive attributes | //value and property are mutually exclusive attributes | ||||
| if( ( value != null ) && ( property != null ) ) | if( ( value != null ) && ( property != null ) ) | ||||
| { | { | ||||
| String message = "Either value or property " + "can be specified, but a replacefilter " + "element cannot have both."; | 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 ) ) | if( ( property != null ) ) | ||||
| @@ -574,7 +575,7 @@ public class Replace extends MatchingTask | |||||
| if( propertyFile == null ) | if( propertyFile == null ) | ||||
| { | { | ||||
| String message = "The replacefilter's property attribute " + "can only be used with the replacetask's " + "propertyFile attribute."; | 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 | //Make sure property exists in property file | ||||
| @@ -582,7 +583,7 @@ public class Replace extends MatchingTask | |||||
| properties.getProperty( property ) == null ) | properties.getProperty( property ) == null ) | ||||
| { | { | ||||
| String message = "property \"" + property + "\" was not found in " + propertyFile.getPath(); | String message = "property \"" + property + "\" was not found in " + propertyFile.getPath(); | ||||
| throw new BuildException( message ); | |||||
| throw new TaskException( message ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -681,7 +681,7 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| String msg = "Failed to copy " + oldFile + " to " + | String msg = "Failed to copy " + oldFile + " to " + | ||||
| newFile + " due to " + ioe.getMessage(); | newFile + " due to " + ioe.getMessage(); | ||||
| newFile + " due to " + ioe.getMessage(); | |||||
| newFile + " due to " + ioe.getMessage(); | |||||
| throw new TaskException( msg, ioe ); | throw new TaskException( msg, ioe ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -30,6 +30,7 @@ import java.util.Enumeration; | |||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | 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.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * Reads in a text file containing SQL statements seperated with semicolons and | * Reads in a text file containing SQL statements seperated with semicolons and | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| @@ -14,7 +15,7 @@ import java.io.PrintStream; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.mail.MailMessage; | import org.apache.tools.mail.MailMessage; | ||||
| @@ -173,11 +174,12 @@ public class SendEmail extends Task | |||||
| private String subject; | private String subject; | ||||
| private String toList; | private String toList; | ||||
| /** | /** | ||||
| * Creates new SendEmail | * Creates new SendEmail | ||||
| */ | */ | ||||
| public SendEmail() { } | |||||
| public SendEmail() | |||||
| { | |||||
| } | |||||
| /** | /** | ||||
| * Sets the FailOnError attribute of the MimeMail object | * 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. | * @param filenames Filenames to include as the message body of this email. | ||||
| */ | */ | ||||
| public void setFiles( String filenames ) | public void setFiles( String filenames ) | ||||
| throws TaskException | |||||
| { | { | ||||
| StringTokenizer t = new StringTokenizer( filenames, ", " ); | StringTokenizer t = new StringTokenizer( filenames, ", " ); | ||||
| @@ -279,10 +282,10 @@ public class SendEmail extends Task | |||||
| /** | /** | ||||
| * Executes this build 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() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -295,7 +298,7 @@ public class SendEmail extends Task | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( "Attribute \"from\" is required." ); | |||||
| throw new TaskException( "Attribute \"from\" is required." ); | |||||
| } | } | ||||
| if( toList != null ) | if( toList != null ) | ||||
| @@ -309,7 +312,7 @@ public class SendEmail extends Task | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( "Attribute \"toList\" is required." ); | |||||
| throw new TaskException( "Attribute \"toList\" is required." ); | |||||
| } | } | ||||
| if( subject != null ) | if( subject != null ) | ||||
| @@ -321,15 +324,15 @@ public class SendEmail extends Task | |||||
| { | { | ||||
| PrintStream out = mailMessage.getPrintStream(); | 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() ) | if( file.exists() && file.canRead() ) | ||||
| { | { | ||||
| int bufsize = 1024; | int bufsize = 1024; | ||||
| int length; | int length; | ||||
| byte[] buf = new byte[bufsize]; | |||||
| byte[] buf = new byte[ bufsize ]; | |||||
| if( includefilenames ) | if( includefilenames ) | ||||
| { | { | ||||
| String filename = file.getName(); | String filename = file.getName(); | ||||
| @@ -364,15 +367,16 @@ public class SendEmail extends Task | |||||
| in.close(); | in.close(); | ||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else | 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 | else | ||||
| { | { | ||||
| throw new BuildException( "Attribute \"file\" or \"message\" is required." ); | |||||
| throw new TaskException( "Attribute \"file\" or \"message\" is required." ); | |||||
| } | } | ||||
| log( "Sending email" ); | log( "Sending email" ); | ||||
| @@ -394,7 +398,7 @@ public class SendEmail extends Task | |||||
| String err = "IO error sending mail " + ioe.toString(); | String err = "IO error sending mail " + ioe.toString(); | ||||
| if( failOnError ) | if( failOnError ) | ||||
| { | { | ||||
| throw new BuildException( err, ioe ); | |||||
| throw new TaskException( err, ioe ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -6,13 +6,13 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | 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.Task; | ||||
| import org.apache.tools.ant.TaskContainer; | import org.apache.tools.ant.TaskContainer; | ||||
| /** | /** | ||||
| * Implements a single threaded task execution. <p> | * 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> | * @author Thomas Christen <a href="mailto:chr@active.ch">chr@active.ch</a> | ||||
| */ | */ | ||||
| public class Sequential extends Task | public class Sequential extends Task | ||||
| implements TaskContainer | |||||
| implements TaskContainer | |||||
| { | { | ||||
| /** | /** | ||||
| @@ -46,14 +46,14 @@ public class Sequential extends Task | |||||
| /** | /** | ||||
| * Execute all nestedTasks. | * Execute all nestedTasks. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | 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(); | nestedTask.perform(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,13 +6,14 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import java.util.zip.ZipEntry; | import java.util.zip.ZipEntry; | ||||
| import java.util.zip.ZipFile; | import java.util.zip.ZipFile; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -133,13 +134,12 @@ public class SignJar extends Task | |||||
| filesets.addElement( set ); | filesets.addElement( set ); | ||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( null == jar && null == filesets ) | 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 ) | if( null != jar ) | ||||
| { | { | ||||
| @@ -153,12 +153,12 @@ public class SignJar extends Task | |||||
| // deal with the filesets | // deal with the filesets | ||||
| for( int i = 0; i < filesets.size(); i++ ) | for( int i = 0; i < filesets.size(); i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )filesets.elementAt( i ); | |||||
| FileSet fs = (FileSet)filesets.elementAt( i ); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| String[] jarFiles = ds.getIncludedFiles(); | String[] jarFiles = ds.getIncludedFiles(); | ||||
| for( int j = 0; j < jarFiles.length; j++ ) | 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(); | Enumeration entries = jarFile.entries(); | ||||
| while( entries.hasMoreElements() ) | while( entries.hasMoreElements() ) | ||||
| { | { | ||||
| String name = ( ( ZipEntry )entries.nextElement() ).getName(); | |||||
| String name = ( (ZipEntry)entries.nextElement() ).getName(); | |||||
| if( name.startsWith( SIG_START ) && name.endsWith( SIG_END ) ) | if( name.startsWith( SIG_START ) && name.endsWith( SIG_END ) ) | ||||
| { | { | ||||
| return true; | return true; | ||||
| @@ -193,7 +193,7 @@ public class SignJar extends Task | |||||
| else | else | ||||
| { | { | ||||
| return jarFile.getEntry( SIG_START + alias.toUpperCase() + | return jarFile.getEntry( SIG_START + alias.toUpperCase() + | ||||
| SIG_END ) != null; | |||||
| SIG_END ) != null; | |||||
| } | } | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| @@ -209,7 +209,8 @@ public class SignJar extends Task | |||||
| jarFile.close(); | jarFile.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -245,21 +246,21 @@ public class SignJar extends Task | |||||
| } | } | ||||
| private void doOneJar( File jarSource, File jarTarget ) | private void doOneJar( File jarSource, File jarTarget ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( project.getJavaVersion().equals( Project.JAVA_1_1 ) ) | 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 ) | if( null == alias ) | ||||
| { | { | ||||
| throw new BuildException( "alias attribute must be set" ); | |||||
| throw new TaskException( "alias attribute must be set" ); | |||||
| } | } | ||||
| if( null == storepass ) | if( null == storepass ) | ||||
| { | { | ||||
| throw new BuildException( "storepass attribute must be set" ); | |||||
| throw new TaskException( "storepass attribute must be set" ); | |||||
| } | } | ||||
| if( isUpToDate( jarSource, jarTarget ) ) | if( isUpToDate( jarSource, jarTarget ) ) | ||||
| @@ -267,7 +268,7 @@ public class SignJar extends Task | |||||
| final StringBuffer sb = new StringBuffer(); | final StringBuffer sb = new StringBuffer(); | ||||
| final ExecTask cmd = ( ExecTask )project.createTask( "exec" ); | |||||
| final ExecTask cmd = (ExecTask)project.createTask( "exec" ); | |||||
| cmd.setExecutable( "jarsigner" ); | cmd.setExecutable( "jarsigner" ); | ||||
| if( null != keystore ) | if( null != keystore ) | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | 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.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -41,12 +42,12 @@ public class Sleep extends Task | |||||
| */ | */ | ||||
| private int milliseconds = 0; | private int milliseconds = 0; | ||||
| /** | /** | ||||
| * Creates new instance | * Creates new instance | ||||
| */ | */ | ||||
| public Sleep() { } | |||||
| public Sleep() | |||||
| { | |||||
| } | |||||
| /** | /** | ||||
| * Sets the FailOnError attribute of the MimeMail object | * Sets the FailOnError attribute of the MimeMail object | ||||
| @@ -58,7 +59,6 @@ public class Sleep extends Task | |||||
| this.failOnError = failOnError; | this.failOnError = failOnError; | ||||
| } | } | ||||
| /** | /** | ||||
| * Sets the Hours attribute of the Sleep object | * Sets the Hours attribute of the Sleep object | ||||
| * | * | ||||
| @@ -69,7 +69,6 @@ public class Sleep extends Task | |||||
| this.hours = hours; | this.hours = hours; | ||||
| } | } | ||||
| /** | /** | ||||
| * Sets the Milliseconds attribute of the Sleep object | * Sets the Milliseconds attribute of the Sleep object | ||||
| * | * | ||||
| @@ -80,7 +79,6 @@ public class Sleep extends Task | |||||
| this.milliseconds = milliseconds; | this.milliseconds = milliseconds; | ||||
| } | } | ||||
| /** | /** | ||||
| * Sets the Minutes attribute of the Sleep object | * Sets the Minutes attribute of the Sleep object | ||||
| * | * | ||||
| @@ -91,7 +89,6 @@ public class Sleep extends Task | |||||
| this.minutes = minutes; | this.minutes = minutes; | ||||
| } | } | ||||
| /** | /** | ||||
| * Sets the Seconds attribute of the Sleep object | * Sets the Seconds attribute of the Sleep object | ||||
| * | * | ||||
| @@ -102,7 +99,6 @@ public class Sleep extends Task | |||||
| this.seconds = seconds; | this.seconds = seconds; | ||||
| } | } | ||||
| /** | /** | ||||
| * sleep for a period of time | * 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. | * there is an error during task execution. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| validate(); | validate(); | ||||
| long sleepTime = getSleepTime(); | long sleepTime = getSleepTime(); | ||||
| log( "sleeping for " + sleepTime + " milliseconds", | log( "sleeping for " + sleepTime + " milliseconds", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| doSleep( sleepTime ); | doSleep( sleepTime ); | ||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| if( failOnError ) | if( failOnError ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -151,23 +146,21 @@ public class Sleep extends Task | |||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * verify parameters | * verify parameters | ||||
| * | * | ||||
| * @throws BuildException if something is invalid | |||||
| * @throws TaskException if something is invalid | |||||
| */ | */ | ||||
| public void validate() | public void validate() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| long sleepTime = getSleepTime(); | long sleepTime = getSleepTime(); | ||||
| if( getSleepTime() < 0 ) | 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 | * return time to sleep | ||||
| * | * | ||||
| @@ -176,7 +169,7 @@ public class Sleep extends Task | |||||
| private long getSleepTime() | private long getSleepTime() | ||||
| { | { | ||||
| return ( ( ( ( long )hours * 60 ) + minutes ) * 60 + seconds ) * 1000 + milliseconds; | |||||
| return ( ( ( (long)hours * 60 ) + minutes ) * 60 + seconds ) * 1000 + milliseconds; | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| @@ -26,7 +27,6 @@ public class StreamPumper implements Runnable | |||||
| private InputStream is; | private InputStream is; | ||||
| private OutputStream os; | private OutputStream os; | ||||
| /** | /** | ||||
| * Create a new stream pumper. | * Create a new stream pumper. | ||||
| * | * | ||||
| @@ -39,14 +39,13 @@ public class StreamPumper implements Runnable | |||||
| this.os = os; | this.os = os; | ||||
| } | } | ||||
| /** | /** | ||||
| * Copies data from the input stream to the output stream. Terminates as | * Copies data from the input stream to the output stream. Terminates as | ||||
| * soon as the input stream is closed or an error occurs. | * soon as the input stream is closed or an error occurs. | ||||
| */ | */ | ||||
| public void run() | public void run() | ||||
| { | { | ||||
| final byte[] buf = new byte[SIZE]; | |||||
| final byte[] buf = new byte[ SIZE ]; | |||||
| int length; | int length; | ||||
| try | try | ||||
| @@ -59,10 +58,12 @@ public class StreamPumper implements Runnable | |||||
| Thread.sleep( SLEEP ); | Thread.sleep( SLEEP ); | ||||
| } | } | ||||
| catch( InterruptedException e ) | catch( InterruptedException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -13,7 +13,7 @@ import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| @@ -91,28 +91,28 @@ public class Tar extends MatchingTask | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( tarFile == null ) | if( tarFile == null ) | ||||
| { | { | ||||
| throw new BuildException( "tarfile attribute must be set!" ); | |||||
| throw new TaskException( "tarfile attribute must be set!" ); | |||||
| } | } | ||||
| if( tarFile.exists() && tarFile.isDirectory() ) | if( tarFile.exists() && tarFile.isDirectory() ) | ||||
| { | { | ||||
| throw new BuildException( "tarfile is a directory!" ); | |||||
| throw new TaskException( "tarfile is a directory!" ); | |||||
| } | } | ||||
| if( tarFile.exists() && !tarFile.canWrite() ) | 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 != null ) | ||||
| { | { | ||||
| if( !baseDir.exists() ) | 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. | // add the main fileset to the list of filesets to process. | ||||
| @@ -123,7 +123,7 @@ public class Tar extends MatchingTask | |||||
| if( filesets.size() == 0 ) | if( filesets.size() == 0 ) | ||||
| { | { | ||||
| throw new BuildException( "You must supply either a basdir attribute or some nested filesets." ); | |||||
| 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 | // 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 ] ) ) ) | 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 ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "Problem creating TAR: " + ioe.getMessage(); | String msg = "Problem creating TAR: " + ioe.getMessage(); | ||||
| throw new BuildException( msg, ioe ); | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -258,7 +258,7 @@ public class Tar extends MatchingTask | |||||
| } | } | ||||
| else if( longFileMode.isFailMode() ) | else if( longFileMode.isFailMode() ) | ||||
| { | { | ||||
| throw new BuildException( | |||||
| throw new TaskException( | |||||
| "Entry: " + vPath + " longer than " + | "Entry: " + vPath + " longer than " + | ||||
| TarConstants.NAMELEN + "characters." ); | TarConstants.NAMELEN + "characters." ); | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -13,7 +14,7 @@ import java.text.DateFormat; | |||||
| import java.text.ParseException; | import java.text.ParseException; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import java.util.Vector; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -89,39 +90,39 @@ public class Touch extends Task | |||||
| /** | /** | ||||
| * Execute the touch operation. | * Execute the touch operation. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( file == null && filesets.size() == 0 ) | if( file == null && filesets.size() == 0 ) | ||||
| { | { | ||||
| throw | 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() ) | 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 ) | if( dateTime != null ) | ||||
| { | { | ||||
| DateFormat df = DateFormat.getDateTimeInstance( DateFormat.SHORT, | DateFormat df = DateFormat.getDateTimeInstance( DateFormat.SHORT, | ||||
| DateFormat.SHORT, | |||||
| Locale.US ); | |||||
| DateFormat.SHORT, | |||||
| Locale.US ); | |||||
| try | try | ||||
| { | { | ||||
| setMillis( df.parse( dateTime ).getTime() ); | setMillis( df.parse( dateTime ).getTime() ); | ||||
| if( millis < 0 ) | 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 ) | 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. | * 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() | protected void touch() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( file != null ) | if( file != null ) | ||||
| { | { | ||||
| @@ -144,12 +145,12 @@ public class Touch extends Task | |||||
| try | try | ||||
| { | { | ||||
| FileOutputStream fos = new FileOutputStream( file ); | FileOutputStream fos = new FileOutputStream( file ); | ||||
| fos.write( new byte[0] ); | |||||
| fos.write( new byte[ 0 ] ); | |||||
| fos.close(); | fos.close(); | ||||
| } | } | ||||
| catch( IOException ioe ) | 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 ) | if( millis >= 0 && project.getJavaVersion() == Project.JAVA_1_1 ) | ||||
| { | { | ||||
| log( "modification time of files cannot be set in JDK 1.1", | log( "modification time of files cannot be set in JDK 1.1", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -176,7 +177,7 @@ public class Touch extends Task | |||||
| // deal with the filesets | // deal with the filesets | ||||
| for( int i = 0; i < filesets.size(); i++ ) | for( int i = 0; i < filesets.size(); i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )filesets.elementAt( i ); | |||||
| FileSet fs = (FileSet)filesets.elementAt( i ); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| File fromDir = fs.getDir( project ); | File fromDir = fs.getDir( project ); | ||||
| @@ -185,12 +186,12 @@ public class Touch extends Task | |||||
| for( int j = 0; j < srcFiles.length; j++ ) | 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++ ) | 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 ) | protected void touch( File file ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( !file.canWrite() ) | 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 ) | if( project.getJavaVersion() == Project.JAVA_1_1 ) | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.Calendar; | import java.util.Calendar; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| @@ -16,7 +17,7 @@ import java.util.NoSuchElementException; | |||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.TimeZone; | import java.util.TimeZone; | ||||
| import java.util.Vector; | 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.Location; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -54,7 +55,7 @@ public class Tstamp extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -72,14 +73,14 @@ public class Tstamp extends Task | |||||
| Enumeration i = customFormats.elements(); | Enumeration i = customFormats.elements(); | ||||
| while( i.hasMoreElements() ) | while( i.hasMoreElements() ) | ||||
| { | { | ||||
| CustomFormat cts = ( CustomFormat )i.nextElement(); | |||||
| CustomFormat cts = (CustomFormat)i.nextElement(); | |||||
| cts.execute( project, d, location ); | cts.execute( project, d, location ); | ||||
| } | } | ||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -104,14 +105,14 @@ public class Tstamp extends Task | |||||
| WEEK, | WEEK, | ||||
| MONTH, | MONTH, | ||||
| YEAR | YEAR | ||||
| }; | |||||
| }; | |||||
| private Hashtable calendarFields = new Hashtable(); | private Hashtable calendarFields = new Hashtable(); | ||||
| public Unit() | public Unit() | ||||
| { | { | ||||
| calendarFields.put( MILLISECOND, | calendarFields.put( MILLISECOND, | ||||
| new Integer( Calendar.MILLISECOND ) ); | |||||
| new Integer( Calendar.MILLISECOND ) ); | |||||
| calendarFields.put( SECOND, new Integer( Calendar.SECOND ) ); | calendarFields.put( SECOND, new Integer( Calendar.SECOND ) ); | ||||
| calendarFields.put( MINUTE, new Integer( Calendar.MINUTE ) ); | calendarFields.put( MINUTE, new Integer( Calendar.MINUTE ) ); | ||||
| calendarFields.put( HOUR, new Integer( Calendar.HOUR_OF_DAY ) ); | calendarFields.put( HOUR, new Integer( Calendar.HOUR_OF_DAY ) ); | ||||
| @@ -124,7 +125,7 @@ public class Tstamp extends Task | |||||
| public int getCalendarField() | public int getCalendarField() | ||||
| { | { | ||||
| String key = getValue().toLowerCase(); | String key = getValue().toLowerCase(); | ||||
| Integer i = ( Integer )calendarFields.get( key ); | |||||
| Integer i = (Integer)calendarFields.get( key ); | |||||
| return i.intValue(); | return i.intValue(); | ||||
| } | } | ||||
| @@ -165,7 +166,7 @@ public class Tstamp extends Task | |||||
| country = st.nextToken(); | country = st.nextToken(); | ||||
| if( st.hasMoreElements() ) | 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 ) | 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 ) | if( propertyName == null ) | ||||
| { | { | ||||
| throw new BuildException( "property attribute must be provided" ); | |||||
| throw new TaskException( "property attribute must be provided" ); | |||||
| } | } | ||||
| if( pattern == null ) | if( pattern == null ) | ||||
| { | { | ||||
| throw new BuildException( "pattern attribute must be provided" ); | |||||
| throw new TaskException( "pattern attribute must be provided" ); | |||||
| } | } | ||||
| SimpleDateFormat sdf; | SimpleDateFormat sdf; | ||||
| @@ -6,8 +6,9 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| /** | /** | ||||
| @@ -23,17 +24,19 @@ public abstract class Unpack extends Task | |||||
| protected File source; | protected File source; | ||||
| public void setDest( String dest ) | public void setDest( String dest ) | ||||
| throws TaskException | |||||
| { | { | ||||
| this.dest = resolveFile( dest ); | this.dest = resolveFile( dest ); | ||||
| } | } | ||||
| public void setSrc( String src ) | public void setSrc( String src ) | ||||
| throws TaskException | |||||
| { | { | ||||
| source = resolveFile( src ); | source = resolveFile( src ); | ||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| validate(); | validate(); | ||||
| extract(); | extract(); | ||||
| @@ -48,11 +51,11 @@ public abstract class Unpack extends Task | |||||
| String sourceName = source.getName(); | String sourceName = source.getName(); | ||||
| int len = sourceName.length(); | int len = sourceName.length(); | ||||
| if( defaultExtension != null | 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, | dest = new File( dest, sourceName.substring( 0, | ||||
| len - defaultExtension.length() ) ); | |||||
| len - defaultExtension.length() ) ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -61,21 +64,21 @@ public abstract class Unpack extends Task | |||||
| } | } | ||||
| private void validate() | private void validate() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( source == null ) | if( source == null ) | ||||
| { | { | ||||
| throw new BuildException( "No Src for gunzip specified" ); | |||||
| throw new TaskException( "No Src for gunzip specified" ); | |||||
| } | } | ||||
| if( !source.exists() ) | if( !source.exists() ) | ||||
| { | { | ||||
| throw new BuildException( "Src doesn't exist" ); | |||||
| throw new TaskException( "Src doesn't exist" ); | |||||
| } | } | ||||
| if( source.isDirectory() ) | if( source.isDirectory() ) | ||||
| { | { | ||||
| throw new BuildException( "Cannot expand a directory" ); | |||||
| throw new TaskException( "Cannot expand a directory" ); | |||||
| } | } | ||||
| if( dest == null ) | if( dest == null ) | ||||
| @@ -6,11 +6,11 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.IOException; | 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.Project; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.tools.tar.TarEntry; | import org.apache.tools.tar.TarEntry; | ||||
| @@ -38,15 +38,15 @@ public class Untar extends Expand | |||||
| while( ( te = tis.getNextEntry() ) != null ) | while( ( te = tis.getNextEntry() ) != null ) | ||||
| { | { | ||||
| extractFile( fileUtils, srcF, dir, tis, | extractFile( fileUtils, srcF, dir, tis, | ||||
| te.getName(), | |||||
| te.getModTime(), te.isDirectory() ); | |||||
| te.getName(), | |||||
| te.getModTime(), te.isDirectory() ); | |||||
| } | } | ||||
| log( "expand complete", Project.MSG_VERBOSE ); | log( "expand complete", Project.MSG_VERBOSE ); | ||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| throw new BuildException( "Error while expanding " + srcF.getPath(), ioe ); | |||||
| throw new TaskException( "Error while expanding " + srcF.getPath(), ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -57,7 +57,8 @@ public class Untar extends Expand | |||||
| tis.close(); | tis.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,10 +6,11 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.condition.Condition; | 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). | * Defines the FileNameMapper to use (nested mapper element). | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public Mapper createMapper() | public Mapper createMapper() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( mapperElement != null ) | 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 ); | mapperElement = new Mapper( project ); | ||||
| return mapperElement; | return mapperElement; | ||||
| @@ -109,12 +110,12 @@ public class UpToDate extends MatchingTask implements Condition | |||||
| { | { | ||||
| if( sourceFileSets.size() == 0 ) | 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 ) | 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 | // 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; | boolean upToDate = true; | ||||
| while( upToDate && enum.hasMoreElements() ) | while( upToDate && enum.hasMoreElements() ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )enum.nextElement(); | |||||
| FileSet fs = (FileSet)enum.nextElement(); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| upToDate = upToDate && scanDir( fs.getDir( project ), | upToDate = upToDate && scanDir( fs.getDir( project ), | ||||
| ds.getIncludedFiles() ); | |||||
| ds.getIncludedFiles() ); | |||||
| } | } | ||||
| return upToDate; | return upToDate; | ||||
| } | } | ||||
| /** | /** | ||||
| * Sets property to true if target files have a more recent timestamp than | * Sets property to true if target files have a more recent timestamp than | ||||
| * each of the corresponding source files. | * each of the corresponding source files. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| boolean upToDate = eval(); | boolean upToDate = eval(); | ||||
| if( upToDate ) | if( upToDate ) | ||||
| @@ -150,12 +150,12 @@ public class UpToDate extends MatchingTask implements Condition | |||||
| if( mapperElement == null ) | if( mapperElement == null ) | ||||
| { | { | ||||
| log( "File \"" + _targetFile.getAbsolutePath() + "\" is up to date.", | log( "File \"" + _targetFile.getAbsolutePath() + "\" is up to date.", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| log( "All target files have been up to date.", | log( "All target files have been up to date.", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,8 +6,9 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.util.Hashtable; | 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.Condition; | ||||
| import org.apache.tools.ant.taskdefs.condition.ConditionBase; | import org.apache.tools.ant.taskdefs.condition.ConditionBase; | ||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | 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 | * Check repeatedly for the specified conditions until they become true or | ||||
| * the timeout expires. | * the timeout expires. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( countConditions() > 1 ) | if( countConditions() > 1 ) | ||||
| { | { | ||||
| throw new BuildException( "You must not nest more than one condition into <waitfor>" ); | |||||
| throw new TaskException( "You must not nest more than one condition into <waitfor>" ); | |||||
| } | } | ||||
| if( countConditions() < 1 ) | 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; | maxWaitMillis *= maxWaitMultiplier; | ||||
| checkEveryMillis *= checkEveryMultiplier; | checkEveryMillis *= checkEveryMultiplier; | ||||
| @@ -149,7 +150,7 @@ public class WaitFor extends ConditionBase | |||||
| private final static String[] units = { | private final static String[] units = { | ||||
| MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK | MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK | ||||
| }; | |||||
| }; | |||||
| private Hashtable timeTable = new Hashtable(); | private Hashtable timeTable = new Hashtable(); | ||||
| @@ -166,7 +167,7 @@ public class WaitFor extends ConditionBase | |||||
| public long getMultiplier() | public long getMultiplier() | ||||
| { | { | ||||
| String key = getValue().toLowerCase(); | String key = getValue().toLowerCase(); | ||||
| Long l = ( Long )timeTable.get( key ); | |||||
| Long l = (Long)timeTable.get( key ); | |||||
| return l.longValue(); | return l.longValue(); | ||||
| } | } | ||||
| @@ -6,14 +6,14 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.ZipFileSet; | import org.apache.tools.ant.types.ZipFileSet; | ||||
| import org.apache.tools.zip.ZipOutputStream; | import org.apache.tools.zip.ZipOutputStream; | ||||
| /** | /** | ||||
| * Creates a WAR archive. | * Creates a WAR archive. | ||||
| * | * | ||||
| @@ -36,7 +36,7 @@ public class War extends Jar | |||||
| { | { | ||||
| deploymentDescriptor = descr; | deploymentDescriptor = descr; | ||||
| if( !deploymentDescriptor.exists() ) | 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. | // Create a ZipFileSet for this file, and pass it up. | ||||
| ZipFileSet fs = new ZipFileSet(); | ZipFileSet fs = new ZipFileSet(); | ||||
| @@ -78,12 +78,12 @@ public class War extends Jar | |||||
| } | } | ||||
| protected void initZipOutputStream( ZipOutputStream zOut ) | protected void initZipOutputStream( ZipOutputStream zOut ) | ||||
| throws IOException, BuildException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| // If no webxml file is specified, it's an error. | // If no webxml file is specified, it's an error. | ||||
| if( deploymentDescriptor == null && !isInUpdateMode() ) | if( deploymentDescriptor == null && !isInUpdateMode() ) | ||||
| { | { | ||||
| throw new BuildException( "webxml attribute is required" ); | |||||
| throw new TaskException( "webxml attribute is required" ); | |||||
| } | } | ||||
| super.initZipOutputStream( zOut ); | super.initZipOutputStream( zOut ); | ||||
| @@ -101,7 +101,7 @@ public class War extends Jar | |||||
| if( deploymentDescriptor == null || !deploymentDescriptor.equals( file ) || descriptorAdded ) | if( deploymentDescriptor == null || !deploymentDescriptor.equals( file ) || descriptorAdded ) | ||||
| { | { | ||||
| log( "Warning: selected " + archiveType + " files include a WEB-INF/web.xml which will be ignored " + | 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 | else | ||||
| { | { | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| /** | /** | ||||
| @@ -10,8 +10,8 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| @@ -209,11 +209,11 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger | |||||
| /** | /** | ||||
| * Executes the task. | * Executes the task. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| DirectoryScanner scanner; | DirectoryScanner scanner; | ||||
| String[] list; | String[] list; | ||||
| @@ -221,7 +221,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger | |||||
| if( xslFile == null ) | if( xslFile == null ) | ||||
| { | { | ||||
| throw new BuildException( "no stylesheet specified" ); | |||||
| throw new TaskException( "no stylesheet specified" ); | |||||
| } | } | ||||
| if( baseDir == null ) | if( baseDir == null ) | ||||
| @@ -256,7 +256,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger | |||||
| if( destDir == null ) | if( destDir == null ) | ||||
| { | { | ||||
| String msg = "destdir attributes must be set!"; | String msg = "destdir attributes must be set!"; | ||||
| throw new BuildException( msg ); | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| scanner = getDirectoryScanner( baseDir ); | scanner = getDirectoryScanner( baseDir ); | ||||
| log( "Transforming into " + destDir, Project.MSG_INFO ); | log( "Transforming into " + destDir, Project.MSG_INFO ); | ||||
| @@ -292,7 +292,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger | |||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -324,7 +324,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger | |||||
| e4.printStackTrace(); | e4.printStackTrace(); | ||||
| e3.printStackTrace(); | e3.printStackTrace(); | ||||
| e2.printStackTrace(); | e2.printStackTrace(); | ||||
| throw new BuildException( "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. | * Loads the stylesheet and set xsl:param parameters. | ||||
| * | * | ||||
| * @param stylesheet Description of Parameter | * @param stylesheet Description of Parameter | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected void configureLiaison( File stylesheet ) | protected void configureLiaison( File stylesheet ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( stylesheetLoaded ) | if( stylesheetLoaded ) | ||||
| { | { | ||||
| @@ -362,20 +362,20 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger | |||||
| catch( Exception ex ) | catch( Exception ex ) | ||||
| { | { | ||||
| log( "Failed to read stylesheet " + stylesheet, Project.MSG_INFO ); | log( "Failed to read stylesheet " + stylesheet, Project.MSG_INFO ); | ||||
| throw new BuildException( "Error", ex ); | |||||
| throw new TaskException( "Error", ex ); | |||||
| } | } | ||||
| } | } | ||||
| private void ensureDirectoryFor( File targetFile ) | private void ensureDirectoryFor( File targetFile ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| File directory = new File( targetFile.getParent() ); | File directory = new File( targetFile.getParent() ); | ||||
| if( !directory.exists() ) | if( !directory.exists() ) | ||||
| { | { | ||||
| if( !directory.mkdirs() ) | 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 xmlFile Description of Parameter | ||||
| * @param destDir Description of Parameter | * @param destDir Description of Parameter | ||||
| * @param stylesheet 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, | private void process( File baseDir, String xmlFile, File destDir, | ||||
| File stylesheet ) | File stylesheet ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| String fileExt = targetExtension; | String fileExt = targetExtension; | ||||
| @@ -457,13 +457,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger | |||||
| outFile.delete(); | outFile.delete(); | ||||
| } | } | ||||
| throw new BuildException( "Error", ex ); | |||||
| throw new TaskException( "Error", ex ); | |||||
| } | } | ||||
| }//-- processXML | }//-- processXML | ||||
| private void process( File inFile, File outFile, File stylesheet ) | private void process( File inFile, File outFile, File stylesheet ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -486,7 +486,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger | |||||
| log( "Failed to process " + inFile, Project.MSG_INFO ); | log( "Failed to process " + inFile, Project.MSG_INFO ); | ||||
| if( outFile != null ) | if( outFile != null ) | ||||
| outFile.delete(); | outFile.delete(); | ||||
| throw new BuildException( "Error", ex ); | |||||
| throw new TaskException( "Error", ex ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -534,18 +534,18 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger | |||||
| } | } | ||||
| public String getExpression() | public String getExpression() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( expression == null ) | if( expression == null ) | ||||
| throw new BuildException( "Expression attribute is missing." ); | |||||
| throw new TaskException( "Expression attribute is missing." ); | |||||
| return expression; | return expression; | ||||
| } | } | ||||
| public String getName() | public String getName() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( name == null ) | if( name == null ) | ||||
| throw new BuildException( "Name attribute is missing." ); | |||||
| throw new TaskException( "Name attribute is missing." ); | |||||
| return name; | return name; | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.ByteArrayInputStream; | import java.io.ByteArrayInputStream; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -19,7 +20,7 @@ import java.util.Stack; | |||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import java.util.zip.CRC32; | import java.util.zip.CRC32; | ||||
| import java.util.zip.ZipInputStream; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.FileScanner; | import org.apache.tools.ant.FileScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| @@ -71,14 +72,14 @@ public class Zip extends MatchingTask | |||||
| protected static String[][] grabFileNames( FileScanner[] scanners ) | 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++ ) | 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; | return result; | ||||
| } | } | ||||
| @@ -94,11 +95,11 @@ public class Zip extends MatchingTask | |||||
| Vector files = new Vector(); | Vector files = new Vector(); | ||||
| for( int i = 0; i < fileNames.length; i++ ) | 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 ); | files.copyInto( toret ); | ||||
| return toret; | return toret; | ||||
| } | } | ||||
| @@ -216,17 +217,17 @@ public class Zip extends MatchingTask | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( baseDir == null && filesets.size() == 0 && "zip".equals( archiveType ) ) | 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 ) | 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 | // Renamed version of original file, if it exists | ||||
| @@ -240,18 +241,18 @@ public class Zip extends MatchingTask | |||||
| { | { | ||||
| FileUtils fileUtils = FileUtils.newFileUtils(); | FileUtils fileUtils = FileUtils.newFileUtils(); | ||||
| renamedFile = fileUtils.createTempFile( "zip", ".tmp", | renamedFile = fileUtils.createTempFile( "zip", ".tmp", | ||||
| fileUtils.getParentFile( zipFile ) ); | |||||
| fileUtils.getParentFile( zipFile ) ); | |||||
| try | try | ||||
| { | { | ||||
| if( !zipFile.renameTo( renamedFile ) ) | 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 ) | 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++ ) | 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 ) ); | dss.addElement( fs.getDirectoryScanner( project ) ); | ||||
| } | } | ||||
| int dssSize = dss.size(); | int dssSize = dss.size(); | ||||
| FileScanner[] scanners = new FileScanner[dssSize]; | |||||
| FileScanner[] scanners = new FileScanner[ dssSize ]; | |||||
| dss.copyInto( scanners ); | dss.copyInto( scanners ); | ||||
| // quick exit if the target is up to date | // quick exit if the target is up to date | ||||
| @@ -319,7 +320,7 @@ public class Zip extends MatchingTask | |||||
| { | { | ||||
| exclusionPattern.append( "," ); | exclusionPattern.append( "," ); | ||||
| } | } | ||||
| exclusionPattern.append( ( String )addedFiles.elementAt( i ) ); | |||||
| exclusionPattern.append( (String)addedFiles.elementAt( i ) ); | |||||
| } | } | ||||
| oldFiles.setExcludes( exclusionPattern.toString() ); | oldFiles.setExcludes( exclusionPattern.toString() ); | ||||
| Vector tmp = new Vector(); | Vector tmp = new Vector(); | ||||
| @@ -371,7 +372,7 @@ public class Zip extends MatchingTask | |||||
| } | } | ||||
| } | } | ||||
| throw new BuildException( msg, ioe ); | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -384,7 +385,7 @@ public class Zip extends MatchingTask | |||||
| if( !renamedFile.delete() ) | if( !renamedFile.delete() ) | ||||
| { | { | ||||
| log( "Warning: unable to delete temporary file " + | 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; | return addingNewFiles; | ||||
| } | } | ||||
| /** | /** | ||||
| * Check whether the archive is up-to-date; and handle behavior for empty | * Check whether the archive is up-to-date; and handle behavior for empty | ||||
| * archives. | * archives. | ||||
| @@ -409,10 +409,10 @@ public class Zip extends MatchingTask | |||||
| * @param zipFile intended archive file (may or may not exist) | * @param zipFile intended archive file (may or may not exist) | ||||
| * @return true if nothing need be done (may have done something already); | * @return true if nothing need be done (may have done something already); | ||||
| * false if archive creation should proceed | * false if archive creation should proceed | ||||
| * @exception BuildException if it likes | |||||
| * @exception TaskException if it likes | |||||
| */ | */ | ||||
| protected boolean isUpToDate( FileScanner[] scanners, File zipFile ) | protected boolean isUpToDate( FileScanner[] scanners, File zipFile ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| String[][] fileNames = grabFileNames( scanners ); | String[][] fileNames = grabFileNames( scanners ); | ||||
| File[] files = grabFiles( scanners, fileNames ); | File[] files = grabFiles( scanners, fileNames ); | ||||
| @@ -421,13 +421,13 @@ public class Zip extends MatchingTask | |||||
| if( emptyBehavior.equals( "skip" ) ) | if( emptyBehavior.equals( "skip" ) ) | ||||
| { | { | ||||
| log( "Warning: skipping " + archiveType + " archive " + zipFile + | log( "Warning: skipping " + archiveType + " archive " + zipFile + | ||||
| " because no files were included.", Project.MSG_WARN ); | |||||
| " because no files were included.", Project.MSG_WARN ); | |||||
| return true; | return true; | ||||
| } | } | ||||
| else if( emptyBehavior.equals( "fail" ) ) | 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 | else | ||||
| { | { | ||||
| @@ -439,9 +439,9 @@ public class Zip extends MatchingTask | |||||
| { | { | ||||
| for( int i = 0; i < files.length; ++i ) | 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() ); | mm.setTo( zipFile.getAbsolutePath() ); | ||||
| for( int i = 0; i < scanners.length; i++ ) | 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; | return false; | ||||
| } | } | ||||
| @@ -480,21 +480,21 @@ public class Zip extends MatchingTask | |||||
| throws IOException | throws IOException | ||||
| { | { | ||||
| if( prefix.length() > 0 && fullpath.length() > 0 ) | 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(); | File thisBaseDir = scanner.getBasedir(); | ||||
| // directories that matched include patterns | // directories that matched include patterns | ||||
| String[] dirs = scanner.getIncludedDirectories(); | String[] dirs = scanner.getIncludedDirectories(); | ||||
| if( dirs.length > 0 && fullpath.length() > 0 ) | 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++ ) | for( int i = 0; i < dirs.length; i++ ) | ||||
| { | { | ||||
| if( "".equals( dirs[i] ) ) | |||||
| if( "".equals( dirs[ i ] ) ) | |||||
| { | { | ||||
| continue; | continue; | ||||
| } | } | ||||
| String name = dirs[i].replace( File.separatorChar, '/' ); | |||||
| String name = dirs[ i ].replace( File.separatorChar, '/' ); | |||||
| if( !name.endsWith( "/" ) ) | if( !name.endsWith( "/" ) ) | ||||
| { | { | ||||
| name += "/"; | name += "/"; | ||||
| @@ -505,10 +505,10 @@ public class Zip extends MatchingTask | |||||
| // files that matched include patterns | // files that matched include patterns | ||||
| String[] files = scanner.getIncludedFiles(); | String[] files = scanner.getIncludedFiles(); | ||||
| if( files.length > 1 && fullpath.length() > 0 ) | 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++ ) | 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 ) | if( fullpath.length() > 0 ) | ||||
| { | { | ||||
| // Add this file at the specified location. | // Add this file at the specified location. | ||||
| @@ -518,7 +518,7 @@ public class Zip extends MatchingTask | |||||
| else | else | ||||
| { | { | ||||
| // Add this file with the specified prefix. | // 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 ); | addParentDirs( thisBaseDir, name, zOut, prefix ); | ||||
| zipFile( f, zOut, prefix + name ); | zipFile( f, zOut, prefix + name ); | ||||
| } | } | ||||
| @@ -539,21 +539,21 @@ public class Zip extends MatchingTask | |||||
| // Add each fileset in the Vector. | // Add each fileset in the Vector. | ||||
| for( int i = 0; i < filesets.size(); i++ ) | for( int i = 0; i < filesets.size(); i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )filesets.elementAt( i ); | |||||
| FileSet fs = (FileSet)filesets.elementAt( i ); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| String prefix = ""; | String prefix = ""; | ||||
| String fullpath = ""; | String fullpath = ""; | ||||
| if( fs instanceof ZipFileSet ) | if( fs instanceof ZipFileSet ) | ||||
| { | { | ||||
| ZipFileSet zfs = ( ZipFileSet )fs; | |||||
| ZipFileSet zfs = (ZipFileSet)fs; | |||||
| prefix = zfs.getPrefix(); | prefix = zfs.getPrefix(); | ||||
| fullpath = zfs.getFullpath(); | fullpath = zfs.getFullpath(); | ||||
| } | } | ||||
| if( prefix.length() > 0 | if( prefix.length() > 0 | ||||
| && !prefix.endsWith( "/" ) | |||||
| && !prefix.endsWith( "\\" ) ) | |||||
| && !prefix.endsWith( "/" ) | |||||
| && !prefix.endsWith( "\\" ) ) | |||||
| { | { | ||||
| prefix += "/"; | prefix += "/"; | ||||
| } | } | ||||
| @@ -571,9 +571,9 @@ public class Zip extends MatchingTask | |||||
| } | } | ||||
| if( fs instanceof ZipFileSet | 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 | else | ||||
| { | { | ||||
| @@ -601,7 +601,7 @@ public class Zip extends MatchingTask | |||||
| Stack directories = new Stack(); | Stack directories = new Stack(); | ||||
| int slashPos = entry.length(); | 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 ); | String dir = entry.substring( 0, slashPos + 1 ); | ||||
| if( addedDirs.get( prefix + dir ) != null ) | if( addedDirs.get( prefix + dir ) != null ) | ||||
| @@ -613,7 +613,7 @@ public class Zip extends MatchingTask | |||||
| while( !directories.isEmpty() ) | while( !directories.isEmpty() ) | ||||
| { | { | ||||
| String dir = ( String )directories.pop(); | |||||
| String dir = (String)directories.pop(); | |||||
| File f = null; | File f = null; | ||||
| if( baseDir != null ) | if( baseDir != null ) | ||||
| { | { | ||||
| @@ -633,9 +633,9 @@ public class Zip extends MatchingTask | |||||
| throws IOException | throws IOException | ||||
| { | { | ||||
| if( prefix.length() > 0 && fullpath.length() > 0 ) | 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(); | File zipSrc = fs.getSrc(); | ||||
| ZipEntry entry; | ZipEntry entry; | ||||
| @@ -714,11 +714,11 @@ public class Zip extends MatchingTask | |||||
| try | try | ||||
| { | { | ||||
| // Cf. PKZIP specification. | // 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 | // remainder zeros | ||||
| os.write( empty ); | os.write( empty ); | ||||
| } | } | ||||
| @@ -729,16 +729,20 @@ public class Zip extends MatchingTask | |||||
| } | } | ||||
| catch( IOException ioe ) | 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; | return true; | ||||
| } | } | ||||
| protected void finalizeZipOutputStream( ZipOutputStream zOut ) | protected void finalizeZipOutputStream( ZipOutputStream zOut ) | ||||
| throws IOException, BuildException { } | |||||
| throws IOException, TaskException | |||||
| { | |||||
| } | |||||
| protected void initZipOutputStream( ZipOutputStream zOut ) | protected void initZipOutputStream( ZipOutputStream zOut ) | ||||
| throws IOException, BuildException { } | |||||
| throws IOException, TaskException | |||||
| { | |||||
| } | |||||
| protected void zipDir( File dir, ZipOutputStream zOut, String vPath ) | protected void zipDir( File dir, ZipOutputStream zOut, String vPath ) | ||||
| throws IOException | throws IOException | ||||
| @@ -797,7 +801,7 @@ public class Zip extends MatchingTask | |||||
| // Store data into a byte[] | // Store data into a byte[] | ||||
| ByteArrayOutputStream bos = new ByteArrayOutputStream(); | ByteArrayOutputStream bos = new ByteArrayOutputStream(); | ||||
| byte[] buffer = new byte[8 * 1024]; | |||||
| byte[] buffer = new byte[ 8 * 1024 ]; | |||||
| int count = 0; | int count = 0; | ||||
| do | do | ||||
| { | { | ||||
| @@ -805,21 +809,21 @@ public class Zip extends MatchingTask | |||||
| cal.update( buffer, 0, count ); | cal.update( buffer, 0, count ); | ||||
| bos.write( buffer, 0, count ); | bos.write( buffer, 0, count ); | ||||
| count = in.read( buffer, 0, buffer.length ); | count = in.read( buffer, 0, buffer.length ); | ||||
| }while ( count != -1 ); | |||||
| } while( count != -1 ); | |||||
| in = new ByteArrayInputStream( bos.toByteArray() ); | in = new ByteArrayInputStream( bos.toByteArray() ); | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| in.mark( Integer.MAX_VALUE ); | in.mark( Integer.MAX_VALUE ); | ||||
| byte[] buffer = new byte[8 * 1024]; | |||||
| byte[] buffer = new byte[ 8 * 1024 ]; | |||||
| int count = 0; | int count = 0; | ||||
| do | do | ||||
| { | { | ||||
| size += count; | size += count; | ||||
| cal.update( buffer, 0, count ); | cal.update( buffer, 0, count ); | ||||
| count = in.read( buffer, 0, buffer.length ); | count = in.read( buffer, 0, buffer.length ); | ||||
| }while ( count != -1 ); | |||||
| } while( count != -1 ); | |||||
| in.reset(); | in.reset(); | ||||
| } | } | ||||
| ze.setSize( size ); | ze.setSize( size ); | ||||
| @@ -828,7 +832,7 @@ public class Zip extends MatchingTask | |||||
| zOut.putNextEntry( ze ); | zOut.putNextEntry( ze ); | ||||
| byte[] buffer = new byte[8 * 1024]; | |||||
| byte[] buffer = new byte[ 8 * 1024 ]; | |||||
| int count = 0; | int count = 0; | ||||
| do | do | ||||
| { | { | ||||
| @@ -837,7 +841,7 @@ public class Zip extends MatchingTask | |||||
| zOut.write( buffer, 0, count ); | zOut.write( buffer, 0, count ); | ||||
| } | } | ||||
| count = in.read( buffer, 0, buffer.length ); | count = in.read( buffer, 0, buffer.length ); | ||||
| }while ( count != -1 ); | |||||
| } while( count != -1 ); | |||||
| addedFiles.addElement( vPath ); | addedFiles.addElement( vPath ); | ||||
| } | } | ||||
| @@ -846,7 +850,7 @@ public class Zip extends MatchingTask | |||||
| { | { | ||||
| if( file.equals( zipFile ) ) | 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 ); | 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. | * Possible behaviors when there are no matching files for the task. | ||||
| * | * | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.compilers; | 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; | import org.apache.tools.ant.taskdefs.Javac; | ||||
| /** | /** | ||||
| @@ -36,8 +37,8 @@ public interface CompilerAdapter | |||||
| * Executes the task. | * Executes the task. | ||||
| * | * | ||||
| * @return has the compilation been successful | * @return has the compilation been successful | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| boolean execute() | boolean execute() | ||||
| throws BuildException; | |||||
| throws TaskException; | |||||
| } | } | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.compilers; | 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.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -21,7 +22,9 @@ public class CompilerAdapterFactory | |||||
| /** | /** | ||||
| * This is a singlton -- can't create instances!! | * This is a singlton -- can't create instances!! | ||||
| */ | */ | ||||
| private CompilerAdapterFactory() { } | |||||
| private CompilerAdapterFactory() | |||||
| { | |||||
| } | |||||
| /** | /** | ||||
| * Based on the parameter passed in, this method creates the necessary | * Based on the parameter passed in, this method creates the necessary | ||||
| @@ -45,11 +48,11 @@ public class CompilerAdapterFactory | |||||
| * classname of the compiler's adapter. | * classname of the compiler's adapter. | ||||
| * @param task a task to log through. | * @param task a task to log through. | ||||
| * @return The Compiler value | * @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. | * compiler adapter. | ||||
| */ | */ | ||||
| public static CompilerAdapter getCompiler( String compilerType, Task task ) | 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 | * If I've done things right, this should be the extent of the | ||||
| @@ -81,7 +84,7 @@ public class CompilerAdapterFactory | |||||
| catch( ClassNotFoundException cnfe ) | catch( ClassNotFoundException cnfe ) | ||||
| { | { | ||||
| task.log( "Modern compiler is not available - using " | task.log( "Modern compiler is not available - using " | ||||
| + "classic compiler", Project.MSG_WARN ); | |||||
| + "classic compiler", Project.MSG_WARN ); | |||||
| return new Javac12(); | return new Javac12(); | ||||
| } | } | ||||
| return new Javac13(); | return new Javac13(); | ||||
| @@ -113,32 +116,32 @@ public class CompilerAdapterFactory | |||||
| * | * | ||||
| * @param className The fully qualified classname to be created. | * @param className The fully qualified classname to be created. | ||||
| * @return Description of the Returned Value | * @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. | * an instance of CompilerAdapter. | ||||
| */ | */ | ||||
| private static CompilerAdapter resolveClassName( String className ) | private static CompilerAdapter resolveClassName( String className ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| Class c = Class.forName( className ); | Class c = Class.forName( className ); | ||||
| Object o = c.newInstance(); | Object o = c.newInstance(); | ||||
| return ( CompilerAdapter )o; | |||||
| return (CompilerAdapter)o; | |||||
| } | } | ||||
| catch( ClassNotFoundException cnfe ) | catch( ClassNotFoundException cnfe ) | ||||
| { | { | ||||
| throw new BuildException( className + " can\'t be found.", cnfe ); | |||||
| throw new TaskException( className + " can\'t be found.", cnfe ); | |||||
| } | } | ||||
| catch( ClassCastException cce ) | 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 ) | catch( Throwable t ) | ||||
| { | { | ||||
| // for all other possibilities | // for all other possibilities | ||||
| throw new BuildException( className + " caused an interesting " | |||||
| + "exception.", t ); | |||||
| throw new TaskException( className + " caused an interesting " | |||||
| + "exception.", t ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,18 +6,18 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.compilers; | package org.apache.tools.ant.taskdefs.compilers; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.PrintWriter; | 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.Location; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.Execute; | import org.apache.tools.ant.taskdefs.Execute; | ||||
| import org.apache.tools.ant.taskdefs.Javac; | import org.apache.tools.ant.taskdefs.Javac; | ||||
| import org.apache.tools.ant.taskdefs.LogStreamHandler; | import org.apache.tools.ant.taskdefs.LogStreamHandler; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.FileSet; | |||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -140,7 +140,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||||
| if( !attributes.isForkedJavac() ) | if( !attributes.isForkedJavac() ) | ||||
| { | { | ||||
| attributes.log( "Since fork is false, ignoring memoryInitialSize setting.", | attributes.log( "Since fork is false, ignoring memoryInitialSize setting.", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -153,7 +153,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||||
| if( !attributes.isForkedJavac() ) | if( !attributes.isForkedJavac() ) | ||||
| { | { | ||||
| attributes.log( "Since fork is false, ignoring memoryMaximumSize setting.", | attributes.log( "Since fork is false, ignoring memoryMaximumSize setting.", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -229,8 +229,8 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||||
| if( debug ) | if( debug ) | ||||
| { | { | ||||
| if( useDebugLevel | 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(); | String debugLevel = attributes.getDebugLevel(); | ||||
| @@ -271,7 +271,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||||
| else | else | ||||
| { | { | ||||
| attributes.log( "depend attribute is not supported by the modern compiler", | 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 ) ); | out = new PrintWriter( new FileWriter( tmpFile ) ); | ||||
| for( int i = firstFileName; i < args.length; i++ ) | for( int i = firstFileName; i < args.length; i++ ) | ||||
| { | { | ||||
| out.println( args[i] ); | |||||
| out.println( args[ i ] ); | |||||
| } | } | ||||
| out.flush(); | out.flush(); | ||||
| commandArray = new String[firstFileName + 1]; | |||||
| commandArray = new String[ firstFileName + 1 ]; | |||||
| System.arraycopy( args, 0, commandArray, 0, firstFileName ); | System.arraycopy( args, 0, commandArray, 0, firstFileName ); | ||||
| commandArray[firstFileName] = "@" + tmpFile.getAbsolutePath(); | |||||
| commandArray[ firstFileName ] = "@" + tmpFile.getAbsolutePath(); | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error creating temporary file", e ); | |||||
| throw new TaskException( "Error creating temporary file", e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -425,7 +425,8 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||||
| out.close(); | out.close(); | ||||
| } | } | ||||
| catch( Throwable t ) | catch( Throwable t ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -437,8 +438,8 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||||
| try | try | ||||
| { | { | ||||
| Execute exe = new Execute( new LogStreamHandler( attributes, | Execute exe = new Execute( new LogStreamHandler( attributes, | ||||
| Project.MSG_INFO, | |||||
| Project.MSG_WARN ) ); | |||||
| Project.MSG_INFO, | |||||
| Project.MSG_WARN ) ); | |||||
| exe.setAntRun( project ); | exe.setAntRun( project ); | ||||
| exe.setWorkingDirectory( project.getBaseDir() ); | exe.setWorkingDirectory( project.getBaseDir() ); | ||||
| exe.setCommandline( commandArray ); | exe.setCommandline( commandArray ); | ||||
| @@ -447,8 +448,8 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error running " + args[0] | |||||
| + " compiler", e ); | |||||
| throw new TaskException( "Error running " + args[ 0 ] | |||||
| + " compiler", e ); | |||||
| } | } | ||||
| } | } | ||||
| finally | finally | ||||
| @@ -469,7 +470,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||||
| protected void logAndAddFilesToCompile( Commandline cmd ) | protected void logAndAddFilesToCompile( Commandline cmd ) | ||||
| { | { | ||||
| attributes.log( "Compilation args: " + cmd.toString(), | attributes.log( "Compilation args: " + cmd.toString(), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| StringBuffer niceSourceList = new StringBuffer( "File" ); | StringBuffer niceSourceList = new StringBuffer( "File" ); | ||||
| if( compileList.length != 1 ) | if( compileList.length != 1 ) | ||||
| @@ -482,7 +483,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter | |||||
| for( int i = 0; i < compileList.length; i++ ) | for( int i = 0; i < compileList.length; i++ ) | ||||
| { | { | ||||
| String arg = compileList[i].getAbsolutePath(); | |||||
| String arg = compileList[ i ].getAbsolutePath(); | |||||
| cmd.createArgument().setValue( arg ); | cmd.createArgument().setValue( arg ); | ||||
| niceSourceList.append( " " + arg + lSep ); | niceSourceList.append( " " + arg + lSep ); | ||||
| } | } | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.compilers; | 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.Project; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| @@ -24,11 +25,11 @@ public class Gcj extends DefaultCompilerAdapter | |||||
| * Performs a compile using the gcj compiler. | * Performs a compile using the gcj compiler. | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| * @author tora@debian.org | * @author tora@debian.org | ||||
| */ | */ | ||||
| public boolean execute() | public boolean execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Commandline cmd; | Commandline cmd; | ||||
| attributes.log( "Using gcj compiler", Project.MSG_VERBOSE ); | attributes.log( "Using gcj compiler", Project.MSG_VERBOSE ); | ||||
| @@ -76,7 +77,7 @@ public class Gcj extends DefaultCompilerAdapter | |||||
| if( destDir.mkdirs() ) | 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. " ); | |||||
| } | } | ||||
| ; | ; | ||||
| } | } | ||||
| @@ -6,11 +6,12 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.compilers; | package org.apache.tools.ant.taskdefs.compilers; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.lang.reflect.Constructor; | import java.lang.reflect.Constructor; | ||||
| import java.lang.reflect.Method; | 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.Project; | ||||
| import org.apache.tools.ant.taskdefs.LogOutputStream; | import org.apache.tools.ant.taskdefs.LogOutputStream; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -29,7 +30,7 @@ public class Javac12 extends DefaultCompilerAdapter | |||||
| { | { | ||||
| public boolean execute() | public boolean execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| attributes.log( "Using classic compiler", Project.MSG_VERBOSE ); | attributes.log( "Using classic compiler", Project.MSG_VERBOSE ); | ||||
| Commandline cmd = setupJavacCommand( true ); | Commandline cmd = setupJavacCommand( true ); | ||||
| @@ -45,24 +46,24 @@ public class Javac12 extends DefaultCompilerAdapter | |||||
| // Call the compile() method | // Call the compile() method | ||||
| Method compile = c.getMethod( "compile", new Class[]{String[].class} ); | 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(); | return ok.booleanValue(); | ||||
| } | } | ||||
| catch( ClassNotFoundException ex ) | 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 ) | catch( Exception ex ) | ||||
| { | { | ||||
| if( ex instanceof BuildException ) | |||||
| if( ex instanceof TaskException ) | |||||
| { | { | ||||
| throw ( BuildException )ex; | |||||
| throw (TaskException)ex; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( "Error starting classic compiler: ", ex ); | |||||
| throw new TaskException( "Error starting classic compiler: ", ex ); | |||||
| } | } | ||||
| } | } | ||||
| finally | finally | ||||
| @@ -74,7 +75,7 @@ public class Javac12 extends DefaultCompilerAdapter | |||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| // plain impossible | // plain impossible | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,12 +6,12 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.compilers; | package org.apache.tools.ant.taskdefs.compilers; | ||||
| import java.lang.reflect.Method; | 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.Project; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| /** | /** | ||||
| * The implementation of the javac compiler for JDK 1.3 This is primarily a | * 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. | * 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; | private final static int MODERN_COMPILER_SUCCESS = 0; | ||||
| public boolean execute() | public boolean execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| attributes.log( "Using modern compiler", Project.MSG_VERBOSE ); | attributes.log( "Using modern compiler", Project.MSG_VERBOSE ); | ||||
| Commandline cmd = setupModernJavacCommand(); | Commandline cmd = setupModernJavacCommand(); | ||||
| @@ -42,20 +42,20 @@ public class Javac13 extends DefaultCompilerAdapter | |||||
| Class c = Class.forName( "com.sun.tools.javac.Main" ); | Class c = Class.forName( "com.sun.tools.javac.Main" ); | ||||
| Object compiler = c.newInstance(); | Object compiler = c.newInstance(); | ||||
| Method compile = c.getMethod( "compile", | 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(); | ( compiler, new Object[]{cmd.getArguments()} ) ).intValue(); | ||||
| return ( result == MODERN_COMPILER_SUCCESS ); | return ( result == MODERN_COMPILER_SUCCESS ); | ||||
| } | } | ||||
| catch( Exception ex ) | catch( Exception ex ) | ||||
| { | { | ||||
| if( ex instanceof BuildException ) | |||||
| if( ex instanceof TaskException ) | |||||
| { | { | ||||
| throw ( BuildException )ex; | |||||
| throw (TaskException)ex; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( "Error starting modern compiler", ex ); | |||||
| throw new TaskException( "Error starting modern compiler", ex ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.compilers; | 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.Project; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -22,10 +23,10 @@ public class JavacExternal extends DefaultCompilerAdapter | |||||
| * Performs a compile using the Javac externally. | * Performs a compile using the Javac externally. | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public boolean execute() | public boolean execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| attributes.log( "Using external javac compiler", Project.MSG_VERBOSE ); | attributes.log( "Using external javac compiler", Project.MSG_VERBOSE ); | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.compilers; | 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.Project; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| @@ -32,11 +33,11 @@ public class Jikes extends DefaultCompilerAdapter | |||||
| * been successfully tested with jikes >1.10 | * been successfully tested with jikes >1.10 | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| * @author skanthak@muehlheim.de | * @author skanthak@muehlheim.de | ||||
| */ | */ | ||||
| public boolean execute() | public boolean execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| attributes.log( "Using jikes compiler", Project.MSG_VERBOSE ); | attributes.log( "Using jikes compiler", Project.MSG_VERBOSE ); | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.compilers; | 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.Project; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| @@ -25,7 +26,7 @@ public class Jvc extends DefaultCompilerAdapter | |||||
| { | { | ||||
| public boolean execute() | public boolean execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| attributes.log( "Using jvc compiler", Project.MSG_VERBOSE ); | attributes.log( "Using jvc compiler", Project.MSG_VERBOSE ); | ||||
| @@ -6,8 +6,9 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.compilers; | package org.apache.tools.ant.taskdefs.compilers; | ||||
| import java.lang.reflect.Method; | 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.Project; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| @@ -22,7 +23,7 @@ public class Kjc extends DefaultCompilerAdapter | |||||
| { | { | ||||
| public boolean execute() | public boolean execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| attributes.log( "Using kjc compiler", Project.MSG_VERBOSE ); | attributes.log( "Using kjc compiler", Project.MSG_VERBOSE ); | ||||
| Commandline cmd = setupKjcCommand(); | Commandline cmd = setupKjcCommand(); | ||||
| @@ -33,26 +34,26 @@ public class Kjc extends DefaultCompilerAdapter | |||||
| // Call the compile() method | // Call the compile() method | ||||
| Method compile = c.getMethod( "compile", | 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(); | return ok.booleanValue(); | ||||
| } | } | ||||
| catch( ClassNotFoundException ex ) | 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 ) | catch( Exception ex ) | ||||
| { | { | ||||
| if( ex instanceof BuildException ) | |||||
| if( ex instanceof TaskException ) | |||||
| { | { | ||||
| throw ( BuildException )ex; | |||||
| throw (TaskException)ex; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( "Error starting kjc compiler: ", ex ); | |||||
| throw new TaskException( "Error starting kjc compiler: ", ex ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.compilers; | 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.Project; | ||||
| import org.apache.tools.ant.types.Commandline; | 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. | * Performs a compile using the sj compiler from Symantec. | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| * @author don@bea.com | * @author don@bea.com | ||||
| */ | */ | ||||
| public boolean execute() | public boolean execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| attributes.log( "Using symantec java compiler", Project.MSG_VERBOSE ); | attributes.log( "Using symantec java compiler", Project.MSG_VERBOSE ); | ||||
| @@ -6,8 +6,9 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.condition; | package org.apache.tools.ant.taskdefs.condition; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * <and> condition container. <p> | * <and> condition container. <p> | ||||
| @@ -22,12 +23,12 @@ public class And extends ConditionBase implements Condition | |||||
| { | { | ||||
| public boolean eval() | public boolean eval() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Enumeration enum = getConditions(); | Enumeration enum = getConditions(); | ||||
| while( enum.hasMoreElements() ) | while( enum.hasMoreElements() ) | ||||
| { | { | ||||
| Condition c = ( Condition )enum.nextElement(); | |||||
| Condition c = (Condition)enum.nextElement(); | |||||
| if( !c.eval() ) | if( !c.eval() ) | ||||
| { | { | ||||
| return false; | return false; | ||||
| @@ -21,7 +21,7 @@ public interface Condition | |||||
| * Is this condition true? | * Is this condition true? | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| boolean eval() | boolean eval() | ||||
| throws TaskException; | throws TaskException; | ||||
| @@ -6,14 +6,15 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.condition; | package org.apache.tools.ant.taskdefs.condition; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.NoSuchElementException; | import java.util.NoSuchElementException; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.framework.Os; | |||||
| import org.apache.tools.ant.ProjectComponent; | import org.apache.tools.ant.ProjectComponent; | ||||
| import org.apache.tools.ant.taskdefs.Available; | import org.apache.tools.ant.taskdefs.Available; | ||||
| import org.apache.tools.ant.taskdefs.Checksum; | import org.apache.tools.ant.taskdefs.Checksum; | ||||
| import org.apache.tools.ant.taskdefs.UpToDate; | import org.apache.tools.ant.taskdefs.UpToDate; | ||||
| import org.apache.myrmidon.framework.Os; | |||||
| /** | /** | ||||
| * Baseclass for the <condition> task as well as several conditions - | * Baseclass for the <condition> task as well as several conditions - | ||||
| @@ -201,7 +202,7 @@ public abstract class ConditionBase extends ProjectComponent | |||||
| if( o instanceof ProjectComponent ) | if( o instanceof ProjectComponent ) | ||||
| { | { | ||||
| ( ( ProjectComponent )o ).setProject( getProject() ); | |||||
| ( (ProjectComponent)o ).setProject( getProject() ); | |||||
| } | } | ||||
| return o; | return o; | ||||
| } | } | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.condition; | package org.apache.tools.ant.taskdefs.condition; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * Simple String comparison condition. | * Simple String comparison condition. | ||||
| @@ -30,11 +31,11 @@ public class Equals implements Condition | |||||
| } | } | ||||
| public boolean eval() | public boolean eval() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( arg1 == null || arg2 == null ) | 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 ); | return arg1.equals( arg2 ); | ||||
| } | } | ||||
| @@ -6,12 +6,12 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.condition; | package org.apache.tools.ant.taskdefs.condition; | ||||
| import java.io.IOException; | |||||
| import java.net.HttpURLConnection; | import java.net.HttpURLConnection; | ||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.net.URLConnection; | 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.Project; | ||||
| import org.apache.tools.ant.ProjectComponent; | import org.apache.tools.ant.ProjectComponent; | ||||
| @@ -31,11 +31,11 @@ public class Http extends ProjectComponent implements Condition | |||||
| } | } | ||||
| public boolean eval() | public boolean eval() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( spec == null ) | 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 ); | log( "Checking for " + spec, Project.MSG_VERBOSE ); | ||||
| try | try | ||||
| @@ -46,7 +46,7 @@ public class Http extends ProjectComponent implements Condition | |||||
| URLConnection conn = url.openConnection(); | URLConnection conn = url.openConnection(); | ||||
| if( conn instanceof HttpURLConnection ) | if( conn instanceof HttpURLConnection ) | ||||
| { | { | ||||
| HttpURLConnection http = ( HttpURLConnection )conn; | |||||
| HttpURLConnection http = (HttpURLConnection)conn; | |||||
| int code = http.getResponseCode(); | int code = http.getResponseCode(); | ||||
| log( "Result code for " + spec + " was " + code, Project.MSG_VERBOSE ); | log( "Result code for " + spec + " was " + code, Project.MSG_VERBOSE ); | ||||
| if( code > 0 && code < 500 ) | if( code > 0 && code < 500 ) | ||||
| @@ -66,7 +66,7 @@ public class Http extends ProjectComponent implements Condition | |||||
| } | } | ||||
| catch( MalformedURLException e ) | catch( MalformedURLException e ) | ||||
| { | { | ||||
| throw new BuildException( "Badly formed URL: " + spec, e ); | |||||
| throw new TaskException( "Badly formed URL: " + spec, e ); | |||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.condition; | 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; | import org.apache.tools.ant.ProjectComponent; | ||||
| /** | /** | ||||
| @@ -25,11 +26,11 @@ public class IsSet extends ProjectComponent implements Condition | |||||
| } | } | ||||
| public boolean eval() | public boolean eval() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( property == null ) | 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; | return getProject().getProperty( property ) != null; | ||||
| @@ -6,7 +6,8 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.condition; | package org.apache.tools.ant.taskdefs.condition; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * <not> condition. Evaluates to true if the single condition nested into | * <not> condition. Evaluates to true if the single condition nested into | ||||
| @@ -19,17 +20,17 @@ public class Not extends ConditionBase implements Condition | |||||
| { | { | ||||
| public boolean eval() | public boolean eval() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( countConditions() > 1 ) | 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 ) | 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(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,8 +6,9 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.condition; | package org.apache.tools.ant.taskdefs.condition; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * <or> condition container. <p> | * <or> condition container. <p> | ||||
| @@ -22,12 +23,12 @@ public class Or extends ConditionBase implements Condition | |||||
| { | { | ||||
| public boolean eval() | public boolean eval() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Enumeration enum = getConditions(); | Enumeration enum = getConditions(); | ||||
| while( enum.hasMoreElements() ) | while( enum.hasMoreElements() ) | ||||
| { | { | ||||
| Condition c = ( Condition )enum.nextElement(); | |||||
| Condition c = (Condition)enum.nextElement(); | |||||
| if( c.eval() ) | if( c.eval() ) | ||||
| { | { | ||||
| return true; | return true; | ||||
| @@ -6,8 +6,9 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.condition; | package org.apache.tools.ant.taskdefs.condition; | ||||
| import java.io.IOException; | 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.Project; | ||||
| import org.apache.tools.ant.ProjectComponent; | import org.apache.tools.ant.ProjectComponent; | ||||
| @@ -33,15 +34,15 @@ public class Socket extends ProjectComponent implements Condition | |||||
| } | } | ||||
| public boolean eval() | public boolean eval() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( server == null ) | if( server == null ) | ||||
| { | { | ||||
| throw new BuildException( "No server specified in Socket task" ); | |||||
| throw new TaskException( "No server specified in Socket task" ); | |||||
| } | } | ||||
| if( port == 0 ) | 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 ); | log( "Checking for listener at " + server + ":" + port, Project.MSG_VERBOSE ); | ||||
| try | try | ||||
| @@ -12,7 +12,7 @@ import java.io.File; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.taskdefs.Execute; | import org.apache.tools.ant.taskdefs.Execute; | ||||
| @@ -110,7 +110,7 @@ public class ANTLR extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| validateAttributes(); | validateAttributes(); | ||||
| @@ -127,7 +127,7 @@ public class ANTLR extends Task | |||||
| int err = run( commandline.getCommandline() ); | int err = run( commandline.getCommandline() ); | ||||
| if( err == 1 ) | if( err == 1 ) | ||||
| { | { | ||||
| throw new BuildException( "ANTLR returned: " + err ); | |||||
| throw new TaskException( "ANTLR returned: " + err ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -144,10 +144,10 @@ public class ANTLR extends Task | |||||
| * Adds the jars or directories containing Antlr this should make the forked | * Adds the jars or directories containing Antlr this should make the forked | ||||
| * JVM work without having to specify it directly. | * JVM work without having to specify it directly. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void init() | public void init() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| addClasspathEntry( "/antlr/Tool.class" ); | addClasspathEntry( "/antlr/Tool.class" ); | ||||
| } | } | ||||
| @@ -196,7 +196,7 @@ public class ANTLR extends Task | |||||
| } | } | ||||
| private File getGeneratedFile() | private File getGeneratedFile() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| String generatedFileName = null; | String generatedFileName = null; | ||||
| try | try | ||||
| @@ -216,11 +216,11 @@ public class ANTLR extends Task | |||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| throw new BuildException( "Unable to determine generated class", e ); | |||||
| throw new TaskException( "Unable to determine generated class", e ); | |||||
| } | } | ||||
| if( generatedFileName == null ) | 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" ); | return new File( outputDirectory, generatedFileName + ".java" ); | ||||
| } | } | ||||
| @@ -230,10 +230,10 @@ public class ANTLR extends Task | |||||
| * | * | ||||
| * @param command Description of Parameter | * @param command Description of Parameter | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private int run( String[] command ) | private int run( String[] command ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Execute exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO, | Execute exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO, | ||||
| Project.MSG_WARN ), null ); | Project.MSG_WARN ), null ); | ||||
| @@ -249,16 +249,16 @@ public class ANTLR extends Task | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| } | } | ||||
| private void validateAttributes() | private void validateAttributes() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( target == null || !target.isFile() ) | 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 | // if no output directory is specified, used the target's directory | ||||
| @@ -269,7 +269,7 @@ public class ANTLR extends Task | |||||
| } | } | ||||
| if( !outputDirectory.isDirectory() ) | if( !outputDirectory.isDirectory() ) | ||||
| { | { | ||||
| throw new BuildException( "Invalid output directory: " + outputDirectory ); | |||||
| throw new TaskException( "Invalid output directory: " + outputDirectory ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -13,17 +14,16 @@ import java.io.OutputStream; | |||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.ExecTask; | import org.apache.tools.ant.taskdefs.ExecTask; | ||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | 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.Commandline; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| /** | /** | ||||
| * Create a CAB archive. | * Create a CAB archive. | ||||
| * | * | ||||
| @@ -106,7 +106,7 @@ public class Cab extends MatchingTask | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| checkConfiguration(); | checkConfiguration(); | ||||
| @@ -144,7 +144,7 @@ public class Cab extends MatchingTask | |||||
| catch( IOException ex ) | catch( IOException ex ) | ||||
| { | { | ||||
| String msg = "Problem creating " + cabFile + " " + ex.getMessage(); | String msg = "Problem creating " + cabFile + " " + ex.getMessage(); | ||||
| throw new BuildException( msg ); | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -178,7 +178,7 @@ public class Cab extends MatchingTask | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "Problem creating " + cabFile + " " + ioe.getMessage(); | 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. | * traditional include parameters. | ||||
| * | * | ||||
| * @return The FileList value | * @return The FileList value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected Vector getFileList() | protected Vector getFileList() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Vector files = new Vector(); | Vector files = new Vector(); | ||||
| @@ -206,7 +206,7 @@ public class Cab extends MatchingTask | |||||
| // get files from filesets | // get files from filesets | ||||
| for( int i = 0; i < filesets.size(); i++ ) | for( int i = 0; i < filesets.size(); i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )filesets.elementAt( i ); | |||||
| FileSet fs = (FileSet)filesets.elementAt( i ); | |||||
| if( fs != null ) | if( fs != null ) | ||||
| { | { | ||||
| appendFiles( files, fs.getDirectoryScanner( project ) ); | appendFiles( files, fs.getDirectoryScanner( project ) ); | ||||
| @@ -248,7 +248,7 @@ public class Cab extends MatchingTask | |||||
| for( int i = 0; i < dsfiles.length; i++ ) | 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... | * for side-effects to me... | ||||
| */ | */ | ||||
| protected void checkConfiguration() | protected void checkConfiguration() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( baseDir == null ) | if( baseDir == null ) | ||||
| { | { | ||||
| throw new BuildException( "basedir attribute must be set!" ); | |||||
| throw new TaskException( "basedir attribute must be set!" ); | |||||
| } | } | ||||
| if( !baseDir.exists() ) | if( !baseDir.exists() ) | ||||
| { | { | ||||
| throw new BuildException( "basedir does not exist!" ); | |||||
| throw new TaskException( "basedir does not exist!" ); | |||||
| } | } | ||||
| if( cabFile == null ) | 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 | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| protected Commandline createCommand( File listFile ) | protected Commandline createCommand( File listFile ) | ||||
| throws TaskException | |||||
| { | { | ||||
| Commandline command = new Commandline(); | Commandline command = new Commandline(); | ||||
| command.setExecutable( "cabarc" ); | command.setExecutable( "cabarc" ); | ||||
| @@ -310,12 +311,12 @@ public class Cab extends MatchingTask | |||||
| * appears in the logs to be the same task as this one. | * appears in the logs to be the same task as this one. | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected ExecTask createExec() | protected ExecTask createExec() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| ExecTask exec = ( ExecTask )project.createTask( "exec" ); | |||||
| ExecTask exec = (ExecTask)project.createTask( "exec" ); | |||||
| exec.setOwningTarget( this.getOwningTarget() ); | exec.setOwningTarget( this.getOwningTarget() ); | ||||
| exec.setTaskName( this.getTaskName() ); | exec.setTaskName( this.getTaskName() ); | ||||
| exec.setDescription( this.getDescription() ); | exec.setDescription( this.getDescription() ); | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| @@ -13,8 +14,8 @@ import java.io.IOException; | |||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.BuildEvent; | import org.apache.tools.ant.BuildEvent; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.BuildListener; | import org.apache.tools.ant.BuildListener; | ||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| @@ -682,10 +683,10 @@ public class IContract extends MatchingTask | |||||
| /** | /** | ||||
| * Executes the task | * Executes the task | ||||
| * | * | ||||
| * @exception BuildException if the instrumentation fails | |||||
| * @exception TaskException if the instrumentation fails | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| preconditions(); | preconditions(); | ||||
| scan(); | scan(); | ||||
| @@ -720,7 +721,7 @@ public class IContract extends MatchingTask | |||||
| // Prepare the directories for iContract. iContract will make them if they | // 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 | // don't exist, but for some reason I don't know, it will complain about the REP files | ||||
| // afterwards | // afterwards | ||||
| Mkdir mkdir = ( Mkdir )project.createTask( "mkdir" ); | |||||
| Mkdir mkdir = (Mkdir)project.createTask( "mkdir" ); | |||||
| mkdir.setDir( instrumentDir ); | mkdir.setDir( instrumentDir ); | ||||
| mkdir.execute(); | mkdir.execute(); | ||||
| mkdir.setDir( buildDir ); | mkdir.setDir( buildDir ); | ||||
| @@ -737,25 +738,25 @@ public class IContract extends MatchingTask | |||||
| classpathHelper.modify( baseClasspath ); | classpathHelper.modify( baseClasspath ); | ||||
| // Create the classpath required to compile the sourcefiles BEFORE instrumentation | // 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() ) ); | beforeInstrumentationClasspath.append( new Path( getProject(), srcDir.getAbsolutePath() ) ); | ||||
| // Create the classpath required to compile the sourcefiles AFTER instrumentation | // 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(), instrumentDir.getAbsolutePath() ) ); | ||||
| afterInstrumentationClasspath.append( new Path( getProject(), repositoryDir.getAbsolutePath() ) ); | afterInstrumentationClasspath.append( new Path( getProject(), repositoryDir.getAbsolutePath() ) ); | ||||
| afterInstrumentationClasspath.append( new Path( getProject(), srcDir.getAbsolutePath() ) ); | afterInstrumentationClasspath.append( new Path( getProject(), srcDir.getAbsolutePath() ) ); | ||||
| afterInstrumentationClasspath.append( new Path( getProject(), buildDir.getAbsolutePath() ) ); | afterInstrumentationClasspath.append( new Path( getProject(), buildDir.getAbsolutePath() ) ); | ||||
| // Create the classpath required to automatically compile the repository files | // 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(), instrumentDir.getAbsolutePath() ) ); | ||||
| repositoryClasspath.append( new Path( getProject(), srcDir.getAbsolutePath() ) ); | repositoryClasspath.append( new Path( getProject(), srcDir.getAbsolutePath() ) ); | ||||
| repositoryClasspath.append( new Path( getProject(), repositoryDir.getAbsolutePath() ) ); | repositoryClasspath.append( new Path( getProject(), repositoryDir.getAbsolutePath() ) ); | ||||
| repositoryClasspath.append( new Path( getProject(), buildDir.getAbsolutePath() ) ); | repositoryClasspath.append( new Path( getProject(), buildDir.getAbsolutePath() ) ); | ||||
| // Create the classpath required for iContract itself | // 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(), 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(), srcDir.getAbsolutePath() ) ); | ||||
| iContractClasspath.append( new Path( getProject(), repositoryDir.getAbsolutePath() ) ); | iContractClasspath.append( new Path( getProject(), repositoryDir.getAbsolutePath() ) ); | ||||
| @@ -763,7 +764,7 @@ public class IContract extends MatchingTask | |||||
| iContractClasspath.append( new Path( getProject(), buildDir.getAbsolutePath() ) ); | iContractClasspath.append( new Path( getProject(), buildDir.getAbsolutePath() ) ); | ||||
| // Create a forked java process | // Create a forked java process | ||||
| Java iContract = ( Java )project.createTask( "java" ); | |||||
| Java iContract = (Java)project.createTask( "java" ); | |||||
| iContract.setTaskName( getTaskName() ); | iContract.setTaskName( getTaskName() ); | ||||
| iContract.setFork( true ); | iContract.setFork( true ); | ||||
| iContract.setClassname( "com.reliablesystems.iContract.Tool" ); | iContract.setClassname( "com.reliablesystems.iContract.Tool" ); | ||||
| @@ -784,7 +785,7 @@ public class IContract extends MatchingTask | |||||
| args.append( "@" ).append( targets.getAbsolutePath() ); | args.append( "@" ).append( targets.getAbsolutePath() ); | ||||
| iContract.createArg().setLine( args.toString() ); | 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. | // update iControlProperties if it's set. | ||||
| if( updateIcontrol ) | if( updateIcontrol ) | ||||
| @@ -825,7 +826,7 @@ public class IContract extends MatchingTask | |||||
| log( classpath.toString() ); | log( classpath.toString() ); | ||||
| log( "If you don't have the iContract jar, go get it at http://www.reliable-systems.com/tools/" ); | 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 | * Creates the -m option based on the values of controlFile, pre, post and | ||||
| * invariant. | * invariant. | ||||
| @@ -890,34 +890,34 @@ public class IContract extends MatchingTask | |||||
| /** | /** | ||||
| * Checks that the required attributes are set. | * Checks that the required attributes are set. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void preconditions() | private void preconditions() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( srcDir == null ) | if( srcDir == null ) | ||||
| { | { | ||||
| throw new BuildException( "srcdir attribute must be set!" ); | |||||
| throw new TaskException( "srcdir attribute must be set!" ); | |||||
| } | } | ||||
| if( !srcDir.exists() ) | if( !srcDir.exists() ) | ||||
| { | { | ||||
| throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!"); | |||||
| throw new TaskException( "srcdir \"" + srcDir.getPath() + "\" does not exist!" ); | |||||
| } | } | ||||
| if( instrumentDir == null ) | if( instrumentDir == null ) | ||||
| { | { | ||||
| throw new BuildException( "instrumentdir attribute must be set!"); | |||||
| throw new TaskException( "instrumentdir attribute must be set!" ); | |||||
| } | } | ||||
| if( repositoryDir == null ) | if( repositoryDir == null ) | ||||
| { | { | ||||
| throw new BuildException( "repositorydir attribute must be set!" ); | |||||
| throw new TaskException( "repositorydir attribute must be set!" ); | |||||
| } | } | ||||
| if( updateIcontrol == true && classDir == null ) | if( updateIcontrol == true && classDir == null ) | ||||
| { | { | ||||
| throw new BuildException( "classdir attribute must be specified when updateicontrol=true!" ); | |||||
| throw new TaskException( "classdir attribute must be specified when updateicontrol=true!" ); | |||||
| } | } | ||||
| if( updateIcontrol == true && controlFile == null ) | if( updateIcontrol == true && controlFile == null ) | ||||
| { | { | ||||
| throw new BuildException( "controlfile attribute must be specified when updateicontrol=true!" ); | |||||
| 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 | * Also creates a temporary file with a list of the source files, that will | ||||
| * be deleted upon exit. | * be deleted upon exit. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void scan() | private void scan() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| long now = ( new Date() ).getTime(); | long now = ( new Date() ).getTime(); | ||||
| @@ -965,20 +965,20 @@ public class IContract extends MatchingTask | |||||
| } | } | ||||
| for( int i = 0; i < files.length; i++ ) | 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). | // print the target, while we're at here. (Only if generatetarget=true). | ||||
| if( targetPrinter != null ) | if( targetPrinter != null ) | ||||
| { | { | ||||
| targetPrinter.println( srcFile.getAbsolutePath() ); | 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 ) | if( srcFile.lastModified() > now ) | ||||
| { | { | ||||
| log( "Warning: file modified in the future: " + | log( "Warning: file modified in the future: " + | ||||
| files[i], Project.MSG_WARN ); | |||||
| files[ i ], Project.MSG_WARN ); | |||||
| } | } | ||||
| if( !classFile.exists() || srcFile.lastModified() > classFile.lastModified() ) | if( !classFile.exists() || srcFile.lastModified() > classFile.lastModified() ) | ||||
| @@ -996,7 +996,7 @@ public class IContract extends MatchingTask | |||||
| } | } | ||||
| catch( IOException e ) | 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 | // also, check controlFile timestamp | ||||
| @@ -1012,8 +1012,8 @@ public class IContract extends MatchingTask | |||||
| files = ds.getIncludedFiles(); | files = ds.getIncludedFiles(); | ||||
| for( int i = 0; i < files.length; i++ ) | 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() ) | if( controlFileTime > srcFile.lastModified() ) | ||||
| { | { | ||||
| @@ -1031,7 +1031,7 @@ public class IContract extends MatchingTask | |||||
| } | } | ||||
| catch( Throwable t ) | 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 | // dummy implementation. Never called | ||||
| public void setJavac( Javac javac ) { } | |||||
| public void setJavac( Javac javac ) | |||||
| { | |||||
| } | |||||
| public boolean execute() | public boolean execute() | ||||
| { | { | ||||
| @@ -1082,9 +1084,13 @@ public class IContract extends MatchingTask | |||||
| */ | */ | ||||
| private class IContractPresenceDetector implements BuildListener | 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 ) | 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 ) | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,11 +6,12 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -229,32 +230,32 @@ public class Javah extends Task | |||||
| /** | /** | ||||
| * Executes the task. | * Executes the task. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| // first off, make sure that we've got a srcdir | // first off, make sure that we've got a srcdir | ||||
| if( ( cls == null ) && ( classes.size() == 0 ) ) | 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 ) ) | 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 != null ) | ||||
| { | { | ||||
| if( !destDir.isDirectory() ) | 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 ) | 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; | int n = 0; | ||||
| log( "Compilation args: " + cmd.toString(), | log( "Compilation args: " + cmd.toString(), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| StringBuffer niceClassList = new StringBuffer(); | StringBuffer niceClassList = new StringBuffer(); | ||||
| if( cls != null ) | if( cls != null ) | ||||
| @@ -308,7 +309,7 @@ public class Javah extends Task | |||||
| Enumeration enum = classes.elements(); | Enumeration enum = classes.elements(); | ||||
| while( enum.hasMoreElements() ) | while( enum.hasMoreElements() ) | ||||
| { | { | ||||
| ClassArgument arg = ( ClassArgument )enum.nextElement(); | |||||
| ClassArgument arg = (ClassArgument)enum.nextElement(); | |||||
| String aClass = arg.getName(); | String aClass = arg.getName(); | ||||
| cmd.createArgument().setValue( aClass ); | cmd.createArgument().setValue( aClass ); | ||||
| niceClassList.append( " " + aClass + lSep ); | niceClassList.append( " " + aClass + lSep ); | ||||
| @@ -381,7 +382,7 @@ public class Javah extends Task | |||||
| { | { | ||||
| if( !old ) | if( !old ) | ||||
| { | { | ||||
| throw new BuildException( "stubs only available in old mode." ); | |||||
| throw new TaskException( "stubs only available in old mode." ); | |||||
| } | } | ||||
| cmd.createArgument().setValue( "-stubs" ); | 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 | * Peforms a compile using the classic compiler that shipped with JDK 1.1 | ||||
| * and 1.2. | * and 1.2. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void doClassicCompile() | private void doClassicCompile() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Commandline cmd = setupJavahCommand(); | Commandline cmd = setupJavahCommand(); | ||||
| @@ -416,7 +417,7 @@ public class Javah extends Task | |||||
| * sun.tools.javac.Main compiler = | * sun.tools.javac.Main compiler = | ||||
| * new sun.tools.javac.Main(new LogOutputStream(this, Project.MSG_WARN), "javac"); | * new sun.tools.javac.Main(new LogOutputStream(this, Project.MSG_WARN), "javac"); | ||||
| * if (!compiler.compile(cmd.getArguments())) { | * if (!compiler.compile(cmd.getArguments())) { | ||||
| * throw new BuildException("Compile failed"); | |||||
| * throw new TaskException("Compile failed"); | |||||
| * } | * } | ||||
| */ | */ | ||||
| try | try | ||||
| @@ -429,20 +430,20 @@ public class Javah extends Task | |||||
| com.sun.tools.javah.Main main = new com.sun.tools.javah.Main( cmd.getArguments() ); | com.sun.tools.javah.Main main = new com.sun.tools.javah.Main( cmd.getArguments() ); | ||||
| main.run(); | 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 ) | catch( Exception ex ) | ||||
| { | { | ||||
| if( ex instanceof BuildException ) | |||||
| if( ex instanceof TaskException ) | |||||
| { | { | ||||
| throw ( BuildException )ex; | |||||
| throw (TaskException)ex; | |||||
| } | } | ||||
| else | 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; | private String name; | ||||
| public ClassArgument() { } | |||||
| public ClassArgument() | |||||
| { | |||||
| } | |||||
| public void setName( String name ) | public void setName( String name ) | ||||
| { | { | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| @@ -17,10 +18,9 @@ import java.util.Enumeration; | |||||
| import java.util.ListIterator; | import java.util.ListIterator; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | 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.Task; | ||||
| /** | /** | ||||
| * Task for creating a manifest file for a jar archiv. use: <pre> | * Task for creating a manifest file for a jar archiv. use: <pre> | ||||
| * <taskdef name="manifest" classname="ManifestFile"/> | * <taskdef name="manifest" classname="ManifestFile"/> | ||||
| @@ -86,10 +86,10 @@ public class ManifestFile extends Task | |||||
| /** | /** | ||||
| * execute task | * execute task | ||||
| * | * | ||||
| * @exception BuildException : Failure in building | |||||
| * @exception TaskException : Failure in building | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| checkParameters(); | checkParameters(); | ||||
| if( isUpdate( currentMethod ) ) | if( isUpdate( currentMethod ) ) | ||||
| @@ -111,7 +111,6 @@ public class ManifestFile extends Task | |||||
| return method.equals( REPLACEALL_.toUpperCase() ); | return method.equals( REPLACEALL_.toUpperCase() ); | ||||
| } | } | ||||
| private boolean isUpdate( String method ) | private boolean isUpdate( String method ) | ||||
| { | { | ||||
| return method.equals( UPDATE_.toUpperCase() ); | return method.equals( UPDATE_.toUpperCase() ); | ||||
| @@ -125,7 +124,6 @@ public class ManifestFile extends Task | |||||
| entry.addTo( container ); | entry.addTo( container ); | ||||
| } | } | ||||
| private StringBuffer buildBuffer() | private StringBuffer buildBuffer() | ||||
| { | { | ||||
| StringBuffer buffer = new StringBuffer(); | StringBuffer buffer = new StringBuffer(); | ||||
| @@ -134,10 +132,10 @@ public class ManifestFile extends Task | |||||
| while( iterator.hasNext() ) | 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; | String entry_string = key + keyValueSeparator + value; | ||||
| buffer.append( entry_string + this.newLine ); | buffer.append( entry_string + this.newLine ); | ||||
| @@ -157,33 +155,33 @@ public class ManifestFile extends Task | |||||
| } | } | ||||
| private void checkParameters() | private void checkParameters() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( !checkParam( manifestFile ) ) | 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 | * adding entries to a container | ||||
| * | * | ||||
| * @exception BuildException | |||||
| * @exception TaskException | |||||
| */ | */ | ||||
| private void executeOperation() | private void executeOperation() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Enumeration enum = entries.elements(); | Enumeration enum = entries.elements(); | ||||
| while( enum.hasMoreElements() ) | while( enum.hasMoreElements() ) | ||||
| { | { | ||||
| Entry entry = ( Entry )enum.nextElement(); | |||||
| Entry entry = (Entry)enum.nextElement(); | |||||
| entry.addTo( container ); | entry.addTo( container ); | ||||
| } | } | ||||
| } | } | ||||
| private void readFile() | private void readFile() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( manifestFile.exists() ) | if( manifestFile.exists() ) | ||||
| @@ -207,32 +205,31 @@ public class ManifestFile extends Task | |||||
| stop = true; | stop = true; | ||||
| } | } | ||||
| else | else | ||||
| buffer.append( ( char )c ); | |||||
| buffer.append( (char)c ); | |||||
| } | } | ||||
| fis.close(); | fis.close(); | ||||
| StringTokenizer lineTokens = getLineTokens( buffer ); | StringTokenizer lineTokens = getLineTokens( buffer ); | ||||
| while( lineTokens.hasMoreElements() ) | while( lineTokens.hasMoreElements() ) | ||||
| { | { | ||||
| String currentLine = ( String )lineTokens.nextElement(); | |||||
| String currentLine = (String)lineTokens.nextElement(); | |||||
| addLine( currentLine ); | addLine( currentLine ); | ||||
| } | } | ||||
| } | } | ||||
| catch( FileNotFoundException fnfe ) | catch( FileNotFoundException fnfe ) | ||||
| { | { | ||||
| throw new BuildException( "File not found exception " + fnfe.toString() ); | |||||
| throw new TaskException( "File not found exception " + fnfe.toString() ); | |||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| throw new BuildException( "Unknown input/output exception " + ioe.toString() ); | |||||
| throw new TaskException( "Unknown input/output exception " + ioe.toString() ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| private void writeFile() | private void writeFile() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -248,7 +245,7 @@ public class ManifestFile extends Task | |||||
| for( int i = 0; i < size; i++ ) | for( int i = 0; i < size; i++ ) | ||||
| { | { | ||||
| fos.write( ( char )buffer.charAt( i ) ); | |||||
| fos.write( (char)buffer.charAt( i ) ); | |||||
| } | } | ||||
| fos.flush(); | fos.flush(); | ||||
| @@ -256,13 +253,13 @@ public class ManifestFile extends Task | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( "Can't create manifest file" ); | |||||
| throw new TaskException( "Can't create manifest file" ); | |||||
| } | } | ||||
| } | } | ||||
| catch( IOException ioe ) | 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 val = null; | ||||
| private String key = null; | private String key = null; | ||||
| public Entry() { } | |||||
| public Entry() | |||||
| { | |||||
| } | |||||
| public void setValue( String value ) | public void setValue( String value ) | ||||
| { | { | ||||
| @@ -298,8 +297,8 @@ public class ManifestFile extends Task | |||||
| try | try | ||||
| { | { | ||||
| Entry e1 = ( Entry )o1; | |||||
| Entry e2 = ( Entry )o2; | |||||
| Entry e1 = (Entry)o1; | |||||
| Entry e2 = (Entry)o2; | |||||
| String key_1 = e1.getKey(); | String key_1 = e1.getKey(); | ||||
| String key_2 = e2.getKey(); | String key_2 = e2.getKey(); | ||||
| @@ -313,21 +312,19 @@ public class ManifestFile extends Task | |||||
| return result; | return result; | ||||
| } | } | ||||
| public boolean equals( Object obj ) | public boolean equals( Object obj ) | ||||
| { | { | ||||
| Entry ent = new Entry(); | Entry ent = new Entry(); | ||||
| boolean result = false; | boolean result = false; | ||||
| int res = ent.compare( this, ( Entry )obj ); | |||||
| int res = ent.compare( this, (Entry)obj ); | |||||
| if( res == 0 ) | if( res == 0 ) | ||||
| result = true; | result = true; | ||||
| return result; | return result; | ||||
| } | } | ||||
| protected void addTo( EntryContainer container ) | protected void addTo( EntryContainer container ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| checkFormat(); | checkFormat(); | ||||
| split(); | split(); | ||||
| @@ -335,12 +332,12 @@ public class ManifestFile extends Task | |||||
| } | } | ||||
| private void checkFormat() | private void checkFormat() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( value == null ) | if( value == null ) | ||||
| { | { | ||||
| throw new BuildException( "no argument for value" ); | |||||
| throw new TaskException( "no argument for value" ); | |||||
| } | } | ||||
| StringTokenizer st = new StringTokenizer( value, ManifestFile.keyValueSeparator ); | StringTokenizer st = new StringTokenizer( value, ManifestFile.keyValueSeparator ); | ||||
| @@ -348,15 +345,15 @@ public class ManifestFile extends Task | |||||
| if( size < 2 ) | 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() | private void split() | ||||
| { | { | ||||
| StringTokenizer st = new StringTokenizer( value, ManifestFile.keyValueSeparator ); | StringTokenizer st = new StringTokenizer( value, ManifestFile.keyValueSeparator ); | ||||
| key = ( String )st.nextElement(); | |||||
| val = ( String )st.nextElement(); | |||||
| key = (String)st.nextElement(); | |||||
| val = (String)st.nextElement(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,8 +6,9 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.File; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | import org.apache.tools.ant.taskdefs.MatchingTask; | ||||
| @@ -34,7 +35,6 @@ public class Native2Ascii extends MatchingTask | |||||
| private Mapper mapper; | private Mapper mapper; | ||||
| /** | /** | ||||
| * Set the destination dirctory to place converted files into. | * 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). | * Defines the FileNameMapper to use (nested mapper element). | ||||
| * | * | ||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public Mapper createMapper() | public Mapper createMapper() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( mapper != null ) | 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 ); | mapper = new Mapper( project ); | ||||
| return mapper; | return mapper; | ||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Commandline baseCmd = null;// the common portion of our cmd line | Commandline baseCmd = null;// the common portion of our cmd line | ||||
| @@ -123,7 +123,7 @@ public class Native2Ascii extends MatchingTask | |||||
| // Require destDir | // Require destDir | ||||
| if( destDir == null ) | 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 | // 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 .... | // include a file with the same extension, but .... | ||||
| if( srcDir.equals( destDir ) && extension == null && mapper == null ) | 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; | FileNameMapper m = null; | ||||
| @@ -162,11 +162,11 @@ public class Native2Ascii extends MatchingTask | |||||
| return; | return; | ||||
| } | } | ||||
| String message = "Converting " + count + " file" | String message = "Converting " + count + " file" | ||||
| + ( count != 1 ? "s" : "" ) + " from "; | |||||
| + ( count != 1 ? "s" : "" ) + " from "; | |||||
| log( message + srcDir + " to " + destDir ); | log( message + srcDir + " to " + destDir ); | ||||
| for( int i = 0; i < files.length; i++ ) | 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 srcName Description of Parameter | ||||
| * @param destName 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 ) | private void convert( String srcName, String destName ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Commandline cmd = new Commandline();// Command line to run | 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 | // Make sure we're not about to clobber something | ||||
| if( srcFile.equals( destFile ) ) | 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 | // Make intermediate directories if needed | ||||
| @@ -220,26 +220,30 @@ public class Native2Ascii extends MatchingTask | |||||
| if( ( !parentFile.exists() ) && ( !parentFile.mkdirs() ) ) | 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 ); | log( "converting " + srcName, Project.MSG_VERBOSE ); | ||||
| sun.tools.native2ascii.Main n2a | sun.tools.native2ascii.Main n2a | ||||
| = new sun.tools.native2ascii.Main(); | |||||
| = new sun.tools.native2ascii.Main(); | |||||
| if( !n2a.convert( cmd.getArguments() ) ) | if( !n2a.convert( cmd.getArguments() ) ) | ||||
| { | { | ||||
| throw new BuildException( "conversion failed" ); | |||||
| throw new TaskException( "conversion failed" ); | |||||
| } | } | ||||
| } | } | ||||
| private class ExtMapper implements FileNameMapper | 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 ) | public String[] mapFileName( String fileName ) | ||||
| { | { | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
| @@ -16,11 +17,11 @@ import java.util.Properties; | |||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import netrexx.lang.Rexx; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | import org.apache.tools.ant.taskdefs.MatchingTask; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| * Task to compile NetRexx source files. This task can take the following | * 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 time; | ||||
| private boolean utf8; | private boolean utf8; | ||||
| /** | /** | ||||
| * Set whether literals are treated as binary, rather than NetRexx types | * Set whether literals are treated as binary, rather than NetRexx types | ||||
| * | * | ||||
| @@ -263,7 +263,6 @@ public class NetRexxC extends MatchingTask | |||||
| this.java = java; | this.java = java; | ||||
| } | } | ||||
| /** | /** | ||||
| * Sets whether the generated java source file should be kept after | * Sets whether the generated java source file should be kept after | ||||
| * compilation. The generated files will have an extension of .java.keep, | * compilation. The generated files will have an extension of .java.keep, | ||||
| @@ -392,7 +391,6 @@ public class NetRexxC extends MatchingTask | |||||
| this.strictprops = strictprops; | this.strictprops = strictprops; | ||||
| } | } | ||||
| /** | /** | ||||
| * Whether the compiler should force catching of exceptions by explicitly | * Whether the compiler should force catching of exceptions by explicitly | ||||
| * named types | * named types | ||||
| @@ -438,15 +436,15 @@ public class NetRexxC extends MatchingTask | |||||
| public void setTrace( String trace ) | public void setTrace( String trace ) | ||||
| { | { | ||||
| if( trace.equalsIgnoreCase( "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; | this.trace = trace; | ||||
| } | } | ||||
| else | 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 | * Executes the task, i.e. does the actual compiler call | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| // first off, make sure that we've got a srcdir and destdir | // first off, make sure that we've got a srcdir and destdir | ||||
| if( srcDir == null || destDir == null ) | 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 | // 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 | * @return The CompileClasspath value | ||||
| */ | */ | ||||
| private String getCompileClasspath() | private String getCompileClasspath() | ||||
| throws TaskException | |||||
| { | { | ||||
| StringBuffer classpath = new StringBuffer(); | StringBuffer classpath = new StringBuffer(); | ||||
| @@ -567,7 +566,7 @@ public class NetRexxC extends MatchingTask | |||||
| options.addElement( "-" + trace ); | options.addElement( "-" + trace ); | ||||
| options.addElement( utf8 ? "-utf8" : "-noutf8" ); | options.addElement( utf8 ? "-utf8" : "-noutf8" ); | ||||
| options.addElement( "-" + verbose ); | options.addElement( "-" + verbose ); | ||||
| String[] results = new String[options.size()]; | |||||
| String[] results = new String[ options.size() ]; | |||||
| options.copyInto( results ); | options.copyInto( results ); | ||||
| return results; | return results; | ||||
| } | } | ||||
| @@ -582,9 +581,10 @@ public class NetRexxC extends MatchingTask | |||||
| * @param source - source classpath to get file objects. | * @param source - source classpath to get file objects. | ||||
| */ | */ | ||||
| private void addExistingToClasspath( StringBuffer target, String source ) | private void addExistingToClasspath( StringBuffer target, String source ) | ||||
| throws TaskException | |||||
| { | { | ||||
| StringTokenizer tok = new StringTokenizer( source, | StringTokenizer tok = new StringTokenizer( source, | ||||
| System.getProperty( "path.separator" ), false ); | |||||
| System.getProperty( "path.separator" ), false ); | |||||
| while( tok.hasMoreTokens() ) | while( tok.hasMoreTokens() ) | ||||
| { | { | ||||
| File f = resolveFile( tok.nextToken() ); | File f = resolveFile( tok.nextToken() ); | ||||
| @@ -597,7 +597,7 @@ public class NetRexxC extends MatchingTask | |||||
| else | else | ||||
| { | { | ||||
| log( "Dropping from classpath: " + | 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(); | Enumeration enum = filecopyList.keys(); | ||||
| while( enum.hasMoreElements() ) | 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 | try | ||||
| { | { | ||||
| FileUtils.newFileUtils().copyFile( fromFile, toFile ); | FileUtils.newFileUtils().copyFile( fromFile, toFile ); | ||||
| @@ -625,8 +625,8 @@ public class NetRexxC extends MatchingTask | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "Failed to copy " + fromFile + " to " + toFile | String msg = "Failed to copy " + fromFile + " to " + toFile | ||||
| + " due to " + ioe.getMessage(); | |||||
| throw new BuildException( msg, ioe ); | |||||
| + " 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 | * Peforms a copmile using the NetRexx 1.1.x compiler | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void doNetRexxCompile() | private void doNetRexxCompile() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| log( "Using NetRexx compiler", Project.MSG_VERBOSE ); | log( "Using NetRexx compiler", Project.MSG_VERBOSE ); | ||||
| String classpath = getCompileClasspath(); | String classpath = getCompileClasspath(); | ||||
| @@ -648,30 +648,30 @@ public class NetRexxC extends MatchingTask | |||||
| // create an array of strings for input to the compiler: one array | // create an array of strings for input to the compiler: one array | ||||
| // comes from the compile options, the other from the compileList | // comes from the compile options, the other from the compileList | ||||
| String[] compileOptionsArray = getCompileOptionsAsArray(); | String[] compileOptionsArray = getCompileOptionsAsArray(); | ||||
| String[] fileListArray = new String[compileList.size()]; | |||||
| String[] fileListArray = new String[ compileList.size() ]; | |||||
| Enumeration e = compileList.elements(); | Enumeration e = compileList.elements(); | ||||
| int j = 0; | int j = 0; | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| fileListArray[j] = ( String )e.nextElement(); | |||||
| fileListArray[ j ] = (String)e.nextElement(); | |||||
| j++; | j++; | ||||
| } | } | ||||
| // create a single array of arguments for the compiler | // 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++ ) | for( int i = 0; i < compileOptionsArray.length; i++ ) | ||||
| { | { | ||||
| compileArgs[i] = compileOptionsArray[i]; | |||||
| compileArgs[ i ] = compileOptionsArray[ i ]; | |||||
| } | } | ||||
| for( int i = 0; i < fileListArray.length; 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 | // print nice output about what we are doing for the log | ||||
| compileOptions.append( "Compilation args: " ); | compileOptions.append( "Compilation args: " ); | ||||
| for( int i = 0; i < compileOptionsArray.length; i++ ) | for( int i = 0; i < compileOptionsArray.length; i++ ) | ||||
| { | { | ||||
| compileOptions.append( compileOptionsArray[i] ); | |||||
| compileOptions.append( compileOptionsArray[ i ] ); | |||||
| compileOptions.append( " " ); | compileOptions.append( " " ); | ||||
| } | } | ||||
| log( compileOptions.toString(), Project.MSG_VERBOSE ); | log( compileOptions.toString(), Project.MSG_VERBOSE ); | ||||
| @@ -704,7 +704,7 @@ public class NetRexxC extends MatchingTask | |||||
| {// 1 is warnings from real NetRexxC | {// 1 is warnings from real NetRexxC | ||||
| log( out.toString(), Project.MSG_ERR ); | log( out.toString(), Project.MSG_ERR ); | ||||
| String msg = "Compile failed, messages should have been provided."; | String msg = "Compile failed, messages should have been provided."; | ||||
| throw new BuildException( msg ); | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| else if( rc == 1 ) | else if( rc == 1 ) | ||||
| { | { | ||||
| @@ -736,9 +736,9 @@ public class NetRexxC extends MatchingTask | |||||
| { | { | ||||
| for( int i = 0; i < files.length; i++ ) | 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 | // if it's a non source file, copy it if a later date than the | ||||
| // dest | // dest | ||||
| // if it's a source file, see if the destination class file | // if it's a source file, see if the destination class file | ||||
| @@ -747,7 +747,7 @@ public class NetRexxC extends MatchingTask | |||||
| { | { | ||||
| File classFile = | File classFile = | ||||
| new File( destDir, | new File( destDir, | ||||
| filename.substring( 0, filename.lastIndexOf( '.' ) ) + ".class" ); | |||||
| filename.substring( 0, filename.lastIndexOf( '.' ) ) + ".class" ); | |||||
| if( !compile || srcFile.lastModified() > classFile.lastModified() ) | if( !compile || srcFile.lastModified() > classFile.lastModified() ) | ||||
| { | { | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -25,7 +26,7 @@ import java.util.Enumeration; | |||||
| import java.util.GregorianCalendar; | import java.util.GregorianCalendar; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import java.util.Vector; | 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.Task; | ||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| @@ -178,7 +179,7 @@ public class PropertyFile extends Task | |||||
| * Methods | * Methods | ||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| checkParameters(); | checkParameters(); | ||||
| readFile(); | readFile(); | ||||
| @@ -200,26 +201,26 @@ public class PropertyFile extends Task | |||||
| } | } | ||||
| private void checkParameters() | private void checkParameters() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( !checkParam( m_propertyfile ) ) | 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() | 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 ); | entry.executeOn( m_properties ); | ||||
| } | } | ||||
| } | } | ||||
| private void readFile() | private void readFile() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| // Create the PropertyFile | // Create the PropertyFile | ||||
| m_properties = new Properties(); | m_properties = new Properties(); | ||||
| @@ -246,7 +247,7 @@ public class PropertyFile extends Task | |||||
| else | else | ||||
| { | { | ||||
| log( "Creating new property file: " + | log( "Creating new property file: " + | ||||
| m_propertyfile.getAbsolutePath() ); | |||||
| m_propertyfile.getAbsolutePath() ); | |||||
| FileOutputStream out = null; | FileOutputStream out = null; | ||||
| try | try | ||||
| { | { | ||||
| @@ -264,12 +265,12 @@ public class PropertyFile extends Task | |||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| throw new BuildException( ioe.toString() ); | |||||
| throw new TaskException( ioe.toString() ); | |||||
| } | } | ||||
| } | } | ||||
| private void writeFile() | private void writeFile() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| BufferedOutputStream bos = null; | BufferedOutputStream bos = null; | ||||
| try | try | ||||
| @@ -279,10 +280,10 @@ public class PropertyFile extends Task | |||||
| // Properties.store is not available in JDK 1.1 | // Properties.store is not available in JDK 1.1 | ||||
| Method m = | Method m = | ||||
| Properties.class.getMethod( "store", | 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} ); | m.invoke( m_properties, new Object[]{bos, m_comment} ); | ||||
| } | } | ||||
| @@ -293,16 +294,16 @@ public class PropertyFile extends Task | |||||
| catch( InvocationTargetException ite ) | catch( InvocationTargetException ite ) | ||||
| { | { | ||||
| Throwable t = ite.getTargetException(); | Throwable t = ite.getTargetException(); | ||||
| throw new BuildException( "Error", t ); | |||||
| throw new TaskException( "Error", t ); | |||||
| } | } | ||||
| catch( IllegalAccessException iae ) | catch( IllegalAccessException iae ) | ||||
| { | { | ||||
| // impossible | // impossible | ||||
| throw new BuildException( "Error", iae ); | |||||
| throw new TaskException( "Error", iae ); | |||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| throw new BuildException( "Error", ioe ); | |||||
| throw new TaskException( "Error", ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -313,7 +314,8 @@ public class PropertyFile extends Task | |||||
| bos.close(); | bos.close(); | ||||
| } | } | ||||
| catch( IOException ioex ) | catch( IOException ioex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -385,7 +387,7 @@ public class PropertyFile extends Task | |||||
| } | } | ||||
| protected void executeOn( Properties props ) | protected void executeOn( Properties props ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| checkParameters(); | checkParameters(); | ||||
| @@ -394,19 +396,19 @@ public class PropertyFile extends Task | |||||
| { | { | ||||
| if( m_type == Type.INTEGER_TYPE ) | 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 ) | 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 ) | else if( m_type == Type.STRING_TYPE ) | ||||
| { | { | ||||
| executeString( ( String )props.get( m_key ) ); | |||||
| executeString( (String)props.get( m_key ) ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( "Unknown operation type: " + m_type + "" ); | |||||
| throw new TaskException( "Unknown operation type: " + m_type + "" ); | |||||
| } | } | ||||
| } | } | ||||
| catch( NullPointerException npe ) | catch( NullPointerException npe ) | ||||
| @@ -423,28 +425,28 @@ public class PropertyFile extends Task | |||||
| /** | /** | ||||
| * Check if parameter combinations can be supported | * Check if parameter combinations can be supported | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void checkParameters() | private void checkParameters() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( m_type == Type.STRING_TYPE && | if( m_type == Type.STRING_TYPE && | ||||
| m_operation == Operation.DECREMENT_OPER ) | 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 ) | 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 ) | if( m_key == null ) | ||||
| { | { | ||||
| throw new BuildException( "key is mandatory" ); | |||||
| throw new TaskException( "key is mandatory" ); | |||||
| } | } | ||||
| if( m_type == Type.STRING_TYPE && | if( m_type == Type.STRING_TYPE && | ||||
| m_pattern != null ) | 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 | * @param oldValue the current value read from the property file or | ||||
| * <code>null</code> if the <code>key</code> was not contained in | * <code>null</code> if the <code>key</code> was not contained in | ||||
| * the property file. | * the property file. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void executeDate( String oldValue ) | private void executeDate( String oldValue ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| GregorianCalendar value = new GregorianCalendar(); | GregorianCalendar value = new GregorianCalendar(); | ||||
| GregorianCalendar newValue = new GregorianCalendar(); | GregorianCalendar newValue = new GregorianCalendar(); | ||||
| @@ -577,23 +579,22 @@ public class PropertyFile extends Task | |||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Handle operations for type <code>int</code>. | * Handle operations for type <code>int</code>. | ||||
| * | * | ||||
| * @param oldValue the current value read from the property file or | * @param oldValue the current value read from the property file or | ||||
| * <code>null</code> if the <code>key</code> was not contained in | * <code>null</code> if the <code>key</code> was not contained in | ||||
| * the property file. | * the property file. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void executeInteger( String oldValue ) | private void executeInteger( String oldValue ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| int value = 0; | int value = 0; | ||||
| int newValue = 0; | int newValue = 0; | ||||
| DecimalFormat fmt = ( m_pattern != null ) ? new DecimalFormat( m_pattern ) | DecimalFormat fmt = ( m_pattern != null ) ? new DecimalFormat( m_pattern ) | ||||
| : new DecimalFormat(); | |||||
| : new DecimalFormat(); | |||||
| if( oldValue != null ) | if( oldValue != null ) | ||||
| { | { | ||||
| @@ -674,10 +675,10 @@ public class PropertyFile extends Task | |||||
| * @param oldValue the current value read from the property file or | * @param oldValue the current value read from the property file or | ||||
| * <code>null</code> if the <code>key</code> was not contained in | * <code>null</code> if the <code>key</code> was not contained in | ||||
| * the property file. | * the property file. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void executeString( String oldValue ) | private void executeString( String oldValue ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| String value = ""; | String value = ""; | ||||
| String newValue = ""; | String newValue = ""; | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -14,9 +15,8 @@ import java.io.FileWriter; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.LineNumberReader; | import java.io.LineNumberReader; | ||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
| import java.util.Random; | |||||
| import java.util.Vector; | 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.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -117,18 +117,20 @@ public class ReplaceRegExp extends Task | |||||
| } | } | ||||
| public void setMatch( String match ) | public void setMatch( String match ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( regex != null ) | 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 = new RegularExpression(); | ||||
| regex.setPattern( match ); | regex.setPattern( match ); | ||||
| } | } | ||||
| public void setReplace( String replace ) | public void setReplace( String replace ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( subs != null ) | 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 = new Substitution(); | ||||
| subs.setExpression( replace ); | subs.setExpression( replace ); | ||||
| @@ -140,33 +142,35 @@ public class ReplaceRegExp extends Task | |||||
| } | } | ||||
| public RegularExpression createRegularExpression() | public RegularExpression createRegularExpression() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( regex != null ) | 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 = new RegularExpression(); | ||||
| return regex; | return regex; | ||||
| } | } | ||||
| public Substitution createSubstitution() | public Substitution createSubstitution() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( subs != null ) | 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 = new Substitution(); | ||||
| return subs; | return subs; | ||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( regex == null ) | if( regex == null ) | ||||
| throw new BuildException( "No expression to match." ); | |||||
| throw new TaskException( "No expression to match." ); | |||||
| if( subs == null ) | 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 ) | 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; | int options = 0; | ||||
| @@ -191,25 +195,25 @@ public class ReplaceRegExp extends Task | |||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| log( "An error occurred processing file: '" + file.getAbsolutePath() + "': " + e.toString(), | log( "An error occurred processing file: '" + file.getAbsolutePath() + "': " + e.toString(), | ||||
| Project.MSG_ERR ); | |||||
| Project.MSG_ERR ); | |||||
| } | } | ||||
| } | } | ||||
| else if( file != null ) | else if( file != null ) | ||||
| { | { | ||||
| log( "The following file is missing: '" + file.getAbsolutePath() + "'", | log( "The following file is missing: '" + file.getAbsolutePath() + "'", | ||||
| Project.MSG_ERR ); | |||||
| Project.MSG_ERR ); | |||||
| } | } | ||||
| int sz = filesets.size(); | int sz = filesets.size(); | ||||
| for( int i = 0; i < sz; i++ ) | for( int i = 0; i < sz; i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )( filesets.elementAt( i ) ); | |||||
| FileSet fs = (FileSet)( filesets.elementAt( i ) ); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); | ||||
| String files[] = ds.getIncludedFiles(); | String files[] = ds.getIncludedFiles(); | ||||
| for( int j = 0; j < files.length; j++ ) | for( int j = 0; j < files.length; j++ ) | ||||
| { | { | ||||
| File f = new File( files[j] ); | |||||
| File f = new File( files[ j ] ); | |||||
| if( f.exists() ) | if( f.exists() ) | ||||
| { | { | ||||
| try | try | ||||
| @@ -219,19 +223,18 @@ public class ReplaceRegExp extends Task | |||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| log( "An error occurred processing file: '" + f.getAbsolutePath() + "': " + e.toString(), | log( "An error occurred processing file: '" + f.getAbsolutePath() + "': " + e.toString(), | ||||
| Project.MSG_ERR ); | |||||
| Project.MSG_ERR ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| log( "The following file is missing: '" + file.getAbsolutePath() + "'", | log( "The following file is missing: '" + file.getAbsolutePath() + "'", | ||||
| Project.MSG_ERR ); | |||||
| Project.MSG_ERR ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| protected String doReplace( RegularExpression r, | protected String doReplace( RegularExpression r, | ||||
| Substitution s, | Substitution s, | ||||
| String input, | String input, | ||||
| @@ -276,11 +279,11 @@ public class ReplaceRegExp extends Task | |||||
| boolean changes = false; | boolean changes = false; | ||||
| log( "Replacing pattern '" + regex.getPattern( project ) + "' with '" + subs.getExpression( project ) + | 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 ) | if( byline ) | ||||
| { | { | ||||
| @@ -299,8 +302,8 @@ public class ReplaceRegExp extends Task | |||||
| } | } | ||||
| else | 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 numread = 0; | ||||
| int totread = 0; | int totread = 0; | ||||
| while( numread != -1 && totread < flen ) | while( numread != -1 && totread < flen ) | ||||
| @@ -342,7 +345,8 @@ public class ReplaceRegExp extends Task | |||||
| r.close(); | r.close(); | ||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| ; | ; | ||||
| try | try | ||||
| @@ -351,7 +355,8 @@ public class ReplaceRegExp extends Task | |||||
| r.close(); | r.close(); | ||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| ; | ; | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,13 +6,14 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.taskdefs.Execute; | import org.apache.tools.ant.taskdefs.Execute; | ||||
| @@ -102,7 +103,7 @@ public class Rpm extends Task | |||||
| { | { | ||||
| if( ( sf == null ) || ( sf.trim().equals( "" ) ) ) | if( ( sf == null ) || ( sf.trim().equals( "" ) ) ) | ||||
| { | { | ||||
| throw new BuildException( "You must specify a spec file" ); | |||||
| throw new TaskException( "You must specify a spec file" ); | |||||
| } | } | ||||
| this.specFile = sf; | this.specFile = sf; | ||||
| } | } | ||||
| @@ -113,7 +114,7 @@ public class Rpm extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Commandline toExecute = new Commandline(); | Commandline toExecute = new Commandline(); | ||||
| @@ -148,7 +149,7 @@ public class Rpm extends Task | |||||
| if( error == null && output == null ) | if( error == null && output == null ) | ||||
| { | { | ||||
| streamhandler = new LogStreamHandler( this, Project.MSG_INFO, | streamhandler = new LogStreamHandler( this, Project.MSG_INFO, | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -160,7 +161,7 @@ public class Rpm extends Task | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -175,7 +176,7 @@ public class Rpm extends Task | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -200,7 +201,7 @@ public class Rpm extends Task | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -211,7 +212,8 @@ public class Rpm extends Task | |||||
| outputstream.close(); | outputstream.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( error != null ) | if( error != null ) | ||||
| { | { | ||||
| @@ -220,7 +222,8 @@ public class Rpm extends Task | |||||
| errorstream.close(); | errorstream.close(); | ||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import com.ibm.bsf.BSFException; | import com.ibm.bsf.BSFException; | ||||
| import com.ibm.bsf.BSFManager; | import com.ibm.bsf.BSFManager; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -13,7 +14,7 @@ import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| /** | /** | ||||
| @@ -46,10 +47,10 @@ public class Script extends Task | |||||
| { | { | ||||
| File file = new File( fileName ); | File file = new File( fileName ); | ||||
| if( !file.exists() ) | 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 | try | ||||
| { | { | ||||
| @@ -59,7 +60,7 @@ public class Script extends Task | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| script += new String( data ); | script += new String( data ); | ||||
| @@ -78,10 +79,10 @@ public class Script extends Task | |||||
| /** | /** | ||||
| * Do the work. | * Do the work. | ||||
| * | * | ||||
| * @exception BuildException if someting goes wrong with the build | |||||
| * @exception TaskException if someting goes wrong with the build | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -96,9 +97,9 @@ public class Script extends Task | |||||
| BSFManager manager = new BSFManager(); | 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 ); | Object value = beans.get( key ); | ||||
| manager.declareBean( key, value, value.getClass() ); | manager.declareBean( key, value, value.getClass() ); | ||||
| } | } | ||||
| @@ -112,16 +113,16 @@ public class Script extends Task | |||||
| Throwable te = be.getTargetException(); | Throwable te = be.getTargetException(); | ||||
| if( te != null ) | if( te != null ) | ||||
| { | { | ||||
| if( te instanceof BuildException ) | |||||
| if( te instanceof TaskException ) | |||||
| { | { | ||||
| throw ( BuildException )te; | |||||
| throw (TaskException)te; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| t = te; | 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 ) | 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 && | boolean isValid = key.length() > 0 && | ||||
| Character.isJavaIdentifierStart( key.charAt( 0 ) ); | Character.isJavaIdentifierStart( key.charAt( 0 ) ); | ||||
| @@ -6,8 +6,9 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.File; | import java.io.File; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.taskdefs.Java; | import org.apache.tools.ant.taskdefs.Java; | ||||
| /** | /** | ||||
| @@ -18,7 +19,7 @@ import org.apache.tools.ant.taskdefs.Java; | |||||
| * Börger</a> | * Börger</a> | ||||
| */ | */ | ||||
| public class StyleBook | public class StyleBook | ||||
| extends Java | |||||
| extends Java | |||||
| { | { | ||||
| protected File m_book; | protected File m_book; | ||||
| protected String m_loaderConfig; | protected String m_loaderConfig; | ||||
| @@ -53,22 +54,22 @@ public class StyleBook | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( null == m_targetDirectory ) | if( null == m_targetDirectory ) | ||||
| { | { | ||||
| throw new BuildException( "TargetDirectory attribute not set." ); | |||||
| throw new TaskException( "TargetDirectory attribute not set." ); | |||||
| } | } | ||||
| if( null == m_skinDirectory ) | if( null == m_skinDirectory ) | ||||
| { | { | ||||
| throw new BuildException( "SkinDirectory attribute not set." ); | |||||
| throw new TaskException( "SkinDirectory attribute not set." ); | |||||
| } | } | ||||
| if( null == m_book ) | if( null == m_book ) | ||||
| { | { | ||||
| throw new BuildException( "book attribute not set." ); | |||||
| throw new TaskException( "book attribute not set." ); | |||||
| } | } | ||||
| createArg().setValue( "targetDirectory=" + m_targetDirectory ); | createArg().setValue( "targetDirectory=" + m_targetDirectory ); | ||||