diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/AntClassLoader.java b/proposal/myrmidon/src/main/org/apache/tools/ant/AntClassLoader.java index d2ef10528..e7a1ef558 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/AntClassLoader.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/AntClassLoader.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -20,7 +21,9 @@ import java.util.Hashtable; import java.util.Vector; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.util.FileUtils; /** * Used to load classes within ant with a different claspath from that used to @@ -97,24 +100,25 @@ public class AntClassLoader extends ClassLoader implements BuildListener * The project to which this class loader belongs. */ private Project project; + static { try { - getProtectionDomain = Class.class.getMethod( "getProtectionDomain", new Class[0] ); + getProtectionDomain = Class.class.getMethod( "getProtectionDomain", new Class[ 0 ] ); Class protectionDomain = Class.forName( "java.security.ProtectionDomain" ); Class[] args = new Class[]{String.class, byte[].class, Integer.TYPE, Integer.TYPE, protectionDomain}; defineClassProtectionDomain = ClassLoader.class.getDeclaredMethod( "defineClass", args ); - getContextClassLoader = Thread.class.getMethod( "getContextClassLoader", new Class[0] ); + getContextClassLoader = Thread.class.getMethod( "getContextClassLoader", new Class[ 0 ] ); args = new Class[]{ClassLoader.class}; setContextClassLoader = Thread.class.getMethod( "setContextClassLoader", args ); } catch( Exception e ) - {} + { + } } - /** * Create a classloader for the given project using the classpath given. * @@ -136,7 +140,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { try { - addPathElement( ( String )pathElements[i] ); + addPathElement( (String)pathElements[ i ] ); } catch( BuildException e ) { @@ -169,7 +173,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener addSystemPackageRoot( "javax" ); } - /** * Create a classloader for the given project using the classpath given. * @@ -243,17 +246,18 @@ public class AntClassLoader extends ClassLoader implements BuildListener * current loader value for later resetting */ public void setThreadContextLoader() + throws TaskException { if( isContextLoaderSaved ) { - throw new BuildException( "Context loader has not been reset" ); + throw new TaskException( "Context loader has not been reset" ); } if( getContextClassLoader != null && setContextClassLoader != null ) { try { savedContextLoader - = ( ClassLoader )getContextClassLoader.invoke( Thread.currentThread(), new Object[0] ); + = (ClassLoader)getContextClassLoader.invoke( Thread.currentThread(), new Object[ 0 ] ); Object[] args = new Object[]{this}; setContextClassLoader.invoke( Thread.currentThread(), args ); isContextLoaderSaved = true; @@ -261,11 +265,11 @@ public class AntClassLoader extends ClassLoader implements BuildListener catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); - throw new BuildException( t.toString() ); + throw new TaskException( t.toString() ); } catch( Exception e ) { - throw new BuildException( e.toString() ); + throw new TaskException( e.toString() ); } } } @@ -293,22 +297,22 @@ public class AntClassLoader extends ClassLoader implements BuildListener if( url != null ) { log( "Resource " + name + " loaded from parent loader", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } else { // try and load from this loader if the parent either didn't find // it or wasn't consulted. - for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && url == null; ) + for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && url == null; ) { - File pathComponent = ( File )e.nextElement(); + File pathComponent = (File)e.nextElement(); url = getResourceURL( pathComponent, name ); if( url != null ) { log( "Resource " + name + " loaded from ant loader", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } } } @@ -321,7 +325,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener if( url != null ) { log( "Resource " + name + " loaded from parent loader", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } } @@ -386,7 +390,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener if( resourceStream == null ) { log( "Couldn't load ResourceStream for " + name, - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } return resourceStream; @@ -403,7 +407,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener loaderPackages.addElement( packageRoot + "." ); } - /** * Add an element to the classpath to be searched * @@ -414,8 +417,8 @@ public class AntClassLoader extends ClassLoader implements BuildListener throws BuildException { File pathComponent - = project != null ? project.resolveFile( pathElement ) - : new File( pathElement ); + = project != null ? FileUtils.newFileUtils().resolveFile( project.getBaseDir(), pathElement ) + : new File( pathElement ); pathComponents.addElement( pathComponent ); } @@ -435,15 +438,17 @@ public class AntClassLoader extends ClassLoader implements BuildListener cleanup(); } - public void buildStarted( BuildEvent event ) { } + public void buildStarted( BuildEvent event ) + { + } public void cleanup() { pathComponents = null; project = null; - for( Enumeration e = zipFiles.elements(); e.hasMoreElements(); ) + for( Enumeration e = zipFiles.elements(); e.hasMoreElements(); ) { - ZipFile zipFile = ( ZipFile )e.nextElement(); + ZipFile zipFile = (ZipFile)e.nextElement(); try { zipFile.close(); @@ -472,7 +477,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener return findClassInComponents( name ); } - /** * Load a class through this class loader even if that class is available on * the parent classpath. This ensures that any classes which are loaded by @@ -524,12 +528,15 @@ public class AntClassLoader extends ClassLoader implements BuildListener return theClass; } - public void messageLogged( BuildEvent event ) { } + public void messageLogged( BuildEvent event ) + { + } /** * Reset the current thread's context loader to its original value */ public void resetThreadContextLoader() + throws TaskException { if( isContextLoaderSaved && getContextClassLoader != null && setContextClassLoader != null ) @@ -544,22 +551,30 @@ public class AntClassLoader extends ClassLoader implements BuildListener catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); - throw new BuildException( t.toString() ); + throw new TaskException( t.toString() ); } catch( Exception e ) { - throw new BuildException( e.toString() ); + throw new TaskException( e.toString() ); } } } - public void targetFinished( BuildEvent event ) { } + public void targetFinished( BuildEvent event ) + { + } - public void targetStarted( BuildEvent event ) { } + public void targetStarted( BuildEvent event ) + { + } - public void taskFinished( BuildEvent event ) { } + public void taskFinished( BuildEvent event ) + { + } - public void taskStarted( BuildEvent event ) { } + public void taskStarted( BuildEvent event ) + { + } /** * Returns an enumeration of URLs representing all the resources with the @@ -575,7 +590,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener return new ResourceEnumeration( name ); } - /** * Load a class with this class loader. This method will load a class. This * class attempts to load the class firstly using the parent class loader. @@ -649,9 +663,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener { project.log( message, priority ); } -// else { -// System.out.println(message); -// } + // else { + // System.out.println(message); + // } } /** @@ -680,7 +694,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int bytesRead = -1; - byte[] buffer = new byte[BUFFER_SIZE]; + byte[] buffer = new byte[ BUFFER_SIZE ]; while( ( bytesRead = stream.read( buffer, 0, BUFFER_SIZE ) ) != -1 ) { @@ -696,20 +710,20 @@ public class AntClassLoader extends ClassLoader implements BuildListener { try { - Object domain = getProtectionDomain.invoke( Project.class, new Object[0] ); + Object domain = getProtectionDomain.invoke( Project.class, new Object[ 0 ] ); Object[] args = new Object[]{classname, classData, new Integer( 0 ), new Integer( classData.length ), domain}; - return ( Class )defineClassProtectionDomain.invoke( this, args ); + return (Class)defineClassProtectionDomain.invoke( this, args ); } catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); if( t instanceof ClassFormatError ) { - throw ( ClassFormatError )t; + throw (ClassFormatError)t; } else if( t instanceof NoClassDefFoundError ) { - throw ( NoClassDefFoundError )t; + throw (NoClassDefFoundError)t; } else { @@ -759,7 +773,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener else { // is the zip file in the cache - ZipFile zipFile = ( ZipFile )zipFiles.get( file ); + ZipFile zipFile = (ZipFile)zipFiles.get( file ); if( zipFile == null ) { zipFile = new ZipFile( file ); @@ -775,7 +789,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener catch( Exception e ) { log( "Ignoring Exception " + e.getClass().getName() + ": " + e.getMessage() + - " reading resource " + resourceName + " from " + file, Project.MSG_VERBOSE ); + " reading resource " + resourceName + " from " + file, Project.MSG_VERBOSE ); } return null; @@ -819,7 +833,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener } else { - ZipFile zipFile = ( ZipFile )zipFiles.get( file ); + ZipFile zipFile = (ZipFile)zipFiles.get( file ); if( zipFile == null ) { zipFile = new ZipFile( file ); @@ -855,9 +869,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener // designated to use a specific loader first (this one or the parent one) boolean useParentFirst = parentFirst; - for( Enumeration e = systemPackages.elements(); e.hasMoreElements(); ) + for( Enumeration e = systemPackages.elements(); e.hasMoreElements(); ) { - String packageName = ( String )e.nextElement(); + String packageName = (String)e.nextElement(); if( resourceName.startsWith( packageName ) ) { useParentFirst = true; @@ -865,9 +879,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener } } - for( Enumeration e = loaderPackages.elements(); e.hasMoreElements(); ) + for( Enumeration e = loaderPackages.elements(); e.hasMoreElements(); ) { - String packageName = ( String )e.nextElement(); + String packageName = (String)e.nextElement(); if( resourceName.startsWith( packageName ) ) { useParentFirst = false; @@ -899,7 +913,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener } } - /** * Find a class on the given classpath. * @@ -916,9 +929,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener String classFilename = getClassFilename( name ); try { - for( Enumeration e = pathComponents.elements(); e.hasMoreElements(); ) + for( Enumeration e = pathComponents.elements(); e.hasMoreElements(); ) { - File pathComponent = ( File )e.nextElement(); + File pathComponent = (File)e.nextElement(); try { stream = getResourceStream( pathComponent, classFilename ); @@ -946,7 +959,8 @@ public class AntClassLoader extends ClassLoader implements BuildListener } } catch( IOException e ) - {} + { + } } } @@ -969,7 +983,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener } } - /** * Get a stream to read the requested resource name from this loader. * @@ -983,9 +996,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener // class we want. InputStream stream = null; - for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && stream == null; ) + for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && stream == null; ) { - File pathComponent = ( File )e.nextElement(); + File pathComponent = (File)e.nextElement(); stream = getResourceStream( pathComponent, name ); } return stream; @@ -1073,11 +1086,11 @@ public class AntClassLoader extends ClassLoader implements BuildListener try { File pathComponent - = ( File )pathComponents.elementAt( pathElementsIndex ); + = (File)pathComponents.elementAt( pathElementsIndex ); url = getResourceURL( pathComponent, this.resourceName ); pathElementsIndex++; } - catch( BuildException e ) + catch( TaskException e ) { // ignore path elements which are not valid relative to the project } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/BuildException.java b/proposal/myrmidon/src/main/org/apache/tools/ant/BuildException.java index a22ef8933..74304cb93 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/BuildException.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/BuildException.java @@ -44,43 +44,6 @@ public class BuildException super( msg, cause ); } - /** - * Constructs an exception with the given message and exception as a root - * cause and a location in a file. - * - * @param msg Description of or information about the exception. - * @param cause Exception that might have cause this one. - * @param location Location in the project file where the error occured. - */ - public BuildException( String msg, Throwable cause, Location location ) - { - this( msg, cause ); - this.location = location; - } - - /** - * Constructs an exception with the given exception as a root cause. - * - * @param cause Exception that might have caused this one. - */ - public BuildException( Throwable cause ) - { - super( cause.toString(), cause ); - } - - /** - * Constructs an exception with the given descriptive message and a location - * in a file. - * - * @param msg Description of or information about the exception. - * @param location Location in the project file where the error occured. - */ - public BuildException( String msg, Location location ) - { - super( msg ); - this.location = location; - } - /** * Sets the file location where the error occured. * diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/DesirableFilter.java b/proposal/myrmidon/src/main/org/apache/tools/ant/DesirableFilter.java deleted file mode 100644 index a53315fa2..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/DesirableFilter.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE file. - */ -package org.apache.tools.ant; -import java.io.File; -import java.io.FilenameFilter; - - -/** - * Filters filenames to determine whether or not the file is desirable. - * - * @author Jason Hunter [jhunter@servlets.com] - * @author james@x180.com - */ -public class DesirableFilter implements FilenameFilter -{ - - /** - * Test the given filename to determine whether or not it's desirable. This - * helps tasks filter temp files and files used by CVS. - * - * @param dir Description of Parameter - * @param name Description of Parameter - * @return Description of the Returned Value - */ - - public boolean accept( File dir, String name ) - { - - // emacs save file - if( name.endsWith( "~" ) ) - { - return false; - } - - // emacs autosave file - if( name.startsWith( "#" ) && name.endsWith( "#" ) ) - { - return false; - } - - // openwindows text editor does this I think - if( name.startsWith( "%" ) && name.endsWith( "%" ) ) - { - return false; - } - - /* - * CVS stuff -- hopefully there won't be a case with - * an all cap file/dir named "CVS" that somebody wants - * to keep around... - */ - if( name.equals( "CVS" ) ) - { - return false; - } - - /* - * If we are going to ignore CVS might as well ignore - * this one as well... - */ - if( name.equals( ".cvsignore" ) ) - { - return false; - } - - // CVS merge autosaves. - if( name.startsWith( ".#" ) ) - { - return false; - } - - // SCCS/CSSC/TeamWare: - if( name.equals( "SCCS" ) ) - { - return false; - } - - // Visual Source Save - if( name.equals( "vssver.scc" ) ) - { - return false; - } - - // default - return true; - } -} - - - - diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/DirectoryScanner.java b/proposal/myrmidon/src/main/org/apache/tools/ant/DirectoryScanner.java index 7d95dd304..c16a43057 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/DirectoryScanner.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/DirectoryScanner.java @@ -6,9 +6,11 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.io.File; import java.util.StringTokenizer; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; /** * Class for scanning a directory for files/directories that match a certain @@ -105,7 +107,7 @@ public class DirectoryScanner implements FileScanner "**/SCCS", "**/SCCS/**", "**/vssver.scc" - }; + }; /** * Have the Vectors holding our results been built by a slow scan? @@ -174,8 +176,9 @@ public class DirectoryScanner implements FileScanner /** * Constructor. */ - public DirectoryScanner() { } - + public DirectoryScanner() + { + } /** * Matches a string against a pattern. The pattern contains two special @@ -192,7 +195,6 @@ public class DirectoryScanner implements FileScanner return match( pattern, str, true ); } - /** * Matches a string against a pattern. The pattern contains two special * characters: '*' which means zero or more characters, '?' which means one @@ -217,7 +219,7 @@ public class DirectoryScanner implements FileScanner boolean containsStar = false; for( int i = 0; i < patArr.length; i++ ) { - if( patArr[i] == '*' ) + if( patArr[ i ] == '*' ) { containsStar = true; break; @@ -233,15 +235,15 @@ public class DirectoryScanner implements FileScanner } for( int i = 0; i <= patIdxEnd; i++ ) { - ch = patArr[i]; + ch = patArr[ i ]; if( ch != '?' ) { - if( isCaseSensitive && ch != strArr[i] ) + if( isCaseSensitive && ch != strArr[ i ] ) { return false;// Character mismatch } if( !isCaseSensitive && Character.toUpperCase( ch ) != - Character.toUpperCase( strArr[i] ) ) + Character.toUpperCase( strArr[ i ] ) ) { return false;// Character mismatch } @@ -256,16 +258,16 @@ public class DirectoryScanner implements FileScanner } // Process characters before first star - while( ( ch = patArr[patIdxStart] ) != '*' && strIdxStart <= strIdxEnd ) + while( ( ch = patArr[ patIdxStart ] ) != '*' && strIdxStart <= strIdxEnd ) { if( ch != '?' ) { - if( isCaseSensitive && ch != strArr[strIdxStart] ) + if( isCaseSensitive && ch != strArr[ strIdxStart ] ) { return false;// Character mismatch } if( !isCaseSensitive && Character.toUpperCase( ch ) != - Character.toUpperCase( strArr[strIdxStart] ) ) + Character.toUpperCase( strArr[ strIdxStart ] ) ) { return false;// Character mismatch } @@ -279,7 +281,7 @@ public class DirectoryScanner implements FileScanner // left in the pattern. If so, we succeeded. Otherwise failure. for( int i = patIdxStart; i <= patIdxEnd; i++ ) { - if( patArr[i] != '*' ) + if( patArr[ i ] != '*' ) { return false; } @@ -288,16 +290,16 @@ public class DirectoryScanner implements FileScanner } // Process characters after last star - while( ( ch = patArr[patIdxEnd] ) != '*' && strIdxStart <= strIdxEnd ) + while( ( ch = patArr[ patIdxEnd ] ) != '*' && strIdxStart <= strIdxEnd ) { if( ch != '?' ) { - if( isCaseSensitive && ch != strArr[strIdxEnd] ) + if( isCaseSensitive && ch != strArr[ strIdxEnd ] ) { return false;// Character mismatch } if( !isCaseSensitive && Character.toUpperCase( ch ) != - Character.toUpperCase( strArr[strIdxEnd] ) ) + Character.toUpperCase( strArr[ strIdxEnd ] ) ) { return false;// Character mismatch } @@ -311,7 +313,7 @@ public class DirectoryScanner implements FileScanner // left in the pattern. If so, we succeeded. Otherwise failure. for( int i = patIdxStart; i <= patIdxEnd; i++ ) { - if( patArr[i] != '*' ) + if( patArr[ i ] != '*' ) { return false; } @@ -326,7 +328,7 @@ public class DirectoryScanner implements FileScanner int patIdxTmp = -1; for( int i = patIdxStart + 1; i <= patIdxEnd; i++ ) { - if( patArr[i] == '*' ) + if( patArr[ i ] == '*' ) { patIdxTmp = i; break; @@ -348,15 +350,15 @@ public class DirectoryScanner implements FileScanner { for( int j = 0; j < patLength; j++ ) { - ch = patArr[patIdxStart + j + 1]; + ch = patArr[ patIdxStart + j + 1 ]; if( ch != '?' ) { - if( isCaseSensitive && ch != strArr[strIdxStart + i + j] ) + if( isCaseSensitive && ch != strArr[ strIdxStart + i + j ] ) { continue strLoop; } if( !isCaseSensitive && Character.toUpperCase( ch ) != - Character.toUpperCase( strArr[strIdxStart + i + j] ) ) + Character.toUpperCase( strArr[ strIdxStart + i + j ] ) ) { continue strLoop; } @@ -380,7 +382,7 @@ public class DirectoryScanner implements FileScanner // in the pattern. If so, we succeeded. Otherwise failure. for( int i = patIdxStart; i <= patIdxEnd; i++ ) { - if( patArr[i] != '*' ) + if( patArr[ i ] != '*' ) { return false; } @@ -444,12 +446,12 @@ public class DirectoryScanner implements FileScanner // up to first '**' while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) { - String patDir = ( String )patDirs.elementAt( patIdxStart ); + String patDir = (String)patDirs.elementAt( patIdxStart ); if( patDir.equals( "**" ) ) { break; } - if( !match( patDir, ( String )strDirs.elementAt( strIdxStart ), isCaseSensitive ) ) + if( !match( patDir, (String)strDirs.elementAt( strIdxStart ), isCaseSensitive ) ) { return false; } @@ -480,12 +482,12 @@ public class DirectoryScanner implements FileScanner // up to last '**' while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) { - String patDir = ( String )patDirs.elementAt( patIdxEnd ); + String patDir = (String)patDirs.elementAt( patIdxEnd ); if( patDir.equals( "**" ) ) { break; } - if( !match( patDir, ( String )strDirs.elementAt( strIdxEnd ), isCaseSensitive ) ) + if( !match( patDir, (String)strDirs.elementAt( strIdxEnd ), isCaseSensitive ) ) { return false; } @@ -532,8 +534,8 @@ public class DirectoryScanner implements FileScanner { for( int j = 0; j < patLength; j++ ) { - String subPat = ( String )patDirs.elementAt( patIdxStart + j + 1 ); - String subStr = ( String )strDirs.elementAt( strIdxStart + i + j ); + String subPat = (String)patDirs.elementAt( patIdxStart + j + 1 ); + String subStr = (String)strDirs.elementAt( strIdxStart + i + j ); if( !match( subPat, subStr, isCaseSensitive ) ) { continue strLoop; @@ -564,7 +566,6 @@ public class DirectoryScanner implements FileScanner return true; } - /** * Does the path match the start of this pattern up to the first "**".
*
@@ -630,12 +631,12 @@ public class DirectoryScanner implements FileScanner
// up to first '**'
while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd )
{
- String patDir = ( String )patDirs.elementAt( patIdxStart );
+ String patDir = (String)patDirs.elementAt( patIdxStart );
if( patDir.equals( "**" ) )
{
break;
}
- if( !match( patDir, ( String )strDirs.elementAt( strIdxStart ), isCaseSensitive ) )
+ if( !match( patDir, (String)strDirs.elementAt( strIdxStart ), isCaseSensitive ) )
{
return false;
}
@@ -661,7 +662,6 @@ public class DirectoryScanner implements FileScanner
}
}
-
/**
* Sets the basedir for scanning. This is the directory that is scanned
* recursively. All '/' and '\' characters are replaced by File.separatorChar
@@ -674,7 +674,6 @@ public class DirectoryScanner implements FileScanner
setBasedir( new File( basedir.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ) ) );
}
-
/**
* Sets the basedir for scanning. This is the directory that is scanned
* recursively.
@@ -686,7 +685,6 @@ public class DirectoryScanner implements FileScanner
this.basedir = basedir;
}
-
/**
* Sets the case sensitivity of the file system
*
@@ -697,7 +695,6 @@ public class DirectoryScanner implements FileScanner
this.isCaseSensitive = isCaseSensitive;
}
-
/**
* Sets the set of exclude patterns to use. All '/' and '\' characters are
* replaced by File.separatorChar
. So the separator used need
@@ -715,16 +712,16 @@ public class DirectoryScanner implements FileScanner
}
else
{
- this.excludes = new String[excludes.length];
+ this.excludes = new String[ excludes.length ];
for( int i = 0; i < excludes.length; i++ )
{
String pattern;
- pattern = excludes[i].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
+ pattern = excludes[ i ].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
if( pattern.endsWith( File.separator ) )
{
pattern += "**";
}
- this.excludes[i] = pattern;
+ this.excludes[ i ] = pattern;
}
}
}
@@ -746,21 +743,20 @@ public class DirectoryScanner implements FileScanner
}
else
{
- this.includes = new String[includes.length];
+ this.includes = new String[ includes.length ];
for( int i = 0; i < includes.length; i++ )
{
String pattern;
- pattern = includes[i].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
+ pattern = includes[ i ].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
if( pattern.endsWith( File.separator ) )
{
pattern += "**";
}
- this.includes[i] = pattern;
+ this.includes[ i ] = pattern;
}
}
}
-
/**
* Gets the basedir that is used for scanning. This is the directory that is
* scanned recursively.
@@ -772,7 +768,6 @@ public class DirectoryScanner implements FileScanner
return basedir;
}
-
/**
* Get the names of the directories that matched at least one of the include
* patterns, an matched also at least one of the exclude patterns. The names
@@ -781,18 +776,18 @@ public class DirectoryScanner implements FileScanner
* @return the names of the directories
*/
public String[] getExcludedDirectories()
+ throws TaskException
{
slowScan();
int count = dirsExcluded.size();
- String[] directories = new String[count];
+ String[] directories = new String[ count ];
for( int i = 0; i < count; i++ )
{
- directories[i] = ( String )dirsExcluded.elementAt( i );
+ directories[ i ] = (String)dirsExcluded.elementAt( i );
}
return directories;
}
-
/**
* Get the names of the files that matched at least one of the include
* patterns, an matched also at least one of the exclude patterns. The names
@@ -801,18 +796,18 @@ public class DirectoryScanner implements FileScanner
* @return the names of the files
*/
public String[] getExcludedFiles()
+ throws TaskException
{
slowScan();
int count = filesExcluded.size();
- String[] files = new String[count];
+ String[] files = new String[ count ];
for( int i = 0; i < count; i++ )
{
- files[i] = ( String )filesExcluded.elementAt( i );
+ files[ i ] = (String)filesExcluded.elementAt( i );
}
return files;
}
-
/**
* Get the names of the directories that matched at least one of the include
* patterns, an matched none of the exclude patterns. The names are relative
@@ -823,15 +818,14 @@ public class DirectoryScanner implements FileScanner
public String[] getIncludedDirectories()
{
int count = dirsIncluded.size();
- String[] directories = new String[count];
+ String[] directories = new String[ count ];
for( int i = 0; i < count; i++ )
{
- directories[i] = ( String )dirsIncluded.elementAt( i );
+ directories[ i ] = (String)dirsIncluded.elementAt( i );
}
return directories;
}
-
/**
* Get the names of the files that matched at least one of the include
* patterns, and matched none of the exclude patterns. The names are
@@ -842,15 +836,14 @@ public class DirectoryScanner implements FileScanner
public String[] getIncludedFiles()
{
int count = filesIncluded.size();
- String[] files = new String[count];
+ String[] files = new String[ count ];
for( int i = 0; i < count; i++ )
{
- files[i] = ( String )filesIncluded.elementAt( i );
+ files[ i ] = (String)filesIncluded.elementAt( i );
}
return files;
}
-
/**
* Get the names of the directories that matched at none of the include
* patterns. The names are relative to the basedir.
@@ -858,18 +851,18 @@ public class DirectoryScanner implements FileScanner
* @return the names of the directories
*/
public String[] getNotIncludedDirectories()
+ throws TaskException
{
slowScan();
int count = dirsNotIncluded.size();
- String[] directories = new String[count];
+ String[] directories = new String[ count ];
for( int i = 0; i < count; i++ )
{
- directories[i] = ( String )dirsNotIncluded.elementAt( i );
+ directories[ i ] = (String)dirsNotIncluded.elementAt( i );
}
return directories;
}
-
/**
* Get the names of the files that matched at none of the include patterns.
* The names are relative to the basedir.
@@ -877,13 +870,14 @@ public class DirectoryScanner implements FileScanner
* @return the names of the files
*/
public String[] getNotIncludedFiles()
+ throws TaskException
{
slowScan();
int count = filesNotIncluded.size();
- String[] files = new String[count];
+ String[] files = new String[ count ];
for( int i = 0; i < count; i++ )
{
- files[i] = ( String )filesNotIncluded.elementAt( i );
+ files[ i ] = (String)filesNotIncluded.elementAt( i );
}
return files;
}
@@ -900,7 +894,6 @@ public class DirectoryScanner implements FileScanner
return everythingIncluded;
}
-
/**
* Adds the array with default exclusions to the current exclusions set.
*/
@@ -908,25 +901,25 @@ public class DirectoryScanner implements FileScanner
{
int excludesLength = excludes == null ? 0 : excludes.length;
String[] newExcludes;
- newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length];
+ newExcludes = new String[ excludesLength + DEFAULTEXCLUDES.length ];
if( excludesLength > 0 )
{
System.arraycopy( excludes, 0, newExcludes, 0, excludesLength );
}
for( int i = 0; i < DEFAULTEXCLUDES.length; i++ )
{
- newExcludes[i + excludesLength] = DEFAULTEXCLUDES[i].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
+ newExcludes[ i + excludesLength ] = DEFAULTEXCLUDES[ i ].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
}
excludes = newExcludes;
}
-
/**
* Scans the base directory for files that match at least one include
* pattern, and don't match any exclude patterns.
*
*/
public void scan()
+ throws TaskException
{
if( basedir == null )
{
@@ -935,23 +928,23 @@ public class DirectoryScanner implements FileScanner
if( !basedir.exists() )
{
throw new IllegalStateException( "basedir " + basedir
- + " does not exist" );
+ + " does not exist" );
}
if( !basedir.isDirectory() )
{
throw new IllegalStateException( "basedir " + basedir
- + " is not a directory" );
+ + " is not a directory" );
}
if( includes == null )
{
// No includes supplied, so set it to 'matches all'
- includes = new String[1];
- includes[0] = "**";
+ includes = new String[ 1 ];
+ includes[ 0 ] = "**";
}
if( excludes == null )
{
- excludes = new String[0];
+ excludes = new String[ 0 ];
}
filesIncluded = new Vector();
@@ -990,7 +983,7 @@ public class DirectoryScanner implements FileScanner
{
for( int i = 0; i < excludes.length; i++ )
{
- if( matchPath( excludes[i], name, isCaseSensitive ) )
+ if( matchPath( excludes[ i ], name, isCaseSensitive ) )
{
return true;
}
@@ -998,7 +991,6 @@ public class DirectoryScanner implements FileScanner
return false;
}
-
/**
* Tests whether a name matches against at least one include pattern.
*
@@ -1010,7 +1002,7 @@ public class DirectoryScanner implements FileScanner
{
for( int i = 0; i < includes.length; i++ )
{
- if( matchPath( includes[i], name, isCaseSensitive ) )
+ if( matchPath( includes[ i ], name, isCaseSensitive ) )
{
return true;
}
@@ -1029,7 +1021,7 @@ public class DirectoryScanner implements FileScanner
{
for( int i = 0; i < includes.length; i++ )
{
- if( matchPatternStart( includes[i], name, isCaseSensitive ) )
+ if( matchPatternStart( includes[ i ], name, isCaseSensitive ) )
{
return true;
}
@@ -1037,7 +1029,6 @@ public class DirectoryScanner implements FileScanner
return false;
}
-
/**
* Scans the passed dir for files and directories. Found files and
* directories are placed in their respective collections, based on the
@@ -1056,6 +1047,7 @@ public class DirectoryScanner implements FileScanner
* @see #dirsExcluded
*/
protected void scandir( File dir, String vpath, boolean fast )
+ throws TaskException
{
String[] newfiles = dir.list();
@@ -1068,14 +1060,14 @@ public class DirectoryScanner implements FileScanner
* (2) an IO error occurred (why doesn't it throw an exception
* then???)
*/
- throw new BuildException( "IO error scanning directory "
- + dir.getAbsolutePath() );
+ throw new TaskException( "IO error scanning directory "
+ + dir.getAbsolutePath() );
}
for( int i = 0; i < newfiles.length; i++ )
{
- String name = vpath + newfiles[i];
- File file = new File( dir, newfiles[i] );
+ String name = vpath + newfiles[ i ];
+ File file = new File( dir, newfiles[ i ] );
if( file.isDirectory() )
{
if( isIncluded( name ) )
@@ -1141,33 +1133,34 @@ public class DirectoryScanner implements FileScanner
* Returns immediately if a slow scan has already been requested.
*/
protected void slowScan()
+ throws TaskException
{
if( haveSlowResults )
{
return;
}
- String[] excl = new String[dirsExcluded.size()];
+ String[] excl = new String[ dirsExcluded.size() ];
dirsExcluded.copyInto( excl );
- String[] notIncl = new String[dirsNotIncluded.size()];
+ String[] notIncl = new String[ dirsNotIncluded.size() ];
dirsNotIncluded.copyInto( notIncl );
for( int i = 0; i < excl.length; i++ )
{
- if( !couldHoldIncluded( excl[i] ) )
+ if( !couldHoldIncluded( excl[ i ] ) )
{
- scandir( new File( basedir, excl[i] ),
- excl[i] + File.separator, false );
+ scandir( new File( basedir, excl[ i ] ),
+ excl[ i ] + File.separator, false );
}
}
for( int i = 0; i < notIncl.length; i++ )
{
- if( !couldHoldIncluded( notIncl[i] ) )
+ if( !couldHoldIncluded( notIncl[ i ] ) )
{
- scandir( new File( basedir, notIncl[i] ),
- notIncl[i] + File.separator, false );
+ scandir( new File( basedir, notIncl[ i ] ),
+ notIncl[ i ] + File.separator, false );
}
}
diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/FileScanner.java b/proposal/myrmidon/src/main/org/apache/tools/ant/FileScanner.java
index a23d95e26..090f52f5d 100644
--- a/proposal/myrmidon/src/main/org/apache/tools/ant/FileScanner.java
+++ b/proposal/myrmidon/src/main/org/apache/tools/ant/FileScanner.java
@@ -6,13 +6,13 @@
* the LICENSE file.
*/
package org.apache.tools.ant;
+
import java.io.File;
+import org.apache.myrmidon.api.TaskException;
/**
* An interface used to describe the actions required by any type of directory
* scanner.
- *
- * @author RT
*/
public interface FileScanner
{
@@ -36,7 +36,7 @@ public interface FileScanner
*
* @return the names of the directories
*/
- String[] getExcludedDirectories();
+ String[] getExcludedDirectories() throws TaskException;
/**
* Get the names of the files that matched at least one of the include
@@ -45,7 +45,7 @@ public interface FileScanner
*
* @return the names of the files
*/
- String[] getExcludedFiles();
+ String[] getExcludedFiles() throws TaskException;
/**
* Get the names of the directories that matched at least one of the include
@@ -63,7 +63,7 @@ public interface FileScanner
*
* @return the names of the files
*/
- String[] getIncludedFiles();
+ String[] getIncludedFiles() throws TaskException;
/**
* Get the names of the directories that matched at none of the include
@@ -71,7 +71,7 @@ public interface FileScanner
*
* @return the names of the directories
*/
- String[] getNotIncludedDirectories();
+ String[] getNotIncludedDirectories() throws TaskException;
/**
* Get the names of the files that matched at none of the include patterns.
@@ -79,14 +79,15 @@ public interface FileScanner
*
* @return the names of the files
*/
- String[] getNotIncludedFiles();
+ String[] getNotIncludedFiles() throws TaskException;
/**
* Scans the base directory for files that match at least one include
* pattern, and don't match any exclude patterns.
*
*/
- void scan();
+ void scan()
+ throws TaskException;
/**
* Sets the basedir for scanning. This is the directory that is scanned
diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/IntrospectionHelper.java b/proposal/myrmidon/src/main/org/apache/tools/ant/IntrospectionHelper.java
index 8b7160c9f..c904a133d 100644
--- a/proposal/myrmidon/src/main/org/apache/tools/ant/IntrospectionHelper.java
+++ b/proposal/myrmidon/src/main/org/apache/tools/ant/IntrospectionHelper.java
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant;
+
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@@ -13,8 +14,10 @@ import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.util.FileUtils;
/**
* Helper class that collects the methods a task or nested element holds to set
@@ -66,6 +69,7 @@ public class IntrospectionHelper implements BuildListener
private Hashtable nestedTypes;
private IntrospectionHelper( final Class bean )
+ throws TaskException
{
attributeTypes = new Hashtable();
attributeSetters = new Hashtable();
@@ -78,52 +82,52 @@ public class IntrospectionHelper implements BuildListener
Method[] methods = bean.getMethods();
for( int i = 0; i < methods.length; i++ )
{
- final Method m = methods[i];
+ final Method m = methods[ i ];
final String name = m.getName();
Class returnType = m.getReturnType();
Class[] args = m.getParameterTypes();
// not really user settable properties on tasks
if( org.apache.tools.ant.Task.class.isAssignableFrom( bean )
- && args.length == 1 &&
+ && args.length == 1 &&
(
(
- "setLocation".equals( name ) && org.apache.tools.ant.Location.class.equals( args[0] )
- ) || (
- "setTaskType".equals( name ) && java.lang.String.class.equals( args[0] )
- )
- ) )
+ "setLocation".equals( name ) && org.apache.tools.ant.Location.class.equals( args[ 0 ] )
+ ) || (
+ "setTaskType".equals( name ) && java.lang.String.class.equals( args[ 0 ] )
+ )
+ ) )
{
continue;
}
// hide addTask for TaskContainers
if( org.apache.tools.ant.TaskContainer.class.isAssignableFrom( bean )
- && args.length == 1 && "addTask".equals( name )
- && org.apache.tools.ant.Task.class.equals( args[0] ) )
+ && args.length == 1 && "addTask".equals( name )
+ && org.apache.tools.ant.Task.class.equals( args[ 0 ] ) )
{
continue;
}
if( "addText".equals( name )
- && java.lang.Void.TYPE.equals( returnType )
- && args.length == 1
- && java.lang.String.class.equals( args[0] ) )
+ && java.lang.Void.TYPE.equals( returnType )
+ && args.length == 1
+ && java.lang.String.class.equals( args[ 0 ] ) )
{
- addText = methods[i];
+ addText = methods[ i ];
}
else if( name.startsWith( "set" )
- && java.lang.Void.TYPE.equals( returnType )
- && args.length == 1
- && !args[0].isArray() )
+ && java.lang.Void.TYPE.equals( returnType )
+ && args.length == 1
+ && !args[ 0 ].isArray() )
{
String propName = getPropertyName( name, "set" );
if( attributeSetters.get( propName ) != null )
{
- if( java.lang.String.class.equals( args[0] ) )
+ if( java.lang.String.class.equals( args[ 0 ] ) )
{
/*
* Ignore method m, as there is an overloaded
@@ -144,109 +148,109 @@ public class IntrospectionHelper implements BuildListener
* particular order.
*/
}
- AttributeSetter as = createAttributeSetter( m, args[0] );
+ AttributeSetter as = createAttributeSetter( m, args[ 0 ] );
if( as != null )
{
- attributeTypes.put( propName, args[0] );
+ attributeTypes.put( propName, args[ 0 ] );
attributeSetters.put( propName, as );
}
}
else if( name.startsWith( "create" )
- && !returnType.isArray()
- && !returnType.isPrimitive()
- && args.length == 0 )
+ && !returnType.isArray()
+ && !returnType.isPrimitive()
+ && args.length == 0 )
{
String propName = getPropertyName( name, "create" );
nestedTypes.put( propName, returnType );
nestedCreators.put( propName,
- new NestedCreator()
- {
+ new NestedCreator()
+ {
- public Object create( Object parent )
- throws InvocationTargetException,
- IllegalAccessException
- {
+ public Object create( Object parent )
+ throws InvocationTargetException,
+ IllegalAccessException
+ {
- return m.invoke( parent, new Object[]{} );
- }
+ return m.invoke( parent, new Object[]{} );
+ }
- } );
+ } );
}
else if( name.startsWith( "addConfigured" )
- && java.lang.Void.TYPE.equals( returnType )
- && args.length == 1
- && !java.lang.String.class.equals( args[0] )
- && !args[0].isArray()
- && !args[0].isPrimitive() )
+ && java.lang.Void.TYPE.equals( returnType )
+ && args.length == 1
+ && !java.lang.String.class.equals( args[ 0 ] )
+ && !args[ 0 ].isArray()
+ && !args[ 0 ].isPrimitive() )
{
try
{
final Constructor c =
- args[0].getConstructor( new Class[]{} );
+ args[ 0 ].getConstructor( new Class[]{} );
String propName = getPropertyName( name, "addConfigured" );
- nestedTypes.put( propName, args[0] );
+ nestedTypes.put( propName, args[ 0 ] );
nestedCreators.put( propName,
- new NestedCreator()
- {
+ new NestedCreator()
+ {
- public Object create( Object parent )
- throws InvocationTargetException, IllegalAccessException, InstantiationException
- {
+ public Object create( Object parent )
+ throws InvocationTargetException, IllegalAccessException, InstantiationException
+ {
- Object o = c.newInstance( new Object[]{} );
- return o;
- }
+ Object o = c.newInstance( new Object[]{} );
+ return o;
+ }
- } );
+ } );
nestedStorers.put( propName,
- new NestedStorer()
- {
+ new NestedStorer()
+ {
- public void store( Object parent, Object child )
- throws InvocationTargetException, IllegalAccessException, InstantiationException
- {
+ public void store( Object parent, Object child )
+ throws InvocationTargetException, IllegalAccessException, InstantiationException
+ {
- m.invoke( parent, new Object[]{child} );
- }
+ m.invoke( parent, new Object[]{child} );
+ }
- } );
+ } );
}
catch( NoSuchMethodException nse )
{
}
}
else if( name.startsWith( "add" )
- && java.lang.Void.TYPE.equals( returnType )
- && args.length == 1
- && !java.lang.String.class.equals( args[0] )
- && !args[0].isArray()
- && !args[0].isPrimitive() )
+ && java.lang.Void.TYPE.equals( returnType )
+ && args.length == 1
+ && !java.lang.String.class.equals( args[ 0 ] )
+ && !args[ 0 ].isArray()
+ && !args[ 0 ].isPrimitive() )
{
try
{
final Constructor c =
- args[0].getConstructor( new Class[]{} );
+ args[ 0 ].getConstructor( new Class[]{} );
String propName = getPropertyName( name, "add" );
- nestedTypes.put( propName, args[0] );
+ nestedTypes.put( propName, args[ 0 ] );
nestedCreators.put( propName,
- new NestedCreator()
- {
+ new NestedCreator()
+ {
- public Object create( Object parent )
- throws InvocationTargetException, IllegalAccessException, InstantiationException
- {
+ public Object create( Object parent )
+ throws InvocationTargetException, IllegalAccessException, InstantiationException
+ {
- Object o = c.newInstance( new Object[]{} );
- m.invoke( parent, new Object[]{o} );
- return o;
- }
+ Object o = c.newInstance( new Object[]{} );
+ m.invoke( parent, new Object[]{o} );
+ return o;
+ }
- } );
+ } );
}
catch( NoSuchMethodException nse )
{
@@ -263,7 +267,7 @@ public class IntrospectionHelper implements BuildListener
*/
public static synchronized IntrospectionHelper getHelper( Class c )
{
- IntrospectionHelper ih = ( IntrospectionHelper )helpers.get( c );
+ IntrospectionHelper ih = (IntrospectionHelper)helpers.get( c );
if( ih == null )
{
ih = new IntrospectionHelper( c );
@@ -285,13 +289,13 @@ public class IntrospectionHelper implements BuildListener
String value )
throws BuildException
{
- AttributeSetter as = ( AttributeSetter )attributeSetters.get( attributeName );
+ AttributeSetter as = (AttributeSetter)attributeSetters.get( attributeName );
if( as == null )
{
String msg = getElementName( p, element ) +
- //String msg = "Class " + element.getClass().getName() +
+ //String msg = "Class " + element.getClass().getName() +
" doesn't support the \"" + attributeName + "\" attribute.";
- throw new BuildException( msg );
+ throw new TaskException( msg );
}
try
{
@@ -300,16 +304,16 @@ public class IntrospectionHelper implements BuildListener
catch( IllegalAccessException ie )
{
// impossible as getMethods should only return public methods
- throw new BuildException( ie );
+ throw new TaskException( ie.toString(), ie );
}
catch( InvocationTargetException ite )
{
Throwable t = ite.getTargetException();
- if( t instanceof BuildException )
+ if( t instanceof TaskException )
{
- throw ( BuildException )t;
+ throw (TaskException)t;
}
- throw new BuildException( t );
+ throw new TaskException( t.toString(), t );
}
}
@@ -318,17 +322,17 @@ public class IntrospectionHelper implements BuildListener
*
* @param attributeName Description of Parameter
* @return The AttributeType value
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public Class getAttributeType( String attributeName )
- throws BuildException
+ throws TaskException
{
- Class at = ( Class )attributeTypes.get( attributeName );
+ Class at = (Class)attributeTypes.get( attributeName );
if( at == null )
{
String msg = "Class " + bean.getName() +
" doesn't support the \"" + attributeName + "\" attribute.";
- throw new BuildException( msg );
+ throw new TaskException( msg );
}
return at;
}
@@ -348,17 +352,17 @@ public class IntrospectionHelper implements BuildListener
*
* @param elementName Description of Parameter
* @return The ElementType value
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public Class getElementType( String elementName )
- throws BuildException
+ throws TaskException
{
- Class nt = ( Class )nestedTypes.get( elementName );
+ Class nt = (Class)nestedTypes.get( elementName );
if( nt == null )
{
String msg = "Class " + bean.getName() +
" doesn't support the nested \"" + elementName + "\" element.";
- throw new BuildException( msg );
+ throw new TaskException( msg );
}
return nt;
}
@@ -381,13 +385,14 @@ public class IntrospectionHelper implements BuildListener
* @param text The feature to be added to the Text attribute
*/
public void addText( Project project, Object element, String text )
+ throws TaskException
{
if( addText == null )
{
String msg = getElementName( project, element ) +
- //String msg = "Class " + element.getClass().getName() +
+ //String msg = "Class " + element.getClass().getName() +
" doesn't support nested text data.";
- throw new BuildException( msg );
+ throw new TaskException( msg );
}
try
{
@@ -396,16 +401,16 @@ public class IntrospectionHelper implements BuildListener
catch( IllegalAccessException ie )
{
// impossible as getMethods should only return public methods
- throw new BuildException( ie );
+ throw new TaskException( ie.getMessage(), ie );
}
catch( InvocationTargetException ite )
{
Throwable t = ite.getTargetException();
- if( t instanceof BuildException )
+ if( t instanceof TaskException )
{
- throw ( BuildException )t;
+ throw (TaskException)t;
}
- throw new BuildException( t );
+ throw new TaskException( t.getMessage(), t );
}
}
@@ -419,7 +424,9 @@ public class IntrospectionHelper implements BuildListener
helpers.clear();
}
- public void buildStarted( BuildEvent event ) { }
+ public void buildStarted( BuildEvent event )
+ {
+ }
/**
* Creates a named nested element.
@@ -428,49 +435,51 @@ public class IntrospectionHelper implements BuildListener
* @param element Description of Parameter
* @param elementName Description of Parameter
* @return Description of the Returned Value
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public Object createElement( Project project, Object element, String elementName )
- throws BuildException
+ throws TaskException
{
- NestedCreator nc = ( NestedCreator )nestedCreators.get( elementName );
+ NestedCreator nc = (NestedCreator)nestedCreators.get( elementName );
if( nc == null )
{
String msg = getElementName( project, element ) +
" doesn't support the nested \"" + elementName + "\" element.";
- throw new BuildException( msg );
+ throw new TaskException( msg );
}
try
{
Object nestedElement = nc.create( element );
if( nestedElement instanceof ProjectComponent )
{
- ( ( ProjectComponent )nestedElement ).setProject( project );
+ ( (ProjectComponent)nestedElement ).setProject( project );
}
return nestedElement;
}
catch( IllegalAccessException ie )
{
// impossible as getMethods should only return public methods
- throw new BuildException( ie );
+ throw new TaskException( ie.getMessage(), ie );
}
catch( InstantiationException ine )
{
// impossible as getMethods should only return public methods
- throw new BuildException( ine );
+ throw new TaskException( ine.getMessage(), ine );
}
catch( InvocationTargetException ite )
{
Throwable t = ite.getTargetException();
- if( t instanceof BuildException )
+ if( t instanceof TaskException )
{
- throw ( BuildException )t;
+ throw (TaskException)t;
}
- throw new BuildException( t );
+ throw new TaskException( t.getMessage(), t );
}
}
- public void messageLogged( BuildEvent event ) { }
+ public void messageLogged( BuildEvent event )
+ {
+ }
/**
* Creates a named nested element.
@@ -479,16 +488,16 @@ public class IntrospectionHelper implements BuildListener
* @param element Description of Parameter
* @param child Description of Parameter
* @param elementName Description of Parameter
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public void storeElement( Project project, Object element, Object child, String elementName )
- throws BuildException
+ throws TaskException
{
if( elementName == null )
{
return;
}
- NestedStorer ns = ( NestedStorer )nestedStorers.get( elementName );
+ NestedStorer ns = (NestedStorer)nestedStorers.get( elementName );
if( ns == null )
{
return;
@@ -500,21 +509,21 @@ public class IntrospectionHelper implements BuildListener
catch( IllegalAccessException ie )
{
// impossible as getMethods should only return public methods
- throw new BuildException( ie );
+ throw new TaskException( ie.getMessage(), ie );
}
catch( InstantiationException ine )
{
// impossible as getMethods should only return public methods
- throw new BuildException( ine );
+ throw new TaskException( ine.getMessage(), ine );
}
catch( InvocationTargetException ite )
{
Throwable t = ite.getTargetException();
- if( t instanceof BuildException )
+ if( t instanceof TaskException )
{
- throw ( BuildException )t;
+ throw (TaskException)t;
}
- throw new BuildException( t );
+ throw new TaskException( t.getMessage(), t );
}
}
@@ -528,13 +537,21 @@ public class IntrospectionHelper implements BuildListener
return addText != null;
}
- public void targetFinished( BuildEvent event ) { }
+ public void targetFinished( BuildEvent event )
+ {
+ }
- public void targetStarted( BuildEvent event ) { }
+ public void targetStarted( BuildEvent event )
+ {
+ }
- public void taskFinished( BuildEvent event ) { }
+ public void taskFinished( BuildEvent event )
+ {
+ }
- public void taskStarted( BuildEvent event ) { }
+ public void taskStarted( BuildEvent event )
+ {
+ }
protected String getElementName( Project project, Object element )
{
@@ -555,8 +572,8 @@ public class IntrospectionHelper implements BuildListener
Enumeration e = elements.keys();
while( e.hasMoreElements() )
{
- String elementName = ( String )e.nextElement();
- Class elementClass = ( Class )elements.get( elementName );
+ String elementName = (String)e.nextElement();
+ Class elementClass = (Class)elements.get( elementName );
if( element.getClass().equals( elementClass ) )
{
return "The <" + elementName + "> " + typeName;
@@ -590,7 +607,8 @@ public class IntrospectionHelper implements BuildListener
* @return Description of the Returned Value
*/
private AttributeSetter createAttributeSetter( final Method m,
- final Class arg )
+ final Class arg )
+ throws TaskException
{
// simplest case - setAttribute expects String
@@ -608,7 +626,7 @@ public class IntrospectionHelper implements BuildListener
// now for the primitive types, use their wrappers
}
else if( java.lang.Character.class.equals( arg )
- || java.lang.Character.TYPE.equals( arg ) )
+ || java.lang.Character.TYPE.equals( arg ) )
{
return
new AttributeSetter()
@@ -702,7 +720,7 @@ public class IntrospectionHelper implements BuildListener
// in Project
}
else if( java.lang.Boolean.class.equals( arg )
- || java.lang.Boolean.TYPE.equals( arg ) )
+ || java.lang.Boolean.TYPE.equals( arg ) )
{
return
new AttributeSetter()
@@ -711,7 +729,7 @@ public class IntrospectionHelper implements BuildListener
throws InvocationTargetException, IllegalAccessException
{
m.invoke( parent,
- new Boolean[]{new Boolean( Project.toBoolean( value ) )} );
+ new Boolean[]{new Boolean( Project.toBoolean( value ) )} );
}
};
@@ -723,7 +741,7 @@ public class IntrospectionHelper implements BuildListener
new AttributeSetter()
{
public void set( Project p, Object parent, String value )
- throws InvocationTargetException, IllegalAccessException, BuildException
+ throws InvocationTargetException, IllegalAccessException, TaskException
{
try
{
@@ -731,7 +749,7 @@ public class IntrospectionHelper implements BuildListener
}
catch( ClassNotFoundException ce )
{
- throw new BuildException( ce );
+ throw new TaskException( ce.toString(), ce );
}
}
};
@@ -745,7 +763,9 @@ public class IntrospectionHelper implements BuildListener
public void set( Project p, Object parent, String value )
throws InvocationTargetException, IllegalAccessException
{
- m.invoke( parent, new File[]{p.resolveFile( value )} );
+ final File file =
+ FileUtils.newFileUtils().resolveFile( p.getBaseDir(), value );
+ m.invoke( parent, new File[]{ file } );
}
};
@@ -771,17 +791,17 @@ public class IntrospectionHelper implements BuildListener
new AttributeSetter()
{
public void set( Project p, Object parent, String value )
- throws InvocationTargetException, IllegalAccessException, BuildException
+ throws InvocationTargetException, IllegalAccessException, TaskException
{
try
{
- org.apache.tools.ant.types.EnumeratedAttribute ea = ( org.apache.tools.ant.types.EnumeratedAttribute )arg.newInstance();
+ org.apache.tools.ant.types.EnumeratedAttribute ea = (org.apache.tools.ant.types.EnumeratedAttribute)arg.newInstance();
ea.setValue( value );
m.invoke( parent, new EnumeratedAttribute[]{ea} );
}
catch( InstantiationException ie )
{
- throw new BuildException( ie );
+ throw new TaskException( ie.getMessage(), ie );
}
}
};
@@ -801,20 +821,20 @@ public class IntrospectionHelper implements BuildListener
{
public void set( Project p, Object parent,
String value )
- throws InvocationTargetException, IllegalAccessException, BuildException
+ throws InvocationTargetException, IllegalAccessException, TaskException
{
try
{
Object attribute = c.newInstance( new String[]{value} );
if( attribute instanceof ProjectComponent )
{
- ( ( ProjectComponent )attribute ).setProject( p );
+ ( (ProjectComponent)attribute ).setProject( p );
}
m.invoke( parent, new Object[]{attribute} );
}
catch( InstantiationException ie )
{
- throw new BuildException( ie );
+ throw new TaskException( ie.getMessage(), ie );
}
}
};
@@ -831,7 +851,7 @@ public class IntrospectionHelper implements BuildListener
{
void set( Project p, Object parent, String value )
throws InvocationTargetException, IllegalAccessException,
- BuildException;
+ TaskException;
}
private interface NestedCreator
diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/Main.java b/proposal/myrmidon/src/main/org/apache/tools/ant/Main.java
index 0c605f732..3721f72dd 100644
--- a/proposal/myrmidon/src/main/org/apache/tools/ant/Main.java
+++ b/proposal/myrmidon/src/main/org/apache/tools/ant/Main.java
@@ -14,6 +14,7 @@ import java.io.PrintStream;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Vector;
+import org.apache.myrmidon.api.TaskException;
/**
* Command line entry point into Ant. This class is entered via the cannonical
@@ -97,7 +98,7 @@ public class Main
private File buildFile;
protected Main( String[] args )
- throws BuildException
+ throws TaskException
{
String searchForThis = null;
@@ -289,7 +290,7 @@ public class Main
if( !buildFile.exists() )
{
System.out.println( "Buildfile: " + buildFile + " does not exist!" );
- throw new BuildException( "Build failed" );
+ throw new TaskException( "Build failed" );
}
// make sure it's not a directory (this falls into the ultra
@@ -298,14 +299,14 @@ public class Main
if( buildFile.isDirectory() )
{
System.out.println( "What? Buildfile: " + buildFile + " is a dir!" );
- throw new BuildException( "Build failed" );
+ throw new TaskException( "Build failed" );
}
readyToRun = true;
}
public static synchronized String getAntVersion()
- throws BuildException
+ throws TaskException
{
if( antVersion == null )
{
@@ -327,12 +328,12 @@ public class Main
}
catch( IOException ioe )
{
- throw new BuildException( "Could not load the version information:"
+ throw new TaskException( "Could not load the version information:"
+ ioe.getMessage() );
}
catch( NullPointerException npe )
{
- throw new BuildException( "Could not load the version information." );
+ throw new TaskException( "Could not load the version information." );
}
}
return antVersion;
@@ -388,7 +389,7 @@ public class Main
m.runBuild( coreLoader );
System.exit( 0 );
}
- catch( BuildException be )
+ catch( TaskException be )
{
if( m.err != System.err )
{
@@ -569,7 +570,7 @@ public class Main
}
private static void printVersion()
- throws BuildException
+ throws TaskException
{
System.out.println( getAntVersion() );
}
@@ -591,7 +592,7 @@ public class Main
}
catch( Throwable exc )
{
- throw new BuildException( "Unable to instantiate listener " + className, exc );
+ throw new TaskException( "Unable to instantiate listener " + className, exc );
}
}
}
@@ -668,10 +669,10 @@ public class Main
* @param suffix Suffix filename to look for in parents.
* @param start Description of Parameter
* @return A handle to the build file
- * @exception BuildException Failed to locate a build file
+ * @exception TaskException Failed to locate a build file
*/
private File findBuildFile( String start, String suffix )
- throws BuildException
+ throws TaskException
{
if( msgOutputLevel >= Project.MSG_INFO )
{
@@ -691,7 +692,7 @@ public class Main
// complain that we can't find the build file.
if( parent == null )
{
- throw new BuildException( "Could not locate a build file!" );
+ throw new TaskException( "Could not locate a build file!" );
}
// refresh our file handle
@@ -705,10 +706,10 @@ public class Main
* Executes the build.
*
* @param coreLoader Description of Parameter
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
private void runBuild( ClassLoader coreLoader )
- throws BuildException
+ throws TaskException
{
if( !readyToRun )
@@ -782,15 +783,15 @@ public class Main
}
catch( NoClassDefFoundError ncdfe )
{
- throw new BuildException( noParserMessage, ncdfe );
+ throw new TaskException( noParserMessage, ncdfe );
}
catch( ClassNotFoundException cnfe )
{
- throw new BuildException( noParserMessage, cnfe );
+ throw new TaskException( noParserMessage, cnfe );
}
catch( NullPointerException npe )
{
- throw new BuildException( noParserMessage, npe );
+ throw new TaskException( noParserMessage, npe );
}
if( projectHelp )
diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/Project.java b/proposal/myrmidon/src/main/org/apache/tools/ant/Project.java
index c509b8795..c2d656e57 100644
--- a/proposal/myrmidon/src/main/org/apache/tools/ant/Project.java
+++ b/proposal/myrmidon/src/main/org/apache/tools/ant/Project.java
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -15,6 +16,7 @@ import java.util.Hashtable;
import java.util.Properties;
import java.util.Stack;
import java.util.Vector;
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection;
import org.apache.tools.ant.util.FileUtils;
@@ -30,10 +32,8 @@ import org.apache.tools.ant.util.FileUtils;
*
* @author duncan@x180.com
*/
-
public class Project
{
-
public final static int MSG_ERR = 0;
public final static int MSG_WARN = 1;
public final static int MSG_INFO = 2;
@@ -71,7 +71,7 @@ public class Project
/**
* The Ant core classloader - may be null if using system loader
*/
- private ClassLoader coreLoader = null;
+ private ClassLoader coreLoader;
/**
* Records the latest task on a thread
@@ -81,8 +81,6 @@ public class Project
private String defaultTarget;
private String description;
- private FileUtils fileUtils;
-
private String name;
static
@@ -113,14 +111,6 @@ public class Project
}
}
- /**
- * create a new ant project
- */
- public Project()
- {
- fileUtils = FileUtils.newFileUtils();
- }
-
/**
* static query of the java version
*
@@ -181,18 +171,18 @@ public class Project
return path.toString();
}
- private static BuildException makeCircularException( String end, Stack stk )
+ private static TaskException makeCircularException( String end, Stack stk )
{
StringBuffer sb = new StringBuffer( "Circular dependency: " );
sb.append( end );
String c;
do
{
- c = ( String )stk.pop();
+ c = (String)stk.pop();
sb.append( " <- " );
sb.append( c );
- }while ( !c.equals( end ) );
- return new BuildException( new String( sb ) );
+ } while( !c.equals( end ) );
+ return new TaskException( new String( sb ) );
}
/**
@@ -200,16 +190,16 @@ public class Project
* and being a directory type
*
* @param baseDir project base directory.
- * @throws BuildException if the directory was invalid
+ * @throws TaskException if the directory was invalid
*/
public void setBaseDir( File baseDir )
- throws BuildException
+ throws TaskException
{
- baseDir = fileUtils.normalize( baseDir.getAbsolutePath() );
+ baseDir = FileUtils.newFileUtils().normalize( baseDir.getAbsolutePath() );
if( !baseDir.exists() )
- throw new BuildException( "Basedir " + baseDir.getAbsolutePath() + " does not exist" );
+ throw new TaskException( "Basedir " + baseDir.getAbsolutePath() + " does not exist" );
if( !baseDir.isDirectory() )
- throw new BuildException( "Basedir " + baseDir.getAbsolutePath() + " is not a directory" );
+ throw new TaskException( "Basedir " + baseDir.getAbsolutePath() + " is not a directory" );
this.baseDir = baseDir;
setPropertyInternal( "basedir", this.baseDir.getPath() );
String msg = "Project base dir set to: " + this.baseDir;
@@ -220,10 +210,10 @@ public class Project
* match basedir attribute in xml
*
* @param baseD project base directory.
- * @throws BuildException if the directory was invalid
+ * @throws TaskException if the directory was invalid
*/
public void setBasedir( String baseD )
- throws BuildException
+ throws TaskException
{
setBaseDir( new File( baseD ) );
}
@@ -233,7 +223,6 @@ public class Project
this.coreLoader = coreLoader;
}
-
/**
* set the default target of the project XML attribute name.
*
@@ -244,18 +233,6 @@ public class Project
this.defaultTarget = defaultTarget;
}
- /**
- * set the default target of the project
- *
- * @param defaultTarget The new DefaultTarget value
- * @see #setDefault(String)
- * @deprecated, use setDefault
- */
- public void setDefaultTarget( String defaultTarget )
- {
- this.defaultTarget = defaultTarget;
- }
-
/**
* set the project description
*
@@ -266,42 +243,21 @@ public class Project
this.description = description;
}
- /**
- * Calls File.setLastModified(long time) in a Java 1.1 compatible way.
- *
- * @param file The new FileLastModified value
- * @param time The new FileLastModified value
- * @exception BuildException Description of Exception
- * @deprecated
- */
- public void setFileLastModified( File file, long time )
- throws BuildException
- {
- if( getJavaVersion() == JAVA_1_1 )
- {
- log( "Cannot change the modification time of " + file
- + " in JDK 1.1", Project.MSG_WARN );
- return;
- }
- fileUtils.setFileLastModified( file, time );
- log( "Setting modification time for " + file, MSG_VERBOSE );
- }
-
/**
* set the ant.java.version property, also tests for unsupported JVM
* versions, prints the verbose log messages
*
- * @throws BuildException if this Java version is not supported
+ * @throws TaskException if this Java version is not supported
*/
public void setJavaVersionProperty()
- throws BuildException
+ throws TaskException
{
setPropertyInternal( "ant.java.version", javaVersion );
// sanity check
if( javaVersion == JAVA_1_0 )
{
- throw new BuildException( "Ant cannot work on Java 1.0" );
+ throw new TaskException( "Ant cannot work on Java 1.0" );
}
log( "Detected Java version: " + javaVersion + " in: " + System.getProperty( "java.home" ), MSG_VERBOSE );
@@ -337,7 +293,7 @@ public class Project
return;
}
log( "Setting project property: " + name + " -> " +
- value, MSG_DEBUG );
+ value, MSG_DEBUG );
properties.put( name, value );
}
@@ -360,11 +316,11 @@ public class Project
if( null != properties.get( name ) )
{
log( "Overriding previous definition of property " + name,
- MSG_VERBOSE );
+ MSG_VERBOSE );
}
log( "Setting project property: " + name + " -> " +
- value, MSG_DEBUG );
+ value, MSG_DEBUG );
properties.put( name, value );
}
@@ -395,7 +351,7 @@ public class Project
public void setUserProperty( String name, String value )
{
log( "Setting ro project property: " + name + " -> " +
- value, MSG_DEBUG );
+ value, MSG_DEBUG );
userProperties.put( name, value );
properties.put( name, value );
}
@@ -414,7 +370,7 @@ public class Project
{
setBasedir( "." );
}
- catch( BuildException ex )
+ catch( TaskException ex )
{
ex.printStackTrace();
}
@@ -462,17 +418,6 @@ public class Project
return description;
}
- /**
- * @return The Filters value
- * @deprecated
- */
- public Hashtable getFilters()
- {
- // we need to build the hashtable dynamically
- return globalFilterSet.getFilterHash();
- }
-
-
public FilterSet getGlobalFilterSet()
{
return globalFilterSet;
@@ -518,7 +463,7 @@ public class Project
{
if( name == null )
return null;
- String property = ( String )properties.get( name );
+ String property = (String)properties.get( name );
return property;
}
@@ -586,7 +531,7 @@ public class Project
{
if( name == null )
return null;
- String property = ( String )userProperties.get( name );
+ String property = (String)userProperties.get( name );
return property;
}
@@ -599,11 +544,11 @@ public class Project
* @param targets is a Hashtable representing a "name to Target" mapping
* @return a Vector of Strings with the names of the targets in sorted
* order.
- * @exception BuildException if there is a cyclic dependency among the
+ * @exception TaskException if there is a cyclic dependency among the
* Targets, or if a Target does not exist.
*/
public final Vector topoSort( String root, Hashtable targets )
- throws BuildException
+ throws TaskException
{
Vector ret = new Vector();
Hashtable state = new Hashtable();
@@ -619,10 +564,10 @@ public class Project
tsort( root, targets, state, visiting, ret );
log( "Build sequence for target `" + root + "' is " + ret, MSG_VERBOSE );
- for( Enumeration en = targets.keys(); en.hasMoreElements(); )
+ for( Enumeration en = targets.keys(); en.hasMoreElements(); )
{
- String curTarget = ( String )( en.nextElement() );
- String st = ( String )state.get( curTarget );
+ String curTarget = (String)( en.nextElement() );
+ String st = (String)state.get( curTarget );
if( st == null )
{
tsort( curTarget, targets, state, visiting, ret );
@@ -652,7 +597,7 @@ public class Project
if( null != dataClassDefinitions.get( typeName ) )
{
log( "Trying to override old definition of datatype " + typeName,
- MSG_WARN );
+ MSG_WARN );
}
String msg = " +User datatype: " + typeName + " " + typeClass.getName();
@@ -660,21 +605,6 @@ public class Project
dataClassDefinitions.put( typeName, typeClass );
}
- /**
- * @param token The feature to be added to the Filter attribute
- * @param value The feature to be added to the Filter attribute
- * @deprecated
- */
- public void addFilter( String token, String value )
- {
- if( token == null )
- {
- return;
- }
-
- globalFilterSet.addFilter( new FilterSet.Filter( token, value ) );
- }
-
/**
* @param target is the Target to be added or replaced in the current
* Project.
@@ -701,7 +631,7 @@ public class Project
if( null != references.get( name ) )
{
log( "Overriding previous definition of reference to " + name,
- MSG_WARN );
+ MSG_WARN );
}
log( "Adding reference: " + name + " -> " + value, MSG_DEBUG );
references.put( name, value );
@@ -714,11 +644,12 @@ public class Project
* @see Project#addOrReplaceTarget to replace existing Targets.
*/
public void addTarget( Target target )
+ throws TaskException
{
String name = target.getName();
if( targets.get( name ) != null )
{
- throw new BuildException( "Duplicate target: `" + name + "'" );
+ throw new TaskException( "Duplicate target: `" + name + "'" );
}
addOrReplaceTarget( name, target );
}
@@ -728,15 +659,15 @@ public class Project
*
* @param target is the Target to be added to the current Project.
* @param targetName is the name to use for the Target
- * @exception BuildException if the Target already exists in the project.
+ * @exception TaskException if the Target already exists in the project.
* @see Project#addOrReplaceTarget to replace existing Targets.
*/
public void addTarget( String targetName, Target target )
- throws BuildException
+ throws TaskException
{
if( targets.get( targetName ) != null )
{
- throw new BuildException( "Duplicate target: `" + targetName + "'" );
+ throw new TaskException( "Duplicate target: `" + targetName + "'" );
}
addOrReplaceTarget( targetName, target );
}
@@ -746,26 +677,26 @@ public class Project
*
* @param taskName name of the task
* @param taskClass full task classname
- * @throws BuildException and logs as Project.MSG_ERR for conditions, that
+ * @throws TaskException and logs as Project.MSG_ERR for conditions, that
* will cause the task execution to fail.
*/
public void addTaskDefinition( String taskName, Class taskClass )
- throws BuildException
+ throws TaskException
{
- Class old = ( Class )taskClassDefinitions.get( taskName );
+ Class old = (Class)taskClassDefinitions.get( taskName );
if( null != old )
{
if( old.equals( taskClass ) )
{
log( "Ignoring override for task " + taskName
+ ", it is already defined by the same class.",
- MSG_VERBOSE );
+ MSG_VERBOSE );
return;
}
else
{
log( "Trying to override old definition of task " + taskName,
- MSG_WARN );
+ MSG_WARN );
invalidateCreatedTasks( taskName );
}
}
@@ -780,23 +711,23 @@ public class Project
* Checks a class, whether it is suitable for serving as ant task.
*
* @param taskClass Description of Parameter
- * @throws BuildException and logs as Project.MSG_ERR for conditions, that
+ * @throws TaskException and logs as Project.MSG_ERR for conditions, that
* will cause the task execution to fail.
*/
public void checkTaskClass( final Class taskClass )
- throws BuildException
+ throws TaskException
{
if( !Modifier.isPublic( taskClass.getModifiers() ) )
{
final String message = taskClass + " is not public";
log( message, Project.MSG_ERR );
- throw new BuildException( message );
+ throw new TaskException( message );
}
if( Modifier.isAbstract( taskClass.getModifiers() ) )
{
final String message = taskClass + " is abstract";
log( message, Project.MSG_ERR );
- throw new BuildException( message );
+ throw new TaskException( message );
}
try
{
@@ -808,169 +739,23 @@ public class Project
{
final String message = "No public default constructor in " + taskClass;
log( message, Project.MSG_ERR );
- throw new BuildException( message );
+ throw new TaskException( message );
}
if( !Task.class.isAssignableFrom( taskClass ) )
TaskAdapter.checkTaskClass( taskClass, this );
}
- /**
- * Convienence method to copy a file from a source to a destination. No
- * filtering is performed.
- *
- * @param sourceFile Description of Parameter
- * @param destFile Description of Parameter
- * @throws IOException
- * @deprecated
- */
- public void copyFile( String sourceFile, String destFile )
- throws IOException
- {
- fileUtils.copyFile( sourceFile, destFile );
- }
-
- /**
- * Convienence method to copy a file from a source to a destination
- * specifying if token filtering must be used.
- *
- * @param sourceFile Description of Parameter
- * @param destFile Description of Parameter
- * @param filtering Description of Parameter
- * @throws IOException
- * @deprecated
- */
- public void copyFile( String sourceFile, String destFile, boolean filtering )
- throws IOException
- {
- fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null );
- }
-
- /**
- * Convienence method to copy a file from a source to a destination
- * specifying if token filtering must be used and if source files may
- * overwrite newer destination files.
- *
- * @param sourceFile Description of Parameter
- * @param destFile Description of Parameter
- * @param filtering Description of Parameter
- * @param overwrite Description of Parameter
- * @throws IOException
- * @deprecated
- */
- public void copyFile( String sourceFile, String destFile, boolean filtering,
- boolean overwrite )
- throws IOException
- {
- fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null, overwrite );
- }
-
- /**
- * Convienence method to copy a file from a source to a destination
- * specifying if token filtering must be used, if source files may overwrite
- * newer destination files and the last modified time of destFile
- * file should be made equal to the last modified time of sourceFile
- * .
- *
- * @param sourceFile Description of Parameter
- * @param destFile Description of Parameter
- * @param filtering Description of Parameter
- * @param overwrite Description of Parameter
- * @param preserveLastModified Description of Parameter
- * @throws IOException
- * @deprecated
- */
- public void copyFile( String sourceFile, String destFile, boolean filtering,
- boolean overwrite, boolean preserveLastModified )
- throws IOException
- {
- fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null,
- overwrite, preserveLastModified );
- }
-
- /**
- * Convienence method to copy a file from a source to a destination. No
- * filtering is performed.
- *
- * @param sourceFile Description of Parameter
- * @param destFile Description of Parameter
- * @throws IOException
- * @deprecated
- */
- public void copyFile( File sourceFile, File destFile )
- throws IOException
- {
- fileUtils.copyFile( sourceFile, destFile );
- }
-
- /**
- * Convienence method to copy a file from a source to a destination
- * specifying if token filtering must be used.
- *
- * @param sourceFile Description of Parameter
- * @param destFile Description of Parameter
- * @param filtering Description of Parameter
- * @throws IOException
- * @deprecated
- */
- public void copyFile( File sourceFile, File destFile, boolean filtering )
- throws IOException
- {
- fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null );
- }
-
- /**
- * Convienence method to copy a file from a source to a destination
- * specifying if token filtering must be used and if source files may
- * overwrite newer destination files.
- *
- * @param sourceFile Description of Parameter
- * @param destFile Description of Parameter
- * @param filtering Description of Parameter
- * @param overwrite Description of Parameter
- * @throws IOException
- * @deprecated
- */
- public void copyFile( File sourceFile, File destFile, boolean filtering,
- boolean overwrite )
- throws IOException
- {
- fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null, overwrite );
- }
-
- /**
- * Convienence method to copy a file from a source to a destination
- * specifying if token filtering must be used, if source files may overwrite
- * newer destination files and the last modified time of destFile
- * file should be made equal to the last modified time of sourceFile
- * .
- *
- * @param sourceFile Description of Parameter
- * @param destFile Description of Parameter
- * @param filtering Description of Parameter
- * @param overwrite Description of Parameter
- * @param preserveLastModified Description of Parameter
- * @throws IOException
- * @deprecated
- */
- public void copyFile( File sourceFile, File destFile, boolean filtering,
- boolean overwrite, boolean preserveLastModified )
- throws IOException
- {
- fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null,
- overwrite, preserveLastModified );
- }
-
/**
* create a new DataType instance
*
* @param typeName name of the datatype
* @return null if the datatype name is unknown
- * @throws BuildException when datatype creation goes bad
+ * @throws TaskException when datatype creation goes bad
*/
public Object createDataType( String typeName )
- throws BuildException
+ throws TaskException
{
- Class c = ( Class )dataClassDefinitions.get( typeName );
+ Class c = (Class)dataClassDefinitions.get( typeName );
if( c == null )
return null;
@@ -983,7 +768,7 @@ public class Project
// Project argument.
try
{
- ctor = c.getConstructor( new Class[0] );
+ ctor = c.getConstructor( new Class[ 0 ] );
noArg = true;
}
catch( NoSuchMethodException nse )
@@ -995,7 +780,7 @@ public class Project
Object o = null;
if( noArg )
{
- o = ctor.newInstance( new Object[0] );
+ o = ctor.newInstance( new Object[ 0 ] );
}
else
{
@@ -1003,7 +788,7 @@ public class Project
}
if( o instanceof ProjectComponent )
{
- ( ( ProjectComponent )o ).setProject( this );
+ ( (ProjectComponent)o ).setProject( this );
}
String msg = " +DataType: " + typeName;
log( msg, MSG_DEBUG );
@@ -1013,14 +798,14 @@ public class Project
{
Throwable t = ite.getTargetException();
String msg = "Could not create datatype of type: "
- + typeName + " due to " + t;
- throw new BuildException( msg, t );
+ + typeName + " due to " + t;
+ throw new TaskException( msg, t );
}
catch( Throwable t )
{
String msg = "Could not create datatype of type: "
- + typeName + " due to " + t;
- throw new BuildException( msg, t );
+ + typeName + " due to " + t;
+ throw new TaskException( msg, t );
}
}
@@ -1029,12 +814,12 @@ public class Project
*
* @param taskType name of the task
* @return null if the task name is unknown
- * @throws BuildException when task creation goes bad
+ * @throws TaskException when task creation goes bad
*/
public Task createTask( String taskType )
- throws BuildException
+ throws TaskException
{
- Class c = ( Class )taskClassDefinitions.get( taskType );
+ Class c = (Class)taskClassDefinitions.get( taskType );
if( c == null )
return null;
@@ -1044,7 +829,7 @@ public class Project
Task task = null;
if( o instanceof Task )
{
- task = ( Task )o;
+ task = (Task)o;
}
else
{
@@ -1068,14 +853,14 @@ public class Project
catch( Throwable t )
{
String msg = "Could not create task of type: "
- + taskType + " due to " + t;
- throw new BuildException( msg, t );
+ + taskType + " due to " + t;
+ throw new TaskException( msg, t );
}
}
public void demuxOutput( String line, boolean isError )
{
- Task task = ( Task )threadTasks.get( Thread.currentThread() );
+ Task task = (Task)threadTasks.get( Thread.currentThread() );
if( task == null )
{
fireMessageLogged( this, line, isError ? MSG_ERR : MSG_INFO );
@@ -1097,10 +882,10 @@ public class Project
* execute the targets and any targets it depends on
*
* @param targetName the target to execute
- * @throws BuildException if the build failed
+ * @throws TaskException if the build failed
*/
public void executeTarget( String targetName )
- throws BuildException
+ throws TaskException
{
// sanity check ourselves, if we've been asked to build nothing
@@ -1109,7 +894,7 @@ public class Project
if( targetName == null )
{
String msg = "No target specified";
- throw new BuildException( msg );
+ throw new TaskException( msg );
}
// Sort the dependency tree, and run everything from the
@@ -1124,25 +909,25 @@ public class Project
do
{
- curtarget = ( Target )sortedTargets.elementAt( curidx++ );
+ curtarget = (Target)sortedTargets.elementAt( curidx++ );
curtarget.performTasks();
- }while ( !curtarget.getName().equals( targetName ) );
+ } while( !curtarget.getName().equals( targetName ) );
}
/**
* execute the sequence of targets, and the targets they depend on
*
* @param targetNames Description of Parameter
- * @throws BuildException if the build failed
+ * @throws TaskException if the build failed
*/
public void executeTargets( Vector targetNames )
- throws BuildException
+ throws TaskException
{
Throwable error = null;
for( int i = 0; i < targetNames.size(); i++ )
{
- executeTarget( ( String )targetNames.elementAt( i ) );
+ executeTarget( (String)targetNames.elementAt( i ) );
}
}
@@ -1150,10 +935,10 @@ public class Project
* Initialise the project. This involves setting the default task
* definitions and loading the system properties.
*
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public void init()
- throws BuildException
+ throws TaskException
{
setJavaVersionProperty();
@@ -1165,7 +950,7 @@ public class Project
InputStream in = this.getClass().getResourceAsStream( defs );
if( in == null )
{
- throw new BuildException( "Can't load default task list" );
+ throw new TaskException( "Can't load default task list" );
}
props.load( in );
in.close();
@@ -1173,7 +958,7 @@ public class Project
Enumeration enum = props.propertyNames();
while( enum.hasMoreElements() )
{
- String key = ( String )enum.nextElement();
+ String key = (String)enum.nextElement();
String value = props.getProperty( key );
try
{
@@ -1192,7 +977,7 @@ public class Project
}
catch( IOException ioe )
{
- throw new BuildException( "Can't load default task list" );
+ throw new TaskException( "Can't load default task list" );
}
String dataDefs = "/org/apache/tools/ant/types/defaults.properties";
@@ -1203,7 +988,7 @@ public class Project
InputStream in = this.getClass().getResourceAsStream( dataDefs );
if( in == null )
{
- throw new BuildException( "Can't load default datatype list" );
+ throw new TaskException( "Can't load default datatype list" );
}
props.load( in );
in.close();
@@ -1211,7 +996,7 @@ public class Project
Enumeration enum = props.propertyNames();
while( enum.hasMoreElements() )
{
- String key = ( String )enum.nextElement();
+ String key = (String)enum.nextElement();
String value = props.getProperty( key );
try
{
@@ -1230,7 +1015,7 @@ public class Project
}
catch( IOException ioe )
{
- throw new BuildException( "Can't load default datatype list" );
+ throw new TaskException( "Can't load default datatype list" );
}
setSystemProperties();
@@ -1296,34 +1081,14 @@ public class Project
*
* @param value the string to be scanned for property references.
* @return Description of the Returned Value
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
public String replaceProperties( String value )
- throws BuildException
+ throws TaskException
{
return ProjectHelper.replaceProperties( this, value );
}
- /**
- * Return the canonical form of fileName as an absolute path.
- * - * If fileName is a relative file name, resolve it relative to rootDir.
- * - * @param fileName Description of Parameter - * @param rootDir Description of Parameter - * @return Description of the Returned Value - * @deprecated - */ - public File resolveFile( String fileName, File rootDir ) - { - return fileUtils.resolveFile( rootDir, fileName ); - } - - public File resolveFile( String fileName ) - { - return fileUtils.resolveFile( baseDir, fileName ); - } - /** * send build finished event to the listeners * @@ -1335,7 +1100,7 @@ public class Project event.setException( exception ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.buildFinished( event ); } } @@ -1348,7 +1113,7 @@ public class Project BuildEvent event = new BuildEvent( this ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.buildStarted( event ); } } @@ -1383,12 +1148,11 @@ public class Project event.setException( exception ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.targetFinished( event ); } } - /** * send target started event to the listeners * @@ -1399,7 +1163,7 @@ public class Project BuildEvent event = new BuildEvent( target ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.targetStarted( event ); } } @@ -1413,7 +1177,7 @@ public class Project event.setException( exception ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.taskFinished( event ); } } @@ -1425,7 +1189,7 @@ public class Project BuildEvent event = new BuildEvent( task ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.taskStarted( event ); } } @@ -1455,7 +1219,7 @@ public class Project // exactly the target names in "state" that are in the VISITING state.) // 1. Set the current target to the VISITING state, and push it onto // the "visiting" stack. - // 2. Throw a BuildException if any child of the current node is + // 2. Throw a TaskException if any child of the current node is // in the VISITING state (implies there is a cycle.) It uses the // "visiting" Stack to construct the cycle. // 3. If any children have not been VISITED, tsort() the child. @@ -1467,12 +1231,12 @@ public class Project private final void tsort( String root, Hashtable targets, Hashtable state, Stack visiting, Vector ret ) - throws BuildException + throws TaskException { state.put( root, VISITING ); visiting.push( root ); - Target target = ( Target )( targets.get( root ) ); + Target target = (Target)( targets.get( root ) ); // Make sure we exist if( target == null ) @@ -1483,19 +1247,19 @@ public class Project visiting.pop(); if( !visiting.empty() ) { - String parent = ( String )visiting.peek(); + String parent = (String)visiting.peek(); sb.append( "It is used from target `" ); sb.append( parent ); sb.append( "'." ); } - throw new BuildException( new String( sb ) ); + throw new TaskException( new String( sb ) ); } - for( Enumeration en = target.getDependencies(); en.hasMoreElements(); ) + for( Enumeration en = target.getDependencies(); en.hasMoreElements(); ) { - String cur = ( String )en.nextElement(); - String m = ( String )state.get( cur ); + String cur = (String)en.nextElement(); + String m = (String)state.get( cur ); if( m == null ) { // Not been visited @@ -1508,7 +1272,7 @@ public class Project } } - String p = ( String )visiting.pop(); + String p = (String)visiting.pop(); if( root != p ) { throw new RuntimeException( "Unexpected internal error: expected to pop " + root + " but got " + p ); @@ -1528,7 +1292,7 @@ public class Project { synchronized( createdTasks ) { - Vector v = ( Vector )createdTasks.get( type ); + Vector v = (Vector)createdTasks.get( type ); if( v == null ) { v = new Vector(); @@ -1543,7 +1307,7 @@ public class Project event.setMessage( message, priority ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.messageLogged( event ); } } @@ -1558,13 +1322,13 @@ public class Project { synchronized( createdTasks ) { - Vector v = ( Vector )createdTasks.get( type ); + Vector v = (Vector)createdTasks.get( type ); if( v != null ) { Enumeration enum = v.elements(); while( enum.hasMoreElements() ) { - Task t = ( Task )enum.nextElement(); + Task t = (Task)enum.nextElement(); t.markInvalid(); } v.removeAllElements(); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/ProjectComponent.java b/proposal/myrmidon/src/main/org/apache/tools/ant/ProjectComponent.java index c7ddf7f96..f8fd3320a 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/ProjectComponent.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/ProjectComponent.java @@ -8,6 +8,8 @@ package org.apache.tools.ant; import org.apache.myrmidon.api.AbstractTask; +import org.apache.tools.ant.util.FileUtils; +import java.io.File; /** * Base class for components of a project, including tasks and data types. @@ -43,6 +45,11 @@ public abstract class ProjectComponent return project; } + protected File resolveFile( final String name ) + { + return FileUtils.newFileUtils().resolveFile( project.getBaseDir(), name ); + } + /** * Log a message with the default (INFO) priority. * diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/ProjectHelper.java b/proposal/myrmidon/src/main/org/apache/tools/ant/ProjectHelper.java index 896a0d8f8..9e55dc561 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/ProjectHelper.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/ProjectHelper.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -17,6 +18,8 @@ import java.util.Vector; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import org.apache.myrmidon.api.TaskException; +import org.apache.tools.ant.util.FileUtils; import org.xml.sax.AttributeList; import org.xml.sax.DocumentHandler; import org.xml.sax.HandlerBase; @@ -64,10 +67,10 @@ public class ProjectHelper * @param buf The feature to be added to the Text attribute * @param start The feature to be added to the Text attribute * @param end The feature to be added to the Text attribute - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public static void addText( Project project, Object target, char[] buf, int start, int end ) - throws BuildException + throws TaskException { addText( project, target, new String( buf, start, end ) ); } @@ -78,10 +81,10 @@ public class ProjectHelper * @param project The feature to be added to the Text attribute * @param target The feature to be added to the Text attribute * @param text The feature to be added to the Text attribute - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public static void addText( Project project, Object target, String text ) - throws BuildException + throws TaskException { if( text == null || text.trim().length() == 0 ) @@ -90,17 +93,17 @@ public class ProjectHelper } if( target instanceof TaskAdapter ) - target = ( ( TaskAdapter )target ).getProxy(); + target = ( (TaskAdapter)target ).getProxy(); IntrospectionHelper.getHelper( target.getClass() ).addText( project, target, text ); } public static void configure( Object target, AttributeList attrs, Project project ) - throws BuildException + throws TaskException { if( target instanceof TaskAdapter ) - target = ( ( TaskAdapter )target ).getProxy(); + target = ( (TaskAdapter)target ).getProxy(); IntrospectionHelper ih = IntrospectionHelper.getHelper( target.getClass() ); @@ -111,14 +114,14 @@ public class ProjectHelper { // reflect these into the target String value = replaceProperties( project, attrs.getValue( i ), - project.getProperties() ); + project.getProperties() ); try { ih.setAttribute( project, target, - attrs.getName( i ).toLowerCase( Locale.US ), value ); + attrs.getName( i ).toLowerCase( Locale.US ), value ); } - catch( BuildException be ) + catch( TaskException be ) { // id attribute must be set externally if( !attrs.getName( i ).equals( "id" ) ) @@ -134,10 +137,10 @@ public class ProjectHelper * * @param project Description of Parameter * @param buildFile Description of Parameter - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public static void configureProject( Project project, File buildFile ) - throws BuildException + throws TaskException { new ProjectHelper( project, buildFile ).parse(); } @@ -151,10 +154,10 @@ public class ProjectHelper * @param value Description of Parameter * @param fragments Description of Parameter * @param propertyRefs Description of Parameter - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public static void parsePropertyString( String value, Vector fragments, Vector propertyRefs ) - throws BuildException + throws TaskException { int prev = 0; int pos; @@ -180,8 +183,8 @@ public class ProjectHelper int endName = value.indexOf( '}', pos ); if( endName < 0 ) { - throw new BuildException( "Syntax error in property: " - + value ); + throw new TaskException( "Syntax error in property: " + + value ); } String propertyName = value.substring( pos + 2, endName ); fragments.addElement( null ); @@ -203,11 +206,11 @@ public class ProjectHelper * @param value the string to be scanned for property references. * @param project Description of Parameter * @return Description of the Returned Value - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception * @since 1.5 */ public static String replaceProperties( Project project, String value ) - throws BuildException + throws TaskException { return replaceProperties( project, value, project.getProperties() ); } @@ -220,10 +223,10 @@ public class ProjectHelper * @param project Description of Parameter * @param keys Description of Parameter * @return Description of the Returned Value - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public static String replaceProperties( Project project, String value, Hashtable keys ) - throws BuildException + throws TaskException { if( value == null ) { @@ -239,16 +242,16 @@ public class ProjectHelper Enumeration j = propertyRefs.elements(); while( i.hasMoreElements() ) { - String fragment = ( String )i.nextElement(); + String fragment = (String)i.nextElement(); if( fragment == null ) { - String propertyName = ( String )j.nextElement(); + String propertyName = (String)j.nextElement(); if( !keys.containsKey( propertyName ) ) { project.log( "Property ${" + propertyName + "} has not been set", Project.MSG_VERBOSE ); } - fragment = ( keys.containsKey( propertyName ) ) ? ( String )keys.get( propertyName ) - : "${" + propertyName + "}"; + fragment = ( keys.containsKey( propertyName ) ) ? (String)keys.get( propertyName ) + : "${" + propertyName + "}"; } sb.append( fragment ); } @@ -265,6 +268,7 @@ public class ProjectHelper * @param tag Description of Parameter */ public static void storeChild( Project project, Object parent, Object child, String tag ) + throws TaskException { IntrospectionHelper ih = IntrospectionHelper.getHelper( parent.getClass() ); ih.storeElement( project, parent, child, tag ); @@ -302,10 +306,10 @@ public class ProjectHelper /** * Parses the project file. * - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ private void parse() - throws BuildException + throws TaskException { FileInputStream inputStream = null; InputSource inputSource = null; @@ -329,7 +333,7 @@ public class ProjectHelper } catch( ParserConfigurationException exc ) { - throw new BuildException( "Parser has not been configured correctly", exc ); + throw new TaskException( "Parser has not been configured correctly", exc ); } catch( SAXParseException exc ) { @@ -339,7 +343,7 @@ public class ProjectHelper Throwable t = exc.getException(); if( t instanceof BuildException ) { - BuildException be = ( BuildException )t; + BuildException be = (BuildException)t; if( be.getLocation() == Location.UNKNOWN_LOCATION ) { be.setLocation( location ); @@ -347,24 +351,24 @@ public class ProjectHelper throw be; } - throw new BuildException( exc.getMessage(), t, location ); + throw new BuildException( exc.getMessage(), t ); } catch( SAXException exc ) { Throwable t = exc.getException(); - if( t instanceof BuildException ) + if( t instanceof TaskException ) { - throw ( BuildException )t; + throw (TaskException)t; } - throw new BuildException( exc.getMessage(), t ); + throw new TaskException( exc.getMessage(), t ); } catch( FileNotFoundException exc ) { - throw new BuildException( exc ); + throw new TaskException( "Error", exc ); } catch( IOException exc ) { - throw new BuildException( "Error reading project file", exc ); + throw new TaskException( "Error reading project file", exc ); } finally { @@ -434,7 +438,9 @@ public class ProjectHelper * Called when this element and all elements nested into it have been * handled. */ - protected void finished() { } + protected void finished() + { + } } /** @@ -466,21 +472,21 @@ public class ProjectHelper { addText( project, element, buf, start, end ); } - catch( BuildException exc ) + catch( TaskException exc ) { throw new SAXParseException( exc.getMessage(), locator, exc ); } } public void init( String propType, AttributeList attrs ) - throws SAXParseException + throws SAXParseException, TaskException { try { element = project.createDataType( propType ); if( element == null ) { - throw new BuildException( "Unknown data type " + propType ); + throw new TaskException( "Unknown data type " + propType ); } if( target != null ) @@ -495,7 +501,7 @@ public class ProjectHelper configureId( element, attrs ); } } - catch( BuildException exc ) + catch( TaskException exc ) { throw new SAXParseException( exc.getMessage(), locator, exc ); } @@ -530,7 +536,7 @@ public class ProjectHelper if( parent instanceof TaskAdapter ) { - this.parent = ( ( TaskAdapter )parent ).getProxy(); + this.parent = ( (TaskAdapter)parent ).getProxy(); } else { @@ -549,7 +555,7 @@ public class ProjectHelper { addText( project, child, buf, start, end ); } - catch( BuildException exc ) + catch( TaskException exc ) { throw new SAXParseException( exc.getMessage(), locator, exc ); } @@ -574,7 +580,7 @@ public class ProjectHelper { UnknownElement uc = new UnknownElement( elementName ); uc.setProject( project ); - ( ( UnknownElement )parent ).addChild( uc ); + ( (UnknownElement)parent ).addChild( uc ); child = uc; } else @@ -596,7 +602,7 @@ public class ProjectHelper ih.storeElement( project, parent, child, elementName ); } } - catch( BuildException exc ) + catch( TaskException exc ) { throw new SAXParseException( exc.getMessage(), locator, exc ); } @@ -609,7 +615,7 @@ public class ProjectHelper { // taskcontainer nested element can contain other tasks - no other // nested elements possible - new TaskHandler( this, ( TaskContainer )child, childWrapper, target ).init( name, attrs ); + new TaskHandler( this, (TaskContainer)child, childWrapper, target ).init( name, attrs ); } else { @@ -631,7 +637,7 @@ public class ProjectHelper } public void init( String tag, AttributeList attrs ) - throws SAXParseException + throws SAXParseException, TaskException { String def = null; String name = null; @@ -668,10 +674,10 @@ public class ProjectHelper if( def == null ) { throw new SAXParseException( "The default attribute of project is required", - locator ); + locator ); } - project.setDefaultTarget( def ); + project.setDefault( def ); if( name != null ) { @@ -701,7 +707,7 @@ public class ProjectHelper } else { - project.setBaseDir( project.resolveFile( baseDir, buildFileParent ) ); + project.setBaseDir( FileUtils.newFileUtils().resolveFile( buildFileParent, baseDir ) ); } } } @@ -833,7 +839,7 @@ public class ProjectHelper catch( FileNotFoundException fne ) { project.log( file.getAbsolutePath() + " could not be found", - Project.MSG_WARN ); + Project.MSG_WARN ); } } // use default if not file or file not found @@ -980,7 +986,7 @@ public class ProjectHelper { addText( project, task, buf, start, end ); } - catch( BuildException exc ) + catch( TaskException exc ) { throw new SAXParseException( exc.getMessage(), locator, exc ); } @@ -998,7 +1004,7 @@ public class ProjectHelper { task = project.createTask( tag ); } - catch( BuildException e ) + catch( TaskException e ) { // swallow here, will be thrown again in // UnknownElement.maybeConfigure if the problem persists. @@ -1041,7 +1047,7 @@ public class ProjectHelper if( task instanceof TaskContainer ) { // task can contain other tasks - no other nested elements possible - new TaskHandler( this, ( TaskContainer )task, wrapper, target ).init( name, attrs ); + new TaskHandler( this, (TaskContainer)task, wrapper, target ).init( name, attrs ); } else { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/RuntimeConfigurable.java b/proposal/myrmidon/src/main/org/apache/tools/ant/RuntimeConfigurable.java index 4acd55108..e55ad54c9 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/RuntimeConfigurable.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/RuntimeConfigurable.java @@ -11,6 +11,7 @@ import java.util.Locale; import java.util.Vector; import org.xml.sax.AttributeList; import org.xml.sax.helpers.AttributeListImpl; +import org.apache.myrmidon.api.TaskException; /** * Wrapper class that holds the attributes of a Task (or elements nested below @@ -102,7 +103,7 @@ public class RuntimeConfigurable * @exception BuildException Description of Exception */ public void maybeConfigure( Project p ) - throws BuildException + throws TaskException { String id = null; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/Target.java b/proposal/myrmidon/src/main/org/apache/tools/ant/Target.java index 78cb4f980..38b0cac3e 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/Target.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/Target.java @@ -6,9 +6,11 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.util.Enumeration; import java.util.StringTokenizer; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; /** * This class implements a target object with required parameters. @@ -28,6 +30,7 @@ public class Target implements TaskContainer private Project project; public void setDepends( String depS ) + throws TaskException { if( depS.length() > 0 ) { @@ -40,9 +43,9 @@ public class Target implements TaskContainer //Make sure the dependency is not empty string if( token.equals( "" ) || token.equals( "," ) ) { - throw new BuildException( "Syntax Error: Depend attribute " + - "for target \"" + getName() + - "\" has an empty string for dependency." ); + throw new TaskException( "Syntax Error: Depend attribute " + + "for target \"" + getName() + + "\" has an empty string for dependency." ); } addDependency( token ); @@ -54,9 +57,9 @@ public class Target implements TaskContainer token = tok.nextToken(); if( !tok.hasMoreTokens() || !token.equals( "," ) ) { - throw new BuildException( "Syntax Error: Depend attribute " + - "for target \"" + getName() + - "\" ends with a , character" ); + throw new TaskException( "Syntax Error: Depend attribute " + + "for target \"" + getName() + + "\" ends with a , character" ); } } } @@ -126,7 +129,7 @@ public class Target implements TaskContainer } } - Task[] retval = new Task[tasks.size()]; + Task[] retval = new Task[ tasks.size() ]; tasks.copyInto( retval ); return retval; } @@ -139,6 +142,10 @@ public class Target implements TaskContainer execute(); project.fireTargetFinished( this, null ); } + catch( final TaskException te ) + { + project.fireTargetFinished( this, te ); + } catch( RuntimeException exc ) { project.fireTargetFinished( this, exc ); @@ -162,7 +169,7 @@ public class Target implements TaskContainer } public void execute() - throws BuildException + throws TaskException { if( testIfCondition() && testUnlessCondition() ) { @@ -172,12 +179,12 @@ public class Target implements TaskContainer Object o = enum.nextElement(); if( o instanceof Task ) { - Task task = ( Task )o; + Task task = (Task)o; task.perform(); } else { - RuntimeConfigurable r = ( RuntimeConfigurable )o; + RuntimeConfigurable r = (RuntimeConfigurable)o; r.maybeConfigure( project ); } } @@ -185,12 +192,12 @@ public class Target implements TaskContainer else if( !testIfCondition() ) { project.log( this, "Skipped because property '" + this.ifCondition + "' not set.", - Project.MSG_VERBOSE ); + Project.MSG_VERBOSE ); } else { project.log( this, "Skipped because property '" + this.unlessCondition + "' set.", - Project.MSG_VERBOSE ); + Project.MSG_VERBOSE ); } } @@ -209,6 +216,7 @@ public class Target implements TaskContainer } private boolean testIfCondition() + throws TaskException { if( "".equals( ifCondition ) ) { @@ -220,6 +228,7 @@ public class Target implements TaskContainer } private boolean testUnlessCondition() + throws TaskException { if( "".equals( unlessCondition ) ) { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java b/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java index 7a08963ea..d0c6d3c8d 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/Task.java @@ -7,7 +7,9 @@ */ package org.apache.tools.ant; +import java.io.File; import org.apache.myrmidon.api.TaskException; +import org.apache.tools.ant.util.FileUtils; public abstract class Task extends ProjectComponent diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/TaskAdapter.java b/proposal/myrmidon/src/main/org/apache/tools/ant/TaskAdapter.java index 6f7ebcbf1..4cc0b1a97 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/TaskAdapter.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/TaskAdapter.java @@ -8,6 +8,7 @@ package org.apache.tools.ant; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import org.apache.myrmidon.api.TaskException; /** @@ -33,6 +34,7 @@ public class TaskAdapter extends Task * @param project Description of Parameter */ public static void checkTaskClass( final Class taskClass, final Project project ) + throws TaskException { // don't have to check for interface, since then // taskClass would be abstract too. @@ -53,7 +55,7 @@ public class TaskAdapter extends Task { final String message = "No public execute() in " + taskClass; project.log( message, Project.MSG_ERR ); - throw new BuildException( message ); + throw new TaskException( message ); } } @@ -100,7 +102,7 @@ public class TaskAdapter extends Task { log( "Error setting project in " + proxy.getClass(), Project.MSG_ERR ); - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } Method executeM = null; @@ -111,7 +113,7 @@ public class TaskAdapter extends Task if( executeM == null ) { log( "No public execute() in " + proxy.getClass(), Project.MSG_ERR ); - throw new BuildException( "No public execute() in " + proxy.getClass() ); + throw new TaskException( "No public execute() in " + proxy.getClass() ); } executeM.invoke( proxy, null ); return; @@ -119,7 +121,7 @@ public class TaskAdapter extends Task catch( Exception ex ) { log( "Error in " + proxy.getClass(), Project.MSG_ERR ); - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/UnknownElement.java b/proposal/myrmidon/src/main/org/apache/tools/ant/UnknownElement.java index efe3b6046..69f21d197 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/UnknownElement.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/UnknownElement.java @@ -6,7 +6,9 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.util.Vector; +import org.apache.myrmidon.api.TaskException; /** * Wrapper class that holds all information necessary to create a task or data @@ -57,7 +59,7 @@ public class UnknownElement extends Task { if( realThing != null && realThing instanceof Task ) { - return ( Task )realThing; + return (Task)realThing; } return null; } @@ -70,7 +72,7 @@ public class UnknownElement extends Task public String getTaskName() { return realThing == null || !( realThing instanceof Task ) ? - super.getTaskName() : ( ( Task )realThing ).getTaskName(); + super.getTaskName() : ( (Task)realThing ).getTaskName(); } /** @@ -87,18 +89,19 @@ public class UnknownElement extends Task * Called when the real task has been configured for the first time. */ public void execute() + throws TaskException { if( realThing == null ) { // plain impossible to get here, maybeConfigure should // have thrown an exception. - throw new BuildException( "Could not create task of type: " - + elementName, location ); + throw new TaskException( "Could not create task of type: " + + elementName ); } if( realThing instanceof Task ) { - ( ( Task )realThing ).perform(); + ( (Task)realThing ).perform(); } } @@ -109,14 +112,14 @@ public class UnknownElement extends Task * @exception BuildException Description of Exception */ public void maybeConfigure() - throws BuildException + throws TaskException { realThing = makeObject( this, wrapper ); wrapper.setProxy( realThing ); if( realThing instanceof Task ) { - ( ( Task )realThing ).setRuntimeConfigurableWrapper( wrapper ); + ( (Task)realThing ).setRuntimeConfigurableWrapper( wrapper ); } handleChildren( realThing, wrapper ); @@ -137,19 +140,19 @@ public class UnknownElement extends Task { String lSep = System.getProperty( "line.separator" ); String msg = "Could not create " + what + " of type: " + elementName - + "." + lSep - + "Ant could not find the task or a class this" + lSep - + "task relies upon." + lSep - + "Common solutions are to use taskdef to declare" + lSep - + "your task, or, if this is an optional task," + lSep - + "to put the optional.jar and all required libraries of" + lSep - + "this task in the lib directory of" + lSep - + "your ant installation (ANT_HOME)." + lSep - + "There is also the possibility that your build file " + lSep - + "is written to work with a more recent version of ant " + lSep - + "than the one you are using, in which case you have to " + lSep - + "upgrade."; - return new BuildException( msg, location ); + + "." + lSep + + "Ant could not find the task or a class this" + lSep + + "task relies upon." + lSep + + "Common solutions are to use taskdef to declare" + lSep + + "your task, or, if this is an optional task," + lSep + + "to put the optional.jar and all required libraries of" + lSep + + "this task in the lib directory of" + lSep + + "your ant installation (ANT_HOME)." + lSep + + "There is also the possibility that your build file " + lSep + + "is written to work with a more recent version of ant " + lSep + + "than the one you are using, in which case you have to " + lSep + + "upgrade."; + return new BuildException( msg ); } /** @@ -162,12 +165,12 @@ public class UnknownElement extends Task */ protected void handleChildren( Object parent, RuntimeConfigurable parentWrapper ) - throws BuildException + throws TaskException { if( parent instanceof TaskAdapter ) { - parent = ( ( TaskAdapter )parent ).getProxy(); + parent = ( (TaskAdapter)parent ).getProxy(); } Class parentClass = parent.getClass(); @@ -176,13 +179,13 @@ public class UnknownElement extends Task for( int i = 0; i < children.size(); i++ ) { RuntimeConfigurable childWrapper = parentWrapper.getChild( i ); - UnknownElement child = ( UnknownElement )children.elementAt( i ); + UnknownElement child = (UnknownElement)children.elementAt( i ); Object realChild = null; if( parent instanceof TaskContainer ) { realChild = makeTask( child, childWrapper, false ); - ( ( TaskContainer )parent ).addTask( ( Task )realChild ); + ( (TaskContainer)parent ).addTask( (Task)realChild ); } else { @@ -192,14 +195,14 @@ public class UnknownElement extends Task childWrapper.setProxy( realChild ); if( parent instanceof TaskContainer ) { - ( ( Task )realChild ).setRuntimeConfigurableWrapper( childWrapper ); + ( (Task)realChild ).setRuntimeConfigurableWrapper( childWrapper ); } child.handleChildren( realChild, childWrapper ); if( parent instanceof TaskContainer ) { - ( ( Task )realChild ).maybeConfigure(); + ( (Task)realChild ).maybeConfigure(); } } } @@ -213,6 +216,7 @@ public class UnknownElement extends Task * @return Description of the Returned Value */ protected Object makeObject( UnknownElement ue, RuntimeConfigurable w ) + throws TaskException { Object o = makeTask( ue, w, true ); if( o == null ) @@ -236,6 +240,7 @@ public class UnknownElement extends Task */ protected Task makeTask( UnknownElement ue, RuntimeConfigurable w, boolean onTopLevel ) + throws TaskException { Task task = project.createTask( ue.getTag() ); if( task == null && !onTopLevel ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ant.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ant.java index 937f44cd2..155526136 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ant.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ant.java @@ -22,6 +22,7 @@ import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.Task; import org.apache.tools.ant.util.FileUtils; +import org.apache.myrmidon.api.TaskException; /** * Call Ant in a sub-project@@ -178,10 +179,10 @@ public class Ant extends Task /** * Do the execution. * - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public void execute() - throws BuildException + throws TaskException { try { @@ -234,7 +235,7 @@ public class Ant extends Task target.equals( this.getOwningTarget().getName() ) ) { - throw new BuildException( "ant task calling its own parent target" ); + throw new TaskException( "ant task calling its own parent target" ); } newProject.executeTarget( target ); @@ -283,10 +284,10 @@ public class Ant extends Task * project. Also copy over all references that don't override existing * references in the new project if inheritall has been requested. * - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ private void addReferences() - throws BuildException + throws TaskException { Hashtable thisReferences = ( Hashtable )project.getReferences().clone(); Hashtable newReferences = newProject.getReferences(); @@ -299,7 +300,7 @@ public class Ant extends Task String refid = ref.getRefId(); if( refid == null ) { - throw new BuildException( "the refid attribute is required for reference elements" ); + throw new TaskException( "the refid attribute is required for reference elements" ); } if( !thisReferences.containsKey( refid ) ) { @@ -387,7 +388,7 @@ public class Ant extends Task { String msg = "Error setting new project instance for reference with id " + oldKey; - throw new BuildException( msg, e2, location ); + throw new TaskException( msg, e2, location ); } } newProject.addReference( newKey, copy ); @@ -482,10 +483,10 @@ public class Ant extends Task * Override the properties in the new project with the one explicitly * defined as nested elements here. * - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ private void overrideProperties() - throws BuildException + throws TaskException { Enumeration e = properties.elements(); while( e.hasMoreElements() ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/AntStructure.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/AntStructure.java index 1b1007267..39416e5a4 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/AntStructure.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/AntStructure.java @@ -58,7 +58,7 @@ public class AntStructure extends Task if( output == null ) { - throw new BuildException( "output attribute is required", location ); + throw new BuildException( "output attribute is required" ); } PrintWriter out = null; @@ -106,7 +106,7 @@ public class AntStructure extends Task catch( IOException ioe ) { throw new BuildException( "Error writing " + output.getAbsolutePath(), - ioe, location ); + ioe ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java index a4396a6a0..94c6e8c5a 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Available.java @@ -16,6 +16,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.util.FileUtils; +import org.apache.myrmidon.api.TaskException; /** * Will set the given property if the requested resource is available at @@ -26,7 +27,9 @@ import org.apache.tools.ant.util.FileUtils; * @author Magesh Umasankar */ -public class Available extends Task implements Condition +public class Available + extends Task + implements Condition { private String value = "true"; private String classname; @@ -77,22 +80,8 @@ public class Available extends Task implements Condition this.resource = resource; } - /** - * @param type The new Type value - * @deprecated setType(String) is deprecated and is replaced with - * setType(Available.FileDir) to make Ant's Introspection mechanism do - * the work and also to encapsulate operations on the type in its own - * class. - */ - public void setType( String type ) - { - log( "DEPRECATED - The setType(String) method has been deprecated." - + " Use setType(Available.FileDir) instead." ); - this.type = new FileDir(); - this.type.setValue( type ); - } - public void setType( FileDir type ) + public void setType( FileDir type ) { this.type = type; } @@ -121,18 +110,18 @@ public class Available extends Task implements Condition } public boolean eval() - throws BuildException + throws TaskException { if( classname == null && file == null && resource == null ) { - throw new BuildException( "At least one of (classname|file|resource) is required", location ); + throw new BuildException( "At least one of (classname|file|resource) is required" ); } if( type != null ) { if( file == null ) { - throw new BuildException( "The type attribute is only valid when specifying the file attribute." ); + throw new TaskException( "The type attribute is only valid when specifying the file attribute." ); } } @@ -176,24 +165,21 @@ public class Available extends Task implements Condition } public void execute() - throws BuildException + throws TaskException { if( property == null ) { - throw new BuildException( "property attribute is required", location ); + throw new BuildException( "property attribute is required"); } if( eval() ) { String lSep = System.getProperty( "line.separator" ); - if( null != project.getProperty( property ) ) + if( null == project.getProperty( property ) ) { - log( "DEPRECATED -used to overide an existing property. " - + lSep - + " Build writer should not reuse the same property name for " - + lSep + "different values." ); + this.project.setProperty( property, value ); } - this.project.setProperty( property, value ); + //else ignore } } @@ -235,7 +221,7 @@ public class Available extends Task implements Condition { if( filepath == null ) { - return checkFile( project.resolveFile( file ), file ); + return checkFile( resolveFile( file ), file ); } else { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java index 882af9655..3b2dc6fdf 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java @@ -49,12 +49,12 @@ public class BUnzip2 extends Unpack int b = bis.read(); if( b != 'B' ) { - throw new BuildException( "Invalid bz2 file.", location ); + throw new BuildException( "Invalid bz2 file." ); } b = bis.read(); if( b != 'Z' ) { - throw new BuildException( "Invalid bz2 file.", location ); + throw new BuildException( "Invalid bz2 file." ); } zIn = new CBZip2InputStream( bis ); byte[] buffer = new byte[8 * 1024]; @@ -68,7 +68,7 @@ public class BUnzip2 extends Unpack catch( IOException ioe ) { String msg = "Problem expanding bzip2 " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BZip2.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BZip2.java index 9c3cdc401..be8635f3f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BZip2.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/BZip2.java @@ -37,7 +37,7 @@ public class BZip2 extends Pack catch( IOException ioe ) { String msg = "Problem creating bzip2 " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CVSPass.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CVSPass.java index 356579a4a..44b7ed617 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CVSPass.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CVSPass.java @@ -14,6 +14,7 @@ import java.io.IOException; import java.io.PrintWriter; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; +import org.apache.myrmidon.api.TaskException; /** * CVSLogin Adds an new entry to a CVS password file @@ -105,9 +106,9 @@ public class CVSPass extends Task throws BuildException { if( cvsRoot == null ) - throw new BuildException( "cvsroot is required" ); + throw new TaskException( "cvsroot is required" ); if( password == null ) - throw new BuildException( "password is required" ); + throw new TaskException( "password is required" ); log( "cvsRoot: " + cvsRoot, project.MSG_DEBUG ); log( "password: " + password, project.MSG_DEBUG ); @@ -147,7 +148,7 @@ public class CVSPass extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CallTarget.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CallTarget.java index 80f570e08..3fdb80063 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CallTarget.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/CallTarget.java @@ -77,8 +77,7 @@ public class CallTarget extends Task if( subTarget == null ) { - throw new BuildException( "Attribute target is required.", - location ); + throw new BuildException( "Attribute target is required." ); } callee.setDir( project.getBaseDir() ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java index a778428c5..e9b444d54 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Checksum.java @@ -25,6 +25,7 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.taskdefs.condition.Condition; import org.apache.tools.ant.types.FileSet; +import org.apache.myrmidon.api.TaskException; /** * This task can be used to create checksums for files. It can also be used to @@ -231,7 +232,7 @@ public class Checksum extends MatchingTask implements Condition + file.getAbsolutePath() + " to generate checksum for."; log( message ); - throw new BuildException( message, location ); + throw new BuildException( message ); } } } @@ -328,7 +329,7 @@ public class Checksum extends MatchingTask implements Condition } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { @@ -366,19 +367,19 @@ public class Checksum extends MatchingTask implements Condition if( file == null && filesets.size() == 0 ) { - throw new BuildException( + throw new TaskException( "Specify at least one source - a file or a fileset." ); } if( file != null && file.exists() && file.isDirectory() ) { - throw new BuildException( + throw new TaskException( "Checksum cannot be generated for directories" ); } if( property != null && fileext != null ) { - throw new BuildException( + throw new TaskException( "Property and FileExt cannot co-exist." ); } @@ -386,7 +387,7 @@ public class Checksum extends MatchingTask implements Condition { if( forceOverwrite ) { - throw new BuildException( + throw new TaskException( "ForceOverwrite cannot be used when Property is specified" ); } @@ -394,7 +395,7 @@ public class Checksum extends MatchingTask implements Condition { if( filesets.size() > 0 ) { - throw new BuildException( + throw new TaskException( "Multiple files cannot be used when Property is specified" ); } } @@ -402,7 +403,7 @@ public class Checksum extends MatchingTask implements Condition { if( filesets.size() > 1 ) { - throw new BuildException( + throw new TaskException( "Multiple files cannot be used when Property is specified" ); } } @@ -415,13 +416,13 @@ public class Checksum extends MatchingTask implements Condition if( verifyProperty != null && forceOverwrite ) { - throw new BuildException( + throw new TaskException( "VerifyProperty and ForceOverwrite cannot co-exist." ); } if( isCondition && forceOverwrite ) { - throw new BuildException( + throw new TaskException( "ForceOverwrite cannot be used when conditions are being used." ); } @@ -431,7 +432,7 @@ public class Checksum extends MatchingTask implements Condition } else if( fileext.trim().length() == 0 ) { - throw new BuildException( + throw new TaskException( "File extension when specified must not be an empty string" ); } @@ -444,11 +445,11 @@ public class Checksum extends MatchingTask implements Condition } catch( NoSuchAlgorithmException noalgo ) { - throw new BuildException( noalgo ); + throw new TaskException( noalgo.toString(), noalgo ); } catch( NoSuchProviderException noprovider ) { - throw new BuildException( noprovider ); + throw new TaskException( noprovider.toString(), noprovider ); } } else @@ -459,14 +460,13 @@ public class Checksum extends MatchingTask implements Condition } catch( NoSuchAlgorithmException noalgo ) { - throw new BuildException( noalgo ); + throw new TaskException( noalgo.toString(), noalgo ); } } if( messageDigest == null ) { - throw new BuildException( "Unable to create Message Digest", - location ); + throw new BuildException( "Unable to create Message Digest" ); } addToIncludeFileMap( file ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Chmod.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Chmod.java index 96f736e03..6df33d6bd 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Chmod.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Chmod.java @@ -40,7 +40,7 @@ public class Chmod extends ExecuteOn public void setCommand( String e ) { - throw new BuildException( taskType + " doesn\'t support the command attribute", location ); + throw new BuildException( taskType + " doesn\'t support the command attribute" ); } /** @@ -75,7 +75,7 @@ public class Chmod extends ExecuteOn public void setExecutable( String e ) { - throw new BuildException( taskType + " doesn\'t support the executable attribute", location ); + throw new BuildException( taskType + " doesn\'t support the executable attribute" ); } public void setFile( File src ) @@ -106,7 +106,7 @@ public class Chmod extends ExecuteOn public void setSkipEmptyFilesets( boolean skip ) { - throw new BuildException( taskType + " doesn\'t support the skipemptyfileset attribute", location ); + throw new BuildException( taskType + " doesn\'t support the skipemptyfileset attribute" ); } /** @@ -161,7 +161,7 @@ public class Chmod extends ExecuteOn } catch( IOException e ) { - throw new BuildException( "Execute failed: " + e, e, location ); + throw new BuildException( "Execute failed: " + e, e ); } finally { @@ -180,8 +180,7 @@ public class Chmod extends ExecuteOn { if( !havePerm ) { - throw new BuildException( "Required attribute perm not set in chmod", - location ); + throw new BuildException( "Required attribute perm not set in chmod" ); } if( defaultSetDefined && defaultSet.getDir( project ) != null ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java index da72ebc93..db05c6075 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java @@ -9,6 +9,7 @@ package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.condition.Condition; import org.apache.tools.ant.taskdefs.condition.ConditionBase; +import org.apache.myrmidon.api.TaskException; /** * <condition> task as a generalization of <available> and @@ -57,15 +58,15 @@ public class ConditionTask extends ConditionBase * @since 1.1 */ public void execute() - throws BuildException + throws TaskException { if( countConditions() > 1 ) { - throw new BuildException( "You must not nest more than one condition into " ); + throw new TaskException( "You must not nest more than one condition into " ); } if( countConditions() < 1 ) { - throw new BuildException( "You must nest a condition into " ); + throw new TaskException( "You must nest a condition into " ); } Condition c = ( Condition )getConditions().nextElement(); if( c.eval() ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Copy.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Copy.java index 055c978fd..ba97365c5 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Copy.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Copy.java @@ -6,11 +6,13 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.File; import java.io.IOException; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; @@ -120,19 +122,6 @@ public class Copy extends Task this.forceOverwrite = overwrite; } - /** - * Give the copied files the same last modified time as the original files. - * - * @param preserve The new PreserveLastModified value - * @deprecated setPreserveLastModified(String) has been deprecated and - * replaced with setPreserveLastModified(boolean) to consistently let - * the Introspection mechanism work. - */ - public void setPreserveLastModified( String preserve ) - { - setPreserveLastModified( Project.toBoolean( preserve ) ); - } - /** * Give the copied files the same last modified time as the original files. * @@ -213,8 +202,7 @@ public class Copy extends Task { if( mapperElement != null ) { - throw new BuildException( "Cannot define more than one mapper", - location ); + throw new BuildException( "Cannot define more than one mapper" ); } mapperElement = new Mapper( project ); return mapperElement; @@ -226,7 +214,7 @@ public class Copy extends Task * @exception BuildException Description of Exception */ public void execute() - throws BuildException + throws TaskException { // make sure we don't have an illegal set of options validateAttributes(); @@ -249,22 +237,22 @@ public class Copy extends Task else { log( file + " omitted as " + destFile + " is up to date.", - Project.MSG_VERBOSE ); + Project.MSG_VERBOSE ); } } else { String message = "Could not find file " - + file.getAbsolutePath() + " to copy."; + + file.getAbsolutePath() + " to copy."; log( message ); - throw new BuildException( message ); + throw new TaskException( message ); } } // deal with the filesets for( int i = 0; i < filesets.size(); i++ ) { - FileSet fs = ( FileSet )filesets.elementAt( i ); + FileSet fs = (FileSet)filesets.elementAt( i ); DirectoryScanner ds = fs.getDirectoryScanner( project ); File fromDir = fs.getDir( project ); @@ -272,7 +260,7 @@ public class Copy extends Task String[] srcDirs = ds.getIncludedDirectories(); boolean isEverythingIncluded = ds.isEverythingIncluded(); if( isEverythingIncluded - && !flatten && mapperElement == null ) + && !flatten && mapperElement == null ) { completeDirMap.put( fromDir, destDir ); } @@ -315,12 +303,12 @@ public class Copy extends Task Vector v = new Vector(); for( int i = 0; i < names.length; i++ ) { - if( mapper.mapFileName( names[i] ) != null ) + if( mapper.mapFileName( names[ i ] ) != null ) { - v.addElement( names[i] ); + v.addElement( names[ i ] ); } } - toCopy = new String[v.size()]; + toCopy = new String[ v.size() ]; v.copyInto( toCopy ); } else @@ -331,8 +319,8 @@ public class Copy extends Task for( int i = 0; i < toCopy.length; i++ ) { - File src = new File( fromDir, toCopy[i] ); - File dest = new File( toDir, mapper.mapFileName( toCopy[i] )[0] ); + File src = new File( fromDir, toCopy[ i ] ); + File dest = new File( toDir, mapper.mapFileName( toCopy[ i ] )[ 0 ] ); map.put( src.getAbsolutePath(), dest.getAbsolutePath() ); } } @@ -346,14 +334,14 @@ public class Copy extends Task if( fileCopyMap.size() > 0 ) { log( "Copying " + fileCopyMap.size() + - " file" + ( fileCopyMap.size() == 1 ? "" : "s" ) + - " to " + destDir.getAbsolutePath() ); + " file" + ( fileCopyMap.size() == 1 ? "" : "s" ) + + " to " + destDir.getAbsolutePath() ); Enumeration e = fileCopyMap.keys(); while( e.hasMoreElements() ) { - String fromFile = ( String )e.nextElement(); - String toFile = ( String )fileCopyMap.get( fromFile ); + String fromFile = (String)e.nextElement(); + String toFile = (String)fileCopyMap.get( fromFile ); if( fromFile.equals( toFile ) ) { @@ -370,18 +358,18 @@ public class Copy extends Task { executionFilters.addFilterSet( project.getGlobalFilterSet() ); } - for( Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements(); ) + for( Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements(); ) { - executionFilters.addFilterSet( ( FilterSet )filterEnum.nextElement() ); + executionFilters.addFilterSet( (FilterSet)filterEnum.nextElement() ); } fileUtils.copyFile( fromFile, toFile, executionFilters, - forceOverwrite, preserveLastModified ); + forceOverwrite, preserveLastModified ); } catch( IOException ioe ) { String msg = "Failed to copy " + fromFile + " to " + toFile - + " due to " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + + " due to " + ioe.getMessage(); + throw new BuildException( msg, ioe ); } } } @@ -392,7 +380,7 @@ public class Copy extends Task int count = 0; while( e.hasMoreElements() ) { - File d = new File( ( String )e.nextElement() ); + File d = new File( (String)e.nextElement() ); if( !d.exists() ) { if( !d.mkdirs() ) @@ -409,9 +397,9 @@ public class Copy extends Task if( count > 0 ) { log( "Copied " + count + - " empty director" + - ( count == 1 ? "y" : "ies" ) + - " to " + destDir.getAbsolutePath() ); + " empty director" + + ( count == 1 ? "y" : "ies" ) + + " to " + destDir.getAbsolutePath() ); } } } @@ -449,9 +437,9 @@ public class Copy extends Task } } -//************************************************************************ -// protected and private methods -//************************************************************************ + //************************************************************************ + // protected and private methods + //************************************************************************ /** * Ensure we have a consistent and legal set of attributes, and set any @@ -460,38 +448,38 @@ public class Copy extends Task * @exception BuildException Description of Exception */ protected void validateAttributes() - throws BuildException + throws TaskException { if( file == null && filesets.size() == 0 ) { - throw new BuildException( "Specify at least one source - a file or a fileset." ); + throw new TaskException( "Specify at least one source - a file or a fileset." ); } if( destFile != null && destDir != null ) { - throw new BuildException( "Only one of tofile and todir may be set." ); + throw new TaskException( "Only one of tofile and todir may be set." ); } if( destFile == null && destDir == null ) { - throw new BuildException( "One of tofile or todir must be set." ); + throw new TaskException( "One of tofile or todir must be set." ); } if( file != null && file.exists() && file.isDirectory() ) { - throw new BuildException( "Use a fileset to copy directories." ); + throw new TaskException( "Use a fileset to copy directories." ); } if( destFile != null && filesets.size() > 0 ) { if( filesets.size() > 1 ) { - throw new BuildException( + throw new TaskException( "Cannot concatenate multiple files into a single file." ); } else { - FileSet fs = ( FileSet )filesets.elementAt( 0 ); + FileSet fs = (FileSet)filesets.elementAt( 0 ); DirectoryScanner ds = fs.getDirectoryScanner( project ); String[] srcFiles = ds.getIncludedFiles(); @@ -499,18 +487,18 @@ public class Copy extends Task { if( file == null ) { - file = new File( srcFiles[0] ); + file = new File( srcFiles[ 0 ] ); filesets.removeElementAt( 0 ); } else { - throw new BuildException( + throw new TaskException( "Cannot concatenate multiple files into a single file." ); } } else { - throw new BuildException( + throw new TaskException( "Cannot perform operation from directory to file." ); } } @@ -520,7 +508,5 @@ public class Copy extends Task { destDir = new File( destFile.getParent() );// be 1.1 friendly } - } - } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Cvs.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Cvs.java index 63bda456c..371f6ca9d 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Cvs.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Cvs.java @@ -6,12 +6,14 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; @@ -120,7 +122,6 @@ public class Cvs extends Task this.cvsRsh = rsh; } - public void setDate( String p ) { if( p != null && p.trim().length() > 0 ) @@ -185,9 +186,8 @@ public class Cvs extends Task } } - public void execute() - throws BuildException + throws TaskException { // XXX: we should use JCVS (www.ice.com/JCVS) instead of command line @@ -252,7 +252,7 @@ public class Cvs extends Task if( error == null && output == null ) { streamhandler = new LogStreamHandler( this, Project.MSG_INFO, - Project.MSG_WARN ); + Project.MSG_WARN ); } else { @@ -264,7 +264,7 @@ public class Cvs extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new TaskException( e.toString(), e ); } } else @@ -279,7 +279,7 @@ public class Cvs extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new TaskException( e.toString(), e ); } } else @@ -290,7 +290,7 @@ public class Cvs extends Task } Execute exe = new Execute( streamhandler, - null ); + null ); exe.setAntRun( project ); if( dest == null ) @@ -306,11 +306,11 @@ public class Cvs extends Task * Throw an exception if cvs exited with error. (Iulian) */ if( failOnError && retCode != 0 ) - throw new BuildException( "cvs exited with error code " + retCode ); + throw new TaskException( "cvs exited with error code " + retCode ); } catch( IOException e ) { - throw new BuildException( e ); + throw new TaskException( e.toString(), e ); } finally { @@ -321,7 +321,8 @@ public class Cvs extends Task outputstream.close(); } catch( IOException e ) - {} + { + } } if( error != null ) { @@ -330,7 +331,8 @@ public class Cvs extends Task errorstream.close(); } catch( IOException e ) - {} + { + } } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Definer.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Definer.java index 0186ee465..6bb9cacae 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Definer.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Definer.java @@ -72,12 +72,6 @@ public abstract class Definer extends Task this.resource = res; } - public void setReverseLoader( boolean reverseLoader ) - { - this.reverseLoader = reverseLoader; - log( "The reverseloader attribute is DEPRECATED. It will be removed", Project.MSG_WARN ); - } - public String getClassname() { return value; @@ -120,13 +114,13 @@ public abstract class Definer extends Task { String msg = "You must not specify name or value " + "together with file or resource."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( file != null && resource != null ) { String msg = "You must not specify both, file and resource."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } Properties props = new Properties(); @@ -169,7 +163,7 @@ public abstract class Definer extends Task } catch( IOException ex ) { - throw new BuildException( ex); + throw new BuildException( "Error", ex); } } } @@ -189,13 +183,13 @@ public abstract class Definer extends Task { String msg = getTaskName() + " class " + value + " cannot be found"; - throw new BuildException( msg, cnfe, location ); + throw new BuildException( msg, cnfe ); } catch( NoClassDefFoundError ncdfe ) { String msg = getTaskName() + " class " + value + " cannot be found"; - throw new BuildException( msg, ncdfe, location ); + throw new BuildException( msg, ncdfe ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Delete.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Delete.java index e7df0b543..f96f39b7d 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Delete.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Delete.java @@ -242,8 +242,7 @@ public class Delete extends MatchingTask if( quiet && failonerror ) { - throw new BuildException( "quiet and failonerror cannot both be set to true", - location ); + throw new BuildException( "quiet and failonerror cannot both be set to true" ); } // delete the single file diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ear.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ear.java index 955cbb6ca..3456e63e8 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ear.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Ear.java @@ -47,13 +47,6 @@ public class Ear extends Jar super.addFileset( fs ); } - public void setEarfile( File earFile ) - { - log( "DEPRECATED - The earfile attribute is deprecated. Use file attribute instead." ); - setFile( earFile ); - } - - public void addArchives( ZipFileSet fs ) { // We just set the prefix for this fileset, and pass it up. @@ -80,7 +73,7 @@ public class Ear extends Jar // If no webxml file is specified, it's an error. if( deploymentDescriptor == null && !isInUpdateMode() ) { - throw new BuildException( "appxml attribute is required", location ); + throw new BuildException( "appxml attribute is required" ); } super.initZipOutputStream( zOut ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Echo.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Echo.java index 1e57b259a..1dbd30558 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Echo.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Echo.java @@ -132,7 +132,7 @@ public class Echo extends Task } catch( IOException ioe ) { - throw new BuildException( ioe); + throw new BuildException( "Error", ioe); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecTask.java index f236d8eae..d81f23827 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecTask.java @@ -52,19 +52,6 @@ public class ExecTask extends Task private String outputprop; private String resultProperty; - /** - * The full commandline to execute, executable + arguments. - * - * @param cmdl The new Command value - */ - public void setCommand( Commandline cmdl ) - { - log( "The command attribute is deprecated. " + - "Please use the executable attribute and nested arg elements.", - Project.MSG_WARN ); - this.cmdl = cmdl; - } - /** * The working directory of the process * @@ -256,7 +243,7 @@ public class ExecTask extends Task { if( failOnError ) { - throw new BuildException( taskType + " returned: " + err, location ); + throw new BuildException( taskType + " returned: " + err ); } else { @@ -291,7 +278,7 @@ public class ExecTask extends Task { if( cmdl.getExecutable() == null ) { - throw new BuildException( "no executable specified", location ); + throw new BuildException( "no executable specified" ); } if( dir != null && !dir.exists() ) { @@ -322,11 +309,11 @@ public class ExecTask extends Task } catch( FileNotFoundException fne ) { - throw new BuildException( "Cannot write to " + out, fne, location ); + throw new BuildException( "Cannot write to " + out, fne ); } catch( IOException ioe ) { - throw new BuildException( "Cannot write to " + out, ioe, location ); + throw new BuildException( "Cannot write to " + out, ioe ); } } else if( outputprop != null ) @@ -439,7 +426,7 @@ public class ExecTask extends Task { if( failIfExecFails ) { - throw new BuildException( "Execute failed: " + e.toString(), e, location ); + throw new BuildException( "Execute failed: " + e.toString(), e ); } else { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Execute.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Execute.java index c1fdd0c72..42626602c 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Execute.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Execute.java @@ -259,12 +259,12 @@ public class Execute int retval = exe.execute(); if( retval != 0 ) { - throw new BuildException( cmdline[ 0 ] + " failed with return code " + retval, task.getLocation() ); + throw new BuildException( cmdline[ 0 ] + " failed with return code " + retval ); } } catch( java.io.IOException exc ) { - throw new BuildException( "Could not launch " + cmdline[ 0 ] + ": " + exc, task.getLocation() ); + throw new BuildException( "Could not launch " + cmdline[ 0 ] + ": " + exc ); } } @@ -806,7 +806,7 @@ public class Execute { throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); } - String antRun = project.resolveFile( antHome + File.separator + _script ).toString(); + String antRun = resolveFile( antHome + File.separator + _script ).toString(); // Build the command File commandDir = workingDir; @@ -871,7 +871,7 @@ public class Execute { throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); } - String antRun = project.resolveFile( antHome + File.separator + _script ).toString(); + String antRun = resolveFile( antHome + File.separator + _script ).toString(); // Build the command File commandDir = workingDir; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java index 6fc077991..1c20e5ffd 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java @@ -37,15 +37,6 @@ public class ExecuteJava this.javaCommand = javaCommand; } - /** - * All output (System.out as well as System.err) will be written to this - * Stream. - * - * @param out The new Output value - * @deprecated manage output at the task level - */ - public void setOutput( PrintStream out ) { } - public void setSystemProperties( CommandlineJava.SysProperties s ) { sysProperties = s; @@ -95,7 +86,7 @@ public class ExecuteJava Throwable t = e.getTargetException(); if( !( t instanceof SecurityException ) ) { - throw new BuildException( t ); + throw new BuildException( "Error", t ); } else { @@ -104,7 +95,7 @@ public class ExecuteJava } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java index 0a8bd9d53..02598c18d 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java @@ -117,8 +117,7 @@ public class ExecuteOn extends ExecTask { if( mapperElement != null ) { - throw new BuildException( "Cannot define more than one mapper", - location ); + throw new BuildException( "Cannot define more than one mapper" ); } mapperElement = new Mapper( project ); return mapperElement; @@ -134,8 +133,7 @@ public class ExecuteOn extends ExecTask { if( srcFilePos != null ) { - throw new BuildException( taskType + " doesn\'t support multiple srcfile elements.", - location ); + throw new BuildException( taskType + " doesn\'t support multiple srcfile elements." ); } srcFilePos = cmdl.createMarker(); return srcFilePos; @@ -151,8 +149,7 @@ public class ExecuteOn extends ExecTask { if( targetFilePos != null ) { - throw new BuildException( taskType + " doesn\'t support multiple targetfile elements.", - location ); + throw new BuildException( taskType + " doesn\'t support multiple targetfile elements." ); } targetFilePos = cmdl.createMarker(); srcIsFirst = ( srcFilePos != null ); @@ -345,15 +342,10 @@ public class ExecuteOn extends ExecTask protected void checkConfiguration() { - if( "execon".equals( taskName ) ) - { - log( "!! execon is deprecated. Use apply instead. !!" ); - } - super.checkConfiguration(); if( filesets.size() == 0 ) { - throw new BuildException( "no filesets specified", location ); + throw new BuildException( "no filesets specified" ); } if( targetFilePos != null || mapperElement != null @@ -362,12 +354,11 @@ public class ExecuteOn extends ExecTask if( mapperElement == null ) { - throw new BuildException( "no mapper specified", location ); + throw new BuildException( "no mapper specified" ); } if( mapperElement == null ) { - throw new BuildException( "no dest attribute specified", - location ); + throw new BuildException( "no dest attribute specified" ); } mapper = mapperElement.getImplementation(); } @@ -448,7 +439,7 @@ public class ExecuteOn extends ExecTask } catch( IOException e ) { - throw new BuildException( "Execute failed: " + e, e, location ); + throw new BuildException( "Execute failed: " + e, e ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java index 38ebc9404..88e1bd21d 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Expand.java @@ -98,11 +98,6 @@ public class Expand extends MatchingTask public void execute() throws BuildException { - if( "expand".equals( taskType ) ) - { - log( "!! expand is deprecated. Use unzip instead. !!" ); - } - if( source == null && filesets.size() == 0 ) { throw new BuildException( "src attribute and/or filesets must be specified" ); @@ -116,7 +111,7 @@ public class Expand extends MatchingTask if( dest.exists() && !dest.isDirectory() ) { - throw new BuildException( "Dest must be a directory.", location ); + throw new BuildException( "Dest must be a directory." ); } FileUtils fileUtils = FileUtils.newFileUtils(); @@ -126,7 +121,7 @@ public class Expand extends MatchingTask if( source.isDirectory() ) { throw new BuildException( "Src must not be a directory." + - " Use nested filesets instead.", location ); + " Use nested filesets instead." ); } else { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Filter.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Filter.java index 6970d0ab4..b51e712f6 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Filter.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Filter.java @@ -51,7 +51,7 @@ public class Filter extends Task if( !isFiltersFromFile && !isSingleFilter ) { - throw new BuildException( "both token and value parameters, or only a filtersFile parameter is required", location ); + throw new BuildException( "both token and value parameters, or only a filtersFile parameter is required" ); } if( isSingleFilter ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java index 2cd21df0a..18c757c2d 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java @@ -147,35 +147,6 @@ public class FixCRLF extends MatchingTask } } - /** - * Specify how carriage return (CR) characters are to be handled - * - * @param attr The new Cr value - * @deprecated use {@link #setEol setEol} instead. - */ - public void setCr( AddAsisRemove attr ) - { - log( "DEPRECATED: The cr attribute has been deprecated,", - Project.MSG_WARN ); - log( "Please us the eol attribute instead", Project.MSG_WARN ); - String option = attr.getValue(); - CrLf c = new CrLf(); - if( option.equals( "remove" ) ) - { - c.setValue( "lf" ); - } - else if( option.equals( "asis" ) ) - { - c.setValue( "asis" ); - } - else - { - // must be "add" - c.setValue( "crlf" ); - } - setEol( c ); - } - /** * Set the destination where the fixed files should be placed. Default is to * replace the original file. @@ -306,8 +277,7 @@ public class FixCRLF extends MatchingTask { if( tlength < 2 || tlength > 80 ) { - throw new BuildException( "tablength must be between 2 and 80", - location ); + throw new BuildException( "tablength must be between 2 and 80" ); } tablength = tlength; StringBuffer sp = new StringBuffer(); @@ -522,7 +492,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); }// end of try-catch } else @@ -581,7 +551,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); }// end of try-catch }// end of else tabs == ADD @@ -617,7 +587,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } while( lines.hasMoreElements() ) @@ -631,7 +601,7 @@ public class FixCRLF extends MatchingTask } catch( NoSuchElementException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } String lineString = line.getLineString(); @@ -649,7 +619,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); }// end of try-catch } @@ -721,7 +691,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } lines.setState( LOOKING ); @@ -744,7 +714,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); }// end of try-catch }// end of while (lines.hasNext()) @@ -763,7 +733,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { @@ -773,7 +743,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } @@ -841,7 +811,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { @@ -914,7 +884,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } @@ -1043,7 +1013,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GUnzip.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GUnzip.java index a4001fba5..50088af38 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GUnzip.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GUnzip.java @@ -56,7 +56,7 @@ public class GUnzip extends Unpack catch( IOException ioe ) { String msg = "Problem expanding gzip " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GZip.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GZip.java index df35b0daf..1469cccee 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GZip.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/GZip.java @@ -34,7 +34,7 @@ public class GZip extends Pack catch( IOException ioe ) { String msg = "Problem creating gzip " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Get.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Get.java index 6c1eb4451..d05868236 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Get.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Get.java @@ -132,29 +132,26 @@ public class Get extends Task { if( source == null ) { - throw new BuildException( "src attribute is required", location ); + throw new BuildException( "src attribute is required" ); } if( dest == null ) { - throw new BuildException( "dest attribute is required", location ); + throw new BuildException( "dest attribute is required" ); } if( dest.exists() && dest.isDirectory() ) { - throw new BuildException( "The specified destination is a directory", - location ); + throw new BuildException( "The specified destination is a directory" ); } if( dest.exists() && !dest.canWrite() ) { - throw new BuildException( "Can't write to " + dest.getAbsolutePath(), - location ); + throw new BuildException( "Can't write to " + dest.getAbsolutePath() ); } try { - log( "Getting: " + source ); //set the timestamp to the file date. @@ -249,8 +246,7 @@ public class Get extends Task log( "Can't get " + source + " to " + dest ); if( ignoreErrors ) return; - throw new BuildException( "Can't get " + source + " to " + dest, - location ); + throw new BuildException( "Can't get " + source + " to " + dest ); } byte[] buffer = new byte[100 * 1024]; @@ -287,7 +283,7 @@ public class Get extends Task log( "Error getting " + source + " to " + dest ); if( ignoreErrors ) return; - throw new BuildException( ioe); + throw new BuildException( "Error", ioe); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Jar.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Jar.java index 1b2d8a976..8d5aec951 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Jar.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Jar.java @@ -63,22 +63,11 @@ public class Jar extends Zip index = flag; } - /** - * @param jarFile The new Jarfile value - * @deprecated use setFile(File) instead. - */ - public void setJarfile( File jarFile ) - { - log( "DEPRECATED - The jarfile attribute is deprecated. Use file attribute instead." ); - setFile( jarFile ); - } - public void setManifest( File manifestFile ) { if( !manifestFile.exists() ) { - throw new BuildException( "Manifest file: " + manifestFile + " does not exist.", - getLocation() ); + throw new BuildException( "Manifest file: " + manifestFile + " does not exist." ); } this.manifestFile = manifestFile; @@ -97,7 +86,7 @@ public class Jar extends Zip catch( ManifestException e ) { log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); - throw new BuildException( "Invalid Manifest: " + manifestFile, e, getLocation() ); + throw new BuildException( "Invalid Manifest: " + manifestFile, e ); } catch( IOException e ) { @@ -262,7 +251,7 @@ public class Jar extends Zip catch( ManifestException e ) { log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); - throw new BuildException( "Invalid Manifest", e, getLocation() ); + throw new BuildException( "Invalid Manifest", e ); } } @@ -391,7 +380,7 @@ public class Jar extends Zip catch( ManifestException e ) { log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); - throw new BuildException( "Invalid Manifest", e, getLocation() ); + throw new BuildException( "Invalid Manifest", e ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java index 060a331c6..2671c6e0f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Java.java @@ -6,13 +6,13 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Vector; import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.ExitException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Commandline; @@ -39,19 +39,6 @@ public class Java extends Task private boolean failOnError = false; private File out; - /** - * Set the command line arguments for the class. - * - * @param s The new Args value - */ - public void setArgs( String s ) - { - log( "The args attribute is deprecated. " + - "Please use nested arg elements.", - Project.MSG_WARN ); - cmdl.createArgument().setLine( s ); - } - /** * Set the class name. * @@ -149,19 +136,6 @@ public class Java extends Task cmdl.setVm( s ); } - /** - * Set the command line arguments for the JVM. - * - * @param s The new Jvmargs value - */ - public void setJvmargs( String s ) - { - log( "The jvmargs attribute is deprecated. " + - "Please use nested jvmarg elements.", - Project.MSG_WARN ); - cmdl.createVmArgument().setLine( s ); - } - /** * -mx or -Xmx depending on VM version * @@ -243,7 +217,7 @@ public class Java extends Task { if( failOnError ) { - throw new BuildException( "Java returned: " + err, location ); + throw new BuildException( "Java returned: " + err ); } else { @@ -290,16 +264,9 @@ public class Java extends Task } log( "Running in same VM " + cmdl.getJavaCommand().toString(), - Project.MSG_VERBOSE ); - try - { - run( cmdl ); - return 0; - } - catch( ExitException ex ) - { - return ex.getStatus(); - } + Project.MSG_VERBOSE ); + run( cmdl ); + return 0; } } @@ -342,7 +309,7 @@ public class Java extends Task cmdj.setClassname( classname ); for( int i = 0; i < args.size(); i++ ) { - cmdj.createArgument().setValue( ( String )args.elementAt( i ) ); + cmdj.createArgument().setValue( (String)args.elementAt( i ) ); } run( cmdj ); } @@ -370,7 +337,7 @@ public class Java extends Task } catch( IOException io ) { - throw new BuildException( io ); + throw new BuildException( "Error", io ); } finally { @@ -403,8 +370,8 @@ public class Java extends Task if( out == null ) { exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO, - Project.MSG_WARN ), - null ); + Project.MSG_WARN ), + null ); } else { @@ -420,8 +387,7 @@ public class Java extends Task } else if( !dir.exists() || !dir.isDirectory() ) { - throw new BuildException( dir.getAbsolutePath() + " is not a valid directory", - location ); + throw new BuildException( dir.getAbsolutePath() + " is not a valid directory"); } exe.setWorkingDirectory( dir ); @@ -433,12 +399,12 @@ public class Java extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } catch( IOException io ) { - throw new BuildException( io ); + throw new BuildException( "Error", io ); } finally { @@ -449,7 +415,8 @@ public class Java extends Task fos.close(); } catch( IOException io ) - {} + { + } } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java index 7793bc4f2..9ff441be4 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -6,15 +6,16 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.File; import java.util.Enumeration; import java.util.Vector; +import org.apache.myrmidon.framework.Os; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter; import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory; -import org.apache.myrmidon.framework.Os; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; @@ -57,9 +58,8 @@ import org.apache.tools.ant.util.SourceFileScanner; public class Javac extends MatchingTask { - private final static String FAIL_MSG - = "Compile failed, messages should have been provided."; + = "Compile failed, messages should have been provided."; private boolean debug = false; private boolean optimize = false; private boolean deprecation = false; @@ -73,7 +73,7 @@ public class Javac extends MatchingTask private Vector implementationSpecificArgs = new Vector(); protected boolean failOnError = true; - protected File[] compileList = new File[0]; + protected File[] compileList = new File[ 0 ]; private Path bootclasspath; private Path compileClasspath; private String debugLevel; @@ -238,15 +238,15 @@ public class Javac extends MatchingTask public void setFork( String f ) { if( f.equalsIgnoreCase( "on" ) - || f.equalsIgnoreCase( "true" ) - || f.equalsIgnoreCase( "yes" ) ) + || f.equalsIgnoreCase( "true" ) + || f.equalsIgnoreCase( "yes" ) ) { fork = "true"; forkedExecutable = getSystemJavac(); } else if( f.equalsIgnoreCase( "off" ) - || f.equalsIgnoreCase( "false" ) - || f.equalsIgnoreCase( "no" ) ) + || f.equalsIgnoreCase( "false" ) + || f.equalsIgnoreCase( "no" ) ) { fork = "false"; forkedExecutable = null; @@ -406,17 +406,17 @@ public class Javac extends MatchingTask { Vector args = new Vector(); for( Enumeration enum = implementationSpecificArgs.elements(); - enum.hasMoreElements(); - ) + enum.hasMoreElements(); + ) { String[] curr = - ( ( ImplementationSpecificArgument )enum.nextElement() ).getParts(); + ( (ImplementationSpecificArgument)enum.nextElement() ).getParts(); for( int i = 0; i < curr.length; i++ ) { - args.addElement( curr[i] ); + args.addElement( curr[ i ] ); } } - String[] res = new String[args.size()]; + String[] res = new String[ args.size() ]; args.copyInto( res ); return res; } @@ -724,17 +724,17 @@ public class Javac extends MatchingTask if( src == null ) { - throw new BuildException( "srcdir attribute must be set!", location ); + throw new BuildException( "srcdir attribute must be set!" ); } String[] list = src.list(); if( list.length == 0 ) { - throw new BuildException( "srcdir attribute must be set!", location ); + throw new BuildException( "srcdir attribute must be set!" ); } if( destDir != null && !destDir.isDirectory() ) { - throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory", location ); + throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory" ); } // scan source directories and dest directory to build up @@ -742,10 +742,10 @@ public class Javac extends MatchingTask resetFileLists(); for( int i = 0; i < list.length; i++ ) { - File srcDir = ( File )project.resolveFile( list[i] ); + File srcDir = (File)resolveFile( list[ i ] ); if( !srcDir.exists() ) { - throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!", location ); + throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!" ); } DirectoryScanner ds = this.getDirectoryScanner( srcDir ); @@ -765,7 +765,7 @@ public class Javac extends MatchingTask CompilerAdapter adapter = CompilerAdapterFactory.getCompiler( compiler, this ); log( "Compiling " + compileList.length + - " source file" + " source file" + ( compileList.length == 1 ? "" : "s" ) + ( destDir != null ? " to " + destDir : "" ) ); @@ -777,7 +777,7 @@ public class Javac extends MatchingTask { if( failOnError ) { - throw new BuildException( FAIL_MSG, location ); + throw new BuildException( FAIL_MSG ); } else { @@ -799,7 +799,7 @@ public class Javac extends MatchingTask // PATH. java.io.File jExecutable = new java.io.File( System.getProperty( "java.home" ) + - "/../bin/javac" + extension ); + "/../bin/javac" + extension ); if( jExecutable.exists() && !Os.isFamily( "netware" ) ) { @@ -837,7 +837,7 @@ public class Javac extends MatchingTask */ protected void resetFileLists() { - compileList = new File[0]; + compileList = new File[ 0 ]; } /** @@ -858,12 +858,12 @@ public class Javac extends MatchingTask if( newFiles.length > 0 ) { - File[] newCompileList = new File[compileList.length + - newFiles.length]; + File[] newCompileList = new File[ compileList.length + + newFiles.length ]; System.arraycopy( compileList, 0, newCompileList, 0, - compileList.length ); + compileList.length ); System.arraycopy( newFiles, 0, newCompileList, - compileList.length, newFiles.length ); + compileList.length, newFiles.length ); compileList = newCompileList; } } @@ -879,7 +879,7 @@ public class Javac extends MatchingTask if( isJdkCompiler( compiler ) ) { log( "Since fork is true, ignoring build.compiler setting.", - Project.MSG_WARN ); + Project.MSG_WARN ); compiler = "extJavac"; } else @@ -915,7 +915,7 @@ public class Javac extends MatchingTask * @author RT */ public class ImplementationSpecificArgument - extends Commandline.Argument + extends Commandline.Argument { private String impl; @@ -933,7 +933,7 @@ public class Javac extends MatchingTask } else { - return new String[0]; + return new String[ 0 ]; } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index e95245de7..98adc71a3 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -318,7 +318,7 @@ public class Javadoc extends Task { throw new BuildException( linkOfflineError ); } - le.setPackagelistLoc( project.resolveFile( tok.nextToken() ) ); + le.setPackagelistLoc( resolveFile( tok.nextToken() ) ); } } @@ -436,7 +436,7 @@ public class Javadoc extends Task { String f = tok.nextToken(); SourceFile sf = new SourceFile(); - sf.setFile( project.resolveFile( f ) ); + sf.setFile( resolveFile( f ) ); addSource( sf ); } } @@ -608,11 +608,6 @@ public class Javadoc extends Task public void execute() throws BuildException { - if( "javadoc2".equals( taskType ) ) - { - log( "!! javadoc2 is deprecated. Use javadoc instead. !!" ); - } - if( sourcePath == null ) { String msg = "sourcePath attribute must be set!"; @@ -689,7 +684,7 @@ public class Javadoc extends Task { if( doclet.getName() == null ) { - throw new BuildException( "The doclet name must be specified.", location ); + throw new BuildException( "The doclet name must be specified." ); } else { @@ -885,8 +880,7 @@ public class Javadoc extends Task } catch( IOException e ) { - throw new BuildException( "Error creating temporary file", - e, location ); + throw new BuildException( "Error creating temporary file", e ); } finally { @@ -923,12 +917,12 @@ public class Javadoc extends Task int ret = exe.execute(); if( ret != 0 && failOnError ) { - throw new BuildException( "Javadoc returned " + ret, location ); + throw new BuildException( "Javadoc returned " + ret ); } } catch( IOException e ) { - throw new BuildException( "Javadoc failed: " + e, e, location ); + throw new BuildException( "Javadoc failed: " + e, e ); } finally { @@ -1117,7 +1111,7 @@ public class Javadoc extends Task for( int j = 0; j < list.length; j++ ) { - File source = project.resolveFile( list[j] ); + File source = resolveFile( list[j] ); fs.setDir( source ); DirectoryScanner ds = fs.getDirectoryScanner( project ); @@ -1160,8 +1154,7 @@ public class Javadoc extends Task } catch( IOException ioex ) { - throw new BuildException( "Error creating temporary file", - ioex, location ); + throw new BuildException( "Error creating temporary file", ioex ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java index b7e6c849b..abb58ef52 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java @@ -42,7 +42,7 @@ public class LogStreamHandler extends PumpStreamHandler catch( IOException e ) { // plain impossible - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Manifest.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Manifest.java index 242b0fa5e..fa0e3f61c 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Manifest.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Manifest.java @@ -320,12 +320,12 @@ public class Manifest extends Task catch( ManifestException m ) { throw new BuildException( "Existing manifest " + manifestFile - + " is invalid", m, location ); + + " is invalid", m ); } catch( IOException e ) { - throw new BuildException( "Failed to read " + manifestFile, - e, location ); + throw new + BuildException( "Failed to read " + manifestFile, e ); } finally { @@ -347,7 +347,7 @@ public class Manifest extends Task } catch( ManifestException m ) { - throw new BuildException( "Manifest is invalid", m, location ); + throw new BuildException( "Manifest is invalid", m ); } PrintWriter w = null; @@ -358,8 +358,7 @@ public class Manifest extends Task } catch( IOException e ) { - throw new BuildException( "Failed to write " + manifestFile, - e, location ); + throw new BuildException( "Failed to write " + manifestFile e ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java index a03cb9be7..375d11526 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java @@ -88,59 +88,6 @@ public abstract class MatchingTask extends Task fileset.setIncludesfile( includesfile ); } - /** - * List of filenames and directory names to not include. They should be - * either , or " " (space) separated. The ignored files will be logged. - * - * @param ignoreString the string containing the files to ignore. - */ - public void XsetIgnore( String ignoreString ) - { - log( "The ignore attribute is deprecated." + - "Please use the excludes attribute.", - Project.MSG_WARN ); - if( ignoreString != null && ignoreString.length() > 0 ) - { - Vector tmpExcludes = new Vector(); - StringTokenizer tok = new StringTokenizer( ignoreString, ", ", false ); - while( tok.hasMoreTokens() ) - { - createExclude().setName( "**/" + tok.nextToken().trim() + "/**" ); - } - } - } - - /** - * Set this to be the items in the base directory that you want to be - * included. You can also specify "*" for the items (ie: items="*") and it - * will include all the items in the base directory. - * - * @param itemString the string containing the files to include. - */ - public void XsetItems( String itemString ) - { - log( "The items attribute is deprecated. " + - "Please use the includes attribute.", - Project.MSG_WARN ); - if( itemString == null || itemString.equals( "*" ) - || itemString.equals( "." ) ) - { - createInclude().setName( "**" ); - } - else - { - StringTokenizer tok = new StringTokenizer( itemString, ", " ); - while( tok.hasMoreTokens() ) - { - String pattern = tok.nextToken().trim(); - if( pattern.length() > 0 ) - { - createInclude().setName( pattern + "/**" ); - } - } - } - } - /** * add a name entry on the exclude list * diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Mkdir.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Mkdir.java index c323430a4..f186760f1 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Mkdir.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Mkdir.java @@ -32,7 +32,7 @@ public class Mkdir extends Task { if( dir == null ) { - throw new BuildException( "dir attribute is required", location ); + throw new BuildException( "dir attribute is required" ); } if( dir.isFile() ) @@ -47,7 +47,7 @@ public class Mkdir extends Task { String msg = "Directory " + dir.getAbsolutePath() + " creation was not " + "successful for an unknown reason"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } log( "Created dir: " + dir.getAbsolutePath() ); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Move.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Move.java index 75811008d..4d021bdf5 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Move.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Move.java @@ -96,7 +96,7 @@ public class Move extends Copy String msg = "Failed to rename dir " + fromDir + " to " + toDir + " due to " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } } } @@ -135,7 +135,7 @@ public class Move extends Copy String msg = "Failed to rename " + fromFile + " to " + toFile + " due to " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } if( !moved ) @@ -168,7 +168,7 @@ public class Move extends Copy String msg = "Failed to copy " + fromFile + " to " + toFile + " due to " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Pack.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Pack.java index 3a9d0701d..2bd1d6ee2 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Pack.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Pack.java @@ -64,18 +64,18 @@ public abstract class Pack extends Task { if( zipFile == null ) { - throw new BuildException( "zipfile attribute is required", location ); + throw new BuildException( "zipfile attribute is required" ); } if( source == null ) { - throw new BuildException( "src attribute is required", location ); + throw new BuildException( "src attribute is required" ); } if( source.isDirectory() ) { throw new BuildException( "Src attribute must not " + - "represent a directory!", location ); + "represent a directory!" ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Parallel.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Parallel.java index 1203369ac..942d7f1cd 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Parallel.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Parallel.java @@ -117,12 +117,12 @@ public class Parallel extends Task } else { - throw new BuildException( firstException ); + throw new BuildException( "Error", firstException ); } } else if( numExceptions > 1 ) { - throw new BuildException( exceptionMessage.toString(), firstLocation ); + throw new BuildException( exceptionMessage.toString() ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Patch.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Patch.java index 8c7657b12..f1edcac78 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Patch.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Patch.java @@ -70,8 +70,7 @@ public class Patch extends Task { if( !file.exists() ) { - throw new BuildException( "patchfile " + file + " doesn\'t exist", - location ); + throw new BuildException( "patchfile " + file + " doesn\'t exist" ); } cmd.createArgument().setValue( "-i" ); cmd.createArgument().setFile( file ); @@ -118,7 +117,7 @@ public class Patch extends Task { if( num < 0 ) { - throw new BuildException( "strip has to be >= 0", location ); + throw new BuildException( "strip has to be >= 0" ); } cmd.createArgument().setValue( "-p" + num ); } @@ -128,8 +127,7 @@ public class Patch extends Task { if( !havePatchfile ) { - throw new BuildException( "patchfile argument is required", - location ); + throw new BuildException( "patchfile argument is required" ); } Commandline toExecute = ( Commandline )cmd.clone(); @@ -150,7 +148,7 @@ public class Patch extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java index 15b182ecf..0c506bce8 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java @@ -99,17 +99,6 @@ public class Property extends Task this.resource = resource; } - /** - * @param userProperty The new UserProperty value - * @deprecated This was never a supported feature and has been deprecated - * without replacement - */ - public void setUserProperty( boolean userProperty ) - { - log( "DEPRECATED: Ignoring request to set user property in Property task.", - Project.MSG_WARN ); - } - public void setValue( String value ) { this.value = value; @@ -161,16 +150,14 @@ public class Property extends Task { if( value == null && ref == null ) { - throw new BuildException( "You must specify value, location or refid with the name attribute", - location ); + throw new BuildException( "You must specify value, location or refid with the name attribute" ); } } else { if( file == null && resource == null && env == null ) { - throw new BuildException( "You must specify file, resource or environment when not using the name attribute", - location ); + throw new BuildException( "You must specify file, resource or environment when not using the name attribute" ); } } @@ -291,7 +278,7 @@ public class Property extends Task } catch( IOException ex ) { - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } @@ -334,7 +321,7 @@ public class Property extends Task } catch( IOException ex ) { - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Replace.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Replace.java index 626ac8216..381d8ef91 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Replace.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Replace.java @@ -245,23 +245,23 @@ public class Replace extends MatchingTask if( src == null && dir == null ) { String message = "Either the file or the dir attribute " + "must be specified"; - throw new BuildException( message, location ); + throw new BuildException( message ); } if( propertyFile != null && !propertyFile.exists() ) { String message = "Property file " + propertyFile.getPath() + " does not exist."; - throw new BuildException( message, location ); + throw new BuildException( message ); } if( token == null && replacefilters.size() == 0 ) { String message = "Either token or a nested replacefilter " + "must be specified"; - throw new BuildException( message, location ); + throw new BuildException( message); } if( token != null && "".equals( token.getText() ) ) { String message = "The token attribute must not be an empty string."; - throw new BuildException( message, location ); + throw new BuildException( message ); } } @@ -293,7 +293,7 @@ public class Replace extends MatchingTask { if( !src.exists() ) { - throw new BuildException( "Replace: source file " + src.getPath() + " doesn't exist", location ); + throw new BuildException( "Replace: source file " + src.getPath() + " doesn't exist" ); } File temp = fileUtils.createTempFile( "rep", ".tmp", @@ -382,7 +382,7 @@ public class Replace extends MatchingTask catch( IOException ioe ) { throw new BuildException( "IOException in " + src + " - " + - ioe.getClass().getName() + ":" + ioe.getMessage(), ioe, location ); + ioe.getClass().getName() + ":" + ioe.getMessage(), ioe ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java index e37fac08e..8ce94edeb 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java @@ -20,6 +20,7 @@ import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.SourceFileScanner; +import org.apache.tools.ant.util.FileUtils; /** * Task to compile RMI stubs and skeletons. This task can take the following @@ -518,11 +519,11 @@ public class Rmic extends MatchingTask { if( baseDir == null ) { - throw new BuildException( "base attribute must be set!", location ); + throw new BuildException( "base attribute must be set!" ); } if( !baseDir.exists() ) { - throw new BuildException( "base does not exist!", location ); + throw new BuildException( "base does not exist!" ); } if( verify ) @@ -565,7 +566,7 @@ public class Rmic extends MatchingTask // finally, lets execute the compiler!! if( !adapter.execute() ) { - throw new BuildException( FAIL_MSG, location ); + throw new BuildException( FAIL_MSG ); } } @@ -672,14 +673,14 @@ public class Rmic extends MatchingTask File newFile = new File( sourceBaseFile, sourceFileName ); try { - project.copyFile( oldFile, newFile, filtering ); + FileUtils.newFileUtils().copyFile( oldFile, newFile, filtering ); oldFile.delete(); } catch( IOException ioe ) { String msg = "Failed to copy " + oldFile + " to " + newFile + " due to " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java index 27acf92a0..a242c5489 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SQLExec.java @@ -400,7 +400,7 @@ public class SQLExec extends Task { if( transactions.size() == 0 ) { - throw new BuildException( "Source file or fileset, transactions or sql statement must be set!", location ); + throw new BuildException( "Source file or fileset, transactions or sql statement must be set!" ); } } else @@ -430,23 +430,23 @@ public class SQLExec extends Task if( driver == null ) { - throw new BuildException( "Driver attribute must be set!", location ); + throw new BuildException( "Driver attribute must be set!" ); } if( userId == null ) { - throw new BuildException( "User Id attribute must be set!", location ); + throw new BuildException( "User Id attribute must be set!" ); } if( password == null ) { - throw new BuildException( "Password attribute must be set!", location ); + throw new BuildException( "Password attribute must be set!" ); } if( url == null ) { - throw new BuildException( "Url attribute must be set!", location ); + throw new BuildException( "Url attribute must be set!" ); } if( srcFile != null && !srcFile.exists() ) { - throw new BuildException( "Source file does not exist!", location ); + throw new BuildException( "Source file does not exist!" ); } Driver driverInstance = null; // Load the driver using the @@ -470,15 +470,15 @@ public class SQLExec extends Task } catch( ClassNotFoundException e ) { - throw new BuildException( "Class Not Found: JDBC driver " + driver + " could not be loaded", location ); + throw new BuildException( "Class Not Found: JDBC driver " + driver + " could not be loaded" ); } catch( IllegalAccessException e ) { - throw new BuildException( "Illegal Access: JDBC driver " + driver + " could not be loaded", location ); + throw new BuildException( "Illegal Access: JDBC driver " + driver + " could not be loaded" ); } catch( InstantiationException e ) { - throw new BuildException( "Instantiation Exception: JDBC driver " + driver + " could not be loaded", location ); + throw new BuildException( "Instantiation Exception: JDBC driver " + driver + " could not be loaded" ); } try @@ -543,7 +543,7 @@ public class SQLExec extends Task catch( SQLException ex ) {} } - throw new BuildException( e ); + throw new BuildException( "Error", e ); } catch( SQLException e ) { @@ -556,7 +556,7 @@ public class SQLExec extends Task catch( SQLException ex ) {} } - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SendEmail.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SendEmail.java index 052ed4940..d69728485 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SendEmail.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/SendEmail.java @@ -201,7 +201,7 @@ public class SendEmail extends Task while( t.hasMoreTokens() ) { - files.addElement( project.resolveFile( t.nextToken() ) ); + files.addElement( resolveFile( t.nextToken() ) ); } } @@ -394,7 +394,7 @@ public class SendEmail extends Task String err = "IO error sending mail " + ioe.toString(); if( failOnError ) { - throw new BuildException( err, ioe, location ); + throw new BuildException( err, ioe ); } else { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sleep.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sleep.java index 2c8d81c86..6c1b9b734 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sleep.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Sleep.java @@ -141,7 +141,7 @@ public class Sleep extends Task { if( failOnError ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } else { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java index 2f3fe3cdc..cbcae1f7d 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -34,33 +35,6 @@ import org.apache.tools.tar.TarOutputStream; public class Tar extends MatchingTask { - - /** - * @deprecated Tar.WARN is deprecated and is replaced with - * Tar.TarLongFileMode.WARN - */ - public final static String WARN = "warn"; - /** - * @deprecated Tar.FAIL is deprecated and is replaced with - * Tar.TarLongFileMode.FAIL - */ - public final static String FAIL = "fail"; - /** - * @deprecated Tar.TRUNCATE is deprecated and is replaced with - * Tar.TarLongFileMode.TRUNCATE - */ - public final static String TRUNCATE = "truncate"; - /** - * @deprecated Tar.GNU is deprecated and is replaced with - * Tar.TarLongFileMode.GNU - */ - public final static String GNU = "gnu"; - /** - * @deprecated Tar.OMIT is deprecated and is replaced with - * Tar.TarLongFileMode.OMIT - */ - public final static String OMIT = "omit"; - private TarLongFileMode longFileMode = new TarLongFileMode(); Vector filesets = new Vector(); @@ -84,28 +58,6 @@ public class Tar extends MatchingTask this.baseDir = baseDir; } - /** - * Set how to handle long files. Allowable values are truncate - paths are - * truncated to the maximum length fail - paths greater than the maximim - * cause a build exception warn - paths greater than the maximum cause a - * warning and GNU is used gnu - GNU extensions are used for any paths - * greater than the maximum. omit - paths greater than the maximum are - * omitted from the archive - * - * @param mode The new Longfile value - * @deprecated setLongFile(String) is deprecated and is replaced with - * setLongFile(Tar.TarLongFileMode) to make Ant's Introspection - * mechanism do the work and also to encapsulate operations on the mode - * in its own class. - */ - public void setLongfile( String mode ) - { - log( "DEPRECATED - The setLongfile(String) method has been deprecated." - + " Use setLongfile(Tar.TarLongFileMode) instead." ); - this.longFileMode = new TarLongFileMode(); - longFileMode.setValue( mode ); - } - /** * Set how to handle long files. Allowable values are truncate - paths are * truncated to the maximum length fail - paths greater than the maximim @@ -121,7 +73,6 @@ public class Tar extends MatchingTask this.longFileMode = mode; } - /** * This is the name/location of where to create the tar file. * @@ -144,27 +95,24 @@ public class Tar extends MatchingTask { if( tarFile == null ) { - throw new BuildException( "tarfile attribute must be set!", - location ); + throw new BuildException( "tarfile attribute must be set!" ); } if( tarFile.exists() && tarFile.isDirectory() ) { - throw new BuildException( "tarfile is a directory!", - location ); + throw new BuildException( "tarfile is a directory!" ); } if( tarFile.exists() && !tarFile.canWrite() ) { - throw new BuildException( "Can not write to the specified tarfile!", - location ); + throw new BuildException( "Can not write to the specified tarfile!" ); } if( baseDir != null ) { if( !baseDir.exists() ) { - throw new BuildException( "basedir does not exist!", location ); + throw new BuildException( "basedir does not exist!" ); } // add the main fileset to the list of filesets to process. @@ -175,16 +123,15 @@ public class Tar extends MatchingTask if( filesets.size() == 0 ) { - throw new BuildException( "You must supply either a basdir attribute or some nested filesets.", - location ); + throw new BuildException( "You must supply either a basdir attribute or some nested filesets." ); } // check if tr is out of date with respect to each // fileset boolean upToDate = true; - for( Enumeration e = filesets.elements(); e.hasMoreElements(); ) + for( Enumeration e = filesets.elements(); e.hasMoreElements(); ) { - TarFileSet fs = ( TarFileSet )e.nextElement(); + TarFileSet fs = (TarFileSet)e.nextElement(); String[] files = fs.getFiles( project ); if( !archiveIsUpToDate( files ) ) @@ -194,9 +141,9 @@ public class Tar extends MatchingTask for( int i = 0; i < files.length; ++i ) { - if( tarFile.equals( new File( fs.getDir( project ), files[i] ) ) ) + if( tarFile.equals( new File( fs.getDir( project ), files[ i ] ) ) ) { - throw new BuildException( "A tar file cannot include itself", location ); + throw new BuildException( "A tar file cannot include itself" ); } } } @@ -204,7 +151,7 @@ public class Tar extends MatchingTask if( upToDate ) { log( "Nothing to do: " + tarFile.getAbsolutePath() + " is up to date.", - Project.MSG_INFO ); + Project.MSG_INFO ); return; } @@ -231,14 +178,14 @@ public class Tar extends MatchingTask } longWarningGiven = false; - for( Enumeration e = filesets.elements(); e.hasMoreElements(); ) + for( Enumeration e = filesets.elements(); e.hasMoreElements(); ) { - TarFileSet fs = ( TarFileSet )e.nextElement(); + TarFileSet fs = (TarFileSet)e.nextElement(); String[] files = fs.getFiles( project ); for( int i = 0; i < files.length; i++ ) { - File f = new File( fs.getDir( project ), files[i] ); - String name = files[i].replace( File.separatorChar, '/' ); + File f = new File( fs.getDir( project ), files[ i ] ); + String name = files[ i ].replace( File.separatorChar, '/' ); tarFile( f, tOut, name, fs ); } } @@ -246,7 +193,7 @@ public class Tar extends MatchingTask catch( IOException ioe ) { String msg = "Problem creating TAR: " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { @@ -258,7 +205,8 @@ public class Tar extends MatchingTask tOut.close(); } catch( IOException e ) - {} + { + } } } } @@ -300,7 +248,7 @@ public class Tar extends MatchingTask else if( longFileMode.isWarnMode() ) { log( "Entry: " + vPath + " longer than " + - TarConstants.NAMELEN + " characters.", Project.MSG_WARN ); + TarConstants.NAMELEN + " characters.", Project.MSG_WARN ); if( !longWarningGiven ) { log( "Resulting tar file can only be processed successfully" @@ -312,7 +260,7 @@ public class Tar extends MatchingTask { throw new BuildException( "Entry: " + vPath + " longer than " + - TarConstants.NAMELEN + "characters.", location ); + TarConstants.NAMELEN + "characters." ); } } @@ -332,13 +280,13 @@ public class Tar extends MatchingTask { fIn = new FileInputStream( file ); - byte[] buffer = new byte[8 * 1024]; + byte[] buffer = new byte[ 8 * 1024 ]; int count = 0; do { tOut.write( buffer, 0, count ); count = fIn.read( buffer, 0, buffer.length ); - }while ( count != -1 ); + } while( count != -1 ); } tOut.closeEntry(); @@ -359,7 +307,6 @@ public class Tar extends MatchingTask private String userName = ""; private String groupName = ""; - public TarFileSet( FileSet fileset ) { super( fileset ); @@ -399,10 +346,10 @@ public class Tar extends MatchingTask DirectoryScanner ds = getDirectoryScanner( p ); String[] directories = ds.getIncludedDirectories(); String[] filesPerSe = ds.getIncludedFiles(); - files = new String[directories.length + filesPerSe.length]; + files = new String[ directories.length + filesPerSe.length ]; System.arraycopy( directories, 0, files, 0, directories.length ); System.arraycopy( filesPerSe, 0, files, directories.length, - filesPerSe.length ); + filesPerSe.length ); } return files; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Touch.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Touch.java index 358597118..d53db1655 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Touch.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Touch.java @@ -121,7 +121,7 @@ public class Touch extends Task } catch( ParseException pe ) { - throw new BuildException( pe.getMessage(), pe, location ); + throw new BuildException( pe.getMessage(), pe ); } } @@ -149,8 +149,7 @@ public class Touch extends Task } catch( IOException ioe ) { - throw new BuildException( "Could not create " + file, ioe, - location ); + throw new BuildException( "Could not create " + file, ioe ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tstamp.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tstamp.java index 276d964e0..5c97426a0 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tstamp.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tstamp.java @@ -79,7 +79,7 @@ public class Tstamp extends Task } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } @@ -165,7 +165,7 @@ public class Tstamp extends Task country = st.nextToken(); if( st.hasMoreElements() ) { - throw new BuildException( "bad locale format", getLocation() ); + throw new BuildException( "bad locale format" ); } } } @@ -176,7 +176,7 @@ public class Tstamp extends Task } catch( NoSuchElementException e ) { - throw new BuildException( "bad locale format", e, getLocation() ); + throw new BuildException( "bad locale format", e ); } } @@ -200,22 +200,6 @@ public class Tstamp extends Task timeZone = TimeZone.getTimeZone( id ); } - /** - * @param unit The new Unit value - * @deprecated setUnit(String) is deprecated and is replaced with - * setUnit(Tstamp.Unit) to make Ant's Introspection mechanism do - * the work and also to encapsulate operations on the unit in its - * own class. - */ - public void setUnit( String unit ) - { - log( "DEPRECATED - The setUnit(String) method has been deprecated." - + " Use setUnit(Tstamp.Unit) instead." ); - Unit u = new Unit(); - u.setValue( unit ); - field = u.getCalendarField(); - } - public void setUnit( Unit unit ) { field = unit.getCalendarField(); @@ -225,12 +209,12 @@ public class Tstamp extends Task { if( propertyName == null ) { - throw new BuildException( "property attribute must be provided", location ); + throw new BuildException( "property attribute must be provided" ); } if( pattern == null ) { - throw new BuildException( "pattern attribute must be provided", location ); + throw new BuildException( "pattern attribute must be provided" ); } SimpleDateFormat sdf; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Unpack.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Unpack.java index 1e641b251..98bbf8f86 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Unpack.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Unpack.java @@ -24,12 +24,12 @@ public abstract class Unpack extends Task public void setDest( String dest ) { - this.dest = project.resolveFile( dest ); + this.dest = resolveFile( dest ); } public void setSrc( String src ) { - source = project.resolveFile( src ); + source = resolveFile( src ); } public void execute() @@ -65,17 +65,17 @@ public abstract class Unpack extends Task { if( source == null ) { - throw new BuildException( "No Src for gunzip specified", location ); + throw new BuildException( "No Src for gunzip specified" ); } if( !source.exists() ) { - throw new BuildException( "Src doesn't exist", location ); + throw new BuildException( "Src doesn't exist" ); } if( source.isDirectory() ) { - throw new BuildException( "Cannot expand a directory", location ); + throw new BuildException( "Cannot expand a directory" ); } if( dest == null ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Untar.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Untar.java index 99fba8759..ea7539ffe 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Untar.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Untar.java @@ -46,8 +46,7 @@ public class Untar extends Expand } catch( IOException ioe ) { - throw new BuildException( "Error while expanding " + srcF.getPath(), - ioe, location ); + throw new BuildException( "Error while expanding " + srcF.getPath(), ioe ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java index 968131b0a..43ae44064 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java @@ -94,8 +94,7 @@ public class UpToDate extends MatchingTask implements Condition { if( mapperElement != null ) { - throw new BuildException( "Cannot define more than one mapper", - location ); + throw new BuildException( "Cannot define more than one mapper" ); } mapperElement = new Mapper( project ); return mapperElement; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/War.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/War.java index ff2bf9c48..33dc1e83b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/War.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/War.java @@ -32,12 +32,6 @@ public class War extends Jar emptyBehavior = "create"; } - public void setWarfile( File warFile ) - { - log( "DEPRECATED - The warfile attribute is deprecated. Use file attribute instead." ); - setFile( warFile ); - } - public void setWebxml( File descr ) { deploymentDescriptor = descr; @@ -89,7 +83,7 @@ public class War extends Jar // If no webxml file is specified, it's an error. if( deploymentDescriptor == null && !isInUpdateMode() ) { - throw new BuildException( "webxml attribute is required", location ); + throw new BuildException( "webxml attribute is required" ); } super.initZipOutputStream( zOut ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java index 13a17d2b2..37d5d6c41 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.File; import java.util.Enumeration; import java.util.Vector; @@ -17,7 +18,6 @@ import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.util.FileUtils; - /** * A Task to process via XSLT a set of XML documents. This is useful for * building views of XML based documentation. arguments: @@ -169,7 +169,6 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger this.outputtype = type; } - public void setProcessor( String processor ) { this.processor = processor; @@ -222,12 +221,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger if( xslFile == null ) { - throw new BuildException( "no stylesheet specified", location ); + throw new BuildException( "no stylesheet specified" ); } if( baseDir == null ) { - baseDir = project.resolveFile( "." ); + baseDir = resolveFile( "." ); } liaison = getLiaison(); @@ -235,25 +234,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger // check if liaison wants to log errors using us as logger if( liaison instanceof XSLTLoggerAware ) { - ( ( XSLTLoggerAware )liaison ).setLogger( this ); + ( (XSLTLoggerAware)liaison ).setLogger( this ); } log( "Using " + liaison.getClass().toString(), Project.MSG_VERBOSE ); - File stylesheet = project.resolveFile( xslFile ); - if( !stylesheet.exists() ) - { - stylesheet = fileUtils.resolveFile( baseDir, xslFile ); - /* - * shouldn't throw out deprecation warnings before we know, - * the wrong version has been used. - */ - if( stylesheet.exists() ) - { - log( "DEPRECATED - the style attribute should be relative to the project\'s" ); - log( " basedir, not the tasks\'s basedir." ); - } - } + File stylesheet = resolveFile( xslFile ); // if we have an in file and out then process them if( inFile != null && outFile != null ) @@ -279,16 +265,16 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger list = scanner.getIncludedFiles(); for( int i = 0; i < list.length; ++i ) { - process( baseDir, list[i], destDir, stylesheet ); + process( baseDir, list[ i ], destDir, stylesheet ); } // Process all the directoried marked for styling dirs = scanner.getIncludedDirectories(); for( int j = 0; j < dirs.length; ++j ) { - list = new File( baseDir, dirs[j] ).list(); + list = new File( baseDir, dirs[ j ] ).list(); for( int i = 0; i < list.length; ++i ) - process( baseDir, list[i], destDir, stylesheet ); + process( baseDir, list[ i ], destDir, stylesheet ); } } @@ -306,7 +292,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } else @@ -338,7 +324,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger e4.printStackTrace(); e3.printStackTrace(); e2.printStackTrace(); - throw new BuildException( e1 ); + throw new BuildException( "Error", e1 ); } } } @@ -367,16 +353,16 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { log( "Loading stylesheet " + stylesheet, Project.MSG_INFO ); liaison.setStylesheet( stylesheet ); - for( Enumeration e = params.elements(); e.hasMoreElements(); ) + for( Enumeration e = params.elements(); e.hasMoreElements(); ) { - Param p = ( Param )e.nextElement(); + Param p = (Param)e.nextElement(); liaison.addParam( p.getName(), p.getExpression() ); } } catch( Exception ex ) { log( "Failed to read stylesheet " + stylesheet, Project.MSG_INFO ); - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } @@ -389,7 +375,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger if( !directory.mkdirs() ) { throw new BuildException( "Unable to create directory: " - + directory.getAbsolutePath() ); + + directory.getAbsolutePath() ); } } } @@ -471,7 +457,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger outFile.delete(); } - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } }//-- processXML @@ -500,7 +486,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger log( "Failed to process " + inFile, Project.MSG_INFO ); if( outFile != null ) outFile.delete(); - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } @@ -518,31 +504,17 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { final Class clazz = loadClass( "org.apache.tools.ant.taskdefs.optional.TraXLiaison" ); - liaison = ( XSLTLiaison )clazz.newInstance(); - } - else if( proc.equals( "xslp" ) ) - { - log( "DEPRECATED - xslp processor is deprecated. Use trax or xalan instead." ); - final Class clazz = - loadClass( "org.apache.tools.ant.taskdefs.optional.XslpLiaison" ); - liaison = ( XSLTLiaison )clazz.newInstance(); + liaison = (XSLTLiaison)clazz.newInstance(); } else if( proc.equals( "xalan" ) ) { final Class clazz = loadClass( "org.apache.tools.ant.taskdefs.optional.XalanLiaison" ); - liaison = ( XSLTLiaison )clazz.newInstance(); - } - else if( proc.equals( "adaptx" ) ) - { - log( "DEPRECATED - adaptx processor is deprecated. Use trax or xalan instead." ); - final Class clazz = - loadClass( "org.apache.tools.ant.taskdefs.optional.AdaptxLiaison" ); - liaison = ( XSLTLiaison )clazz.newInstance(); + liaison = (XSLTLiaison)clazz.newInstance(); } else { - liaison = ( XSLTLiaison )loadClass( proc ).newInstance(); + liaison = (XSLTLiaison)loadClass( proc ).newInstance(); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java index 802ec0476..6317eb017 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -184,18 +184,6 @@ public class Zip extends MatchingTask emptyBehavior = we.getValue(); } - /** - * This is the name/location of where to create the .zip file. - * - * @param zipFile The new Zipfile value - * @deprecated Use setFile() instead - */ - public void setZipfile( File zipFile ) - { - log( "DEPRECATED - The zipfile attribute is deprecated. Use file attribute instead." ); - setFile( zipFile ); - } - /** * Are we updating an existing archive? * @@ -383,7 +371,7 @@ public class Zip extends MatchingTask } } - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { @@ -439,7 +427,7 @@ public class Zip extends MatchingTask else if( emptyBehavior.equals( "fail" ) ) { throw new BuildException( "Cannot create " + archiveType + " archive " + zipFile + - ": no files were included.", location ); + ": no files were included." ); } else { @@ -453,7 +441,7 @@ public class Zip extends MatchingTask { if( files[i].equals( zipFile ) ) { - throw new BuildException( "A zip file cannot include itself", location ); + throw new BuildException( "A zip file cannot include itself" ); } } @@ -741,7 +729,7 @@ public class Zip extends MatchingTask } catch( IOException ioe ) { - throw new BuildException( "Could not create empty ZIP archive", ioe, location ); + throw new BuildException( "Could not create empty ZIP archive", ioe ); } return true; } @@ -858,7 +846,7 @@ public class Zip extends MatchingTask { if( file.equals( zipFile ) ) { - throw new BuildException( "A zip file cannot include itself", location ); + throw new BuildException( "A zip file cannot include itself" ); } FileInputStream fIn = new FileInputStream( file ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index a4675b48d..8396985a1 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -414,7 +414,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter } catch( IOException e ) { - throw new BuildException( "Error creating temporary file", e, location ); + throw new BuildException( "Error creating temporary file", e ); } finally { @@ -448,7 +448,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter catch( IOException e ) { throw new BuildException( "Error running " + args[0] - + " compiler", e, location ); + + " compiler", e ); } } finally diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java index 9eee2523a..c5927bacd 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java @@ -52,7 +52,7 @@ public class Javac12 extends DefaultCompilerAdapter { 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.", location ); + " JAVA_HOME to your jdk directory." ); } catch( Exception ex ) { @@ -62,7 +62,7 @@ public class Javac12 extends DefaultCompilerAdapter } else { - throw new BuildException( "Error starting classic compiler: ", ex, location ); + throw new BuildException( "Error starting classic compiler: ", ex ); } } finally @@ -74,7 +74,7 @@ public class Javac12 extends DefaultCompilerAdapter catch( IOException e ) { // plain impossible - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java index 7516d43c9..c0f5f4bc7 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java @@ -55,7 +55,7 @@ public class Javac13 extends DefaultCompilerAdapter } else { - throw new BuildException( "Error starting modern compiler", ex, location ); + throw new BuildException( "Error starting modern compiler", ex ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java index a45f64c3c..e6e869e60 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java @@ -131,23 +131,6 @@ public class Jikes extends DefaultCompilerAdapter cmd.createArgument().setValue( "+E" ); } - /** - * Jikes issues more warnings that javac, for example, when you have - * files in your classpath that don't exist. As this is often the case, - * these warning can be pretty annoying. - */ - String warningsProperty = project.getProperty( "build.compiler.warnings" ); - if( warningsProperty != null ) - { - attributes.log( "!! the build.compiler.warnings property is deprecated. !!", - Project.MSG_WARN ); - attributes.log( "!! Use the nowarn attribute instead. !!", - Project.MSG_WARN ); - if( !Project.toBoolean( warningsProperty ) ) - { - cmd.createArgument().setValue( "-nowarn" ); - } - } if( attributes.getNowarn() ) { /* diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java index 2cb2bdc48..4aa6a8c5d 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java @@ -42,7 +42,7 @@ public class Kjc extends DefaultCompilerAdapter { 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).", location ); + " CLASSPATH to your kjc archive (kjc.jar)." ); } catch( Exception ex ) { @@ -52,7 +52,7 @@ public class Kjc extends DefaultCompilerAdapter } else { - throw new BuildException( "Error starting kjc compiler: ", ex, location ); + throw new BuildException( "Error starting kjc compiler: ", ex ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/defaults.properties index c680c8f92..e31998fb6 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -132,10 +132,3 @@ jspc=org.apache.tools.ant.taskdefs.optional.jsp.JspC replaceregexp=org.apache.tools.ant.taskdefs.optional.ReplaceRegExp translate=org.apache.tools.ant.taskdefs.optional.i18n.Translate -# deprecated ant tasks (kept for back compatibility) -javadoc2=org.apache.tools.ant.taskdefs.Javadoc -#compileTask=org.apache.tools.ant.taskdefs.CompileTask -copydir=org.apache.tools.ant.taskdefs.Copydir -copyfile=org.apache.tools.ant.taskdefs.Copyfile -deltree=org.apache.tools.ant.taskdefs.Deltree -rename=org.apache.tools.ant.taskdefs.Rename diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java index 7269bf2b2..2508be19e 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java @@ -6,13 +6,13 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs.optional; + import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.net.URL; import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.ExitException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Execute; @@ -20,7 +20,6 @@ import org.apache.tools.ant.taskdefs.ExecuteJava; import org.apache.tools.ant.taskdefs.LogStreamHandler; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; -import org.apache.tools.ant.types.Environment; import org.apache.tools.ant.types.Path; /** @@ -128,7 +127,7 @@ public class ANTLR extends Task int err = run( commandline.getCommandline() ); if( err == 1 ) { - throw new BuildException( "ANTLR returned: " + err, location ); + throw new BuildException( "ANTLR returned: " + err ); } } else @@ -136,17 +135,7 @@ public class ANTLR extends Task ExecuteJava exe = new ExecuteJava(); exe.setJavaCommand( commandline.getJavaCommand() ); exe.setClasspath( commandline.getClasspath() ); - try - { - exe.execute( project ); - } - catch( ExitException e ) - { - if( e.getStatus() != 0 ) - { - throw new BuildException( "ANTLR returned: " + e.getStatus(), location ); - } - } + exe.execute( project ); } } } @@ -183,7 +172,7 @@ public class ANTLR extends Task int pling = u.indexOf( "!" ); String jarName = u.substring( 9, pling ); log( "Implicitly adding " + jarName + " to classpath", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); createClasspath().setLocation( new File( ( new File( jarName ) ).getAbsolutePath() ) ); } else if( u.startsWith( "file:" ) ) @@ -191,13 +180,13 @@ public class ANTLR extends Task int tail = u.indexOf( resource ); String dirName = u.substring( 5, tail ); log( "Implicitly adding " + dirName + " to classpath", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); createClasspath().setLocation( new File( ( new File( dirName ) ).getAbsolutePath() ) ); } else { log( "Don\'t know how to handle resource URL " + u, - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } } else @@ -247,7 +236,7 @@ public class ANTLR extends Task throws BuildException { Execute exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO, - Project.MSG_WARN ), null ); + Project.MSG_WARN ), null ); exe.setAntRun( project ); if( workingdir != null ) { @@ -260,7 +249,7 @@ public class ANTLR extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java index cc52a4708..8f60da24c 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/IContract.java @@ -897,27 +897,27 @@ public class IContract extends MatchingTask { if( srcDir == null ) { - throw new BuildException( "srcdir attribute must be set!", location ); + throw new BuildException( "srcdir attribute must be set!" ); } if( !srcDir.exists() ) { - throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!", location ); + throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!"); } if( instrumentDir == null ) { - throw new BuildException( "instrumentdir attribute must be set!", location ); + throw new BuildException( "instrumentdir attribute must be set!"); } if( repositoryDir == null ) { - throw new BuildException( "repositorydir attribute must be set!", location ); + throw new BuildException( "repositorydir attribute must be set!" ); } if( updateIcontrol == true && classDir == null ) { - throw new BuildException( "classdir attribute must be specified when updateicontrol=true!", location ); + throw new BuildException( "classdir attribute must be specified when updateicontrol=true!" ); } if( updateIcontrol == true && controlFile == null ) { - throw new BuildException( "controlfile attribute must be specified when updateicontrol=true!", location ); + throw new BuildException( "controlfile attribute must be specified when updateicontrol=true!" ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java index 76d48b24c..cdd5faaaf 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java @@ -238,23 +238,23 @@ public class Javah extends Task if( ( cls == null ) && ( classes.size() == 0 ) ) { - throw new BuildException( "class attribute must be set!", location ); + throw new BuildException( "class attribute must be set!" ); } if( ( cls != null ) && ( classes.size() > 0 ) ) { - throw new BuildException( "set class attribute or class element, not both.", location ); + throw new BuildException( "set class attribute or class element, not both." ); } if( destDir != null ) { if( !destDir.isDirectory() ) { - throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory", location ); + throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory" ); } if( outputFile != null ) { - throw new BuildException( "destdir and outputFile are mutually exclusive", location ); + throw new BuildException( "destdir and outputFile are mutually exclusive"); } } @@ -381,7 +381,7 @@ public class Javah extends Task { if( !old ) { - throw new BuildException( "stubs only available in old mode.", location ); + throw new BuildException( "stubs only available in old mode." ); } cmd.createArgument().setValue( "-stubs" ); } @@ -442,7 +442,7 @@ public class Javah extends Task } else { - throw new BuildException( "Error starting javah: ", ex, location ); + throw new BuildException( "Error starting javah: ", ex ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ManifestFile.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ManifestFile.java index 4ef6878db..29c3680f4 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ManifestFile.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ManifestFile.java @@ -161,7 +161,7 @@ public class ManifestFile extends Task { if( !checkParam( manifestFile ) ) { - throw new BuildException( "file token must not be null.", location ); + throw new BuildException( "file token must not be null." ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java index 882335c60..413aec28c 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java @@ -100,8 +100,7 @@ public class Native2Ascii extends MatchingTask { if( mapper != null ) { - throw new BuildException( "Cannot define more than one mapper", - location ); + throw new BuildException( "Cannot define more than one mapper" ); } mapper = new Mapper( project ); return mapper; @@ -118,7 +117,7 @@ public class Native2Ascii extends MatchingTask // default srcDir to basedir if( srcDir == null ) { - srcDir = project.resolveFile( "." ); + srcDir = resolveFile( "." ); } // Require destDir diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java index 3b05253a1..a33bd080b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java @@ -19,6 +19,7 @@ import netrexx.lang.Rexx; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; +import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.taskdefs.MatchingTask; /** @@ -586,7 +587,7 @@ public class NetRexxC extends MatchingTask System.getProperty( "path.separator" ), false ); while( tok.hasMoreTokens() ) { - File f = project.resolveFile( tok.nextToken() ); + File f = resolveFile( tok.nextToken() ); if( f.exists() ) { @@ -619,7 +620,7 @@ public class NetRexxC extends MatchingTask String toFile = ( String )filecopyList.get( fromFile ); try { - project.copyFile( fromFile, toFile ); + FileUtils.newFileUtils().copyFile( fromFile, toFile ); } catch( IOException ioe ) { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java index ab7bfd7b1..c185769d7 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java @@ -204,7 +204,7 @@ public class PropertyFile extends Task { if( !checkParam( m_propertyfile ) ) { - throw new BuildException( "file token must not be null.", location ); + throw new BuildException( "file token must not be null." ); } } @@ -293,16 +293,16 @@ public class PropertyFile extends Task catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); - throw new BuildException( t ); + throw new BuildException( "Error", t ); } catch( IllegalAccessException iae ) { // impossible - throw new BuildException( iae ); + throw new BuildException( "Error", iae ); } catch( IOException ioe ) { - throw new BuildException( ioe ); + throw new BuildException( "Error", ioe ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java index 3811e701b..a681c349f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java @@ -102,7 +102,7 @@ public class Rpm extends Task { if( ( sf == null ) || ( sf.trim().equals( "" ) ) ) { - throw new BuildException( "You must specify a spec file", location ); + throw new BuildException( "You must specify a spec file" ); } this.specFile = sf; } @@ -160,7 +160,7 @@ public class Rpm extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } else @@ -175,7 +175,7 @@ public class Rpm extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } else @@ -200,7 +200,7 @@ public class Rpm extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Script.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Script.java index 43a545ec1..294ea0ba8 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Script.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Script.java @@ -59,7 +59,7 @@ public class Script extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } script += new String( data ); @@ -121,7 +121,7 @@ public class Script extends Task t = te; } } - throw new BuildException( t ); + throw new BuildException( "Error", t ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java index 974e06ce5..3105ead43 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java @@ -127,7 +127,7 @@ public class CCMCheck extends Continuus if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java index f4ed8a11a..35f9391e7 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java @@ -280,7 +280,7 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } //create task ok, set this task as the default one @@ -295,7 +295,7 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler if( result != 0 ) { String msg = "Failed executing: " + commandLine2.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java index d079f2ae7..388599fba 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java @@ -133,7 +133,7 @@ public class CCMReconfigure extends Continuus if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java index efc30650d..ad7cdb5b5 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java @@ -120,7 +120,7 @@ public abstract class Continuus extends Task } catch( java.io.IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java index e4104295a..891d53a45 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java @@ -348,7 +348,7 @@ public class CCCheckin extends ClearCase if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java index 7c649bc5b..123c1d040 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java @@ -435,7 +435,7 @@ public class CCCheckout extends ClearCase if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java index 02a442f2c..96b994bc4 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java @@ -139,7 +139,7 @@ public class CCUnCheckout extends ClearCase if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java index 2d88f71c4..9d9e5f1de 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java @@ -352,7 +352,7 @@ public class CCUpdate extends ClearCase if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java index 917152f39..9f003d69f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java @@ -116,7 +116,7 @@ public abstract class ClearCase extends Task } catch( java.io.IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java index 62ec1812e..01196c9b7 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java @@ -201,7 +201,7 @@ public class Depend extends MatchingTask String[] srcPathList = srcPath.list(); if( srcPathList.length == 0 ) { - throw new BuildException( "srcdir attribute must be set!", location ); + throw new BuildException( "srcdir attribute must be set!" ); } if( destPath == null ) @@ -261,7 +261,7 @@ public class Depend extends MatchingTask outOfDateClasses = new Hashtable(); for( int i = 0; i < srcPathList.length; i++ ) { - File srcDir = ( File )project.resolveFile( srcPathList[i] ); + File srcDir = ( File )resolveFile( srcPathList[i] ); if( srcDir.exists() ) { DirectoryScanner ds = this.getDirectoryScanner( srcDir ); @@ -310,7 +310,7 @@ public class Depend extends MatchingTask } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java index 371264a4a..fabadd12b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java @@ -649,7 +649,7 @@ public class CSharp throws BuildException { if( _srcDir == null ) - _srcDir = project.resolveFile( "." ); + _srcDir = resolveFile( "." ); NetCommand command = new NetCommand( this, "CSC", csc_exe_name ); command.setFailOnError( getFailFailOnError() ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java index b1440d32f..c5e94ca64 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java @@ -310,7 +310,7 @@ public class Ilasm throws BuildException { if( _srcDir == null ) - _srcDir = project.resolveFile( "." ); + _srcDir = resolveFile( "." ); //get dependencies list. DirectoryScanner scanner = super.getDirectoryScanner( _srcDir ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java index 4f28dffe7..74ed0e33e 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java @@ -158,7 +158,7 @@ public class NetCommand { if( _failOnError ) { - throw new BuildException( _title + " returned: " + err, _owner.getLocation() ); + throw new BuildException( _title + " returned: " + err ); } else { @@ -168,7 +168,7 @@ public class NetCommand } catch( IOException e ) { - throw new BuildException( _title + " failed: " + e, e, _owner.getLocation() ); + throw new BuildException( _title + " failed: " + e, e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java index ff7a72719..5f37ba9c4 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java @@ -396,13 +396,13 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exec if( result != 0 ) { String msg = "Failed executing java2iiop (ret code is " + result + ")"; - throw new BuildException( msg, getTask().getLocation() ); + throw new BuildException( msg ); } } catch( java.io.IOException e ) { log( "java2iiop exception :" + e.getMessage(), Project.MSG_ERR ); - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java index 29a49f9aa..6343dbbb2 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java @@ -307,7 +307,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { String msg = "A valid destination directory must be specified " + "using the \"destdir\" attribute."; - throw new BuildException( msg, getLocation() ); + throw new BuildException( msg ); } } @@ -859,8 +859,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool in = new FileInputStream( config.manifest ); if( in == null ) { - throw new BuildException( "Could not find manifest file: " + config.manifest, - getLocation() ); + throw new BuildException( "Could not find manifest file: " + config.manifest ); } } else @@ -869,8 +868,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool in = this.getClass().getResourceAsStream( defaultManifest ); if( in == null ) { - throw new BuildException( "Could not find default manifest: " + defaultManifest, - getLocation() ); + throw new BuildException( "Could not find default manifest: " + defaultManifest ); } } @@ -878,7 +876,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool } catch( IOException e ) { - throw new BuildException( "Unable to read manifest", e, getLocation() ); + throw new BuildException( "Unable to read manifest", e ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java index 0dfdd0041..8c647dc47 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java @@ -218,7 +218,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool + " descriptor should be prepended with the JAR " + "name or it should be specified using the " + "attribute \"basejarname\" in the \"ejbjar\" task."; - throw new BuildException( msg, getLocation() ); + throw new BuildException( msg ); } File iasDescriptor = new File( getConfig().descriptorDir, @@ -227,14 +227,14 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { String msg = "The iAS-specific EJB descriptor (" + iasDescriptor + ") was not found."; - throw new BuildException( msg, getLocation() ); + throw new BuildException( msg ); } if( ( iashome != null ) && ( !iashome.isDirectory() ) ) { String msg = "If \"iashome\" is specified, it must be a valid " + "directory (it was set to " + iashome + ")."; - throw new BuildException( msg, getLocation() ); + throw new BuildException( msg ); } } @@ -287,7 +287,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool catch( IPlanetEjbc.EjbcException e ) { throw new BuildException( "An error has occurred while trying to " - + "execute the iAS ejbc utility", e, getLocation() ); + + "execute the iAS ejbc utility", e ); } displayName = ejbc.getDisplayName(); @@ -313,7 +313,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool if( !cmpFile.exists() ) { throw new BuildException( "The CMP descriptor file (" - + cmpFile + ") could not be found.", getLocation() ); + + cmpFile + ") could not be found." ); } files.put( cmpDescriptors[i], cmpFile ); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java index ce5f22396..bc6ba5c99 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java @@ -229,12 +229,12 @@ public class IPlanetEjbcTask extends Task catch( SAXException e ) { String msg = "Unable to create a SAXParser: " + e.getMessage(); - throw new BuildException( msg, e, location ); + throw new BuildException( msg, e ); } catch( ParserConfigurationException e ) { String msg = "Unable to create a SAXParser: " + e.getMessage(); - throw new BuildException( msg, e, location ); + throw new BuildException( msg, e ); } return saxParser; @@ -253,46 +253,46 @@ public class IPlanetEjbcTask extends Task { String msg = "The standard EJB descriptor must be specified using " + "the \"ejbdescriptor\" attribute."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( ( !ejbdescriptor.exists() ) || ( !ejbdescriptor.isFile() ) ) { String msg = "The standard EJB descriptor (" + ejbdescriptor + ") was not found or isn't a file."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( iasdescriptor == null ) { String msg = "The iAS-speific XML descriptor must be specified using" + " the \"iasdescriptor\" attribute."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( ( !iasdescriptor.exists() ) || ( !iasdescriptor.isFile() ) ) { String msg = "The iAS-specific XML descriptor (" + iasdescriptor + ") was not found or isn't a file."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( dest == null ) { String msg = "The destination directory must be specified using " + "the \"dest\" attribute."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( ( !dest.exists() ) || ( !dest.isDirectory() ) ) { String msg = "The destination directory (" + dest + ") was not " + "found or isn't a directory."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( ( iashome != null ) && ( !iashome.isDirectory() ) ) { String msg = "If \"iashome\" is specified, it must be a valid " + "directory (it was set to " + iashome + ")."; - throw new BuildException( msg, getLocation() ); + throw new BuildException( msg ); } } @@ -327,19 +327,19 @@ public class IPlanetEjbcTask extends Task { String msg = "An IOException occurred while trying to read the XML " + "descriptor file: " + e.getMessage(); - throw new BuildException( msg, e, location ); + throw new BuildException( msg, e ); } catch( SAXException e ) { String msg = "A SAXException occurred while trying to read the XML " + "descriptor file: " + e.getMessage(); - throw new BuildException( msg, e, location ); + throw new BuildException( msg, e ); } catch( IPlanetEjbc.EjbcException e ) { String msg = "An exception occurred while trying to run the ejbc " + "utility: " + e.getMessage(); - throw new BuildException( msg, e, location ); + throw new BuildException( msg, e ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java index e4d43714a..227763d2d 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java @@ -304,7 +304,7 @@ public class WLRun extends Task if( !propertiesFile.exists() ) { // OK, properties file may be absolute - propertiesFile = project.resolveFile( weblogicPropertiesFile ); + propertiesFile = resolveFile( weblogicPropertiesFile ); if( !propertiesFile.exists() ) { throw new BuildException( "Properties file " + weblogicPropertiesFile + @@ -411,7 +411,7 @@ public class WLRun extends Task // absolute path. Use the project to resolve it. if( this.securityPolicy != null && !securityPolicyFile.exists() ) { - securityPolicyFile = project.resolveFile( securityPolicy ); + securityPolicyFile = resolveFile( securityPolicy ); } // If we still can't find it, complain if( !securityPolicyFile.exists() ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java index ddd1d9e6e..a84e8a330 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java @@ -6,12 +6,24 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs.optional.i18n; -import java.io.*; -import java.util.*; -import org.apache.tools.ant.*; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.Hashtable; +import java.util.Locale; +import java.util.Vector; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.MatchingTask; -import org.apache.tools.ant.types.*; -import org.apache.tools.ant.util.*; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.util.FileUtils; /** * Translates text embedded in files using Resource Bundle files. @@ -35,7 +47,7 @@ public class Translate extends MatchingTask /** * Last Modified Timestamp of resource bundle file being used. */ - private long[] bundleLastModified = new long[7]; + private long[] bundleLastModified = new long[ 7 ]; /** * Has at least one file from the bundle been loaded? */ @@ -229,34 +241,29 @@ public class Translate extends MatchingTask { if( bundle == null ) { - throw new BuildException( "The bundle attribute must be set.", - location ); + throw new BuildException( "The bundle attribute must be set." ); } if( startToken == null ) { - throw new BuildException( "The starttoken attribute must be set.", - location ); + throw new BuildException( "The starttoken attribute must be set." ); } if( startToken.length() != 1 ) { throw new BuildException( - "The starttoken attribute must be a single character.", - location ); + "The starttoken attribute must be a single character." ); } if( endToken == null ) { - throw new BuildException( "The endtoken attribute must be set.", - location ); + throw new BuildException( "The endtoken attribute must be set." ); } if( endToken.length() != 1 ) { throw new BuildException( - "The endtoken attribute must be a single character.", - location ); + "The endtoken attribute must be a single character." ); } if( bundleLanguage == null ) @@ -280,8 +287,7 @@ public class Translate extends MatchingTask if( toDir == null ) { - throw new BuildException( "The todir attribute must be set.", - location ); + throw new BuildException( "The todir attribute must be set." ); } if( !toDir.exists() ) @@ -391,7 +397,7 @@ public class Translate extends MatchingTask } catch( IOException ioe ) { - throw new BuildException( ioe.getMessage(), location ); + throw new BuildException( ioe.getMessage() ); } } @@ -415,8 +421,8 @@ public class Translate extends MatchingTask throws BuildException { Locale locale = new Locale( bundleLanguage, - bundleCountry, - bundleVariant ); + bundleCountry, + bundleVariant ); String language = locale.getLanguage().length() > 0 ? "_" + locale.getLanguage() : ""; @@ -481,7 +487,7 @@ public class Translate extends MatchingTask { ins = new FileInputStream( bundleFile ); loaded = true; - bundleLastModified[i] = new File( bundleFile ).lastModified(); + bundleLastModified[ i ] = new File( bundleFile ).lastModified(); log( "Using " + bundleFile, Project.MSG_DEBUG ); loadResourceMap( ins ); } @@ -493,7 +499,7 @@ public class Translate extends MatchingTask //find a single resrouce file, throw exception if( !loaded && checkLoaded ) { - throw new BuildException( ioe.getMessage(), location ); + throw new BuildException( ioe.getMessage() ); } } } @@ -515,14 +521,14 @@ public class Translate extends MatchingTask { for( int i = 0; i < filesets.size(); i++ ) { - FileSet fs = ( FileSet )filesets.elementAt( i ); + FileSet fs = (FileSet)filesets.elementAt( i ); DirectoryScanner ds = fs.getDirectoryScanner( project ); String[] srcFiles = ds.getIncludedFiles(); for( int j = 0; j < srcFiles.length; j++ ) { try { - File dest = fileUtils.resolveFile( toDir, srcFiles[j] ); + File dest = fileUtils.resolveFile( toDir, srcFiles[ j ] ); //Make sure parent dirs exist, else, create them. try { @@ -536,31 +542,31 @@ public class Translate extends MatchingTask { log( "Exception occured while trying to check/create " + " parent directory. " + e.getMessage(), - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } destLastModified = dest.lastModified(); - srcLastModified = new File( srcFiles[i] ).lastModified(); + srcLastModified = new File( srcFiles[ i ] ).lastModified(); //Check to see if dest file has to be recreated if( forceOverwrite - || destLastModified < srcLastModified - || destLastModified < bundleLastModified[0] - || destLastModified < bundleLastModified[1] - || destLastModified < bundleLastModified[2] - || destLastModified < bundleLastModified[3] - || destLastModified < bundleLastModified[4] - || destLastModified < bundleLastModified[5] - || destLastModified < bundleLastModified[6] ) + || destLastModified < srcLastModified + || destLastModified < bundleLastModified[ 0 ] + || destLastModified < bundleLastModified[ 1 ] + || destLastModified < bundleLastModified[ 2 ] + || destLastModified < bundleLastModified[ 3 ] + || destLastModified < bundleLastModified[ 4 ] + || destLastModified < bundleLastModified[ 5 ] + || destLastModified < bundleLastModified[ 6 ] ) { - log( "Processing " + srcFiles[j], - Project.MSG_DEBUG ); + log( "Processing " + srcFiles[ j ], + Project.MSG_DEBUG ); FileOutputStream fos = new FileOutputStream( dest ); BufferedWriter out = new BufferedWriter( new OutputStreamWriter( fos, - destEncoding ) ); - FileInputStream fis = new FileInputStream( srcFiles[j] ); + destEncoding ) ); + FileInputStream fis = new FileInputStream( srcFiles[ j ] ); BufferedReader in = new BufferedReader( new InputStreamReader( fis, - srcEncoding ) ); + srcEncoding ) ); String line; while( ( line = in.readLine() ) != null ) { @@ -582,7 +588,7 @@ public class Translate extends MatchingTask break; } String matches = line.substring( startIndex + 1, - endIndex ); + endIndex ); //If there is a white space or = or :, then //it isn't to be treated as a valid key. for( int k = 0; k < matches.length(); k++ ) @@ -597,19 +603,19 @@ public class Translate extends MatchingTask } } String replace = null; - replace = ( String )resourceMap.get( matches ); + replace = (String)resourceMap.get( matches ); //If the key hasn't been loaded into resourceMap, //use the key itself as the value also. if( replace == null ) { log( "Warning: The key: " + matches + " hasn't been defined.", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); replace = matches; } line = line.substring( 0, startIndex ) - + replace - + line.substring( endIndex + 1 ); + + replace + + line.substring( endIndex + 1 ); endIndex = startIndex + replace.length() + 1; if( endIndex + 1 >= line.length() ) { @@ -630,14 +636,14 @@ public class Translate extends MatchingTask } else { - log( "Skipping " + srcFiles[j] + - " as destination file is up to date", - Project.MSG_VERBOSE ); + log( "Skipping " + srcFiles[ j ] + + " as destination file is up to date", + Project.MSG_VERBOSE ); } } catch( IOException ioe ) { - throw new BuildException( ioe.getMessage(), location ); + throw new BuildException( ioe.getMessage() ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java index 247c2427a..729090720 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java @@ -392,7 +392,7 @@ abstract class VAJLocalUtil implements VAJUtil } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } if( files.size() > 0 ) { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java index c14253574..119ce308f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java @@ -69,7 +69,7 @@ class VAJRemoteUtil implements VAJUtil } catch( Exception ex ) { - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } @@ -104,7 +104,7 @@ class VAJRemoteUtil implements VAJUtil } catch( Exception ex ) { - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } @@ -135,7 +135,7 @@ class VAJRemoteUtil implements VAJUtil } catch( Exception ex ) { - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java index c8e6da765..2efdae7e3 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java @@ -280,8 +280,7 @@ public class JDependTask extends Task if( errorOccurred ) { if( getHaltonerror() ) - throw new BuildException( "JDepend failed", - location ); + throw new BuildException( "JDepend failed" ); else log( "JDepend FAILED", Project.MSG_ERR ); } @@ -352,7 +351,7 @@ public class JDependTask extends Task } catch( IOException e ) { - throw new BuildException( "Process fork failed.", e, location ); + throw new BuildException( "Process fork failed.", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java index 94d642f0c..a053c2111 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java @@ -173,7 +173,7 @@ public class JlinkTask extends MatchingTask } catch( Exception ex ) { - throw new BuildException( ex); + throw new BuildException( "Error", ex); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java index 2d91db4ca..ae6938f5a 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java @@ -323,22 +323,19 @@ public class JspC extends MatchingTask // first off, make sure that we've got a srcdir if( src == null ) { - throw new BuildException( "srcdir attribute must be set!", - location ); + throw new BuildException( "srcdir attribute must be set!" ); } String[] list = src.list(); if( list.length == 0 ) { - throw new BuildException( "srcdir attribute must be set!", - location ); + throw new BuildException( "srcdir attribute must be set!" ); } if( destDir != null && !destDir.isDirectory() ) { throw new BuildException( "destination directory \"" + destDir + - "\" does not exist or is not a directory", - location ); + "\" does not exist or is not a directory" ); } // calculate where the files will end up: @@ -358,11 +355,11 @@ public class JspC extends MatchingTask int filecount = 0; for( int i = 0; i < list.length; i++ ) { - File srcDir = ( File )project.resolveFile( list[i] ); + File srcDir = ( File )resolveFile( list[i] ); if( !srcDir.exists() ) { throw new BuildException( "srcdir \"" + srcDir.getPath() + - "\" does not exist!", location ); + "\" does not exist!" ); } DirectoryScanner ds = this.getDirectoryScanner( srcDir ); @@ -399,7 +396,7 @@ public class JspC extends MatchingTask { if( failOnError ) { - throw new BuildException( FAIL_MSG, location ); + throw new BuildException( FAIL_MSG ); } else { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java index 20d7a9176..0c8e43a4b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java @@ -149,7 +149,7 @@ public class WLJspc extends MatchingTask if( destinationPackage == null ) { - throw new BuildException( "package attribute must be present.", location ); + throw new BuildException( "package attribute must be present." ); } String systemClassPath = System.getProperty( "java.class.path" ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java index 4f0985bbf..bd169b9f6 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java @@ -53,7 +53,7 @@ public class JasperC extends DefaultCompilerAdapter else { throw new BuildException( "Error running jsp compiler: ", - ex, getJspc().getLocation() ); + ex ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java index 0d1e7e9d7..123c51854 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java @@ -17,6 +17,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; +import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.types.EnumeratedAttribute; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -216,11 +217,12 @@ public class AggregateTransformer // set the destination directory relative from the project if needed. if( toDir == null ) { - toDir = task.getProject().resolveFile( "." ); + toDir = FileUtils.newFileUtils().resolveFile( task.getProject().getBaseDir(), "." ); } else if( !toDir.isAbsolute() ) { - toDir = task.getProject().resolveFile( toDir.getPath() ); + toDir = FileUtils.newFileUtils(). + resolveFile( task.getProject().getBaseDir(), toDir.getPath() ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java index b7db0aa61..5bc2dc3a9 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java @@ -185,7 +185,7 @@ public class FormatterElement } catch( ClassNotFoundException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } Object o = null; @@ -195,11 +195,11 @@ public class FormatterElement } catch( InstantiationException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } catch( IllegalAccessException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } if( !( o instanceof JUnitResultFormatter ) ) @@ -217,7 +217,7 @@ public class FormatterElement } catch( java.io.IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } r.setOutput( out ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index b53a45da3..42e0488e5 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -443,7 +443,7 @@ public class JUnitTask extends Task String filename = test.getOutfile() + fe.getExtension(); File destFile = new File( test.getTodir(), filename ); String absFilename = destFile.getAbsolutePath(); - return project.resolveFile( absFilename ); + return resolveFile( absFilename ); } return null; } @@ -525,7 +525,7 @@ public class JUnitTask extends Task //@todo should be moved to the test class instead. if( test.getTodir() == null ) { - test.setTodir( project.resolveFile( "." ) ); + test.setTodir( resolveFile( "." ) ); } if( test.getOutfile() == null ) @@ -561,8 +561,7 @@ public class JUnitTask extends Task || failureOccurredHere && test.getHaltonfailure() ) { throw new BuildException( "Test " + test.getName() + " failed" - + ( wasKilled ? " (timeout)" : "" ), - location ); + + ( wasKilled ? " (timeout)" : "" ) ); } else { @@ -672,7 +671,7 @@ public class JUnitTask extends Task } catch( java.io.IOException e ) { - throw new BuildException( "Error creating temporary properties file.", e, location ); + throw new BuildException( "Error creating temporary properties file.", e ); } Execute execute = new Execute( new LogStreamHandler( this, Project.MSG_INFO, Project.MSG_WARN ), watchdog ); @@ -691,7 +690,7 @@ public class JUnitTask extends Task } catch( IOException e ) { - throw new BuildException( "Process fork failed.", e, location ); + throw new BuildException( "Process fork failed.", e ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java index cc72e239f..bdbf5233f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java @@ -24,6 +24,7 @@ import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.util.DOMElementWriter; import org.apache.tools.ant.util.StringUtils; +import org.apache.tools.ant.util.FileUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; @@ -185,7 +186,7 @@ public class XMLResultAggregator extends Task implements XMLConstants } if( toDir == null ) { - toDir = project.resolveFile( DEFAULT_DIR ); + toDir = FileUtils.newFileUtils().resolveFile( project.getBaseDir(), DEFAULT_DIR ); } return new File( toDir, toFile ); } @@ -211,7 +212,8 @@ public class XMLResultAggregator extends Task implements XMLConstants if( pathname.endsWith( ".xml" ) ) { File file = new File( ds.getBasedir(), pathname ); - file = project.resolveFile( file.getPath() ); + file = FileUtils.newFileUtils(). + resolveFile( project.getBaseDir(), file.getPath() ); v.addElement( file ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java index 500cddfd7..31b5ff0c9 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java @@ -276,7 +276,7 @@ public abstract class AbstractMetamataTask extends Task { throw new BuildException( "'metamatahome' must point to Metamata home directory." ); } - metamataHome = project.resolveFile( metamataHome.getPath() ); + metamataHome = resolveFile( metamataHome.getPath() ); File jar = getMetamataJar( metamataHome ); if( !jar.exists() ) { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MAudit.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MAudit.java index 80c5415bb..900bdc243 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MAudit.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MAudit.java @@ -238,7 +238,7 @@ public class MAudit extends AbstractMetamataTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } return handler; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java index efbc76c0a..1e25b6b93 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java @@ -336,7 +336,7 @@ public class MParse extends Task { throw new BuildException( "'metamatahome' must point to Metamata home directory." ); } - metahome = project.resolveFile( metahome.getPath() ); + metahome = resolveFile( metahome.getPath() ); // check that the needed jar exists. File[] jars = getMetamataLibs(); @@ -353,7 +353,7 @@ public class MParse extends Task { throw new BuildException( "Invalid target: " + target ); } - target = project.resolveFile( target.getPath() ); + target = resolveFile( target.getPath() ); } /** diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java index 5d6ba1f1c..8865b344b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java @@ -95,27 +95,6 @@ public class FTP private String server; private String userid; - /** - * Sets the FTP action to be taken. Currently accepts "put", "get", "del", - * "mkdir" and "list". - * - * @param action The new Action value - * @exception BuildException Description of Exception - * @deprecated setAction(String) is deprecated and is replaced with - * setAction(FTP.Action) to make Ant's Introspection mechanism do the - * work and also to encapsulate operations on the type in its own - * class. - */ - public void setAction( String action ) - throws BuildException - { - log( "DEPRECATED - The setAction(String) method has been deprecated." - + " Use setAction(FTP.Action) instead." ); - Action a = new Action(); - a.setValue( action ); - this.action = a.getAction(); - } - /** * Sets the FTP action to be taken. Currently accepts "put", "get", "del", * "mkdir" and "list". @@ -419,7 +398,7 @@ public class FTP OutputStream outstream = null; try { - File file = project.resolveFile( new File( dir, filename ).getPath() ); + File file = resolveFile( new File( dir, filename ).getPath() ); if( newerOnly && isUpToDate( ftp, file, resolveFile( filename ) ) ) return; @@ -747,7 +726,7 @@ public class FTP InputStream instream = null; try { - File file = project.resolveFile( new File( dir, filename ).getPath() ); + File file = resolveFile( new File( dir, filename ).getPath() ); if( newerOnly && isUpToDate( ftp, file, resolveFile( filename ) ) ) return; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java index 1a498c6df..ec6043e87 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java @@ -296,7 +296,7 @@ public class MimeMail extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } @@ -361,7 +361,7 @@ public class MimeMail extends Task { if( failOnError ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } else { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java index f2d1e7c46..8fa57bed6 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java @@ -249,7 +249,7 @@ public class TelnetTask extends Task } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } @@ -299,7 +299,7 @@ public class TelnetTask extends Task Thread.sleep( 250 ); } if( is.available() == 0 ) - throw new BuildException( "Response Timed-Out", getLocation() ); + throw new BuildException( "Response Timed-Out" ); sb.append( ( char )is.read() ); } } @@ -311,7 +311,7 @@ public class TelnetTask extends Task } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java index dd93d117c..f23e4f6b4 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java @@ -170,7 +170,7 @@ public abstract class P4Base extends org.apache.tools.ant.Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java index 552817a5b..d077d85ae 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java @@ -81,7 +81,7 @@ public abstract class P4HandlerAdapter implements P4Handler } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java index 64ad0ad85..0068b772b 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java @@ -370,7 +370,7 @@ public class Pvcs extends org.apache.tools.ant.Task if( result != 0 && !ignorerc ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( !tmp.exists() ) @@ -412,24 +412,24 @@ public class Pvcs extends org.apache.tools.ant.Task if( result != 0 && !ignorerc ) { String msg = "Failed executing: " + commandLine.toString() + ". Return code was " + result; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } catch( FileNotFoundException e ) { String msg = "Failed executing: " + commandLine.toString() + ". Exception: " + e.getMessage(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } catch( IOException e ) { String msg = "Failed executing: " + commandLine.toString() + ". Exception: " + e.getMessage(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } catch( ParseException e ) { String msg = "Failed executing: " + commandLine.toString() + ". Exception: " + e.getMessage(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } finally { @@ -459,7 +459,7 @@ public class Pvcs extends org.apache.tools.ant.Task catch( java.io.IOException e ) { String msg = "Failed executing: " + cmd.toString() + ". Exception: " + e.getMessage(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java index 23abe6fe7..6711b46bf 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java @@ -155,7 +155,7 @@ public class CovMerge extends Task { String pathname = f[j]; File file = new File( ds.getBasedir(), pathname ); - file = project.resolveFile( file.getPath() ); + file = resolveFile( file.getPath() ); v.addElement( file ); } } @@ -214,7 +214,7 @@ public class CovMerge extends Task pw.println( snapshots[i].getAbsolutePath() ); } // last file is the output snapshot - pw.println( project.resolveFile( tofile.getPath() ) ); + pw.println( resolveFile( tofile.getPath() ) ); pw.flush(); } catch( IOException e ) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java index 287b559d2..01a62e3b4 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java @@ -285,13 +285,13 @@ public class CovReport extends Task { v.addElement( "-filters=" + filters ); } - v.addElement( "-output=" + project.resolveFile( tofile.getPath() ) ); - v.addElement( "-snapshot=" + project.resolveFile( snapshot.getPath() ) ); + v.addElement( "-output=" + resolveFile( tofile.getPath() ) ); + v.addElement( "-snapshot=" + resolveFile( snapshot.getPath() ) ); // as a default -sourcepath use . in JProbe, so use project . if( sourcePath == null ) { sourcePath = new Path( project ); - sourcePath.createPath().setLocation( project.resolveFile( "." ) ); + sourcePath.createPath().setLocation( resolveFile( "." ) ); } v.addElement( "-sourcepath=" + sourcePath ); diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java index 3dc028c44..5b0039698 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java @@ -331,7 +331,7 @@ public class Coverage extends Task } if( javaExe != null ) { - params.addElement( "-jp_java_exe=" + project.resolveFile( javaExe.getPath() ) ); + params.addElement( "-jp_java_exe=" + resolveFile( javaExe.getPath() ) ); } params.addElement( "-jp_working_dir=" + workingDir.getPath() ); params.addElement( "-jp_snapshot_dir=" + snapshotDir.getPath() ); @@ -408,7 +408,7 @@ public class Coverage extends Task { snapshotDir = new File( "." ); } - snapshotDir = project.resolveFile( snapshotDir.getPath() ); + snapshotDir = resolveFile( snapshotDir.getPath() ); if( !snapshotDir.isDirectory() || !snapshotDir.exists() ) { throw new BuildException( "Snapshot directory does not exists :" + snapshotDir ); @@ -417,7 +417,7 @@ public class Coverage extends Task { workingDir = new File( "." ); } - workingDir = project.resolveFile( workingDir.getPath() ); + workingDir = resolveFile( workingDir.getPath() ); // check for info, do your best to select the java executable. // JProbe 3.0 fails if there is no javaexe option. So diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java index 2bd290da5..63a63e54a 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java @@ -232,7 +232,7 @@ public abstract class MSVSS extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java index 8e936b6d4..c69dc33b1 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java @@ -142,7 +142,7 @@ public class MSVSSCHECKIN extends MSVSS else { // make sure m_LocalDir exists, create it if it doesn't - File dir = project.resolveFile( m_LocalPath ); + File dir = resolveFile( m_LocalPath ); if( !dir.exists() ) { boolean done = dir.mkdirs(); @@ -150,7 +150,7 @@ public class MSVSSCHECKIN extends MSVSS { String msg = "Directory " + m_LocalPath + " creation was not " + "succesful for an unknown reason"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } project.log( "Created dir: " + dir.getAbsolutePath() ); } @@ -207,7 +207,7 @@ public class MSVSSCHECKIN extends MSVSS if( getVsspath() == null ) { String msg = "vsspath attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } // now look for illegal combinations of things ... @@ -237,7 +237,7 @@ public class MSVSSCHECKIN extends MSVSS if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java index 356bf1565..e3f0124ee 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java @@ -169,7 +169,7 @@ public class MSVSSCHECKOUT extends MSVSS else { // make sure m_LocalDir exists, create it if it doesn't - File dir = project.resolveFile( m_LocalPath ); + File dir = resolveFile( m_LocalPath ); if( !dir.exists() ) { boolean done = dir.mkdirs(); @@ -177,7 +177,7 @@ public class MSVSSCHECKOUT extends MSVSS { String msg = "Directory " + m_LocalPath + " creation was not " + "succesful for an unknown reason"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } project.log( "Created dir: " + dir.getAbsolutePath() ); } @@ -242,7 +242,7 @@ public class MSVSSCHECKOUT extends MSVSS if( getVsspath() == null ) { String msg = "vsspath attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } // now look for illegal combinations of things ... @@ -270,7 +270,7 @@ public class MSVSSCHECKOUT extends MSVSS if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java index 17bcc222c..8ec462510 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java @@ -377,7 +377,7 @@ public class MSVSSGET extends MSVSS else { // make sure m_LocalDir exists, create it if it doesn't - File dir = project.resolveFile( m_LocalPath ); + File dir = resolveFile( m_LocalPath ); if( !dir.exists() ) { boolean done = dir.mkdirs(); @@ -385,7 +385,7 @@ public class MSVSSGET extends MSVSS { String msg = "Directory " + m_LocalPath + " creation was not " + "successful for an unknown reason"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } project.log( "Created dir: " + dir.getAbsolutePath() ); } @@ -473,7 +473,7 @@ public class MSVSSGET extends MSVSS if( getVsspath() == null ) { String msg = "vsspath attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } // now look for illegal combinations of things ... @@ -505,7 +505,7 @@ public class MSVSSGET extends MSVSS if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java index 583e2249a..58b2d1e4f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java @@ -226,7 +226,7 @@ public class MSVSSHISTORY extends MSVSS if( getVsspath() == null ) { String msg = "vsspath attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } // now look for illegal combinations of things ... @@ -272,7 +272,7 @@ public class MSVSSHISTORY extends MSVSS if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } @@ -346,7 +346,7 @@ public class MSVSSHISTORY extends MSVSS catch( ParseException ex ) { String msg = "Error parsing date: " + m_ToDate; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } cmd.createArgument().setValue( FLAG_VERSION_DATE + m_ToDate + VALUE_FROMDATE + startDate ); } @@ -360,7 +360,7 @@ public class MSVSSHISTORY extends MSVSS catch( ParseException ex ) { String msg = "Error parsing date: " + m_FromDate; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } cmd.createArgument().setValue( FLAG_VERSION_DATE + endDate + VALUE_FROMDATE + m_FromDate ); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java index d113a2f03..d9ac730f8 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java @@ -328,12 +328,12 @@ public class MSVSSLABEL extends MSVSS if( getVsspath() == null ) { String msg = "vsspath attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( getLabel() == null ) { String msg = "label attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } // now look for illegal combinations of things ... @@ -368,7 +368,7 @@ public class MSVSSLABEL extends MSVSS if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java index a7a76813e..c835faf9f 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java @@ -42,7 +42,7 @@ public class KaffeRmic extends DefaultRmicAdapter { throw new BuildException( "Cannot use Kaffe rmic, as it is not available" + " A common solution is to set the environment variable" + - " JAVA_HOME or CLASSPATH.", getRmic().getLocation() ); + " JAVA_HOME or CLASSPATH." ); } catch( Exception ex ) { @@ -52,7 +52,7 @@ public class KaffeRmic extends DefaultRmicAdapter } else { - throw new BuildException( "Error starting Kaffe rmic: ", ex, getRmic().getLocation() ); + throw new BuildException( "Error starting Kaffe rmic: ", ex ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java index 6b375df25..c21c07c09 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java @@ -50,7 +50,7 @@ public class SunRmic extends DefaultRmicAdapter { throw new BuildException( "Cannot use SUN rmic, as it is not available" + " A common solution is to set the environment variable" + - " JAVA_HOME or CLASSPATH.", getRmic().getLocation() ); + " JAVA_HOME or CLASSPATH." ); } catch( Exception ex ) { @@ -60,7 +60,7 @@ public class SunRmic extends DefaultRmicAdapter } else { - throw new BuildException( "Error starting SUN rmic: ", ex, getRmic().getLocation() ); + throw new BuildException( "Error starting SUN rmic: ", ex ); } } finally @@ -71,7 +71,7 @@ public class SunRmic extends DefaultRmicAdapter } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java index 67fc6fcf4..fae6392a0 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java @@ -58,7 +58,7 @@ public class WLRmic extends DefaultRmicAdapter { throw new BuildException( "Cannot use WebLogic rmic, as it is not available" + " A common solution is to set the environment variable" + - " CLASSPATH.", getRmic().getLocation() ); + " CLASSPATH." ); } catch( Exception ex ) { @@ -68,7 +68,7 @@ public class WLRmic extends DefaultRmicAdapter } else { - throw new BuildException( "Error starting WebLogic rmic: ", ex, getRmic().getLocation() ); + throw new BuildException( "Error starting WebLogic rmic: ", ex ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/DataType.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/DataType.java index 6bc7085f0..7ac037887 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/DataType.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/DataType.java @@ -6,7 +6,9 @@ * the LICENSE file. */ package org.apache.tools.ant.types; + import java.util.Stack; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectComponent; @@ -22,16 +24,19 @@ import org.apache.tools.ant.ProjectComponent; * * @author Stefan Bodewig */ -public abstract class DataType extends ProjectComponent +public abstract class DataType + extends ProjectComponent { /** * The descriptin the user has set. */ - protected String description = null; + protected String description; + /** * Value to the refid attribute. */ - protected Reference ref = null; + protected Reference ref; + /** * Are we sure we don't hold circular references? * @@ -62,6 +67,7 @@ public abstract class DataType extends ProjectComponent * @param ref The new Refid value */ public void setRefid( Reference ref ) + throws TaskException { this.ref = ref; checked = false; @@ -87,6 +93,12 @@ public abstract class DataType extends ProjectComponent return ref != null; } + public void execute() + throws TaskException + { + //HACK: NOOP execute - should be deleted in the future! + } + /** * Performs the check for circular references and returns the referenced * object. @@ -96,6 +108,7 @@ public abstract class DataType extends ProjectComponent * @return The CheckedRef value */ protected Object getCheckedRef( Class requiredClass, String dataTypeName ) + throws TaskException { if( !checked ) { @@ -108,7 +121,7 @@ public abstract class DataType extends ProjectComponent if( !( requiredClass.isAssignableFrom( o.getClass() ) ) ) { String msg = ref.getRefId() + " doesn\'t denote a " + dataTypeName; - throw new BuildException( msg ); + throw new TaskException( msg ); } else { @@ -165,7 +178,7 @@ public abstract class DataType extends ProjectComponent else { stk.push( o ); - ( ( DataType )o ).dieOnCircularReference( stk, p ); + ( (DataType)o ).dieOnCircularReference( stk, p ); stk.pop(); } } @@ -192,6 +205,6 @@ public abstract class DataType extends ProjectComponent protected BuildException tooManyAttributes() { return new BuildException( "You must not specify more than one attribute" + - " when using refid" ); + " when using refid" ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java index 5961775ab..3662f329e 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/FileSet.java @@ -6,9 +6,11 @@ * the LICENSE file. */ package org.apache.tools.ant.types; + import java.io.File; import java.util.Stack; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.FileScanner; @@ -69,6 +71,7 @@ public class FileSet extends DataType implements Cloneable * should be used, "false"|"off"|"no" when they shouldn't be used. */ public void setDefaultexcludes( boolean useDefaultExcludes ) + throws TaskException { if( isReference() ) { @@ -96,6 +99,7 @@ public class FileSet extends DataType implements Cloneable * @param excludes the string containing the exclude patterns */ public void setExcludes( String excludes ) + throws TaskException { if( isReference() ) { @@ -129,6 +133,7 @@ public class FileSet extends DataType implements Cloneable * @param includes the string containing the include patterns */ public void setIncludes( String includes ) + throws TaskException { if( isReference() ) { @@ -155,7 +160,6 @@ public class FileSet extends DataType implements Cloneable defaultPatterns.setIncludesfile( incl ); } - /** * Makes this instance in effect a reference to another PatternSet instance. *
@@ -167,7 +171,7 @@ public class FileSet extends DataType implements Cloneable * @exception BuildException Description of Exception */ public void setRefid( Reference r ) - throws BuildException + throws TaskException { if( dir != null || defaultPatterns.hasPatterns() ) { @@ -192,11 +196,11 @@ public class FileSet extends DataType implements Cloneable for( int i = 0; i < additionalPatterns.size(); i++ ) { Object o = additionalPatterns.elementAt( i ); - defaultPatterns.append( ( PatternSet )o, p ); + defaultPatterns.append( (PatternSet)o, p ); } p.log( "FileSet: Setup file scanner in dir " + dir + - " with " + defaultPatterns, p.MSG_DEBUG ); + " with " + defaultPatterns, p.MSG_DEBUG ); ds.setIncludes( defaultPatterns.getIncludePatterns( p ) ); ds.setExcludes( defaultPatterns.getExcludePatterns( p ) ); @@ -206,6 +210,7 @@ public class FileSet extends DataType implements Cloneable } public File getDir( Project p ) + throws TaskException { if( isReference() ) { @@ -221,6 +226,7 @@ public class FileSet extends DataType implements Cloneable * @return The DirectoryScanner value */ public DirectoryScanner getDirectoryScanner( Project p ) + throws TaskException { if( isReference() ) { @@ -229,16 +235,16 @@ public class FileSet extends DataType implements Cloneable if( dir == null ) { - throw new BuildException( "No directory specified for fileset." ); + throw new TaskException( "No directory specified for fileset." ); } if( !dir.exists() ) { - throw new BuildException( dir.getAbsolutePath() + " not found." ); + throw new TaskException( dir.getAbsolutePath() + " not found." ); } if( !dir.isDirectory() ) { - throw new BuildException( dir.getAbsolutePath() + " is not a directory." ); + throw new TaskException( dir.getAbsolutePath() + " is not a directory." ); } DirectoryScanner ds = new DirectoryScanner(); @@ -255,13 +261,19 @@ public class FileSet extends DataType implements Cloneable */ public Object clone() { - if( isReference() ) + try { - return new FileSet( getRef( getProject() ) ); + if( isReference() ) + { + return new FileSet( getRef( getProject() ) ); + } + else + { + return new FileSet( this ); + } } - else + catch( TaskException e ) { - return new FileSet( this ); } } @@ -271,6 +283,7 @@ public class FileSet extends DataType implements Cloneable * @return Description of the Returned Value */ public PatternSet.NameEntry createExclude() + throws TaskException { if( isReference() ) { @@ -285,6 +298,7 @@ public class FileSet extends DataType implements Cloneable * @return Description of the Returned Value */ public PatternSet.NameEntry createExcludesFile() + throws TaskException { if( isReference() ) { @@ -299,6 +313,7 @@ public class FileSet extends DataType implements Cloneable * @return Description of the Returned Value */ public PatternSet.NameEntry createInclude() + throws TaskException { if( isReference() ) { @@ -313,6 +328,7 @@ public class FileSet extends DataType implements Cloneable * @return Description of the Returned Value */ public PatternSet.NameEntry createIncludesFile() + throws TaskException { if( isReference() ) { @@ -322,6 +338,7 @@ public class FileSet extends DataType implements Cloneable } public PatternSet createPatternSet() + throws TaskException { if( isReference() ) { @@ -340,6 +357,7 @@ public class FileSet extends DataType implements Cloneable * @return The Ref value */ protected FileSet getRef( Project p ) + throws TaskException { if( !checked ) { @@ -352,11 +370,11 @@ public class FileSet extends DataType implements Cloneable if( !( o instanceof FileSet ) ) { String msg = ref.getRefId() + " doesn\'t denote a fileset"; - throw new BuildException( msg ); + throw new TaskException( msg ); } else { - return ( FileSet )o; + return (FileSet)o; } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSet.java index 927114f4a..5e4a6bb48 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSet.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSet.java @@ -6,17 +6,18 @@ * the LICENSE file. */ package org.apache.tools.ant.types;// java io classes + import java.io.File; import java.io.FileInputStream; -import java.io.IOException;// java util classes +import java.io.IOException; import java.util.Enumeration; import java.util.Hashtable; import java.util.Properties; -import java.util.Vector;// ant classes +import java.util.Vector; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; - /** * A set of filters to be applied to something. A filter set may have begintoken * and endtokens defined. @@ -45,7 +46,9 @@ public class FilterSet extends DataType implements Cloneable */ private Vector filters = new Vector(); - public FilterSet() { } + public FilterSet() + { + } /** * Create a Filterset from another filterset @@ -53,9 +56,10 @@ public class FilterSet extends DataType implements Cloneable * @param filterset the filterset upon which this filterset will be based. */ protected FilterSet( FilterSet filterset ) + throws TaskException { super(); - this.filters = ( Vector )filterset.getFilters().clone(); + this.filters = (Vector)filterset.getFilters().clone(); } /** @@ -64,6 +68,7 @@ public class FilterSet extends DataType implements Cloneable * @param startOfToken The new Begintoken value */ public void setBeginToken( String startOfToken ) + throws TaskException { if( isReference() ) { @@ -71,18 +76,18 @@ public class FilterSet extends DataType implements Cloneable } if( startOfToken == null || "".equals( startOfToken ) ) { - throw new BuildException( "beginToken must not be empty" ); + throw new TaskException( "beginToken must not be empty" ); } this.startOfToken = startOfToken; } - /** * The string used to id the end of a token. * * @param endOfToken The new Endtoken value */ public void setEndToken( String endOfToken ) + throws TaskException { if( isReference() ) { @@ -90,7 +95,7 @@ public class FilterSet extends DataType implements Cloneable } if( endOfToken == null || "".equals( endOfToken ) ) { - throw new BuildException( "endToken must not be empty" ); + throw new TaskException( "endToken must not be empty" ); } this.endOfToken = endOfToken; } @@ -113,6 +118,7 @@ public class FilterSet extends DataType implements Cloneable } public String getBeginToken() + throws TaskException { if( isReference() ) { @@ -122,6 +128,7 @@ public class FilterSet extends DataType implements Cloneable } public String getEndToken() + throws TaskException { if( isReference() ) { @@ -136,12 +143,13 @@ public class FilterSet extends DataType implements Cloneable * @return The hash of the tokens and values for quick lookup. */ public Hashtable getFilterHash() + throws TaskException { int filterSize = getFilters().size(); Hashtable filterHash = new Hashtable( filterSize ); - for( Enumeration e = getFilters().elements(); e.hasMoreElements(); ) + for( Enumeration e = getFilters().elements(); e.hasMoreElements(); ) { - Filter filter = ( Filter )e.nextElement(); + Filter filter = (Filter)e.nextElement(); filterHash.put( filter.getToken(), filter.getValue() ); } return filterHash; @@ -153,6 +161,7 @@ public class FilterSet extends DataType implements Cloneable * @param filter The feature to be added to the Filter attribute */ public void addFilter( Filter filter ) + throws TaskException { if( isReference() ) { @@ -168,6 +177,7 @@ public class FilterSet extends DataType implements Cloneable * @param value The value for the new filter. */ public void addFilter( String token, String value ) + throws TaskException { if( isReference() ) { @@ -182,27 +192,34 @@ public class FilterSet extends DataType implements Cloneable * @param filterSet the filterset to be added to this filterset */ public void addFilterSet( FilterSet filterSet ) + throws TaskException { if( isReference() ) { throw noChildrenAllowed(); } - for( Enumeration e = filterSet.getFilters().elements(); e.hasMoreElements(); ) + for( Enumeration e = filterSet.getFilters().elements(); e.hasMoreElements(); ) { - filters.addElement( ( Filter )e.nextElement() ); + filters.addElement( (Filter)e.nextElement() ); } } public Object clone() - throws BuildException { - if( isReference() ) + try { - return new FilterSet( getRef() ); + if( isReference() ) + { + return new FilterSet( getRef() ); + } + else + { + return new FilterSet( this ); + } } - else + catch( final TaskException te ) { - return new FilterSet( this ); + throw new RuntimeException( te.toString() ); } } @@ -212,6 +229,7 @@ public class FilterSet extends DataType implements Cloneable * @return The filter that was created. */ public FiltersFile createFiltersfile() + throws TaskException { if( isReference() ) { @@ -226,11 +244,11 @@ public class FilterSet extends DataType implements Cloneable * @return Return true if there are filter in this set otherwise false. */ public boolean hasFilters() + throws TaskException { return getFilters().size() > 0; } - /** * Read the filters from the given file. * @@ -260,7 +278,7 @@ public class FilterSet extends DataType implements Cloneable Vector filters = getFilters(); while( enum.hasMoreElements() ) { - String strPropName = ( String )enum.nextElement(); + String strPropName = (String)enum.nextElement(); String strValue = props.getProperty( strPropName ); filters.addElement( new Filter( strPropName, strValue ) ); } @@ -297,6 +315,7 @@ public class FilterSet extends DataType implements Cloneable * @return The string with the tokens replaced. */ public String replaceTokens( String line ) + throws TaskException { String beginToken = getBeginToken(); String endToken = getEndToken(); @@ -323,7 +342,7 @@ public class FilterSet extends DataType implements Cloneable b.append( line.substring( i, index ) ); if( tokens.containsKey( token ) ) { - value = ( String )tokens.get( token ); + value = (String)tokens.get( token ); log( "Replacing: " + beginToken + token + endToken + " -> " + value, Project.MSG_VERBOSE ); b.append( value ); i = index + beginToken.length() + token.length() + endToken.length(); @@ -334,7 +353,7 @@ public class FilterSet extends DataType implements Cloneable b.append( beginToken ); i = index + beginToken.length(); } - }while ( ( index = line.indexOf( beginToken, i ) ) > -1 ); + } while( ( index = line.indexOf( beginToken, i ) ) > -1 ); b.append( line.substring( i ) ); return b.toString(); @@ -351,6 +370,7 @@ public class FilterSet extends DataType implements Cloneable } protected Vector getFilters() + throws TaskException { if( isReference() ) { @@ -360,8 +380,9 @@ public class FilterSet extends DataType implements Cloneable } protected FilterSet getRef() + throws TaskException { - return ( FilterSet )getCheckedRef( FilterSet.class, "filterset" ); + return (FilterSet)getCheckedRef( FilterSet.class, "filterset" ); } /** @@ -397,7 +418,9 @@ public class FilterSet extends DataType implements Cloneable /** * No argument conmstructor */ - public Filter() { } + public Filter() + { + } /** * Sets the Token attribute of the Filter object @@ -452,7 +475,9 @@ public class FilterSet extends DataType implements Cloneable /** * Constructor for the Filter object */ - public FiltersFile() { } + public FiltersFile() + { + } /** * Sets the file from which filters will be read. @@ -460,6 +485,7 @@ public class FilterSet extends DataType implements Cloneable * @param file the file from which filters will be read. */ public void setFile( File file ) + throws TaskException { readFiltersFromFile( file ); } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSetCollection.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSetCollection.java index 9bc5162a9..a83bff596 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSetCollection.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/FilterSetCollection.java @@ -6,14 +6,15 @@ * the LICENSE file. */ package org.apache.tools.ant.types;// java io classes + // java util classes + import java.util.Enumeration; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; // ant classes - - /** * A FilterSetCollection is a collection of filtersets each of which may have a * different start/end token settings. @@ -25,14 +26,15 @@ public class FilterSetCollection private Vector filterSets = new Vector(); - public FilterSetCollection() { } + public FilterSetCollection() + { + } public FilterSetCollection( FilterSet filterSet ) { addFilterSet( filterSet ); } - public void addFilterSet( FilterSet filterSet ) { filterSets.addElement( filterSet ); @@ -44,10 +46,11 @@ public class FilterSetCollection * @return Return true if there are filter in this set otherwise false. */ public boolean hasFilters() + throws TaskException { - for( Enumeration e = filterSets.elements(); e.hasMoreElements(); ) + for( Enumeration e = filterSets.elements(); e.hasMoreElements(); ) { - FilterSet filterSet = ( FilterSet )e.nextElement(); + FilterSet filterSet = (FilterSet)e.nextElement(); if( filterSet.hasFilters() ) { return true; @@ -64,11 +67,12 @@ public class FilterSetCollection * @return The string with the tokens replaced. */ public String replaceTokens( String line ) + throws TaskException { String replacedLine = line; - for( Enumeration e = filterSets.elements(); e.hasMoreElements(); ) + for( Enumeration e = filterSets.elements(); e.hasMoreElements(); ) { - FilterSet filterSet = ( FilterSet )e.nextElement(); + FilterSet filterSet = (FilterSet)e.nextElement(); replacedLine = filterSet.replaceTokens( replacedLine ); } return replacedLine; diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/Mapper.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/Mapper.java index b0df6dc91..33e628dfe 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/Mapper.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/Mapper.java @@ -201,7 +201,7 @@ public class Mapper extends DataType implements Cloneable } catch( Throwable t ) { - throw new BuildException( t ); + throw new BuildException( "Error", t ); } finally { diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java index 729dd96ae..94dbee1ac 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java @@ -6,16 +6,18 @@ * the LICENSE file. */ package org.apache.tools.ant.types; + import java.io.File; import java.util.Enumeration; import java.util.Locale; import java.util.Stack; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.PathTokenizer; import org.apache.tools.ant.Project; - +import org.apache.tools.ant.util.FileUtils; /** * This object represents a path as used by CLASSPATH or PATH environment @@ -49,14 +51,26 @@ import org.apache.tools.ant.Project; * @author Stefan Bodewig */ -public class Path extends DataType implements Cloneable +public class Path + extends DataType + implements Cloneable { - - public static Path systemClasspath = - new Path( null, System.getProperty( "java.class.path" ) ); + public final static Path systemClasspath = createSystemClasspath(); private Vector elements; + private static Path createSystemClasspath() + { + try + { + return new Path( null, System.getProperty( "java.class.path" ) ); + } + catch( final TaskException te ) + { + throw new Error( te.toString() ); + } + } + /** * Invoked by IntrospectionHelper for
setXXX(Path p)
attribute * setters. @@ -65,6 +79,7 @@ public class Path extends DataType implements Cloneable * @param path Description of Parameter */ public Path( Project p, String path ) + throws TaskException { this( p ); createPathElement().setPath( path ); @@ -108,7 +123,7 @@ public class Path extends DataType implements Cloneable { final Vector result = new Vector(); if( source == null ) - return new String[0]; + return new String[ 0 ]; PathTokenizer tok = new PathTokenizer( source ); StringBuffer element = new StringBuffer(); @@ -120,10 +135,10 @@ public class Path extends DataType implements Cloneable { element.append( resolveFile( project, pathElement ) ); } - catch( BuildException e ) + catch( TaskException e ) { project.log( "Dropping path element " + pathElement + " as it is not valid relative to the project", - Project.MSG_VERBOSE ); + Project.MSG_VERBOSE ); } for( int i = 0; i < element.length(); i++ ) { @@ -131,7 +146,7 @@ public class Path extends DataType implements Cloneable } result.addElement( element.toString() ); } - String[] res = new String[result.size()]; + String[] res = new String[ result.size() ]; result.copyInto( res ); return res; } @@ -181,7 +196,8 @@ public class Path extends DataType implements Cloneable { if( project != null ) { - File f = project.resolveFile( relativeName ); + File f = FileUtils.newFileUtils(). + resolveFile( project.getBaseDir(), relativeName ); return f.getAbsolutePath(); } return relativeName; @@ -204,7 +220,6 @@ public class Path extends DataType implements Cloneable createPathElement().setLocation( location ); } - /** * Parses a path definition and creates single PathElements. * @@ -231,7 +246,7 @@ public class Path extends DataType implements Cloneable * @exception BuildException Description of Exception */ public void setRefid( Reference r ) - throws BuildException + throws TaskException { if( !elements.isEmpty() ) { @@ -248,6 +263,7 @@ public class Path extends DataType implements Cloneable * @param source - source path whose components are examined for existence */ public void addExisting( Path source ) + throws TaskException { String[] list = source.list(); for( int i = 0; i < list.length; i++ ) @@ -255,11 +271,11 @@ public class Path extends DataType implements Cloneable File f = null; if( getProject() != null ) { - f = getProject().resolveFile( list[i] ); + f = resolveFile( list[ i ] ); } else { - f = new File( list[i] ); + f = new File( list[ i ] ); } if( f.exists() ) @@ -277,6 +293,7 @@ public class Path extends DataType implements Cloneable * @param extdirs The feature to be added to the Extdirs attribute */ public void addExtdirs( Path extdirs ) + throws TaskException { if( extdirs == null ) { @@ -294,7 +311,7 @@ public class Path extends DataType implements Cloneable String[] dirs = extdirs.list(); for( int i = 0; i < dirs.length; i++ ) { - File dir = getProject().resolveFile( dirs[i] ); + File dir = resolveFile( dirs[ i ] ); if( dir.exists() && dir.isDirectory() ) { FileSet fs = new FileSet(); @@ -312,7 +329,7 @@ public class Path extends DataType implements Cloneable * @exception BuildException Description of Exception */ public void addFileset( FileSet fs ) - throws BuildException + throws TaskException { if( isReference() ) { @@ -326,6 +343,7 @@ public class Path extends DataType implements Cloneable * Add the Java Runtime classes to this Path instance. */ public void addJavaRuntime() + throws TaskException { if( System.getProperty( "java.vendor" ).toLowerCase( Locale.US ).indexOf( "microsoft" ) >= 0 ) { @@ -339,8 +357,8 @@ public class Path extends DataType implements Cloneable { FileSet kaffeJarFiles = new FileSet(); kaffeJarFiles.setDir( new File( System.getProperty( "java.home" ) - + File.separator + "share" - + File.separator + "kaffe" ) ); + + File.separator + "share" + + File.separator + "kaffe" ) ); kaffeJarFiles.setIncludes( "*.jar" ); addFileset( kaffeJarFiles ); @@ -348,37 +366,37 @@ public class Path extends DataType implements Cloneable else if( Project.getJavaVersion() == Project.JAVA_1_1 ) { addExisting( new Path( null, - System.getProperty( "java.home" ) - + File.separator + "lib" - + File.separator - + "classes.zip" ) ); + System.getProperty( "java.home" ) + + File.separator + "lib" + + File.separator + + "classes.zip" ) ); } else { // JDK > 1.1 seems to set java.home to the JRE directory. addExisting( new Path( null, - System.getProperty( "java.home" ) - + File.separator + "lib" - + File.separator + "rt.jar" ) ); + System.getProperty( "java.home" ) + + File.separator + "lib" + + File.separator + "rt.jar" ) ); // Just keep the old version as well and let addExisting // sort it out. addExisting( new Path( null, - System.getProperty( "java.home" ) - + File.separator + "jre" - + File.separator + "lib" - + File.separator + "rt.jar" ) ); + System.getProperty( "java.home" ) + + File.separator + "jre" + + File.separator + "lib" + + File.separator + "rt.jar" ) ); // Added for MacOS X addExisting( new Path( null, - System.getProperty( "java.home" ) - + File.separator + ".." - + File.separator + "Classes" - + File.separator + "classes.jar" ) ); + System.getProperty( "java.home" ) + + File.separator + ".." + + File.separator + "Classes" + + File.separator + "classes.jar" ) ); addExisting( new Path( null, - System.getProperty( "java.home" ) - + File.separator + ".." - + File.separator + "Classes" - + File.separator + "ui.jar" ) ); + System.getProperty( "java.home" ) + + File.separator + ".." + + File.separator + "Classes" + + File.separator + "ui.jar" ) ); } } @@ -388,15 +406,16 @@ public class Path extends DataType implements Cloneable * @param other Description of Parameter */ public void append( Path other ) + throws TaskException { if( other == null ) return; String[] l = other.list(); for( int i = 0; i < l.length; i++ ) { - if( elements.indexOf( l[i] ) == -1 ) + if( elements.indexOf( l[ i ] ) == -1 ) { - elements.addElement( l[i] ); + elements.addElement( l[ i ] ); } } } @@ -433,8 +452,8 @@ public class Path extends DataType implements Cloneable * @return Description of the Returned Value */ public Path concatSystemClasspath( String defValue ) + throws TaskException { - Path result = new Path( getProject() ); String order = defValue; @@ -472,7 +491,7 @@ public class Path extends DataType implements Cloneable if( !order.equals( "last" ) ) { log( "invalid value for build.sysclasspath: " + order, - Project.MSG_WARN ); + Project.MSG_WARN ); } result.addExisting( this ); @@ -525,6 +544,7 @@ public class Path extends DataType implements Cloneable * @return list of path elements. */ public String[] list() + throws TaskException { if( !checked ) { @@ -540,36 +560,36 @@ public class Path extends DataType implements Cloneable Object o = elements.elementAt( i ); if( o instanceof Reference ) { - Reference r = ( Reference )o; + Reference r = (Reference)o; o = r.getReferencedObject( getProject() ); // we only support references to paths right now if( !( o instanceof Path ) ) { String msg = r.getRefId() + " doesn\'t denote a path"; - throw new BuildException( msg ); + throw new TaskException( msg ); } } if( o instanceof String ) { // obtained via append - addUnlessPresent( result, ( String )o ); + addUnlessPresent( result, (String)o ); } else if( o instanceof PathElement ) { - String[] parts = ( ( PathElement )o ).getParts(); + String[] parts = ( (PathElement)o ).getParts(); if( parts == null ) { - throw new BuildException( "You must either set location or path on" ); + throw new TaskException( "You must either set location or path on " ); } for( int j = 0; j < parts.length; j++ ) { - addUnlessPresent( result, parts[j] ); + addUnlessPresent( result, parts[ j ] ); } } else if( o instanceof Path ) { - Path p = ( Path )o; + Path p = (Path)o; if( p.getProject() == null ) { p.setProject( getProject() ); @@ -577,24 +597,24 @@ public class Path extends DataType implements Cloneable String[] parts = p.list(); for( int j = 0; j < parts.length; j++ ) { - addUnlessPresent( result, parts[j] ); + addUnlessPresent( result, parts[ j ] ); } } else if( o instanceof FileSet ) { - FileSet fs = ( FileSet )o; + FileSet fs = (FileSet)o; DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); String[] s = ds.getIncludedFiles(); File dir = fs.getDir( getProject() ); for( int j = 0; j < s.length; j++ ) { - File f = new File( dir, s[j] ); + File f = new File( dir, s[ j ] ); String absolutePath = f.getAbsolutePath(); addUnlessPresent( result, translateFile( absolutePath ) ); } } } - String[] res = new String[result.size()]; + String[] res = new String[ result.size() ]; result.copyInto( res ); return res; } @@ -605,11 +625,11 @@ public class Path extends DataType implements Cloneable * @return Description of the Returned Value */ public int size() + throws TaskException { return list().length; } - /** * Returns a textual representation of the path, which can be used as * CLASSPATH or PATH environment variable definition. @@ -618,21 +638,28 @@ public class Path extends DataType implements Cloneable */ public String toString() { - final String[] list = list(); + try + { + final String[] list = list(); - // empty path return empty string - if( list.length == 0 ) - return ""; + // empty path return empty string + if( list.length == 0 ) + return ""; + + // path containing one or more elements + final StringBuffer result = new StringBuffer( list[ 0 ].toString() ); + for( int i = 1; i < list.length; i++ ) + { + result.append( File.pathSeparatorChar ); + result.append( list[ i ] ); + } - // path containing one or more elements - final StringBuffer result = new StringBuffer( list[0].toString() ); - for( int i = 1; i < list.length; i++ ) + return result.toString(); + } + catch( final TaskException te ) { - result.append( File.pathSeparatorChar ); - result.append( list[i] ); + throw new Error( te.toString() ); } - - return result.toString(); } /** @@ -658,7 +685,7 @@ public class Path extends DataType implements Cloneable Object o = enum.nextElement(); if( o instanceof Reference ) { - o = ( ( Reference )o ).getReferencedObject( p ); + o = ( (Reference)o ).getReferencedObject( p ); } if( o instanceof DataType ) @@ -670,7 +697,7 @@ public class Path extends DataType implements Cloneable else { stk.push( o ); - ( ( DataType )o ).dieOnCircularReference( stk, p ); + ( (DataType)o ).dieOnCircularReference( stk, p ); stk.pop(); } } @@ -678,7 +705,6 @@ public class Path extends DataType implements Cloneable checked = true; } - /** * Helper class, holds the nested <pathelement>
values. * diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java index b4200922f..015c78890 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/types/PatternSet.java @@ -367,7 +367,7 @@ public class PatternSet extends DataType String fileName = ne.evalName( p ); if( fileName != null ) { - File inclFile = p.resolveFile( fileName ); + File inclFile = resolveFile( fileName ); if( !inclFile.exists() ) throw new BuildException( "Includesfile " + inclFile.getAbsolutePath() @@ -387,7 +387,7 @@ public class PatternSet extends DataType String fileName = ne.evalName( p ); if( fileName != null ) { - File exclFile = p.resolveFile( fileName ); + File exclFile = resolveFile( fileName ); if( !exclFile.exists() ) throw new BuildException( "Excludesfile " + exclFile.getAbsolutePath() diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java b/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java index a27ab6f63..75d33d52a 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant.util; + import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -16,13 +17,12 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; -import java.io.InputStream; import java.lang.reflect.Method; import java.text.DecimalFormat; import java.util.Random; import java.util.Stack; import java.util.StringTokenizer; -import org.apache.tools.ant.BuildException; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.FilterSetCollection; @@ -46,7 +46,9 @@ public class FileUtils /** * Empty constructor. */ - protected FileUtils() { } + protected FileUtils() + { + } /** * Factory method. @@ -66,20 +68,20 @@ public class FileUtils * @exception BuildException Description of Exception */ public void setFileLastModified( File file, long time ) - throws BuildException + throws TaskException { if( Project.getJavaVersion() == Project.JAVA_1_1 ) { return; } - Long[] times = new Long[1]; + Long[] times = new Long[ 1 ]; if( time < 0 ) { - times[0] = new Long( System.currentTimeMillis() ); + times[ 0 ] = new Long( System.currentTimeMillis() ); } else { - times[0] = new Long( time ); + times[ 0 ] = new Long( time ); } try @@ -89,13 +91,13 @@ public class FileUtils catch( java.lang.reflect.InvocationTargetException ite ) { Throwable nested = ite.getTargetException(); - throw new BuildException( "Exception setting the modification time " - + "of " + file, nested ); + throw new TaskException( "Exception setting the modification time " + + "of " + file, nested ); } catch( Throwable other ) { - throw new BuildException( "Exception setting the modification time " - + "of " + file, other ); + throw new TaskException( "Exception setting the modification time " + + "of " + file, other ); } } @@ -179,7 +181,8 @@ public class FileUtils in1.close(); } catch( IOException e ) - {} + { + } } if( in2 != null ) { @@ -188,7 +191,8 @@ public class FileUtils in2.close(); } catch( IOException e ) - {} + { + } } } } @@ -202,7 +206,7 @@ public class FileUtils * @throws IOException */ public void copyFile( String sourceFile, String destFile ) - throws IOException + throws IOException, TaskException { copyFile( new File( sourceFile ), new File( destFile ), null, false, false ); } @@ -217,7 +221,7 @@ public class FileUtils * @throws IOException */ public void copyFile( String sourceFile, String destFile, FilterSetCollection filters ) - throws IOException + throws IOException, TaskException { copyFile( new File( sourceFile ), new File( destFile ), filters, false, false ); } @@ -235,10 +239,10 @@ public class FileUtils */ public void copyFile( String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite ) - throws IOException + throws IOException, TaskException { copyFile( new File( sourceFile ), new File( destFile ), filters, - overwrite, false ); + overwrite, false ); } /** @@ -257,10 +261,10 @@ public class FileUtils */ public void copyFile( String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified ) - throws IOException + throws IOException, TaskException { copyFile( new File( sourceFile ), new File( destFile ), filters, - overwrite, preserveLastModified ); + overwrite, preserveLastModified ); } /** @@ -272,7 +276,7 @@ public class FileUtils * @throws IOException */ public void copyFile( File sourceFile, File destFile ) - throws IOException + throws IOException, TaskException { copyFile( sourceFile, destFile, null, false, false ); } @@ -287,7 +291,7 @@ public class FileUtils * @throws IOException */ public void copyFile( File sourceFile, File destFile, FilterSetCollection filters ) - throws IOException + throws IOException, TaskException { copyFile( sourceFile, destFile, filters, false, false ); } @@ -305,7 +309,7 @@ public class FileUtils */ public void copyFile( File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite ) - throws IOException + throws IOException, TaskException { copyFile( sourceFile, destFile, filters, overwrite, false ); } @@ -326,7 +330,7 @@ public class FileUtils */ public void copyFile( File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified ) - throws IOException + throws IOException, TaskException { if( overwrite || !destFile.exists() || @@ -377,13 +381,13 @@ public class FileUtils FileInputStream in = new FileInputStream( sourceFile ); FileOutputStream out = new FileOutputStream( destFile ); - byte[] buffer = new byte[8 * 1024]; + byte[] buffer = new byte[ 8 * 1024 ]; int count = 0; do { out.write( buffer, 0, count ); count = in.read( buffer, 0, buffer.length ); - }while ( count != -1 ); + } while( count != -1 ); in.close(); out.close(); @@ -429,9 +433,9 @@ public class FileUtils do { result = new File( parent, - prefix + fmt.format( rand.nextInt() ) - + suffix ); - }while ( result.exists() ); + prefix + fmt.format( rand.nextInt() ) + + suffix ); + } while( result.exists() ); } return result; } @@ -454,6 +458,7 @@ public class FileUtils * @throws java.lang.NullPointerException if the file path is equal to null. */ public File normalize( String path ) + throws TaskException { String orig = path; @@ -465,10 +470,10 @@ public class FileUtils !( path.length() >= 2 && Character.isLetter( path.charAt( 0 ) ) && path.charAt( 1 ) == ':' ) - ) + ) { String msg = path + " is not an absolute path"; - throw new BuildException( msg ); + throw new TaskException( msg ); } boolean dosWithDrive = false; @@ -483,15 +488,15 @@ public class FileUtils char[] ca = path.replace( '/', '\\' ).toCharArray(); StringBuffer sb = new StringBuffer(); - sb.append( Character.toUpperCase( ca[0] ) ).append( ':' ); + sb.append( Character.toUpperCase( ca[ 0 ] ) ).append( ':' ); for( int i = 2; i < ca.length; i++ ) { - if( ( ca[i] != '\\' ) || - ( ca[i] == '\\' && ca[i - 1] != '\\' ) - ) + if( ( ca[ i ] != '\\' ) || + ( ca[ i ] == '\\' && ca[ i - 1 ] != '\\' ) + ) { - sb.append( ca[i] ); + sb.append( ca[ i ] ); } } @@ -542,7 +547,7 @@ public class FileUtils { if( s.size() < 2 ) { - throw new BuildException( "Cannot resolve path " + orig ); + throw new TaskException( "Cannot resolve path " + orig ); } else { @@ -589,6 +594,7 @@ public class FileUtils * current platform. */ public File resolveFile( File file, String filename ) + throws TaskException { filename = filename.replace( '/', File.separatorChar ) .replace( '\\', File.separatorChar ); @@ -598,7 +604,7 @@ public class FileUtils ( filename.length() >= 2 && Character.isLetter( filename.charAt( 0 ) ) && filename.charAt( 1 ) == ':' ) - ) + ) { return normalize( filename ); } @@ -619,9 +625,9 @@ public class FileUtils if( helpFile == null ) { String msg = "The file or path you specified (" - + filename + ") is invalid relative to " - + file.getPath(); - throw new BuildException( msg ); + + filename + ") is invalid relative to " + + file.getPath(); + throw new TaskException( msg ); } } else if( part.equals( "." ) ) @@ -643,6 +649,7 @@ public class FileUtils * @return The SetLastModified value */ protected final Method getSetLastModified() + throws TaskException { if( Project.getJavaVersion() == Project.JAVA_1_1 ) { @@ -658,12 +665,12 @@ public class FileUtils { setLastModified = java.io.File.class.getMethod( "setLastModified", - new Class[]{Long.TYPE} ); + new Class[]{Long.TYPE} ); } catch( NoSuchMethodException nse ) { - throw new BuildException( "File.setlastModified not in JDK > 1.1?", - nse ); + throw new TaskException( "File.setlastModified not in JDK > 1.1?", + nse ); } } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java b/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java index 1421fb167..1c6d57994 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java @@ -138,7 +138,7 @@ public class JakartaOroMatcher implements RegexpMatcher } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java b/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java index 7c486420e..a58796880 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java @@ -122,7 +122,7 @@ public class Jdk14RegexpMatcher implements RegexpMatcher } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java b/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java index ae7b5331a..5620b9b70 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java @@ -97,7 +97,7 @@ public class RegexpMatcherFactory } catch( Throwable t ) { - throw new BuildException( t ); + throw new BuildException( "Error", t ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/AntClassLoader.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/AntClassLoader.java index d2ef10528..e7a1ef558 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/AntClassLoader.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/AntClassLoader.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -20,7 +21,9 @@ import java.util.Hashtable; import java.util.Vector; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.util.FileUtils; /** * Used to load classes within ant with a different claspath from that used to @@ -97,24 +100,25 @@ public class AntClassLoader extends ClassLoader implements BuildListener * The project to which this class loader belongs. */ private Project project; + static { try { - getProtectionDomain = Class.class.getMethod( "getProtectionDomain", new Class[0] ); + getProtectionDomain = Class.class.getMethod( "getProtectionDomain", new Class[ 0 ] ); Class protectionDomain = Class.forName( "java.security.ProtectionDomain" ); Class[] args = new Class[]{String.class, byte[].class, Integer.TYPE, Integer.TYPE, protectionDomain}; defineClassProtectionDomain = ClassLoader.class.getDeclaredMethod( "defineClass", args ); - getContextClassLoader = Thread.class.getMethod( "getContextClassLoader", new Class[0] ); + getContextClassLoader = Thread.class.getMethod( "getContextClassLoader", new Class[ 0 ] ); args = new Class[]{ClassLoader.class}; setContextClassLoader = Thread.class.getMethod( "setContextClassLoader", args ); } catch( Exception e ) - {} + { + } } - /** * Create a classloader for the given project using the classpath given. * @@ -136,7 +140,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { try { - addPathElement( ( String )pathElements[i] ); + addPathElement( (String)pathElements[ i ] ); } catch( BuildException e ) { @@ -169,7 +173,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener addSystemPackageRoot( "javax" ); } - /** * Create a classloader for the given project using the classpath given. * @@ -243,17 +246,18 @@ public class AntClassLoader extends ClassLoader implements BuildListener * current loader value for later resetting */ public void setThreadContextLoader() + throws TaskException { if( isContextLoaderSaved ) { - throw new BuildException( "Context loader has not been reset" ); + throw new TaskException( "Context loader has not been reset" ); } if( getContextClassLoader != null && setContextClassLoader != null ) { try { savedContextLoader - = ( ClassLoader )getContextClassLoader.invoke( Thread.currentThread(), new Object[0] ); + = (ClassLoader)getContextClassLoader.invoke( Thread.currentThread(), new Object[ 0 ] ); Object[] args = new Object[]{this}; setContextClassLoader.invoke( Thread.currentThread(), args ); isContextLoaderSaved = true; @@ -261,11 +265,11 @@ public class AntClassLoader extends ClassLoader implements BuildListener catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); - throw new BuildException( t.toString() ); + throw new TaskException( t.toString() ); } catch( Exception e ) { - throw new BuildException( e.toString() ); + throw new TaskException( e.toString() ); } } } @@ -293,22 +297,22 @@ public class AntClassLoader extends ClassLoader implements BuildListener if( url != null ) { log( "Resource " + name + " loaded from parent loader", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } else { // try and load from this loader if the parent either didn't find // it or wasn't consulted. - for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && url == null; ) + for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && url == null; ) { - File pathComponent = ( File )e.nextElement(); + File pathComponent = (File)e.nextElement(); url = getResourceURL( pathComponent, name ); if( url != null ) { log( "Resource " + name + " loaded from ant loader", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } } } @@ -321,7 +325,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener if( url != null ) { log( "Resource " + name + " loaded from parent loader", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } } @@ -386,7 +390,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener if( resourceStream == null ) { log( "Couldn't load ResourceStream for " + name, - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } return resourceStream; @@ -403,7 +407,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener loaderPackages.addElement( packageRoot + "." ); } - /** * Add an element to the classpath to be searched * @@ -414,8 +417,8 @@ public class AntClassLoader extends ClassLoader implements BuildListener throws BuildException { File pathComponent - = project != null ? project.resolveFile( pathElement ) - : new File( pathElement ); + = project != null ? FileUtils.newFileUtils().resolveFile( project.getBaseDir(), pathElement ) + : new File( pathElement ); pathComponents.addElement( pathComponent ); } @@ -435,15 +438,17 @@ public class AntClassLoader extends ClassLoader implements BuildListener cleanup(); } - public void buildStarted( BuildEvent event ) { } + public void buildStarted( BuildEvent event ) + { + } public void cleanup() { pathComponents = null; project = null; - for( Enumeration e = zipFiles.elements(); e.hasMoreElements(); ) + for( Enumeration e = zipFiles.elements(); e.hasMoreElements(); ) { - ZipFile zipFile = ( ZipFile )e.nextElement(); + ZipFile zipFile = (ZipFile)e.nextElement(); try { zipFile.close(); @@ -472,7 +477,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener return findClassInComponents( name ); } - /** * Load a class through this class loader even if that class is available on * the parent classpath. This ensures that any classes which are loaded by @@ -524,12 +528,15 @@ public class AntClassLoader extends ClassLoader implements BuildListener return theClass; } - public void messageLogged( BuildEvent event ) { } + public void messageLogged( BuildEvent event ) + { + } /** * Reset the current thread's context loader to its original value */ public void resetThreadContextLoader() + throws TaskException { if( isContextLoaderSaved && getContextClassLoader != null && setContextClassLoader != null ) @@ -544,22 +551,30 @@ public class AntClassLoader extends ClassLoader implements BuildListener catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); - throw new BuildException( t.toString() ); + throw new TaskException( t.toString() ); } catch( Exception e ) { - throw new BuildException( e.toString() ); + throw new TaskException( e.toString() ); } } } - public void targetFinished( BuildEvent event ) { } + public void targetFinished( BuildEvent event ) + { + } - public void targetStarted( BuildEvent event ) { } + public void targetStarted( BuildEvent event ) + { + } - public void taskFinished( BuildEvent event ) { } + public void taskFinished( BuildEvent event ) + { + } - public void taskStarted( BuildEvent event ) { } + public void taskStarted( BuildEvent event ) + { + } /** * Returns an enumeration of URLs representing all the resources with the @@ -575,7 +590,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener return new ResourceEnumeration( name ); } - /** * Load a class with this class loader. This method will load a class. This * class attempts to load the class firstly using the parent class loader. @@ -649,9 +663,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener { project.log( message, priority ); } -// else { -// System.out.println(message); -// } + // else { + // System.out.println(message); + // } } /** @@ -680,7 +694,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int bytesRead = -1; - byte[] buffer = new byte[BUFFER_SIZE]; + byte[] buffer = new byte[ BUFFER_SIZE ]; while( ( bytesRead = stream.read( buffer, 0, BUFFER_SIZE ) ) != -1 ) { @@ -696,20 +710,20 @@ public class AntClassLoader extends ClassLoader implements BuildListener { try { - Object domain = getProtectionDomain.invoke( Project.class, new Object[0] ); + Object domain = getProtectionDomain.invoke( Project.class, new Object[ 0 ] ); Object[] args = new Object[]{classname, classData, new Integer( 0 ), new Integer( classData.length ), domain}; - return ( Class )defineClassProtectionDomain.invoke( this, args ); + return (Class)defineClassProtectionDomain.invoke( this, args ); } catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); if( t instanceof ClassFormatError ) { - throw ( ClassFormatError )t; + throw (ClassFormatError)t; } else if( t instanceof NoClassDefFoundError ) { - throw ( NoClassDefFoundError )t; + throw (NoClassDefFoundError)t; } else { @@ -759,7 +773,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener else { // is the zip file in the cache - ZipFile zipFile = ( ZipFile )zipFiles.get( file ); + ZipFile zipFile = (ZipFile)zipFiles.get( file ); if( zipFile == null ) { zipFile = new ZipFile( file ); @@ -775,7 +789,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener catch( Exception e ) { log( "Ignoring Exception " + e.getClass().getName() + ": " + e.getMessage() + - " reading resource " + resourceName + " from " + file, Project.MSG_VERBOSE ); + " reading resource " + resourceName + " from " + file, Project.MSG_VERBOSE ); } return null; @@ -819,7 +833,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener } else { - ZipFile zipFile = ( ZipFile )zipFiles.get( file ); + ZipFile zipFile = (ZipFile)zipFiles.get( file ); if( zipFile == null ) { zipFile = new ZipFile( file ); @@ -855,9 +869,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener // designated to use a specific loader first (this one or the parent one) boolean useParentFirst = parentFirst; - for( Enumeration e = systemPackages.elements(); e.hasMoreElements(); ) + for( Enumeration e = systemPackages.elements(); e.hasMoreElements(); ) { - String packageName = ( String )e.nextElement(); + String packageName = (String)e.nextElement(); if( resourceName.startsWith( packageName ) ) { useParentFirst = true; @@ -865,9 +879,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener } } - for( Enumeration e = loaderPackages.elements(); e.hasMoreElements(); ) + for( Enumeration e = loaderPackages.elements(); e.hasMoreElements(); ) { - String packageName = ( String )e.nextElement(); + String packageName = (String)e.nextElement(); if( resourceName.startsWith( packageName ) ) { useParentFirst = false; @@ -899,7 +913,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener } } - /** * Find a class on the given classpath. * @@ -916,9 +929,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener String classFilename = getClassFilename( name ); try { - for( Enumeration e = pathComponents.elements(); e.hasMoreElements(); ) + for( Enumeration e = pathComponents.elements(); e.hasMoreElements(); ) { - File pathComponent = ( File )e.nextElement(); + File pathComponent = (File)e.nextElement(); try { stream = getResourceStream( pathComponent, classFilename ); @@ -946,7 +959,8 @@ public class AntClassLoader extends ClassLoader implements BuildListener } } catch( IOException e ) - {} + { + } } } @@ -969,7 +983,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener } } - /** * Get a stream to read the requested resource name from this loader. * @@ -983,9 +996,9 @@ public class AntClassLoader extends ClassLoader implements BuildListener // class we want. InputStream stream = null; - for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && stream == null; ) + for( Enumeration e = pathComponents.elements(); e.hasMoreElements() && stream == null; ) { - File pathComponent = ( File )e.nextElement(); + File pathComponent = (File)e.nextElement(); stream = getResourceStream( pathComponent, name ); } return stream; @@ -1073,11 +1086,11 @@ public class AntClassLoader extends ClassLoader implements BuildListener try { File pathComponent - = ( File )pathComponents.elementAt( pathElementsIndex ); + = (File)pathComponents.elementAt( pathElementsIndex ); url = getResourceURL( pathComponent, this.resourceName ); pathElementsIndex++; } - catch( BuildException e ) + catch( TaskException e ) { // ignore path elements which are not valid relative to the project } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/BuildException.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/BuildException.java index a22ef8933..74304cb93 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/BuildException.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/BuildException.java @@ -44,43 +44,6 @@ public class BuildException super( msg, cause ); } - /** - * Constructs an exception with the given message and exception as a root - * cause and a location in a file. - * - * @param msg Description of or information about the exception. - * @param cause Exception that might have cause this one. - * @param location Location in the project file where the error occured. - */ - public BuildException( String msg, Throwable cause, Location location ) - { - this( msg, cause ); - this.location = location; - } - - /** - * Constructs an exception with the given exception as a root cause. - * - * @param cause Exception that might have caused this one. - */ - public BuildException( Throwable cause ) - { - super( cause.toString(), cause ); - } - - /** - * Constructs an exception with the given descriptive message and a location - * in a file. - * - * @param msg Description of or information about the exception. - * @param location Location in the project file where the error occured. - */ - public BuildException( String msg, Location location ) - { - super( msg ); - this.location = location; - } - /** * Sets the file location where the error occured. * diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/DesirableFilter.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/DesirableFilter.java deleted file mode 100644 index a53315fa2..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/DesirableFilter.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE file. - */ -package org.apache.tools.ant; -import java.io.File; -import java.io.FilenameFilter; - - -/** - * Filters filenames to determine whether or not the file is desirable. - * - * @author Jason Hunter [jhunter@servlets.com] - * @author james@x180.com - */ -public class DesirableFilter implements FilenameFilter -{ - - /** - * Test the given filename to determine whether or not it's desirable. This - * helps tasks filter temp files and files used by CVS. - * - * @param dir Description of Parameter - * @param name Description of Parameter - * @return Description of the Returned Value - */ - - public boolean accept( File dir, String name ) - { - - // emacs save file - if( name.endsWith( "~" ) ) - { - return false; - } - - // emacs autosave file - if( name.startsWith( "#" ) && name.endsWith( "#" ) ) - { - return false; - } - - // openwindows text editor does this I think - if( name.startsWith( "%" ) && name.endsWith( "%" ) ) - { - return false; - } - - /* - * CVS stuff -- hopefully there won't be a case with - * an all cap file/dir named "CVS" that somebody wants - * to keep around... - */ - if( name.equals( "CVS" ) ) - { - return false; - } - - /* - * If we are going to ignore CVS might as well ignore - * this one as well... - */ - if( name.equals( ".cvsignore" ) ) - { - return false; - } - - // CVS merge autosaves. - if( name.startsWith( ".#" ) ) - { - return false; - } - - // SCCS/CSSC/TeamWare: - if( name.equals( "SCCS" ) ) - { - return false; - } - - // Visual Source Save - if( name.equals( "vssver.scc" ) ) - { - return false; - } - - // default - return true; - } -} - - - - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/DirectoryScanner.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/DirectoryScanner.java index 7d95dd304..c16a43057 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/DirectoryScanner.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/DirectoryScanner.java @@ -6,9 +6,11 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.io.File; import java.util.StringTokenizer; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; /** * Class for scanning a directory for files/directories that match a certain @@ -105,7 +107,7 @@ public class DirectoryScanner implements FileScanner "**/SCCS", "**/SCCS/**", "**/vssver.scc" - }; + }; /** * Have the Vectors holding our results been built by a slow scan? @@ -174,8 +176,9 @@ public class DirectoryScanner implements FileScanner /** * Constructor. */ - public DirectoryScanner() { } - + public DirectoryScanner() + { + } /** * Matches a string against a pattern. The pattern contains two special @@ -192,7 +195,6 @@ public class DirectoryScanner implements FileScanner return match( pattern, str, true ); } - /** * Matches a string against a pattern. The pattern contains two special * characters: '*' which means zero or more characters, '?' which means one @@ -217,7 +219,7 @@ public class DirectoryScanner implements FileScanner boolean containsStar = false; for( int i = 0; i < patArr.length; i++ ) { - if( patArr[i] == '*' ) + if( patArr[ i ] == '*' ) { containsStar = true; break; @@ -233,15 +235,15 @@ public class DirectoryScanner implements FileScanner } for( int i = 0; i <= patIdxEnd; i++ ) { - ch = patArr[i]; + ch = patArr[ i ]; if( ch != '?' ) { - if( isCaseSensitive && ch != strArr[i] ) + if( isCaseSensitive && ch != strArr[ i ] ) { return false;// Character mismatch } if( !isCaseSensitive && Character.toUpperCase( ch ) != - Character.toUpperCase( strArr[i] ) ) + Character.toUpperCase( strArr[ i ] ) ) { return false;// Character mismatch } @@ -256,16 +258,16 @@ public class DirectoryScanner implements FileScanner } // Process characters before first star - while( ( ch = patArr[patIdxStart] ) != '*' && strIdxStart <= strIdxEnd ) + while( ( ch = patArr[ patIdxStart ] ) != '*' && strIdxStart <= strIdxEnd ) { if( ch != '?' ) { - if( isCaseSensitive && ch != strArr[strIdxStart] ) + if( isCaseSensitive && ch != strArr[ strIdxStart ] ) { return false;// Character mismatch } if( !isCaseSensitive && Character.toUpperCase( ch ) != - Character.toUpperCase( strArr[strIdxStart] ) ) + Character.toUpperCase( strArr[ strIdxStart ] ) ) { return false;// Character mismatch } @@ -279,7 +281,7 @@ public class DirectoryScanner implements FileScanner // left in the pattern. If so, we succeeded. Otherwise failure. for( int i = patIdxStart; i <= patIdxEnd; i++ ) { - if( patArr[i] != '*' ) + if( patArr[ i ] != '*' ) { return false; } @@ -288,16 +290,16 @@ public class DirectoryScanner implements FileScanner } // Process characters after last star - while( ( ch = patArr[patIdxEnd] ) != '*' && strIdxStart <= strIdxEnd ) + while( ( ch = patArr[ patIdxEnd ] ) != '*' && strIdxStart <= strIdxEnd ) { if( ch != '?' ) { - if( isCaseSensitive && ch != strArr[strIdxEnd] ) + if( isCaseSensitive && ch != strArr[ strIdxEnd ] ) { return false;// Character mismatch } if( !isCaseSensitive && Character.toUpperCase( ch ) != - Character.toUpperCase( strArr[strIdxEnd] ) ) + Character.toUpperCase( strArr[ strIdxEnd ] ) ) { return false;// Character mismatch } @@ -311,7 +313,7 @@ public class DirectoryScanner implements FileScanner // left in the pattern. If so, we succeeded. Otherwise failure. for( int i = patIdxStart; i <= patIdxEnd; i++ ) { - if( patArr[i] != '*' ) + if( patArr[ i ] != '*' ) { return false; } @@ -326,7 +328,7 @@ public class DirectoryScanner implements FileScanner int patIdxTmp = -1; for( int i = patIdxStart + 1; i <= patIdxEnd; i++ ) { - if( patArr[i] == '*' ) + if( patArr[ i ] == '*' ) { patIdxTmp = i; break; @@ -348,15 +350,15 @@ public class DirectoryScanner implements FileScanner { for( int j = 0; j < patLength; j++ ) { - ch = patArr[patIdxStart + j + 1]; + ch = patArr[ patIdxStart + j + 1 ]; if( ch != '?' ) { - if( isCaseSensitive && ch != strArr[strIdxStart + i + j] ) + if( isCaseSensitive && ch != strArr[ strIdxStart + i + j ] ) { continue strLoop; } if( !isCaseSensitive && Character.toUpperCase( ch ) != - Character.toUpperCase( strArr[strIdxStart + i + j] ) ) + Character.toUpperCase( strArr[ strIdxStart + i + j ] ) ) { continue strLoop; } @@ -380,7 +382,7 @@ public class DirectoryScanner implements FileScanner // in the pattern. If so, we succeeded. Otherwise failure. for( int i = patIdxStart; i <= patIdxEnd; i++ ) { - if( patArr[i] != '*' ) + if( patArr[ i ] != '*' ) { return false; } @@ -444,12 +446,12 @@ public class DirectoryScanner implements FileScanner // up to first '**' while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) { - String patDir = ( String )patDirs.elementAt( patIdxStart ); + String patDir = (String)patDirs.elementAt( patIdxStart ); if( patDir.equals( "**" ) ) { break; } - if( !match( patDir, ( String )strDirs.elementAt( strIdxStart ), isCaseSensitive ) ) + if( !match( patDir, (String)strDirs.elementAt( strIdxStart ), isCaseSensitive ) ) { return false; } @@ -480,12 +482,12 @@ public class DirectoryScanner implements FileScanner // up to last '**' while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) { - String patDir = ( String )patDirs.elementAt( patIdxEnd ); + String patDir = (String)patDirs.elementAt( patIdxEnd ); if( patDir.equals( "**" ) ) { break; } - if( !match( patDir, ( String )strDirs.elementAt( strIdxEnd ), isCaseSensitive ) ) + if( !match( patDir, (String)strDirs.elementAt( strIdxEnd ), isCaseSensitive ) ) { return false; } @@ -532,8 +534,8 @@ public class DirectoryScanner implements FileScanner { for( int j = 0; j < patLength; j++ ) { - String subPat = ( String )patDirs.elementAt( patIdxStart + j + 1 ); - String subStr = ( String )strDirs.elementAt( strIdxStart + i + j ); + String subPat = (String)patDirs.elementAt( patIdxStart + j + 1 ); + String subStr = (String)strDirs.elementAt( strIdxStart + i + j ); if( !match( subPat, subStr, isCaseSensitive ) ) { continue strLoop; @@ -564,7 +566,6 @@ public class DirectoryScanner implements FileScanner return true; } - /** * Does the path match the start of this pattern up to the first "**".* @@ -630,12 +631,12 @@ public class DirectoryScanner implements FileScanner // up to first '**' while( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) { - String patDir = ( String )patDirs.elementAt( patIdxStart ); + String patDir = (String)patDirs.elementAt( patIdxStart ); if( patDir.equals( "**" ) ) { break; } - if( !match( patDir, ( String )strDirs.elementAt( strIdxStart ), isCaseSensitive ) ) + if( !match( patDir, (String)strDirs.elementAt( strIdxStart ), isCaseSensitive ) ) { return false; } @@ -661,7 +662,6 @@ public class DirectoryScanner implements FileScanner } } - /** * Sets the basedir for scanning. This is the directory that is scanned * recursively. All '/' and '\' characters are replaced by
File.separatorChar
@@ -674,7 +674,6 @@ public class DirectoryScanner implements FileScanner setBasedir( new File( basedir.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ) ) ); } - /** * Sets the basedir for scanning. This is the directory that is scanned * recursively. @@ -686,7 +685,6 @@ public class DirectoryScanner implements FileScanner this.basedir = basedir; } - /** * Sets the case sensitivity of the file system * @@ -697,7 +695,6 @@ public class DirectoryScanner implements FileScanner this.isCaseSensitive = isCaseSensitive; } - /** * Sets the set of exclude patterns to use. All '/' and '\' characters are * replaced byFile.separatorChar
. So the separator used need @@ -715,16 +712,16 @@ public class DirectoryScanner implements FileScanner } else { - this.excludes = new String[excludes.length]; + this.excludes = new String[ excludes.length ]; for( int i = 0; i < excludes.length; i++ ) { String pattern; - pattern = excludes[i].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ); + pattern = excludes[ i ].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ); if( pattern.endsWith( File.separator ) ) { pattern += "**"; } - this.excludes[i] = pattern; + this.excludes[ i ] = pattern; } } } @@ -746,21 +743,20 @@ public class DirectoryScanner implements FileScanner } else { - this.includes = new String[includes.length]; + this.includes = new String[ includes.length ]; for( int i = 0; i < includes.length; i++ ) { String pattern; - pattern = includes[i].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ); + pattern = includes[ i ].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ); if( pattern.endsWith( File.separator ) ) { pattern += "**"; } - this.includes[i] = pattern; + this.includes[ i ] = pattern; } } } - /** * Gets the basedir that is used for scanning. This is the directory that is * scanned recursively. @@ -772,7 +768,6 @@ public class DirectoryScanner implements FileScanner return basedir; } - /** * Get the names of the directories that matched at least one of the include * patterns, an matched also at least one of the exclude patterns. The names @@ -781,18 +776,18 @@ public class DirectoryScanner implements FileScanner * @return the names of the directories */ public String[] getExcludedDirectories() + throws TaskException { slowScan(); int count = dirsExcluded.size(); - String[] directories = new String[count]; + String[] directories = new String[ count ]; for( int i = 0; i < count; i++ ) { - directories[i] = ( String )dirsExcluded.elementAt( i ); + directories[ i ] = (String)dirsExcluded.elementAt( i ); } return directories; } - /** * Get the names of the files that matched at least one of the include * patterns, an matched also at least one of the exclude patterns. The names @@ -801,18 +796,18 @@ public class DirectoryScanner implements FileScanner * @return the names of the files */ public String[] getExcludedFiles() + throws TaskException { slowScan(); int count = filesExcluded.size(); - String[] files = new String[count]; + String[] files = new String[ count ]; for( int i = 0; i < count; i++ ) { - files[i] = ( String )filesExcluded.elementAt( i ); + files[ i ] = (String)filesExcluded.elementAt( i ); } return files; } - /** * Get the names of the directories that matched at least one of the include * patterns, an matched none of the exclude patterns. The names are relative @@ -823,15 +818,14 @@ public class DirectoryScanner implements FileScanner public String[] getIncludedDirectories() { int count = dirsIncluded.size(); - String[] directories = new String[count]; + String[] directories = new String[ count ]; for( int i = 0; i < count; i++ ) { - directories[i] = ( String )dirsIncluded.elementAt( i ); + directories[ i ] = (String)dirsIncluded.elementAt( i ); } return directories; } - /** * Get the names of the files that matched at least one of the include * patterns, and matched none of the exclude patterns. The names are @@ -842,15 +836,14 @@ public class DirectoryScanner implements FileScanner public String[] getIncludedFiles() { int count = filesIncluded.size(); - String[] files = new String[count]; + String[] files = new String[ count ]; for( int i = 0; i < count; i++ ) { - files[i] = ( String )filesIncluded.elementAt( i ); + files[ i ] = (String)filesIncluded.elementAt( i ); } return files; } - /** * Get the names of the directories that matched at none of the include * patterns. The names are relative to the basedir. @@ -858,18 +851,18 @@ public class DirectoryScanner implements FileScanner * @return the names of the directories */ public String[] getNotIncludedDirectories() + throws TaskException { slowScan(); int count = dirsNotIncluded.size(); - String[] directories = new String[count]; + String[] directories = new String[ count ]; for( int i = 0; i < count; i++ ) { - directories[i] = ( String )dirsNotIncluded.elementAt( i ); + directories[ i ] = (String)dirsNotIncluded.elementAt( i ); } return directories; } - /** * Get the names of the files that matched at none of the include patterns. * The names are relative to the basedir. @@ -877,13 +870,14 @@ public class DirectoryScanner implements FileScanner * @return the names of the files */ public String[] getNotIncludedFiles() + throws TaskException { slowScan(); int count = filesNotIncluded.size(); - String[] files = new String[count]; + String[] files = new String[ count ]; for( int i = 0; i < count; i++ ) { - files[i] = ( String )filesNotIncluded.elementAt( i ); + files[ i ] = (String)filesNotIncluded.elementAt( i ); } return files; } @@ -900,7 +894,6 @@ public class DirectoryScanner implements FileScanner return everythingIncluded; } - /** * Adds the array with default exclusions to the current exclusions set. */ @@ -908,25 +901,25 @@ public class DirectoryScanner implements FileScanner { int excludesLength = excludes == null ? 0 : excludes.length; String[] newExcludes; - newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length]; + newExcludes = new String[ excludesLength + DEFAULTEXCLUDES.length ]; if( excludesLength > 0 ) { System.arraycopy( excludes, 0, newExcludes, 0, excludesLength ); } for( int i = 0; i < DEFAULTEXCLUDES.length; i++ ) { - newExcludes[i + excludesLength] = DEFAULTEXCLUDES[i].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ); + newExcludes[ i + excludesLength ] = DEFAULTEXCLUDES[ i ].replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ); } excludes = newExcludes; } - /** * Scans the base directory for files that match at least one include * pattern, and don't match any exclude patterns. * */ public void scan() + throws TaskException { if( basedir == null ) { @@ -935,23 +928,23 @@ public class DirectoryScanner implements FileScanner if( !basedir.exists() ) { throw new IllegalStateException( "basedir " + basedir - + " does not exist" ); + + " does not exist" ); } if( !basedir.isDirectory() ) { throw new IllegalStateException( "basedir " + basedir - + " is not a directory" ); + + " is not a directory" ); } if( includes == null ) { // No includes supplied, so set it to 'matches all' - includes = new String[1]; - includes[0] = "**"; + includes = new String[ 1 ]; + includes[ 0 ] = "**"; } if( excludes == null ) { - excludes = new String[0]; + excludes = new String[ 0 ]; } filesIncluded = new Vector(); @@ -990,7 +983,7 @@ public class DirectoryScanner implements FileScanner { for( int i = 0; i < excludes.length; i++ ) { - if( matchPath( excludes[i], name, isCaseSensitive ) ) + if( matchPath( excludes[ i ], name, isCaseSensitive ) ) { return true; } @@ -998,7 +991,6 @@ public class DirectoryScanner implements FileScanner return false; } - /** * Tests whether a name matches against at least one include pattern. * @@ -1010,7 +1002,7 @@ public class DirectoryScanner implements FileScanner { for( int i = 0; i < includes.length; i++ ) { - if( matchPath( includes[i], name, isCaseSensitive ) ) + if( matchPath( includes[ i ], name, isCaseSensitive ) ) { return true; } @@ -1029,7 +1021,7 @@ public class DirectoryScanner implements FileScanner { for( int i = 0; i < includes.length; i++ ) { - if( matchPatternStart( includes[i], name, isCaseSensitive ) ) + if( matchPatternStart( includes[ i ], name, isCaseSensitive ) ) { return true; } @@ -1037,7 +1029,6 @@ public class DirectoryScanner implements FileScanner return false; } - /** * Scans the passed dir for files and directories. Found files and * directories are placed in their respective collections, based on the @@ -1056,6 +1047,7 @@ public class DirectoryScanner implements FileScanner * @see #dirsExcluded */ protected void scandir( File dir, String vpath, boolean fast ) + throws TaskException { String[] newfiles = dir.list(); @@ -1068,14 +1060,14 @@ public class DirectoryScanner implements FileScanner * (2) an IO error occurred (why doesn't it throw an exception * then???) */ - throw new BuildException( "IO error scanning directory " - + dir.getAbsolutePath() ); + throw new TaskException( "IO error scanning directory " + + dir.getAbsolutePath() ); } for( int i = 0; i < newfiles.length; i++ ) { - String name = vpath + newfiles[i]; - File file = new File( dir, newfiles[i] ); + String name = vpath + newfiles[ i ]; + File file = new File( dir, newfiles[ i ] ); if( file.isDirectory() ) { if( isIncluded( name ) ) @@ -1141,33 +1133,34 @@ public class DirectoryScanner implements FileScanner * Returns immediately if a slow scan has already been requested. */ protected void slowScan() + throws TaskException { if( haveSlowResults ) { return; } - String[] excl = new String[dirsExcluded.size()]; + String[] excl = new String[ dirsExcluded.size() ]; dirsExcluded.copyInto( excl ); - String[] notIncl = new String[dirsNotIncluded.size()]; + String[] notIncl = new String[ dirsNotIncluded.size() ]; dirsNotIncluded.copyInto( notIncl ); for( int i = 0; i < excl.length; i++ ) { - if( !couldHoldIncluded( excl[i] ) ) + if( !couldHoldIncluded( excl[ i ] ) ) { - scandir( new File( basedir, excl[i] ), - excl[i] + File.separator, false ); + scandir( new File( basedir, excl[ i ] ), + excl[ i ] + File.separator, false ); } } for( int i = 0; i < notIncl.length; i++ ) { - if( !couldHoldIncluded( notIncl[i] ) ) + if( !couldHoldIncluded( notIncl[ i ] ) ) { - scandir( new File( basedir, notIncl[i] ), - notIncl[i] + File.separator, false ); + scandir( new File( basedir, notIncl[ i ] ), + notIncl[ i ] + File.separator, false ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/FileScanner.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/FileScanner.java index a23d95e26..090f52f5d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/FileScanner.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/FileScanner.java @@ -6,13 +6,13 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.io.File; +import org.apache.myrmidon.api.TaskException; /** * An interface used to describe the actions required by any type of directory * scanner. - * - * @author RT */ public interface FileScanner { @@ -36,7 +36,7 @@ public interface FileScanner * * @return the names of the directories */ - String[] getExcludedDirectories(); + String[] getExcludedDirectories() throws TaskException; /** * Get the names of the files that matched at least one of the include @@ -45,7 +45,7 @@ public interface FileScanner * * @return the names of the files */ - String[] getExcludedFiles(); + String[] getExcludedFiles() throws TaskException; /** * Get the names of the directories that matched at least one of the include @@ -63,7 +63,7 @@ public interface FileScanner * * @return the names of the files */ - String[] getIncludedFiles(); + String[] getIncludedFiles() throws TaskException; /** * Get the names of the directories that matched at none of the include @@ -71,7 +71,7 @@ public interface FileScanner * * @return the names of the directories */ - String[] getNotIncludedDirectories(); + String[] getNotIncludedDirectories() throws TaskException; /** * Get the names of the files that matched at none of the include patterns. @@ -79,14 +79,15 @@ public interface FileScanner * * @return the names of the files */ - String[] getNotIncludedFiles(); + String[] getNotIncludedFiles() throws TaskException; /** * Scans the base directory for files that match at least one include * pattern, and don't match any exclude patterns. * */ - void scan(); + void scan() + throws TaskException; /** * Sets the basedir for scanning. This is the directory that is scanned diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/IntrospectionHelper.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/IntrospectionHelper.java index 8b7160c9f..c904a133d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/IntrospectionHelper.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/IntrospectionHelper.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; @@ -13,8 +14,10 @@ import java.lang.reflect.Method; import java.util.Enumeration; import java.util.Hashtable; import java.util.Locale; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.util.FileUtils; /** * Helper class that collects the methods a task or nested element holds to set @@ -66,6 +69,7 @@ public class IntrospectionHelper implements BuildListener private Hashtable nestedTypes; private IntrospectionHelper( final Class bean ) + throws TaskException { attributeTypes = new Hashtable(); attributeSetters = new Hashtable(); @@ -78,52 +82,52 @@ public class IntrospectionHelper implements BuildListener Method[] methods = bean.getMethods(); for( int i = 0; i < methods.length; i++ ) { - final Method m = methods[i]; + final Method m = methods[ i ]; final String name = m.getName(); Class returnType = m.getReturnType(); Class[] args = m.getParameterTypes(); // not really user settable properties on tasks if( org.apache.tools.ant.Task.class.isAssignableFrom( bean ) - && args.length == 1 && + && args.length == 1 && ( ( - "setLocation".equals( name ) && org.apache.tools.ant.Location.class.equals( args[0] ) - ) || ( - "setTaskType".equals( name ) && java.lang.String.class.equals( args[0] ) - ) - ) ) + "setLocation".equals( name ) && org.apache.tools.ant.Location.class.equals( args[ 0 ] ) + ) || ( + "setTaskType".equals( name ) && java.lang.String.class.equals( args[ 0 ] ) + ) + ) ) { continue; } // hide addTask for TaskContainers if( org.apache.tools.ant.TaskContainer.class.isAssignableFrom( bean ) - && args.length == 1 && "addTask".equals( name ) - && org.apache.tools.ant.Task.class.equals( args[0] ) ) + && args.length == 1 && "addTask".equals( name ) + && org.apache.tools.ant.Task.class.equals( args[ 0 ] ) ) { continue; } if( "addText".equals( name ) - && java.lang.Void.TYPE.equals( returnType ) - && args.length == 1 - && java.lang.String.class.equals( args[0] ) ) + && java.lang.Void.TYPE.equals( returnType ) + && args.length == 1 + && java.lang.String.class.equals( args[ 0 ] ) ) { - addText = methods[i]; + addText = methods[ i ]; } else if( name.startsWith( "set" ) - && java.lang.Void.TYPE.equals( returnType ) - && args.length == 1 - && !args[0].isArray() ) + && java.lang.Void.TYPE.equals( returnType ) + && args.length == 1 + && !args[ 0 ].isArray() ) { String propName = getPropertyName( name, "set" ); if( attributeSetters.get( propName ) != null ) { - if( java.lang.String.class.equals( args[0] ) ) + if( java.lang.String.class.equals( args[ 0 ] ) ) { /* * Ignore method m, as there is an overloaded @@ -144,109 +148,109 @@ public class IntrospectionHelper implements BuildListener * particular order. */ } - AttributeSetter as = createAttributeSetter( m, args[0] ); + AttributeSetter as = createAttributeSetter( m, args[ 0 ] ); if( as != null ) { - attributeTypes.put( propName, args[0] ); + attributeTypes.put( propName, args[ 0 ] ); attributeSetters.put( propName, as ); } } else if( name.startsWith( "create" ) - && !returnType.isArray() - && !returnType.isPrimitive() - && args.length == 0 ) + && !returnType.isArray() + && !returnType.isPrimitive() + && args.length == 0 ) { String propName = getPropertyName( name, "create" ); nestedTypes.put( propName, returnType ); nestedCreators.put( propName, - new NestedCreator() - { + new NestedCreator() + { - public Object create( Object parent ) - throws InvocationTargetException, - IllegalAccessException - { + public Object create( Object parent ) + throws InvocationTargetException, + IllegalAccessException + { - return m.invoke( parent, new Object[]{} ); - } + return m.invoke( parent, new Object[]{} ); + } - } ); + } ); } else if( name.startsWith( "addConfigured" ) - && java.lang.Void.TYPE.equals( returnType ) - && args.length == 1 - && !java.lang.String.class.equals( args[0] ) - && !args[0].isArray() - && !args[0].isPrimitive() ) + && java.lang.Void.TYPE.equals( returnType ) + && args.length == 1 + && !java.lang.String.class.equals( args[ 0 ] ) + && !args[ 0 ].isArray() + && !args[ 0 ].isPrimitive() ) { try { final Constructor c = - args[0].getConstructor( new Class[]{} ); + args[ 0 ].getConstructor( new Class[]{} ); String propName = getPropertyName( name, "addConfigured" ); - nestedTypes.put( propName, args[0] ); + nestedTypes.put( propName, args[ 0 ] ); nestedCreators.put( propName, - new NestedCreator() - { + new NestedCreator() + { - public Object create( Object parent ) - throws InvocationTargetException, IllegalAccessException, InstantiationException - { + public Object create( Object parent ) + throws InvocationTargetException, IllegalAccessException, InstantiationException + { - Object o = c.newInstance( new Object[]{} ); - return o; - } + Object o = c.newInstance( new Object[]{} ); + return o; + } - } ); + } ); nestedStorers.put( propName, - new NestedStorer() - { + new NestedStorer() + { - public void store( Object parent, Object child ) - throws InvocationTargetException, IllegalAccessException, InstantiationException - { + public void store( Object parent, Object child ) + throws InvocationTargetException, IllegalAccessException, InstantiationException + { - m.invoke( parent, new Object[]{child} ); - } + m.invoke( parent, new Object[]{child} ); + } - } ); + } ); } catch( NoSuchMethodException nse ) { } } else if( name.startsWith( "add" ) - && java.lang.Void.TYPE.equals( returnType ) - && args.length == 1 - && !java.lang.String.class.equals( args[0] ) - && !args[0].isArray() - && !args[0].isPrimitive() ) + && java.lang.Void.TYPE.equals( returnType ) + && args.length == 1 + && !java.lang.String.class.equals( args[ 0 ] ) + && !args[ 0 ].isArray() + && !args[ 0 ].isPrimitive() ) { try { final Constructor c = - args[0].getConstructor( new Class[]{} ); + args[ 0 ].getConstructor( new Class[]{} ); String propName = getPropertyName( name, "add" ); - nestedTypes.put( propName, args[0] ); + nestedTypes.put( propName, args[ 0 ] ); nestedCreators.put( propName, - new NestedCreator() - { + new NestedCreator() + { - public Object create( Object parent ) - throws InvocationTargetException, IllegalAccessException, InstantiationException - { + public Object create( Object parent ) + throws InvocationTargetException, IllegalAccessException, InstantiationException + { - Object o = c.newInstance( new Object[]{} ); - m.invoke( parent, new Object[]{o} ); - return o; - } + Object o = c.newInstance( new Object[]{} ); + m.invoke( parent, new Object[]{o} ); + return o; + } - } ); + } ); } catch( NoSuchMethodException nse ) { @@ -263,7 +267,7 @@ public class IntrospectionHelper implements BuildListener */ public static synchronized IntrospectionHelper getHelper( Class c ) { - IntrospectionHelper ih = ( IntrospectionHelper )helpers.get( c ); + IntrospectionHelper ih = (IntrospectionHelper)helpers.get( c ); if( ih == null ) { ih = new IntrospectionHelper( c ); @@ -285,13 +289,13 @@ public class IntrospectionHelper implements BuildListener String value ) throws BuildException { - AttributeSetter as = ( AttributeSetter )attributeSetters.get( attributeName ); + AttributeSetter as = (AttributeSetter)attributeSetters.get( attributeName ); if( as == null ) { String msg = getElementName( p, element ) + - //String msg = "Class " + element.getClass().getName() + + //String msg = "Class " + element.getClass().getName() + " doesn't support the \"" + attributeName + "\" attribute."; - throw new BuildException( msg ); + throw new TaskException( msg ); } try { @@ -300,16 +304,16 @@ public class IntrospectionHelper implements BuildListener catch( IllegalAccessException ie ) { // impossible as getMethods should only return public methods - throw new BuildException( ie ); + throw new TaskException( ie.toString(), ie ); } catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); - if( t instanceof BuildException ) + if( t instanceof TaskException ) { - throw ( BuildException )t; + throw (TaskException)t; } - throw new BuildException( t ); + throw new TaskException( t.toString(), t ); } } @@ -318,17 +322,17 @@ public class IntrospectionHelper implements BuildListener * * @param attributeName Description of Parameter * @return The AttributeType value - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public Class getAttributeType( String attributeName ) - throws BuildException + throws TaskException { - Class at = ( Class )attributeTypes.get( attributeName ); + Class at = (Class)attributeTypes.get( attributeName ); if( at == null ) { String msg = "Class " + bean.getName() + " doesn't support the \"" + attributeName + "\" attribute."; - throw new BuildException( msg ); + throw new TaskException( msg ); } return at; } @@ -348,17 +352,17 @@ public class IntrospectionHelper implements BuildListener * * @param elementName Description of Parameter * @return The ElementType value - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public Class getElementType( String elementName ) - throws BuildException + throws TaskException { - Class nt = ( Class )nestedTypes.get( elementName ); + Class nt = (Class)nestedTypes.get( elementName ); if( nt == null ) { String msg = "Class " + bean.getName() + " doesn't support the nested \"" + elementName + "\" element."; - throw new BuildException( msg ); + throw new TaskException( msg ); } return nt; } @@ -381,13 +385,14 @@ public class IntrospectionHelper implements BuildListener * @param text The feature to be added to the Text attribute */ public void addText( Project project, Object element, String text ) + throws TaskException { if( addText == null ) { String msg = getElementName( project, element ) + - //String msg = "Class " + element.getClass().getName() + + //String msg = "Class " + element.getClass().getName() + " doesn't support nested text data."; - throw new BuildException( msg ); + throw new TaskException( msg ); } try { @@ -396,16 +401,16 @@ public class IntrospectionHelper implements BuildListener catch( IllegalAccessException ie ) { // impossible as getMethods should only return public methods - throw new BuildException( ie ); + throw new TaskException( ie.getMessage(), ie ); } catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); - if( t instanceof BuildException ) + if( t instanceof TaskException ) { - throw ( BuildException )t; + throw (TaskException)t; } - throw new BuildException( t ); + throw new TaskException( t.getMessage(), t ); } } @@ -419,7 +424,9 @@ public class IntrospectionHelper implements BuildListener helpers.clear(); } - public void buildStarted( BuildEvent event ) { } + public void buildStarted( BuildEvent event ) + { + } /** * Creates a named nested element. @@ -428,49 +435,51 @@ public class IntrospectionHelper implements BuildListener * @param element Description of Parameter * @param elementName Description of Parameter * @return Description of the Returned Value - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public Object createElement( Project project, Object element, String elementName ) - throws BuildException + throws TaskException { - NestedCreator nc = ( NestedCreator )nestedCreators.get( elementName ); + NestedCreator nc = (NestedCreator)nestedCreators.get( elementName ); if( nc == null ) { String msg = getElementName( project, element ) + " doesn't support the nested \"" + elementName + "\" element."; - throw new BuildException( msg ); + throw new TaskException( msg ); } try { Object nestedElement = nc.create( element ); if( nestedElement instanceof ProjectComponent ) { - ( ( ProjectComponent )nestedElement ).setProject( project ); + ( (ProjectComponent)nestedElement ).setProject( project ); } return nestedElement; } catch( IllegalAccessException ie ) { // impossible as getMethods should only return public methods - throw new BuildException( ie ); + throw new TaskException( ie.getMessage(), ie ); } catch( InstantiationException ine ) { // impossible as getMethods should only return public methods - throw new BuildException( ine ); + throw new TaskException( ine.getMessage(), ine ); } catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); - if( t instanceof BuildException ) + if( t instanceof TaskException ) { - throw ( BuildException )t; + throw (TaskException)t; } - throw new BuildException( t ); + throw new TaskException( t.getMessage(), t ); } } - public void messageLogged( BuildEvent event ) { } + public void messageLogged( BuildEvent event ) + { + } /** * Creates a named nested element. @@ -479,16 +488,16 @@ public class IntrospectionHelper implements BuildListener * @param element Description of Parameter * @param child Description of Parameter * @param elementName Description of Parameter - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public void storeElement( Project project, Object element, Object child, String elementName ) - throws BuildException + throws TaskException { if( elementName == null ) { return; } - NestedStorer ns = ( NestedStorer )nestedStorers.get( elementName ); + NestedStorer ns = (NestedStorer)nestedStorers.get( elementName ); if( ns == null ) { return; @@ -500,21 +509,21 @@ public class IntrospectionHelper implements BuildListener catch( IllegalAccessException ie ) { // impossible as getMethods should only return public methods - throw new BuildException( ie ); + throw new TaskException( ie.getMessage(), ie ); } catch( InstantiationException ine ) { // impossible as getMethods should only return public methods - throw new BuildException( ine ); + throw new TaskException( ine.getMessage(), ine ); } catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); - if( t instanceof BuildException ) + if( t instanceof TaskException ) { - throw ( BuildException )t; + throw (TaskException)t; } - throw new BuildException( t ); + throw new TaskException( t.getMessage(), t ); } } @@ -528,13 +537,21 @@ public class IntrospectionHelper implements BuildListener return addText != null; } - public void targetFinished( BuildEvent event ) { } + public void targetFinished( BuildEvent event ) + { + } - public void targetStarted( BuildEvent event ) { } + public void targetStarted( BuildEvent event ) + { + } - public void taskFinished( BuildEvent event ) { } + public void taskFinished( BuildEvent event ) + { + } - public void taskStarted( BuildEvent event ) { } + public void taskStarted( BuildEvent event ) + { + } protected String getElementName( Project project, Object element ) { @@ -555,8 +572,8 @@ public class IntrospectionHelper implements BuildListener Enumeration e = elements.keys(); while( e.hasMoreElements() ) { - String elementName = ( String )e.nextElement(); - Class elementClass = ( Class )elements.get( elementName ); + String elementName = (String)e.nextElement(); + Class elementClass = (Class)elements.get( elementName ); if( element.getClass().equals( elementClass ) ) { return "The <" + elementName + "> " + typeName; @@ -590,7 +607,8 @@ public class IntrospectionHelper implements BuildListener * @return Description of the Returned Value */ private AttributeSetter createAttributeSetter( final Method m, - final Class arg ) + final Class arg ) + throws TaskException { // simplest case - setAttribute expects String @@ -608,7 +626,7 @@ public class IntrospectionHelper implements BuildListener // now for the primitive types, use their wrappers } else if( java.lang.Character.class.equals( arg ) - || java.lang.Character.TYPE.equals( arg ) ) + || java.lang.Character.TYPE.equals( arg ) ) { return new AttributeSetter() @@ -702,7 +720,7 @@ public class IntrospectionHelper implements BuildListener // in Project } else if( java.lang.Boolean.class.equals( arg ) - || java.lang.Boolean.TYPE.equals( arg ) ) + || java.lang.Boolean.TYPE.equals( arg ) ) { return new AttributeSetter() @@ -711,7 +729,7 @@ public class IntrospectionHelper implements BuildListener throws InvocationTargetException, IllegalAccessException { m.invoke( parent, - new Boolean[]{new Boolean( Project.toBoolean( value ) )} ); + new Boolean[]{new Boolean( Project.toBoolean( value ) )} ); } }; @@ -723,7 +741,7 @@ public class IntrospectionHelper implements BuildListener new AttributeSetter() { public void set( Project p, Object parent, String value ) - throws InvocationTargetException, IllegalAccessException, BuildException + throws InvocationTargetException, IllegalAccessException, TaskException { try { @@ -731,7 +749,7 @@ public class IntrospectionHelper implements BuildListener } catch( ClassNotFoundException ce ) { - throw new BuildException( ce ); + throw new TaskException( ce.toString(), ce ); } } }; @@ -745,7 +763,9 @@ public class IntrospectionHelper implements BuildListener public void set( Project p, Object parent, String value ) throws InvocationTargetException, IllegalAccessException { - m.invoke( parent, new File[]{p.resolveFile( value )} ); + final File file = + FileUtils.newFileUtils().resolveFile( p.getBaseDir(), value ); + m.invoke( parent, new File[]{ file } ); } }; @@ -771,17 +791,17 @@ public class IntrospectionHelper implements BuildListener new AttributeSetter() { public void set( Project p, Object parent, String value ) - throws InvocationTargetException, IllegalAccessException, BuildException + throws InvocationTargetException, IllegalAccessException, TaskException { try { - org.apache.tools.ant.types.EnumeratedAttribute ea = ( org.apache.tools.ant.types.EnumeratedAttribute )arg.newInstance(); + org.apache.tools.ant.types.EnumeratedAttribute ea = (org.apache.tools.ant.types.EnumeratedAttribute)arg.newInstance(); ea.setValue( value ); m.invoke( parent, new EnumeratedAttribute[]{ea} ); } catch( InstantiationException ie ) { - throw new BuildException( ie ); + throw new TaskException( ie.getMessage(), ie ); } } }; @@ -801,20 +821,20 @@ public class IntrospectionHelper implements BuildListener { public void set( Project p, Object parent, String value ) - throws InvocationTargetException, IllegalAccessException, BuildException + throws InvocationTargetException, IllegalAccessException, TaskException { try { Object attribute = c.newInstance( new String[]{value} ); if( attribute instanceof ProjectComponent ) { - ( ( ProjectComponent )attribute ).setProject( p ); + ( (ProjectComponent)attribute ).setProject( p ); } m.invoke( parent, new Object[]{attribute} ); } catch( InstantiationException ie ) { - throw new BuildException( ie ); + throw new TaskException( ie.getMessage(), ie ); } } }; @@ -831,7 +851,7 @@ public class IntrospectionHelper implements BuildListener { void set( Project p, Object parent, String value ) throws InvocationTargetException, IllegalAccessException, - BuildException; + TaskException; } private interface NestedCreator diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/Main.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/Main.java index 0c605f732..3721f72dd 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/Main.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/Main.java @@ -14,6 +14,7 @@ import java.io.PrintStream; import java.util.Enumeration; import java.util.Properties; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; /** * Command line entry point into Ant. This class is entered via the cannonical @@ -97,7 +98,7 @@ public class Main private File buildFile; protected Main( String[] args ) - throws BuildException + throws TaskException { String searchForThis = null; @@ -289,7 +290,7 @@ public class Main if( !buildFile.exists() ) { System.out.println( "Buildfile: " + buildFile + " does not exist!" ); - throw new BuildException( "Build failed" ); + throw new TaskException( "Build failed" ); } // make sure it's not a directory (this falls into the ultra @@ -298,14 +299,14 @@ public class Main if( buildFile.isDirectory() ) { System.out.println( "What? Buildfile: " + buildFile + " is a dir!" ); - throw new BuildException( "Build failed" ); + throw new TaskException( "Build failed" ); } readyToRun = true; } public static synchronized String getAntVersion() - throws BuildException + throws TaskException { if( antVersion == null ) { @@ -327,12 +328,12 @@ public class Main } catch( IOException ioe ) { - throw new BuildException( "Could not load the version information:" + throw new TaskException( "Could not load the version information:" + ioe.getMessage() ); } catch( NullPointerException npe ) { - throw new BuildException( "Could not load the version information." ); + throw new TaskException( "Could not load the version information." ); } } return antVersion; @@ -388,7 +389,7 @@ public class Main m.runBuild( coreLoader ); System.exit( 0 ); } - catch( BuildException be ) + catch( TaskException be ) { if( m.err != System.err ) { @@ -569,7 +570,7 @@ public class Main } private static void printVersion() - throws BuildException + throws TaskException { System.out.println( getAntVersion() ); } @@ -591,7 +592,7 @@ public class Main } catch( Throwable exc ) { - throw new BuildException( "Unable to instantiate listener " + className, exc ); + throw new TaskException( "Unable to instantiate listener " + className, exc ); } } } @@ -668,10 +669,10 @@ public class Main * @param suffix Suffix filename to look for in parents. * @param start Description of Parameter * @return A handle to the build file - * @exception BuildException Failed to locate a build file + * @exception TaskException Failed to locate a build file */ private File findBuildFile( String start, String suffix ) - throws BuildException + throws TaskException { if( msgOutputLevel >= Project.MSG_INFO ) { @@ -691,7 +692,7 @@ public class Main // complain that we can't find the build file. if( parent == null ) { - throw new BuildException( "Could not locate a build file!" ); + throw new TaskException( "Could not locate a build file!" ); } // refresh our file handle @@ -705,10 +706,10 @@ public class Main * Executes the build. * * @param coreLoader Description of Parameter - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ private void runBuild( ClassLoader coreLoader ) - throws BuildException + throws TaskException { if( !readyToRun ) @@ -782,15 +783,15 @@ public class Main } catch( NoClassDefFoundError ncdfe ) { - throw new BuildException( noParserMessage, ncdfe ); + throw new TaskException( noParserMessage, ncdfe ); } catch( ClassNotFoundException cnfe ) { - throw new BuildException( noParserMessage, cnfe ); + throw new TaskException( noParserMessage, cnfe ); } catch( NullPointerException npe ) { - throw new BuildException( noParserMessage, npe ); + throw new TaskException( noParserMessage, npe ); } if( projectHelp ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/Project.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/Project.java index c509b8795..c2d656e57 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/Project.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/Project.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -15,6 +16,7 @@ import java.util.Hashtable; import java.util.Properties; import java.util.Stack; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.types.FilterSet; import org.apache.tools.ant.types.FilterSetCollection; import org.apache.tools.ant.util.FileUtils; @@ -30,10 +32,8 @@ import org.apache.tools.ant.util.FileUtils; * * @author duncan@x180.com */ - public class Project { - public final static int MSG_ERR = 0; public final static int MSG_WARN = 1; public final static int MSG_INFO = 2; @@ -71,7 +71,7 @@ public class Project /** * The Ant core classloader - may be null if using system loader */ - private ClassLoader coreLoader = null; + private ClassLoader coreLoader; /** * Records the latest task on a thread @@ -81,8 +81,6 @@ public class Project private String defaultTarget; private String description; - private FileUtils fileUtils; - private String name; static @@ -113,14 +111,6 @@ public class Project } } - /** - * create a new ant project - */ - public Project() - { - fileUtils = FileUtils.newFileUtils(); - } - /** * static query of the java version * @@ -181,18 +171,18 @@ public class Project return path.toString(); } - private static BuildException makeCircularException( String end, Stack stk ) + private static TaskException makeCircularException( String end, Stack stk ) { StringBuffer sb = new StringBuffer( "Circular dependency: " ); sb.append( end ); String c; do { - c = ( String )stk.pop(); + c = (String)stk.pop(); sb.append( " <- " ); sb.append( c ); - }while ( !c.equals( end ) ); - return new BuildException( new String( sb ) ); + } while( !c.equals( end ) ); + return new TaskException( new String( sb ) ); } /** @@ -200,16 +190,16 @@ public class Project * and being a directory type * * @param baseDir project base directory. - * @throws BuildException if the directory was invalid + * @throws TaskException if the directory was invalid */ public void setBaseDir( File baseDir ) - throws BuildException + throws TaskException { - baseDir = fileUtils.normalize( baseDir.getAbsolutePath() ); + baseDir = FileUtils.newFileUtils().normalize( baseDir.getAbsolutePath() ); if( !baseDir.exists() ) - throw new BuildException( "Basedir " + baseDir.getAbsolutePath() + " does not exist" ); + throw new TaskException( "Basedir " + baseDir.getAbsolutePath() + " does not exist" ); if( !baseDir.isDirectory() ) - throw new BuildException( "Basedir " + baseDir.getAbsolutePath() + " is not a directory" ); + throw new TaskException( "Basedir " + baseDir.getAbsolutePath() + " is not a directory" ); this.baseDir = baseDir; setPropertyInternal( "basedir", this.baseDir.getPath() ); String msg = "Project base dir set to: " + this.baseDir; @@ -220,10 +210,10 @@ public class Project * match basedir attribute in xml * * @param baseD project base directory. - * @throws BuildException if the directory was invalid + * @throws TaskException if the directory was invalid */ public void setBasedir( String baseD ) - throws BuildException + throws TaskException { setBaseDir( new File( baseD ) ); } @@ -233,7 +223,6 @@ public class Project this.coreLoader = coreLoader; } - /** * set the default target of the project XML attribute name. * @@ -244,18 +233,6 @@ public class Project this.defaultTarget = defaultTarget; } - /** - * set the default target of the project - * - * @param defaultTarget The new DefaultTarget value - * @see #setDefault(String) - * @deprecated, use setDefault - */ - public void setDefaultTarget( String defaultTarget ) - { - this.defaultTarget = defaultTarget; - } - /** * set the project description * @@ -266,42 +243,21 @@ public class Project this.description = description; } - /** - * Calls File.setLastModified(long time) in a Java 1.1 compatible way. - * - * @param file The new FileLastModified value - * @param time The new FileLastModified value - * @exception BuildException Description of Exception - * @deprecated - */ - public void setFileLastModified( File file, long time ) - throws BuildException - { - if( getJavaVersion() == JAVA_1_1 ) - { - log( "Cannot change the modification time of " + file - + " in JDK 1.1", Project.MSG_WARN ); - return; - } - fileUtils.setFileLastModified( file, time ); - log( "Setting modification time for " + file, MSG_VERBOSE ); - } - /** * set the ant.java.version property, also tests for unsupported JVM * versions, prints the verbose log messages * - * @throws BuildException if this Java version is not supported + * @throws TaskException if this Java version is not supported */ public void setJavaVersionProperty() - throws BuildException + throws TaskException { setPropertyInternal( "ant.java.version", javaVersion ); // sanity check if( javaVersion == JAVA_1_0 ) { - throw new BuildException( "Ant cannot work on Java 1.0" ); + throw new TaskException( "Ant cannot work on Java 1.0" ); } log( "Detected Java version: " + javaVersion + " in: " + System.getProperty( "java.home" ), MSG_VERBOSE ); @@ -337,7 +293,7 @@ public class Project return; } log( "Setting project property: " + name + " -> " + - value, MSG_DEBUG ); + value, MSG_DEBUG ); properties.put( name, value ); } @@ -360,11 +316,11 @@ public class Project if( null != properties.get( name ) ) { log( "Overriding previous definition of property " + name, - MSG_VERBOSE ); + MSG_VERBOSE ); } log( "Setting project property: " + name + " -> " + - value, MSG_DEBUG ); + value, MSG_DEBUG ); properties.put( name, value ); } @@ -395,7 +351,7 @@ public class Project public void setUserProperty( String name, String value ) { log( "Setting ro project property: " + name + " -> " + - value, MSG_DEBUG ); + value, MSG_DEBUG ); userProperties.put( name, value ); properties.put( name, value ); } @@ -414,7 +370,7 @@ public class Project { setBasedir( "." ); } - catch( BuildException ex ) + catch( TaskException ex ) { ex.printStackTrace(); } @@ -462,17 +418,6 @@ public class Project return description; } - /** - * @return The Filters value - * @deprecated - */ - public Hashtable getFilters() - { - // we need to build the hashtable dynamically - return globalFilterSet.getFilterHash(); - } - - public FilterSet getGlobalFilterSet() { return globalFilterSet; @@ -518,7 +463,7 @@ public class Project { if( name == null ) return null; - String property = ( String )properties.get( name ); + String property = (String)properties.get( name ); return property; } @@ -586,7 +531,7 @@ public class Project { if( name == null ) return null; - String property = ( String )userProperties.get( name ); + String property = (String)userProperties.get( name ); return property; } @@ -599,11 +544,11 @@ public class Project * @param targets is a Hashtable representing a "name to Target" mapping * @return a Vector of Strings with the names of the targets in sorted * order. - * @exception BuildException if there is a cyclic dependency among the + * @exception TaskException if there is a cyclic dependency among the * Targets, or if a Target does not exist. */ public final Vector topoSort( String root, Hashtable targets ) - throws BuildException + throws TaskException { Vector ret = new Vector(); Hashtable state = new Hashtable(); @@ -619,10 +564,10 @@ public class Project tsort( root, targets, state, visiting, ret ); log( "Build sequence for target `" + root + "' is " + ret, MSG_VERBOSE ); - for( Enumeration en = targets.keys(); en.hasMoreElements(); ) + for( Enumeration en = targets.keys(); en.hasMoreElements(); ) { - String curTarget = ( String )( en.nextElement() ); - String st = ( String )state.get( curTarget ); + String curTarget = (String)( en.nextElement() ); + String st = (String)state.get( curTarget ); if( st == null ) { tsort( curTarget, targets, state, visiting, ret ); @@ -652,7 +597,7 @@ public class Project if( null != dataClassDefinitions.get( typeName ) ) { log( "Trying to override old definition of datatype " + typeName, - MSG_WARN ); + MSG_WARN ); } String msg = " +User datatype: " + typeName + " " + typeClass.getName(); @@ -660,21 +605,6 @@ public class Project dataClassDefinitions.put( typeName, typeClass ); } - /** - * @param token The feature to be added to the Filter attribute - * @param value The feature to be added to the Filter attribute - * @deprecated - */ - public void addFilter( String token, String value ) - { - if( token == null ) - { - return; - } - - globalFilterSet.addFilter( new FilterSet.Filter( token, value ) ); - } - /** * @param target is the Target to be added or replaced in the current * Project. @@ -701,7 +631,7 @@ public class Project if( null != references.get( name ) ) { log( "Overriding previous definition of reference to " + name, - MSG_WARN ); + MSG_WARN ); } log( "Adding reference: " + name + " -> " + value, MSG_DEBUG ); references.put( name, value ); @@ -714,11 +644,12 @@ public class Project * @see Project#addOrReplaceTarget to replace existing Targets. */ public void addTarget( Target target ) + throws TaskException { String name = target.getName(); if( targets.get( name ) != null ) { - throw new BuildException( "Duplicate target: `" + name + "'" ); + throw new TaskException( "Duplicate target: `" + name + "'" ); } addOrReplaceTarget( name, target ); } @@ -728,15 +659,15 @@ public class Project * * @param target is the Target to be added to the current Project. * @param targetName is the name to use for the Target - * @exception BuildException if the Target already exists in the project. + * @exception TaskException if the Target already exists in the project. * @see Project#addOrReplaceTarget to replace existing Targets. */ public void addTarget( String targetName, Target target ) - throws BuildException + throws TaskException { if( targets.get( targetName ) != null ) { - throw new BuildException( "Duplicate target: `" + targetName + "'" ); + throw new TaskException( "Duplicate target: `" + targetName + "'" ); } addOrReplaceTarget( targetName, target ); } @@ -746,26 +677,26 @@ public class Project * * @param taskName name of the task * @param taskClass full task classname - * @throws BuildException and logs as Project.MSG_ERR for conditions, that + * @throws TaskException and logs as Project.MSG_ERR for conditions, that * will cause the task execution to fail. */ public void addTaskDefinition( String taskName, Class taskClass ) - throws BuildException + throws TaskException { - Class old = ( Class )taskClassDefinitions.get( taskName ); + Class old = (Class)taskClassDefinitions.get( taskName ); if( null != old ) { if( old.equals( taskClass ) ) { log( "Ignoring override for task " + taskName + ", it is already defined by the same class.", - MSG_VERBOSE ); + MSG_VERBOSE ); return; } else { log( "Trying to override old definition of task " + taskName, - MSG_WARN ); + MSG_WARN ); invalidateCreatedTasks( taskName ); } } @@ -780,23 +711,23 @@ public class Project * Checks a class, whether it is suitable for serving as ant task. * * @param taskClass Description of Parameter - * @throws BuildException and logs as Project.MSG_ERR for conditions, that + * @throws TaskException and logs as Project.MSG_ERR for conditions, that * will cause the task execution to fail. */ public void checkTaskClass( final Class taskClass ) - throws BuildException + throws TaskException { if( !Modifier.isPublic( taskClass.getModifiers() ) ) { final String message = taskClass + " is not public"; log( message, Project.MSG_ERR ); - throw new BuildException( message ); + throw new TaskException( message ); } if( Modifier.isAbstract( taskClass.getModifiers() ) ) { final String message = taskClass + " is abstract"; log( message, Project.MSG_ERR ); - throw new BuildException( message ); + throw new TaskException( message ); } try { @@ -808,169 +739,23 @@ public class Project { final String message = "No public default constructor in " + taskClass; log( message, Project.MSG_ERR ); - throw new BuildException( message ); + throw new TaskException( message ); } if( !Task.class.isAssignableFrom( taskClass ) ) TaskAdapter.checkTaskClass( taskClass, this ); } - /** - * Convienence method to copy a file from a source to a destination. No - * filtering is performed. - * - * @param sourceFile Description of Parameter - * @param destFile Description of Parameter - * @throws IOException - * @deprecated - */ - public void copyFile( String sourceFile, String destFile ) - throws IOException - { - fileUtils.copyFile( sourceFile, destFile ); - } - - /** - * Convienence method to copy a file from a source to a destination - * specifying if token filtering must be used. - * - * @param sourceFile Description of Parameter - * @param destFile Description of Parameter - * @param filtering Description of Parameter - * @throws IOException - * @deprecated - */ - public void copyFile( String sourceFile, String destFile, boolean filtering ) - throws IOException - { - fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null ); - } - - /** - * Convienence method to copy a file from a source to a destination - * specifying if token filtering must be used and if source files may - * overwrite newer destination files. - * - * @param sourceFile Description of Parameter - * @param destFile Description of Parameter - * @param filtering Description of Parameter - * @param overwrite Description of Parameter - * @throws IOException - * @deprecated - */ - public void copyFile( String sourceFile, String destFile, boolean filtering, - boolean overwrite ) - throws IOException - { - fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null, overwrite ); - } - - /** - * Convienence method to copy a file from a source to a destination - * specifying if token filtering must be used, if source files may overwrite - * newer destination files and the last modified time ofdestFile
- * file should be made equal to the last modified time ofsourceFile
- * . - * - * @param sourceFile Description of Parameter - * @param destFile Description of Parameter - * @param filtering Description of Parameter - * @param overwrite Description of Parameter - * @param preserveLastModified Description of Parameter - * @throws IOException - * @deprecated - */ - public void copyFile( String sourceFile, String destFile, boolean filtering, - boolean overwrite, boolean preserveLastModified ) - throws IOException - { - fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null, - overwrite, preserveLastModified ); - } - - /** - * Convienence method to copy a file from a source to a destination. No - * filtering is performed. - * - * @param sourceFile Description of Parameter - * @param destFile Description of Parameter - * @throws IOException - * @deprecated - */ - public void copyFile( File sourceFile, File destFile ) - throws IOException - { - fileUtils.copyFile( sourceFile, destFile ); - } - - /** - * Convienence method to copy a file from a source to a destination - * specifying if token filtering must be used. - * - * @param sourceFile Description of Parameter - * @param destFile Description of Parameter - * @param filtering Description of Parameter - * @throws IOException - * @deprecated - */ - public void copyFile( File sourceFile, File destFile, boolean filtering ) - throws IOException - { - fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null ); - } - - /** - * Convienence method to copy a file from a source to a destination - * specifying if token filtering must be used and if source files may - * overwrite newer destination files. - * - * @param sourceFile Description of Parameter - * @param destFile Description of Parameter - * @param filtering Description of Parameter - * @param overwrite Description of Parameter - * @throws IOException - * @deprecated - */ - public void copyFile( File sourceFile, File destFile, boolean filtering, - boolean overwrite ) - throws IOException - { - fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null, overwrite ); - } - - /** - * Convienence method to copy a file from a source to a destination - * specifying if token filtering must be used, if source files may overwrite - * newer destination files and the last modified time ofdestFile
- * file should be made equal to the last modified time ofsourceFile
- * . - * - * @param sourceFile Description of Parameter - * @param destFile Description of Parameter - * @param filtering Description of Parameter - * @param overwrite Description of Parameter - * @param preserveLastModified Description of Parameter - * @throws IOException - * @deprecated - */ - public void copyFile( File sourceFile, File destFile, boolean filtering, - boolean overwrite, boolean preserveLastModified ) - throws IOException - { - fileUtils.copyFile( sourceFile, destFile, filtering ? globalFilters : null, - overwrite, preserveLastModified ); - } - /** * create a new DataType instance * * @param typeName name of the datatype * @return null if the datatype name is unknown - * @throws BuildException when datatype creation goes bad + * @throws TaskException when datatype creation goes bad */ public Object createDataType( String typeName ) - throws BuildException + throws TaskException { - Class c = ( Class )dataClassDefinitions.get( typeName ); + Class c = (Class)dataClassDefinitions.get( typeName ); if( c == null ) return null; @@ -983,7 +768,7 @@ public class Project // Project argument. try { - ctor = c.getConstructor( new Class[0] ); + ctor = c.getConstructor( new Class[ 0 ] ); noArg = true; } catch( NoSuchMethodException nse ) @@ -995,7 +780,7 @@ public class Project Object o = null; if( noArg ) { - o = ctor.newInstance( new Object[0] ); + o = ctor.newInstance( new Object[ 0 ] ); } else { @@ -1003,7 +788,7 @@ public class Project } if( o instanceof ProjectComponent ) { - ( ( ProjectComponent )o ).setProject( this ); + ( (ProjectComponent)o ).setProject( this ); } String msg = " +DataType: " + typeName; log( msg, MSG_DEBUG ); @@ -1013,14 +798,14 @@ public class Project { Throwable t = ite.getTargetException(); String msg = "Could not create datatype of type: " - + typeName + " due to " + t; - throw new BuildException( msg, t ); + + typeName + " due to " + t; + throw new TaskException( msg, t ); } catch( Throwable t ) { String msg = "Could not create datatype of type: " - + typeName + " due to " + t; - throw new BuildException( msg, t ); + + typeName + " due to " + t; + throw new TaskException( msg, t ); } } @@ -1029,12 +814,12 @@ public class Project * * @param taskType name of the task * @return null if the task name is unknown - * @throws BuildException when task creation goes bad + * @throws TaskException when task creation goes bad */ public Task createTask( String taskType ) - throws BuildException + throws TaskException { - Class c = ( Class )taskClassDefinitions.get( taskType ); + Class c = (Class)taskClassDefinitions.get( taskType ); if( c == null ) return null; @@ -1044,7 +829,7 @@ public class Project Task task = null; if( o instanceof Task ) { - task = ( Task )o; + task = (Task)o; } else { @@ -1068,14 +853,14 @@ public class Project catch( Throwable t ) { String msg = "Could not create task of type: " - + taskType + " due to " + t; - throw new BuildException( msg, t ); + + taskType + " due to " + t; + throw new TaskException( msg, t ); } } public void demuxOutput( String line, boolean isError ) { - Task task = ( Task )threadTasks.get( Thread.currentThread() ); + Task task = (Task)threadTasks.get( Thread.currentThread() ); if( task == null ) { fireMessageLogged( this, line, isError ? MSG_ERR : MSG_INFO ); @@ -1097,10 +882,10 @@ public class Project * execute the targets and any targets it depends on * * @param targetName the target to execute - * @throws BuildException if the build failed + * @throws TaskException if the build failed */ public void executeTarget( String targetName ) - throws BuildException + throws TaskException { // sanity check ourselves, if we've been asked to build nothing @@ -1109,7 +894,7 @@ public class Project if( targetName == null ) { String msg = "No target specified"; - throw new BuildException( msg ); + throw new TaskException( msg ); } // Sort the dependency tree, and run everything from the @@ -1124,25 +909,25 @@ public class Project do { - curtarget = ( Target )sortedTargets.elementAt( curidx++ ); + curtarget = (Target)sortedTargets.elementAt( curidx++ ); curtarget.performTasks(); - }while ( !curtarget.getName().equals( targetName ) ); + } while( !curtarget.getName().equals( targetName ) ); } /** * execute the sequence of targets, and the targets they depend on * * @param targetNames Description of Parameter - * @throws BuildException if the build failed + * @throws TaskException if the build failed */ public void executeTargets( Vector targetNames ) - throws BuildException + throws TaskException { Throwable error = null; for( int i = 0; i < targetNames.size(); i++ ) { - executeTarget( ( String )targetNames.elementAt( i ) ); + executeTarget( (String)targetNames.elementAt( i ) ); } } @@ -1150,10 +935,10 @@ public class Project * Initialise the project. This involves setting the default task * definitions and loading the system properties. * - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public void init() - throws BuildException + throws TaskException { setJavaVersionProperty(); @@ -1165,7 +950,7 @@ public class Project InputStream in = this.getClass().getResourceAsStream( defs ); if( in == null ) { - throw new BuildException( "Can't load default task list" ); + throw new TaskException( "Can't load default task list" ); } props.load( in ); in.close(); @@ -1173,7 +958,7 @@ public class Project Enumeration enum = props.propertyNames(); while( enum.hasMoreElements() ) { - String key = ( String )enum.nextElement(); + String key = (String)enum.nextElement(); String value = props.getProperty( key ); try { @@ -1192,7 +977,7 @@ public class Project } catch( IOException ioe ) { - throw new BuildException( "Can't load default task list" ); + throw new TaskException( "Can't load default task list" ); } String dataDefs = "/org/apache/tools/ant/types/defaults.properties"; @@ -1203,7 +988,7 @@ public class Project InputStream in = this.getClass().getResourceAsStream( dataDefs ); if( in == null ) { - throw new BuildException( "Can't load default datatype list" ); + throw new TaskException( "Can't load default datatype list" ); } props.load( in ); in.close(); @@ -1211,7 +996,7 @@ public class Project Enumeration enum = props.propertyNames(); while( enum.hasMoreElements() ) { - String key = ( String )enum.nextElement(); + String key = (String)enum.nextElement(); String value = props.getProperty( key ); try { @@ -1230,7 +1015,7 @@ public class Project } catch( IOException ioe ) { - throw new BuildException( "Can't load default datatype list" ); + throw new TaskException( "Can't load default datatype list" ); } setSystemProperties(); @@ -1296,34 +1081,14 @@ public class Project * * @param value the string to be scanned for property references. * @return Description of the Returned Value - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public String replaceProperties( String value ) - throws BuildException + throws TaskException { return ProjectHelper.replaceProperties( this, value ); } - /** - * Return the canonical form of fileName as an absolute path.- * - * If fileName is a relative file name, resolve it relative to rootDir.
- * - * @param fileName Description of Parameter - * @param rootDir Description of Parameter - * @return Description of the Returned Value - * @deprecated - */ - public File resolveFile( String fileName, File rootDir ) - { - return fileUtils.resolveFile( rootDir, fileName ); - } - - public File resolveFile( String fileName ) - { - return fileUtils.resolveFile( baseDir, fileName ); - } - /** * send build finished event to the listeners * @@ -1335,7 +1100,7 @@ public class Project event.setException( exception ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.buildFinished( event ); } } @@ -1348,7 +1113,7 @@ public class Project BuildEvent event = new BuildEvent( this ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.buildStarted( event ); } } @@ -1383,12 +1148,11 @@ public class Project event.setException( exception ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.targetFinished( event ); } } - /** * send target started event to the listeners * @@ -1399,7 +1163,7 @@ public class Project BuildEvent event = new BuildEvent( target ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.targetStarted( event ); } } @@ -1413,7 +1177,7 @@ public class Project event.setException( exception ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.taskFinished( event ); } } @@ -1425,7 +1189,7 @@ public class Project BuildEvent event = new BuildEvent( task ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.taskStarted( event ); } } @@ -1455,7 +1219,7 @@ public class Project // exactly the target names in "state" that are in the VISITING state.) // 1. Set the current target to the VISITING state, and push it onto // the "visiting" stack. - // 2. Throw a BuildException if any child of the current node is + // 2. Throw a TaskException if any child of the current node is // in the VISITING state (implies there is a cycle.) It uses the // "visiting" Stack to construct the cycle. // 3. If any children have not been VISITED, tsort() the child. @@ -1467,12 +1231,12 @@ public class Project private final void tsort( String root, Hashtable targets, Hashtable state, Stack visiting, Vector ret ) - throws BuildException + throws TaskException { state.put( root, VISITING ); visiting.push( root ); - Target target = ( Target )( targets.get( root ) ); + Target target = (Target)( targets.get( root ) ); // Make sure we exist if( target == null ) @@ -1483,19 +1247,19 @@ public class Project visiting.pop(); if( !visiting.empty() ) { - String parent = ( String )visiting.peek(); + String parent = (String)visiting.peek(); sb.append( "It is used from target `" ); sb.append( parent ); sb.append( "'." ); } - throw new BuildException( new String( sb ) ); + throw new TaskException( new String( sb ) ); } - for( Enumeration en = target.getDependencies(); en.hasMoreElements(); ) + for( Enumeration en = target.getDependencies(); en.hasMoreElements(); ) { - String cur = ( String )en.nextElement(); - String m = ( String )state.get( cur ); + String cur = (String)en.nextElement(); + String m = (String)state.get( cur ); if( m == null ) { // Not been visited @@ -1508,7 +1272,7 @@ public class Project } } - String p = ( String )visiting.pop(); + String p = (String)visiting.pop(); if( root != p ) { throw new RuntimeException( "Unexpected internal error: expected to pop " + root + " but got " + p ); @@ -1528,7 +1292,7 @@ public class Project { synchronized( createdTasks ) { - Vector v = ( Vector )createdTasks.get( type ); + Vector v = (Vector)createdTasks.get( type ); if( v == null ) { v = new Vector(); @@ -1543,7 +1307,7 @@ public class Project event.setMessage( message, priority ); for( int i = 0; i < listeners.size(); i++ ) { - BuildListener listener = ( BuildListener )listeners.elementAt( i ); + BuildListener listener = (BuildListener)listeners.elementAt( i ); listener.messageLogged( event ); } } @@ -1558,13 +1322,13 @@ public class Project { synchronized( createdTasks ) { - Vector v = ( Vector )createdTasks.get( type ); + Vector v = (Vector)createdTasks.get( type ); if( v != null ) { Enumeration enum = v.elements(); while( enum.hasMoreElements() ) { - Task t = ( Task )enum.nextElement(); + Task t = (Task)enum.nextElement(); t.markInvalid(); } v.removeAllElements(); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/ProjectComponent.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/ProjectComponent.java index c7ddf7f96..f8fd3320a 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/ProjectComponent.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/ProjectComponent.java @@ -8,6 +8,8 @@ package org.apache.tools.ant; import org.apache.myrmidon.api.AbstractTask; +import org.apache.tools.ant.util.FileUtils; +import java.io.File; /** * Base class for components of a project, including tasks and data types. @@ -43,6 +45,11 @@ public abstract class ProjectComponent return project; } + protected File resolveFile( final String name ) + { + return FileUtils.newFileUtils().resolveFile( project.getBaseDir(), name ); + } + /** * Log a message with the default (INFO) priority. * diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/ProjectHelper.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/ProjectHelper.java index 896a0d8f8..9e55dc561 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/ProjectHelper.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/ProjectHelper.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -17,6 +18,8 @@ import java.util.Vector; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import org.apache.myrmidon.api.TaskException; +import org.apache.tools.ant.util.FileUtils; import org.xml.sax.AttributeList; import org.xml.sax.DocumentHandler; import org.xml.sax.HandlerBase; @@ -64,10 +67,10 @@ public class ProjectHelper * @param buf The feature to be added to the Text attribute * @param start The feature to be added to the Text attribute * @param end The feature to be added to the Text attribute - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public static void addText( Project project, Object target, char[] buf, int start, int end ) - throws BuildException + throws TaskException { addText( project, target, new String( buf, start, end ) ); } @@ -78,10 +81,10 @@ public class ProjectHelper * @param project The feature to be added to the Text attribute * @param target The feature to be added to the Text attribute * @param text The feature to be added to the Text attribute - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public static void addText( Project project, Object target, String text ) - throws BuildException + throws TaskException { if( text == null || text.trim().length() == 0 ) @@ -90,17 +93,17 @@ public class ProjectHelper } if( target instanceof TaskAdapter ) - target = ( ( TaskAdapter )target ).getProxy(); + target = ( (TaskAdapter)target ).getProxy(); IntrospectionHelper.getHelper( target.getClass() ).addText( project, target, text ); } public static void configure( Object target, AttributeList attrs, Project project ) - throws BuildException + throws TaskException { if( target instanceof TaskAdapter ) - target = ( ( TaskAdapter )target ).getProxy(); + target = ( (TaskAdapter)target ).getProxy(); IntrospectionHelper ih = IntrospectionHelper.getHelper( target.getClass() ); @@ -111,14 +114,14 @@ public class ProjectHelper { // reflect these into the target String value = replaceProperties( project, attrs.getValue( i ), - project.getProperties() ); + project.getProperties() ); try { ih.setAttribute( project, target, - attrs.getName( i ).toLowerCase( Locale.US ), value ); + attrs.getName( i ).toLowerCase( Locale.US ), value ); } - catch( BuildException be ) + catch( TaskException be ) { // id attribute must be set externally if( !attrs.getName( i ).equals( "id" ) ) @@ -134,10 +137,10 @@ public class ProjectHelper * * @param project Description of Parameter * @param buildFile Description of Parameter - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public static void configureProject( Project project, File buildFile ) - throws BuildException + throws TaskException { new ProjectHelper( project, buildFile ).parse(); } @@ -151,10 +154,10 @@ public class ProjectHelper * @param value Description of Parameter * @param fragments Description of Parameter * @param propertyRefs Description of Parameter - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public static void parsePropertyString( String value, Vector fragments, Vector propertyRefs ) - throws BuildException + throws TaskException { int prev = 0; int pos; @@ -180,8 +183,8 @@ public class ProjectHelper int endName = value.indexOf( '}', pos ); if( endName < 0 ) { - throw new BuildException( "Syntax error in property: " - + value ); + throw new TaskException( "Syntax error in property: " + + value ); } String propertyName = value.substring( pos + 2, endName ); fragments.addElement( null ); @@ -203,11 +206,11 @@ public class ProjectHelper * @param value the string to be scanned for property references. * @param project Description of Parameter * @return Description of the Returned Value - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception * @since 1.5 */ public static String replaceProperties( Project project, String value ) - throws BuildException + throws TaskException { return replaceProperties( project, value, project.getProperties() ); } @@ -220,10 +223,10 @@ public class ProjectHelper * @param project Description of Parameter * @param keys Description of Parameter * @return Description of the Returned Value - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public static String replaceProperties( Project project, String value, Hashtable keys ) - throws BuildException + throws TaskException { if( value == null ) { @@ -239,16 +242,16 @@ public class ProjectHelper Enumeration j = propertyRefs.elements(); while( i.hasMoreElements() ) { - String fragment = ( String )i.nextElement(); + String fragment = (String)i.nextElement(); if( fragment == null ) { - String propertyName = ( String )j.nextElement(); + String propertyName = (String)j.nextElement(); if( !keys.containsKey( propertyName ) ) { project.log( "Property ${" + propertyName + "} has not been set", Project.MSG_VERBOSE ); } - fragment = ( keys.containsKey( propertyName ) ) ? ( String )keys.get( propertyName ) - : "${" + propertyName + "}"; + fragment = ( keys.containsKey( propertyName ) ) ? (String)keys.get( propertyName ) + : "${" + propertyName + "}"; } sb.append( fragment ); } @@ -265,6 +268,7 @@ public class ProjectHelper * @param tag Description of Parameter */ public static void storeChild( Project project, Object parent, Object child, String tag ) + throws TaskException { IntrospectionHelper ih = IntrospectionHelper.getHelper( parent.getClass() ); ih.storeElement( project, parent, child, tag ); @@ -302,10 +306,10 @@ public class ProjectHelper /** * Parses the project file. * - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ private void parse() - throws BuildException + throws TaskException { FileInputStream inputStream = null; InputSource inputSource = null; @@ -329,7 +333,7 @@ public class ProjectHelper } catch( ParserConfigurationException exc ) { - throw new BuildException( "Parser has not been configured correctly", exc ); + throw new TaskException( "Parser has not been configured correctly", exc ); } catch( SAXParseException exc ) { @@ -339,7 +343,7 @@ public class ProjectHelper Throwable t = exc.getException(); if( t instanceof BuildException ) { - BuildException be = ( BuildException )t; + BuildException be = (BuildException)t; if( be.getLocation() == Location.UNKNOWN_LOCATION ) { be.setLocation( location ); @@ -347,24 +351,24 @@ public class ProjectHelper throw be; } - throw new BuildException( exc.getMessage(), t, location ); + throw new BuildException( exc.getMessage(), t ); } catch( SAXException exc ) { Throwable t = exc.getException(); - if( t instanceof BuildException ) + if( t instanceof TaskException ) { - throw ( BuildException )t; + throw (TaskException)t; } - throw new BuildException( exc.getMessage(), t ); + throw new TaskException( exc.getMessage(), t ); } catch( FileNotFoundException exc ) { - throw new BuildException( exc ); + throw new TaskException( "Error", exc ); } catch( IOException exc ) { - throw new BuildException( "Error reading project file", exc ); + throw new TaskException( "Error reading project file", exc ); } finally { @@ -434,7 +438,9 @@ public class ProjectHelper * Called when this element and all elements nested into it have been * handled. */ - protected void finished() { } + protected void finished() + { + } } /** @@ -466,21 +472,21 @@ public class ProjectHelper { addText( project, element, buf, start, end ); } - catch( BuildException exc ) + catch( TaskException exc ) { throw new SAXParseException( exc.getMessage(), locator, exc ); } } public void init( String propType, AttributeList attrs ) - throws SAXParseException + throws SAXParseException, TaskException { try { element = project.createDataType( propType ); if( element == null ) { - throw new BuildException( "Unknown data type " + propType ); + throw new TaskException( "Unknown data type " + propType ); } if( target != null ) @@ -495,7 +501,7 @@ public class ProjectHelper configureId( element, attrs ); } } - catch( BuildException exc ) + catch( TaskException exc ) { throw new SAXParseException( exc.getMessage(), locator, exc ); } @@ -530,7 +536,7 @@ public class ProjectHelper if( parent instanceof TaskAdapter ) { - this.parent = ( ( TaskAdapter )parent ).getProxy(); + this.parent = ( (TaskAdapter)parent ).getProxy(); } else { @@ -549,7 +555,7 @@ public class ProjectHelper { addText( project, child, buf, start, end ); } - catch( BuildException exc ) + catch( TaskException exc ) { throw new SAXParseException( exc.getMessage(), locator, exc ); } @@ -574,7 +580,7 @@ public class ProjectHelper { UnknownElement uc = new UnknownElement( elementName ); uc.setProject( project ); - ( ( UnknownElement )parent ).addChild( uc ); + ( (UnknownElement)parent ).addChild( uc ); child = uc; } else @@ -596,7 +602,7 @@ public class ProjectHelper ih.storeElement( project, parent, child, elementName ); } } - catch( BuildException exc ) + catch( TaskException exc ) { throw new SAXParseException( exc.getMessage(), locator, exc ); } @@ -609,7 +615,7 @@ public class ProjectHelper { // taskcontainer nested element can contain other tasks - no other // nested elements possible - new TaskHandler( this, ( TaskContainer )child, childWrapper, target ).init( name, attrs ); + new TaskHandler( this, (TaskContainer)child, childWrapper, target ).init( name, attrs ); } else { @@ -631,7 +637,7 @@ public class ProjectHelper } public void init( String tag, AttributeList attrs ) - throws SAXParseException + throws SAXParseException, TaskException { String def = null; String name = null; @@ -668,10 +674,10 @@ public class ProjectHelper if( def == null ) { throw new SAXParseException( "The default attribute of project is required", - locator ); + locator ); } - project.setDefaultTarget( def ); + project.setDefault( def ); if( name != null ) { @@ -701,7 +707,7 @@ public class ProjectHelper } else { - project.setBaseDir( project.resolveFile( baseDir, buildFileParent ) ); + project.setBaseDir( FileUtils.newFileUtils().resolveFile( buildFileParent, baseDir ) ); } } } @@ -833,7 +839,7 @@ public class ProjectHelper catch( FileNotFoundException fne ) { project.log( file.getAbsolutePath() + " could not be found", - Project.MSG_WARN ); + Project.MSG_WARN ); } } // use default if not file or file not found @@ -980,7 +986,7 @@ public class ProjectHelper { addText( project, task, buf, start, end ); } - catch( BuildException exc ) + catch( TaskException exc ) { throw new SAXParseException( exc.getMessage(), locator, exc ); } @@ -998,7 +1004,7 @@ public class ProjectHelper { task = project.createTask( tag ); } - catch( BuildException e ) + catch( TaskException e ) { // swallow here, will be thrown again in // UnknownElement.maybeConfigure if the problem persists. @@ -1041,7 +1047,7 @@ public class ProjectHelper if( task instanceof TaskContainer ) { // task can contain other tasks - no other nested elements possible - new TaskHandler( this, ( TaskContainer )task, wrapper, target ).init( name, attrs ); + new TaskHandler( this, (TaskContainer)task, wrapper, target ).init( name, attrs ); } else { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/RuntimeConfigurable.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/RuntimeConfigurable.java index 4acd55108..e55ad54c9 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/RuntimeConfigurable.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/RuntimeConfigurable.java @@ -11,6 +11,7 @@ import java.util.Locale; import java.util.Vector; import org.xml.sax.AttributeList; import org.xml.sax.helpers.AttributeListImpl; +import org.apache.myrmidon.api.TaskException; /** * Wrapper class that holds the attributes of a Task (or elements nested below @@ -102,7 +103,7 @@ public class RuntimeConfigurable * @exception BuildException Description of Exception */ public void maybeConfigure( Project p ) - throws BuildException + throws TaskException { String id = null; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/Target.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/Target.java index 78cb4f980..38b0cac3e 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/Target.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/Target.java @@ -6,9 +6,11 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.util.Enumeration; import java.util.StringTokenizer; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; /** * This class implements a target object with required parameters. @@ -28,6 +30,7 @@ public class Target implements TaskContainer private Project project; public void setDepends( String depS ) + throws TaskException { if( depS.length() > 0 ) { @@ -40,9 +43,9 @@ public class Target implements TaskContainer //Make sure the dependency is not empty string if( token.equals( "" ) || token.equals( "," ) ) { - throw new BuildException( "Syntax Error: Depend attribute " + - "for target \"" + getName() + - "\" has an empty string for dependency." ); + throw new TaskException( "Syntax Error: Depend attribute " + + "for target \"" + getName() + + "\" has an empty string for dependency." ); } addDependency( token ); @@ -54,9 +57,9 @@ public class Target implements TaskContainer token = tok.nextToken(); if( !tok.hasMoreTokens() || !token.equals( "," ) ) { - throw new BuildException( "Syntax Error: Depend attribute " + - "for target \"" + getName() + - "\" ends with a , character" ); + throw new TaskException( "Syntax Error: Depend attribute " + + "for target \"" + getName() + + "\" ends with a , character" ); } } } @@ -126,7 +129,7 @@ public class Target implements TaskContainer } } - Task[] retval = new Task[tasks.size()]; + Task[] retval = new Task[ tasks.size() ]; tasks.copyInto( retval ); return retval; } @@ -139,6 +142,10 @@ public class Target implements TaskContainer execute(); project.fireTargetFinished( this, null ); } + catch( final TaskException te ) + { + project.fireTargetFinished( this, te ); + } catch( RuntimeException exc ) { project.fireTargetFinished( this, exc ); @@ -162,7 +169,7 @@ public class Target implements TaskContainer } public void execute() - throws BuildException + throws TaskException { if( testIfCondition() && testUnlessCondition() ) { @@ -172,12 +179,12 @@ public class Target implements TaskContainer Object o = enum.nextElement(); if( o instanceof Task ) { - Task task = ( Task )o; + Task task = (Task)o; task.perform(); } else { - RuntimeConfigurable r = ( RuntimeConfigurable )o; + RuntimeConfigurable r = (RuntimeConfigurable)o; r.maybeConfigure( project ); } } @@ -185,12 +192,12 @@ public class Target implements TaskContainer else if( !testIfCondition() ) { project.log( this, "Skipped because property '" + this.ifCondition + "' not set.", - Project.MSG_VERBOSE ); + Project.MSG_VERBOSE ); } else { project.log( this, "Skipped because property '" + this.unlessCondition + "' set.", - Project.MSG_VERBOSE ); + Project.MSG_VERBOSE ); } } @@ -209,6 +216,7 @@ public class Target implements TaskContainer } private boolean testIfCondition() + throws TaskException { if( "".equals( ifCondition ) ) { @@ -220,6 +228,7 @@ public class Target implements TaskContainer } private boolean testUnlessCondition() + throws TaskException { if( "".equals( unlessCondition ) ) { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/Task.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/Task.java index 7a08963ea..d0c6d3c8d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/Task.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/Task.java @@ -7,7 +7,9 @@ */ package org.apache.tools.ant; +import java.io.File; import org.apache.myrmidon.api.TaskException; +import org.apache.tools.ant.util.FileUtils; public abstract class Task extends ProjectComponent diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/TaskAdapter.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/TaskAdapter.java index 6f7ebcbf1..4cc0b1a97 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/TaskAdapter.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/TaskAdapter.java @@ -8,6 +8,7 @@ package org.apache.tools.ant; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import org.apache.myrmidon.api.TaskException; /** @@ -33,6 +34,7 @@ public class TaskAdapter extends Task * @param project Description of Parameter */ public static void checkTaskClass( final Class taskClass, final Project project ) + throws TaskException { // don't have to check for interface, since then // taskClass would be abstract too. @@ -53,7 +55,7 @@ public class TaskAdapter extends Task { final String message = "No public execute() in " + taskClass; project.log( message, Project.MSG_ERR ); - throw new BuildException( message ); + throw new TaskException( message ); } } @@ -100,7 +102,7 @@ public class TaskAdapter extends Task { log( "Error setting project in " + proxy.getClass(), Project.MSG_ERR ); - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } Method executeM = null; @@ -111,7 +113,7 @@ public class TaskAdapter extends Task if( executeM == null ) { log( "No public execute() in " + proxy.getClass(), Project.MSG_ERR ); - throw new BuildException( "No public execute() in " + proxy.getClass() ); + throw new TaskException( "No public execute() in " + proxy.getClass() ); } executeM.invoke( proxy, null ); return; @@ -119,7 +121,7 @@ public class TaskAdapter extends Task catch( Exception ex ) { log( "Error in " + proxy.getClass(), Project.MSG_ERR ); - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/UnknownElement.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/UnknownElement.java index efe3b6046..69f21d197 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/UnknownElement.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/UnknownElement.java @@ -6,7 +6,9 @@ * the LICENSE file. */ package org.apache.tools.ant; + import java.util.Vector; +import org.apache.myrmidon.api.TaskException; /** * Wrapper class that holds all information necessary to create a task or data @@ -57,7 +59,7 @@ public class UnknownElement extends Task { if( realThing != null && realThing instanceof Task ) { - return ( Task )realThing; + return (Task)realThing; } return null; } @@ -70,7 +72,7 @@ public class UnknownElement extends Task public String getTaskName() { return realThing == null || !( realThing instanceof Task ) ? - super.getTaskName() : ( ( Task )realThing ).getTaskName(); + super.getTaskName() : ( (Task)realThing ).getTaskName(); } /** @@ -87,18 +89,19 @@ public class UnknownElement extends Task * Called when the real task has been configured for the first time. */ public void execute() + throws TaskException { if( realThing == null ) { // plain impossible to get here, maybeConfigure should // have thrown an exception. - throw new BuildException( "Could not create task of type: " - + elementName, location ); + throw new TaskException( "Could not create task of type: " + + elementName ); } if( realThing instanceof Task ) { - ( ( Task )realThing ).perform(); + ( (Task)realThing ).perform(); } } @@ -109,14 +112,14 @@ public class UnknownElement extends Task * @exception BuildException Description of Exception */ public void maybeConfigure() - throws BuildException + throws TaskException { realThing = makeObject( this, wrapper ); wrapper.setProxy( realThing ); if( realThing instanceof Task ) { - ( ( Task )realThing ).setRuntimeConfigurableWrapper( wrapper ); + ( (Task)realThing ).setRuntimeConfigurableWrapper( wrapper ); } handleChildren( realThing, wrapper ); @@ -137,19 +140,19 @@ public class UnknownElement extends Task { String lSep = System.getProperty( "line.separator" ); String msg = "Could not create " + what + " of type: " + elementName - + "." + lSep - + "Ant could not find the task or a class this" + lSep - + "task relies upon." + lSep - + "Common solutions are to use taskdef to declare" + lSep - + "your task, or, if this is an optional task," + lSep - + "to put the optional.jar and all required libraries of" + lSep - + "this task in the lib directory of" + lSep - + "your ant installation (ANT_HOME)." + lSep - + "There is also the possibility that your build file " + lSep - + "is written to work with a more recent version of ant " + lSep - + "than the one you are using, in which case you have to " + lSep - + "upgrade."; - return new BuildException( msg, location ); + + "." + lSep + + "Ant could not find the task or a class this" + lSep + + "task relies upon." + lSep + + "Common solutions are to use taskdef to declare" + lSep + + "your task, or, if this is an optional task," + lSep + + "to put the optional.jar and all required libraries of" + lSep + + "this task in the lib directory of" + lSep + + "your ant installation (ANT_HOME)." + lSep + + "There is also the possibility that your build file " + lSep + + "is written to work with a more recent version of ant " + lSep + + "than the one you are using, in which case you have to " + lSep + + "upgrade."; + return new BuildException( msg ); } /** @@ -162,12 +165,12 @@ public class UnknownElement extends Task */ protected void handleChildren( Object parent, RuntimeConfigurable parentWrapper ) - throws BuildException + throws TaskException { if( parent instanceof TaskAdapter ) { - parent = ( ( TaskAdapter )parent ).getProxy(); + parent = ( (TaskAdapter)parent ).getProxy(); } Class parentClass = parent.getClass(); @@ -176,13 +179,13 @@ public class UnknownElement extends Task for( int i = 0; i < children.size(); i++ ) { RuntimeConfigurable childWrapper = parentWrapper.getChild( i ); - UnknownElement child = ( UnknownElement )children.elementAt( i ); + UnknownElement child = (UnknownElement)children.elementAt( i ); Object realChild = null; if( parent instanceof TaskContainer ) { realChild = makeTask( child, childWrapper, false ); - ( ( TaskContainer )parent ).addTask( ( Task )realChild ); + ( (TaskContainer)parent ).addTask( (Task)realChild ); } else { @@ -192,14 +195,14 @@ public class UnknownElement extends Task childWrapper.setProxy( realChild ); if( parent instanceof TaskContainer ) { - ( ( Task )realChild ).setRuntimeConfigurableWrapper( childWrapper ); + ( (Task)realChild ).setRuntimeConfigurableWrapper( childWrapper ); } child.handleChildren( realChild, childWrapper ); if( parent instanceof TaskContainer ) { - ( ( Task )realChild ).maybeConfigure(); + ( (Task)realChild ).maybeConfigure(); } } } @@ -213,6 +216,7 @@ public class UnknownElement extends Task * @return Description of the Returned Value */ protected Object makeObject( UnknownElement ue, RuntimeConfigurable w ) + throws TaskException { Object o = makeTask( ue, w, true ); if( o == null ) @@ -236,6 +240,7 @@ public class UnknownElement extends Task */ protected Task makeTask( UnknownElement ue, RuntimeConfigurable w, boolean onTopLevel ) + throws TaskException { Task task = project.createTask( ue.getTag() ); if( task == null && !onTopLevel ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Ant.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Ant.java index 937f44cd2..155526136 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Ant.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Ant.java @@ -22,6 +22,7 @@ import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.Task; import org.apache.tools.ant.util.FileUtils; +import org.apache.myrmidon.api.TaskException; /** * Call Ant in a sub-project@@ -178,10 +179,10 @@ public class Ant extends Task /** * Do the execution. * - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ public void execute() - throws BuildException + throws TaskException { try { @@ -234,7 +235,7 @@ public class Ant extends Task target.equals( this.getOwningTarget().getName() ) ) { - throw new BuildException( "ant task calling its own parent target" ); + throw new TaskException( "ant task calling its own parent target" ); } newProject.executeTarget( target ); @@ -283,10 +284,10 @@ public class Ant extends Task * project. Also copy over all references that don't override existing * references in the new project if inheritall has been requested. * - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ private void addReferences() - throws BuildException + throws TaskException { Hashtable thisReferences = ( Hashtable )project.getReferences().clone(); Hashtable newReferences = newProject.getReferences(); @@ -299,7 +300,7 @@ public class Ant extends Task String refid = ref.getRefId(); if( refid == null ) { - throw new BuildException( "the refid attribute is required for reference elements" ); + throw new TaskException( "the refid attribute is required for reference elements" ); } if( !thisReferences.containsKey( refid ) ) { @@ -387,7 +388,7 @@ public class Ant extends Task { String msg = "Error setting new project instance for reference with id " + oldKey; - throw new BuildException( msg, e2, location ); + throw new TaskException( msg, e2, location ); } } newProject.addReference( newKey, copy ); @@ -482,10 +483,10 @@ public class Ant extends Task * Override the properties in the new project with the one explicitly * defined as nested elements here. * - * @exception BuildException Description of Exception + * @exception TaskException Description of Exception */ private void overrideProperties() - throws BuildException + throws TaskException { Enumeration e = properties.elements(); while( e.hasMoreElements() ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/AntStructure.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/AntStructure.java index 1b1007267..39416e5a4 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/AntStructure.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/AntStructure.java @@ -58,7 +58,7 @@ public class AntStructure extends Task if( output == null ) { - throw new BuildException( "output attribute is required", location ); + throw new BuildException( "output attribute is required" ); } PrintWriter out = null; @@ -106,7 +106,7 @@ public class AntStructure extends Task catch( IOException ioe ) { throw new BuildException( "Error writing " + output.getAbsolutePath(), - ioe, location ); + ioe ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Available.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Available.java index a4396a6a0..94c6e8c5a 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Available.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Available.java @@ -16,6 +16,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.util.FileUtils; +import org.apache.myrmidon.api.TaskException; /** * Will set the given property if the requested resource is available at @@ -26,7 +27,9 @@ import org.apache.tools.ant.util.FileUtils; * @author Magesh Umasankar */ -public class Available extends Task implements Condition +public class Available + extends Task + implements Condition { private String value = "true"; private String classname; @@ -77,22 +80,8 @@ public class Available extends Task implements Condition this.resource = resource; } - /** - * @param type The new Type value - * @deprecated setType(String) is deprecated and is replaced with - * setType(Available.FileDir) to make Ant's Introspection mechanism do - * the work and also to encapsulate operations on the type in its own - * class. - */ - public void setType( String type ) - { - log( "DEPRECATED - The setType(String) method has been deprecated." - + " Use setType(Available.FileDir) instead." ); - this.type = new FileDir(); - this.type.setValue( type ); - } - public void setType( FileDir type ) + public void setType( FileDir type ) { this.type = type; } @@ -121,18 +110,18 @@ public class Available extends Task implements Condition } public boolean eval() - throws BuildException + throws TaskException { if( classname == null && file == null && resource == null ) { - throw new BuildException( "At least one of (classname|file|resource) is required", location ); + throw new BuildException( "At least one of (classname|file|resource) is required" ); } if( type != null ) { if( file == null ) { - throw new BuildException( "The type attribute is only valid when specifying the file attribute." ); + throw new TaskException( "The type attribute is only valid when specifying the file attribute." ); } } @@ -176,24 +165,21 @@ public class Available extends Task implements Condition } public void execute() - throws BuildException + throws TaskException { if( property == null ) { - throw new BuildException( "property attribute is required", location ); + throw new BuildException( "property attribute is required"); } if( eval() ) { String lSep = System.getProperty( "line.separator" ); - if( null != project.getProperty( property ) ) + if( null == project.getProperty( property ) ) { - log( "DEPRECATED -used to overide an existing property. " - + lSep - + " Build writer should not reuse the same property name for " - + lSep + "different values." ); + this.project.setProperty( property, value ); } - this.project.setProperty( property, value ); + //else ignore } } @@ -235,7 +221,7 @@ public class Available extends Task implements Condition { if( filepath == null ) { - return checkFile( project.resolveFile( file ), file ); + return checkFile( resolveFile( file ), file ); } else { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/BUnzip2.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/BUnzip2.java index 882af9655..3b2dc6fdf 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/BUnzip2.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/BUnzip2.java @@ -49,12 +49,12 @@ public class BUnzip2 extends Unpack int b = bis.read(); if( b != 'B' ) { - throw new BuildException( "Invalid bz2 file.", location ); + throw new BuildException( "Invalid bz2 file." ); } b = bis.read(); if( b != 'Z' ) { - throw new BuildException( "Invalid bz2 file.", location ); + throw new BuildException( "Invalid bz2 file." ); } zIn = new CBZip2InputStream( bis ); byte[] buffer = new byte[8 * 1024]; @@ -68,7 +68,7 @@ public class BUnzip2 extends Unpack catch( IOException ioe ) { String msg = "Problem expanding bzip2 " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/BZip2.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/BZip2.java index 9c3cdc401..be8635f3f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/BZip2.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/BZip2.java @@ -37,7 +37,7 @@ public class BZip2 extends Pack catch( IOException ioe ) { String msg = "Problem creating bzip2 " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/CVSPass.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/CVSPass.java index 356579a4a..44b7ed617 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/CVSPass.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/CVSPass.java @@ -14,6 +14,7 @@ import java.io.IOException; import java.io.PrintWriter; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; +import org.apache.myrmidon.api.TaskException; /** * CVSLogin Adds an new entry to a CVS password file @@ -105,9 +106,9 @@ public class CVSPass extends Task throws BuildException { if( cvsRoot == null ) - throw new BuildException( "cvsroot is required" ); + throw new TaskException( "cvsroot is required" ); if( password == null ) - throw new BuildException( "password is required" ); + throw new TaskException( "password is required" ); log( "cvsRoot: " + cvsRoot, project.MSG_DEBUG ); log( "password: " + password, project.MSG_DEBUG ); @@ -147,7 +148,7 @@ public class CVSPass extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/CallTarget.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/CallTarget.java index 80f570e08..3fdb80063 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/CallTarget.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/CallTarget.java @@ -77,8 +77,7 @@ public class CallTarget extends Task if( subTarget == null ) { - throw new BuildException( "Attribute target is required.", - location ); + throw new BuildException( "Attribute target is required." ); } callee.setDir( project.getBaseDir() ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Checksum.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Checksum.java index a778428c5..e9b444d54 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Checksum.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Checksum.java @@ -25,6 +25,7 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.taskdefs.condition.Condition; import org.apache.tools.ant.types.FileSet; +import org.apache.myrmidon.api.TaskException; /** * This task can be used to create checksums for files. It can also be used to @@ -231,7 +232,7 @@ public class Checksum extends MatchingTask implements Condition + file.getAbsolutePath() + " to generate checksum for."; log( message ); - throw new BuildException( message, location ); + throw new BuildException( message ); } } } @@ -328,7 +329,7 @@ public class Checksum extends MatchingTask implements Condition } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { @@ -366,19 +367,19 @@ public class Checksum extends MatchingTask implements Condition if( file == null && filesets.size() == 0 ) { - throw new BuildException( + throw new TaskException( "Specify at least one source - a file or a fileset." ); } if( file != null && file.exists() && file.isDirectory() ) { - throw new BuildException( + throw new TaskException( "Checksum cannot be generated for directories" ); } if( property != null && fileext != null ) { - throw new BuildException( + throw new TaskException( "Property and FileExt cannot co-exist." ); } @@ -386,7 +387,7 @@ public class Checksum extends MatchingTask implements Condition { if( forceOverwrite ) { - throw new BuildException( + throw new TaskException( "ForceOverwrite cannot be used when Property is specified" ); } @@ -394,7 +395,7 @@ public class Checksum extends MatchingTask implements Condition { if( filesets.size() > 0 ) { - throw new BuildException( + throw new TaskException( "Multiple files cannot be used when Property is specified" ); } } @@ -402,7 +403,7 @@ public class Checksum extends MatchingTask implements Condition { if( filesets.size() > 1 ) { - throw new BuildException( + throw new TaskException( "Multiple files cannot be used when Property is specified" ); } } @@ -415,13 +416,13 @@ public class Checksum extends MatchingTask implements Condition if( verifyProperty != null && forceOverwrite ) { - throw new BuildException( + throw new TaskException( "VerifyProperty and ForceOverwrite cannot co-exist." ); } if( isCondition && forceOverwrite ) { - throw new BuildException( + throw new TaskException( "ForceOverwrite cannot be used when conditions are being used." ); } @@ -431,7 +432,7 @@ public class Checksum extends MatchingTask implements Condition } else if( fileext.trim().length() == 0 ) { - throw new BuildException( + throw new TaskException( "File extension when specified must not be an empty string" ); } @@ -444,11 +445,11 @@ public class Checksum extends MatchingTask implements Condition } catch( NoSuchAlgorithmException noalgo ) { - throw new BuildException( noalgo ); + throw new TaskException( noalgo.toString(), noalgo ); } catch( NoSuchProviderException noprovider ) { - throw new BuildException( noprovider ); + throw new TaskException( noprovider.toString(), noprovider ); } } else @@ -459,14 +460,13 @@ public class Checksum extends MatchingTask implements Condition } catch( NoSuchAlgorithmException noalgo ) { - throw new BuildException( noalgo ); + throw new TaskException( noalgo.toString(), noalgo ); } } if( messageDigest == null ) { - throw new BuildException( "Unable to create Message Digest", - location ); + throw new BuildException( "Unable to create Message Digest" ); } addToIncludeFileMap( file ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Chmod.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Chmod.java index 96f736e03..6df33d6bd 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Chmod.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Chmod.java @@ -40,7 +40,7 @@ public class Chmod extends ExecuteOn public void setCommand( String e ) { - throw new BuildException( taskType + " doesn\'t support the command attribute", location ); + throw new BuildException( taskType + " doesn\'t support the command attribute" ); } /** @@ -75,7 +75,7 @@ public class Chmod extends ExecuteOn public void setExecutable( String e ) { - throw new BuildException( taskType + " doesn\'t support the executable attribute", location ); + throw new BuildException( taskType + " doesn\'t support the executable attribute" ); } public void setFile( File src ) @@ -106,7 +106,7 @@ public class Chmod extends ExecuteOn public void setSkipEmptyFilesets( boolean skip ) { - throw new BuildException( taskType + " doesn\'t support the skipemptyfileset attribute", location ); + throw new BuildException( taskType + " doesn\'t support the skipemptyfileset attribute" ); } /** @@ -161,7 +161,7 @@ public class Chmod extends ExecuteOn } catch( IOException e ) { - throw new BuildException( "Execute failed: " + e, e, location ); + throw new BuildException( "Execute failed: " + e, e ); } finally { @@ -180,8 +180,7 @@ public class Chmod extends ExecuteOn { if( !havePerm ) { - throw new BuildException( "Required attribute perm not set in chmod", - location ); + throw new BuildException( "Required attribute perm not set in chmod" ); } if( defaultSetDefined && defaultSet.getDir( project ) != null ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ConditionTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ConditionTask.java index da72ebc93..db05c6075 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ConditionTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ConditionTask.java @@ -9,6 +9,7 @@ package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.condition.Condition; import org.apache.tools.ant.taskdefs.condition.ConditionBase; +import org.apache.myrmidon.api.TaskException; /** * <condition> task as a generalization of <available> and @@ -57,15 +58,15 @@ public class ConditionTask extends ConditionBase * @since 1.1 */ public void execute() - throws BuildException + throws TaskException { if( countConditions() > 1 ) { - throw new BuildException( "You must not nest more than one condition into " ); + throw new TaskException( "You must not nest more than one condition into " ); } if( countConditions() < 1 ) { - throw new BuildException( "You must nest a condition into " ); + throw new TaskException( "You must nest a condition into " ); } Condition c = ( Condition )getConditions().nextElement(); if( c.eval() ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Copy.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Copy.java index 055c978fd..ba97365c5 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Copy.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Copy.java @@ -6,11 +6,13 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.File; import java.io.IOException; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; @@ -120,19 +122,6 @@ public class Copy extends Task this.forceOverwrite = overwrite; } - /** - * Give the copied files the same last modified time as the original files. - * - * @param preserve The new PreserveLastModified value - * @deprecated setPreserveLastModified(String) has been deprecated and - * replaced with setPreserveLastModified(boolean) to consistently let - * the Introspection mechanism work. - */ - public void setPreserveLastModified( String preserve ) - { - setPreserveLastModified( Project.toBoolean( preserve ) ); - } - /** * Give the copied files the same last modified time as the original files. * @@ -213,8 +202,7 @@ public class Copy extends Task { if( mapperElement != null ) { - throw new BuildException( "Cannot define more than one mapper", - location ); + throw new BuildException( "Cannot define more than one mapper" ); } mapperElement = new Mapper( project ); return mapperElement; @@ -226,7 +214,7 @@ public class Copy extends Task * @exception BuildException Description of Exception */ public void execute() - throws BuildException + throws TaskException { // make sure we don't have an illegal set of options validateAttributes(); @@ -249,22 +237,22 @@ public class Copy extends Task else { log( file + " omitted as " + destFile + " is up to date.", - Project.MSG_VERBOSE ); + Project.MSG_VERBOSE ); } } else { String message = "Could not find file " - + file.getAbsolutePath() + " to copy."; + + file.getAbsolutePath() + " to copy."; log( message ); - throw new BuildException( message ); + throw new TaskException( message ); } } // deal with the filesets for( int i = 0; i < filesets.size(); i++ ) { - FileSet fs = ( FileSet )filesets.elementAt( i ); + FileSet fs = (FileSet)filesets.elementAt( i ); DirectoryScanner ds = fs.getDirectoryScanner( project ); File fromDir = fs.getDir( project ); @@ -272,7 +260,7 @@ public class Copy extends Task String[] srcDirs = ds.getIncludedDirectories(); boolean isEverythingIncluded = ds.isEverythingIncluded(); if( isEverythingIncluded - && !flatten && mapperElement == null ) + && !flatten && mapperElement == null ) { completeDirMap.put( fromDir, destDir ); } @@ -315,12 +303,12 @@ public class Copy extends Task Vector v = new Vector(); for( int i = 0; i < names.length; i++ ) { - if( mapper.mapFileName( names[i] ) != null ) + if( mapper.mapFileName( names[ i ] ) != null ) { - v.addElement( names[i] ); + v.addElement( names[ i ] ); } } - toCopy = new String[v.size()]; + toCopy = new String[ v.size() ]; v.copyInto( toCopy ); } else @@ -331,8 +319,8 @@ public class Copy extends Task for( int i = 0; i < toCopy.length; i++ ) { - File src = new File( fromDir, toCopy[i] ); - File dest = new File( toDir, mapper.mapFileName( toCopy[i] )[0] ); + File src = new File( fromDir, toCopy[ i ] ); + File dest = new File( toDir, mapper.mapFileName( toCopy[ i ] )[ 0 ] ); map.put( src.getAbsolutePath(), dest.getAbsolutePath() ); } } @@ -346,14 +334,14 @@ public class Copy extends Task if( fileCopyMap.size() > 0 ) { log( "Copying " + fileCopyMap.size() + - " file" + ( fileCopyMap.size() == 1 ? "" : "s" ) + - " to " + destDir.getAbsolutePath() ); + " file" + ( fileCopyMap.size() == 1 ? "" : "s" ) + + " to " + destDir.getAbsolutePath() ); Enumeration e = fileCopyMap.keys(); while( e.hasMoreElements() ) { - String fromFile = ( String )e.nextElement(); - String toFile = ( String )fileCopyMap.get( fromFile ); + String fromFile = (String)e.nextElement(); + String toFile = (String)fileCopyMap.get( fromFile ); if( fromFile.equals( toFile ) ) { @@ -370,18 +358,18 @@ public class Copy extends Task { executionFilters.addFilterSet( project.getGlobalFilterSet() ); } - for( Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements(); ) + for( Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements(); ) { - executionFilters.addFilterSet( ( FilterSet )filterEnum.nextElement() ); + executionFilters.addFilterSet( (FilterSet)filterEnum.nextElement() ); } fileUtils.copyFile( fromFile, toFile, executionFilters, - forceOverwrite, preserveLastModified ); + forceOverwrite, preserveLastModified ); } catch( IOException ioe ) { String msg = "Failed to copy " + fromFile + " to " + toFile - + " due to " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + + " due to " + ioe.getMessage(); + throw new BuildException( msg, ioe ); } } } @@ -392,7 +380,7 @@ public class Copy extends Task int count = 0; while( e.hasMoreElements() ) { - File d = new File( ( String )e.nextElement() ); + File d = new File( (String)e.nextElement() ); if( !d.exists() ) { if( !d.mkdirs() ) @@ -409,9 +397,9 @@ public class Copy extends Task if( count > 0 ) { log( "Copied " + count + - " empty director" + - ( count == 1 ? "y" : "ies" ) + - " to " + destDir.getAbsolutePath() ); + " empty director" + + ( count == 1 ? "y" : "ies" ) + + " to " + destDir.getAbsolutePath() ); } } } @@ -449,9 +437,9 @@ public class Copy extends Task } } -//************************************************************************ -// protected and private methods -//************************************************************************ + //************************************************************************ + // protected and private methods + //************************************************************************ /** * Ensure we have a consistent and legal set of attributes, and set any @@ -460,38 +448,38 @@ public class Copy extends Task * @exception BuildException Description of Exception */ protected void validateAttributes() - throws BuildException + throws TaskException { if( file == null && filesets.size() == 0 ) { - throw new BuildException( "Specify at least one source - a file or a fileset." ); + throw new TaskException( "Specify at least one source - a file or a fileset." ); } if( destFile != null && destDir != null ) { - throw new BuildException( "Only one of tofile and todir may be set." ); + throw new TaskException( "Only one of tofile and todir may be set." ); } if( destFile == null && destDir == null ) { - throw new BuildException( "One of tofile or todir must be set." ); + throw new TaskException( "One of tofile or todir must be set." ); } if( file != null && file.exists() && file.isDirectory() ) { - throw new BuildException( "Use a fileset to copy directories." ); + throw new TaskException( "Use a fileset to copy directories." ); } if( destFile != null && filesets.size() > 0 ) { if( filesets.size() > 1 ) { - throw new BuildException( + throw new TaskException( "Cannot concatenate multiple files into a single file." ); } else { - FileSet fs = ( FileSet )filesets.elementAt( 0 ); + FileSet fs = (FileSet)filesets.elementAt( 0 ); DirectoryScanner ds = fs.getDirectoryScanner( project ); String[] srcFiles = ds.getIncludedFiles(); @@ -499,18 +487,18 @@ public class Copy extends Task { if( file == null ) { - file = new File( srcFiles[0] ); + file = new File( srcFiles[ 0 ] ); filesets.removeElementAt( 0 ); } else { - throw new BuildException( + throw new TaskException( "Cannot concatenate multiple files into a single file." ); } } else { - throw new BuildException( + throw new TaskException( "Cannot perform operation from directory to file." ); } } @@ -520,7 +508,5 @@ public class Copy extends Task { destDir = new File( destFile.getParent() );// be 1.1 friendly } - } - } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Cvs.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Cvs.java index 63bda456c..371f6ca9d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Cvs.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Cvs.java @@ -6,12 +6,14 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; @@ -120,7 +122,6 @@ public class Cvs extends Task this.cvsRsh = rsh; } - public void setDate( String p ) { if( p != null && p.trim().length() > 0 ) @@ -185,9 +186,8 @@ public class Cvs extends Task } } - public void execute() - throws BuildException + throws TaskException { // XXX: we should use JCVS (www.ice.com/JCVS) instead of command line @@ -252,7 +252,7 @@ public class Cvs extends Task if( error == null && output == null ) { streamhandler = new LogStreamHandler( this, Project.MSG_INFO, - Project.MSG_WARN ); + Project.MSG_WARN ); } else { @@ -264,7 +264,7 @@ public class Cvs extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new TaskException( e.toString(), e ); } } else @@ -279,7 +279,7 @@ public class Cvs extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new TaskException( e.toString(), e ); } } else @@ -290,7 +290,7 @@ public class Cvs extends Task } Execute exe = new Execute( streamhandler, - null ); + null ); exe.setAntRun( project ); if( dest == null ) @@ -306,11 +306,11 @@ public class Cvs extends Task * Throw an exception if cvs exited with error. (Iulian) */ if( failOnError && retCode != 0 ) - throw new BuildException( "cvs exited with error code " + retCode ); + throw new TaskException( "cvs exited with error code " + retCode ); } catch( IOException e ) { - throw new BuildException( e ); + throw new TaskException( e.toString(), e ); } finally { @@ -321,7 +321,8 @@ public class Cvs extends Task outputstream.close(); } catch( IOException e ) - {} + { + } } if( error != null ) { @@ -330,7 +331,8 @@ public class Cvs extends Task errorstream.close(); } catch( IOException e ) - {} + { + } } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Definer.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Definer.java index 0186ee465..6bb9cacae 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Definer.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Definer.java @@ -72,12 +72,6 @@ public abstract class Definer extends Task this.resource = res; } - public void setReverseLoader( boolean reverseLoader ) - { - this.reverseLoader = reverseLoader; - log( "The reverseloader attribute is DEPRECATED. It will be removed", Project.MSG_WARN ); - } - public String getClassname() { return value; @@ -120,13 +114,13 @@ public abstract class Definer extends Task { String msg = "You must not specify name or value " + "together with file or resource."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( file != null && resource != null ) { String msg = "You must not specify both, file and resource."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } Properties props = new Properties(); @@ -169,7 +163,7 @@ public abstract class Definer extends Task } catch( IOException ex ) { - throw new BuildException( ex); + throw new BuildException( "Error", ex); } } } @@ -189,13 +183,13 @@ public abstract class Definer extends Task { String msg = getTaskName() + " class " + value + " cannot be found"; - throw new BuildException( msg, cnfe, location ); + throw new BuildException( msg, cnfe ); } catch( NoClassDefFoundError ncdfe ) { String msg = getTaskName() + " class " + value + " cannot be found"; - throw new BuildException( msg, ncdfe, location ); + throw new BuildException( msg, ncdfe ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Delete.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Delete.java index e7df0b543..f96f39b7d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Delete.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Delete.java @@ -242,8 +242,7 @@ public class Delete extends MatchingTask if( quiet && failonerror ) { - throw new BuildException( "quiet and failonerror cannot both be set to true", - location ); + throw new BuildException( "quiet and failonerror cannot both be set to true" ); } // delete the single file diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Ear.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Ear.java index 955cbb6ca..3456e63e8 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Ear.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Ear.java @@ -47,13 +47,6 @@ public class Ear extends Jar super.addFileset( fs ); } - public void setEarfile( File earFile ) - { - log( "DEPRECATED - The earfile attribute is deprecated. Use file attribute instead." ); - setFile( earFile ); - } - - public void addArchives( ZipFileSet fs ) { // We just set the prefix for this fileset, and pass it up. @@ -80,7 +73,7 @@ public class Ear extends Jar // If no webxml file is specified, it's an error. if( deploymentDescriptor == null && !isInUpdateMode() ) { - throw new BuildException( "appxml attribute is required", location ); + throw new BuildException( "appxml attribute is required" ); } super.initZipOutputStream( zOut ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Echo.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Echo.java index 1e57b259a..1dbd30558 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Echo.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Echo.java @@ -132,7 +132,7 @@ public class Echo extends Task } catch( IOException ioe ) { - throw new BuildException( ioe); + throw new BuildException( "Error", ioe); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecTask.java index f236d8eae..d81f23827 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecTask.java @@ -52,19 +52,6 @@ public class ExecTask extends Task private String outputprop; private String resultProperty; - /** - * The full commandline to execute, executable + arguments. - * - * @param cmdl The new Command value - */ - public void setCommand( Commandline cmdl ) - { - log( "The command attribute is deprecated. " + - "Please use the executable attribute and nested arg elements.", - Project.MSG_WARN ); - this.cmdl = cmdl; - } - /** * The working directory of the process * @@ -256,7 +243,7 @@ public class ExecTask extends Task { if( failOnError ) { - throw new BuildException( taskType + " returned: " + err, location ); + throw new BuildException( taskType + " returned: " + err ); } else { @@ -291,7 +278,7 @@ public class ExecTask extends Task { if( cmdl.getExecutable() == null ) { - throw new BuildException( "no executable specified", location ); + throw new BuildException( "no executable specified" ); } if( dir != null && !dir.exists() ) { @@ -322,11 +309,11 @@ public class ExecTask extends Task } catch( FileNotFoundException fne ) { - throw new BuildException( "Cannot write to " + out, fne, location ); + throw new BuildException( "Cannot write to " + out, fne ); } catch( IOException ioe ) { - throw new BuildException( "Cannot write to " + out, ioe, location ); + throw new BuildException( "Cannot write to " + out, ioe ); } } else if( outputprop != null ) @@ -439,7 +426,7 @@ public class ExecTask extends Task { if( failIfExecFails ) { - throw new BuildException( "Execute failed: " + e.toString(), e, location ); + throw new BuildException( "Execute failed: " + e.toString(), e ); } else { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Execute.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Execute.java index c1fdd0c72..42626602c 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Execute.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Execute.java @@ -259,12 +259,12 @@ public class Execute int retval = exe.execute(); if( retval != 0 ) { - throw new BuildException( cmdline[ 0 ] + " failed with return code " + retval, task.getLocation() ); + throw new BuildException( cmdline[ 0 ] + " failed with return code " + retval ); } } catch( java.io.IOException exc ) { - throw new BuildException( "Could not launch " + cmdline[ 0 ] + ": " + exc, task.getLocation() ); + throw new BuildException( "Could not launch " + cmdline[ 0 ] + ": " + exc ); } } @@ -806,7 +806,7 @@ public class Execute { throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); } - String antRun = project.resolveFile( antHome + File.separator + _script ).toString(); + String antRun = resolveFile( antHome + File.separator + _script ).toString(); // Build the command File commandDir = workingDir; @@ -871,7 +871,7 @@ public class Execute { throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); } - String antRun = project.resolveFile( antHome + File.separator + _script ).toString(); + String antRun = resolveFile( antHome + File.separator + _script ).toString(); // Build the command File commandDir = workingDir; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteJava.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteJava.java index 6fc077991..1c20e5ffd 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteJava.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteJava.java @@ -37,15 +37,6 @@ public class ExecuteJava this.javaCommand = javaCommand; } - /** - * All output (System.out as well as System.err) will be written to this - * Stream. - * - * @param out The new Output value - * @deprecated manage output at the task level - */ - public void setOutput( PrintStream out ) { } - public void setSystemProperties( CommandlineJava.SysProperties s ) { sysProperties = s; @@ -95,7 +86,7 @@ public class ExecuteJava Throwable t = e.getTargetException(); if( !( t instanceof SecurityException ) ) { - throw new BuildException( t ); + throw new BuildException( "Error", t ); } else { @@ -104,7 +95,7 @@ public class ExecuteJava } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteOn.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteOn.java index 0a8bd9d53..02598c18d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteOn.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/ExecuteOn.java @@ -117,8 +117,7 @@ public class ExecuteOn extends ExecTask { if( mapperElement != null ) { - throw new BuildException( "Cannot define more than one mapper", - location ); + throw new BuildException( "Cannot define more than one mapper" ); } mapperElement = new Mapper( project ); return mapperElement; @@ -134,8 +133,7 @@ public class ExecuteOn extends ExecTask { if( srcFilePos != null ) { - throw new BuildException( taskType + " doesn\'t support multiple srcfile elements.", - location ); + throw new BuildException( taskType + " doesn\'t support multiple srcfile elements." ); } srcFilePos = cmdl.createMarker(); return srcFilePos; @@ -151,8 +149,7 @@ public class ExecuteOn extends ExecTask { if( targetFilePos != null ) { - throw new BuildException( taskType + " doesn\'t support multiple targetfile elements.", - location ); + throw new BuildException( taskType + " doesn\'t support multiple targetfile elements." ); } targetFilePos = cmdl.createMarker(); srcIsFirst = ( srcFilePos != null ); @@ -345,15 +342,10 @@ public class ExecuteOn extends ExecTask protected void checkConfiguration() { - if( "execon".equals( taskName ) ) - { - log( "!! execon is deprecated. Use apply instead. !!" ); - } - super.checkConfiguration(); if( filesets.size() == 0 ) { - throw new BuildException( "no filesets specified", location ); + throw new BuildException( "no filesets specified" ); } if( targetFilePos != null || mapperElement != null @@ -362,12 +354,11 @@ public class ExecuteOn extends ExecTask if( mapperElement == null ) { - throw new BuildException( "no mapper specified", location ); + throw new BuildException( "no mapper specified" ); } if( mapperElement == null ) { - throw new BuildException( "no dest attribute specified", - location ); + throw new BuildException( "no dest attribute specified" ); } mapper = mapperElement.getImplementation(); } @@ -448,7 +439,7 @@ public class ExecuteOn extends ExecTask } catch( IOException e ) { - throw new BuildException( "Execute failed: " + e, e, location ); + throw new BuildException( "Execute failed: " + e, e ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Expand.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Expand.java index 38ebc9404..88e1bd21d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Expand.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Expand.java @@ -98,11 +98,6 @@ public class Expand extends MatchingTask public void execute() throws BuildException { - if( "expand".equals( taskType ) ) - { - log( "!! expand is deprecated. Use unzip instead. !!" ); - } - if( source == null && filesets.size() == 0 ) { throw new BuildException( "src attribute and/or filesets must be specified" ); @@ -116,7 +111,7 @@ public class Expand extends MatchingTask if( dest.exists() && !dest.isDirectory() ) { - throw new BuildException( "Dest must be a directory.", location ); + throw new BuildException( "Dest must be a directory." ); } FileUtils fileUtils = FileUtils.newFileUtils(); @@ -126,7 +121,7 @@ public class Expand extends MatchingTask if( source.isDirectory() ) { throw new BuildException( "Src must not be a directory." + - " Use nested filesets instead.", location ); + " Use nested filesets instead." ); } else { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Filter.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Filter.java index 6970d0ab4..b51e712f6 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Filter.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Filter.java @@ -51,7 +51,7 @@ public class Filter extends Task if( !isFiltersFromFile && !isSingleFilter ) { - throw new BuildException( "both token and value parameters, or only a filtersFile parameter is required", location ); + throw new BuildException( "both token and value parameters, or only a filtersFile parameter is required" ); } if( isSingleFilter ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/FixCRLF.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/FixCRLF.java index 2cd21df0a..18c757c2d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/FixCRLF.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/FixCRLF.java @@ -147,35 +147,6 @@ public class FixCRLF extends MatchingTask } } - /** - * Specify how carriage return (CR) characters are to be handled - * - * @param attr The new Cr value - * @deprecated use {@link #setEol setEol} instead. - */ - public void setCr( AddAsisRemove attr ) - { - log( "DEPRECATED: The cr attribute has been deprecated,", - Project.MSG_WARN ); - log( "Please us the eol attribute instead", Project.MSG_WARN ); - String option = attr.getValue(); - CrLf c = new CrLf(); - if( option.equals( "remove" ) ) - { - c.setValue( "lf" ); - } - else if( option.equals( "asis" ) ) - { - c.setValue( "asis" ); - } - else - { - // must be "add" - c.setValue( "crlf" ); - } - setEol( c ); - } - /** * Set the destination where the fixed files should be placed. Default is to * replace the original file. @@ -306,8 +277,7 @@ public class FixCRLF extends MatchingTask { if( tlength < 2 || tlength > 80 ) { - throw new BuildException( "tablength must be between 2 and 80", - location ); + throw new BuildException( "tablength must be between 2 and 80" ); } tablength = tlength; StringBuffer sp = new StringBuffer(); @@ -522,7 +492,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); }// end of try-catch } else @@ -581,7 +551,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); }// end of try-catch }// end of else tabs == ADD @@ -617,7 +587,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } while( lines.hasMoreElements() ) @@ -631,7 +601,7 @@ public class FixCRLF extends MatchingTask } catch( NoSuchElementException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } String lineString = line.getLineString(); @@ -649,7 +619,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); }// end of try-catch } @@ -721,7 +691,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } lines.setState( LOOKING ); @@ -744,7 +714,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); }// end of try-catch }// end of while (lines.hasNext()) @@ -763,7 +733,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { @@ -773,7 +743,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } @@ -841,7 +811,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { @@ -914,7 +884,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } @@ -1043,7 +1013,7 @@ public class FixCRLF extends MatchingTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/GUnzip.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/GUnzip.java index a4001fba5..50088af38 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/GUnzip.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/GUnzip.java @@ -56,7 +56,7 @@ public class GUnzip extends Unpack catch( IOException ioe ) { String msg = "Problem expanding gzip " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/GZip.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/GZip.java index df35b0daf..1469cccee 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/GZip.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/GZip.java @@ -34,7 +34,7 @@ public class GZip extends Pack catch( IOException ioe ) { String msg = "Problem creating gzip " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Get.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Get.java index 6c1eb4451..d05868236 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Get.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Get.java @@ -132,29 +132,26 @@ public class Get extends Task { if( source == null ) { - throw new BuildException( "src attribute is required", location ); + throw new BuildException( "src attribute is required" ); } if( dest == null ) { - throw new BuildException( "dest attribute is required", location ); + throw new BuildException( "dest attribute is required" ); } if( dest.exists() && dest.isDirectory() ) { - throw new BuildException( "The specified destination is a directory", - location ); + throw new BuildException( "The specified destination is a directory" ); } if( dest.exists() && !dest.canWrite() ) { - throw new BuildException( "Can't write to " + dest.getAbsolutePath(), - location ); + throw new BuildException( "Can't write to " + dest.getAbsolutePath() ); } try { - log( "Getting: " + source ); //set the timestamp to the file date. @@ -249,8 +246,7 @@ public class Get extends Task log( "Can't get " + source + " to " + dest ); if( ignoreErrors ) return; - throw new BuildException( "Can't get " + source + " to " + dest, - location ); + throw new BuildException( "Can't get " + source + " to " + dest ); } byte[] buffer = new byte[100 * 1024]; @@ -287,7 +283,7 @@ public class Get extends Task log( "Error getting " + source + " to " + dest ); if( ignoreErrors ) return; - throw new BuildException( ioe); + throw new BuildException( "Error", ioe); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Jar.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Jar.java index 1b2d8a976..8d5aec951 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Jar.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Jar.java @@ -63,22 +63,11 @@ public class Jar extends Zip index = flag; } - /** - * @param jarFile The new Jarfile value - * @deprecated use setFile(File) instead. - */ - public void setJarfile( File jarFile ) - { - log( "DEPRECATED - The jarfile attribute is deprecated. Use file attribute instead." ); - setFile( jarFile ); - } - public void setManifest( File manifestFile ) { if( !manifestFile.exists() ) { - throw new BuildException( "Manifest file: " + manifestFile + " does not exist.", - getLocation() ); + throw new BuildException( "Manifest file: " + manifestFile + " does not exist." ); } this.manifestFile = manifestFile; @@ -97,7 +86,7 @@ public class Jar extends Zip catch( ManifestException e ) { log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); - throw new BuildException( "Invalid Manifest: " + manifestFile, e, getLocation() ); + throw new BuildException( "Invalid Manifest: " + manifestFile, e ); } catch( IOException e ) { @@ -262,7 +251,7 @@ public class Jar extends Zip catch( ManifestException e ) { log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); - throw new BuildException( "Invalid Manifest", e, getLocation() ); + throw new BuildException( "Invalid Manifest", e ); } } @@ -391,7 +380,7 @@ public class Jar extends Zip catch( ManifestException e ) { log( "Manifest is invalid: " + e.getMessage(), Project.MSG_ERR ); - throw new BuildException( "Invalid Manifest", e, getLocation() ); + throw new BuildException( "Invalid Manifest", e ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java index 060a331c6..2671c6e0f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Java.java @@ -6,13 +6,13 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.Vector; import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.ExitException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Commandline; @@ -39,19 +39,6 @@ public class Java extends Task private boolean failOnError = false; private File out; - /** - * Set the command line arguments for the class. - * - * @param s The new Args value - */ - public void setArgs( String s ) - { - log( "The args attribute is deprecated. " + - "Please use nested arg elements.", - Project.MSG_WARN ); - cmdl.createArgument().setLine( s ); - } - /** * Set the class name. * @@ -149,19 +136,6 @@ public class Java extends Task cmdl.setVm( s ); } - /** - * Set the command line arguments for the JVM. - * - * @param s The new Jvmargs value - */ - public void setJvmargs( String s ) - { - log( "The jvmargs attribute is deprecated. " + - "Please use nested jvmarg elements.", - Project.MSG_WARN ); - cmdl.createVmArgument().setLine( s ); - } - /** * -mx or -Xmx depending on VM version * @@ -243,7 +217,7 @@ public class Java extends Task { if( failOnError ) { - throw new BuildException( "Java returned: " + err, location ); + throw new BuildException( "Java returned: " + err ); } else { @@ -290,16 +264,9 @@ public class Java extends Task } log( "Running in same VM " + cmdl.getJavaCommand().toString(), - Project.MSG_VERBOSE ); - try - { - run( cmdl ); - return 0; - } - catch( ExitException ex ) - { - return ex.getStatus(); - } + Project.MSG_VERBOSE ); + run( cmdl ); + return 0; } } @@ -342,7 +309,7 @@ public class Java extends Task cmdj.setClassname( classname ); for( int i = 0; i < args.size(); i++ ) { - cmdj.createArgument().setValue( ( String )args.elementAt( i ) ); + cmdj.createArgument().setValue( (String)args.elementAt( i ) ); } run( cmdj ); } @@ -370,7 +337,7 @@ public class Java extends Task } catch( IOException io ) { - throw new BuildException( io ); + throw new BuildException( "Error", io ); } finally { @@ -403,8 +370,8 @@ public class Java extends Task if( out == null ) { exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO, - Project.MSG_WARN ), - null ); + Project.MSG_WARN ), + null ); } else { @@ -420,8 +387,7 @@ public class Java extends Task } else if( !dir.exists() || !dir.isDirectory() ) { - throw new BuildException( dir.getAbsolutePath() + " is not a valid directory", - location ); + throw new BuildException( dir.getAbsolutePath() + " is not a valid directory"); } exe.setWorkingDirectory( dir ); @@ -433,12 +399,12 @@ public class Java extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } catch( IOException io ) { - throw new BuildException( io ); + throw new BuildException( "Error", io ); } finally { @@ -449,7 +415,8 @@ public class Java extends Task fos.close(); } catch( IOException io ) - {} + { + } } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javac.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javac.java index 7793bc4f2..9ff441be4 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javac.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javac.java @@ -6,15 +6,16 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.File; import java.util.Enumeration; import java.util.Vector; +import org.apache.myrmidon.framework.Os; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter; import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory; -import org.apache.myrmidon.framework.Os; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; @@ -57,9 +58,8 @@ import org.apache.tools.ant.util.SourceFileScanner; public class Javac extends MatchingTask { - private final static String FAIL_MSG - = "Compile failed, messages should have been provided."; + = "Compile failed, messages should have been provided."; private boolean debug = false; private boolean optimize = false; private boolean deprecation = false; @@ -73,7 +73,7 @@ public class Javac extends MatchingTask private Vector implementationSpecificArgs = new Vector(); protected boolean failOnError = true; - protected File[] compileList = new File[0]; + protected File[] compileList = new File[ 0 ]; private Path bootclasspath; private Path compileClasspath; private String debugLevel; @@ -238,15 +238,15 @@ public class Javac extends MatchingTask public void setFork( String f ) { if( f.equalsIgnoreCase( "on" ) - || f.equalsIgnoreCase( "true" ) - || f.equalsIgnoreCase( "yes" ) ) + || f.equalsIgnoreCase( "true" ) + || f.equalsIgnoreCase( "yes" ) ) { fork = "true"; forkedExecutable = getSystemJavac(); } else if( f.equalsIgnoreCase( "off" ) - || f.equalsIgnoreCase( "false" ) - || f.equalsIgnoreCase( "no" ) ) + || f.equalsIgnoreCase( "false" ) + || f.equalsIgnoreCase( "no" ) ) { fork = "false"; forkedExecutable = null; @@ -406,17 +406,17 @@ public class Javac extends MatchingTask { Vector args = new Vector(); for( Enumeration enum = implementationSpecificArgs.elements(); - enum.hasMoreElements(); - ) + enum.hasMoreElements(); + ) { String[] curr = - ( ( ImplementationSpecificArgument )enum.nextElement() ).getParts(); + ( (ImplementationSpecificArgument)enum.nextElement() ).getParts(); for( int i = 0; i < curr.length; i++ ) { - args.addElement( curr[i] ); + args.addElement( curr[ i ] ); } } - String[] res = new String[args.size()]; + String[] res = new String[ args.size() ]; args.copyInto( res ); return res; } @@ -724,17 +724,17 @@ public class Javac extends MatchingTask if( src == null ) { - throw new BuildException( "srcdir attribute must be set!", location ); + throw new BuildException( "srcdir attribute must be set!" ); } String[] list = src.list(); if( list.length == 0 ) { - throw new BuildException( "srcdir attribute must be set!", location ); + throw new BuildException( "srcdir attribute must be set!" ); } if( destDir != null && !destDir.isDirectory() ) { - throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory", location ); + throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory" ); } // scan source directories and dest directory to build up @@ -742,10 +742,10 @@ public class Javac extends MatchingTask resetFileLists(); for( int i = 0; i < list.length; i++ ) { - File srcDir = ( File )project.resolveFile( list[i] ); + File srcDir = (File)resolveFile( list[ i ] ); if( !srcDir.exists() ) { - throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!", location ); + throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!" ); } DirectoryScanner ds = this.getDirectoryScanner( srcDir ); @@ -765,7 +765,7 @@ public class Javac extends MatchingTask CompilerAdapter adapter = CompilerAdapterFactory.getCompiler( compiler, this ); log( "Compiling " + compileList.length + - " source file" + " source file" + ( compileList.length == 1 ? "" : "s" ) + ( destDir != null ? " to " + destDir : "" ) ); @@ -777,7 +777,7 @@ public class Javac extends MatchingTask { if( failOnError ) { - throw new BuildException( FAIL_MSG, location ); + throw new BuildException( FAIL_MSG ); } else { @@ -799,7 +799,7 @@ public class Javac extends MatchingTask // PATH. java.io.File jExecutable = new java.io.File( System.getProperty( "java.home" ) + - "/../bin/javac" + extension ); + "/../bin/javac" + extension ); if( jExecutable.exists() && !Os.isFamily( "netware" ) ) { @@ -837,7 +837,7 @@ public class Javac extends MatchingTask */ protected void resetFileLists() { - compileList = new File[0]; + compileList = new File[ 0 ]; } /** @@ -858,12 +858,12 @@ public class Javac extends MatchingTask if( newFiles.length > 0 ) { - File[] newCompileList = new File[compileList.length + - newFiles.length]; + File[] newCompileList = new File[ compileList.length + + newFiles.length ]; System.arraycopy( compileList, 0, newCompileList, 0, - compileList.length ); + compileList.length ); System.arraycopy( newFiles, 0, newCompileList, - compileList.length, newFiles.length ); + compileList.length, newFiles.length ); compileList = newCompileList; } } @@ -879,7 +879,7 @@ public class Javac extends MatchingTask if( isJdkCompiler( compiler ) ) { log( "Since fork is true, ignoring build.compiler setting.", - Project.MSG_WARN ); + Project.MSG_WARN ); compiler = "extJavac"; } else @@ -915,7 +915,7 @@ public class Javac extends MatchingTask * @author RT */ public class ImplementationSpecificArgument - extends Commandline.Argument + extends Commandline.Argument { private String impl; @@ -933,7 +933,7 @@ public class Javac extends MatchingTask } else { - return new String[0]; + return new String[ 0 ]; } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javadoc.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javadoc.java index e95245de7..98adc71a3 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Javadoc.java @@ -318,7 +318,7 @@ public class Javadoc extends Task { throw new BuildException( linkOfflineError ); } - le.setPackagelistLoc( project.resolveFile( tok.nextToken() ) ); + le.setPackagelistLoc( resolveFile( tok.nextToken() ) ); } } @@ -436,7 +436,7 @@ public class Javadoc extends Task { String f = tok.nextToken(); SourceFile sf = new SourceFile(); - sf.setFile( project.resolveFile( f ) ); + sf.setFile( resolveFile( f ) ); addSource( sf ); } } @@ -608,11 +608,6 @@ public class Javadoc extends Task public void execute() throws BuildException { - if( "javadoc2".equals( taskType ) ) - { - log( "!! javadoc2 is deprecated. Use javadoc instead. !!" ); - } - if( sourcePath == null ) { String msg = "sourcePath attribute must be set!"; @@ -689,7 +684,7 @@ public class Javadoc extends Task { if( doclet.getName() == null ) { - throw new BuildException( "The doclet name must be specified.", location ); + throw new BuildException( "The doclet name must be specified." ); } else { @@ -885,8 +880,7 @@ public class Javadoc extends Task } catch( IOException e ) { - throw new BuildException( "Error creating temporary file", - e, location ); + throw new BuildException( "Error creating temporary file", e ); } finally { @@ -923,12 +917,12 @@ public class Javadoc extends Task int ret = exe.execute(); if( ret != 0 && failOnError ) { - throw new BuildException( "Javadoc returned " + ret, location ); + throw new BuildException( "Javadoc returned " + ret ); } } catch( IOException e ) { - throw new BuildException( "Javadoc failed: " + e, e, location ); + throw new BuildException( "Javadoc failed: " + e, e ); } finally { @@ -1117,7 +1111,7 @@ public class Javadoc extends Task for( int j = 0; j < list.length; j++ ) { - File source = project.resolveFile( list[j] ); + File source = resolveFile( list[j] ); fs.setDir( source ); DirectoryScanner ds = fs.getDirectoryScanner( project ); @@ -1160,8 +1154,7 @@ public class Javadoc extends Task } catch( IOException ioex ) { - throw new BuildException( "Error creating temporary file", - ioex, location ); + throw new BuildException( "Error creating temporary file", ioex ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/LogStreamHandler.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/LogStreamHandler.java index b7e6c849b..abb58ef52 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/LogStreamHandler.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/LogStreamHandler.java @@ -42,7 +42,7 @@ public class LogStreamHandler extends PumpStreamHandler catch( IOException e ) { // plain impossible - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Manifest.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Manifest.java index 242b0fa5e..fa0e3f61c 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Manifest.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Manifest.java @@ -320,12 +320,12 @@ public class Manifest extends Task catch( ManifestException m ) { throw new BuildException( "Existing manifest " + manifestFile - + " is invalid", m, location ); + + " is invalid", m ); } catch( IOException e ) { - throw new BuildException( "Failed to read " + manifestFile, - e, location ); + throw new + BuildException( "Failed to read " + manifestFile, e ); } finally { @@ -347,7 +347,7 @@ public class Manifest extends Task } catch( ManifestException m ) { - throw new BuildException( "Manifest is invalid", m, location ); + throw new BuildException( "Manifest is invalid", m ); } PrintWriter w = null; @@ -358,8 +358,7 @@ public class Manifest extends Task } catch( IOException e ) { - throw new BuildException( "Failed to write " + manifestFile, - e, location ); + throw new BuildException( "Failed to write " + manifestFile e ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java index a03cb9be7..375d11526 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/MatchingTask.java @@ -88,59 +88,6 @@ public abstract class MatchingTask extends Task fileset.setIncludesfile( includesfile ); } - /** - * List of filenames and directory names to not include. They should be - * either , or " " (space) separated. The ignored files will be logged. - * - * @param ignoreString the string containing the files to ignore. - */ - public void XsetIgnore( String ignoreString ) - { - log( "The ignore attribute is deprecated." + - "Please use the excludes attribute.", - Project.MSG_WARN ); - if( ignoreString != null && ignoreString.length() > 0 ) - { - Vector tmpExcludes = new Vector(); - StringTokenizer tok = new StringTokenizer( ignoreString, ", ", false ); - while( tok.hasMoreTokens() ) - { - createExclude().setName( "**/" + tok.nextToken().trim() + "/**" ); - } - } - } - - /** - * Set this to be the items in the base directory that you want to be - * included. You can also specify "*" for the items (ie: items="*") and it - * will include all the items in the base directory. - * - * @param itemString the string containing the files to include. - */ - public void XsetItems( String itemString ) - { - log( "The items attribute is deprecated. " + - "Please use the includes attribute.", - Project.MSG_WARN ); - if( itemString == null || itemString.equals( "*" ) - || itemString.equals( "." ) ) - { - createInclude().setName( "**" ); - } - else - { - StringTokenizer tok = new StringTokenizer( itemString, ", " ); - while( tok.hasMoreTokens() ) - { - String pattern = tok.nextToken().trim(); - if( pattern.length() > 0 ) - { - createInclude().setName( pattern + "/**" ); - } - } - } - } - /** * add a name entry on the exclude list * diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Mkdir.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Mkdir.java index c323430a4..f186760f1 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Mkdir.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Mkdir.java @@ -32,7 +32,7 @@ public class Mkdir extends Task { if( dir == null ) { - throw new BuildException( "dir attribute is required", location ); + throw new BuildException( "dir attribute is required" ); } if( dir.isFile() ) @@ -47,7 +47,7 @@ public class Mkdir extends Task { String msg = "Directory " + dir.getAbsolutePath() + " creation was not " + "successful for an unknown reason"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } log( "Created dir: " + dir.getAbsolutePath() ); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Move.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Move.java index 75811008d..4d021bdf5 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Move.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Move.java @@ -96,7 +96,7 @@ public class Move extends Copy String msg = "Failed to rename dir " + fromDir + " to " + toDir + " due to " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } } } @@ -135,7 +135,7 @@ public class Move extends Copy String msg = "Failed to rename " + fromFile + " to " + toFile + " due to " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } if( !moved ) @@ -168,7 +168,7 @@ public class Move extends Copy String msg = "Failed to copy " + fromFile + " to " + toFile + " due to " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Pack.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Pack.java index 3a9d0701d..2bd1d6ee2 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Pack.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Pack.java @@ -64,18 +64,18 @@ public abstract class Pack extends Task { if( zipFile == null ) { - throw new BuildException( "zipfile attribute is required", location ); + throw new BuildException( "zipfile attribute is required" ); } if( source == null ) { - throw new BuildException( "src attribute is required", location ); + throw new BuildException( "src attribute is required" ); } if( source.isDirectory() ) { throw new BuildException( "Src attribute must not " + - "represent a directory!", location ); + "represent a directory!" ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Parallel.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Parallel.java index 1203369ac..942d7f1cd 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Parallel.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Parallel.java @@ -117,12 +117,12 @@ public class Parallel extends Task } else { - throw new BuildException( firstException ); + throw new BuildException( "Error", firstException ); } } else if( numExceptions > 1 ) { - throw new BuildException( exceptionMessage.toString(), firstLocation ); + throw new BuildException( exceptionMessage.toString() ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Patch.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Patch.java index 8c7657b12..f1edcac78 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Patch.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Patch.java @@ -70,8 +70,7 @@ public class Patch extends Task { if( !file.exists() ) { - throw new BuildException( "patchfile " + file + " doesn\'t exist", - location ); + throw new BuildException( "patchfile " + file + " doesn\'t exist" ); } cmd.createArgument().setValue( "-i" ); cmd.createArgument().setFile( file ); @@ -118,7 +117,7 @@ public class Patch extends Task { if( num < 0 ) { - throw new BuildException( "strip has to be >= 0", location ); + throw new BuildException( "strip has to be >= 0" ); } cmd.createArgument().setValue( "-p" + num ); } @@ -128,8 +127,7 @@ public class Patch extends Task { if( !havePatchfile ) { - throw new BuildException( "patchfile argument is required", - location ); + throw new BuildException( "patchfile argument is required" ); } Commandline toExecute = ( Commandline )cmd.clone(); @@ -150,7 +148,7 @@ public class Patch extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Property.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Property.java index 15b182ecf..0c506bce8 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Property.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Property.java @@ -99,17 +99,6 @@ public class Property extends Task this.resource = resource; } - /** - * @param userProperty The new UserProperty value - * @deprecated This was never a supported feature and has been deprecated - * without replacement - */ - public void setUserProperty( boolean userProperty ) - { - log( "DEPRECATED: Ignoring request to set user property in Property task.", - Project.MSG_WARN ); - } - public void setValue( String value ) { this.value = value; @@ -161,16 +150,14 @@ public class Property extends Task { if( value == null && ref == null ) { - throw new BuildException( "You must specify value, location or refid with the name attribute", - location ); + throw new BuildException( "You must specify value, location or refid with the name attribute" ); } } else { if( file == null && resource == null && env == null ) { - throw new BuildException( "You must specify file, resource or environment when not using the name attribute", - location ); + throw new BuildException( "You must specify file, resource or environment when not using the name attribute" ); } } @@ -291,7 +278,7 @@ public class Property extends Task } catch( IOException ex ) { - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } @@ -334,7 +321,7 @@ public class Property extends Task } catch( IOException ex ) { - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Replace.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Replace.java index 626ac8216..381d8ef91 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Replace.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Replace.java @@ -245,23 +245,23 @@ public class Replace extends MatchingTask if( src == null && dir == null ) { String message = "Either the file or the dir attribute " + "must be specified"; - throw new BuildException( message, location ); + throw new BuildException( message ); } if( propertyFile != null && !propertyFile.exists() ) { String message = "Property file " + propertyFile.getPath() + " does not exist."; - throw new BuildException( message, location ); + throw new BuildException( message ); } if( token == null && replacefilters.size() == 0 ) { String message = "Either token or a nested replacefilter " + "must be specified"; - throw new BuildException( message, location ); + throw new BuildException( message); } if( token != null && "".equals( token.getText() ) ) { String message = "The token attribute must not be an empty string."; - throw new BuildException( message, location ); + throw new BuildException( message ); } } @@ -293,7 +293,7 @@ public class Replace extends MatchingTask { if( !src.exists() ) { - throw new BuildException( "Replace: source file " + src.getPath() + " doesn't exist", location ); + throw new BuildException( "Replace: source file " + src.getPath() + " doesn't exist" ); } File temp = fileUtils.createTempFile( "rep", ".tmp", @@ -382,7 +382,7 @@ public class Replace extends MatchingTask catch( IOException ioe ) { throw new BuildException( "IOException in " + src + " - " + - ioe.getClass().getName() + ":" + ioe.getMessage(), ioe, location ); + ioe.getClass().getName() + ":" + ioe.getMessage(), ioe ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Rmic.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Rmic.java index e37fac08e..8ce94edeb 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Rmic.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Rmic.java @@ -20,6 +20,7 @@ import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.SourceFileScanner; +import org.apache.tools.ant.util.FileUtils; /** * Task to compile RMI stubs and skeletons. This task can take the following @@ -518,11 +519,11 @@ public class Rmic extends MatchingTask { if( baseDir == null ) { - throw new BuildException( "base attribute must be set!", location ); + throw new BuildException( "base attribute must be set!" ); } if( !baseDir.exists() ) { - throw new BuildException( "base does not exist!", location ); + throw new BuildException( "base does not exist!" ); } if( verify ) @@ -565,7 +566,7 @@ public class Rmic extends MatchingTask // finally, lets execute the compiler!! if( !adapter.execute() ) { - throw new BuildException( FAIL_MSG, location ); + throw new BuildException( FAIL_MSG ); } } @@ -672,14 +673,14 @@ public class Rmic extends MatchingTask File newFile = new File( sourceBaseFile, sourceFileName ); try { - project.copyFile( oldFile, newFile, filtering ); + FileUtils.newFileUtils().copyFile( oldFile, newFile, filtering ); oldFile.delete(); } catch( IOException ioe ) { String msg = "Failed to copy " + oldFile + " to " + newFile + " due to " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SQLExec.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SQLExec.java index 27acf92a0..a242c5489 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SQLExec.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SQLExec.java @@ -400,7 +400,7 @@ public class SQLExec extends Task { if( transactions.size() == 0 ) { - throw new BuildException( "Source file or fileset, transactions or sql statement must be set!", location ); + throw new BuildException( "Source file or fileset, transactions or sql statement must be set!" ); } } else @@ -430,23 +430,23 @@ public class SQLExec extends Task if( driver == null ) { - throw new BuildException( "Driver attribute must be set!", location ); + throw new BuildException( "Driver attribute must be set!" ); } if( userId == null ) { - throw new BuildException( "User Id attribute must be set!", location ); + throw new BuildException( "User Id attribute must be set!" ); } if( password == null ) { - throw new BuildException( "Password attribute must be set!", location ); + throw new BuildException( "Password attribute must be set!" ); } if( url == null ) { - throw new BuildException( "Url attribute must be set!", location ); + throw new BuildException( "Url attribute must be set!" ); } if( srcFile != null && !srcFile.exists() ) { - throw new BuildException( "Source file does not exist!", location ); + throw new BuildException( "Source file does not exist!" ); } Driver driverInstance = null; // Load the driver using the @@ -470,15 +470,15 @@ public class SQLExec extends Task } catch( ClassNotFoundException e ) { - throw new BuildException( "Class Not Found: JDBC driver " + driver + " could not be loaded", location ); + throw new BuildException( "Class Not Found: JDBC driver " + driver + " could not be loaded" ); } catch( IllegalAccessException e ) { - throw new BuildException( "Illegal Access: JDBC driver " + driver + " could not be loaded", location ); + throw new BuildException( "Illegal Access: JDBC driver " + driver + " could not be loaded" ); } catch( InstantiationException e ) { - throw new BuildException( "Instantiation Exception: JDBC driver " + driver + " could not be loaded", location ); + throw new BuildException( "Instantiation Exception: JDBC driver " + driver + " could not be loaded" ); } try @@ -543,7 +543,7 @@ public class SQLExec extends Task catch( SQLException ex ) {} } - throw new BuildException( e ); + throw new BuildException( "Error", e ); } catch( SQLException e ) { @@ -556,7 +556,7 @@ public class SQLExec extends Task catch( SQLException ex ) {} } - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SendEmail.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SendEmail.java index 052ed4940..d69728485 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SendEmail.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/SendEmail.java @@ -201,7 +201,7 @@ public class SendEmail extends Task while( t.hasMoreTokens() ) { - files.addElement( project.resolveFile( t.nextToken() ) ); + files.addElement( resolveFile( t.nextToken() ) ); } } @@ -394,7 +394,7 @@ public class SendEmail extends Task String err = "IO error sending mail " + ioe.toString(); if( failOnError ) { - throw new BuildException( err, ioe, location ); + throw new BuildException( err, ioe ); } else { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Sleep.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Sleep.java index 2c8d81c86..6c1b9b734 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Sleep.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Sleep.java @@ -141,7 +141,7 @@ public class Sleep extends Task { if( failOnError ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } else { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tar.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tar.java index 2f3fe3cdc..cbcae1f7d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tar.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tar.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -34,33 +35,6 @@ import org.apache.tools.tar.TarOutputStream; public class Tar extends MatchingTask { - - /** - * @deprecated Tar.WARN is deprecated and is replaced with - * Tar.TarLongFileMode.WARN - */ - public final static String WARN = "warn"; - /** - * @deprecated Tar.FAIL is deprecated and is replaced with - * Tar.TarLongFileMode.FAIL - */ - public final static String FAIL = "fail"; - /** - * @deprecated Tar.TRUNCATE is deprecated and is replaced with - * Tar.TarLongFileMode.TRUNCATE - */ - public final static String TRUNCATE = "truncate"; - /** - * @deprecated Tar.GNU is deprecated and is replaced with - * Tar.TarLongFileMode.GNU - */ - public final static String GNU = "gnu"; - /** - * @deprecated Tar.OMIT is deprecated and is replaced with - * Tar.TarLongFileMode.OMIT - */ - public final static String OMIT = "omit"; - private TarLongFileMode longFileMode = new TarLongFileMode(); Vector filesets = new Vector(); @@ -84,28 +58,6 @@ public class Tar extends MatchingTask this.baseDir = baseDir; } - /** - * Set how to handle long files. Allowable values are truncate - paths are - * truncated to the maximum length fail - paths greater than the maximim - * cause a build exception warn - paths greater than the maximum cause a - * warning and GNU is used gnu - GNU extensions are used for any paths - * greater than the maximum. omit - paths greater than the maximum are - * omitted from the archive - * - * @param mode The new Longfile value - * @deprecated setLongFile(String) is deprecated and is replaced with - * setLongFile(Tar.TarLongFileMode) to make Ant's Introspection - * mechanism do the work and also to encapsulate operations on the mode - * in its own class. - */ - public void setLongfile( String mode ) - { - log( "DEPRECATED - The setLongfile(String) method has been deprecated." - + " Use setLongfile(Tar.TarLongFileMode) instead." ); - this.longFileMode = new TarLongFileMode(); - longFileMode.setValue( mode ); - } - /** * Set how to handle long files. Allowable values are truncate - paths are * truncated to the maximum length fail - paths greater than the maximim @@ -121,7 +73,6 @@ public class Tar extends MatchingTask this.longFileMode = mode; } - /** * This is the name/location of where to create the tar file. * @@ -144,27 +95,24 @@ public class Tar extends MatchingTask { if( tarFile == null ) { - throw new BuildException( "tarfile attribute must be set!", - location ); + throw new BuildException( "tarfile attribute must be set!" ); } if( tarFile.exists() && tarFile.isDirectory() ) { - throw new BuildException( "tarfile is a directory!", - location ); + throw new BuildException( "tarfile is a directory!" ); } if( tarFile.exists() && !tarFile.canWrite() ) { - throw new BuildException( "Can not write to the specified tarfile!", - location ); + throw new BuildException( "Can not write to the specified tarfile!" ); } if( baseDir != null ) { if( !baseDir.exists() ) { - throw new BuildException( "basedir does not exist!", location ); + throw new BuildException( "basedir does not exist!" ); } // add the main fileset to the list of filesets to process. @@ -175,16 +123,15 @@ public class Tar extends MatchingTask if( filesets.size() == 0 ) { - throw new BuildException( "You must supply either a basdir attribute or some nested filesets.", - location ); + throw new BuildException( "You must supply either a basdir attribute or some nested filesets." ); } // check if tr is out of date with respect to each // fileset boolean upToDate = true; - for( Enumeration e = filesets.elements(); e.hasMoreElements(); ) + for( Enumeration e = filesets.elements(); e.hasMoreElements(); ) { - TarFileSet fs = ( TarFileSet )e.nextElement(); + TarFileSet fs = (TarFileSet)e.nextElement(); String[] files = fs.getFiles( project ); if( !archiveIsUpToDate( files ) ) @@ -194,9 +141,9 @@ public class Tar extends MatchingTask for( int i = 0; i < files.length; ++i ) { - if( tarFile.equals( new File( fs.getDir( project ), files[i] ) ) ) + if( tarFile.equals( new File( fs.getDir( project ), files[ i ] ) ) ) { - throw new BuildException( "A tar file cannot include itself", location ); + throw new BuildException( "A tar file cannot include itself" ); } } } @@ -204,7 +151,7 @@ public class Tar extends MatchingTask if( upToDate ) { log( "Nothing to do: " + tarFile.getAbsolutePath() + " is up to date.", - Project.MSG_INFO ); + Project.MSG_INFO ); return; } @@ -231,14 +178,14 @@ public class Tar extends MatchingTask } longWarningGiven = false; - for( Enumeration e = filesets.elements(); e.hasMoreElements(); ) + for( Enumeration e = filesets.elements(); e.hasMoreElements(); ) { - TarFileSet fs = ( TarFileSet )e.nextElement(); + TarFileSet fs = (TarFileSet)e.nextElement(); String[] files = fs.getFiles( project ); for( int i = 0; i < files.length; i++ ) { - File f = new File( fs.getDir( project ), files[i] ); - String name = files[i].replace( File.separatorChar, '/' ); + File f = new File( fs.getDir( project ), files[ i ] ); + String name = files[ i ].replace( File.separatorChar, '/' ); tarFile( f, tOut, name, fs ); } } @@ -246,7 +193,7 @@ public class Tar extends MatchingTask catch( IOException ioe ) { String msg = "Problem creating TAR: " + ioe.getMessage(); - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { @@ -258,7 +205,8 @@ public class Tar extends MatchingTask tOut.close(); } catch( IOException e ) - {} + { + } } } } @@ -300,7 +248,7 @@ public class Tar extends MatchingTask else if( longFileMode.isWarnMode() ) { log( "Entry: " + vPath + " longer than " + - TarConstants.NAMELEN + " characters.", Project.MSG_WARN ); + TarConstants.NAMELEN + " characters.", Project.MSG_WARN ); if( !longWarningGiven ) { log( "Resulting tar file can only be processed successfully" @@ -312,7 +260,7 @@ public class Tar extends MatchingTask { throw new BuildException( "Entry: " + vPath + " longer than " + - TarConstants.NAMELEN + "characters.", location ); + TarConstants.NAMELEN + "characters." ); } } @@ -332,13 +280,13 @@ public class Tar extends MatchingTask { fIn = new FileInputStream( file ); - byte[] buffer = new byte[8 * 1024]; + byte[] buffer = new byte[ 8 * 1024 ]; int count = 0; do { tOut.write( buffer, 0, count ); count = fIn.read( buffer, 0, buffer.length ); - }while ( count != -1 ); + } while( count != -1 ); } tOut.closeEntry(); @@ -359,7 +307,6 @@ public class Tar extends MatchingTask private String userName = ""; private String groupName = ""; - public TarFileSet( FileSet fileset ) { super( fileset ); @@ -399,10 +346,10 @@ public class Tar extends MatchingTask DirectoryScanner ds = getDirectoryScanner( p ); String[] directories = ds.getIncludedDirectories(); String[] filesPerSe = ds.getIncludedFiles(); - files = new String[directories.length + filesPerSe.length]; + files = new String[ directories.length + filesPerSe.length ]; System.arraycopy( directories, 0, files, 0, directories.length ); System.arraycopy( filesPerSe, 0, files, directories.length, - filesPerSe.length ); + filesPerSe.length ); } return files; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Touch.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Touch.java index 358597118..d53db1655 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Touch.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Touch.java @@ -121,7 +121,7 @@ public class Touch extends Task } catch( ParseException pe ) { - throw new BuildException( pe.getMessage(), pe, location ); + throw new BuildException( pe.getMessage(), pe ); } } @@ -149,8 +149,7 @@ public class Touch extends Task } catch( IOException ioe ) { - throw new BuildException( "Could not create " + file, ioe, - location ); + throw new BuildException( "Could not create " + file, ioe ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tstamp.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tstamp.java index 276d964e0..5c97426a0 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tstamp.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Tstamp.java @@ -79,7 +79,7 @@ public class Tstamp extends Task } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } @@ -165,7 +165,7 @@ public class Tstamp extends Task country = st.nextToken(); if( st.hasMoreElements() ) { - throw new BuildException( "bad locale format", getLocation() ); + throw new BuildException( "bad locale format" ); } } } @@ -176,7 +176,7 @@ public class Tstamp extends Task } catch( NoSuchElementException e ) { - throw new BuildException( "bad locale format", e, getLocation() ); + throw new BuildException( "bad locale format", e ); } } @@ -200,22 +200,6 @@ public class Tstamp extends Task timeZone = TimeZone.getTimeZone( id ); } - /** - * @param unit The new Unit value - * @deprecated setUnit(String) is deprecated and is replaced with - * setUnit(Tstamp.Unit) to make Ant's Introspection mechanism do - * the work and also to encapsulate operations on the unit in its - * own class. - */ - public void setUnit( String unit ) - { - log( "DEPRECATED - The setUnit(String) method has been deprecated." - + " Use setUnit(Tstamp.Unit) instead." ); - Unit u = new Unit(); - u.setValue( unit ); - field = u.getCalendarField(); - } - public void setUnit( Unit unit ) { field = unit.getCalendarField(); @@ -225,12 +209,12 @@ public class Tstamp extends Task { if( propertyName == null ) { - throw new BuildException( "property attribute must be provided", location ); + throw new BuildException( "property attribute must be provided" ); } if( pattern == null ) { - throw new BuildException( "pattern attribute must be provided", location ); + throw new BuildException( "pattern attribute must be provided" ); } SimpleDateFormat sdf; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Unpack.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Unpack.java index 1e641b251..98bbf8f86 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Unpack.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Unpack.java @@ -24,12 +24,12 @@ public abstract class Unpack extends Task public void setDest( String dest ) { - this.dest = project.resolveFile( dest ); + this.dest = resolveFile( dest ); } public void setSrc( String src ) { - source = project.resolveFile( src ); + source = resolveFile( src ); } public void execute() @@ -65,17 +65,17 @@ public abstract class Unpack extends Task { if( source == null ) { - throw new BuildException( "No Src for gunzip specified", location ); + throw new BuildException( "No Src for gunzip specified" ); } if( !source.exists() ) { - throw new BuildException( "Src doesn't exist", location ); + throw new BuildException( "Src doesn't exist" ); } if( source.isDirectory() ) { - throw new BuildException( "Cannot expand a directory", location ); + throw new BuildException( "Cannot expand a directory" ); } if( dest == null ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Untar.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Untar.java index 99fba8759..ea7539ffe 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Untar.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Untar.java @@ -46,8 +46,7 @@ public class Untar extends Expand } catch( IOException ioe ) { - throw new BuildException( "Error while expanding " + srcF.getPath(), - ioe, location ); + throw new BuildException( "Error while expanding " + srcF.getPath(), ioe ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/UpToDate.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/UpToDate.java index 968131b0a..43ae44064 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/UpToDate.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/UpToDate.java @@ -94,8 +94,7 @@ public class UpToDate extends MatchingTask implements Condition { if( mapperElement != null ) { - throw new BuildException( "Cannot define more than one mapper", - location ); + throw new BuildException( "Cannot define more than one mapper" ); } mapperElement = new Mapper( project ); return mapperElement; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/War.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/War.java index ff2bf9c48..33dc1e83b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/War.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/War.java @@ -32,12 +32,6 @@ public class War extends Jar emptyBehavior = "create"; } - public void setWarfile( File warFile ) - { - log( "DEPRECATED - The warfile attribute is deprecated. Use file attribute instead." ); - setFile( warFile ); - } - public void setWebxml( File descr ) { deploymentDescriptor = descr; @@ -89,7 +83,7 @@ public class War extends Jar // If no webxml file is specified, it's an error. if( deploymentDescriptor == null && !isInUpdateMode() ) { - throw new BuildException( "webxml attribute is required", location ); + throw new BuildException( "webxml attribute is required" ); } super.initZipOutputStream( zOut ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/XSLTProcess.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/XSLTProcess.java index 13a17d2b2..37d5d6c41 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/XSLTProcess.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/XSLTProcess.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs; + import java.io.File; import java.util.Enumeration; import java.util.Vector; @@ -17,7 +18,6 @@ import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.util.FileUtils; - /** * A Task to process via XSLT a set of XML documents. This is useful for * building views of XML based documentation. arguments: @@ -169,7 +169,6 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger this.outputtype = type; } - public void setProcessor( String processor ) { this.processor = processor; @@ -222,12 +221,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger if( xslFile == null ) { - throw new BuildException( "no stylesheet specified", location ); + throw new BuildException( "no stylesheet specified" ); } if( baseDir == null ) { - baseDir = project.resolveFile( "." ); + baseDir = resolveFile( "." ); } liaison = getLiaison(); @@ -235,25 +234,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger // check if liaison wants to log errors using us as logger if( liaison instanceof XSLTLoggerAware ) { - ( ( XSLTLoggerAware )liaison ).setLogger( this ); + ( (XSLTLoggerAware)liaison ).setLogger( this ); } log( "Using " + liaison.getClass().toString(), Project.MSG_VERBOSE ); - File stylesheet = project.resolveFile( xslFile ); - if( !stylesheet.exists() ) - { - stylesheet = fileUtils.resolveFile( baseDir, xslFile ); - /* - * shouldn't throw out deprecation warnings before we know, - * the wrong version has been used. - */ - if( stylesheet.exists() ) - { - log( "DEPRECATED - the style attribute should be relative to the project\'s" ); - log( " basedir, not the tasks\'s basedir." ); - } - } + File stylesheet = resolveFile( xslFile ); // if we have an in file and out then process them if( inFile != null && outFile != null ) @@ -279,16 +265,16 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger list = scanner.getIncludedFiles(); for( int i = 0; i < list.length; ++i ) { - process( baseDir, list[i], destDir, stylesheet ); + process( baseDir, list[ i ], destDir, stylesheet ); } // Process all the directoried marked for styling dirs = scanner.getIncludedDirectories(); for( int j = 0; j < dirs.length; ++j ) { - list = new File( baseDir, dirs[j] ).list(); + list = new File( baseDir, dirs[ j ] ).list(); for( int i = 0; i < list.length; ++i ) - process( baseDir, list[i], destDir, stylesheet ); + process( baseDir, list[ i ], destDir, stylesheet ); } } @@ -306,7 +292,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } else @@ -338,7 +324,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger e4.printStackTrace(); e3.printStackTrace(); e2.printStackTrace(); - throw new BuildException( e1 ); + throw new BuildException( "Error", e1 ); } } } @@ -367,16 +353,16 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { log( "Loading stylesheet " + stylesheet, Project.MSG_INFO ); liaison.setStylesheet( stylesheet ); - for( Enumeration e = params.elements(); e.hasMoreElements(); ) + for( Enumeration e = params.elements(); e.hasMoreElements(); ) { - Param p = ( Param )e.nextElement(); + Param p = (Param)e.nextElement(); liaison.addParam( p.getName(), p.getExpression() ); } } catch( Exception ex ) { log( "Failed to read stylesheet " + stylesheet, Project.MSG_INFO ); - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } @@ -389,7 +375,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger if( !directory.mkdirs() ) { throw new BuildException( "Unable to create directory: " - + directory.getAbsolutePath() ); + + directory.getAbsolutePath() ); } } } @@ -471,7 +457,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger outFile.delete(); } - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } }//-- processXML @@ -500,7 +486,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger log( "Failed to process " + inFile, Project.MSG_INFO ); if( outFile != null ) outFile.delete(); - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } @@ -518,31 +504,17 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { final Class clazz = loadClass( "org.apache.tools.ant.taskdefs.optional.TraXLiaison" ); - liaison = ( XSLTLiaison )clazz.newInstance(); - } - else if( proc.equals( "xslp" ) ) - { - log( "DEPRECATED - xslp processor is deprecated. Use trax or xalan instead." ); - final Class clazz = - loadClass( "org.apache.tools.ant.taskdefs.optional.XslpLiaison" ); - liaison = ( XSLTLiaison )clazz.newInstance(); + liaison = (XSLTLiaison)clazz.newInstance(); } else if( proc.equals( "xalan" ) ) { final Class clazz = loadClass( "org.apache.tools.ant.taskdefs.optional.XalanLiaison" ); - liaison = ( XSLTLiaison )clazz.newInstance(); - } - else if( proc.equals( "adaptx" ) ) - { - log( "DEPRECATED - adaptx processor is deprecated. Use trax or xalan instead." ); - final Class clazz = - loadClass( "org.apache.tools.ant.taskdefs.optional.AdaptxLiaison" ); - liaison = ( XSLTLiaison )clazz.newInstance(); + liaison = (XSLTLiaison)clazz.newInstance(); } else { - liaison = ( XSLTLiaison )loadClass( proc ).newInstance(); + liaison = (XSLTLiaison)loadClass( proc ).newInstance(); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Zip.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Zip.java index 802ec0476..6317eb017 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Zip.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/Zip.java @@ -184,18 +184,6 @@ public class Zip extends MatchingTask emptyBehavior = we.getValue(); } - /** - * This is the name/location of where to create the .zip file. - * - * @param zipFile The new Zipfile value - * @deprecated Use setFile() instead - */ - public void setZipfile( File zipFile ) - { - log( "DEPRECATED - The zipfile attribute is deprecated. Use file attribute instead." ); - setFile( zipFile ); - } - /** * Are we updating an existing archive? * @@ -383,7 +371,7 @@ public class Zip extends MatchingTask } } - throw new BuildException( msg, ioe, location ); + throw new BuildException( msg, ioe ); } finally { @@ -439,7 +427,7 @@ public class Zip extends MatchingTask else if( emptyBehavior.equals( "fail" ) ) { throw new BuildException( "Cannot create " + archiveType + " archive " + zipFile + - ": no files were included.", location ); + ": no files were included." ); } else { @@ -453,7 +441,7 @@ public class Zip extends MatchingTask { if( files[i].equals( zipFile ) ) { - throw new BuildException( "A zip file cannot include itself", location ); + throw new BuildException( "A zip file cannot include itself" ); } } @@ -741,7 +729,7 @@ public class Zip extends MatchingTask } catch( IOException ioe ) { - throw new BuildException( "Could not create empty ZIP archive", ioe, location ); + throw new BuildException( "Could not create empty ZIP archive", ioe ); } return true; } @@ -858,7 +846,7 @@ public class Zip extends MatchingTask { if( file.equals( zipFile ) ) { - throw new BuildException( "A zip file cannot include itself", location ); + throw new BuildException( "A zip file cannot include itself" ); } FileInputStream fIn = new FileInputStream( file ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index a4675b48d..8396985a1 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -414,7 +414,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter } catch( IOException e ) { - throw new BuildException( "Error creating temporary file", e, location ); + throw new BuildException( "Error creating temporary file", e ); } finally { @@ -448,7 +448,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter catch( IOException e ) { throw new BuildException( "Error running " + args[0] - + " compiler", e, location ); + + " compiler", e ); } } finally diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac12.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac12.java index 9eee2523a..c5927bacd 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac12.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac12.java @@ -52,7 +52,7 @@ public class Javac12 extends DefaultCompilerAdapter { 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.", location ); + " JAVA_HOME to your jdk directory." ); } catch( Exception ex ) { @@ -62,7 +62,7 @@ public class Javac12 extends DefaultCompilerAdapter } else { - throw new BuildException( "Error starting classic compiler: ", ex, location ); + throw new BuildException( "Error starting classic compiler: ", ex ); } } finally @@ -74,7 +74,7 @@ public class Javac12 extends DefaultCompilerAdapter catch( IOException e ) { // plain impossible - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac13.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac13.java index 7516d43c9..c0f5f4bc7 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac13.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Javac13.java @@ -55,7 +55,7 @@ public class Javac13 extends DefaultCompilerAdapter } else { - throw new BuildException( "Error starting modern compiler", ex, location ); + throw new BuildException( "Error starting modern compiler", ex ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Jikes.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Jikes.java index a45f64c3c..e6e869e60 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Jikes.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Jikes.java @@ -131,23 +131,6 @@ public class Jikes extends DefaultCompilerAdapter cmd.createArgument().setValue( "+E" ); } - /** - * Jikes issues more warnings that javac, for example, when you have - * files in your classpath that don't exist. As this is often the case, - * these warning can be pretty annoying. - */ - String warningsProperty = project.getProperty( "build.compiler.warnings" ); - if( warningsProperty != null ) - { - attributes.log( "!! the build.compiler.warnings property is deprecated. !!", - Project.MSG_WARN ); - attributes.log( "!! Use the nowarn attribute instead. !!", - Project.MSG_WARN ); - if( !Project.toBoolean( warningsProperty ) ) - { - cmd.createArgument().setValue( "-nowarn" ); - } - } if( attributes.getNowarn() ) { /* diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Kjc.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Kjc.java index 2cb2bdc48..4aa6a8c5d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Kjc.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/Kjc.java @@ -42,7 +42,7 @@ public class Kjc extends DefaultCompilerAdapter { 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).", location ); + " CLASSPATH to your kjc archive (kjc.jar)." ); } catch( Exception ex ) { @@ -52,7 +52,7 @@ public class Kjc extends DefaultCompilerAdapter } else { - throw new BuildException( "Error starting kjc compiler: ", ex, location ); + throw new BuildException( "Error starting kjc compiler: ", ex ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/defaults.properties b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/defaults.properties index c680c8f92..e31998fb6 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/defaults.properties +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/defaults.properties @@ -132,10 +132,3 @@ jspc=org.apache.tools.ant.taskdefs.optional.jsp.JspC replaceregexp=org.apache.tools.ant.taskdefs.optional.ReplaceRegExp translate=org.apache.tools.ant.taskdefs.optional.i18n.Translate -# deprecated ant tasks (kept for back compatibility) -javadoc2=org.apache.tools.ant.taskdefs.Javadoc -#compileTask=org.apache.tools.ant.taskdefs.CompileTask -copydir=org.apache.tools.ant.taskdefs.Copydir -copyfile=org.apache.tools.ant.taskdefs.Copyfile -deltree=org.apache.tools.ant.taskdefs.Deltree -rename=org.apache.tools.ant.taskdefs.Rename diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java index 7269bf2b2..2508be19e 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ANTLR.java @@ -6,13 +6,13 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs.optional; + import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.net.URL; import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.ExitException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Execute; @@ -20,7 +20,6 @@ import org.apache.tools.ant.taskdefs.ExecuteJava; import org.apache.tools.ant.taskdefs.LogStreamHandler; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; -import org.apache.tools.ant.types.Environment; import org.apache.tools.ant.types.Path; /** @@ -128,7 +127,7 @@ public class ANTLR extends Task int err = run( commandline.getCommandline() ); if( err == 1 ) { - throw new BuildException( "ANTLR returned: " + err, location ); + throw new BuildException( "ANTLR returned: " + err ); } } else @@ -136,17 +135,7 @@ public class ANTLR extends Task ExecuteJava exe = new ExecuteJava(); exe.setJavaCommand( commandline.getJavaCommand() ); exe.setClasspath( commandline.getClasspath() ); - try - { - exe.execute( project ); - } - catch( ExitException e ) - { - if( e.getStatus() != 0 ) - { - throw new BuildException( "ANTLR returned: " + e.getStatus(), location ); - } - } + exe.execute( project ); } } } @@ -183,7 +172,7 @@ public class ANTLR extends Task int pling = u.indexOf( "!" ); String jarName = u.substring( 9, pling ); log( "Implicitly adding " + jarName + " to classpath", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); createClasspath().setLocation( new File( ( new File( jarName ) ).getAbsolutePath() ) ); } else if( u.startsWith( "file:" ) ) @@ -191,13 +180,13 @@ public class ANTLR extends Task int tail = u.indexOf( resource ); String dirName = u.substring( 5, tail ); log( "Implicitly adding " + dirName + " to classpath", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); createClasspath().setLocation( new File( ( new File( dirName ) ).getAbsolutePath() ) ); } else { log( "Don\'t know how to handle resource URL " + u, - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } } else @@ -247,7 +236,7 @@ public class ANTLR extends Task throws BuildException { Execute exe = new Execute( new LogStreamHandler( this, Project.MSG_INFO, - Project.MSG_WARN ), null ); + Project.MSG_WARN ), null ); exe.setAntRun( project ); if( workingdir != null ) { @@ -260,7 +249,7 @@ public class ANTLR extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/IContract.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/IContract.java index cc52a4708..8f60da24c 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/IContract.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/IContract.java @@ -897,27 +897,27 @@ public class IContract extends MatchingTask { if( srcDir == null ) { - throw new BuildException( "srcdir attribute must be set!", location ); + throw new BuildException( "srcdir attribute must be set!" ); } if( !srcDir.exists() ) { - throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!", location ); + throw new BuildException( "srcdir \"" + srcDir.getPath() + "\" does not exist!"); } if( instrumentDir == null ) { - throw new BuildException( "instrumentdir attribute must be set!", location ); + throw new BuildException( "instrumentdir attribute must be set!"); } if( repositoryDir == null ) { - throw new BuildException( "repositorydir attribute must be set!", location ); + throw new BuildException( "repositorydir attribute must be set!" ); } if( updateIcontrol == true && classDir == null ) { - throw new BuildException( "classdir attribute must be specified when updateicontrol=true!", location ); + throw new BuildException( "classdir attribute must be specified when updateicontrol=true!" ); } if( updateIcontrol == true && controlFile == null ) { - throw new BuildException( "controlfile attribute must be specified when updateicontrol=true!", location ); + throw new BuildException( "controlfile attribute must be specified when updateicontrol=true!" ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Javah.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Javah.java index 76d48b24c..cdd5faaaf 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Javah.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Javah.java @@ -238,23 +238,23 @@ public class Javah extends Task if( ( cls == null ) && ( classes.size() == 0 ) ) { - throw new BuildException( "class attribute must be set!", location ); + throw new BuildException( "class attribute must be set!" ); } if( ( cls != null ) && ( classes.size() > 0 ) ) { - throw new BuildException( "set class attribute or class element, not both.", location ); + throw new BuildException( "set class attribute or class element, not both." ); } if( destDir != null ) { if( !destDir.isDirectory() ) { - throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory", location ); + throw new BuildException( "destination directory \"" + destDir + "\" does not exist or is not a directory" ); } if( outputFile != null ) { - throw new BuildException( "destdir and outputFile are mutually exclusive", location ); + throw new BuildException( "destdir and outputFile are mutually exclusive"); } } @@ -381,7 +381,7 @@ public class Javah extends Task { if( !old ) { - throw new BuildException( "stubs only available in old mode.", location ); + throw new BuildException( "stubs only available in old mode." ); } cmd.createArgument().setValue( "-stubs" ); } @@ -442,7 +442,7 @@ public class Javah extends Task } else { - throw new BuildException( "Error starting javah: ", ex, location ); + throw new BuildException( "Error starting javah: ", ex ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ManifestFile.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ManifestFile.java index 4ef6878db..29c3680f4 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ManifestFile.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ManifestFile.java @@ -161,7 +161,7 @@ public class ManifestFile extends Task { if( !checkParam( manifestFile ) ) { - throw new BuildException( "file token must not be null.", location ); + throw new BuildException( "file token must not be null." ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java index 882335c60..413aec28c 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java @@ -100,8 +100,7 @@ public class Native2Ascii extends MatchingTask { if( mapper != null ) { - throw new BuildException( "Cannot define more than one mapper", - location ); + throw new BuildException( "Cannot define more than one mapper" ); } mapper = new Mapper( project ); return mapper; @@ -118,7 +117,7 @@ public class Native2Ascii extends MatchingTask // default srcDir to basedir if( srcDir == null ) { - srcDir = project.resolveFile( "." ); + srcDir = resolveFile( "." ); } // Require destDir diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/NetRexxC.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/NetRexxC.java index 3b05253a1..a33bd080b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/NetRexxC.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/NetRexxC.java @@ -19,6 +19,7 @@ import netrexx.lang.Rexx; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; +import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.taskdefs.MatchingTask; /** @@ -586,7 +587,7 @@ public class NetRexxC extends MatchingTask System.getProperty( "path.separator" ), false ); while( tok.hasMoreTokens() ) { - File f = project.resolveFile( tok.nextToken() ); + File f = resolveFile( tok.nextToken() ); if( f.exists() ) { @@ -619,7 +620,7 @@ public class NetRexxC extends MatchingTask String toFile = ( String )filecopyList.get( fromFile ); try { - project.copyFile( fromFile, toFile ); + FileUtils.newFileUtils().copyFile( fromFile, toFile ); } catch( IOException ioe ) { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/PropertyFile.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/PropertyFile.java index ab7bfd7b1..c185769d7 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/PropertyFile.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/PropertyFile.java @@ -204,7 +204,7 @@ public class PropertyFile extends Task { if( !checkParam( m_propertyfile ) ) { - throw new BuildException( "file token must not be null.", location ); + throw new BuildException( "file token must not be null." ); } } @@ -293,16 +293,16 @@ public class PropertyFile extends Task catch( InvocationTargetException ite ) { Throwable t = ite.getTargetException(); - throw new BuildException( t ); + throw new BuildException( "Error", t ); } catch( IllegalAccessException iae ) { // impossible - throw new BuildException( iae ); + throw new BuildException( "Error", iae ); } catch( IOException ioe ) { - throw new BuildException( ioe ); + throw new BuildException( "Error", ioe ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Rpm.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Rpm.java index 3811e701b..a681c349f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Rpm.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Rpm.java @@ -102,7 +102,7 @@ public class Rpm extends Task { if( ( sf == null ) || ( sf.trim().equals( "" ) ) ) { - throw new BuildException( "You must specify a spec file", location ); + throw new BuildException( "You must specify a spec file" ); } this.specFile = sf; } @@ -160,7 +160,7 @@ public class Rpm extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } else @@ -175,7 +175,7 @@ public class Rpm extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } else @@ -200,7 +200,7 @@ public class Rpm extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Script.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Script.java index 43a545ec1..294ea0ba8 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Script.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/Script.java @@ -59,7 +59,7 @@ public class Script extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } script += new String( data ); @@ -121,7 +121,7 @@ public class Script extends Task t = te; } } - throw new BuildException( t ); + throw new BuildException( "Error", t ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java index 974e06ce5..3105ead43 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java @@ -127,7 +127,7 @@ public class CCMCheck extends Continuus if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java index f4ed8a11a..35f9391e7 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMCreateTask.java @@ -280,7 +280,7 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } //create task ok, set this task as the default one @@ -295,7 +295,7 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler if( result != 0 ) { String msg = "Failed executing: " + commandLine2.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java index d079f2ae7..388599fba 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/CCMReconfigure.java @@ -133,7 +133,7 @@ public class CCMReconfigure extends Continuus if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java index efc30650d..ad7cdb5b5 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java @@ -120,7 +120,7 @@ public abstract class Continuus extends Task } catch( java.io.IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java index e4104295a..891d53a45 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java @@ -348,7 +348,7 @@ public class CCCheckin extends ClearCase if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java index 7c649bc5b..123c1d040 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java @@ -435,7 +435,7 @@ public class CCCheckout extends ClearCase if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java index 02a442f2c..96b994bc4 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java @@ -139,7 +139,7 @@ public class CCUnCheckout extends ClearCase if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java index 2d88f71c4..9d9e5f1de 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java @@ -352,7 +352,7 @@ public class CCUpdate extends ClearCase if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java index 917152f39..9f003d69f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java @@ -116,7 +116,7 @@ public abstract class ClearCase extends Task } catch( java.io.IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/depend/Depend.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/depend/Depend.java index 62ec1812e..01196c9b7 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/depend/Depend.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/depend/Depend.java @@ -201,7 +201,7 @@ public class Depend extends MatchingTask String[] srcPathList = srcPath.list(); if( srcPathList.length == 0 ) { - throw new BuildException( "srcdir attribute must be set!", location ); + throw new BuildException( "srcdir attribute must be set!" ); } if( destPath == null ) @@ -261,7 +261,7 @@ public class Depend extends MatchingTask outOfDateClasses = new Hashtable(); for( int i = 0; i < srcPathList.length; i++ ) { - File srcDir = ( File )project.resolveFile( srcPathList[i] ); + File srcDir = ( File )resolveFile( srcPathList[i] ); if( srcDir.exists() ) { DirectoryScanner ds = this.getDirectoryScanner( srcDir ); @@ -310,7 +310,7 @@ public class Depend extends MatchingTask } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java index 371264a4a..fabadd12b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java @@ -649,7 +649,7 @@ public class CSharp throws BuildException { if( _srcDir == null ) - _srcDir = project.resolveFile( "." ); + _srcDir = resolveFile( "." ); NetCommand command = new NetCommand( this, "CSC", csc_exe_name ); command.setFailOnError( getFailFailOnError() ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java index b1440d32f..c5e94ca64 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/Ilasm.java @@ -310,7 +310,7 @@ public class Ilasm throws BuildException { if( _srcDir == null ) - _srcDir = project.resolveFile( "." ); + _srcDir = resolveFile( "." ); //get dependencies list. DirectoryScanner scanner = super.getDirectoryScanner( _srcDir ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java index 4f28dffe7..74ed0e33e 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/dotnet/NetCommand.java @@ -158,7 +158,7 @@ public class NetCommand { if( _failOnError ) { - throw new BuildException( _title + " returned: " + err, _owner.getLocation() ); + throw new BuildException( _title + " returned: " + err ); } else { @@ -168,7 +168,7 @@ public class NetCommand } catch( IOException e ) { - throw new BuildException( _title + " failed: " + e, e, _owner.getLocation() ); + throw new BuildException( _title + " failed: " + e, e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java index ff7a72719..5f37ba9c4 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java @@ -396,13 +396,13 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exec if( result != 0 ) { String msg = "Failed executing java2iiop (ret code is " + result + ")"; - throw new BuildException( msg, getTask().getLocation() ); + throw new BuildException( msg ); } } catch( java.io.IOException e ) { log( "java2iiop exception :" + e.getMessage(), Project.MSG_ERR ); - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java index 29a49f9aa..6343dbbb2 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java @@ -307,7 +307,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { String msg = "A valid destination directory must be specified " + "using the \"destdir\" attribute."; - throw new BuildException( msg, getLocation() ); + throw new BuildException( msg ); } } @@ -859,8 +859,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool in = new FileInputStream( config.manifest ); if( in == null ) { - throw new BuildException( "Could not find manifest file: " + config.manifest, - getLocation() ); + throw new BuildException( "Could not find manifest file: " + config.manifest ); } } else @@ -869,8 +868,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool in = this.getClass().getResourceAsStream( defaultManifest ); if( in == null ) { - throw new BuildException( "Could not find default manifest: " + defaultManifest, - getLocation() ); + throw new BuildException( "Could not find default manifest: " + defaultManifest ); } } @@ -878,7 +876,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool } catch( IOException e ) { - throw new BuildException( "Unable to read manifest", e, getLocation() ); + throw new BuildException( "Unable to read manifest", e ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java index 0dfdd0041..8c647dc47 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetDeploymentTool.java @@ -218,7 +218,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool + " descriptor should be prepended with the JAR " + "name or it should be specified using the " + "attribute \"basejarname\" in the \"ejbjar\" task."; - throw new BuildException( msg, getLocation() ); + throw new BuildException( msg ); } File iasDescriptor = new File( getConfig().descriptorDir, @@ -227,14 +227,14 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool { String msg = "The iAS-specific EJB descriptor (" + iasDescriptor + ") was not found."; - throw new BuildException( msg, getLocation() ); + throw new BuildException( msg ); } if( ( iashome != null ) && ( !iashome.isDirectory() ) ) { String msg = "If \"iashome\" is specified, it must be a valid " + "directory (it was set to " + iashome + ")."; - throw new BuildException( msg, getLocation() ); + throw new BuildException( msg ); } } @@ -287,7 +287,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool catch( IPlanetEjbc.EjbcException e ) { throw new BuildException( "An error has occurred while trying to " - + "execute the iAS ejbc utility", e, getLocation() ); + + "execute the iAS ejbc utility", e ); } displayName = ejbc.getDisplayName(); @@ -313,7 +313,7 @@ public class IPlanetDeploymentTool extends GenericDeploymentTool if( !cmpFile.exists() ) { throw new BuildException( "The CMP descriptor file (" - + cmpFile + ") could not be found.", getLocation() ); + + cmpFile + ") could not be found." ); } files.put( cmpDescriptors[i], cmpFile ); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java index ce5f22396..bc6ba5c99 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java @@ -229,12 +229,12 @@ public class IPlanetEjbcTask extends Task catch( SAXException e ) { String msg = "Unable to create a SAXParser: " + e.getMessage(); - throw new BuildException( msg, e, location ); + throw new BuildException( msg, e ); } catch( ParserConfigurationException e ) { String msg = "Unable to create a SAXParser: " + e.getMessage(); - throw new BuildException( msg, e, location ); + throw new BuildException( msg, e ); } return saxParser; @@ -253,46 +253,46 @@ public class IPlanetEjbcTask extends Task { String msg = "The standard EJB descriptor must be specified using " + "the \"ejbdescriptor\" attribute."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( ( !ejbdescriptor.exists() ) || ( !ejbdescriptor.isFile() ) ) { String msg = "The standard EJB descriptor (" + ejbdescriptor + ") was not found or isn't a file."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( iasdescriptor == null ) { String msg = "The iAS-speific XML descriptor must be specified using" + " the \"iasdescriptor\" attribute."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( ( !iasdescriptor.exists() ) || ( !iasdescriptor.isFile() ) ) { String msg = "The iAS-specific XML descriptor (" + iasdescriptor + ") was not found or isn't a file."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( dest == null ) { String msg = "The destination directory must be specified using " + "the \"dest\" attribute."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( ( !dest.exists() ) || ( !dest.isDirectory() ) ) { String msg = "The destination directory (" + dest + ") was not " + "found or isn't a directory."; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( ( iashome != null ) && ( !iashome.isDirectory() ) ) { String msg = "If \"iashome\" is specified, it must be a valid " + "directory (it was set to " + iashome + ")."; - throw new BuildException( msg, getLocation() ); + throw new BuildException( msg ); } } @@ -327,19 +327,19 @@ public class IPlanetEjbcTask extends Task { String msg = "An IOException occurred while trying to read the XML " + "descriptor file: " + e.getMessage(); - throw new BuildException( msg, e, location ); + throw new BuildException( msg, e ); } catch( SAXException e ) { String msg = "A SAXException occurred while trying to read the XML " + "descriptor file: " + e.getMessage(); - throw new BuildException( msg, e, location ); + throw new BuildException( msg, e ); } catch( IPlanetEjbc.EjbcException e ) { String msg = "An exception occurred while trying to run the ejbc " + "utility: " + e.getMessage(); - throw new BuildException( msg, e, location ); + throw new BuildException( msg, e ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java index e4d43714a..227763d2d 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java @@ -304,7 +304,7 @@ public class WLRun extends Task if( !propertiesFile.exists() ) { // OK, properties file may be absolute - propertiesFile = project.resolveFile( weblogicPropertiesFile ); + propertiesFile = resolveFile( weblogicPropertiesFile ); if( !propertiesFile.exists() ) { throw new BuildException( "Properties file " + weblogicPropertiesFile + @@ -411,7 +411,7 @@ public class WLRun extends Task // absolute path. Use the project to resolve it. if( this.securityPolicy != null && !securityPolicyFile.exists() ) { - securityPolicyFile = project.resolveFile( securityPolicy ); + securityPolicyFile = resolveFile( securityPolicy ); } // If we still can't find it, complain if( !securityPolicyFile.exists() ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java index ddd1d9e6e..a84e8a330 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java @@ -6,12 +6,24 @@ * the LICENSE file. */ package org.apache.tools.ant.taskdefs.optional.i18n; -import java.io.*; -import java.util.*; -import org.apache.tools.ant.*; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.Hashtable; +import java.util.Locale; +import java.util.Vector; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.MatchingTask; -import org.apache.tools.ant.types.*; -import org.apache.tools.ant.util.*; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.util.FileUtils; /** * Translates text embedded in files using Resource Bundle files. @@ -35,7 +47,7 @@ public class Translate extends MatchingTask /** * Last Modified Timestamp of resource bundle file being used. */ - private long[] bundleLastModified = new long[7]; + private long[] bundleLastModified = new long[ 7 ]; /** * Has at least one file from the bundle been loaded? */ @@ -229,34 +241,29 @@ public class Translate extends MatchingTask { if( bundle == null ) { - throw new BuildException( "The bundle attribute must be set.", - location ); + throw new BuildException( "The bundle attribute must be set." ); } if( startToken == null ) { - throw new BuildException( "The starttoken attribute must be set.", - location ); + throw new BuildException( "The starttoken attribute must be set." ); } if( startToken.length() != 1 ) { throw new BuildException( - "The starttoken attribute must be a single character.", - location ); + "The starttoken attribute must be a single character." ); } if( endToken == null ) { - throw new BuildException( "The endtoken attribute must be set.", - location ); + throw new BuildException( "The endtoken attribute must be set." ); } if( endToken.length() != 1 ) { throw new BuildException( - "The endtoken attribute must be a single character.", - location ); + "The endtoken attribute must be a single character." ); } if( bundleLanguage == null ) @@ -280,8 +287,7 @@ public class Translate extends MatchingTask if( toDir == null ) { - throw new BuildException( "The todir attribute must be set.", - location ); + throw new BuildException( "The todir attribute must be set." ); } if( !toDir.exists() ) @@ -391,7 +397,7 @@ public class Translate extends MatchingTask } catch( IOException ioe ) { - throw new BuildException( ioe.getMessage(), location ); + throw new BuildException( ioe.getMessage() ); } } @@ -415,8 +421,8 @@ public class Translate extends MatchingTask throws BuildException { Locale locale = new Locale( bundleLanguage, - bundleCountry, - bundleVariant ); + bundleCountry, + bundleVariant ); String language = locale.getLanguage().length() > 0 ? "_" + locale.getLanguage() : ""; @@ -481,7 +487,7 @@ public class Translate extends MatchingTask { ins = new FileInputStream( bundleFile ); loaded = true; - bundleLastModified[i] = new File( bundleFile ).lastModified(); + bundleLastModified[ i ] = new File( bundleFile ).lastModified(); log( "Using " + bundleFile, Project.MSG_DEBUG ); loadResourceMap( ins ); } @@ -493,7 +499,7 @@ public class Translate extends MatchingTask //find a single resrouce file, throw exception if( !loaded && checkLoaded ) { - throw new BuildException( ioe.getMessage(), location ); + throw new BuildException( ioe.getMessage() ); } } } @@ -515,14 +521,14 @@ public class Translate extends MatchingTask { for( int i = 0; i < filesets.size(); i++ ) { - FileSet fs = ( FileSet )filesets.elementAt( i ); + FileSet fs = (FileSet)filesets.elementAt( i ); DirectoryScanner ds = fs.getDirectoryScanner( project ); String[] srcFiles = ds.getIncludedFiles(); for( int j = 0; j < srcFiles.length; j++ ) { try { - File dest = fileUtils.resolveFile( toDir, srcFiles[j] ); + File dest = fileUtils.resolveFile( toDir, srcFiles[ j ] ); //Make sure parent dirs exist, else, create them. try { @@ -536,31 +542,31 @@ public class Translate extends MatchingTask { log( "Exception occured while trying to check/create " + " parent directory. " + e.getMessage(), - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); } destLastModified = dest.lastModified(); - srcLastModified = new File( srcFiles[i] ).lastModified(); + srcLastModified = new File( srcFiles[ i ] ).lastModified(); //Check to see if dest file has to be recreated if( forceOverwrite - || destLastModified < srcLastModified - || destLastModified < bundleLastModified[0] - || destLastModified < bundleLastModified[1] - || destLastModified < bundleLastModified[2] - || destLastModified < bundleLastModified[3] - || destLastModified < bundleLastModified[4] - || destLastModified < bundleLastModified[5] - || destLastModified < bundleLastModified[6] ) + || destLastModified < srcLastModified + || destLastModified < bundleLastModified[ 0 ] + || destLastModified < bundleLastModified[ 1 ] + || destLastModified < bundleLastModified[ 2 ] + || destLastModified < bundleLastModified[ 3 ] + || destLastModified < bundleLastModified[ 4 ] + || destLastModified < bundleLastModified[ 5 ] + || destLastModified < bundleLastModified[ 6 ] ) { - log( "Processing " + srcFiles[j], - Project.MSG_DEBUG ); + log( "Processing " + srcFiles[ j ], + Project.MSG_DEBUG ); FileOutputStream fos = new FileOutputStream( dest ); BufferedWriter out = new BufferedWriter( new OutputStreamWriter( fos, - destEncoding ) ); - FileInputStream fis = new FileInputStream( srcFiles[j] ); + destEncoding ) ); + FileInputStream fis = new FileInputStream( srcFiles[ j ] ); BufferedReader in = new BufferedReader( new InputStreamReader( fis, - srcEncoding ) ); + srcEncoding ) ); String line; while( ( line = in.readLine() ) != null ) { @@ -582,7 +588,7 @@ public class Translate extends MatchingTask break; } String matches = line.substring( startIndex + 1, - endIndex ); + endIndex ); //If there is a white space or = or :, then //it isn't to be treated as a valid key. for( int k = 0; k < matches.length(); k++ ) @@ -597,19 +603,19 @@ public class Translate extends MatchingTask } } String replace = null; - replace = ( String )resourceMap.get( matches ); + replace = (String)resourceMap.get( matches ); //If the key hasn't been loaded into resourceMap, //use the key itself as the value also. if( replace == null ) { log( "Warning: The key: " + matches + " hasn't been defined.", - Project.MSG_DEBUG ); + Project.MSG_DEBUG ); replace = matches; } line = line.substring( 0, startIndex ) - + replace - + line.substring( endIndex + 1 ); + + replace + + line.substring( endIndex + 1 ); endIndex = startIndex + replace.length() + 1; if( endIndex + 1 >= line.length() ) { @@ -630,14 +636,14 @@ public class Translate extends MatchingTask } else { - log( "Skipping " + srcFiles[j] + - " as destination file is up to date", - Project.MSG_VERBOSE ); + log( "Skipping " + srcFiles[ j ] + + " as destination file is up to date", + Project.MSG_VERBOSE ); } } catch( IOException ioe ) { - throw new BuildException( ioe.getMessage(), location ); + throw new BuildException( ioe.getMessage() ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java index 247c2427a..729090720 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java @@ -392,7 +392,7 @@ abstract class VAJLocalUtil implements VAJUtil } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } if( files.size() > 0 ) { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java index c14253574..119ce308f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java @@ -69,7 +69,7 @@ class VAJRemoteUtil implements VAJUtil } catch( Exception ex ) { - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } @@ -104,7 +104,7 @@ class VAJRemoteUtil implements VAJUtil } catch( Exception ex ) { - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } @@ -135,7 +135,7 @@ class VAJRemoteUtil implements VAJUtil } catch( Exception ex ) { - throw new BuildException( ex ); + throw new BuildException( "Error", ex ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java index c8e6da765..2efdae7e3 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java @@ -280,8 +280,7 @@ public class JDependTask extends Task if( errorOccurred ) { if( getHaltonerror() ) - throw new BuildException( "JDepend failed", - location ); + throw new BuildException( "JDepend failed" ); else log( "JDepend FAILED", Project.MSG_ERR ); } @@ -352,7 +351,7 @@ public class JDependTask extends Task } catch( IOException e ) { - throw new BuildException( "Process fork failed.", e, location ); + throw new BuildException( "Process fork failed.", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java index 94d642f0c..a053c2111 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.java @@ -173,7 +173,7 @@ public class JlinkTask extends MatchingTask } catch( Exception ex ) { - throw new BuildException( ex); + throw new BuildException( "Error", ex); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java index 2d91db4ca..ae6938f5a 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java @@ -323,22 +323,19 @@ public class JspC extends MatchingTask // first off, make sure that we've got a srcdir if( src == null ) { - throw new BuildException( "srcdir attribute must be set!", - location ); + throw new BuildException( "srcdir attribute must be set!" ); } String[] list = src.list(); if( list.length == 0 ) { - throw new BuildException( "srcdir attribute must be set!", - location ); + throw new BuildException( "srcdir attribute must be set!" ); } if( destDir != null && !destDir.isDirectory() ) { throw new BuildException( "destination directory \"" + destDir + - "\" does not exist or is not a directory", - location ); + "\" does not exist or is not a directory" ); } // calculate where the files will end up: @@ -358,11 +355,11 @@ public class JspC extends MatchingTask int filecount = 0; for( int i = 0; i < list.length; i++ ) { - File srcDir = ( File )project.resolveFile( list[i] ); + File srcDir = ( File )resolveFile( list[i] ); if( !srcDir.exists() ) { throw new BuildException( "srcdir \"" + srcDir.getPath() + - "\" does not exist!", location ); + "\" does not exist!" ); } DirectoryScanner ds = this.getDirectoryScanner( srcDir ); @@ -399,7 +396,7 @@ public class JspC extends MatchingTask { if( failOnError ) { - throw new BuildException( FAIL_MSG, location ); + throw new BuildException( FAIL_MSG ); } else { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java index 20d7a9176..0c8e43a4b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java @@ -149,7 +149,7 @@ public class WLJspc extends MatchingTask if( destinationPackage == null ) { - throw new BuildException( "package attribute must be present.", location ); + throw new BuildException( "package attribute must be present." ); } String systemClassPath = System.getProperty( "java.class.path" ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java index 4f0985bbf..bd169b9f6 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java @@ -53,7 +53,7 @@ public class JasperC extends DefaultCompilerAdapter else { throw new BuildException( "Error running jsp compiler: ", - ex, getJspc().getLocation() ); + ex ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java index 0d1e7e9d7..123c51854 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java @@ -17,6 +17,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; +import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.types.EnumeratedAttribute; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -216,11 +217,12 @@ public class AggregateTransformer // set the destination directory relative from the project if needed. if( toDir == null ) { - toDir = task.getProject().resolveFile( "." ); + toDir = FileUtils.newFileUtils().resolveFile( task.getProject().getBaseDir(), "." ); } else if( !toDir.isAbsolute() ) { - toDir = task.getProject().resolveFile( toDir.getPath() ); + toDir = FileUtils.newFileUtils(). + resolveFile( task.getProject().getBaseDir(), toDir.getPath() ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java index b7db0aa61..5bc2dc3a9 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java @@ -185,7 +185,7 @@ public class FormatterElement } catch( ClassNotFoundException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } Object o = null; @@ -195,11 +195,11 @@ public class FormatterElement } catch( InstantiationException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } catch( IllegalAccessException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } if( !( o instanceof JUnitResultFormatter ) ) @@ -217,7 +217,7 @@ public class FormatterElement } catch( java.io.IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } r.setOutput( out ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index b53a45da3..42e0488e5 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -443,7 +443,7 @@ public class JUnitTask extends Task String filename = test.getOutfile() + fe.getExtension(); File destFile = new File( test.getTodir(), filename ); String absFilename = destFile.getAbsolutePath(); - return project.resolveFile( absFilename ); + return resolveFile( absFilename ); } return null; } @@ -525,7 +525,7 @@ public class JUnitTask extends Task //@todo should be moved to the test class instead. if( test.getTodir() == null ) { - test.setTodir( project.resolveFile( "." ) ); + test.setTodir( resolveFile( "." ) ); } if( test.getOutfile() == null ) @@ -561,8 +561,7 @@ public class JUnitTask extends Task || failureOccurredHere && test.getHaltonfailure() ) { throw new BuildException( "Test " + test.getName() + " failed" - + ( wasKilled ? " (timeout)" : "" ), - location ); + + ( wasKilled ? " (timeout)" : "" ) ); } else { @@ -672,7 +671,7 @@ public class JUnitTask extends Task } catch( java.io.IOException e ) { - throw new BuildException( "Error creating temporary properties file.", e, location ); + throw new BuildException( "Error creating temporary properties file.", e ); } Execute execute = new Execute( new LogStreamHandler( this, Project.MSG_INFO, Project.MSG_WARN ), watchdog ); @@ -691,7 +690,7 @@ public class JUnitTask extends Task } catch( IOException e ) { - throw new BuildException( "Process fork failed.", e, location ); + throw new BuildException( "Process fork failed.", e ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java index cc72e239f..bdbf5233f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java @@ -24,6 +24,7 @@ import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.util.DOMElementWriter; import org.apache.tools.ant.util.StringUtils; +import org.apache.tools.ant.util.FileUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; @@ -185,7 +186,7 @@ public class XMLResultAggregator extends Task implements XMLConstants } if( toDir == null ) { - toDir = project.resolveFile( DEFAULT_DIR ); + toDir = FileUtils.newFileUtils().resolveFile( project.getBaseDir(), DEFAULT_DIR ); } return new File( toDir, toFile ); } @@ -211,7 +212,8 @@ public class XMLResultAggregator extends Task implements XMLConstants if( pathname.endsWith( ".xml" ) ) { File file = new File( ds.getBasedir(), pathname ); - file = project.resolveFile( file.getPath() ); + file = FileUtils.newFileUtils(). + resolveFile( project.getBaseDir(), file.getPath() ); v.addElement( file ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java index 500cddfd7..31b5ff0c9 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java @@ -276,7 +276,7 @@ public abstract class AbstractMetamataTask extends Task { throw new BuildException( "'metamatahome' must point to Metamata home directory." ); } - metamataHome = project.resolveFile( metamataHome.getPath() ); + metamataHome = resolveFile( metamataHome.getPath() ); File jar = getMetamataJar( metamataHome ); if( !jar.exists() ) { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MAudit.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MAudit.java index 80c5415bb..900bdc243 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MAudit.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MAudit.java @@ -238,7 +238,7 @@ public class MAudit extends AbstractMetamataTask } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } return handler; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java index efbc76c0a..1e25b6b93 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java @@ -336,7 +336,7 @@ public class MParse extends Task { throw new BuildException( "'metamatahome' must point to Metamata home directory." ); } - metahome = project.resolveFile( metahome.getPath() ); + metahome = resolveFile( metahome.getPath() ); // check that the needed jar exists. File[] jars = getMetamataLibs(); @@ -353,7 +353,7 @@ public class MParse extends Task { throw new BuildException( "Invalid target: " + target ); } - target = project.resolveFile( target.getPath() ); + target = resolveFile( target.getPath() ); } /** diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/FTP.java index 5d6ba1f1c..8865b344b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/FTP.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/FTP.java @@ -95,27 +95,6 @@ public class FTP private String server; private String userid; - /** - * Sets the FTP action to be taken. Currently accepts "put", "get", "del", - * "mkdir" and "list". - * - * @param action The new Action value - * @exception BuildException Description of Exception - * @deprecated setAction(String) is deprecated and is replaced with - * setAction(FTP.Action) to make Ant's Introspection mechanism do the - * work and also to encapsulate operations on the type in its own - * class. - */ - public void setAction( String action ) - throws BuildException - { - log( "DEPRECATED - The setAction(String) method has been deprecated." - + " Use setAction(FTP.Action) instead." ); - Action a = new Action(); - a.setValue( action ); - this.action = a.getAction(); - } - /** * Sets the FTP action to be taken. Currently accepts "put", "get", "del", * "mkdir" and "list". @@ -419,7 +398,7 @@ public class FTP OutputStream outstream = null; try { - File file = project.resolveFile( new File( dir, filename ).getPath() ); + File file = resolveFile( new File( dir, filename ).getPath() ); if( newerOnly && isUpToDate( ftp, file, resolveFile( filename ) ) ) return; @@ -747,7 +726,7 @@ public class FTP InputStream instream = null; try { - File file = project.resolveFile( new File( dir, filename ).getPath() ); + File file = resolveFile( new File( dir, filename ).getPath() ); if( newerOnly && isUpToDate( ftp, file, resolveFile( filename ) ) ) return; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java index 1a498c6df..ec6043e87 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java @@ -296,7 +296,7 @@ public class MimeMail extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } @@ -361,7 +361,7 @@ public class MimeMail extends Task { if( failOnError ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } else { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java index f2d1e7c46..8fa57bed6 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java @@ -249,7 +249,7 @@ public class TelnetTask extends Task } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } @@ -299,7 +299,7 @@ public class TelnetTask extends Task Thread.sleep( 250 ); } if( is.available() == 0 ) - throw new BuildException( "Response Timed-Out", getLocation() ); + throw new BuildException( "Response Timed-Out" ); sb.append( ( char )is.read() ); } } @@ -311,7 +311,7 @@ public class TelnetTask extends Task } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java index dd93d117c..f23e4f6b4 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java @@ -170,7 +170,7 @@ public abstract class P4Base extends org.apache.tools.ant.Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java index 552817a5b..d077d85ae 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java @@ -81,7 +81,7 @@ public abstract class P4HandlerAdapter implements P4Handler } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java index 64ad0ad85..0068b772b 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java @@ -370,7 +370,7 @@ public class Pvcs extends org.apache.tools.ant.Task if( result != 0 && !ignorerc ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( !tmp.exists() ) @@ -412,24 +412,24 @@ public class Pvcs extends org.apache.tools.ant.Task if( result != 0 && !ignorerc ) { String msg = "Failed executing: " + commandLine.toString() + ". Return code was " + result; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } catch( FileNotFoundException e ) { String msg = "Failed executing: " + commandLine.toString() + ". Exception: " + e.getMessage(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } catch( IOException e ) { String msg = "Failed executing: " + commandLine.toString() + ". Exception: " + e.getMessage(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } catch( ParseException e ) { String msg = "Failed executing: " + commandLine.toString() + ". Exception: " + e.getMessage(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } finally { @@ -459,7 +459,7 @@ public class Pvcs extends org.apache.tools.ant.Task catch( java.io.IOException e ) { String msg = "Failed executing: " + cmd.toString() + ". Exception: " + e.getMessage(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java index 23abe6fe7..6711b46bf 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java @@ -155,7 +155,7 @@ public class CovMerge extends Task { String pathname = f[j]; File file = new File( ds.getBasedir(), pathname ); - file = project.resolveFile( file.getPath() ); + file = resolveFile( file.getPath() ); v.addElement( file ); } } @@ -214,7 +214,7 @@ public class CovMerge extends Task pw.println( snapshots[i].getAbsolutePath() ); } // last file is the output snapshot - pw.println( project.resolveFile( tofile.getPath() ) ); + pw.println( resolveFile( tofile.getPath() ) ); pw.flush(); } catch( IOException e ) diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java index 287b559d2..01a62e3b4 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java @@ -285,13 +285,13 @@ public class CovReport extends Task { v.addElement( "-filters=" + filters ); } - v.addElement( "-output=" + project.resolveFile( tofile.getPath() ) ); - v.addElement( "-snapshot=" + project.resolveFile( snapshot.getPath() ) ); + v.addElement( "-output=" + resolveFile( tofile.getPath() ) ); + v.addElement( "-snapshot=" + resolveFile( snapshot.getPath() ) ); // as a default -sourcepath use . in JProbe, so use project . if( sourcePath == null ) { sourcePath = new Path( project ); - sourcePath.createPath().setLocation( project.resolveFile( "." ) ); + sourcePath.createPath().setLocation( resolveFile( "." ) ); } v.addElement( "-sourcepath=" + sourcePath ); diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java index 3dc028c44..5b0039698 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java @@ -331,7 +331,7 @@ public class Coverage extends Task } if( javaExe != null ) { - params.addElement( "-jp_java_exe=" + project.resolveFile( javaExe.getPath() ) ); + params.addElement( "-jp_java_exe=" + resolveFile( javaExe.getPath() ) ); } params.addElement( "-jp_working_dir=" + workingDir.getPath() ); params.addElement( "-jp_snapshot_dir=" + snapshotDir.getPath() ); @@ -408,7 +408,7 @@ public class Coverage extends Task { snapshotDir = new File( "." ); } - snapshotDir = project.resolveFile( snapshotDir.getPath() ); + snapshotDir = resolveFile( snapshotDir.getPath() ); if( !snapshotDir.isDirectory() || !snapshotDir.exists() ) { throw new BuildException( "Snapshot directory does not exists :" + snapshotDir ); @@ -417,7 +417,7 @@ public class Coverage extends Task { workingDir = new File( "." ); } - workingDir = project.resolveFile( workingDir.getPath() ); + workingDir = resolveFile( workingDir.getPath() ); // check for info, do your best to select the java executable. // JProbe 3.0 fails if there is no javaexe option. So diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java index 2bd290da5..63a63e54a 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java @@ -232,7 +232,7 @@ public abstract class MSVSS extends Task } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java index 8e936b6d4..c69dc33b1 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java @@ -142,7 +142,7 @@ public class MSVSSCHECKIN extends MSVSS else { // make sure m_LocalDir exists, create it if it doesn't - File dir = project.resolveFile( m_LocalPath ); + File dir = resolveFile( m_LocalPath ); if( !dir.exists() ) { boolean done = dir.mkdirs(); @@ -150,7 +150,7 @@ public class MSVSSCHECKIN extends MSVSS { String msg = "Directory " + m_LocalPath + " creation was not " + "succesful for an unknown reason"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } project.log( "Created dir: " + dir.getAbsolutePath() ); } @@ -207,7 +207,7 @@ public class MSVSSCHECKIN extends MSVSS if( getVsspath() == null ) { String msg = "vsspath attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } // now look for illegal combinations of things ... @@ -237,7 +237,7 @@ public class MSVSSCHECKIN extends MSVSS if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java index 356bf1565..e3f0124ee 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java @@ -169,7 +169,7 @@ public class MSVSSCHECKOUT extends MSVSS else { // make sure m_LocalDir exists, create it if it doesn't - File dir = project.resolveFile( m_LocalPath ); + File dir = resolveFile( m_LocalPath ); if( !dir.exists() ) { boolean done = dir.mkdirs(); @@ -177,7 +177,7 @@ public class MSVSSCHECKOUT extends MSVSS { String msg = "Directory " + m_LocalPath + " creation was not " + "succesful for an unknown reason"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } project.log( "Created dir: " + dir.getAbsolutePath() ); } @@ -242,7 +242,7 @@ public class MSVSSCHECKOUT extends MSVSS if( getVsspath() == null ) { String msg = "vsspath attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } // now look for illegal combinations of things ... @@ -270,7 +270,7 @@ public class MSVSSCHECKOUT extends MSVSS if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java index 17bcc222c..8ec462510 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java @@ -377,7 +377,7 @@ public class MSVSSGET extends MSVSS else { // make sure m_LocalDir exists, create it if it doesn't - File dir = project.resolveFile( m_LocalPath ); + File dir = resolveFile( m_LocalPath ); if( !dir.exists() ) { boolean done = dir.mkdirs(); @@ -385,7 +385,7 @@ public class MSVSSGET extends MSVSS { String msg = "Directory " + m_LocalPath + " creation was not " + "successful for an unknown reason"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } project.log( "Created dir: " + dir.getAbsolutePath() ); } @@ -473,7 +473,7 @@ public class MSVSSGET extends MSVSS if( getVsspath() == null ) { String msg = "vsspath attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } // now look for illegal combinations of things ... @@ -505,7 +505,7 @@ public class MSVSSGET extends MSVSS if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java index 583e2249a..58b2d1e4f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java @@ -226,7 +226,7 @@ public class MSVSSHISTORY extends MSVSS if( getVsspath() == null ) { String msg = "vsspath attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } // now look for illegal combinations of things ... @@ -272,7 +272,7 @@ public class MSVSSHISTORY extends MSVSS if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } @@ -346,7 +346,7 @@ public class MSVSSHISTORY extends MSVSS catch( ParseException ex ) { String msg = "Error parsing date: " + m_ToDate; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } cmd.createArgument().setValue( FLAG_VERSION_DATE + m_ToDate + VALUE_FROMDATE + startDate ); } @@ -360,7 +360,7 @@ public class MSVSSHISTORY extends MSVSS catch( ParseException ex ) { String msg = "Error parsing date: " + m_FromDate; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } cmd.createArgument().setValue( FLAG_VERSION_DATE + endDate + VALUE_FROMDATE + m_FromDate ); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java index d113a2f03..d9ac730f8 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java @@ -328,12 +328,12 @@ public class MSVSSLABEL extends MSVSS if( getVsspath() == null ) { String msg = "vsspath attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } if( getLabel() == null ) { String msg = "label attribute must be set!"; - throw new BuildException( msg, location ); + throw new BuildException( msg ); } // now look for illegal combinations of things ... @@ -368,7 +368,7 @@ public class MSVSSLABEL extends MSVSS if( result != 0 ) { String msg = "Failed executing: " + commandLine.toString(); - throw new BuildException( msg, location ); + throw new BuildException( msg ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java index a7a76813e..c835faf9f 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java @@ -42,7 +42,7 @@ public class KaffeRmic extends DefaultRmicAdapter { throw new BuildException( "Cannot use Kaffe rmic, as it is not available" + " A common solution is to set the environment variable" + - " JAVA_HOME or CLASSPATH.", getRmic().getLocation() ); + " JAVA_HOME or CLASSPATH." ); } catch( Exception ex ) { @@ -52,7 +52,7 @@ public class KaffeRmic extends DefaultRmicAdapter } else { - throw new BuildException( "Error starting Kaffe rmic: ", ex, getRmic().getLocation() ); + throw new BuildException( "Error starting Kaffe rmic: ", ex ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/SunRmic.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/SunRmic.java index 6b375df25..c21c07c09 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/SunRmic.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/SunRmic.java @@ -50,7 +50,7 @@ public class SunRmic extends DefaultRmicAdapter { throw new BuildException( "Cannot use SUN rmic, as it is not available" + " A common solution is to set the environment variable" + - " JAVA_HOME or CLASSPATH.", getRmic().getLocation() ); + " JAVA_HOME or CLASSPATH." ); } catch( Exception ex ) { @@ -60,7 +60,7 @@ public class SunRmic extends DefaultRmicAdapter } else { - throw new BuildException( "Error starting SUN rmic: ", ex, getRmic().getLocation() ); + throw new BuildException( "Error starting SUN rmic: ", ex ); } } finally @@ -71,7 +71,7 @@ public class SunRmic extends DefaultRmicAdapter } catch( IOException e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/WLRmic.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/WLRmic.java index 67fc6fcf4..fae6392a0 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/WLRmic.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/rmic/WLRmic.java @@ -58,7 +58,7 @@ public class WLRmic extends DefaultRmicAdapter { throw new BuildException( "Cannot use WebLogic rmic, as it is not available" + " A common solution is to set the environment variable" + - " CLASSPATH.", getRmic().getLocation() ); + " CLASSPATH." ); } catch( Exception ex ) { @@ -68,7 +68,7 @@ public class WLRmic extends DefaultRmicAdapter } else { - throw new BuildException( "Error starting WebLogic rmic: ", ex, getRmic().getLocation() ); + throw new BuildException( "Error starting WebLogic rmic: ", ex ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/DataType.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/DataType.java index 6bc7085f0..7ac037887 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/DataType.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/DataType.java @@ -6,7 +6,9 @@ * the LICENSE file. */ package org.apache.tools.ant.types; + import java.util.Stack; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectComponent; @@ -22,16 +24,19 @@ import org.apache.tools.ant.ProjectComponent; * * @author Stefan Bodewig */ -public abstract class DataType extends ProjectComponent +public abstract class DataType + extends ProjectComponent { /** * The descriptin the user has set. */ - protected String description = null; + protected String description; + /** * Value to the refid attribute. */ - protected Reference ref = null; + protected Reference ref; + /** * Are we sure we don't hold circular references? * @@ -62,6 +67,7 @@ public abstract class DataType extends ProjectComponent * @param ref The new Refid value */ public void setRefid( Reference ref ) + throws TaskException { this.ref = ref; checked = false; @@ -87,6 +93,12 @@ public abstract class DataType extends ProjectComponent return ref != null; } + public void execute() + throws TaskException + { + //HACK: NOOP execute - should be deleted in the future! + } + /** * Performs the check for circular references and returns the referenced * object. @@ -96,6 +108,7 @@ public abstract class DataType extends ProjectComponent * @return The CheckedRef value */ protected Object getCheckedRef( Class requiredClass, String dataTypeName ) + throws TaskException { if( !checked ) { @@ -108,7 +121,7 @@ public abstract class DataType extends ProjectComponent if( !( requiredClass.isAssignableFrom( o.getClass() ) ) ) { String msg = ref.getRefId() + " doesn\'t denote a " + dataTypeName; - throw new BuildException( msg ); + throw new TaskException( msg ); } else { @@ -165,7 +178,7 @@ public abstract class DataType extends ProjectComponent else { stk.push( o ); - ( ( DataType )o ).dieOnCircularReference( stk, p ); + ( (DataType)o ).dieOnCircularReference( stk, p ); stk.pop(); } } @@ -192,6 +205,6 @@ public abstract class DataType extends ProjectComponent protected BuildException tooManyAttributes() { return new BuildException( "You must not specify more than one attribute" + - " when using refid" ); + " when using refid" ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java index 5961775ab..3662f329e 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FileSet.java @@ -6,9 +6,11 @@ * the LICENSE file. */ package org.apache.tools.ant.types; + import java.io.File; import java.util.Stack; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.FileScanner; @@ -69,6 +71,7 @@ public class FileSet extends DataType implements Cloneable * should be used, "false"|"off"|"no" when they shouldn't be used. */ public void setDefaultexcludes( boolean useDefaultExcludes ) + throws TaskException { if( isReference() ) { @@ -96,6 +99,7 @@ public class FileSet extends DataType implements Cloneable * @param excludes the string containing the exclude patterns */ public void setExcludes( String excludes ) + throws TaskException { if( isReference() ) { @@ -129,6 +133,7 @@ public class FileSet extends DataType implements Cloneable * @param includes the string containing the include patterns */ public void setIncludes( String includes ) + throws TaskException { if( isReference() ) { @@ -155,7 +160,6 @@ public class FileSet extends DataType implements Cloneable defaultPatterns.setIncludesfile( incl ); } - /** * Makes this instance in effect a reference to another PatternSet instance. *
@@ -167,7 +171,7 @@ public class FileSet extends DataType implements Cloneable * @exception BuildException Description of Exception */ public void setRefid( Reference r ) - throws BuildException + throws TaskException { if( dir != null || defaultPatterns.hasPatterns() ) { @@ -192,11 +196,11 @@ public class FileSet extends DataType implements Cloneable for( int i = 0; i < additionalPatterns.size(); i++ ) { Object o = additionalPatterns.elementAt( i ); - defaultPatterns.append( ( PatternSet )o, p ); + defaultPatterns.append( (PatternSet)o, p ); } p.log( "FileSet: Setup file scanner in dir " + dir + - " with " + defaultPatterns, p.MSG_DEBUG ); + " with " + defaultPatterns, p.MSG_DEBUG ); ds.setIncludes( defaultPatterns.getIncludePatterns( p ) ); ds.setExcludes( defaultPatterns.getExcludePatterns( p ) ); @@ -206,6 +210,7 @@ public class FileSet extends DataType implements Cloneable } public File getDir( Project p ) + throws TaskException { if( isReference() ) { @@ -221,6 +226,7 @@ public class FileSet extends DataType implements Cloneable * @return The DirectoryScanner value */ public DirectoryScanner getDirectoryScanner( Project p ) + throws TaskException { if( isReference() ) { @@ -229,16 +235,16 @@ public class FileSet extends DataType implements Cloneable if( dir == null ) { - throw new BuildException( "No directory specified for fileset." ); + throw new TaskException( "No directory specified for fileset." ); } if( !dir.exists() ) { - throw new BuildException( dir.getAbsolutePath() + " not found." ); + throw new TaskException( dir.getAbsolutePath() + " not found." ); } if( !dir.isDirectory() ) { - throw new BuildException( dir.getAbsolutePath() + " is not a directory." ); + throw new TaskException( dir.getAbsolutePath() + " is not a directory." ); } DirectoryScanner ds = new DirectoryScanner(); @@ -255,13 +261,19 @@ public class FileSet extends DataType implements Cloneable */ public Object clone() { - if( isReference() ) + try { - return new FileSet( getRef( getProject() ) ); + if( isReference() ) + { + return new FileSet( getRef( getProject() ) ); + } + else + { + return new FileSet( this ); + } } - else + catch( TaskException e ) { - return new FileSet( this ); } } @@ -271,6 +283,7 @@ public class FileSet extends DataType implements Cloneable * @return Description of the Returned Value */ public PatternSet.NameEntry createExclude() + throws TaskException { if( isReference() ) { @@ -285,6 +298,7 @@ public class FileSet extends DataType implements Cloneable * @return Description of the Returned Value */ public PatternSet.NameEntry createExcludesFile() + throws TaskException { if( isReference() ) { @@ -299,6 +313,7 @@ public class FileSet extends DataType implements Cloneable * @return Description of the Returned Value */ public PatternSet.NameEntry createInclude() + throws TaskException { if( isReference() ) { @@ -313,6 +328,7 @@ public class FileSet extends DataType implements Cloneable * @return Description of the Returned Value */ public PatternSet.NameEntry createIncludesFile() + throws TaskException { if( isReference() ) { @@ -322,6 +338,7 @@ public class FileSet extends DataType implements Cloneable } public PatternSet createPatternSet() + throws TaskException { if( isReference() ) { @@ -340,6 +357,7 @@ public class FileSet extends DataType implements Cloneable * @return The Ref value */ protected FileSet getRef( Project p ) + throws TaskException { if( !checked ) { @@ -352,11 +370,11 @@ public class FileSet extends DataType implements Cloneable if( !( o instanceof FileSet ) ) { String msg = ref.getRefId() + " doesn\'t denote a fileset"; - throw new BuildException( msg ); + throw new TaskException( msg ); } else { - return ( FileSet )o; + return (FileSet)o; } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSet.java index 927114f4a..5e4a6bb48 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSet.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSet.java @@ -6,17 +6,18 @@ * the LICENSE file. */ package org.apache.tools.ant.types;// java io classes + import java.io.File; import java.io.FileInputStream; -import java.io.IOException;// java util classes +import java.io.IOException; import java.util.Enumeration; import java.util.Hashtable; import java.util.Properties; -import java.util.Vector;// ant classes +import java.util.Vector; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; - /** * A set of filters to be applied to something. A filter set may have begintoken * and endtokens defined. @@ -45,7 +46,9 @@ public class FilterSet extends DataType implements Cloneable */ private Vector filters = new Vector(); - public FilterSet() { } + public FilterSet() + { + } /** * Create a Filterset from another filterset @@ -53,9 +56,10 @@ public class FilterSet extends DataType implements Cloneable * @param filterset the filterset upon which this filterset will be based. */ protected FilterSet( FilterSet filterset ) + throws TaskException { super(); - this.filters = ( Vector )filterset.getFilters().clone(); + this.filters = (Vector)filterset.getFilters().clone(); } /** @@ -64,6 +68,7 @@ public class FilterSet extends DataType implements Cloneable * @param startOfToken The new Begintoken value */ public void setBeginToken( String startOfToken ) + throws TaskException { if( isReference() ) { @@ -71,18 +76,18 @@ public class FilterSet extends DataType implements Cloneable } if( startOfToken == null || "".equals( startOfToken ) ) { - throw new BuildException( "beginToken must not be empty" ); + throw new TaskException( "beginToken must not be empty" ); } this.startOfToken = startOfToken; } - /** * The string used to id the end of a token. * * @param endOfToken The new Endtoken value */ public void setEndToken( String endOfToken ) + throws TaskException { if( isReference() ) { @@ -90,7 +95,7 @@ public class FilterSet extends DataType implements Cloneable } if( endOfToken == null || "".equals( endOfToken ) ) { - throw new BuildException( "endToken must not be empty" ); + throw new TaskException( "endToken must not be empty" ); } this.endOfToken = endOfToken; } @@ -113,6 +118,7 @@ public class FilterSet extends DataType implements Cloneable } public String getBeginToken() + throws TaskException { if( isReference() ) { @@ -122,6 +128,7 @@ public class FilterSet extends DataType implements Cloneable } public String getEndToken() + throws TaskException { if( isReference() ) { @@ -136,12 +143,13 @@ public class FilterSet extends DataType implements Cloneable * @return The hash of the tokens and values for quick lookup. */ public Hashtable getFilterHash() + throws TaskException { int filterSize = getFilters().size(); Hashtable filterHash = new Hashtable( filterSize ); - for( Enumeration e = getFilters().elements(); e.hasMoreElements(); ) + for( Enumeration e = getFilters().elements(); e.hasMoreElements(); ) { - Filter filter = ( Filter )e.nextElement(); + Filter filter = (Filter)e.nextElement(); filterHash.put( filter.getToken(), filter.getValue() ); } return filterHash; @@ -153,6 +161,7 @@ public class FilterSet extends DataType implements Cloneable * @param filter The feature to be added to the Filter attribute */ public void addFilter( Filter filter ) + throws TaskException { if( isReference() ) { @@ -168,6 +177,7 @@ public class FilterSet extends DataType implements Cloneable * @param value The value for the new filter. */ public void addFilter( String token, String value ) + throws TaskException { if( isReference() ) { @@ -182,27 +192,34 @@ public class FilterSet extends DataType implements Cloneable * @param filterSet the filterset to be added to this filterset */ public void addFilterSet( FilterSet filterSet ) + throws TaskException { if( isReference() ) { throw noChildrenAllowed(); } - for( Enumeration e = filterSet.getFilters().elements(); e.hasMoreElements(); ) + for( Enumeration e = filterSet.getFilters().elements(); e.hasMoreElements(); ) { - filters.addElement( ( Filter )e.nextElement() ); + filters.addElement( (Filter)e.nextElement() ); } } public Object clone() - throws BuildException { - if( isReference() ) + try { - return new FilterSet( getRef() ); + if( isReference() ) + { + return new FilterSet( getRef() ); + } + else + { + return new FilterSet( this ); + } } - else + catch( final TaskException te ) { - return new FilterSet( this ); + throw new RuntimeException( te.toString() ); } } @@ -212,6 +229,7 @@ public class FilterSet extends DataType implements Cloneable * @return The filter that was created. */ public FiltersFile createFiltersfile() + throws TaskException { if( isReference() ) { @@ -226,11 +244,11 @@ public class FilterSet extends DataType implements Cloneable * @return Return true if there are filter in this set otherwise false. */ public boolean hasFilters() + throws TaskException { return getFilters().size() > 0; } - /** * Read the filters from the given file. * @@ -260,7 +278,7 @@ public class FilterSet extends DataType implements Cloneable Vector filters = getFilters(); while( enum.hasMoreElements() ) { - String strPropName = ( String )enum.nextElement(); + String strPropName = (String)enum.nextElement(); String strValue = props.getProperty( strPropName ); filters.addElement( new Filter( strPropName, strValue ) ); } @@ -297,6 +315,7 @@ public class FilterSet extends DataType implements Cloneable * @return The string with the tokens replaced. */ public String replaceTokens( String line ) + throws TaskException { String beginToken = getBeginToken(); String endToken = getEndToken(); @@ -323,7 +342,7 @@ public class FilterSet extends DataType implements Cloneable b.append( line.substring( i, index ) ); if( tokens.containsKey( token ) ) { - value = ( String )tokens.get( token ); + value = (String)tokens.get( token ); log( "Replacing: " + beginToken + token + endToken + " -> " + value, Project.MSG_VERBOSE ); b.append( value ); i = index + beginToken.length() + token.length() + endToken.length(); @@ -334,7 +353,7 @@ public class FilterSet extends DataType implements Cloneable b.append( beginToken ); i = index + beginToken.length(); } - }while ( ( index = line.indexOf( beginToken, i ) ) > -1 ); + } while( ( index = line.indexOf( beginToken, i ) ) > -1 ); b.append( line.substring( i ) ); return b.toString(); @@ -351,6 +370,7 @@ public class FilterSet extends DataType implements Cloneable } protected Vector getFilters() + throws TaskException { if( isReference() ) { @@ -360,8 +380,9 @@ public class FilterSet extends DataType implements Cloneable } protected FilterSet getRef() + throws TaskException { - return ( FilterSet )getCheckedRef( FilterSet.class, "filterset" ); + return (FilterSet)getCheckedRef( FilterSet.class, "filterset" ); } /** @@ -397,7 +418,9 @@ public class FilterSet extends DataType implements Cloneable /** * No argument conmstructor */ - public Filter() { } + public Filter() + { + } /** * Sets the Token attribute of the Filter object @@ -452,7 +475,9 @@ public class FilterSet extends DataType implements Cloneable /** * Constructor for the Filter object */ - public FiltersFile() { } + public FiltersFile() + { + } /** * Sets the file from which filters will be read. @@ -460,6 +485,7 @@ public class FilterSet extends DataType implements Cloneable * @param file the file from which filters will be read. */ public void setFile( File file ) + throws TaskException { readFiltersFromFile( file ); } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSetCollection.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSetCollection.java index 9bc5162a9..a83bff596 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSetCollection.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/FilterSetCollection.java @@ -6,14 +6,15 @@ * the LICENSE file. */ package org.apache.tools.ant.types;// java io classes + // java util classes + import java.util.Enumeration; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; // ant classes - - /** * A FilterSetCollection is a collection of filtersets each of which may have a * different start/end token settings. @@ -25,14 +26,15 @@ public class FilterSetCollection private Vector filterSets = new Vector(); - public FilterSetCollection() { } + public FilterSetCollection() + { + } public FilterSetCollection( FilterSet filterSet ) { addFilterSet( filterSet ); } - public void addFilterSet( FilterSet filterSet ) { filterSets.addElement( filterSet ); @@ -44,10 +46,11 @@ public class FilterSetCollection * @return Return true if there are filter in this set otherwise false. */ public boolean hasFilters() + throws TaskException { - for( Enumeration e = filterSets.elements(); e.hasMoreElements(); ) + for( Enumeration e = filterSets.elements(); e.hasMoreElements(); ) { - FilterSet filterSet = ( FilterSet )e.nextElement(); + FilterSet filterSet = (FilterSet)e.nextElement(); if( filterSet.hasFilters() ) { return true; @@ -64,11 +67,12 @@ public class FilterSetCollection * @return The string with the tokens replaced. */ public String replaceTokens( String line ) + throws TaskException { String replacedLine = line; - for( Enumeration e = filterSets.elements(); e.hasMoreElements(); ) + for( Enumeration e = filterSets.elements(); e.hasMoreElements(); ) { - FilterSet filterSet = ( FilterSet )e.nextElement(); + FilterSet filterSet = (FilterSet)e.nextElement(); replacedLine = filterSet.replaceTokens( replacedLine ); } return replacedLine; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Mapper.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Mapper.java index b0df6dc91..33e628dfe 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Mapper.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Mapper.java @@ -201,7 +201,7 @@ public class Mapper extends DataType implements Cloneable } catch( Throwable t ) { - throw new BuildException( t ); + throw new BuildException( "Error", t ); } finally { diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java index 729dd96ae..94dbee1ac 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/Path.java @@ -6,16 +6,18 @@ * the LICENSE file. */ package org.apache.tools.ant.types; + import java.io.File; import java.util.Enumeration; import java.util.Locale; import java.util.Stack; import java.util.Vector; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.PathTokenizer; import org.apache.tools.ant.Project; - +import org.apache.tools.ant.util.FileUtils; /** * This object represents a path as used by CLASSPATH or PATH environment @@ -49,14 +51,26 @@ import org.apache.tools.ant.Project; * @author Stefan Bodewig */ -public class Path extends DataType implements Cloneable +public class Path + extends DataType + implements Cloneable { - - public static Path systemClasspath = - new Path( null, System.getProperty( "java.class.path" ) ); + public final static Path systemClasspath = createSystemClasspath(); private Vector elements; + private static Path createSystemClasspath() + { + try + { + return new Path( null, System.getProperty( "java.class.path" ) ); + } + catch( final TaskException te ) + { + throw new Error( te.toString() ); + } + } + /** * Invoked by IntrospectionHelper for
setXXX(Path p)
attribute * setters. @@ -65,6 +79,7 @@ public class Path extends DataType implements Cloneable * @param path Description of Parameter */ public Path( Project p, String path ) + throws TaskException { this( p ); createPathElement().setPath( path ); @@ -108,7 +123,7 @@ public class Path extends DataType implements Cloneable { final Vector result = new Vector(); if( source == null ) - return new String[0]; + return new String[ 0 ]; PathTokenizer tok = new PathTokenizer( source ); StringBuffer element = new StringBuffer(); @@ -120,10 +135,10 @@ public class Path extends DataType implements Cloneable { element.append( resolveFile( project, pathElement ) ); } - catch( BuildException e ) + catch( TaskException e ) { project.log( "Dropping path element " + pathElement + " as it is not valid relative to the project", - Project.MSG_VERBOSE ); + Project.MSG_VERBOSE ); } for( int i = 0; i < element.length(); i++ ) { @@ -131,7 +146,7 @@ public class Path extends DataType implements Cloneable } result.addElement( element.toString() ); } - String[] res = new String[result.size()]; + String[] res = new String[ result.size() ]; result.copyInto( res ); return res; } @@ -181,7 +196,8 @@ public class Path extends DataType implements Cloneable { if( project != null ) { - File f = project.resolveFile( relativeName ); + File f = FileUtils.newFileUtils(). + resolveFile( project.getBaseDir(), relativeName ); return f.getAbsolutePath(); } return relativeName; @@ -204,7 +220,6 @@ public class Path extends DataType implements Cloneable createPathElement().setLocation( location ); } - /** * Parses a path definition and creates single PathElements. * @@ -231,7 +246,7 @@ public class Path extends DataType implements Cloneable * @exception BuildException Description of Exception */ public void setRefid( Reference r ) - throws BuildException + throws TaskException { if( !elements.isEmpty() ) { @@ -248,6 +263,7 @@ public class Path extends DataType implements Cloneable * @param source - source path whose components are examined for existence */ public void addExisting( Path source ) + throws TaskException { String[] list = source.list(); for( int i = 0; i < list.length; i++ ) @@ -255,11 +271,11 @@ public class Path extends DataType implements Cloneable File f = null; if( getProject() != null ) { - f = getProject().resolveFile( list[i] ); + f = resolveFile( list[ i ] ); } else { - f = new File( list[i] ); + f = new File( list[ i ] ); } if( f.exists() ) @@ -277,6 +293,7 @@ public class Path extends DataType implements Cloneable * @param extdirs The feature to be added to the Extdirs attribute */ public void addExtdirs( Path extdirs ) + throws TaskException { if( extdirs == null ) { @@ -294,7 +311,7 @@ public class Path extends DataType implements Cloneable String[] dirs = extdirs.list(); for( int i = 0; i < dirs.length; i++ ) { - File dir = getProject().resolveFile( dirs[i] ); + File dir = resolveFile( dirs[ i ] ); if( dir.exists() && dir.isDirectory() ) { FileSet fs = new FileSet(); @@ -312,7 +329,7 @@ public class Path extends DataType implements Cloneable * @exception BuildException Description of Exception */ public void addFileset( FileSet fs ) - throws BuildException + throws TaskException { if( isReference() ) { @@ -326,6 +343,7 @@ public class Path extends DataType implements Cloneable * Add the Java Runtime classes to this Path instance. */ public void addJavaRuntime() + throws TaskException { if( System.getProperty( "java.vendor" ).toLowerCase( Locale.US ).indexOf( "microsoft" ) >= 0 ) { @@ -339,8 +357,8 @@ public class Path extends DataType implements Cloneable { FileSet kaffeJarFiles = new FileSet(); kaffeJarFiles.setDir( new File( System.getProperty( "java.home" ) - + File.separator + "share" - + File.separator + "kaffe" ) ); + + File.separator + "share" + + File.separator + "kaffe" ) ); kaffeJarFiles.setIncludes( "*.jar" ); addFileset( kaffeJarFiles ); @@ -348,37 +366,37 @@ public class Path extends DataType implements Cloneable else if( Project.getJavaVersion() == Project.JAVA_1_1 ) { addExisting( new Path( null, - System.getProperty( "java.home" ) - + File.separator + "lib" - + File.separator - + "classes.zip" ) ); + System.getProperty( "java.home" ) + + File.separator + "lib" + + File.separator + + "classes.zip" ) ); } else { // JDK > 1.1 seems to set java.home to the JRE directory. addExisting( new Path( null, - System.getProperty( "java.home" ) - + File.separator + "lib" - + File.separator + "rt.jar" ) ); + System.getProperty( "java.home" ) + + File.separator + "lib" + + File.separator + "rt.jar" ) ); // Just keep the old version as well and let addExisting // sort it out. addExisting( new Path( null, - System.getProperty( "java.home" ) - + File.separator + "jre" - + File.separator + "lib" - + File.separator + "rt.jar" ) ); + System.getProperty( "java.home" ) + + File.separator + "jre" + + File.separator + "lib" + + File.separator + "rt.jar" ) ); // Added for MacOS X addExisting( new Path( null, - System.getProperty( "java.home" ) - + File.separator + ".." - + File.separator + "Classes" - + File.separator + "classes.jar" ) ); + System.getProperty( "java.home" ) + + File.separator + ".." + + File.separator + "Classes" + + File.separator + "classes.jar" ) ); addExisting( new Path( null, - System.getProperty( "java.home" ) - + File.separator + ".." - + File.separator + "Classes" - + File.separator + "ui.jar" ) ); + System.getProperty( "java.home" ) + + File.separator + ".." + + File.separator + "Classes" + + File.separator + "ui.jar" ) ); } } @@ -388,15 +406,16 @@ public class Path extends DataType implements Cloneable * @param other Description of Parameter */ public void append( Path other ) + throws TaskException { if( other == null ) return; String[] l = other.list(); for( int i = 0; i < l.length; i++ ) { - if( elements.indexOf( l[i] ) == -1 ) + if( elements.indexOf( l[ i ] ) == -1 ) { - elements.addElement( l[i] ); + elements.addElement( l[ i ] ); } } } @@ -433,8 +452,8 @@ public class Path extends DataType implements Cloneable * @return Description of the Returned Value */ public Path concatSystemClasspath( String defValue ) + throws TaskException { - Path result = new Path( getProject() ); String order = defValue; @@ -472,7 +491,7 @@ public class Path extends DataType implements Cloneable if( !order.equals( "last" ) ) { log( "invalid value for build.sysclasspath: " + order, - Project.MSG_WARN ); + Project.MSG_WARN ); } result.addExisting( this ); @@ -525,6 +544,7 @@ public class Path extends DataType implements Cloneable * @return list of path elements. */ public String[] list() + throws TaskException { if( !checked ) { @@ -540,36 +560,36 @@ public class Path extends DataType implements Cloneable Object o = elements.elementAt( i ); if( o instanceof Reference ) { - Reference r = ( Reference )o; + Reference r = (Reference)o; o = r.getReferencedObject( getProject() ); // we only support references to paths right now if( !( o instanceof Path ) ) { String msg = r.getRefId() + " doesn\'t denote a path"; - throw new BuildException( msg ); + throw new TaskException( msg ); } } if( o instanceof String ) { // obtained via append - addUnlessPresent( result, ( String )o ); + addUnlessPresent( result, (String)o ); } else if( o instanceof PathElement ) { - String[] parts = ( ( PathElement )o ).getParts(); + String[] parts = ( (PathElement)o ).getParts(); if( parts == null ) { - throw new BuildException( "You must either set location or path on" ); + throw new TaskException( "You must either set location or path on " ); } for( int j = 0; j < parts.length; j++ ) { - addUnlessPresent( result, parts[j] ); + addUnlessPresent( result, parts[ j ] ); } } else if( o instanceof Path ) { - Path p = ( Path )o; + Path p = (Path)o; if( p.getProject() == null ) { p.setProject( getProject() ); @@ -577,24 +597,24 @@ public class Path extends DataType implements Cloneable String[] parts = p.list(); for( int j = 0; j < parts.length; j++ ) { - addUnlessPresent( result, parts[j] ); + addUnlessPresent( result, parts[ j ] ); } } else if( o instanceof FileSet ) { - FileSet fs = ( FileSet )o; + FileSet fs = (FileSet)o; DirectoryScanner ds = fs.getDirectoryScanner( getProject() ); String[] s = ds.getIncludedFiles(); File dir = fs.getDir( getProject() ); for( int j = 0; j < s.length; j++ ) { - File f = new File( dir, s[j] ); + File f = new File( dir, s[ j ] ); String absolutePath = f.getAbsolutePath(); addUnlessPresent( result, translateFile( absolutePath ) ); } } } - String[] res = new String[result.size()]; + String[] res = new String[ result.size() ]; result.copyInto( res ); return res; } @@ -605,11 +625,11 @@ public class Path extends DataType implements Cloneable * @return Description of the Returned Value */ public int size() + throws TaskException { return list().length; } - /** * Returns a textual representation of the path, which can be used as * CLASSPATH or PATH environment variable definition. @@ -618,21 +638,28 @@ public class Path extends DataType implements Cloneable */ public String toString() { - final String[] list = list(); + try + { + final String[] list = list(); - // empty path return empty string - if( list.length == 0 ) - return ""; + // empty path return empty string + if( list.length == 0 ) + return ""; + + // path containing one or more elements + final StringBuffer result = new StringBuffer( list[ 0 ].toString() ); + for( int i = 1; i < list.length; i++ ) + { + result.append( File.pathSeparatorChar ); + result.append( list[ i ] ); + } - // path containing one or more elements - final StringBuffer result = new StringBuffer( list[0].toString() ); - for( int i = 1; i < list.length; i++ ) + return result.toString(); + } + catch( final TaskException te ) { - result.append( File.pathSeparatorChar ); - result.append( list[i] ); + throw new Error( te.toString() ); } - - return result.toString(); } /** @@ -658,7 +685,7 @@ public class Path extends DataType implements Cloneable Object o = enum.nextElement(); if( o instanceof Reference ) { - o = ( ( Reference )o ).getReferencedObject( p ); + o = ( (Reference)o ).getReferencedObject( p ); } if( o instanceof DataType ) @@ -670,7 +697,7 @@ public class Path extends DataType implements Cloneable else { stk.push( o ); - ( ( DataType )o ).dieOnCircularReference( stk, p ); + ( (DataType)o ).dieOnCircularReference( stk, p ); stk.pop(); } } @@ -678,7 +705,6 @@ public class Path extends DataType implements Cloneable checked = true; } - /** * Helper class, holds the nested <pathelement>
values. * diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java index b4200922f..015c78890 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/types/PatternSet.java @@ -367,7 +367,7 @@ public class PatternSet extends DataType String fileName = ne.evalName( p ); if( fileName != null ) { - File inclFile = p.resolveFile( fileName ); + File inclFile = resolveFile( fileName ); if( !inclFile.exists() ) throw new BuildException( "Includesfile " + inclFile.getAbsolutePath() @@ -387,7 +387,7 @@ public class PatternSet extends DataType String fileName = ne.evalName( p ); if( fileName != null ) { - File exclFile = p.resolveFile( fileName ); + File exclFile = resolveFile( fileName ); if( !exclFile.exists() ) throw new BuildException( "Excludesfile " + exclFile.getAbsolutePath() diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/util/FileUtils.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/util/FileUtils.java index a27ab6f63..75d33d52a 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/util/FileUtils.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/util/FileUtils.java @@ -6,6 +6,7 @@ * the LICENSE file. */ package org.apache.tools.ant.util; + import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -16,13 +17,12 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; -import java.io.InputStream; import java.lang.reflect.Method; import java.text.DecimalFormat; import java.util.Random; import java.util.Stack; import java.util.StringTokenizer; -import org.apache.tools.ant.BuildException; +import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.FilterSetCollection; @@ -46,7 +46,9 @@ public class FileUtils /** * Empty constructor. */ - protected FileUtils() { } + protected FileUtils() + { + } /** * Factory method. @@ -66,20 +68,20 @@ public class FileUtils * @exception BuildException Description of Exception */ public void setFileLastModified( File file, long time ) - throws BuildException + throws TaskException { if( Project.getJavaVersion() == Project.JAVA_1_1 ) { return; } - Long[] times = new Long[1]; + Long[] times = new Long[ 1 ]; if( time < 0 ) { - times[0] = new Long( System.currentTimeMillis() ); + times[ 0 ] = new Long( System.currentTimeMillis() ); } else { - times[0] = new Long( time ); + times[ 0 ] = new Long( time ); } try @@ -89,13 +91,13 @@ public class FileUtils catch( java.lang.reflect.InvocationTargetException ite ) { Throwable nested = ite.getTargetException(); - throw new BuildException( "Exception setting the modification time " - + "of " + file, nested ); + throw new TaskException( "Exception setting the modification time " + + "of " + file, nested ); } catch( Throwable other ) { - throw new BuildException( "Exception setting the modification time " - + "of " + file, other ); + throw new TaskException( "Exception setting the modification time " + + "of " + file, other ); } } @@ -179,7 +181,8 @@ public class FileUtils in1.close(); } catch( IOException e ) - {} + { + } } if( in2 != null ) { @@ -188,7 +191,8 @@ public class FileUtils in2.close(); } catch( IOException e ) - {} + { + } } } } @@ -202,7 +206,7 @@ public class FileUtils * @throws IOException */ public void copyFile( String sourceFile, String destFile ) - throws IOException + throws IOException, TaskException { copyFile( new File( sourceFile ), new File( destFile ), null, false, false ); } @@ -217,7 +221,7 @@ public class FileUtils * @throws IOException */ public void copyFile( String sourceFile, String destFile, FilterSetCollection filters ) - throws IOException + throws IOException, TaskException { copyFile( new File( sourceFile ), new File( destFile ), filters, false, false ); } @@ -235,10 +239,10 @@ public class FileUtils */ public void copyFile( String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite ) - throws IOException + throws IOException, TaskException { copyFile( new File( sourceFile ), new File( destFile ), filters, - overwrite, false ); + overwrite, false ); } /** @@ -257,10 +261,10 @@ public class FileUtils */ public void copyFile( String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified ) - throws IOException + throws IOException, TaskException { copyFile( new File( sourceFile ), new File( destFile ), filters, - overwrite, preserveLastModified ); + overwrite, preserveLastModified ); } /** @@ -272,7 +276,7 @@ public class FileUtils * @throws IOException */ public void copyFile( File sourceFile, File destFile ) - throws IOException + throws IOException, TaskException { copyFile( sourceFile, destFile, null, false, false ); } @@ -287,7 +291,7 @@ public class FileUtils * @throws IOException */ public void copyFile( File sourceFile, File destFile, FilterSetCollection filters ) - throws IOException + throws IOException, TaskException { copyFile( sourceFile, destFile, filters, false, false ); } @@ -305,7 +309,7 @@ public class FileUtils */ public void copyFile( File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite ) - throws IOException + throws IOException, TaskException { copyFile( sourceFile, destFile, filters, overwrite, false ); } @@ -326,7 +330,7 @@ public class FileUtils */ public void copyFile( File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified ) - throws IOException + throws IOException, TaskException { if( overwrite || !destFile.exists() || @@ -377,13 +381,13 @@ public class FileUtils FileInputStream in = new FileInputStream( sourceFile ); FileOutputStream out = new FileOutputStream( destFile ); - byte[] buffer = new byte[8 * 1024]; + byte[] buffer = new byte[ 8 * 1024 ]; int count = 0; do { out.write( buffer, 0, count ); count = in.read( buffer, 0, buffer.length ); - }while ( count != -1 ); + } while( count != -1 ); in.close(); out.close(); @@ -429,9 +433,9 @@ public class FileUtils do { result = new File( parent, - prefix + fmt.format( rand.nextInt() ) - + suffix ); - }while ( result.exists() ); + prefix + fmt.format( rand.nextInt() ) + + suffix ); + } while( result.exists() ); } return result; } @@ -454,6 +458,7 @@ public class FileUtils * @throws java.lang.NullPointerException if the file path is equal to null. */ public File normalize( String path ) + throws TaskException { String orig = path; @@ -465,10 +470,10 @@ public class FileUtils !( path.length() >= 2 && Character.isLetter( path.charAt( 0 ) ) && path.charAt( 1 ) == ':' ) - ) + ) { String msg = path + " is not an absolute path"; - throw new BuildException( msg ); + throw new TaskException( msg ); } boolean dosWithDrive = false; @@ -483,15 +488,15 @@ public class FileUtils char[] ca = path.replace( '/', '\\' ).toCharArray(); StringBuffer sb = new StringBuffer(); - sb.append( Character.toUpperCase( ca[0] ) ).append( ':' ); + sb.append( Character.toUpperCase( ca[ 0 ] ) ).append( ':' ); for( int i = 2; i < ca.length; i++ ) { - if( ( ca[i] != '\\' ) || - ( ca[i] == '\\' && ca[i - 1] != '\\' ) - ) + if( ( ca[ i ] != '\\' ) || + ( ca[ i ] == '\\' && ca[ i - 1 ] != '\\' ) + ) { - sb.append( ca[i] ); + sb.append( ca[ i ] ); } } @@ -542,7 +547,7 @@ public class FileUtils { if( s.size() < 2 ) { - throw new BuildException( "Cannot resolve path " + orig ); + throw new TaskException( "Cannot resolve path " + orig ); } else { @@ -589,6 +594,7 @@ public class FileUtils * current platform. */ public File resolveFile( File file, String filename ) + throws TaskException { filename = filename.replace( '/', File.separatorChar ) .replace( '\\', File.separatorChar ); @@ -598,7 +604,7 @@ public class FileUtils ( filename.length() >= 2 && Character.isLetter( filename.charAt( 0 ) ) && filename.charAt( 1 ) == ':' ) - ) + ) { return normalize( filename ); } @@ -619,9 +625,9 @@ public class FileUtils if( helpFile == null ) { String msg = "The file or path you specified (" - + filename + ") is invalid relative to " - + file.getPath(); - throw new BuildException( msg ); + + filename + ") is invalid relative to " + + file.getPath(); + throw new TaskException( msg ); } } else if( part.equals( "." ) ) @@ -643,6 +649,7 @@ public class FileUtils * @return The SetLastModified value */ protected final Method getSetLastModified() + throws TaskException { if( Project.getJavaVersion() == Project.JAVA_1_1 ) { @@ -658,12 +665,12 @@ public class FileUtils { setLastModified = java.io.File.class.getMethod( "setLastModified", - new Class[]{Long.TYPE} ); + new Class[]{Long.TYPE} ); } catch( NoSuchMethodException nse ) { - throw new BuildException( "File.setlastModified not in JDK > 1.1?", - nse ); + throw new TaskException( "File.setlastModified not in JDK > 1.1?", + nse ); } } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java index 1421fb167..1c6d57994 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java @@ -138,7 +138,7 @@ public class JakartaOroMatcher implements RegexpMatcher } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java index 7c486420e..a58796880 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java @@ -122,7 +122,7 @@ public class Jdk14RegexpMatcher implements RegexpMatcher } catch( Exception e ) { - throw new BuildException( e ); + throw new BuildException( "Error", e ); } } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java index ae7b5331a..5620b9b70 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java @@ -97,7 +97,7 @@ public class RegexpMatcherFactory } catch( Throwable t ) { - throw new BuildException( t ); + throw new BuildException( "Error", t ); } } }