git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270159 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -128,6 +128,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener | |||||
| * value of ${build.sysclasspath} | * value of ${build.sysclasspath} | ||||
| */ | */ | ||||
| public AntClassLoader( Project project, Path classpath ) | public AntClassLoader( Project project, Path classpath ) | ||||
| throws TaskException | |||||
| { | { | ||||
| parent = AntClassLoader.class.getClassLoader(); | parent = AntClassLoader.class.getClassLoader(); | ||||
| this.project = project; | this.project = project; | ||||
| @@ -142,7 +143,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener | |||||
| { | { | ||||
| addPathElement( (String)pathElements[ i ] ); | addPathElement( (String)pathElements[ i ] ); | ||||
| } | } | ||||
| catch( BuildException e ) | |||||
| catch( TaskException e ) | |||||
| { | { | ||||
| // ignore path elements which are invalid relative to the project | // ignore path elements which are invalid relative to the project | ||||
| } | } | ||||
| @@ -162,6 +163,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener | |||||
| */ | */ | ||||
| public AntClassLoader( ClassLoader parent, Project project, Path classpath, | public AntClassLoader( ClassLoader parent, Project project, Path classpath, | ||||
| boolean parentFirst ) | boolean parentFirst ) | ||||
| throws TaskException | |||||
| { | { | ||||
| this( project, classpath ); | this( project, classpath ); | ||||
| if( parent != null ) | if( parent != null ) | ||||
| @@ -182,6 +184,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener | |||||
| * be consulted before trying to load the a class through this loader. | * be consulted before trying to load the a class through this loader. | ||||
| */ | */ | ||||
| public AntClassLoader( Project project, Path classpath, boolean parentFirst ) | public AntClassLoader( Project project, Path classpath, boolean parentFirst ) | ||||
| throws TaskException | |||||
| { | { | ||||
| this( null, project, classpath, parentFirst ); | this( null, project, classpath, parentFirst ); | ||||
| } | } | ||||
| @@ -411,10 +414,10 @@ public class AntClassLoader extends ClassLoader implements BuildListener | |||||
| * Add an element to the classpath to be searched | * Add an element to the classpath to be searched | ||||
| * | * | ||||
| * @param pathElement The feature to be added to the PathElement attribute | * @param pathElement The feature to be added to the PathElement attribute | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void addPathElement( String pathElement ) | public void addPathElement( String pathElement ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| File pathComponent | File pathComponent | ||||
| = project != null ? FileUtils.newFileUtils().resolveFile( project.getBaseDir(), pathElement ) | = project != null ? FileUtils.newFileUtils().resolveFile( project.getBaseDir(), pathElement ) | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FilenameFilter; | import java.io.FilenameFilter; | ||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| @@ -13,6 +14,7 @@ import java.net.MalformedURLException; | |||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * This is the Ant command line front end to end. This front end works out where | * This is the Ant command line front end to end. This front end works out where | ||||
| @@ -24,6 +26,7 @@ public class Launcher | |||||
| { | { | ||||
| public static void main( String[] args ) | public static void main( String[] args ) | ||||
| throws TaskException | |||||
| { | { | ||||
| File antHome = null; | File antHome = null; | ||||
| ClassLoader systemClassLoader = Launcher.class.getClassLoader(); | ClassLoader systemClassLoader = Launcher.class.getClassLoader(); | ||||
| @@ -65,7 +68,7 @@ public class Launcher | |||||
| antLoader.initializeClass( mainClass ); | antLoader.initializeClass( mainClass ); | ||||
| final Class[] param = {Class.forName( "[Ljava.lang.String;" ), | final Class[] param = {Class.forName( "[Ljava.lang.String;" ), | ||||
| Properties.class, ClassLoader.class}; | |||||
| Properties.class, ClassLoader.class}; | |||||
| final Method startMethod = mainClass.getMethod( "start", param ); | final Method startMethod = mainClass.getMethod( "start", param ); | ||||
| final Object[] argument = {args, launchProperties, systemClassLoader}; | final Object[] argument = {args, launchProperties, systemClassLoader}; | ||||
| startMethod.invoke( null, argument ); | startMethod.invoke( null, argument ); | ||||
| @@ -78,6 +81,7 @@ public class Launcher | |||||
| } | } | ||||
| private static void addDirJars( AntClassLoader classLoader, File jarDir ) | private static void addDirJars( AntClassLoader classLoader, File jarDir ) | ||||
| throws TaskException | |||||
| { | { | ||||
| String[] fileList = jarDir.list( | String[] fileList = jarDir.list( | ||||
| new FilenameFilter() | new FilenameFilter() | ||||
| @@ -92,7 +96,7 @@ public class Launcher | |||||
| { | { | ||||
| for( int i = 0; i < fileList.length; ++i ) | for( int i = 0; i < fileList.length; ++i ) | ||||
| { | { | ||||
| File jarFile = new File( jarDir, fileList[i] ); | |||||
| File jarFile = new File( jarDir, fileList[ i ] ); | |||||
| classLoader.addPathElement( jarFile.getAbsolutePath() ); | classLoader.addPathElement( jarFile.getAbsolutePath() ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -107,7 +108,7 @@ public class Main | |||||
| for( int i = 0; i < args.length; i++ ) | for( int i = 0; i < args.length; i++ ) | ||||
| { | { | ||||
| String arg = args[i]; | |||||
| String arg = args[ i ]; | |||||
| if( arg.equals( "-help" ) ) | if( arg.equals( "-help" ) ) | ||||
| { | { | ||||
| @@ -137,7 +138,7 @@ public class Main | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| File logFile = new File( args[i + 1] ); | |||||
| File logFile = new File( args[ i + 1 ] ); | |||||
| i++; | i++; | ||||
| out = new PrintStream( new FileOutputStream( logFile ) ); | out = new PrintStream( new FileOutputStream( logFile ) ); | ||||
| err = out; | err = out; | ||||
| @@ -163,7 +164,7 @@ public class Main | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| buildFile = new File( args[i + 1] ); | |||||
| buildFile = new File( args[ i + 1 ] ); | |||||
| i++; | i++; | ||||
| } | } | ||||
| catch( ArrayIndexOutOfBoundsException aioobe ) | catch( ArrayIndexOutOfBoundsException aioobe ) | ||||
| @@ -178,7 +179,7 @@ public class Main | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| listeners.addElement( args[i + 1] ); | |||||
| listeners.addElement( args[ i + 1 ] ); | |||||
| i++; | i++; | ||||
| } | } | ||||
| catch( ArrayIndexOutOfBoundsException aioobe ) | catch( ArrayIndexOutOfBoundsException aioobe ) | ||||
| @@ -212,7 +213,7 @@ public class Main | |||||
| name = name.substring( 0, posEq ); | name = name.substring( 0, posEq ); | ||||
| } | } | ||||
| else if( i < args.length - 1 ) | else if( i < args.length - 1 ) | ||||
| value = args[++i]; | |||||
| value = args[ ++i ]; | |||||
| definedProps.put( name, value ); | definedProps.put( name, value ); | ||||
| } | } | ||||
| @@ -225,12 +226,12 @@ public class Main | |||||
| } | } | ||||
| try | try | ||||
| { | { | ||||
| loggerClassname = args[++i]; | |||||
| loggerClassname = args[ ++i ]; | |||||
| } | } | ||||
| catch( ArrayIndexOutOfBoundsException aioobe ) | catch( ArrayIndexOutOfBoundsException aioobe ) | ||||
| { | { | ||||
| System.out.println( "You must specify a classname when " + | System.out.println( "You must specify a classname when " + | ||||
| "using the -logger argument" ); | |||||
| "using the -logger argument" ); | |||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| @@ -248,7 +249,7 @@ public class Main | |||||
| // eat up next arg if present, default to build.xml | // eat up next arg if present, default to build.xml | ||||
| if( i < args.length - 1 ) | if( i < args.length - 1 ) | ||||
| { | { | ||||
| searchForThis = args[++i]; | |||||
| searchForThis = args[ ++i ]; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -278,7 +279,7 @@ public class Main | |||||
| if( searchForThis != null ) | if( searchForThis != null ) | ||||
| { | { | ||||
| buildFile = findBuildFile( System.getProperty( "user.dir" ), | buildFile = findBuildFile( System.getProperty( "user.dir" ), | ||||
| searchForThis ); | |||||
| searchForThis ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -329,7 +330,7 @@ public class Main | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| throw new TaskException( "Could not load the version information:" | throw new TaskException( "Could not load the version information:" | ||||
| + ioe.getMessage() ); | |||||
| + ioe.getMessage() ); | |||||
| } | } | ||||
| catch( NullPointerException npe ) | catch( NullPointerException npe ) | ||||
| { | { | ||||
| @@ -339,7 +340,6 @@ public class Main | |||||
| return antVersion; | return antVersion; | ||||
| } | } | ||||
| /** | /** | ||||
| * Command line entry point. This method kicks off the building of a project | * Command line entry point. This method kicks off the building of a project | ||||
| * object and executes a build using either a given target or the default | * object and executes a build using either a given target or the default | ||||
| @@ -376,9 +376,9 @@ public class Main | |||||
| if( additionalUserProperties != null ) | if( additionalUserProperties != null ) | ||||
| { | { | ||||
| for( Enumeration e = additionalUserProperties.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = additionalUserProperties.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String key = ( String )e.nextElement(); | |||||
| String key = (String)e.nextElement(); | |||||
| String property = additionalUserProperties.getProperty( key ); | String property = additionalUserProperties.getProperty( key ); | ||||
| m.definedProps.put( key, property ); | m.definedProps.put( key, property ); | ||||
| } | } | ||||
| @@ -417,7 +417,7 @@ public class Main | |||||
| int res = names.size(); | int res = names.size(); | ||||
| for( int i = 0; i < names.size() && res == names.size(); i++ ) | for( int i = 0; i < names.size() && res == names.size(); i++ ) | ||||
| { | { | ||||
| if( name.compareTo( ( String )names.elementAt( i ) ) < 0 ) | |||||
| if( name.compareTo( (String)names.elementAt( i ) ) < 0 ) | |||||
| { | { | ||||
| res = i; | res = i; | ||||
| } | } | ||||
| @@ -474,7 +474,7 @@ public class Main | |||||
| while( ptargets.hasMoreElements() ) | while( ptargets.hasMoreElements() ) | ||||
| { | { | ||||
| currentTarget = ( Target )ptargets.nextElement(); | |||||
| currentTarget = (Target)ptargets.nextElement(); | |||||
| targetName = currentTarget.getName(); | targetName = currentTarget.getName(); | ||||
| targetDescription = currentTarget.getDescription(); | targetDescription = currentTarget.getDescription(); | ||||
| // maintain a sorted list of targets | // maintain a sorted list of targets | ||||
| @@ -535,7 +535,7 @@ public class Main | |||||
| msg.append( names.elementAt( i ) ); | msg.append( names.elementAt( i ) ); | ||||
| if( descriptions != null ) | if( descriptions != null ) | ||||
| { | { | ||||
| msg.append( spaces.substring( 0, maxlen - ( ( String )names.elementAt( i ) ).length() + 2 ) ); | |||||
| msg.append( spaces.substring( 0, maxlen - ( (String)names.elementAt( i ) ).length() + 2 ) ); | |||||
| msg.append( descriptions.elementAt( i ) ); | msg.append( descriptions.elementAt( i ) ); | ||||
| } | } | ||||
| msg.append( lSep ); | msg.append( lSep ); | ||||
| @@ -576,18 +576,18 @@ public class Main | |||||
| } | } | ||||
| protected void addBuildListeners( Project project ) | protected void addBuildListeners( Project project ) | ||||
| throws TaskException | |||||
| { | { | ||||
| // Add the default listener | // Add the default listener | ||||
| project.addBuildListener( createLogger() ); | project.addBuildListener( createLogger() ); | ||||
| for( int i = 0; i < listeners.size(); i++ ) | for( int i = 0; i < listeners.size(); i++ ) | ||||
| { | { | ||||
| String className = ( String )listeners.elementAt( i ); | |||||
| String className = (String)listeners.elementAt( i ); | |||||
| try | try | ||||
| { | { | ||||
| BuildListener listener = | BuildListener listener = | ||||
| ( BuildListener )Class.forName( className ).newInstance(); | |||||
| (BuildListener)Class.forName( className ).newInstance(); | |||||
| project.addBuildListener( listener ); | project.addBuildListener( listener ); | ||||
| } | } | ||||
| catch( Throwable exc ) | catch( Throwable exc ) | ||||
| @@ -631,18 +631,18 @@ public class Main | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| logger = ( BuildLogger )( Class.forName( loggerClassname ).newInstance() ); | |||||
| logger = (BuildLogger)( Class.forName( loggerClassname ).newInstance() ); | |||||
| } | } | ||||
| catch( ClassCastException e ) | catch( ClassCastException e ) | ||||
| { | { | ||||
| System.err.println( "The specified logger class " + loggerClassname + | System.err.println( "The specified logger class " + loggerClassname + | ||||
| " does not implement the BuildLogger interface" ); | |||||
| " does not implement the BuildLogger interface" ); | |||||
| throw new RuntimeException(); | throw new RuntimeException(); | ||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| System.err.println( "Unable to instantiate specified logger class " + | System.err.println( "Unable to instantiate specified logger class " + | ||||
| loggerClassname + " : " + e.getClass().getName() ); | |||||
| loggerClassname + " : " + e.getClass().getName() ); | |||||
| throw new RuntimeException(); | throw new RuntimeException(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -765,8 +765,8 @@ public class Main | |||||
| Enumeration e = definedProps.keys(); | Enumeration e = definedProps.keys(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| String arg = ( String )e.nextElement(); | |||||
| String value = ( String )definedProps.get( arg ); | |||||
| String arg = (String)e.nextElement(); | |||||
| String value = (String)definedProps.get( arg ); | |||||
| project.setUserProperty( arg, value ); | project.setUserProperty( arg, value ); | ||||
| } | } | ||||
| @@ -6,14 +6,15 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| @@ -87,7 +88,7 @@ public abstract class Definer extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| AntClassLoader al = createLoader(); | AntClassLoader al = createLoader(); | ||||
| @@ -98,9 +99,9 @@ public abstract class Definer extends Task | |||||
| if( name == null || value == null ) | if( name == null || value == null ) | ||||
| { | { | ||||
| String msg = "name or classname attributes of " | String msg = "name or classname attributes of " | ||||
| + getTaskName() + " element " | |||||
| + "are undefined"; | |||||
| throw new BuildException( msg ); | |||||
| + getTaskName() + " element " | |||||
| + "are undefined"; | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| addDefinition( al, name, value ); | addDefinition( al, name, value ); | ||||
| @@ -113,14 +114,14 @@ public abstract class Definer extends Task | |||||
| if( name != null || value != null ) | if( name != null || value != null ) | ||||
| { | { | ||||
| String msg = "You must not specify name or value " | String msg = "You must not specify name or value " | ||||
| + "together with file or resource."; | |||||
| throw new BuildException( msg ); | |||||
| + "together with file or resource."; | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| if( file != null && resource != null ) | if( file != null && resource != null ) | ||||
| { | { | ||||
| String msg = "You must not specify both, file and resource."; | String msg = "You must not specify both, file and resource."; | ||||
| throw new BuildException( msg ); | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| Properties props = new Properties(); | Properties props = new Properties(); | ||||
| @@ -128,7 +129,7 @@ public abstract class Definer extends Task | |||||
| if( file != null ) | if( file != null ) | ||||
| { | { | ||||
| log( "Loading definitions from file " + file, | log( "Loading definitions from file " + file, | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| is = new FileInputStream( file ); | is = new FileInputStream( file ); | ||||
| if( is == null ) | if( is == null ) | ||||
| { | { | ||||
| @@ -139,13 +140,13 @@ public abstract class Definer extends Task | |||||
| if( resource != null ) | if( resource != null ) | ||||
| { | { | ||||
| log( "Loading definitions from resource " + resource, | log( "Loading definitions from resource " + resource, | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| is = al.getResourceAsStream( resource ); | is = al.getResourceAsStream( resource ); | ||||
| if( is == null ) | if( is == null ) | ||||
| { | { | ||||
| log( "Could not load definitions from resource " | log( "Could not load definitions from resource " | ||||
| + resource + ". It could not be found.", | + resource + ". It could not be found.", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -155,7 +156,7 @@ public abstract class Definer extends Task | |||||
| Enumeration keys = props.keys(); | Enumeration keys = props.keys(); | ||||
| while( keys.hasMoreElements() ) | while( keys.hasMoreElements() ) | ||||
| { | { | ||||
| String n = ( String )keys.nextElement(); | |||||
| String n = (String)keys.nextElement(); | |||||
| String v = props.getProperty( n ); | String v = props.getProperty( n ); | ||||
| addDefinition( al, n, v ); | addDefinition( al, n, v ); | ||||
| } | } | ||||
| @@ -163,7 +164,7 @@ public abstract class Definer extends Task | |||||
| } | } | ||||
| catch( IOException ex ) | catch( IOException ex ) | ||||
| { | { | ||||
| throw new BuildException( "Error", ex); | |||||
| throw new TaskException( "Error", ex ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -171,7 +172,7 @@ public abstract class Definer extends Task | |||||
| protected abstract void addDefinition( String name, Class c ); | protected abstract void addDefinition( String name, Class c ); | ||||
| private void addDefinition( ClassLoader al, String name, String value ) | private void addDefinition( ClassLoader al, String name, String value ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -183,18 +184,18 @@ public abstract class Definer extends Task | |||||
| { | { | ||||
| String msg = getTaskName() + " class " + value + | String msg = getTaskName() + " class " + value + | ||||
| " cannot be found"; | " cannot be found"; | ||||
| throw new BuildException( msg, cnfe ); | |||||
| throw new TaskException( msg, cnfe ); | |||||
| } | } | ||||
| catch( NoClassDefFoundError ncdfe ) | catch( NoClassDefFoundError ncdfe ) | ||||
| { | { | ||||
| String msg = getTaskName() + " class " + value + | String msg = getTaskName() + " class " + value + | ||||
| " cannot be found"; | " cannot be found"; | ||||
| throw new BuildException( msg, ncdfe ); | |||||
| throw new TaskException( msg, ncdfe ); | |||||
| } | } | ||||
| } | } | ||||
| private AntClassLoader createLoader() | private AntClassLoader createLoader() | ||||
| throws TaskException | |||||
| { | { | ||||
| AntClassLoader al = null; | AntClassLoader al = null; | ||||
| if( classpath != null ) | if( classpath != null ) | ||||
| @@ -16,10 +16,12 @@ import java.lang.reflect.InvocationTargetException; | |||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.myrmidon.framework.Os; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.myrmidon.framework.Os; | |||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| /** | /** | ||||
| @@ -428,7 +430,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public int execute() | public int execute() | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| CommandLauncher launcher = vmLauncher != null ? vmLauncher : shellLauncher; | CommandLauncher launcher = vmLauncher != null ? vmLauncher : shellLauncher; | ||||
| if( !useVMLauncher ) | if( !useVMLauncher ) | ||||
| @@ -547,7 +549,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env ) | public Process exec( Project project, String[] cmd, String[] env ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| if( project != null ) | if( project != null ) | ||||
| { | { | ||||
| @@ -571,7 +573,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| if( workingDir == null ) | if( workingDir == null ) | ||||
| { | { | ||||
| @@ -608,7 +610,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env ) | public Process exec( Project project, String[] cmd, String[] env ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| return _launcher.exec( project, cmd, env ); | return _launcher.exec( project, cmd, env ); | ||||
| } | } | ||||
| @@ -633,7 +635,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env ) | public Process exec( Project project, String[] cmd, String[] env ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| // Need to quote arguments with spaces, and to escape quote characters | // Need to quote arguments with spaces, and to escape quote characters | ||||
| String[] newcmd = new String[ cmd.length ]; | String[] newcmd = new String[ cmd.length ]; | ||||
| @@ -741,7 +743,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| if( workingDir == null ) | if( workingDir == null ) | ||||
| { | { | ||||
| @@ -768,7 +770,6 @@ public class Execute | |||||
| */ | */ | ||||
| private static class PerlScriptCommandLauncher extends CommandLauncherProxy | private static class PerlScriptCommandLauncher extends CommandLauncherProxy | ||||
| { | { | ||||
| private String _script; | private String _script; | ||||
| PerlScriptCommandLauncher( String script, CommandLauncher launcher ) | PerlScriptCommandLauncher( String script, CommandLauncher launcher ) | ||||
| @@ -789,7 +790,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| if( project == null ) | if( project == null ) | ||||
| { | { | ||||
| @@ -806,7 +807,8 @@ public class Execute | |||||
| { | { | ||||
| throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | ||||
| } | } | ||||
| String antRun = resolveFile( antHome + File.separator + _script ).toString(); | |||||
| String antRun = FileUtils.newFileUtils(). | |||||
| resolveFile( project.getBaseDir(), antHome + File.separator + _script ).toString(); | |||||
| // Build the command | // Build the command | ||||
| File commandDir = workingDir; | File commandDir = workingDir; | ||||
| @@ -854,7 +856,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| if( project == null ) | if( project == null ) | ||||
| { | { | ||||
| @@ -871,7 +873,8 @@ public class Execute | |||||
| { | { | ||||
| throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | ||||
| } | } | ||||
| String antRun = resolveFile( antHome + File.separator + _script ).toString(); | |||||
| String antRun = FileUtils.newFileUtils(). | |||||
| resolveFile( project.getBaseDir(), antHome + File.separator + _script ).toString(); | |||||
| // Build the command | // Build the command | ||||
| File commandDir = workingDir; | File commandDir = workingDir; | ||||
| @@ -914,7 +917,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| File commandDir = workingDir; | File commandDir = workingDir; | ||||
| if( workingDir == null ) | if( workingDir == null ) | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -13,6 +14,7 @@ import java.io.InputStream; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| @@ -144,20 +146,20 @@ public class Property extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( name != null ) | if( name != null ) | ||||
| { | { | ||||
| if( value == null && ref == null ) | if( value == null && ref == null ) | ||||
| { | { | ||||
| throw new BuildException( "You must specify value, location or refid with the name attribute" ); | |||||
| throw new TaskException( "You must specify value, location or refid with the name attribute" ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| if( file == null && resource == null && env == null ) | if( file == null && resource == null && env == null ) | ||||
| { | { | ||||
| throw new BuildException( "You must specify file, resource or environment when not using the name attribute" ); | |||||
| throw new TaskException( "You must specify file, resource or environment when not using the name attribute" ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -196,8 +198,8 @@ public class Property extends Task | |||||
| Enumeration e = props.keys(); | Enumeration e = props.keys(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| String name = ( String )e.nextElement(); | |||||
| String value = ( String )props.getProperty( name ); | |||||
| String name = (String)e.nextElement(); | |||||
| String value = (String)props.getProperty( name ); | |||||
| String v = project.replaceProperties( value ); | String v = project.replaceProperties( value ); | ||||
| addProperty( name, v ); | addProperty( name, v ); | ||||
| @@ -230,9 +232,9 @@ public class Property extends Task | |||||
| prefix += "."; | prefix += "."; | ||||
| log( "Loading Environment " + prefix, Project.MSG_VERBOSE ); | log( "Loading Environment " + prefix, Project.MSG_VERBOSE ); | ||||
| Vector osEnv = Execute.getProcEnvironment(); | Vector osEnv = Execute.getProcEnvironment(); | ||||
| for( Enumeration e = osEnv.elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = osEnv.elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String entry = ( String )e.nextElement(); | |||||
| String entry = (String)e.nextElement(); | |||||
| int pos = entry.indexOf( '=' ); | int pos = entry.indexOf( '=' ); | ||||
| if( pos == -1 ) | if( pos == -1 ) | ||||
| { | { | ||||
| @@ -241,14 +243,14 @@ public class Property extends Task | |||||
| else | else | ||||
| { | { | ||||
| props.put( prefix + entry.substring( 0, pos ), | props.put( prefix + entry.substring( 0, pos ), | ||||
| entry.substring( pos + 1 ) ); | |||||
| entry.substring( pos + 1 ) ); | |||||
| } | } | ||||
| } | } | ||||
| addProperties( props ); | addProperties( props ); | ||||
| } | } | ||||
| protected void loadFile( File file ) | protected void loadFile( File file ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Properties props = new Properties(); | Properties props = new Properties(); | ||||
| log( "Loading " + file.getAbsolutePath(), Project.MSG_VERBOSE ); | log( "Loading " + file.getAbsolutePath(), Project.MSG_VERBOSE ); | ||||
| @@ -273,16 +275,17 @@ public class Property extends Task | |||||
| else | else | ||||
| { | { | ||||
| log( "Unable to find property file: " + file.getAbsolutePath(), | log( "Unable to find property file: " + file.getAbsolutePath(), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| } | } | ||||
| catch( IOException ex ) | catch( IOException ex ) | ||||
| { | { | ||||
| throw new BuildException( "Error", ex ); | |||||
| throw new TaskException( "Error", ex ); | |||||
| } | } | ||||
| } | } | ||||
| protected void loadResource( String name ) | protected void loadResource( String name ) | ||||
| throws TaskException | |||||
| { | { | ||||
| Properties props = new Properties(); | Properties props = new Properties(); | ||||
| log( "Resource Loading " + name, Project.MSG_VERBOSE ); | log( "Resource Loading " + name, Project.MSG_VERBOSE ); | ||||
| @@ -321,16 +324,16 @@ public class Property extends Task | |||||
| } | } | ||||
| catch( IOException ex ) | catch( IOException ex ) | ||||
| { | { | ||||
| throw new BuildException( "Error", ex ); | |||||
| throw new TaskException( "Error", ex ); | |||||
| } | } | ||||
| } | } | ||||
| private void resolveAllProperties( Properties props ) | private void resolveAllProperties( Properties props ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| for( Enumeration e = props.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = props.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String name = ( String )e.nextElement(); | |||||
| String name = (String)e.nextElement(); | |||||
| String value = props.getProperty( name ); | String value = props.getProperty( name ); | ||||
| boolean resolved = false; | boolean resolved = false; | ||||
| @@ -348,13 +351,13 @@ public class Property extends Task | |||||
| Enumeration j = propertyRefs.elements(); | Enumeration j = propertyRefs.elements(); | ||||
| while( i.hasMoreElements() ) | while( i.hasMoreElements() ) | ||||
| { | { | ||||
| String fragment = ( String )i.nextElement(); | |||||
| String fragment = (String)i.nextElement(); | |||||
| if( fragment == null ) | if( fragment == null ) | ||||
| { | { | ||||
| String propertyName = ( String )j.nextElement(); | |||||
| String propertyName = (String)j.nextElement(); | |||||
| if( propertyName.equals( name ) ) | if( propertyName.equals( name ) ) | ||||
| { | { | ||||
| throw new BuildException( "Property " + name + " was circularly defined." ); | |||||
| throw new TaskException( "Property " + name + " was circularly defined." ); | |||||
| } | } | ||||
| fragment = getProject().getProperty( propertyName ); | fragment = getProject().getProperty( propertyName ); | ||||
| if( fragment == null ) | if( fragment == null ) | ||||
| @@ -6,12 +6,13 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.rmi.Remote; | import java.rmi.Remote; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.rmic.RmicAdapter; | import org.apache.tools.ant.taskdefs.rmic.RmicAdapter; | ||||
| @@ -19,8 +20,8 @@ import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory; | |||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
| import org.apache.tools.ant.util.FileNameMapper; | import org.apache.tools.ant.util.FileNameMapper; | ||||
| import org.apache.tools.ant.util.SourceFileScanner; | |||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.tools.ant.util.SourceFileScanner; | |||||
| /** | /** | ||||
| * Task to compile RMI stubs and skeletons. This task can take the following | * Task to compile RMI stubs and skeletons. This task can take the following | ||||
| @@ -60,7 +61,7 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| private final static String FAIL_MSG | private final static String FAIL_MSG | ||||
| = "Rmic failed, messages should have been provided."; | |||||
| = "Rmic failed, messages should have been provided."; | |||||
| private boolean verify = false; | private boolean verify = false; | ||||
| private boolean filtering = false; | private boolean filtering = false; | ||||
| @@ -413,9 +414,9 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| for( int i = 0; i < interfaces.length; i++ ) | for( int i = 0; i < interfaces.length; i++ ) | ||||
| { | { | ||||
| if( Remote.class.isAssignableFrom( interfaces[i] ) ) | |||||
| if( Remote.class.isAssignableFrom( interfaces[ i ] ) ) | |||||
| { | { | ||||
| return interfaces[i]; | |||||
| return interfaces[ i ]; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -469,18 +470,18 @@ public class Rmic extends MatchingTask | |||||
| catch( ClassNotFoundException e ) | catch( ClassNotFoundException e ) | ||||
| { | { | ||||
| log( "Unable to verify class " + classname + | log( "Unable to verify class " + classname + | ||||
| ". It could not be found.", Project.MSG_WARN ); | |||||
| ". It could not be found.", Project.MSG_WARN ); | |||||
| } | } | ||||
| catch( NoClassDefFoundError e ) | catch( NoClassDefFoundError e ) | ||||
| { | { | ||||
| log( "Unable to verify class " + classname + | log( "Unable to verify class " + classname + | ||||
| ". It is not defined.", Project.MSG_WARN ); | |||||
| ". It is not defined.", Project.MSG_WARN ); | |||||
| } | } | ||||
| catch( Throwable t ) | catch( Throwable t ) | ||||
| { | { | ||||
| log( "Unable to verify class " + classname + | log( "Unable to verify class " + classname + | ||||
| ". Loading caused Exception: " + | |||||
| t.getMessage(), Project.MSG_WARN ); | |||||
| ". Loading caused Exception: " + | |||||
| t.getMessage(), Project.MSG_WARN ); | |||||
| } | } | ||||
| // we only get here if an exception has been thrown | // we only get here if an exception has been thrown | ||||
| return false; | return false; | ||||
| @@ -515,15 +516,15 @@ public class Rmic extends MatchingTask | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( baseDir == null ) | if( baseDir == null ) | ||||
| { | { | ||||
| throw new BuildException( "base attribute must be set!" ); | |||||
| throw new TaskException( "base attribute must be set!" ); | |||||
| } | } | ||||
| if( !baseDir.exists() ) | if( !baseDir.exists() ) | ||||
| { | { | ||||
| throw new BuildException( "base does not exist!" ); | |||||
| throw new TaskException( "base does not exist!" ); | |||||
| } | } | ||||
| if( verify ) | if( verify ) | ||||
| @@ -552,21 +553,21 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| // otherwise perform a timestamp comparison - at least | // otherwise perform a timestamp comparison - at least | ||||
| scanDir( baseDir, | scanDir( baseDir, | ||||
| new String[]{classname.replace( '.', File.separatorChar ) + ".class"}, | |||||
| adapter.getMapper() ); | |||||
| new String[]{classname.replace( '.', File.separatorChar ) + ".class"}, | |||||
| adapter.getMapper() ); | |||||
| } | } | ||||
| int fileCount = compileList.size(); | int fileCount = compileList.size(); | ||||
| if( fileCount > 0 ) | if( fileCount > 0 ) | ||||
| { | { | ||||
| log( "RMI Compiling " + fileCount + | log( "RMI Compiling " + fileCount + | ||||
| " class" + ( fileCount > 1 ? "es" : "" ) + " to " + baseDir, | |||||
| Project.MSG_INFO ); | |||||
| " class" + ( fileCount > 1 ? "es" : "" ) + " to " + baseDir, | |||||
| Project.MSG_INFO ); | |||||
| // finally, lets execute the compiler!! | // finally, lets execute the compiler!! | ||||
| if( !adapter.execute() ) | if( !adapter.execute() ) | ||||
| { | { | ||||
| throw new BuildException( FAIL_MSG ); | |||||
| throw new TaskException( FAIL_MSG ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -580,7 +581,7 @@ public class Rmic extends MatchingTask | |||||
| if( idl ) | if( idl ) | ||||
| { | { | ||||
| log( "Cannot determine sourcefiles in idl mode, ", | log( "Cannot determine sourcefiles in idl mode, ", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| log( "sourcebase attribute will be ignored.", Project.MSG_WARN ); | log( "sourcebase attribute will be ignored.", Project.MSG_WARN ); | ||||
| } | } | ||||
| else | else | ||||
| @@ -588,8 +589,8 @@ public class Rmic extends MatchingTask | |||||
| for( int j = 0; j < fileCount; j++ ) | for( int j = 0; j < fileCount; j++ ) | ||||
| { | { | ||||
| moveGeneratedFile( baseDir, sourceBase, | moveGeneratedFile( baseDir, sourceBase, | ||||
| ( String )compileList.elementAt( j ), | |||||
| adapter ); | |||||
| (String)compileList.elementAt( j ), | |||||
| adapter ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -612,13 +613,13 @@ public class Rmic extends MatchingTask | |||||
| if( idl ) | if( idl ) | ||||
| { | { | ||||
| log( "will leave uptodate test to rmic implementation in idl mode.", | log( "will leave uptodate test to rmic implementation in idl mode.", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| else if( iiop | else if( iiop | ||||
| && iiopopts != null && iiopopts.indexOf( "-always" ) > -1 ) | |||||
| && iiopopts != null && iiopopts.indexOf( "-always" ) > -1 ) | |||||
| { | { | ||||
| log( "no uptodate test as -always option has been specified", | log( "no uptodate test as -always option has been specified", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -628,7 +629,7 @@ public class Rmic extends MatchingTask | |||||
| for( int i = 0; i < newFiles.length; i++ ) | for( int i = 0; i < newFiles.length; i++ ) | ||||
| { | { | ||||
| String classname = newFiles[i].replace( File.separatorChar, '.' ); | |||||
| String classname = newFiles[ i ].replace( File.separatorChar, '.' ); | |||||
| classname = classname.substring( 0, classname.lastIndexOf( ".class" ) ); | classname = classname.substring( 0, classname.lastIndexOf( ".class" ) ); | ||||
| compileList.addElement( classname ); | compileList.addElement( classname ); | ||||
| } | } | ||||
| @@ -652,12 +653,12 @@ public class Rmic extends MatchingTask | |||||
| * @param sourceBaseFile Description of Parameter | * @param sourceBaseFile Description of Parameter | ||||
| * @param classname Description of Parameter | * @param classname Description of Parameter | ||||
| * @param adapter Description of Parameter | * @param adapter Description of Parameter | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void moveGeneratedFile( File baseDir, File sourceBaseFile, | private void moveGeneratedFile( File baseDir, File sourceBaseFile, | ||||
| String classname, | String classname, | ||||
| RmicAdapter adapter ) | RmicAdapter adapter ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| String classFileName = | String classFileName = | ||||
| @@ -680,7 +681,8 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| String msg = "Failed to copy " + oldFile + " to " + | String msg = "Failed to copy " + oldFile + " to " + | ||||
| newFile + " due to " + ioe.getMessage(); | newFile + " due to " + ioe.getMessage(); | ||||
| throw new BuildException( msg, ioe ); | |||||
| newFile + " due to " + ioe.getMessage(); | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -30,15 +31,14 @@ import java.util.Properties; | |||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.ProjectHelper; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * Reads in a text file containing SQL statements seperated with semicolons and | * Reads in a text file containing SQL statements seperated with semicolons and | ||||
| @@ -258,7 +258,6 @@ public class SQLExec extends Task | |||||
| this.output = output; | this.output = output; | ||||
| } | } | ||||
| /** | /** | ||||
| * Set the password for the DB connection. | * Set the password for the DB connection. | ||||
| * | * | ||||
| @@ -373,7 +372,6 @@ public class SQLExec extends Task | |||||
| return this.classpath.createPath(); | return this.classpath.createPath(); | ||||
| } | } | ||||
| /** | /** | ||||
| * Set the sql command to execute | * Set the sql command to execute | ||||
| * | * | ||||
| @@ -389,10 +387,10 @@ public class SQLExec extends Task | |||||
| /** | /** | ||||
| * Load the sql file and then execute it | * Load the sql file and then execute it | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| sqlCommand = sqlCommand.trim(); | sqlCommand = sqlCommand.trim(); | ||||
| @@ -400,7 +398,7 @@ public class SQLExec extends Task | |||||
| { | { | ||||
| if( transactions.size() == 0 ) | if( transactions.size() == 0 ) | ||||
| { | { | ||||
| throw new BuildException( "Source file or fileset, transactions or sql statement must be set!" ); | |||||
| throw new TaskException( "Source file or fileset, transactions or sql statement must be set!" ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -408,7 +406,7 @@ public class SQLExec extends Task | |||||
| // deal with the filesets | // deal with the filesets | ||||
| for( int i = 0; i < filesets.size(); i++ ) | for( int i = 0; i < filesets.size(); i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )filesets.elementAt( i ); | |||||
| FileSet fs = (FileSet)filesets.elementAt( i ); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| File srcDir = fs.getDir( project ); | File srcDir = fs.getDir( project ); | ||||
| @@ -418,7 +416,7 @@ public class SQLExec extends Task | |||||
| for( int j = 0; j < srcFiles.length; j++ ) | for( int j = 0; j < srcFiles.length; j++ ) | ||||
| { | { | ||||
| Transaction t = createTransaction(); | Transaction t = createTransaction(); | ||||
| t.setSrc( new File( srcDir, srcFiles[j] ) ); | |||||
| t.setSrc( new File( srcDir, srcFiles[ j ] ) ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -430,23 +428,23 @@ public class SQLExec extends Task | |||||
| if( driver == null ) | if( driver == null ) | ||||
| { | { | ||||
| throw new BuildException( "Driver attribute must be set!" ); | |||||
| throw new TaskException( "Driver attribute must be set!" ); | |||||
| } | } | ||||
| if( userId == null ) | if( userId == null ) | ||||
| { | { | ||||
| throw new BuildException( "User Id attribute must be set!" ); | |||||
| throw new TaskException( "User Id attribute must be set!" ); | |||||
| } | } | ||||
| if( password == null ) | if( password == null ) | ||||
| { | { | ||||
| throw new BuildException( "Password attribute must be set!" ); | |||||
| throw new TaskException( "Password attribute must be set!" ); | |||||
| } | } | ||||
| if( url == null ) | if( url == null ) | ||||
| { | { | ||||
| throw new BuildException( "Url attribute must be set!" ); | |||||
| throw new TaskException( "Url attribute must be set!" ); | |||||
| } | } | ||||
| if( srcFile != null && !srcFile.exists() ) | if( srcFile != null && !srcFile.exists() ) | ||||
| { | { | ||||
| throw new BuildException( "Source file does not exist!" ); | |||||
| throw new TaskException( "Source file does not exist!" ); | |||||
| } | } | ||||
| Driver driverInstance = null; | Driver driverInstance = null; | ||||
| // Load the driver using the | // Load the driver using the | ||||
| @@ -456,7 +454,7 @@ public class SQLExec extends Task | |||||
| if( classpath != null ) | if( classpath != null ) | ||||
| { | { | ||||
| log( "Loading " + driver + " using AntClassLoader with classpath " + classpath, | log( "Loading " + driver + " using AntClassLoader with classpath " + classpath, | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| loader = new AntClassLoader( project, classpath ); | loader = new AntClassLoader( project, classpath ); | ||||
| dc = loader.loadClass( driver ); | dc = loader.loadClass( driver ); | ||||
| @@ -466,19 +464,19 @@ public class SQLExec extends Task | |||||
| log( "Loading " + driver + " using system loader.", Project.MSG_VERBOSE ); | log( "Loading " + driver + " using system loader.", Project.MSG_VERBOSE ); | ||||
| dc = Class.forName( driver ); | dc = Class.forName( driver ); | ||||
| } | } | ||||
| driverInstance = ( Driver )dc.newInstance(); | |||||
| driverInstance = (Driver)dc.newInstance(); | |||||
| } | } | ||||
| catch( ClassNotFoundException e ) | catch( ClassNotFoundException e ) | ||||
| { | { | ||||
| throw new BuildException( "Class Not Found: JDBC driver " + driver + " could not be loaded" ); | |||||
| throw new TaskException( "Class Not Found: JDBC driver " + driver + " could not be loaded" ); | |||||
| } | } | ||||
| catch( IllegalAccessException e ) | catch( IllegalAccessException e ) | ||||
| { | { | ||||
| throw new BuildException( "Illegal Access: JDBC driver " + driver + " could not be loaded" ); | |||||
| throw new TaskException( "Illegal Access: JDBC driver " + driver + " could not be loaded" ); | |||||
| } | } | ||||
| catch( InstantiationException e ) | catch( InstantiationException e ) | ||||
| { | { | ||||
| throw new BuildException( "Instantiation Exception: JDBC driver " + driver + " could not be loaded" ); | |||||
| throw new TaskException( "Instantiation Exception: JDBC driver " + driver + " could not be loaded" ); | |||||
| } | } | ||||
| try | try | ||||
| @@ -513,10 +511,10 @@ public class SQLExec extends Task | |||||
| // Process all transactions | // Process all transactions | ||||
| for( Enumeration e = transactions.elements(); | for( Enumeration e = transactions.elements(); | ||||
| e.hasMoreElements(); ) | |||||
| e.hasMoreElements(); ) | |||||
| { | { | ||||
| ( ( Transaction )e.nextElement() ).runTransaction( out ); | |||||
| ( (Transaction)e.nextElement() ).runTransaction( out ); | |||||
| if( !autocommit ) | if( !autocommit ) | ||||
| { | { | ||||
| log( "Commiting transaction", Project.MSG_VERBOSE ); | log( "Commiting transaction", Project.MSG_VERBOSE ); | ||||
| @@ -541,9 +539,10 @@ public class SQLExec extends Task | |||||
| conn.rollback(); | conn.rollback(); | ||||
| } | } | ||||
| catch( SQLException ex ) | catch( SQLException ex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| catch( SQLException e ) | catch( SQLException e ) | ||||
| { | { | ||||
| @@ -554,9 +553,10 @@ public class SQLExec extends Task | |||||
| conn.rollback(); | conn.rollback(); | ||||
| } | } | ||||
| catch( SQLException ex ) | catch( SQLException ex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -572,11 +572,12 @@ public class SQLExec extends Task | |||||
| } | } | ||||
| } | } | ||||
| catch( SQLException e ) | catch( SQLException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| log( goodSql + " of " + totalSql + | log( goodSql + " of " + totalSql + | ||||
| " SQL statements executed successfully" ); | |||||
| " SQL statements executed successfully" ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -650,7 +651,7 @@ public class SQLExec extends Task | |||||
| if( !statement.execute( sql ) ) | if( !statement.execute( sql ) ) | ||||
| { | { | ||||
| log( statement.getUpdateCount() + " rows affected", | log( statement.getUpdateCount() + " rows affected", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -733,7 +734,7 @@ public class SQLExec extends Task | |||||
| line.setLength( 0 ); | line.setLength( 0 ); | ||||
| } | } | ||||
| } | } | ||||
| }while ( statement.getMoreResults() ); | |||||
| } while( statement.getMoreResults() ); | |||||
| out.println(); | out.println(); | ||||
| } | } | ||||
| @@ -855,9 +856,9 @@ public class SQLExec extends Task | |||||
| if( tSrcFile != null ) | if( tSrcFile != null ) | ||||
| { | { | ||||
| log( "Executing file: " + tSrcFile.getAbsolutePath(), | log( "Executing file: " + tSrcFile.getAbsolutePath(), | ||||
| Project.MSG_INFO ); | |||||
| Project.MSG_INFO ); | |||||
| Reader reader = ( encoding == null ) ? new FileReader( tSrcFile ) | Reader reader = ( encoding == null ) ? new FileReader( tSrcFile ) | ||||
| : new InputStreamReader( new FileInputStream( tSrcFile ), encoding ); | |||||
| : new InputStreamReader( new FileInputStream( tSrcFile ), encoding ); | |||||
| runStatements( reader, out ); | runStatements( reader, out ); | ||||
| reader.close(); | reader.close(); | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| @@ -17,8 +18,8 @@ import java.net.URL; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -73,7 +74,7 @@ public class XMLValidateTask extends Task | |||||
| */ | */ | ||||
| protected XMLReader xmlReader = null;// XMLReader used to validation process | protected XMLReader xmlReader = null;// XMLReader used to validation process | ||||
| protected ValidatorErrorHandler errorHandler | protected ValidatorErrorHandler errorHandler | ||||
| = new ValidatorErrorHandler();// to report sax parsing errors | |||||
| = new ValidatorErrorHandler();// to report sax parsing errors | |||||
| protected Hashtable features = new Hashtable(); | protected Hashtable features = new Hashtable(); | ||||
| /** | /** | ||||
| @@ -102,7 +103,6 @@ public class XMLValidateTask extends Task | |||||
| readerClassName = className; | readerClassName = className; | ||||
| } | } | ||||
| /** | /** | ||||
| * Specify the classpath to be searched to load the parser (optional) | * Specify the classpath to be searched to load the parser (optional) | ||||
| * | * | ||||
| @@ -133,7 +133,7 @@ public class XMLValidateTask extends Task | |||||
| /** | /** | ||||
| * Specify how parser error are to be handled. <p> | * Specify how parser error are to be handled. <p> | ||||
| * | * | ||||
| * If set to <code>true</code> (default), throw a buildException if the | |||||
| * If set to <code>true</code> (default), throw a TaskException if the | |||||
| * parser yields an error. | * parser yields an error. | ||||
| * | * | ||||
| * @param fail The new FailOnError value | * @param fail The new FailOnError value | ||||
| @@ -226,13 +226,13 @@ public class XMLValidateTask extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| int fileProcessed = 0; | int fileProcessed = 0; | ||||
| if( file == null && ( filesets.size() == 0 ) ) | if( file == null && ( filesets.size() == 0 ) ) | ||||
| { | { | ||||
| throw new BuildException( "Specify at least one source - a file or a fileset." ); | |||||
| throw new TaskException( "Specify at least one source - a file or a fileset." ); | |||||
| } | } | ||||
| initValidator(); | initValidator(); | ||||
| @@ -248,7 +248,7 @@ public class XMLValidateTask extends Task | |||||
| { | { | ||||
| String errorMsg = "File " + file + " cannot be read"; | String errorMsg = "File " + file + " cannot be read"; | ||||
| if( failOnError ) | if( failOnError ) | ||||
| throw new BuildException( errorMsg ); | |||||
| throw new TaskException( errorMsg ); | |||||
| else | else | ||||
| log( errorMsg, Project.MSG_ERR ); | log( errorMsg, Project.MSG_ERR ); | ||||
| } | } | ||||
| @@ -257,13 +257,13 @@ public class XMLValidateTask extends Task | |||||
| for( int i = 0; i < filesets.size(); i++ ) | for( int i = 0; i < filesets.size(); i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )filesets.elementAt( i ); | |||||
| FileSet fs = (FileSet)filesets.elementAt( i ); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| String[] files = ds.getIncludedFiles(); | String[] files = ds.getIncludedFiles(); | ||||
| for( int j = 0; j < files.length; j++ ) | for( int j = 0; j < files.length; j++ ) | ||||
| { | { | ||||
| File srcFile = new File( fs.getDir( project ), files[j] ); | |||||
| File srcFile = new File( fs.getDir( project ), files[ j ] ); | |||||
| doValidate( srcFile ); | doValidate( srcFile ); | ||||
| fileProcessed++; | fileProcessed++; | ||||
| } | } | ||||
| @@ -275,9 +275,9 @@ public class XMLValidateTask extends Task | |||||
| { | { | ||||
| LocalResolver resolver = new LocalResolver(); | LocalResolver resolver = new LocalResolver(); | ||||
| for( Enumeration i = dtdLocations.elements(); i.hasMoreElements(); ) | |||||
| for( Enumeration i = dtdLocations.elements(); i.hasMoreElements(); ) | |||||
| { | { | ||||
| DTDLocation location = ( DTDLocation )i.nextElement(); | |||||
| DTDLocation location = (DTDLocation)i.nextElement(); | |||||
| resolver.registerDTD( location ); | resolver.registerDTD( location ); | ||||
| } | } | ||||
| return resolver; | return resolver; | ||||
| @@ -302,7 +302,7 @@ public class XMLValidateTask extends Task | |||||
| log( "Could not set feature '" | log( "Could not set feature '" | ||||
| + feature | + feature | ||||
| + "' because the parser doesn't recognize it", | + "' because the parser doesn't recognize it", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| } | } | ||||
| catch( SAXNotSupportedException e ) | catch( SAXNotSupportedException e ) | ||||
| { | { | ||||
| @@ -310,7 +310,7 @@ public class XMLValidateTask extends Task | |||||
| log( "Could not set feature '" | log( "Could not set feature '" | ||||
| + feature | + feature | ||||
| + "' because the parser doesn't support it", | + "' because the parser doesn't support it", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| } | } | ||||
| return toReturn; | return toReturn; | ||||
| } | } | ||||
| @@ -327,7 +327,7 @@ public class XMLValidateTask extends Task | |||||
| InputSource is = new InputSource( new FileReader( afile ) ); | InputSource is = new InputSource( new FileReader( afile ) ); | ||||
| String uri = "file:" + afile.getAbsolutePath().replace( '\\', '/' ); | String uri = "file:" + afile.getAbsolutePath().replace( '\\', '/' ); | ||||
| for( int index = uri.indexOf( '#' ); index != -1; | for( int index = uri.indexOf( '#' ); index != -1; | ||||
| index = uri.indexOf( '#' ) ) | |||||
| index = uri.indexOf( '#' ) ) | |||||
| { | { | ||||
| uri = uri.substring( 0, index ) + "%23" + uri.substring( index + 1 ); | uri = uri.substring( 0, index ) + "%23" + uri.substring( index + 1 ); | ||||
| } | } | ||||
| @@ -337,17 +337,17 @@ public class XMLValidateTask extends Task | |||||
| catch( SAXException ex ) | catch( SAXException ex ) | ||||
| { | { | ||||
| if( failOnError ) | if( failOnError ) | ||||
| throw new BuildException( "Could not validate document " + afile ); | |||||
| throw new TaskException( "Could not validate document " + afile ); | |||||
| } | } | ||||
| catch( IOException ex ) | catch( IOException ex ) | ||||
| { | { | ||||
| throw new BuildException( "Could not validate document " + afile, ex ); | |||||
| throw new TaskException( "Could not validate document " + afile, ex ); | |||||
| } | } | ||||
| if( errorHandler.getFailure() ) | if( errorHandler.getFailure() ) | ||||
| { | { | ||||
| if( failOnError ) | if( failOnError ) | ||||
| throw new BuildException( afile + " is not a valid XML document." ); | |||||
| throw new TaskException( afile + " is not a valid XML document." ); | |||||
| else | else | ||||
| log( afile + " is not a valid XML document", Project.MSG_ERR ); | log( afile + " is not a valid XML document", Project.MSG_ERR ); | ||||
| } | } | ||||
| @@ -357,6 +357,7 @@ public class XMLValidateTask extends Task | |||||
| * init the parser : load the parser class, and set features if necessary | * init the parser : load the parser class, and set features if necessary | ||||
| */ | */ | ||||
| private void initValidator() | private void initValidator() | ||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| @@ -369,7 +370,7 @@ public class XMLValidateTask extends Task | |||||
| if( classpath != null ) | if( classpath != null ) | ||||
| { | { | ||||
| AntClassLoader loader = new AntClassLoader( project, classpath ); | AntClassLoader loader = new AntClassLoader( project, classpath ); | ||||
| // loader.addSystemPackageRoot("org.xml"); // needed to avoid conflict | |||||
| // loader.addSystemPackageRoot("org.xml"); // needed to avoid conflict | |||||
| readerClass = loader.loadClass( readerClassName ); | readerClass = loader.loadClass( readerClassName ); | ||||
| AntClassLoader.initializeClass( readerClass ); | AntClassLoader.initializeClass( readerClass ); | ||||
| } | } | ||||
| @@ -380,7 +381,7 @@ public class XMLValidateTask extends Task | |||||
| if( XMLReader.class.isAssignableFrom( readerClass ) ) | if( XMLReader.class.isAssignableFrom( readerClass ) ) | ||||
| { | { | ||||
| xmlReader = ( XMLReader )readerClass.newInstance(); | |||||
| xmlReader = (XMLReader)readerClass.newInstance(); | |||||
| log( "Using SAX2 reader " + readerClassName, Project.MSG_VERBOSE ); | log( "Using SAX2 reader " + readerClassName, Project.MSG_VERBOSE ); | ||||
| } | } | ||||
| else | else | ||||
| @@ -389,29 +390,29 @@ public class XMLValidateTask extends Task | |||||
| // see if it is a SAX1 Parser | // see if it is a SAX1 Parser | ||||
| if( Parser.class.isAssignableFrom( readerClass ) ) | if( Parser.class.isAssignableFrom( readerClass ) ) | ||||
| { | { | ||||
| Parser parser = ( Parser )readerClass.newInstance(); | |||||
| Parser parser = (Parser)readerClass.newInstance(); | |||||
| xmlReader = new ParserAdapter( parser ); | xmlReader = new ParserAdapter( parser ); | ||||
| log( "Using SAX1 parser " + readerClassName, Project.MSG_VERBOSE ); | log( "Using SAX1 parser " + readerClassName, Project.MSG_VERBOSE ); | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( INIT_FAILED_MSG | |||||
| + readerClassName | |||||
| + " implements nor SAX1 Parser nor SAX2 XMLReader." ); | |||||
| throw new TaskException( INIT_FAILED_MSG | |||||
| + readerClassName | |||||
| + " implements nor SAX1 Parser nor SAX2 XMLReader." ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| catch( ClassNotFoundException e ) | catch( ClassNotFoundException e ) | ||||
| { | { | ||||
| throw new BuildException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| throw new TaskException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| } | } | ||||
| catch( InstantiationException e ) | catch( InstantiationException e ) | ||||
| { | { | ||||
| throw new BuildException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| throw new TaskException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| } | } | ||||
| catch( IllegalAccessException e ) | catch( IllegalAccessException e ) | ||||
| { | { | ||||
| throw new BuildException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| throw new TaskException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| } | } | ||||
| xmlReader.setEntityResolver( getEntityResolver() ); | xmlReader.setEntityResolver( getEntityResolver() ); | ||||
| @@ -425,17 +426,17 @@ public class XMLValidateTask extends Task | |||||
| boolean ok = setFeature( "http://xml.org/sax/features/validation", true, true ); | boolean ok = setFeature( "http://xml.org/sax/features/validation", true, true ); | ||||
| if( !ok ) | if( !ok ) | ||||
| { | { | ||||
| throw new BuildException( INIT_FAILED_MSG | |||||
| + readerClassName | |||||
| + " doesn't provide validation" ); | |||||
| throw new TaskException( INIT_FAILED_MSG | |||||
| + readerClassName | |||||
| + " doesn't provide validation" ); | |||||
| } | } | ||||
| } | } | ||||
| // set other features | // set other features | ||||
| Enumeration enum = features.keys(); | Enumeration enum = features.keys(); | ||||
| while( enum.hasMoreElements() ) | while( enum.hasMoreElements() ) | ||||
| { | { | ||||
| String featureId = ( String )enum.nextElement(); | |||||
| setFeature( featureId, ( ( Boolean )features.get( featureId ) ).booleanValue(), true ); | |||||
| String featureId = (String)enum.nextElement(); | |||||
| setFeature( featureId, ( (Boolean)features.get( featureId ) ).booleanValue(), true ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -542,13 +543,15 @@ public class XMLValidateTask extends Task | |||||
| } | } | ||||
| private class LocalResolver | private class LocalResolver | ||||
| implements EntityResolver | |||||
| implements EntityResolver | |||||
| { | { | ||||
| private Hashtable fileDTDs = new Hashtable(); | private Hashtable fileDTDs = new Hashtable(); | ||||
| private Hashtable resourceDTDs = new Hashtable(); | private Hashtable resourceDTDs = new Hashtable(); | ||||
| private Hashtable urlDTDs = new Hashtable(); | private Hashtable urlDTDs = new Hashtable(); | ||||
| public LocalResolver() { } | |||||
| public LocalResolver() | |||||
| { | |||||
| } | |||||
| public void registerDTD( String publicId, String location ) | public void registerDTD( String publicId, String location ) | ||||
| { | { | ||||
| @@ -599,7 +602,7 @@ public class XMLValidateTask extends Task | |||||
| public InputSource resolveEntity( String publicId, String systemId ) | public InputSource resolveEntity( String publicId, String systemId ) | ||||
| throws SAXException | throws SAXException | ||||
| { | { | ||||
| File dtdFile = ( File )fileDTDs.get( publicId ); | |||||
| File dtdFile = (File)fileDTDs.get( publicId ); | |||||
| if( dtdFile != null ) | if( dtdFile != null ) | ||||
| { | { | ||||
| try | try | ||||
| @@ -613,7 +616,7 @@ public class XMLValidateTask extends Task | |||||
| } | } | ||||
| } | } | ||||
| String dtdResourceName = ( String )resourceDTDs.get( publicId ); | |||||
| String dtdResourceName = (String)resourceDTDs.get( publicId ); | |||||
| if( dtdResourceName != null ) | if( dtdResourceName != null ) | ||||
| { | { | ||||
| InputStream is = this.getClass().getResourceAsStream( dtdResourceName ); | InputStream is = this.getClass().getResourceAsStream( dtdResourceName ); | ||||
| @@ -624,7 +627,7 @@ public class XMLValidateTask extends Task | |||||
| } | } | ||||
| } | } | ||||
| URL dtdUrl = ( URL )urlDTDs.get( publicId ); | |||||
| URL dtdUrl = (URL)urlDTDs.get( publicId ); | |||||
| if( dtdUrl != null ) | if( dtdUrl != null ) | ||||
| { | { | ||||
| try | try | ||||
| @@ -640,7 +643,7 @@ public class XMLValidateTask extends Task | |||||
| } | } | ||||
| log( "Could not resolve ( publicId: " + publicId + ", systemId: " + systemId + ") to a local entity", | log( "Could not resolve ( publicId: " + publicId + ", systemId: " + systemId + ") to a local entity", | ||||
| Project.MSG_INFO ); | |||||
| Project.MSG_INFO ); | |||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional.depend; | package org.apache.tools.ant.taskdefs.optional.depend; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| @@ -17,15 +18,14 @@ import java.net.URL; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | import org.apache.tools.ant.taskdefs.MatchingTask; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
| /** | /** | ||||
| * Generate a dependency file for a given set of classes | * Generate a dependency file for a given set of classes | ||||
| * | * | ||||
| @@ -152,7 +152,6 @@ public class Depend extends MatchingTask | |||||
| this.dump = dump; | this.dump = dump; | ||||
| } | } | ||||
| /** | /** | ||||
| * Set the source dirs to find the source Java files. | * Set the source dirs to find the source Java files. | ||||
| * | * | ||||
| @@ -190,10 +189,10 @@ public class Depend extends MatchingTask | |||||
| /** | /** | ||||
| * Does the work. | * Does the work. | ||||
| * | * | ||||
| * @exception BuildException Thrown in unrecovrable error. | |||||
| * @exception TaskException Thrown in unrecovrable error. | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -201,7 +200,7 @@ public class Depend extends MatchingTask | |||||
| String[] srcPathList = srcPath.list(); | String[] srcPathList = srcPath.list(); | ||||
| if( srcPathList.length == 0 ) | if( srcPathList.length == 0 ) | ||||
| { | { | ||||
| throw new BuildException( "srcdir attribute must be set!" ); | |||||
| throw new TaskException( "srcdir attribute must be set!" ); | |||||
| } | } | ||||
| if( destPath == null ) | if( destPath == null ) | ||||
| @@ -211,7 +210,7 @@ public class Depend extends MatchingTask | |||||
| if( cache != null && cache.exists() && !cache.isDirectory() ) | if( cache != null && cache.exists() && !cache.isDirectory() ) | ||||
| { | { | ||||
| throw new BuildException( "The cache, if specified, must point to a directory" ); | |||||
| throw new TaskException( "The cache, if specified, must point to a directory" ); | |||||
| } | } | ||||
| if( cache != null && !cache.exists() ) | if( cache != null && !cache.exists() ) | ||||
| @@ -224,16 +223,16 @@ public class Depend extends MatchingTask | |||||
| if( dump ) | if( dump ) | ||||
| { | { | ||||
| log( "Reverse Dependency Dump for " + affectedClassMap.size() + | log( "Reverse Dependency Dump for " + affectedClassMap.size() + | ||||
| " classes:", Project.MSG_DEBUG ); | |||||
| for( Enumeration e = affectedClassMap.keys(); e.hasMoreElements(); ) | |||||
| " classes:", Project.MSG_DEBUG ); | |||||
| for( Enumeration e = affectedClassMap.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )e.nextElement(); | |||||
| String className = (String)e.nextElement(); | |||||
| log( " Class " + className + " affects:", Project.MSG_DEBUG ); | log( " Class " + className + " affects:", Project.MSG_DEBUG ); | ||||
| Hashtable affectedClasses = ( Hashtable )affectedClassMap.get( className ); | |||||
| for( Enumeration e2 = affectedClasses.keys(); e2.hasMoreElements(); ) | |||||
| Hashtable affectedClasses = (Hashtable)affectedClassMap.get( className ); | |||||
| for( Enumeration e2 = affectedClasses.keys(); e2.hasMoreElements(); ) | |||||
| { | { | ||||
| String affectedClass = ( String )e2.nextElement(); | |||||
| ClassFileInfo info = ( ClassFileInfo )affectedClasses.get( affectedClass ); | |||||
| String affectedClass = (String)e2.nextElement(); | |||||
| ClassFileInfo info = (ClassFileInfo)affectedClasses.get( affectedClass ); | |||||
| log( " " + affectedClass + " in " + info.absoluteFile.getPath(), Project.MSG_DEBUG ); | log( " " + affectedClass + " in " + info.absoluteFile.getPath(), Project.MSG_DEBUG ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -241,14 +240,14 @@ public class Depend extends MatchingTask | |||||
| if( classpathDependencies != null ) | if( classpathDependencies != null ) | ||||
| { | { | ||||
| log( "Classpath file dependencies (Forward):", Project.MSG_DEBUG ); | log( "Classpath file dependencies (Forward):", Project.MSG_DEBUG ); | ||||
| for( Enumeration e = classpathDependencies.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = classpathDependencies.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )e.nextElement(); | |||||
| String className = (String)e.nextElement(); | |||||
| log( " Class " + className + " depends on:", Project.MSG_DEBUG ); | log( " Class " + className + " depends on:", Project.MSG_DEBUG ); | ||||
| Hashtable dependencies = ( Hashtable )classpathDependencies.get( className ); | |||||
| for( Enumeration e2 = dependencies.elements(); e2.hasMoreElements(); ) | |||||
| Hashtable dependencies = (Hashtable)classpathDependencies.get( className ); | |||||
| for( Enumeration e2 = dependencies.elements(); e2.hasMoreElements(); ) | |||||
| { | { | ||||
| File classpathFile = ( File )e2.nextElement(); | |||||
| File classpathFile = (File)e2.nextElement(); | |||||
| log( " " + classpathFile.getPath(), Project.MSG_DEBUG ); | log( " " + classpathFile.getPath(), Project.MSG_DEBUG ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -261,7 +260,7 @@ public class Depend extends MatchingTask | |||||
| outOfDateClasses = new Hashtable(); | outOfDateClasses = new Hashtable(); | ||||
| for( int i = 0; i < srcPathList.length; i++ ) | for( int i = 0; i < srcPathList.length; i++ ) | ||||
| { | { | ||||
| File srcDir = ( File )resolveFile( srcPathList[i] ); | |||||
| File srcDir = (File)resolveFile( srcPathList[ i ] ); | |||||
| if( srcDir.exists() ) | if( srcDir.exists() ) | ||||
| { | { | ||||
| DirectoryScanner ds = this.getDirectoryScanner( srcDir ); | DirectoryScanner ds = this.getDirectoryScanner( srcDir ); | ||||
| @@ -273,25 +272,25 @@ public class Depend extends MatchingTask | |||||
| // now check classpath file dependencies | // now check classpath file dependencies | ||||
| if( classpathDependencies != null ) | if( classpathDependencies != null ) | ||||
| { | { | ||||
| for( Enumeration e = classpathDependencies.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = classpathDependencies.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )e.nextElement(); | |||||
| String className = (String)e.nextElement(); | |||||
| if( !outOfDateClasses.containsKey( className ) ) | if( !outOfDateClasses.containsKey( className ) ) | ||||
| { | { | ||||
| ClassFileInfo info = ( ClassFileInfo )classFileInfoMap.get( className ); | |||||
| ClassFileInfo info = (ClassFileInfo)classFileInfoMap.get( className ); | |||||
| // if we have no info about the class - it may have been deleted already and we | // if we have no info about the class - it may have been deleted already and we | ||||
| // are using cached info. | // are using cached info. | ||||
| if( info != null ) | if( info != null ) | ||||
| { | { | ||||
| Hashtable dependencies = ( Hashtable )classpathDependencies.get( className ); | |||||
| for( Enumeration e2 = dependencies.elements(); e2.hasMoreElements(); ) | |||||
| Hashtable dependencies = (Hashtable)classpathDependencies.get( className ); | |||||
| for( Enumeration e2 = dependencies.elements(); e2.hasMoreElements(); ) | |||||
| { | { | ||||
| File classpathFile = ( File )e2.nextElement(); | |||||
| File classpathFile = (File)e2.nextElement(); | |||||
| if( classpathFile.lastModified() > info.absoluteFile.lastModified() ) | if( classpathFile.lastModified() > info.absoluteFile.lastModified() ) | ||||
| { | { | ||||
| log( "Class " + className + | log( "Class " + className + | ||||
| " is out of date with respect to " + classpathFile, Project.MSG_DEBUG ); | |||||
| " is out of date with respect to " + classpathFile, Project.MSG_DEBUG ); | |||||
| outOfDateClasses.put( className, className ); | outOfDateClasses.put( className, className ); | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -310,7 +309,7 @@ public class Depend extends MatchingTask | |||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -328,14 +327,14 @@ public class Depend extends MatchingTask | |||||
| for( int i = 0; i < files.length; i++ ) | for( int i = 0; i < files.length; i++ ) | ||||
| { | { | ||||
| File srcFile = new File( srcDir, files[i] ); | |||||
| if( files[i].endsWith( ".java" ) ) | |||||
| File srcFile = new File( srcDir, files[ i ] ); | |||||
| if( files[ i ].endsWith( ".java" ) ) | |||||
| { | { | ||||
| String filePath = srcFile.getPath(); | String filePath = srcFile.getPath(); | ||||
| String className = filePath.substring( srcDir.getPath().length() + 1, | String className = filePath.substring( srcDir.getPath().length() + 1, | ||||
| filePath.length() - ".java".length() ); | |||||
| filePath.length() - ".java".length() ); | |||||
| className = ClassFileUtils.convertSlashName( className ); | className = ClassFileUtils.convertSlashName( className ); | ||||
| ClassFileInfo info = ( ClassFileInfo )classFileInfoMap.get( className ); | |||||
| ClassFileInfo info = (ClassFileInfo)classFileInfoMap.get( className ); | |||||
| if( info == null ) | if( info == null ) | ||||
| { | { | ||||
| // there was no class file. add this class to the list | // there was no class file. add this class to the list | ||||
| @@ -352,7 +351,6 @@ public class Depend extends MatchingTask | |||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Get the list of class files we are going to analyse. | * Get the list of class files we are going to analyse. | ||||
| * | * | ||||
| @@ -369,7 +367,7 @@ public class Depend extends MatchingTask | |||||
| for( int i = 0; i < classLocationsList.length; ++i ) | for( int i = 0; i < classLocationsList.length; ++i ) | ||||
| { | { | ||||
| File dir = new File( classLocationsList[i] ); | |||||
| File dir = new File( classLocationsList[ i ] ); | |||||
| if( dir.isDirectory() ) | if( dir.isDirectory() ) | ||||
| { | { | ||||
| addClassFiles( classFileList, dir, dir ); | addClassFiles( classFileList, dir, dir ); | ||||
| @@ -397,7 +395,7 @@ public class Depend extends MatchingTask | |||||
| for( int i = 0; i < length; ++i ) | for( int i = 0; i < length; ++i ) | ||||
| { | { | ||||
| File file = new File( dir, filesInDir[i] ); | |||||
| File file = new File( dir, filesInDir[ i ] ); | |||||
| if( file.isDirectory() ) | if( file.isDirectory() ) | ||||
| { | { | ||||
| addClassFiles( classFileList, file, root ); | addClassFiles( classFileList, file, root ); | ||||
| @@ -407,7 +405,7 @@ public class Depend extends MatchingTask | |||||
| ClassFileInfo info = new ClassFileInfo(); | ClassFileInfo info = new ClassFileInfo(); | ||||
| info.absoluteFile = file; | info.absoluteFile = file; | ||||
| info.relativeName = file.getPath().substring( root.getPath().length() + 1, | info.relativeName = file.getPath().substring( root.getPath().length() + 1, | ||||
| file.getPath().length() - 6 ); | |||||
| file.getPath().length() - 6 ); | |||||
| info.className = ClassFileUtils.convertSlashName( info.relativeName ); | info.className = ClassFileUtils.convertSlashName( info.relativeName ); | ||||
| classFileList.addElement( info ); | classFileList.addElement( info ); | ||||
| } | } | ||||
| @@ -419,17 +417,17 @@ public class Depend extends MatchingTask | |||||
| { | { | ||||
| int count = 0; | int count = 0; | ||||
| Hashtable affectedClasses = ( Hashtable )affectedClassMap.get( className ); | |||||
| Hashtable affectedClasses = (Hashtable)affectedClassMap.get( className ); | |||||
| if( affectedClasses != null ) | if( affectedClasses != null ) | ||||
| { | { | ||||
| for( Enumeration e = affectedClasses.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = affectedClasses.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String affectedClassName = ( String )e.nextElement(); | |||||
| ClassFileInfo affectedClassInfo = ( ClassFileInfo )affectedClasses.get( affectedClassName ); | |||||
| String affectedClassName = (String)e.nextElement(); | |||||
| ClassFileInfo affectedClassInfo = (ClassFileInfo)affectedClasses.get( affectedClassName ); | |||||
| if( affectedClassInfo.absoluteFile.exists() ) | if( affectedClassInfo.absoluteFile.exists() ) | ||||
| { | { | ||||
| log( "Deleting file " + affectedClassInfo.absoluteFile.getPath() + " since " + | log( "Deleting file " + affectedClassInfo.absoluteFile.getPath() + " since " + | ||||
| className + " out of date", Project.MSG_VERBOSE ); | |||||
| className + " out of date", Project.MSG_VERBOSE ); | |||||
| affectedClassInfo.absoluteFile.delete(); | affectedClassInfo.absoluteFile.delete(); | ||||
| count++; | count++; | ||||
| if( closure ) | if( closure ) | ||||
| @@ -445,15 +443,15 @@ public class Depend extends MatchingTask | |||||
| { | { | ||||
| // need to delete the main class | // need to delete the main class | ||||
| String topLevelClassName | String topLevelClassName | ||||
| = affectedClassName.substring( 0, affectedClassName.indexOf( "$" ) ); | |||||
| = affectedClassName.substring( 0, affectedClassName.indexOf( "$" ) ); | |||||
| log( "Top level class = " + topLevelClassName, Project.MSG_VERBOSE ); | log( "Top level class = " + topLevelClassName, Project.MSG_VERBOSE ); | ||||
| ClassFileInfo topLevelClassInfo | ClassFileInfo topLevelClassInfo | ||||
| = ( ClassFileInfo )classFileInfoMap.get( topLevelClassName ); | |||||
| = (ClassFileInfo)classFileInfoMap.get( topLevelClassName ); | |||||
| if( topLevelClassInfo != null && | if( topLevelClassInfo != null && | ||||
| topLevelClassInfo.absoluteFile.exists() ) | topLevelClassInfo.absoluteFile.exists() ) | ||||
| { | { | ||||
| log( "Deleting file " + topLevelClassInfo.absoluteFile.getPath() + " since " + | log( "Deleting file " + topLevelClassInfo.absoluteFile.getPath() + " since " + | ||||
| "one of its inner classes was removed", Project.MSG_VERBOSE ); | |||||
| "one of its inner classes was removed", Project.MSG_VERBOSE ); | |||||
| topLevelClassInfo.absoluteFile.delete(); | topLevelClassInfo.absoluteFile.delete(); | ||||
| count++; | count++; | ||||
| if( closure ) | if( closure ) | ||||
| @@ -472,11 +470,11 @@ public class Depend extends MatchingTask | |||||
| private int deleteAllAffectedFiles() | private int deleteAllAffectedFiles() | ||||
| { | { | ||||
| int count = 0; | int count = 0; | ||||
| for( Enumeration e = outOfDateClasses.elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = outOfDateClasses.elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )e.nextElement(); | |||||
| String className = (String)e.nextElement(); | |||||
| count += deleteAffectedFiles( className ); | count += deleteAffectedFiles( className ); | ||||
| ClassFileInfo classInfo = ( ClassFileInfo )classFileInfoMap.get( className ); | |||||
| ClassFileInfo classInfo = (ClassFileInfo)classFileInfoMap.get( className ); | |||||
| if( classInfo != null && classInfo.absoluteFile.exists() ) | if( classInfo != null && classInfo.absoluteFile.exists() ) | ||||
| { | { | ||||
| classInfo.absoluteFile.delete(); | classInfo.absoluteFile.delete(); | ||||
| @@ -486,7 +484,6 @@ public class Depend extends MatchingTask | |||||
| return count; | return count; | ||||
| } | } | ||||
| /** | /** | ||||
| * Determine the dependencies between classes. Class dependencies are | * Determine the dependencies between classes. Class dependencies are | ||||
| * determined by examining the class references in a class file to other | * determined by examining the class references in a class file to other | ||||
| @@ -495,7 +492,7 @@ public class Depend extends MatchingTask | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| private void determineDependencies() | private void determineDependencies() | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| affectedClassMap = new Hashtable(); | affectedClassMap = new Hashtable(); | ||||
| classFileInfoMap = new Hashtable(); | classFileInfoMap = new Hashtable(); | ||||
| @@ -514,9 +511,9 @@ public class Depend extends MatchingTask | |||||
| depCacheFileExists = depCacheFile.exists(); | depCacheFileExists = depCacheFile.exists(); | ||||
| depCacheFileLastModified = depCacheFile.lastModified(); | depCacheFileLastModified = depCacheFile.lastModified(); | ||||
| } | } | ||||
| for( Enumeration e = getClassFiles( destPath ).elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = getClassFiles( destPath ).elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| ClassFileInfo info = ( ClassFileInfo )e.nextElement(); | |||||
| ClassFileInfo info = (ClassFileInfo)e.nextElement(); | |||||
| log( "Adding class info for " + info.className, Project.MSG_DEBUG ); | log( "Adding class info for " + info.className, Project.MSG_DEBUG ); | ||||
| classFileInfoMap.put( info.className, info ); | classFileInfoMap.put( info.className, info ); | ||||
| @@ -529,7 +526,7 @@ public class Depend extends MatchingTask | |||||
| { | { | ||||
| // depFile exists and is newer than the class file | // depFile exists and is newer than the class file | ||||
| // need to get dependency list from the map. | // need to get dependency list from the map. | ||||
| dependencyList = ( Vector )dependencyMap.get( info.className ); | |||||
| dependencyList = (Vector)dependencyMap.get( info.className ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -562,11 +559,11 @@ public class Depend extends MatchingTask | |||||
| // This class depends on each class in the dependency list. For each | // This class depends on each class in the dependency list. For each | ||||
| // one of those, add this class into their affected classes list | // one of those, add this class into their affected classes list | ||||
| for( Enumeration depEnum = dependencyList.elements(); depEnum.hasMoreElements(); ) | |||||
| for( Enumeration depEnum = dependencyList.elements(); depEnum.hasMoreElements(); ) | |||||
| { | { | ||||
| String dependentClass = ( String )depEnum.nextElement(); | |||||
| String dependentClass = (String)depEnum.nextElement(); | |||||
| Hashtable affectedClasses = ( Hashtable )affectedClassMap.get( dependentClass ); | |||||
| Hashtable affectedClasses = (Hashtable)affectedClassMap.get( dependentClass ); | |||||
| if( affectedClasses == null ) | if( affectedClasses == null ) | ||||
| { | { | ||||
| affectedClasses = new Hashtable(); | affectedClasses = new Hashtable(); | ||||
| @@ -586,15 +583,15 @@ public class Depend extends MatchingTask | |||||
| Hashtable classpathFileCache = new Hashtable(); | Hashtable classpathFileCache = new Hashtable(); | ||||
| Object nullFileMarker = new Object(); | Object nullFileMarker = new Object(); | ||||
| for( Enumeration e = dependencyMap.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = dependencyMap.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )e.nextElement(); | |||||
| Vector dependencyList = ( Vector )dependencyMap.get( className ); | |||||
| String className = (String)e.nextElement(); | |||||
| Vector dependencyList = (Vector)dependencyMap.get( className ); | |||||
| Hashtable dependencies = new Hashtable(); | Hashtable dependencies = new Hashtable(); | ||||
| classpathDependencies.put( className, dependencies ); | classpathDependencies.put( className, dependencies ); | ||||
| for( Enumeration e2 = dependencyList.elements(); e2.hasMoreElements(); ) | |||||
| for( Enumeration e2 = dependencyList.elements(); e2.hasMoreElements(); ) | |||||
| { | { | ||||
| String dependency = ( String )e2.nextElement(); | |||||
| String dependency = (String)e2.nextElement(); | |||||
| Object classpathFileObject = classpathFileCache.get( dependency ); | Object classpathFileObject = classpathFileCache.get( dependency ); | ||||
| if( classpathFileObject == null ) | if( classpathFileObject == null ) | ||||
| { | { | ||||
| @@ -621,8 +618,8 @@ public class Depend extends MatchingTask | |||||
| classpathFileObject = new File( classFilePath ); | classpathFileObject = new File( classFilePath ); | ||||
| } | } | ||||
| log( "Class " + className + | log( "Class " + className + | ||||
| " depends on " + classpathFileObject + | |||||
| " due to " + dependency, Project.MSG_DEBUG ); | |||||
| " depends on " + classpathFileObject + | |||||
| " due to " + dependency, Project.MSG_DEBUG ); | |||||
| } | } | ||||
| } | } | ||||
| classpathFileCache.put( dependency, classpathFileObject ); | classpathFileCache.put( dependency, classpathFileObject ); | ||||
| @@ -630,7 +627,7 @@ public class Depend extends MatchingTask | |||||
| if( classpathFileObject != null && classpathFileObject != nullFileMarker ) | if( classpathFileObject != null && classpathFileObject != nullFileMarker ) | ||||
| { | { | ||||
| // we need to add this jar to the list for this class. | // we need to add this jar to the list for this class. | ||||
| File jarFile = ( File )classpathFileObject; | |||||
| File jarFile = (File)classpathFileObject; | |||||
| dependencies.put( jarFile, jarFile ); | dependencies.put( jarFile, jarFile ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -713,13 +710,13 @@ public class Depend extends MatchingTask | |||||
| File depFile = new File( cache, CACHE_FILE_NAME ); | File depFile = new File( cache, CACHE_FILE_NAME ); | ||||
| pw = new PrintWriter( new FileWriter( depFile ) ); | pw = new PrintWriter( new FileWriter( depFile ) ); | ||||
| for( Enumeration deps = dependencyMap.keys(); deps.hasMoreElements(); ) | |||||
| for( Enumeration deps = dependencyMap.keys(); deps.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )deps.nextElement(); | |||||
| String className = (String)deps.nextElement(); | |||||
| pw.println( CLASSNAME_PREPEND + className ); | pw.println( CLASSNAME_PREPEND + className ); | ||||
| Vector dependencyList = ( Vector )dependencyMap.get( className ); | |||||
| Vector dependencyList = (Vector)dependencyMap.get( className ); | |||||
| int size = dependencyList.size(); | int size = dependencyList.size(); | ||||
| for( int x = 0; x < size; x++ ) | for( int x = 0; x < size; x++ ) | ||||
| { | { | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional.ejb; | package org.apache.tools.ant.taskdefs.optional.ejb; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| @@ -24,14 +25,13 @@ import java.util.zip.ZipEntry; | |||||
| import javax.xml.parsers.SAXParser; | import javax.xml.parsers.SAXParser; | ||||
| import org.apache.bcel.*; | import org.apache.bcel.*; | ||||
| import org.apache.bcel.classfile.*; | import org.apache.bcel.classfile.*; | ||||
| import org.apache.tools.ant.*; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Location; | import org.apache.tools.ant.Location; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.*; | |||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.util.depend.Dependencies; | import org.apache.tools.ant.util.depend.Dependencies; | ||||
| @@ -39,7 +39,6 @@ import org.apache.tools.ant.util.depend.Filter; | |||||
| import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
| import org.xml.sax.SAXException; | import org.xml.sax.SAXException; | ||||
| /** | /** | ||||
| * A deployment tool which creates generic EJB jars. Generic jars contains only | * A deployment tool which creates generic EJB jars. Generic jars contains only | ||||
| * those classes and META-INF entries specified in the EJB 1.1 standard This | * those classes and META-INF entries specified in the EJB 1.1 standard This | ||||
| @@ -133,7 +132,6 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| this.genericJarSuffix = inString; | this.genericJarSuffix = inString; | ||||
| } | } | ||||
| /** | /** | ||||
| * Set the task which owns this tool | * Set the task which owns this tool | ||||
| * | * | ||||
| @@ -178,7 +176,6 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| return ddPrefix; | return ddPrefix; | ||||
| } | } | ||||
| /** | /** | ||||
| * Configure this tool for use in the ejbjar task. | * Configure this tool for use in the ejbjar task. | ||||
| * | * | ||||
| @@ -227,7 +224,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| // First the regular deployment descriptor | // First the regular deployment descriptor | ||||
| ejbFiles.put( META_DIR + EJB_DD, | ejbFiles.put( META_DIR + EJB_DD, | ||||
| new File( config.descriptorDir, descriptorFileName ) ); | |||||
| new File( config.descriptorDir, descriptorFileName ) ); | |||||
| // now the vendor specific files, if any | // now the vendor specific files, if any | ||||
| addVendorFiles( ejbFiles, ddPrefix ); | addVendorFiles( ejbFiles, ddPrefix ); | ||||
| @@ -260,7 +257,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| + " with " | + " with " | ||||
| + String.valueOf( ejbFiles.size() ) | + String.valueOf( ejbFiles.size() ) | ||||
| + " files", | + " files", | ||||
| Project.MSG_INFO ); | |||||
| Project.MSG_INFO ); | |||||
| // Use helper method to write the jarfile | // Use helper method to write the jarfile | ||||
| String publicId = getPublicId(); | String publicId = getPublicId(); | ||||
| @@ -271,26 +268,26 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| { | { | ||||
| // Log that the file is up to date... | // Log that the file is up to date... | ||||
| log( jarFile.toString() + " is up to date.", | log( jarFile.toString() + " is up to date.", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| } | } | ||||
| catch( SAXException se ) | catch( SAXException se ) | ||||
| { | { | ||||
| String msg = "SAXException while parsing '" | String msg = "SAXException while parsing '" | ||||
| + descriptorFileName.toString() | |||||
| + "'. This probably indicates badly-formed XML." | |||||
| + " Details: " | |||||
| + se.getMessage(); | |||||
| + descriptorFileName.toString() | |||||
| + "'. This probably indicates badly-formed XML." | |||||
| + " Details: " | |||||
| + se.getMessage(); | |||||
| throw new BuildException( msg, se ); | throw new BuildException( msg, se ); | ||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "IOException while parsing'" | String msg = "IOException while parsing'" | ||||
| + descriptorFileName.toString() | |||||
| + "'. This probably indicates that the descriptor" | |||||
| + " doesn't exist. Details: " | |||||
| + ioe.getMessage(); | |||||
| + descriptorFileName.toString() | |||||
| + "'. This probably indicates that the descriptor" | |||||
| + " doesn't exist. Details: " | |||||
| + ioe.getMessage(); | |||||
| throw new BuildException( msg, ioe ); | throw new BuildException( msg, ioe ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -306,12 +303,11 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| if( ( destDir == null ) || ( !destDir.isDirectory() ) ) | if( ( destDir == null ) || ( !destDir.isDirectory() ) ) | ||||
| { | { | ||||
| String msg = "A valid destination directory must be specified " | String msg = "A valid destination directory must be specified " | ||||
| + "using the \"destdir\" attribute."; | |||||
| + "using the \"destdir\" attribute."; | |||||
| throw new BuildException( msg ); | throw new BuildException( msg ); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Returns a Classloader object which parses the passed in generic EjbJar | * Returns a Classloader object which parses the passed in generic EjbJar | ||||
| * classpath. The loader is used to dynamically load classes from | * classpath. The loader is used to dynamically load classes from | ||||
| @@ -320,6 +316,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| * @return The ClassLoaderForBuild value | * @return The ClassLoaderForBuild value | ||||
| */ | */ | ||||
| protected ClassLoader getClassLoaderForBuild() | protected ClassLoader getClassLoaderForBuild() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( classpathLoader != null ) | if( classpathLoader != null ) | ||||
| { | { | ||||
| @@ -382,9 +379,9 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| registerKnownDTDs( handler ); | registerKnownDTDs( handler ); | ||||
| // register any DTDs supplied by the user | // register any DTDs supplied by the user | ||||
| for( Iterator i = getConfig().dtdLocations.iterator(); i.hasNext(); ) | |||||
| for( Iterator i = getConfig().dtdLocations.iterator(); i.hasNext(); ) | |||||
| { | { | ||||
| EjbJar.DTDLocation dtdLocation = ( EjbJar.DTDLocation )i.next(); | |||||
| EjbJar.DTDLocation dtdLocation = (EjbJar.DTDLocation)i.next(); | |||||
| handler.registerDTD( dtdLocation.getPublicId(), dtdLocation.getLocation() ); | handler.registerDTD( dtdLocation.getPublicId(), dtdLocation.getLocation() ); | ||||
| } | } | ||||
| return handler; | return handler; | ||||
| @@ -400,7 +397,6 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| return destDir; | return destDir; | ||||
| } | } | ||||
| /** | /** | ||||
| * Using the EJB descriptor file name passed from the <code>ejbjar</code> | * Using the EJB descriptor file name passed from the <code>ejbjar</code> | ||||
| * task, this method returns the "basename" which will be used to name the | * task, this method returns the "basename" which will be used to name the | ||||
| @@ -433,7 +429,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| if( lastSeparatorIndex != -1 ) | if( lastSeparatorIndex != -1 ) | ||||
| { | { | ||||
| endBaseName = descriptorFileName.indexOf( config.baseNameTerminator, | endBaseName = descriptorFileName.indexOf( config.baseNameTerminator, | ||||
| lastSeparatorIndex ); | |||||
| lastSeparatorIndex ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -522,13 +518,13 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| // Create the file input stream, and buffer everything over | // Create the file input stream, and buffer everything over | ||||
| // to the jar output stream | // to the jar output stream | ||||
| byte[] byteBuffer = new byte[2 * 1024]; | |||||
| byte[] byteBuffer = new byte[ 2 * 1024 ]; | |||||
| int count = 0; | int count = 0; | ||||
| do | do | ||||
| { | { | ||||
| jStream.write( byteBuffer, 0, count ); | jStream.write( byteBuffer, 0, count ); | ||||
| count = iStream.read( byteBuffer, 0, byteBuffer.length ); | count = iStream.read( byteBuffer, 0, byteBuffer.length ); | ||||
| }while ( count != -1 ); | |||||
| } while( count != -1 ); | |||||
| //add it to list of files in jar | //add it to list of files in jar | ||||
| addedfiles.add( logicalFilename ); | addedfiles.add( logicalFilename ); | ||||
| @@ -537,8 +533,8 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| log( "WARNING: IOException while adding entry " + | log( "WARNING: IOException while adding entry " + | ||||
| logicalFilename + " to jarfile from " + inputFile.getPath() + " " + | |||||
| ioe.getClass().getName() + "-" + ioe.getMessage(), Project.MSG_WARN ); | |||||
| logicalFilename + " to jarfile from " + inputFile.getPath() + " " + | |||||
| ioe.getClass().getName() + "-" + ioe.getMessage(), Project.MSG_WARN ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -550,7 +546,8 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| iStream.close(); | iStream.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -566,16 +563,16 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| { | { | ||||
| // add in support classes if any | // add in support classes if any | ||||
| Project project = task.getProject(); | Project project = task.getProject(); | ||||
| for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); ) | |||||
| for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); ) | |||||
| { | { | ||||
| FileSet supportFileSet = ( FileSet )i.next(); | |||||
| FileSet supportFileSet = (FileSet)i.next(); | |||||
| File supportBaseDir = supportFileSet.getDir( project ); | File supportBaseDir = supportFileSet.getDir( project ); | ||||
| DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner( project ); | DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner( project ); | ||||
| supportScanner.scan(); | supportScanner.scan(); | ||||
| String[] supportFiles = supportScanner.getIncludedFiles(); | String[] supportFiles = supportScanner.getIncludedFiles(); | ||||
| for( int j = 0; j < supportFiles.length; ++j ) | for( int j = 0; j < supportFiles.length; ++j ) | ||||
| { | { | ||||
| ejbFiles.put( supportFiles[j], new File( supportBaseDir, supportFiles[j] ) ); | |||||
| ejbFiles.put( supportFiles[ j ], new File( supportBaseDir, supportFiles[ j ] ) ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -591,7 +588,6 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| // nothing to add for generic tool. | // nothing to add for generic tool. | ||||
| }// end of writeJar | }// end of writeJar | ||||
| /** | /** | ||||
| * Add all available classes, that depend on Remote, Home, Bean, PK | * Add all available classes, that depend on Remote, Home, Bean, PK | ||||
| * | * | ||||
| @@ -610,7 +606,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| Iterator i = checkEntries.keySet().iterator(); | Iterator i = checkEntries.keySet().iterator(); | ||||
| while( i.hasNext() ) | while( i.hasNext() ) | ||||
| { | { | ||||
| String entryName = ( String )i.next(); | |||||
| String entryName = (String)i.next(); | |||||
| if( entryName.endsWith( ".class" ) ) | if( entryName.endsWith( ".class" ) ) | ||||
| newSet.add( entryName.substring( 0, entryName.length() - ".class".length() ).replace( File.separatorChar, '/' ) ); | newSet.add( entryName.substring( 0, entryName.length() - ".class".length() ).replace( File.separatorChar, '/' ) ); | ||||
| } | } | ||||
| @@ -621,7 +617,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| i = newSet.iterator(); | i = newSet.iterator(); | ||||
| while( i.hasNext() ) | while( i.hasNext() ) | ||||
| { | { | ||||
| String fileName = base + ( ( String )i.next() ).replace( '/', File.separatorChar ) + ".class"; | |||||
| String fileName = base + ( (String)i.next() ).replace( '/', File.separatorChar ) + ".class"; | |||||
| try | try | ||||
| { | { | ||||
| @@ -638,22 +634,22 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| visitor.clearDependencies(); | visitor.clearDependencies(); | ||||
| Dependencies.applyFilter( newSet, | Dependencies.applyFilter( newSet, | ||||
| new Filter() | |||||
| { | |||||
| public boolean accept( Object object ) | |||||
| { | |||||
| String fileName = base + ( ( String )object ).replace( '/', File.separatorChar ) + ".class"; | |||||
| return new File( fileName ).exists(); | |||||
| } | |||||
| } ); | |||||
| new Filter() | |||||
| { | |||||
| public boolean accept( Object object ) | |||||
| { | |||||
| String fileName = base + ( (String)object ).replace( '/', File.separatorChar ) + ".class"; | |||||
| return new File( fileName ).exists(); | |||||
| } | |||||
| } ); | |||||
| newSet.removeAll( set ); | newSet.removeAll( set ); | ||||
| set.addAll( newSet ); | set.addAll( newSet ); | ||||
| }while ( newSet.size() > 0 ); | |||||
| } while( newSet.size() > 0 ); | |||||
| i = set.iterator(); | i = set.iterator(); | ||||
| while( i.hasNext() ) | while( i.hasNext() ) | ||||
| { | { | ||||
| String next = ( ( String )i.next() ).replace( '/', File.separatorChar ); | |||||
| String next = ( (String)i.next() ).replace( '/', File.separatorChar ); | |||||
| checkEntries.put( next + ".class", new File( base + next + ".class" ) ); | checkEntries.put( next + ".class", new File( base + next + ".class" ) ); | ||||
| log( "dependent class: " + next + ".class" + " - " + base + next + ".class", Project.MSG_VERBOSE ); | log( "dependent class: " + next + ".class" + " - " + base + next + ".class", Project.MSG_VERBOSE ); | ||||
| } | } | ||||
| @@ -713,7 +709,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| config.manifest.lastModified() > lastBuild ) | config.manifest.lastModified() > lastBuild ) | ||||
| { | { | ||||
| log( "Build needed because manifest " + config.manifest + " is out of date", | log( "Build needed because manifest " + config.manifest + " is out of date", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -723,11 +719,11 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| // more recently than the destination jar. | // more recently than the destination jar. | ||||
| while( fileIter.hasNext() ) | while( fileIter.hasNext() ) | ||||
| { | { | ||||
| File currentFile = ( File )fileIter.next(); | |||||
| File currentFile = (File)fileIter.next(); | |||||
| if( lastBuild < currentFile.lastModified() ) | if( lastBuild < currentFile.lastModified() ) | ||||
| { | { | ||||
| log( "Build needed because " + currentFile.getPath() + " is out of date", | log( "Build needed because " + currentFile.getPath() + " is out of date", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| @@ -780,7 +776,8 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| descriptorStream.close(); | descriptorStream.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -892,13 +889,13 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| jarStream.setMethod( JarOutputStream.DEFLATED ); | jarStream.setMethod( JarOutputStream.DEFLATED ); | ||||
| // Loop through all the class files found and add them to the jar | // Loop through all the class files found and add them to the jar | ||||
| for( Iterator entryIterator = files.keySet().iterator(); entryIterator.hasNext(); ) | |||||
| for( Iterator entryIterator = files.keySet().iterator(); entryIterator.hasNext(); ) | |||||
| { | { | ||||
| String entryName = ( String )entryIterator.next(); | |||||
| File entryFile = ( File )files.get( entryName ); | |||||
| String entryName = (String)entryIterator.next(); | |||||
| File entryFile = (File)files.get( entryName ); | |||||
| log( "adding file '" + entryName + "'", | log( "adding file '" + entryName + "'", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| addFileToJar( jarStream, entryFile, entryName ); | addFileToJar( jarStream, entryFile, entryName ); | ||||
| @@ -913,17 +910,17 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| int entryIndex = entryName.lastIndexOf( entryFile.getName() ) - 1; | int entryIndex = entryName.lastIndexOf( entryFile.getName() ) - 1; | ||||
| if( entryIndex < 0 ) | if( entryIndex < 0 ) | ||||
| { | { | ||||
| entryName = innerfiles[i]; | |||||
| entryName = innerfiles[ i ]; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| entryName = entryName.substring( 0, entryIndex ) + File.separatorChar + innerfiles[i]; | |||||
| entryName = entryName.substring( 0, entryIndex ) + File.separatorChar + innerfiles[ i ]; | |||||
| } | } | ||||
| // link the file | // link the file | ||||
| entryFile = new File( config.srcDir, entryName ); | entryFile = new File( config.srcDir, entryName ); | ||||
| log( "adding innerclass file '" + entryName + "'", | log( "adding innerclass file '" + entryName + "'", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| addFileToJar( jarStream, entryFile, entryName ); | addFileToJar( jarStream, entryFile, entryName ); | ||||
| @@ -933,9 +930,9 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "IOException while processing ejb-jar file '" | String msg = "IOException while processing ejb-jar file '" | ||||
| + jarfile.toString() | |||||
| + "'. Details: " | |||||
| + ioe.getMessage(); | |||||
| + jarfile.toString() | |||||
| + "'. Details: " | |||||
| + ioe.getMessage(); | |||||
| throw new BuildException( msg, ioe ); | throw new BuildException( msg, ioe ); | ||||
| } | } | ||||
| finally | finally | ||||
| @@ -947,12 +944,12 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| jarStream.close(); | jarStream.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Get the vendor specific name of the Jar that will be output. The | * Get the vendor specific name of the Jar that will be output. The | ||||
| * modification date of this jar will be checked against the dependent bean | * modification date of this jar will be checked against the dependent bean | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional.ejb; | package org.apache.tools.ant.taskdefs.optional.ejb; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| @@ -19,9 +20,10 @@ import java.util.jar.JarFile; | |||||
| import java.util.jar.JarOutputStream; | import java.util.jar.JarOutputStream; | ||||
| import javax.xml.parsers.SAXParser; | import javax.xml.parsers.SAXParser; | ||||
| import javax.xml.parsers.SAXParserFactory; | import javax.xml.parsers.SAXParserFactory; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import org.apache.tools.ant.taskdefs.Java; | import org.apache.tools.ant.taskdefs.Java; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
| @@ -29,27 +31,27 @@ import org.xml.sax.InputSource; | |||||
| public class WeblogicDeploymentTool extends GenericDeploymentTool | public class WeblogicDeploymentTool extends GenericDeploymentTool | ||||
| { | { | ||||
| public final static String PUBLICID_EJB11 | public final static String PUBLICID_EJB11 | ||||
| = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"; | |||||
| = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"; | |||||
| public final static String PUBLICID_EJB20 | public final static String PUBLICID_EJB20 | ||||
| = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"; | |||||
| = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"; | |||||
| public final static String PUBLICID_WEBLOGIC_EJB510 | public final static String PUBLICID_WEBLOGIC_EJB510 | ||||
| = "-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN"; | |||||
| = "-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN"; | |||||
| public final static String PUBLICID_WEBLOGIC_EJB600 | public final static String PUBLICID_WEBLOGIC_EJB600 | ||||
| = "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN"; | |||||
| = "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN"; | |||||
| protected final static String DEFAULT_WL51_EJB11_DTD_LOCATION | protected final static String DEFAULT_WL51_EJB11_DTD_LOCATION | ||||
| = "/weblogic/ejb/deployment/xml/ejb-jar.dtd"; | |||||
| = "/weblogic/ejb/deployment/xml/ejb-jar.dtd"; | |||||
| protected final static String DEFAULT_WL60_EJB11_DTD_LOCATION | protected final static String DEFAULT_WL60_EJB11_DTD_LOCATION | ||||
| = "/weblogic/ejb20/dd/xml/ejb11-jar.dtd"; | |||||
| = "/weblogic/ejb20/dd/xml/ejb11-jar.dtd"; | |||||
| protected final static String DEFAULT_WL60_EJB20_DTD_LOCATION | protected final static String DEFAULT_WL60_EJB20_DTD_LOCATION | ||||
| = "/weblogic/ejb20/dd/xml/ejb20-jar.dtd"; | |||||
| = "/weblogic/ejb20/dd/xml/ejb20-jar.dtd"; | |||||
| protected final static String DEFAULT_WL51_DTD_LOCATION | protected final static String DEFAULT_WL51_DTD_LOCATION | ||||
| = "/weblogic/ejb/deployment/xml/weblogic-ejb-jar.dtd"; | |||||
| = "/weblogic/ejb/deployment/xml/weblogic-ejb-jar.dtd"; | |||||
| protected final static String DEFAULT_WL60_51_DTD_LOCATION | protected final static String DEFAULT_WL60_51_DTD_LOCATION | ||||
| = "/weblogic/ejb20/dd/xml/weblogic510-ejb-jar.dtd"; | |||||
| = "/weblogic/ejb20/dd/xml/weblogic510-ejb-jar.dtd"; | |||||
| protected final static String DEFAULT_WL60_DTD_LOCATION | protected final static String DEFAULT_WL60_DTD_LOCATION | ||||
| = "/weblogic/ejb20/dd/xml/weblogic600-ejb-jar.dtd"; | |||||
| = "/weblogic/ejb20/dd/xml/weblogic600-ejb-jar.dtd"; | |||||
| protected final static String DEFAULT_COMPILER = "default"; | protected final static String DEFAULT_COMPILER = "default"; | ||||
| @@ -235,7 +237,6 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| this.alwaysRebuild = rebuild; | this.alwaysRebuild = rebuild; | ||||
| } | } | ||||
| /** | /** | ||||
| * Setter used to store the suffix for the generated weblogic jar file. | * Setter used to store the suffix for the generated weblogic jar file. | ||||
| * | * | ||||
| @@ -262,7 +263,6 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| this.weblogicDTD = inString; | this.weblogicDTD = inString; | ||||
| } | } | ||||
| /** | /** | ||||
| * Setter used to store the location of the ejb-jar DTD. This can be a file | * Setter used to store the location of the ejb-jar DTD. This can be a file | ||||
| * on the system or a resource on the classpath. | * on the system or a resource on the classpath. | ||||
| @@ -306,10 +306,10 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| /** | /** | ||||
| * Called to validate that the tool parameters have been configured. | * Called to validate that the tool parameters have been configured. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void validateConfigured() | public void validateConfigured() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| super.validateConfigured(); | super.validateConfigured(); | ||||
| } | } | ||||
| @@ -323,7 +323,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| protected ClassLoader getClassLoaderFromJar( File classjar ) | protected ClassLoader getClassLoaderFromJar( File classjar ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| Path lookupPath = new Path( getTask().getProject() ); | Path lookupPath = new Path( getTask().getProject() ); | ||||
| lookupPath.setLocation( classjar ); | lookupPath.setLocation( classjar ); | ||||
| @@ -350,7 +350,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| String fileNameWithMETA = currentText; | String fileNameWithMETA = currentText; | ||||
| //trim the META_INF\ off of the file name | //trim the META_INF\ off of the file name | ||||
| String fileName = fileNameWithMETA.substring( META_DIR.length(), | String fileName = fileNameWithMETA.substring( META_DIR.length(), | ||||
| fileNameWithMETA.length() ); | |||||
| fileNameWithMETA.length() ); | |||||
| File descriptorFile = new File( srcDir, fileName ); | File descriptorFile = new File( srcDir, fileName ); | ||||
| ejbFiles.put( fileNameWithMETA, descriptorFile ); | ejbFiles.put( fileNameWithMETA, descriptorFile ); | ||||
| @@ -364,15 +364,14 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| handler.registerDTD( PUBLICID_WEBLOGIC_EJB510, weblogicDTD ); | handler.registerDTD( PUBLICID_WEBLOGIC_EJB510, weblogicDTD ); | ||||
| handler.registerDTD( PUBLICID_WEBLOGIC_EJB600, weblogicDTD ); | handler.registerDTD( PUBLICID_WEBLOGIC_EJB600, weblogicDTD ); | ||||
| for( Iterator i = getConfig().dtdLocations.iterator(); i.hasNext(); ) | |||||
| for( Iterator i = getConfig().dtdLocations.iterator(); i.hasNext(); ) | |||||
| { | { | ||||
| EjbJar.DTDLocation dtdLocation = ( EjbJar.DTDLocation )i.next(); | |||||
| EjbJar.DTDLocation dtdLocation = (EjbJar.DTDLocation)i.next(); | |||||
| handler.registerDTD( dtdLocation.getPublicId(), dtdLocation.getLocation() ); | handler.registerDTD( dtdLocation.getPublicId(), dtdLocation.getLocation() ); | ||||
| } | } | ||||
| return handler; | return handler; | ||||
| } | } | ||||
| /** | /** | ||||
| * Helper method to check to see if a weblogic EBJ1.1 jar needs to be | * Helper method to check to see if a weblogic EBJ1.1 jar needs to be | ||||
| * rebuilt using ejbc. Called from writeJar it sees if the "Bean" classes | * rebuilt using ejbc. Called from writeJar it sees if the "Bean" classes | ||||
| @@ -398,6 +397,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| * @return The RebuildRequired value | * @return The RebuildRequired value | ||||
| */ | */ | ||||
| protected boolean isRebuildRequired( File genericJarFile, File weblogicJarFile ) | protected boolean isRebuildRequired( File genericJarFile, File weblogicJarFile ) | ||||
| throws TaskException | |||||
| { | { | ||||
| boolean rebuild = false; | boolean rebuild = false; | ||||
| @@ -409,10 +409,10 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| try | try | ||||
| { | { | ||||
| log( "Checking if weblogic Jar needs to be rebuilt for jar " + weblogicJarFile.getName(), | log( "Checking if weblogic Jar needs to be rebuilt for jar " + weblogicJarFile.getName(), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| // Only go forward if the generic and the weblogic file both exist | // Only go forward if the generic and the weblogic file both exist | ||||
| if( genericJarFile.exists() && genericJarFile.isFile() | if( genericJarFile.exists() && genericJarFile.isFile() | ||||
| && weblogicJarFile.exists() && weblogicJarFile.isFile() ) | |||||
| && weblogicJarFile.exists() && weblogicJarFile.isFile() ) | |||||
| { | { | ||||
| //open jar files | //open jar files | ||||
| genericJar = new JarFile( genericJarFile ); | genericJar = new JarFile( genericJarFile ); | ||||
| @@ -423,31 +423,31 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| Hashtable replaceEntries = new Hashtable(); | Hashtable replaceEntries = new Hashtable(); | ||||
| //get the list of generic jar entries | //get the list of generic jar entries | ||||
| for( Enumeration e = genericJar.entries(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = genericJar.entries(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| JarEntry je = ( JarEntry )e.nextElement(); | |||||
| JarEntry je = (JarEntry)e.nextElement(); | |||||
| genericEntries.put( je.getName().replace( '\\', '/' ), je ); | genericEntries.put( je.getName().replace( '\\', '/' ), je ); | ||||
| } | } | ||||
| //get the list of weblogic jar entries | //get the list of weblogic jar entries | ||||
| for( Enumeration e = wlJar.entries(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = wlJar.entries(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| JarEntry je = ( JarEntry )e.nextElement(); | |||||
| JarEntry je = (JarEntry)e.nextElement(); | |||||
| wlEntries.put( je.getName(), je ); | wlEntries.put( je.getName(), je ); | ||||
| } | } | ||||
| //Cycle Through generic and make sure its in weblogic | //Cycle Through generic and make sure its in weblogic | ||||
| ClassLoader genericLoader = getClassLoaderFromJar( genericJarFile ); | ClassLoader genericLoader = getClassLoaderFromJar( genericJarFile ); | ||||
| for( Enumeration e = genericEntries.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = genericEntries.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String filepath = ( String )e.nextElement(); | |||||
| String filepath = (String)e.nextElement(); | |||||
| if( wlEntries.containsKey( filepath ) ) | if( wlEntries.containsKey( filepath ) ) | ||||
| {// File name/path match | {// File name/path match | ||||
| // Check files see if same | // Check files see if same | ||||
| JarEntry genericEntry = ( JarEntry )genericEntries.get( filepath ); | |||||
| JarEntry wlEntry = ( JarEntry )wlEntries.get( filepath ); | |||||
| JarEntry genericEntry = (JarEntry)genericEntries.get( filepath ); | |||||
| JarEntry wlEntry = (JarEntry)wlEntries.get( filepath ); | |||||
| if( ( genericEntry.getCrc() != wlEntry.getCrc() ) || // Crc's Match | if( ( genericEntry.getCrc() != wlEntry.getCrc() ) || // Crc's Match | ||||
| ( genericEntry.getSize() != wlEntry.getSize() ) ) | |||||
| ( genericEntry.getSize() != wlEntry.getSize() ) ) | |||||
| {// Size Match | {// Size Match | ||||
| if( genericEntry.getName().endsWith( ".class" ) ) | if( genericEntry.getName().endsWith( ".class" ) ) | ||||
| @@ -504,12 +504,12 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| newJarStream.setLevel( 0 ); | newJarStream.setLevel( 0 ); | ||||
| //Copy files from old weblogic jar | //Copy files from old weblogic jar | ||||
| for( Enumeration e = wlEntries.elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = wlEntries.elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| byte[] buffer = new byte[1024]; | |||||
| byte[] buffer = new byte[ 1024 ]; | |||||
| int bytesRead; | int bytesRead; | ||||
| InputStream is; | InputStream is; | ||||
| JarEntry je = ( JarEntry )e.nextElement(); | |||||
| JarEntry je = (JarEntry)e.nextElement(); | |||||
| if( je.getCompressedSize() == -1 || | if( je.getCompressedSize() == -1 || | ||||
| je.getCompressedSize() == je.getSize() ) | je.getCompressedSize() == je.getSize() ) | ||||
| { | { | ||||
| @@ -525,7 +525,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| { | { | ||||
| log( "Updating Bean class from generic Jar " + je.getName(), Project.MSG_VERBOSE ); | log( "Updating Bean class from generic Jar " + je.getName(), Project.MSG_VERBOSE ); | ||||
| // Use the entry from the generic jar | // Use the entry from the generic jar | ||||
| je = ( JarEntry )replaceEntries.get( je.getName() ); | |||||
| je = (JarEntry)replaceEntries.get( je.getName() ); | |||||
| is = genericJar.getInputStream( je ); | is = genericJar.getInputStream( je ); | ||||
| } | } | ||||
| else | else | ||||
| @@ -555,16 +555,16 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| catch( ClassNotFoundException cnfe ) | catch( ClassNotFoundException cnfe ) | ||||
| { | { | ||||
| String cnfmsg = "ClassNotFoundException while processing ejb-jar file" | String cnfmsg = "ClassNotFoundException while processing ejb-jar file" | ||||
| + ". Details: " | |||||
| + cnfe.getMessage(); | |||||
| throw new BuildException( cnfmsg, cnfe ); | |||||
| + ". Details: " | |||||
| + cnfe.getMessage(); | |||||
| throw new TaskException( cnfmsg, cnfe ); | |||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "IOException while processing ejb-jar file " | String msg = "IOException while processing ejb-jar file " | ||||
| + ". Details: " | |||||
| + ioe.getMessage(); | |||||
| throw new BuildException( msg, ioe ); | |||||
| + ". Details: " | |||||
| + ioe.getMessage(); | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -576,7 +576,8 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| genericJar.close(); | genericJar.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( wlJar != null ) | if( wlJar != null ) | ||||
| @@ -586,7 +587,8 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| wlJar.close(); | wlJar.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( newJarStream != null ) | if( newJarStream != null ) | ||||
| @@ -596,7 +598,8 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| newJarStream.close(); | newJarStream.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| weblogicJarFile.delete(); | weblogicJarFile.delete(); | ||||
| newWLJarFile.renameTo( weblogicJarFile ); | newWLJarFile.renameTo( weblogicJarFile ); | ||||
| @@ -623,12 +626,12 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| if( weblogicDD.exists() ) | if( weblogicDD.exists() ) | ||||
| { | { | ||||
| ejbFiles.put( META_DIR + WL_DD, | ejbFiles.put( META_DIR + WL_DD, | ||||
| weblogicDD ); | |||||
| weblogicDD ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| log( "Unable to locate weblogic deployment descriptor. It was expected to be in " + | log( "Unable to locate weblogic deployment descriptor. It was expected to be in " + | ||||
| weblogicDD.getPath(), Project.MSG_WARN ); | |||||
| weblogicDD.getPath(), Project.MSG_WARN ); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -636,14 +639,14 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| { | { | ||||
| log( "The old method for locating CMP files has been DEPRECATED.", Project.MSG_VERBOSE ); | log( "The old method for locating CMP files has been DEPRECATED.", Project.MSG_VERBOSE ); | ||||
| log( "Please adjust your weblogic descriptor and set newCMP=\"true\" " + | log( "Please adjust your weblogic descriptor and set newCMP=\"true\" " + | ||||
| "to use the new CMP descriptor inclusion mechanism. ", Project.MSG_VERBOSE ); | |||||
| "to use the new CMP descriptor inclusion mechanism. ", Project.MSG_VERBOSE ); | |||||
| // The the weblogic cmp deployment descriptor | // The the weblogic cmp deployment descriptor | ||||
| File weblogicCMPDD = new File( getConfig().descriptorDir, ddPrefix + WL_CMP_DD ); | File weblogicCMPDD = new File( getConfig().descriptorDir, ddPrefix + WL_CMP_DD ); | ||||
| if( weblogicCMPDD.exists() ) | if( weblogicCMPDD.exists() ) | ||||
| { | { | ||||
| ejbFiles.put( META_DIR + WL_CMP_DD, | ejbFiles.put( META_DIR + WL_CMP_DD, | ||||
| weblogicCMPDD ); | |||||
| weblogicCMPDD ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -654,28 +657,28 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| // mapping tool descriptors. | // mapping tool descriptors. | ||||
| try | try | ||||
| { | { | ||||
| File ejbDescriptor = ( File )ejbFiles.get( META_DIR + EJB_DD ); | |||||
| File ejbDescriptor = (File)ejbFiles.get( META_DIR + EJB_DD ); | |||||
| SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); | SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); | ||||
| saxParserFactory.setValidating( true ); | saxParserFactory.setValidating( true ); | ||||
| SAXParser saxParser = saxParserFactory.newSAXParser(); | SAXParser saxParser = saxParserFactory.newSAXParser(); | ||||
| DescriptorHandler handler = getWeblogicDescriptorHandler( ejbDescriptor.getParentFile() ); | DescriptorHandler handler = getWeblogicDescriptorHandler( ejbDescriptor.getParentFile() ); | ||||
| saxParser.parse( new InputSource | saxParser.parse( new InputSource | ||||
| ( new FileInputStream | ( new FileInputStream | ||||
| ( weblogicDD ) ), | |||||
| handler ); | |||||
| ( weblogicDD ) ), | |||||
| handler ); | |||||
| Hashtable ht = handler.getFiles(); | Hashtable ht = handler.getFiles(); | ||||
| Enumeration e = ht.keys(); | Enumeration e = ht.keys(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| String key = ( String )e.nextElement(); | |||||
| String key = (String)e.nextElement(); | |||||
| ejbFiles.put( key, ht.get( key ) ); | ejbFiles.put( key, ht.get( key ) ); | ||||
| } | } | ||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| String msg = "Exception while adding Vendor specific files: " + e.toString(); | String msg = "Exception while adding Vendor specific files: " + e.toString(); | ||||
| throw new BuildException( msg, e ); | |||||
| throw new TaskException( msg, e ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -698,11 +701,11 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| * @param jarFile Description of Parameter | * @param jarFile Description of Parameter | ||||
| * @param files Description of Parameter | * @param files Description of Parameter | ||||
| * @param publicId Description of Parameter | * @param publicId Description of Parameter | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected void writeJar( String baseName, File jarFile, Hashtable files, | protected void writeJar( String baseName, File jarFile, Hashtable files, | ||||
| String publicId ) | String publicId ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| // need to create a generic jar first. | // need to create a generic jar first. | ||||
| File genericJarFile = super.getVendorOutputJarFile( baseName ); | File genericJarFile = super.getVendorOutputJarFile( baseName ); | ||||
| @@ -715,7 +718,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| if( !keepGeneric ) | if( !keepGeneric ) | ||||
| { | { | ||||
| log( "deleting generic jar " + genericJarFile.toString(), | log( "deleting generic jar " + genericJarFile.toString(), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| genericJarFile.delete(); | genericJarFile.delete(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -751,7 +754,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| getTask().getProject().copyFile( sourceJar, destJar ); | |||||
| FileUtils.newFileUtils().copyFile( sourceJar, destJar ); | |||||
| if( !keepgenerated ) | if( !keepgenerated ) | ||||
| { | { | ||||
| sourceJar.delete(); | sourceJar.delete(); | ||||
| @@ -760,7 +763,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Unable to write EJB jar", e ); | |||||
| throw new TaskException( "Unable to write EJB jar", e ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -768,7 +771,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| try | try | ||||
| { | { | ||||
| javaTask = ( Java )getTask().getProject().createTask( "java" ); | |||||
| javaTask = (Java)getTask().getProject().createTask( "java" ); | |||||
| javaTask.setTaskName( "ejbc" ); | javaTask.setTaskName( "ejbc" ); | ||||
| if( getJvmDebugLevel() != null ) | if( getJvmDebugLevel() != null ) | ||||
| @@ -835,18 +838,18 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| } | } | ||||
| log( "Calling " + ejbcClassName + " for " + sourceJar.toString(), | log( "Calling " + ejbcClassName + " for " + sourceJar.toString(), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| if( javaTask.executeJava() != 0 ) | if( javaTask.executeJava() != 0 ) | ||||
| { | { | ||||
| throw new BuildException( "Ejbc reported an error" ); | |||||
| throw new TaskException( "Ejbc reported an error" ); | |||||
| } | } | ||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| // Have to catch this because of the semantics of calling main() | // Have to catch this because of the semantics of calling main() | ||||
| String msg = "Exception while calling " + ejbcClassName + ". Details: " + e.toString(); | String msg = "Exception while calling " + ejbcClassName + ". Details: " + e.toString(); | ||||
| throw new BuildException( msg, e ); | |||||
| throw new TaskException( msg, e ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,12 +6,13 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| /** | /** | ||||
| * Commandline objects help handling command lines specifying processes to | * Commandline objects help handling command lines specifying processes to | ||||
| * execute. The class can be used to define a command line as nested elements or | * execute. The class can be used to define a command line as nested elements or | ||||
| @@ -44,10 +45,10 @@ public class Commandline implements Cloneable | |||||
| String[] tmp = translateCommandline( to_process ); | String[] tmp = translateCommandline( to_process ); | ||||
| if( tmp != null && tmp.length > 0 ) | if( tmp != null && tmp.length > 0 ) | ||||
| { | { | ||||
| setExecutable( tmp[0] ); | |||||
| setExecutable( tmp[ 0 ] ); | |||||
| for( int i = 1; i < tmp.length; i++ ) | for( int i = 1; i < tmp.length; i++ ) | ||||
| { | { | ||||
| createArgument().setValue( tmp[i] ); | |||||
| createArgument().setValue( tmp[ i ] ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -68,6 +69,7 @@ public class Commandline implements Cloneable | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public static String quoteArgument( String argument ) | public static String quoteArgument( String argument ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( argument.indexOf( "\"" ) > -1 ) | if( argument.indexOf( "\"" ) > -1 ) | ||||
| { | { | ||||
| @@ -104,7 +106,15 @@ public class Commandline implements Cloneable | |||||
| { | { | ||||
| result.append( ' ' ); | result.append( ' ' ); | ||||
| } | } | ||||
| result.append( quoteArgument( line[i] ) ); | |||||
| try | |||||
| { | |||||
| result.append( quoteArgument( line[ i ] ) ); | |||||
| } | |||||
| catch( TaskException e ) | |||||
| { | |||||
| } | |||||
| } | } | ||||
| return result.toString(); | return result.toString(); | ||||
| } | } | ||||
| @@ -113,7 +123,7 @@ public class Commandline implements Cloneable | |||||
| { | { | ||||
| if( to_process == null || to_process.length() == 0 ) | if( to_process == null || to_process.length() == 0 ) | ||||
| { | { | ||||
| return new String[0]; | |||||
| return new String[ 0 ]; | |||||
| } | } | ||||
| // parse with a simple finite state machine | // parse with a simple finite state machine | ||||
| @@ -129,50 +139,50 @@ public class Commandline implements Cloneable | |||||
| while( tok.hasMoreTokens() ) | while( tok.hasMoreTokens() ) | ||||
| { | { | ||||
| String nextTok = tok.nextToken(); | String nextTok = tok.nextToken(); | ||||
| switch ( state ) | |||||
| switch( state ) | |||||
| { | { | ||||
| case inQuote: | |||||
| if( "\'".equals( nextTok ) ) | |||||
| { | |||||
| state = normal; | |||||
| } | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| case inDoubleQuote: | |||||
| if( "\"".equals( nextTok ) ) | |||||
| { | |||||
| state = normal; | |||||
| } | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| default: | |||||
| if( "\'".equals( nextTok ) ) | |||||
| { | |||||
| state = inQuote; | |||||
| } | |||||
| else if( "\"".equals( nextTok ) ) | |||||
| { | |||||
| state = inDoubleQuote; | |||||
| } | |||||
| else if( " ".equals( nextTok ) ) | |||||
| { | |||||
| if( current.length() != 0 ) | |||||
| case inQuote: | |||||
| if( "\'".equals( nextTok ) ) | |||||
| { | { | ||||
| v.addElement( current.toString() ); | |||||
| current.setLength( 0 ); | |||||
| state = normal; | |||||
| } | } | ||||
| } | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| case inDoubleQuote: | |||||
| if( "\"".equals( nextTok ) ) | |||||
| { | |||||
| state = normal; | |||||
| } | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| default: | |||||
| if( "\'".equals( nextTok ) ) | |||||
| { | |||||
| state = inQuote; | |||||
| } | |||||
| else if( "\"".equals( nextTok ) ) | |||||
| { | |||||
| state = inDoubleQuote; | |||||
| } | |||||
| else if( " ".equals( nextTok ) ) | |||||
| { | |||||
| if( current.length() != 0 ) | |||||
| { | |||||
| v.addElement( current.toString() ); | |||||
| current.setLength( 0 ); | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| @@ -186,12 +196,11 @@ public class Commandline implements Cloneable | |||||
| throw new BuildException( "unbalanced quotes in " + to_process ); | throw new BuildException( "unbalanced quotes in " + to_process ); | ||||
| } | } | ||||
| String[] args = new String[v.size()]; | |||||
| String[] args = new String[ v.size() ]; | |||||
| v.copyInto( args ); | v.copyInto( args ); | ||||
| return args; | return args; | ||||
| } | } | ||||
| /** | /** | ||||
| * Sets the executable to run. | * Sets the executable to run. | ||||
| * | * | ||||
| @@ -205,7 +214,6 @@ public class Commandline implements Cloneable | |||||
| .replace( '\\', File.separatorChar ); | .replace( '\\', File.separatorChar ); | ||||
| } | } | ||||
| /** | /** | ||||
| * Returns all arguments defined by <code>addLine</code>, <code>addValue</code> | * Returns all arguments defined by <code>addLine</code>, <code>addValue</code> | ||||
| * or the argument object. | * or the argument object. | ||||
| @@ -217,15 +225,15 @@ public class Commandline implements Cloneable | |||||
| Vector result = new Vector( arguments.size() * 2 ); | Vector result = new Vector( arguments.size() * 2 ); | ||||
| for( int i = 0; i < arguments.size(); i++ ) | for( int i = 0; i < arguments.size(); i++ ) | ||||
| { | { | ||||
| Argument arg = ( Argument )arguments.elementAt( i ); | |||||
| Argument arg = (Argument)arguments.elementAt( i ); | |||||
| String[] s = arg.getParts(); | String[] s = arg.getParts(); | ||||
| for( int j = 0; j < s.length; j++ ) | for( int j = 0; j < s.length; j++ ) | ||||
| { | { | ||||
| result.addElement( s[j] ); | |||||
| result.addElement( s[ j ] ); | |||||
| } | } | ||||
| } | } | ||||
| String[] res = new String[result.size()]; | |||||
| String[] res = new String[ result.size() ]; | |||||
| result.copyInto( res ); | result.copyInto( res ); | ||||
| return res; | return res; | ||||
| } | } | ||||
| @@ -240,24 +248,22 @@ public class Commandline implements Cloneable | |||||
| final String[] args = getArguments(); | final String[] args = getArguments(); | ||||
| if( executable == null ) | if( executable == null ) | ||||
| return args; | return args; | ||||
| final String[] result = new String[args.length + 1]; | |||||
| result[0] = executable; | |||||
| final String[] result = new String[ args.length + 1 ]; | |||||
| result[ 0 ] = executable; | |||||
| System.arraycopy( args, 0, result, 1, args.length ); | System.arraycopy( args, 0, result, 1, args.length ); | ||||
| return result; | return result; | ||||
| } | } | ||||
| public String getExecutable() | public String getExecutable() | ||||
| { | { | ||||
| return executable; | return executable; | ||||
| } | } | ||||
| public void addArguments( String[] line ) | public void addArguments( String[] line ) | ||||
| { | { | ||||
| for( int i = 0; i < line.length; i++ ) | for( int i = 0; i < line.length; i++ ) | ||||
| { | { | ||||
| createArgument().setValue( line[i] ); | |||||
| createArgument().setValue( line[ i ] ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -318,7 +324,6 @@ public class Commandline implements Cloneable | |||||
| return getCommandline().length; | return getCommandline().length; | ||||
| } | } | ||||
| public String toString() | public String toString() | ||||
| { | { | ||||
| return toString( getCommandline() ); | return toString( getCommandline() ); | ||||
| @@ -421,7 +426,7 @@ public class Commandline implements Cloneable | |||||
| realPos = ( executable == null ? 0 : 1 ); | realPos = ( executable == null ? 0 : 1 ); | ||||
| for( int i = 0; i < position; i++ ) | for( int i = 0; i < position; i++ ) | ||||
| { | { | ||||
| Argument arg = ( Argument )arguments.elementAt( i ); | |||||
| Argument arg = (Argument)arguments.elementAt( i ); | |||||
| realPos += arg.getParts().length; | realPos += arg.getParts().length; | ||||
| } | } | ||||
| } | } | ||||
| @@ -82,7 +82,7 @@ public class FileSet extends DataType implements Cloneable | |||||
| } | } | ||||
| public void setDir( File dir ) | public void setDir( File dir ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -113,10 +113,10 @@ public class FileSet extends DataType implements Cloneable | |||||
| * Sets the name of the file containing the includes patterns. | * Sets the name of the file containing the includes patterns. | ||||
| * | * | ||||
| * @param excl The file to fetch the exclude patterns from. | * @param excl The file to fetch the exclude patterns from. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setExcludesfile( File excl ) | public void setExcludesfile( File excl ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -147,10 +147,10 @@ public class FileSet extends DataType implements Cloneable | |||||
| * Sets the name of the file containing the includes patterns. | * Sets the name of the file containing the includes patterns. | ||||
| * | * | ||||
| * @param incl The file to fetch the include patterns from. | * @param incl The file to fetch the include patterns from. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setIncludesfile( File incl ) | public void setIncludesfile( File incl ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -168,7 +168,7 @@ public class FileSet extends DataType implements Cloneable | |||||
| * if you make it a reference.</p> | * if you make it a reference.</p> | ||||
| * | * | ||||
| * @param r The new Refid value | * @param r The new Refid value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setRefid( Reference r ) | public void setRefid( Reference r ) | ||||
| throws TaskException | throws TaskException | ||||
| @@ -6,12 +6,13 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import java.util.Stack; | import java.util.Stack; | ||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.util.FileNameMapper; | import org.apache.tools.ant.util.FileNameMapper; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * Element to define a FileNameMapper. | * Element to define a FileNameMapper. | ||||
| @@ -106,10 +107,10 @@ public class Mapper extends DataType implements Cloneable | |||||
| * You must not set any other attribute if you make it a reference.</p> | * You must not set any other attribute if you make it a reference.</p> | ||||
| * | * | ||||
| * @param r The new Refid value | * @param r The new Refid value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setRefid( Reference r ) | public void setRefid( Reference r ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( type != null || from != null || to != null ) | if( type != null || from != null || to != null ) | ||||
| { | { | ||||
| @@ -150,10 +151,10 @@ public class Mapper extends DataType implements Cloneable | |||||
| * Returns a fully configured FileNameMapper implementation. | * Returns a fully configured FileNameMapper implementation. | ||||
| * | * | ||||
| * @return The Implementation value | * @return The Implementation value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public FileNameMapper getImplementation() | public FileNameMapper getImplementation() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -162,12 +163,12 @@ public class Mapper extends DataType implements Cloneable | |||||
| if( type == null && classname == null ) | if( type == null && classname == null ) | ||||
| { | { | ||||
| throw new BuildException( "one of the attributes type or classname is required" ); | |||||
| throw new TaskException( "one of the attributes type or classname is required" ); | |||||
| } | } | ||||
| if( type != null && classname != null ) | if( type != null && classname != null ) | ||||
| { | { | ||||
| throw new BuildException( "must not specify both type and classname attribute" ); | |||||
| throw new TaskException( "must not specify both type and classname attribute" ); | |||||
| } | } | ||||
| try | try | ||||
| @@ -185,23 +186,23 @@ public class Mapper extends DataType implements Cloneable | |||||
| else | else | ||||
| { | { | ||||
| AntClassLoader al = new AntClassLoader( getProject(), | AntClassLoader al = new AntClassLoader( getProject(), | ||||
| classpath ); | |||||
| classpath ); | |||||
| c = al.loadClass( classname ); | c = al.loadClass( classname ); | ||||
| AntClassLoader.initializeClass( c ); | AntClassLoader.initializeClass( c ); | ||||
| } | } | ||||
| FileNameMapper m = ( FileNameMapper )c.newInstance(); | |||||
| FileNameMapper m = (FileNameMapper)c.newInstance(); | |||||
| m.setFrom( from ); | m.setFrom( from ); | ||||
| m.setTo( to ); | m.setTo( to ); | ||||
| return m; | return m; | ||||
| } | } | ||||
| catch( BuildException be ) | |||||
| catch( TaskException be ) | |||||
| { | { | ||||
| throw be; | throw be; | ||||
| } | } | ||||
| catch( Throwable t ) | catch( Throwable t ) | ||||
| { | { | ||||
| throw new BuildException( "Error", t ); | |||||
| throw new TaskException( "Error", t ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -249,11 +250,11 @@ public class Mapper extends DataType implements Cloneable | |||||
| if( !( o instanceof Mapper ) ) | if( !( o instanceof Mapper ) ) | ||||
| { | { | ||||
| String msg = ref.getRefId() + " doesn\'t denote a mapper"; | String msg = ref.getRefId() + " doesn\'t denote a mapper"; | ||||
| throw new BuildException( msg ); | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| return ( Mapper )o; | |||||
| return (Mapper)o; | |||||
| } | } | ||||
| } | } | ||||
| @@ -270,15 +271,15 @@ public class Mapper extends DataType implements Cloneable | |||||
| { | { | ||||
| implementations = new Properties(); | implementations = new Properties(); | ||||
| implementations.put( "identity", | implementations.put( "identity", | ||||
| "org.apache.tools.ant.util.IdentityMapper" ); | |||||
| "org.apache.tools.ant.util.IdentityMapper" ); | |||||
| implementations.put( "flatten", | implementations.put( "flatten", | ||||
| "org.apache.tools.ant.util.FlatFileNameMapper" ); | |||||
| "org.apache.tools.ant.util.FlatFileNameMapper" ); | |||||
| implementations.put( "glob", | implementations.put( "glob", | ||||
| "org.apache.tools.ant.util.GlobPatternMapper" ); | |||||
| "org.apache.tools.ant.util.GlobPatternMapper" ); | |||||
| implementations.put( "merge", | implementations.put( "merge", | ||||
| "org.apache.tools.ant.util.MergingMapper" ); | |||||
| "org.apache.tools.ant.util.MergingMapper" ); | |||||
| implementations.put( "regexp", | implementations.put( "regexp", | ||||
| "org.apache.tools.ant.util.RegexpPatternMapper" ); | |||||
| "org.apache.tools.ant.util.RegexpPatternMapper" ); | |||||
| } | } | ||||
| public String getImplementation() | public String getImplementation() | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| @@ -14,9 +15,8 @@ import java.util.Enumeration; | |||||
| import java.util.Stack; | import java.util.Stack; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.ProjectHelper; | |||||
| /** | /** | ||||
| * Named collection of include/exclude tags. <p> | * Named collection of include/exclude tags. <p> | ||||
| @@ -50,6 +50,7 @@ public class PatternSet extends DataType | |||||
| * @param excludes the string containing the exclude patterns | * @param excludes the string containing the exclude patterns | ||||
| */ | */ | ||||
| public void setExcludes( String excludes ) | public void setExcludes( String excludes ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -69,10 +70,10 @@ public class PatternSet extends DataType | |||||
| * Sets the name of the file containing the excludes patterns. | * Sets the name of the file containing the excludes patterns. | ||||
| * | * | ||||
| * @param excludesFile The file to fetch the exclude patterns from. | * @param excludesFile The file to fetch the exclude patterns from. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setExcludesfile( File excludesFile ) | public void setExcludesfile( File excludesFile ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -88,6 +89,7 @@ public class PatternSet extends DataType | |||||
| * @param includes the string containing the include patterns | * @param includes the string containing the include patterns | ||||
| */ | */ | ||||
| public void setIncludes( String includes ) | public void setIncludes( String includes ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -107,10 +109,10 @@ public class PatternSet extends DataType | |||||
| * Sets the name of the file containing the includes patterns. | * Sets the name of the file containing the includes patterns. | ||||
| * | * | ||||
| * @param includesFile The file to fetch the include patterns from. | * @param includesFile The file to fetch the include patterns from. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setIncludesfile( File includesFile ) | public void setIncludesfile( File includesFile ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -127,10 +129,10 @@ public class PatternSet extends DataType | |||||
| * if you make it a reference.</p> | * if you make it a reference.</p> | ||||
| * | * | ||||
| * @param r The new Refid value | * @param r The new Refid value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setRefid( Reference r ) | public void setRefid( Reference r ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( !includeList.isEmpty() || !excludeList.isEmpty() ) | if( !includeList.isEmpty() || !excludeList.isEmpty() ) | ||||
| { | { | ||||
| @@ -146,6 +148,7 @@ public class PatternSet extends DataType | |||||
| * @return The ExcludePatterns value | * @return The ExcludePatterns value | ||||
| */ | */ | ||||
| public String[] getExcludePatterns( Project p ) | public String[] getExcludePatterns( Project p ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -165,6 +168,7 @@ public class PatternSet extends DataType | |||||
| * @return The IncludePatterns value | * @return The IncludePatterns value | ||||
| */ | */ | ||||
| public String[] getIncludePatterns( Project p ) | public String[] getIncludePatterns( Project p ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -184,10 +188,11 @@ public class PatternSet extends DataType | |||||
| * @param p Description of Parameter | * @param p Description of Parameter | ||||
| */ | */ | ||||
| public void append( PatternSet other, Project p ) | public void append( PatternSet other, Project p ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| throw new BuildException( "Cannot append to a reference" ); | |||||
| throw new TaskException( "Cannot append to a reference" ); | |||||
| } | } | ||||
| String[] incl = other.getIncludePatterns( p ); | String[] incl = other.getIncludePatterns( p ); | ||||
| @@ -195,7 +200,7 @@ public class PatternSet extends DataType | |||||
| { | { | ||||
| for( int i = 0; i < incl.length; i++ ) | for( int i = 0; i < incl.length; i++ ) | ||||
| { | { | ||||
| createInclude().setName( incl[i] ); | |||||
| createInclude().setName( incl[ i ] ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -204,7 +209,7 @@ public class PatternSet extends DataType | |||||
| { | { | ||||
| for( int i = 0; i < excl.length; i++ ) | for( int i = 0; i < excl.length; i++ ) | ||||
| { | { | ||||
| createExclude().setName( excl[i] ); | |||||
| createExclude().setName( excl[ i ] ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -215,6 +220,7 @@ public class PatternSet extends DataType | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public NameEntry createExclude() | public NameEntry createExclude() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -229,6 +235,7 @@ public class PatternSet extends DataType | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public NameEntry createExcludesFile() | public NameEntry createExcludesFile() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -243,6 +250,7 @@ public class PatternSet extends DataType | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public NameEntry createInclude() | public NameEntry createInclude() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -257,6 +265,7 @@ public class PatternSet extends DataType | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public NameEntry createIncludesFile() | public NameEntry createIncludesFile() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -279,7 +288,7 @@ public class PatternSet extends DataType | |||||
| boolean hasPatterns() | boolean hasPatterns() | ||||
| { | { | ||||
| return includesFileList.size() > 0 || excludesFileList.size() > 0 | return includesFileList.size() > 0 || excludesFileList.size() > 0 | ||||
| || includeList.size() > 0 || excludeList.size() > 0; | |||||
| || includeList.size() > 0 || excludeList.size() > 0; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -290,6 +299,7 @@ public class PatternSet extends DataType | |||||
| * @return The Ref value | * @return The Ref value | ||||
| */ | */ | ||||
| private PatternSet getRef( Project p ) | private PatternSet getRef( Project p ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( !checked ) | if( !checked ) | ||||
| { | { | ||||
| @@ -302,11 +312,11 @@ public class PatternSet extends DataType | |||||
| if( !( o instanceof PatternSet ) ) | if( !( o instanceof PatternSet ) ) | ||||
| { | { | ||||
| String msg = ref.getRefId() + " doesn\'t denote a patternset"; | String msg = ref.getRefId() + " doesn\'t denote a patternset"; | ||||
| throw new BuildException( msg ); | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| return ( PatternSet )o; | |||||
| return (PatternSet)o; | |||||
| } | } | ||||
| } | } | ||||
| @@ -336,9 +346,9 @@ public class PatternSet extends DataType | |||||
| return null; | return null; | ||||
| Vector tmpNames = new Vector(); | Vector tmpNames = new Vector(); | ||||
| for( Enumeration e = list.elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = list.elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| NameEntry ne = ( NameEntry )e.nextElement(); | |||||
| NameEntry ne = (NameEntry)e.nextElement(); | |||||
| String pattern = ne.evalName( p ); | String pattern = ne.evalName( p ); | ||||
| if( pattern != null && pattern.length() > 0 ) | if( pattern != null && pattern.length() > 0 ) | ||||
| { | { | ||||
| @@ -346,7 +356,7 @@ public class PatternSet extends DataType | |||||
| } | } | ||||
| } | } | ||||
| String result[] = new String[tmpNames.size()]; | |||||
| String result[] = new String[ tmpNames.size() ]; | |||||
| tmpNames.copyInto( result ); | tmpNames.copyInto( result ); | ||||
| return result; | return result; | ||||
| } | } | ||||
| @@ -357,21 +367,22 @@ public class PatternSet extends DataType | |||||
| * @param p Description of Parameter | * @param p Description of Parameter | ||||
| */ | */ | ||||
| private void readFiles( Project p ) | private void readFiles( Project p ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( includesFileList.size() > 0 ) | if( includesFileList.size() > 0 ) | ||||
| { | { | ||||
| Enumeration e = includesFileList.elements(); | Enumeration e = includesFileList.elements(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| NameEntry ne = ( NameEntry )e.nextElement(); | |||||
| NameEntry ne = (NameEntry)e.nextElement(); | |||||
| String fileName = ne.evalName( p ); | String fileName = ne.evalName( p ); | ||||
| if( fileName != null ) | if( fileName != null ) | ||||
| { | { | ||||
| File inclFile = resolveFile( fileName ); | File inclFile = resolveFile( fileName ); | ||||
| if( !inclFile.exists() ) | if( !inclFile.exists() ) | ||||
| throw new BuildException( "Includesfile " | |||||
| + inclFile.getAbsolutePath() | |||||
| + " not found." ); | |||||
| throw new TaskException( "Includesfile " | |||||
| + inclFile.getAbsolutePath() | |||||
| + " not found." ); | |||||
| readPatterns( inclFile, includeList, p ); | readPatterns( inclFile, includeList, p ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -383,15 +394,15 @@ public class PatternSet extends DataType | |||||
| Enumeration e = excludesFileList.elements(); | Enumeration e = excludesFileList.elements(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| NameEntry ne = ( NameEntry )e.nextElement(); | |||||
| NameEntry ne = (NameEntry)e.nextElement(); | |||||
| String fileName = ne.evalName( p ); | String fileName = ne.evalName( p ); | ||||
| if( fileName != null ) | if( fileName != null ) | ||||
| { | { | ||||
| File exclFile = resolveFile( fileName ); | File exclFile = resolveFile( fileName ); | ||||
| if( !exclFile.exists() ) | if( !exclFile.exists() ) | ||||
| throw new BuildException( "Excludesfile " | |||||
| + exclFile.getAbsolutePath() | |||||
| + " not found." ); | |||||
| throw new TaskException( "Excludesfile " | |||||
| + exclFile.getAbsolutePath() | |||||
| + " not found." ); | |||||
| readPatterns( exclFile, excludeList, p ); | readPatterns( exclFile, excludeList, p ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -406,10 +417,10 @@ public class PatternSet extends DataType | |||||
| * @param patternfile Description of Parameter | * @param patternfile Description of Parameter | ||||
| * @param patternlist Description of Parameter | * @param patternlist Description of Parameter | ||||
| * @param p Description of Parameter | * @param p Description of Parameter | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void readPatterns( File patternfile, Vector patternlist, Project p ) | private void readPatterns( File patternfile, Vector patternlist, Project p ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| BufferedReader patternReader = null; | BufferedReader patternReader = null; | ||||
| @@ -435,8 +446,8 @@ public class PatternSet extends DataType | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "An error occured while reading from pattern file: " | String msg = "An error occured while reading from pattern file: " | ||||
| + patternfile; | |||||
| throw new BuildException( msg, ioe ); | |||||
| + patternfile; | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -128,6 +128,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener | |||||
| * value of ${build.sysclasspath} | * value of ${build.sysclasspath} | ||||
| */ | */ | ||||
| public AntClassLoader( Project project, Path classpath ) | public AntClassLoader( Project project, Path classpath ) | ||||
| throws TaskException | |||||
| { | { | ||||
| parent = AntClassLoader.class.getClassLoader(); | parent = AntClassLoader.class.getClassLoader(); | ||||
| this.project = project; | this.project = project; | ||||
| @@ -142,7 +143,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener | |||||
| { | { | ||||
| addPathElement( (String)pathElements[ i ] ); | addPathElement( (String)pathElements[ i ] ); | ||||
| } | } | ||||
| catch( BuildException e ) | |||||
| catch( TaskException e ) | |||||
| { | { | ||||
| // ignore path elements which are invalid relative to the project | // ignore path elements which are invalid relative to the project | ||||
| } | } | ||||
| @@ -162,6 +163,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener | |||||
| */ | */ | ||||
| public AntClassLoader( ClassLoader parent, Project project, Path classpath, | public AntClassLoader( ClassLoader parent, Project project, Path classpath, | ||||
| boolean parentFirst ) | boolean parentFirst ) | ||||
| throws TaskException | |||||
| { | { | ||||
| this( project, classpath ); | this( project, classpath ); | ||||
| if( parent != null ) | if( parent != null ) | ||||
| @@ -182,6 +184,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener | |||||
| * be consulted before trying to load the a class through this loader. | * be consulted before trying to load the a class through this loader. | ||||
| */ | */ | ||||
| public AntClassLoader( Project project, Path classpath, boolean parentFirst ) | public AntClassLoader( Project project, Path classpath, boolean parentFirst ) | ||||
| throws TaskException | |||||
| { | { | ||||
| this( null, project, classpath, parentFirst ); | this( null, project, classpath, parentFirst ); | ||||
| } | } | ||||
| @@ -411,10 +414,10 @@ public class AntClassLoader extends ClassLoader implements BuildListener | |||||
| * Add an element to the classpath to be searched | * Add an element to the classpath to be searched | ||||
| * | * | ||||
| * @param pathElement The feature to be added to the PathElement attribute | * @param pathElement The feature to be added to the PathElement attribute | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void addPathElement( String pathElement ) | public void addPathElement( String pathElement ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| File pathComponent | File pathComponent | ||||
| = project != null ? FileUtils.newFileUtils().resolveFile( project.getBaseDir(), pathElement ) | = project != null ? FileUtils.newFileUtils().resolveFile( project.getBaseDir(), pathElement ) | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FilenameFilter; | import java.io.FilenameFilter; | ||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| @@ -13,6 +14,7 @@ import java.net.MalformedURLException; | |||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * This is the Ant command line front end to end. This front end works out where | * This is the Ant command line front end to end. This front end works out where | ||||
| @@ -24,6 +26,7 @@ public class Launcher | |||||
| { | { | ||||
| public static void main( String[] args ) | public static void main( String[] args ) | ||||
| throws TaskException | |||||
| { | { | ||||
| File antHome = null; | File antHome = null; | ||||
| ClassLoader systemClassLoader = Launcher.class.getClassLoader(); | ClassLoader systemClassLoader = Launcher.class.getClassLoader(); | ||||
| @@ -65,7 +68,7 @@ public class Launcher | |||||
| antLoader.initializeClass( mainClass ); | antLoader.initializeClass( mainClass ); | ||||
| final Class[] param = {Class.forName( "[Ljava.lang.String;" ), | final Class[] param = {Class.forName( "[Ljava.lang.String;" ), | ||||
| Properties.class, ClassLoader.class}; | |||||
| Properties.class, ClassLoader.class}; | |||||
| final Method startMethod = mainClass.getMethod( "start", param ); | final Method startMethod = mainClass.getMethod( "start", param ); | ||||
| final Object[] argument = {args, launchProperties, systemClassLoader}; | final Object[] argument = {args, launchProperties, systemClassLoader}; | ||||
| startMethod.invoke( null, argument ); | startMethod.invoke( null, argument ); | ||||
| @@ -78,6 +81,7 @@ public class Launcher | |||||
| } | } | ||||
| private static void addDirJars( AntClassLoader classLoader, File jarDir ) | private static void addDirJars( AntClassLoader classLoader, File jarDir ) | ||||
| throws TaskException | |||||
| { | { | ||||
| String[] fileList = jarDir.list( | String[] fileList = jarDir.list( | ||||
| new FilenameFilter() | new FilenameFilter() | ||||
| @@ -92,7 +96,7 @@ public class Launcher | |||||
| { | { | ||||
| for( int i = 0; i < fileList.length; ++i ) | for( int i = 0; i < fileList.length; ++i ) | ||||
| { | { | ||||
| File jarFile = new File( jarDir, fileList[i] ); | |||||
| File jarFile = new File( jarDir, fileList[ i ] ); | |||||
| classLoader.addPathElement( jarFile.getAbsolutePath() ); | classLoader.addPathElement( jarFile.getAbsolutePath() ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -107,7 +108,7 @@ public class Main | |||||
| for( int i = 0; i < args.length; i++ ) | for( int i = 0; i < args.length; i++ ) | ||||
| { | { | ||||
| String arg = args[i]; | |||||
| String arg = args[ i ]; | |||||
| if( arg.equals( "-help" ) ) | if( arg.equals( "-help" ) ) | ||||
| { | { | ||||
| @@ -137,7 +138,7 @@ public class Main | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| File logFile = new File( args[i + 1] ); | |||||
| File logFile = new File( args[ i + 1 ] ); | |||||
| i++; | i++; | ||||
| out = new PrintStream( new FileOutputStream( logFile ) ); | out = new PrintStream( new FileOutputStream( logFile ) ); | ||||
| err = out; | err = out; | ||||
| @@ -163,7 +164,7 @@ public class Main | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| buildFile = new File( args[i + 1] ); | |||||
| buildFile = new File( args[ i + 1 ] ); | |||||
| i++; | i++; | ||||
| } | } | ||||
| catch( ArrayIndexOutOfBoundsException aioobe ) | catch( ArrayIndexOutOfBoundsException aioobe ) | ||||
| @@ -178,7 +179,7 @@ public class Main | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| listeners.addElement( args[i + 1] ); | |||||
| listeners.addElement( args[ i + 1 ] ); | |||||
| i++; | i++; | ||||
| } | } | ||||
| catch( ArrayIndexOutOfBoundsException aioobe ) | catch( ArrayIndexOutOfBoundsException aioobe ) | ||||
| @@ -212,7 +213,7 @@ public class Main | |||||
| name = name.substring( 0, posEq ); | name = name.substring( 0, posEq ); | ||||
| } | } | ||||
| else if( i < args.length - 1 ) | else if( i < args.length - 1 ) | ||||
| value = args[++i]; | |||||
| value = args[ ++i ]; | |||||
| definedProps.put( name, value ); | definedProps.put( name, value ); | ||||
| } | } | ||||
| @@ -225,12 +226,12 @@ public class Main | |||||
| } | } | ||||
| try | try | ||||
| { | { | ||||
| loggerClassname = args[++i]; | |||||
| loggerClassname = args[ ++i ]; | |||||
| } | } | ||||
| catch( ArrayIndexOutOfBoundsException aioobe ) | catch( ArrayIndexOutOfBoundsException aioobe ) | ||||
| { | { | ||||
| System.out.println( "You must specify a classname when " + | System.out.println( "You must specify a classname when " + | ||||
| "using the -logger argument" ); | |||||
| "using the -logger argument" ); | |||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| @@ -248,7 +249,7 @@ public class Main | |||||
| // eat up next arg if present, default to build.xml | // eat up next arg if present, default to build.xml | ||||
| if( i < args.length - 1 ) | if( i < args.length - 1 ) | ||||
| { | { | ||||
| searchForThis = args[++i]; | |||||
| searchForThis = args[ ++i ]; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -278,7 +279,7 @@ public class Main | |||||
| if( searchForThis != null ) | if( searchForThis != null ) | ||||
| { | { | ||||
| buildFile = findBuildFile( System.getProperty( "user.dir" ), | buildFile = findBuildFile( System.getProperty( "user.dir" ), | ||||
| searchForThis ); | |||||
| searchForThis ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -329,7 +330,7 @@ public class Main | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| throw new TaskException( "Could not load the version information:" | throw new TaskException( "Could not load the version information:" | ||||
| + ioe.getMessage() ); | |||||
| + ioe.getMessage() ); | |||||
| } | } | ||||
| catch( NullPointerException npe ) | catch( NullPointerException npe ) | ||||
| { | { | ||||
| @@ -339,7 +340,6 @@ public class Main | |||||
| return antVersion; | return antVersion; | ||||
| } | } | ||||
| /** | /** | ||||
| * Command line entry point. This method kicks off the building of a project | * Command line entry point. This method kicks off the building of a project | ||||
| * object and executes a build using either a given target or the default | * object and executes a build using either a given target or the default | ||||
| @@ -376,9 +376,9 @@ public class Main | |||||
| if( additionalUserProperties != null ) | if( additionalUserProperties != null ) | ||||
| { | { | ||||
| for( Enumeration e = additionalUserProperties.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = additionalUserProperties.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String key = ( String )e.nextElement(); | |||||
| String key = (String)e.nextElement(); | |||||
| String property = additionalUserProperties.getProperty( key ); | String property = additionalUserProperties.getProperty( key ); | ||||
| m.definedProps.put( key, property ); | m.definedProps.put( key, property ); | ||||
| } | } | ||||
| @@ -417,7 +417,7 @@ public class Main | |||||
| int res = names.size(); | int res = names.size(); | ||||
| for( int i = 0; i < names.size() && res == names.size(); i++ ) | for( int i = 0; i < names.size() && res == names.size(); i++ ) | ||||
| { | { | ||||
| if( name.compareTo( ( String )names.elementAt( i ) ) < 0 ) | |||||
| if( name.compareTo( (String)names.elementAt( i ) ) < 0 ) | |||||
| { | { | ||||
| res = i; | res = i; | ||||
| } | } | ||||
| @@ -474,7 +474,7 @@ public class Main | |||||
| while( ptargets.hasMoreElements() ) | while( ptargets.hasMoreElements() ) | ||||
| { | { | ||||
| currentTarget = ( Target )ptargets.nextElement(); | |||||
| currentTarget = (Target)ptargets.nextElement(); | |||||
| targetName = currentTarget.getName(); | targetName = currentTarget.getName(); | ||||
| targetDescription = currentTarget.getDescription(); | targetDescription = currentTarget.getDescription(); | ||||
| // maintain a sorted list of targets | // maintain a sorted list of targets | ||||
| @@ -535,7 +535,7 @@ public class Main | |||||
| msg.append( names.elementAt( i ) ); | msg.append( names.elementAt( i ) ); | ||||
| if( descriptions != null ) | if( descriptions != null ) | ||||
| { | { | ||||
| msg.append( spaces.substring( 0, maxlen - ( ( String )names.elementAt( i ) ).length() + 2 ) ); | |||||
| msg.append( spaces.substring( 0, maxlen - ( (String)names.elementAt( i ) ).length() + 2 ) ); | |||||
| msg.append( descriptions.elementAt( i ) ); | msg.append( descriptions.elementAt( i ) ); | ||||
| } | } | ||||
| msg.append( lSep ); | msg.append( lSep ); | ||||
| @@ -576,18 +576,18 @@ public class Main | |||||
| } | } | ||||
| protected void addBuildListeners( Project project ) | protected void addBuildListeners( Project project ) | ||||
| throws TaskException | |||||
| { | { | ||||
| // Add the default listener | // Add the default listener | ||||
| project.addBuildListener( createLogger() ); | project.addBuildListener( createLogger() ); | ||||
| for( int i = 0; i < listeners.size(); i++ ) | for( int i = 0; i < listeners.size(); i++ ) | ||||
| { | { | ||||
| String className = ( String )listeners.elementAt( i ); | |||||
| String className = (String)listeners.elementAt( i ); | |||||
| try | try | ||||
| { | { | ||||
| BuildListener listener = | BuildListener listener = | ||||
| ( BuildListener )Class.forName( className ).newInstance(); | |||||
| (BuildListener)Class.forName( className ).newInstance(); | |||||
| project.addBuildListener( listener ); | project.addBuildListener( listener ); | ||||
| } | } | ||||
| catch( Throwable exc ) | catch( Throwable exc ) | ||||
| @@ -631,18 +631,18 @@ public class Main | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| logger = ( BuildLogger )( Class.forName( loggerClassname ).newInstance() ); | |||||
| logger = (BuildLogger)( Class.forName( loggerClassname ).newInstance() ); | |||||
| } | } | ||||
| catch( ClassCastException e ) | catch( ClassCastException e ) | ||||
| { | { | ||||
| System.err.println( "The specified logger class " + loggerClassname + | System.err.println( "The specified logger class " + loggerClassname + | ||||
| " does not implement the BuildLogger interface" ); | |||||
| " does not implement the BuildLogger interface" ); | |||||
| throw new RuntimeException(); | throw new RuntimeException(); | ||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| System.err.println( "Unable to instantiate specified logger class " + | System.err.println( "Unable to instantiate specified logger class " + | ||||
| loggerClassname + " : " + e.getClass().getName() ); | |||||
| loggerClassname + " : " + e.getClass().getName() ); | |||||
| throw new RuntimeException(); | throw new RuntimeException(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -765,8 +765,8 @@ public class Main | |||||
| Enumeration e = definedProps.keys(); | Enumeration e = definedProps.keys(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| String arg = ( String )e.nextElement(); | |||||
| String value = ( String )definedProps.get( arg ); | |||||
| String arg = (String)e.nextElement(); | |||||
| String value = (String)definedProps.get( arg ); | |||||
| project.setUserProperty( arg, value ); | project.setUserProperty( arg, value ); | ||||
| } | } | ||||
| @@ -6,14 +6,15 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| @@ -87,7 +88,7 @@ public abstract class Definer extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| AntClassLoader al = createLoader(); | AntClassLoader al = createLoader(); | ||||
| @@ -98,9 +99,9 @@ public abstract class Definer extends Task | |||||
| if( name == null || value == null ) | if( name == null || value == null ) | ||||
| { | { | ||||
| String msg = "name or classname attributes of " | String msg = "name or classname attributes of " | ||||
| + getTaskName() + " element " | |||||
| + "are undefined"; | |||||
| throw new BuildException( msg ); | |||||
| + getTaskName() + " element " | |||||
| + "are undefined"; | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| addDefinition( al, name, value ); | addDefinition( al, name, value ); | ||||
| @@ -113,14 +114,14 @@ public abstract class Definer extends Task | |||||
| if( name != null || value != null ) | if( name != null || value != null ) | ||||
| { | { | ||||
| String msg = "You must not specify name or value " | String msg = "You must not specify name or value " | ||||
| + "together with file or resource."; | |||||
| throw new BuildException( msg ); | |||||
| + "together with file or resource."; | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| if( file != null && resource != null ) | if( file != null && resource != null ) | ||||
| { | { | ||||
| String msg = "You must not specify both, file and resource."; | String msg = "You must not specify both, file and resource."; | ||||
| throw new BuildException( msg ); | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| Properties props = new Properties(); | Properties props = new Properties(); | ||||
| @@ -128,7 +129,7 @@ public abstract class Definer extends Task | |||||
| if( file != null ) | if( file != null ) | ||||
| { | { | ||||
| log( "Loading definitions from file " + file, | log( "Loading definitions from file " + file, | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| is = new FileInputStream( file ); | is = new FileInputStream( file ); | ||||
| if( is == null ) | if( is == null ) | ||||
| { | { | ||||
| @@ -139,13 +140,13 @@ public abstract class Definer extends Task | |||||
| if( resource != null ) | if( resource != null ) | ||||
| { | { | ||||
| log( "Loading definitions from resource " + resource, | log( "Loading definitions from resource " + resource, | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| is = al.getResourceAsStream( resource ); | is = al.getResourceAsStream( resource ); | ||||
| if( is == null ) | if( is == null ) | ||||
| { | { | ||||
| log( "Could not load definitions from resource " | log( "Could not load definitions from resource " | ||||
| + resource + ". It could not be found.", | + resource + ". It could not be found.", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -155,7 +156,7 @@ public abstract class Definer extends Task | |||||
| Enumeration keys = props.keys(); | Enumeration keys = props.keys(); | ||||
| while( keys.hasMoreElements() ) | while( keys.hasMoreElements() ) | ||||
| { | { | ||||
| String n = ( String )keys.nextElement(); | |||||
| String n = (String)keys.nextElement(); | |||||
| String v = props.getProperty( n ); | String v = props.getProperty( n ); | ||||
| addDefinition( al, n, v ); | addDefinition( al, n, v ); | ||||
| } | } | ||||
| @@ -163,7 +164,7 @@ public abstract class Definer extends Task | |||||
| } | } | ||||
| catch( IOException ex ) | catch( IOException ex ) | ||||
| { | { | ||||
| throw new BuildException( "Error", ex); | |||||
| throw new TaskException( "Error", ex ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -171,7 +172,7 @@ public abstract class Definer extends Task | |||||
| protected abstract void addDefinition( String name, Class c ); | protected abstract void addDefinition( String name, Class c ); | ||||
| private void addDefinition( ClassLoader al, String name, String value ) | private void addDefinition( ClassLoader al, String name, String value ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -183,18 +184,18 @@ public abstract class Definer extends Task | |||||
| { | { | ||||
| String msg = getTaskName() + " class " + value + | String msg = getTaskName() + " class " + value + | ||||
| " cannot be found"; | " cannot be found"; | ||||
| throw new BuildException( msg, cnfe ); | |||||
| throw new TaskException( msg, cnfe ); | |||||
| } | } | ||||
| catch( NoClassDefFoundError ncdfe ) | catch( NoClassDefFoundError ncdfe ) | ||||
| { | { | ||||
| String msg = getTaskName() + " class " + value + | String msg = getTaskName() + " class " + value + | ||||
| " cannot be found"; | " cannot be found"; | ||||
| throw new BuildException( msg, ncdfe ); | |||||
| throw new TaskException( msg, ncdfe ); | |||||
| } | } | ||||
| } | } | ||||
| private AntClassLoader createLoader() | private AntClassLoader createLoader() | ||||
| throws TaskException | |||||
| { | { | ||||
| AntClassLoader al = null; | AntClassLoader al = null; | ||||
| if( classpath != null ) | if( classpath != null ) | ||||
| @@ -16,10 +16,12 @@ import java.lang.reflect.InvocationTargetException; | |||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.myrmidon.framework.Os; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.myrmidon.framework.Os; | |||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| /** | /** | ||||
| @@ -428,7 +430,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public int execute() | public int execute() | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| CommandLauncher launcher = vmLauncher != null ? vmLauncher : shellLauncher; | CommandLauncher launcher = vmLauncher != null ? vmLauncher : shellLauncher; | ||||
| if( !useVMLauncher ) | if( !useVMLauncher ) | ||||
| @@ -547,7 +549,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env ) | public Process exec( Project project, String[] cmd, String[] env ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| if( project != null ) | if( project != null ) | ||||
| { | { | ||||
| @@ -571,7 +573,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| if( workingDir == null ) | if( workingDir == null ) | ||||
| { | { | ||||
| @@ -608,7 +610,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env ) | public Process exec( Project project, String[] cmd, String[] env ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| return _launcher.exec( project, cmd, env ); | return _launcher.exec( project, cmd, env ); | ||||
| } | } | ||||
| @@ -633,7 +635,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env ) | public Process exec( Project project, String[] cmd, String[] env ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| // Need to quote arguments with spaces, and to escape quote characters | // Need to quote arguments with spaces, and to escape quote characters | ||||
| String[] newcmd = new String[ cmd.length ]; | String[] newcmd = new String[ cmd.length ]; | ||||
| @@ -741,7 +743,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| if( workingDir == null ) | if( workingDir == null ) | ||||
| { | { | ||||
| @@ -768,7 +770,6 @@ public class Execute | |||||
| */ | */ | ||||
| private static class PerlScriptCommandLauncher extends CommandLauncherProxy | private static class PerlScriptCommandLauncher extends CommandLauncherProxy | ||||
| { | { | ||||
| private String _script; | private String _script; | ||||
| PerlScriptCommandLauncher( String script, CommandLauncher launcher ) | PerlScriptCommandLauncher( String script, CommandLauncher launcher ) | ||||
| @@ -789,7 +790,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| if( project == null ) | if( project == null ) | ||||
| { | { | ||||
| @@ -806,7 +807,8 @@ public class Execute | |||||
| { | { | ||||
| throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | ||||
| } | } | ||||
| String antRun = resolveFile( antHome + File.separator + _script ).toString(); | |||||
| String antRun = FileUtils.newFileUtils(). | |||||
| resolveFile( project.getBaseDir(), antHome + File.separator + _script ).toString(); | |||||
| // Build the command | // Build the command | ||||
| File commandDir = workingDir; | File commandDir = workingDir; | ||||
| @@ -854,7 +856,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| if( project == null ) | if( project == null ) | ||||
| { | { | ||||
| @@ -871,7 +873,8 @@ public class Execute | |||||
| { | { | ||||
| throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | throw new IOException( "Cannot locate antRun script: Property 'ant.home' not found" ); | ||||
| } | } | ||||
| String antRun = resolveFile( antHome + File.separator + _script ).toString(); | |||||
| String antRun = FileUtils.newFileUtils(). | |||||
| resolveFile( project.getBaseDir(), antHome + File.separator + _script ).toString(); | |||||
| // Build the command | // Build the command | ||||
| File commandDir = workingDir; | File commandDir = workingDir; | ||||
| @@ -914,7 +917,7 @@ public class Execute | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | public Process exec( Project project, String[] cmd, String[] env, File workingDir ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| File commandDir = workingDir; | File commandDir = workingDir; | ||||
| if( workingDir == null ) | if( workingDir == null ) | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -13,6 +14,7 @@ import java.io.InputStream; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| @@ -144,20 +146,20 @@ public class Property extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( name != null ) | if( name != null ) | ||||
| { | { | ||||
| if( value == null && ref == null ) | if( value == null && ref == null ) | ||||
| { | { | ||||
| throw new BuildException( "You must specify value, location or refid with the name attribute" ); | |||||
| throw new TaskException( "You must specify value, location or refid with the name attribute" ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| if( file == null && resource == null && env == null ) | if( file == null && resource == null && env == null ) | ||||
| { | { | ||||
| throw new BuildException( "You must specify file, resource or environment when not using the name attribute" ); | |||||
| throw new TaskException( "You must specify file, resource or environment when not using the name attribute" ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -196,8 +198,8 @@ public class Property extends Task | |||||
| Enumeration e = props.keys(); | Enumeration e = props.keys(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| String name = ( String )e.nextElement(); | |||||
| String value = ( String )props.getProperty( name ); | |||||
| String name = (String)e.nextElement(); | |||||
| String value = (String)props.getProperty( name ); | |||||
| String v = project.replaceProperties( value ); | String v = project.replaceProperties( value ); | ||||
| addProperty( name, v ); | addProperty( name, v ); | ||||
| @@ -230,9 +232,9 @@ public class Property extends Task | |||||
| prefix += "."; | prefix += "."; | ||||
| log( "Loading Environment " + prefix, Project.MSG_VERBOSE ); | log( "Loading Environment " + prefix, Project.MSG_VERBOSE ); | ||||
| Vector osEnv = Execute.getProcEnvironment(); | Vector osEnv = Execute.getProcEnvironment(); | ||||
| for( Enumeration e = osEnv.elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = osEnv.elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String entry = ( String )e.nextElement(); | |||||
| String entry = (String)e.nextElement(); | |||||
| int pos = entry.indexOf( '=' ); | int pos = entry.indexOf( '=' ); | ||||
| if( pos == -1 ) | if( pos == -1 ) | ||||
| { | { | ||||
| @@ -241,14 +243,14 @@ public class Property extends Task | |||||
| else | else | ||||
| { | { | ||||
| props.put( prefix + entry.substring( 0, pos ), | props.put( prefix + entry.substring( 0, pos ), | ||||
| entry.substring( pos + 1 ) ); | |||||
| entry.substring( pos + 1 ) ); | |||||
| } | } | ||||
| } | } | ||||
| addProperties( props ); | addProperties( props ); | ||||
| } | } | ||||
| protected void loadFile( File file ) | protected void loadFile( File file ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| Properties props = new Properties(); | Properties props = new Properties(); | ||||
| log( "Loading " + file.getAbsolutePath(), Project.MSG_VERBOSE ); | log( "Loading " + file.getAbsolutePath(), Project.MSG_VERBOSE ); | ||||
| @@ -273,16 +275,17 @@ public class Property extends Task | |||||
| else | else | ||||
| { | { | ||||
| log( "Unable to find property file: " + file.getAbsolutePath(), | log( "Unable to find property file: " + file.getAbsolutePath(), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| } | } | ||||
| catch( IOException ex ) | catch( IOException ex ) | ||||
| { | { | ||||
| throw new BuildException( "Error", ex ); | |||||
| throw new TaskException( "Error", ex ); | |||||
| } | } | ||||
| } | } | ||||
| protected void loadResource( String name ) | protected void loadResource( String name ) | ||||
| throws TaskException | |||||
| { | { | ||||
| Properties props = new Properties(); | Properties props = new Properties(); | ||||
| log( "Resource Loading " + name, Project.MSG_VERBOSE ); | log( "Resource Loading " + name, Project.MSG_VERBOSE ); | ||||
| @@ -321,16 +324,16 @@ public class Property extends Task | |||||
| } | } | ||||
| catch( IOException ex ) | catch( IOException ex ) | ||||
| { | { | ||||
| throw new BuildException( "Error", ex ); | |||||
| throw new TaskException( "Error", ex ); | |||||
| } | } | ||||
| } | } | ||||
| private void resolveAllProperties( Properties props ) | private void resolveAllProperties( Properties props ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| for( Enumeration e = props.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = props.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String name = ( String )e.nextElement(); | |||||
| String name = (String)e.nextElement(); | |||||
| String value = props.getProperty( name ); | String value = props.getProperty( name ); | ||||
| boolean resolved = false; | boolean resolved = false; | ||||
| @@ -348,13 +351,13 @@ public class Property extends Task | |||||
| Enumeration j = propertyRefs.elements(); | Enumeration j = propertyRefs.elements(); | ||||
| while( i.hasMoreElements() ) | while( i.hasMoreElements() ) | ||||
| { | { | ||||
| String fragment = ( String )i.nextElement(); | |||||
| String fragment = (String)i.nextElement(); | |||||
| if( fragment == null ) | if( fragment == null ) | ||||
| { | { | ||||
| String propertyName = ( String )j.nextElement(); | |||||
| String propertyName = (String)j.nextElement(); | |||||
| if( propertyName.equals( name ) ) | if( propertyName.equals( name ) ) | ||||
| { | { | ||||
| throw new BuildException( "Property " + name + " was circularly defined." ); | |||||
| throw new TaskException( "Property " + name + " was circularly defined." ); | |||||
| } | } | ||||
| fragment = getProject().getProperty( propertyName ); | fragment = getProject().getProperty( propertyName ); | ||||
| if( fragment == null ) | if( fragment == null ) | ||||
| @@ -6,12 +6,13 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.rmi.Remote; | import java.rmi.Remote; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.rmic.RmicAdapter; | import org.apache.tools.ant.taskdefs.rmic.RmicAdapter; | ||||
| @@ -19,8 +20,8 @@ import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory; | |||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
| import org.apache.tools.ant.util.FileNameMapper; | import org.apache.tools.ant.util.FileNameMapper; | ||||
| import org.apache.tools.ant.util.SourceFileScanner; | |||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.tools.ant.util.SourceFileScanner; | |||||
| /** | /** | ||||
| * Task to compile RMI stubs and skeletons. This task can take the following | * Task to compile RMI stubs and skeletons. This task can take the following | ||||
| @@ -60,7 +61,7 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| private final static String FAIL_MSG | private final static String FAIL_MSG | ||||
| = "Rmic failed, messages should have been provided."; | |||||
| = "Rmic failed, messages should have been provided."; | |||||
| private boolean verify = false; | private boolean verify = false; | ||||
| private boolean filtering = false; | private boolean filtering = false; | ||||
| @@ -413,9 +414,9 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| for( int i = 0; i < interfaces.length; i++ ) | for( int i = 0; i < interfaces.length; i++ ) | ||||
| { | { | ||||
| if( Remote.class.isAssignableFrom( interfaces[i] ) ) | |||||
| if( Remote.class.isAssignableFrom( interfaces[ i ] ) ) | |||||
| { | { | ||||
| return interfaces[i]; | |||||
| return interfaces[ i ]; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -469,18 +470,18 @@ public class Rmic extends MatchingTask | |||||
| catch( ClassNotFoundException e ) | catch( ClassNotFoundException e ) | ||||
| { | { | ||||
| log( "Unable to verify class " + classname + | log( "Unable to verify class " + classname + | ||||
| ". It could not be found.", Project.MSG_WARN ); | |||||
| ". It could not be found.", Project.MSG_WARN ); | |||||
| } | } | ||||
| catch( NoClassDefFoundError e ) | catch( NoClassDefFoundError e ) | ||||
| { | { | ||||
| log( "Unable to verify class " + classname + | log( "Unable to verify class " + classname + | ||||
| ". It is not defined.", Project.MSG_WARN ); | |||||
| ". It is not defined.", Project.MSG_WARN ); | |||||
| } | } | ||||
| catch( Throwable t ) | catch( Throwable t ) | ||||
| { | { | ||||
| log( "Unable to verify class " + classname + | log( "Unable to verify class " + classname + | ||||
| ". Loading caused Exception: " + | |||||
| t.getMessage(), Project.MSG_WARN ); | |||||
| ". Loading caused Exception: " + | |||||
| t.getMessage(), Project.MSG_WARN ); | |||||
| } | } | ||||
| // we only get here if an exception has been thrown | // we only get here if an exception has been thrown | ||||
| return false; | return false; | ||||
| @@ -515,15 +516,15 @@ public class Rmic extends MatchingTask | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( baseDir == null ) | if( baseDir == null ) | ||||
| { | { | ||||
| throw new BuildException( "base attribute must be set!" ); | |||||
| throw new TaskException( "base attribute must be set!" ); | |||||
| } | } | ||||
| if( !baseDir.exists() ) | if( !baseDir.exists() ) | ||||
| { | { | ||||
| throw new BuildException( "base does not exist!" ); | |||||
| throw new TaskException( "base does not exist!" ); | |||||
| } | } | ||||
| if( verify ) | if( verify ) | ||||
| @@ -552,21 +553,21 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| // otherwise perform a timestamp comparison - at least | // otherwise perform a timestamp comparison - at least | ||||
| scanDir( baseDir, | scanDir( baseDir, | ||||
| new String[]{classname.replace( '.', File.separatorChar ) + ".class"}, | |||||
| adapter.getMapper() ); | |||||
| new String[]{classname.replace( '.', File.separatorChar ) + ".class"}, | |||||
| adapter.getMapper() ); | |||||
| } | } | ||||
| int fileCount = compileList.size(); | int fileCount = compileList.size(); | ||||
| if( fileCount > 0 ) | if( fileCount > 0 ) | ||||
| { | { | ||||
| log( "RMI Compiling " + fileCount + | log( "RMI Compiling " + fileCount + | ||||
| " class" + ( fileCount > 1 ? "es" : "" ) + " to " + baseDir, | |||||
| Project.MSG_INFO ); | |||||
| " class" + ( fileCount > 1 ? "es" : "" ) + " to " + baseDir, | |||||
| Project.MSG_INFO ); | |||||
| // finally, lets execute the compiler!! | // finally, lets execute the compiler!! | ||||
| if( !adapter.execute() ) | if( !adapter.execute() ) | ||||
| { | { | ||||
| throw new BuildException( FAIL_MSG ); | |||||
| throw new TaskException( FAIL_MSG ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -580,7 +581,7 @@ public class Rmic extends MatchingTask | |||||
| if( idl ) | if( idl ) | ||||
| { | { | ||||
| log( "Cannot determine sourcefiles in idl mode, ", | log( "Cannot determine sourcefiles in idl mode, ", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| log( "sourcebase attribute will be ignored.", Project.MSG_WARN ); | log( "sourcebase attribute will be ignored.", Project.MSG_WARN ); | ||||
| } | } | ||||
| else | else | ||||
| @@ -588,8 +589,8 @@ public class Rmic extends MatchingTask | |||||
| for( int j = 0; j < fileCount; j++ ) | for( int j = 0; j < fileCount; j++ ) | ||||
| { | { | ||||
| moveGeneratedFile( baseDir, sourceBase, | moveGeneratedFile( baseDir, sourceBase, | ||||
| ( String )compileList.elementAt( j ), | |||||
| adapter ); | |||||
| (String)compileList.elementAt( j ), | |||||
| adapter ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -612,13 +613,13 @@ public class Rmic extends MatchingTask | |||||
| if( idl ) | if( idl ) | ||||
| { | { | ||||
| log( "will leave uptodate test to rmic implementation in idl mode.", | log( "will leave uptodate test to rmic implementation in idl mode.", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| else if( iiop | else if( iiop | ||||
| && iiopopts != null && iiopopts.indexOf( "-always" ) > -1 ) | |||||
| && iiopopts != null && iiopopts.indexOf( "-always" ) > -1 ) | |||||
| { | { | ||||
| log( "no uptodate test as -always option has been specified", | log( "no uptodate test as -always option has been specified", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -628,7 +629,7 @@ public class Rmic extends MatchingTask | |||||
| for( int i = 0; i < newFiles.length; i++ ) | for( int i = 0; i < newFiles.length; i++ ) | ||||
| { | { | ||||
| String classname = newFiles[i].replace( File.separatorChar, '.' ); | |||||
| String classname = newFiles[ i ].replace( File.separatorChar, '.' ); | |||||
| classname = classname.substring( 0, classname.lastIndexOf( ".class" ) ); | classname = classname.substring( 0, classname.lastIndexOf( ".class" ) ); | ||||
| compileList.addElement( classname ); | compileList.addElement( classname ); | ||||
| } | } | ||||
| @@ -652,12 +653,12 @@ public class Rmic extends MatchingTask | |||||
| * @param sourceBaseFile Description of Parameter | * @param sourceBaseFile Description of Parameter | ||||
| * @param classname Description of Parameter | * @param classname Description of Parameter | ||||
| * @param adapter Description of Parameter | * @param adapter Description of Parameter | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void moveGeneratedFile( File baseDir, File sourceBaseFile, | private void moveGeneratedFile( File baseDir, File sourceBaseFile, | ||||
| String classname, | String classname, | ||||
| RmicAdapter adapter ) | RmicAdapter adapter ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| String classFileName = | String classFileName = | ||||
| @@ -680,7 +681,8 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| String msg = "Failed to copy " + oldFile + " to " + | String msg = "Failed to copy " + oldFile + " to " + | ||||
| newFile + " due to " + ioe.getMessage(); | newFile + " due to " + ioe.getMessage(); | ||||
| throw new BuildException( msg, ioe ); | |||||
| newFile + " due to " + ioe.getMessage(); | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| @@ -30,15 +31,14 @@ import java.util.Properties; | |||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.ProjectHelper; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.EnumeratedAttribute; | import org.apache.tools.ant.types.EnumeratedAttribute; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * Reads in a text file containing SQL statements seperated with semicolons and | * Reads in a text file containing SQL statements seperated with semicolons and | ||||
| @@ -258,7 +258,6 @@ public class SQLExec extends Task | |||||
| this.output = output; | this.output = output; | ||||
| } | } | ||||
| /** | /** | ||||
| * Set the password for the DB connection. | * Set the password for the DB connection. | ||||
| * | * | ||||
| @@ -373,7 +372,6 @@ public class SQLExec extends Task | |||||
| return this.classpath.createPath(); | return this.classpath.createPath(); | ||||
| } | } | ||||
| /** | /** | ||||
| * Set the sql command to execute | * Set the sql command to execute | ||||
| * | * | ||||
| @@ -389,10 +387,10 @@ public class SQLExec extends Task | |||||
| /** | /** | ||||
| * Load the sql file and then execute it | * Load the sql file and then execute it | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| sqlCommand = sqlCommand.trim(); | sqlCommand = sqlCommand.trim(); | ||||
| @@ -400,7 +398,7 @@ public class SQLExec extends Task | |||||
| { | { | ||||
| if( transactions.size() == 0 ) | if( transactions.size() == 0 ) | ||||
| { | { | ||||
| throw new BuildException( "Source file or fileset, transactions or sql statement must be set!" ); | |||||
| throw new TaskException( "Source file or fileset, transactions or sql statement must be set!" ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -408,7 +406,7 @@ public class SQLExec extends Task | |||||
| // deal with the filesets | // deal with the filesets | ||||
| for( int i = 0; i < filesets.size(); i++ ) | for( int i = 0; i < filesets.size(); i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )filesets.elementAt( i ); | |||||
| FileSet fs = (FileSet)filesets.elementAt( i ); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| File srcDir = fs.getDir( project ); | File srcDir = fs.getDir( project ); | ||||
| @@ -418,7 +416,7 @@ public class SQLExec extends Task | |||||
| for( int j = 0; j < srcFiles.length; j++ ) | for( int j = 0; j < srcFiles.length; j++ ) | ||||
| { | { | ||||
| Transaction t = createTransaction(); | Transaction t = createTransaction(); | ||||
| t.setSrc( new File( srcDir, srcFiles[j] ) ); | |||||
| t.setSrc( new File( srcDir, srcFiles[ j ] ) ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -430,23 +428,23 @@ public class SQLExec extends Task | |||||
| if( driver == null ) | if( driver == null ) | ||||
| { | { | ||||
| throw new BuildException( "Driver attribute must be set!" ); | |||||
| throw new TaskException( "Driver attribute must be set!" ); | |||||
| } | } | ||||
| if( userId == null ) | if( userId == null ) | ||||
| { | { | ||||
| throw new BuildException( "User Id attribute must be set!" ); | |||||
| throw new TaskException( "User Id attribute must be set!" ); | |||||
| } | } | ||||
| if( password == null ) | if( password == null ) | ||||
| { | { | ||||
| throw new BuildException( "Password attribute must be set!" ); | |||||
| throw new TaskException( "Password attribute must be set!" ); | |||||
| } | } | ||||
| if( url == null ) | if( url == null ) | ||||
| { | { | ||||
| throw new BuildException( "Url attribute must be set!" ); | |||||
| throw new TaskException( "Url attribute must be set!" ); | |||||
| } | } | ||||
| if( srcFile != null && !srcFile.exists() ) | if( srcFile != null && !srcFile.exists() ) | ||||
| { | { | ||||
| throw new BuildException( "Source file does not exist!" ); | |||||
| throw new TaskException( "Source file does not exist!" ); | |||||
| } | } | ||||
| Driver driverInstance = null; | Driver driverInstance = null; | ||||
| // Load the driver using the | // Load the driver using the | ||||
| @@ -456,7 +454,7 @@ public class SQLExec extends Task | |||||
| if( classpath != null ) | if( classpath != null ) | ||||
| { | { | ||||
| log( "Loading " + driver + " using AntClassLoader with classpath " + classpath, | log( "Loading " + driver + " using AntClassLoader with classpath " + classpath, | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| loader = new AntClassLoader( project, classpath ); | loader = new AntClassLoader( project, classpath ); | ||||
| dc = loader.loadClass( driver ); | dc = loader.loadClass( driver ); | ||||
| @@ -466,19 +464,19 @@ public class SQLExec extends Task | |||||
| log( "Loading " + driver + " using system loader.", Project.MSG_VERBOSE ); | log( "Loading " + driver + " using system loader.", Project.MSG_VERBOSE ); | ||||
| dc = Class.forName( driver ); | dc = Class.forName( driver ); | ||||
| } | } | ||||
| driverInstance = ( Driver )dc.newInstance(); | |||||
| driverInstance = (Driver)dc.newInstance(); | |||||
| } | } | ||||
| catch( ClassNotFoundException e ) | catch( ClassNotFoundException e ) | ||||
| { | { | ||||
| throw new BuildException( "Class Not Found: JDBC driver " + driver + " could not be loaded" ); | |||||
| throw new TaskException( "Class Not Found: JDBC driver " + driver + " could not be loaded" ); | |||||
| } | } | ||||
| catch( IllegalAccessException e ) | catch( IllegalAccessException e ) | ||||
| { | { | ||||
| throw new BuildException( "Illegal Access: JDBC driver " + driver + " could not be loaded" ); | |||||
| throw new TaskException( "Illegal Access: JDBC driver " + driver + " could not be loaded" ); | |||||
| } | } | ||||
| catch( InstantiationException e ) | catch( InstantiationException e ) | ||||
| { | { | ||||
| throw new BuildException( "Instantiation Exception: JDBC driver " + driver + " could not be loaded" ); | |||||
| throw new TaskException( "Instantiation Exception: JDBC driver " + driver + " could not be loaded" ); | |||||
| } | } | ||||
| try | try | ||||
| @@ -513,10 +511,10 @@ public class SQLExec extends Task | |||||
| // Process all transactions | // Process all transactions | ||||
| for( Enumeration e = transactions.elements(); | for( Enumeration e = transactions.elements(); | ||||
| e.hasMoreElements(); ) | |||||
| e.hasMoreElements(); ) | |||||
| { | { | ||||
| ( ( Transaction )e.nextElement() ).runTransaction( out ); | |||||
| ( (Transaction)e.nextElement() ).runTransaction( out ); | |||||
| if( !autocommit ) | if( !autocommit ) | ||||
| { | { | ||||
| log( "Commiting transaction", Project.MSG_VERBOSE ); | log( "Commiting transaction", Project.MSG_VERBOSE ); | ||||
| @@ -541,9 +539,10 @@ public class SQLExec extends Task | |||||
| conn.rollback(); | conn.rollback(); | ||||
| } | } | ||||
| catch( SQLException ex ) | catch( SQLException ex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| catch( SQLException e ) | catch( SQLException e ) | ||||
| { | { | ||||
| @@ -554,9 +553,10 @@ public class SQLExec extends Task | |||||
| conn.rollback(); | conn.rollback(); | ||||
| } | } | ||||
| catch( SQLException ex ) | catch( SQLException ex ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -572,11 +572,12 @@ public class SQLExec extends Task | |||||
| } | } | ||||
| } | } | ||||
| catch( SQLException e ) | catch( SQLException e ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| log( goodSql + " of " + totalSql + | log( goodSql + " of " + totalSql + | ||||
| " SQL statements executed successfully" ); | |||||
| " SQL statements executed successfully" ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -650,7 +651,7 @@ public class SQLExec extends Task | |||||
| if( !statement.execute( sql ) ) | if( !statement.execute( sql ) ) | ||||
| { | { | ||||
| log( statement.getUpdateCount() + " rows affected", | log( statement.getUpdateCount() + " rows affected", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -733,7 +734,7 @@ public class SQLExec extends Task | |||||
| line.setLength( 0 ); | line.setLength( 0 ); | ||||
| } | } | ||||
| } | } | ||||
| }while ( statement.getMoreResults() ); | |||||
| } while( statement.getMoreResults() ); | |||||
| out.println(); | out.println(); | ||||
| } | } | ||||
| @@ -855,9 +856,9 @@ public class SQLExec extends Task | |||||
| if( tSrcFile != null ) | if( tSrcFile != null ) | ||||
| { | { | ||||
| log( "Executing file: " + tSrcFile.getAbsolutePath(), | log( "Executing file: " + tSrcFile.getAbsolutePath(), | ||||
| Project.MSG_INFO ); | |||||
| Project.MSG_INFO ); | |||||
| Reader reader = ( encoding == null ) ? new FileReader( tSrcFile ) | Reader reader = ( encoding == null ) ? new FileReader( tSrcFile ) | ||||
| : new InputStreamReader( new FileInputStream( tSrcFile ), encoding ); | |||||
| : new InputStreamReader( new FileInputStream( tSrcFile ), encoding ); | |||||
| runStatements( reader, out ); | runStatements( reader, out ); | ||||
| reader.close(); | reader.close(); | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| @@ -17,8 +18,8 @@ import java.net.URL; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| @@ -73,7 +74,7 @@ public class XMLValidateTask extends Task | |||||
| */ | */ | ||||
| protected XMLReader xmlReader = null;// XMLReader used to validation process | protected XMLReader xmlReader = null;// XMLReader used to validation process | ||||
| protected ValidatorErrorHandler errorHandler | protected ValidatorErrorHandler errorHandler | ||||
| = new ValidatorErrorHandler();// to report sax parsing errors | |||||
| = new ValidatorErrorHandler();// to report sax parsing errors | |||||
| protected Hashtable features = new Hashtable(); | protected Hashtable features = new Hashtable(); | ||||
| /** | /** | ||||
| @@ -102,7 +103,6 @@ public class XMLValidateTask extends Task | |||||
| readerClassName = className; | readerClassName = className; | ||||
| } | } | ||||
| /** | /** | ||||
| * Specify the classpath to be searched to load the parser (optional) | * Specify the classpath to be searched to load the parser (optional) | ||||
| * | * | ||||
| @@ -133,7 +133,7 @@ public class XMLValidateTask extends Task | |||||
| /** | /** | ||||
| * Specify how parser error are to be handled. <p> | * Specify how parser error are to be handled. <p> | ||||
| * | * | ||||
| * If set to <code>true</code> (default), throw a buildException if the | |||||
| * If set to <code>true</code> (default), throw a TaskException if the | |||||
| * parser yields an error. | * parser yields an error. | ||||
| * | * | ||||
| * @param fail The new FailOnError value | * @param fail The new FailOnError value | ||||
| @@ -226,13 +226,13 @@ public class XMLValidateTask extends Task | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| int fileProcessed = 0; | int fileProcessed = 0; | ||||
| if( file == null && ( filesets.size() == 0 ) ) | if( file == null && ( filesets.size() == 0 ) ) | ||||
| { | { | ||||
| throw new BuildException( "Specify at least one source - a file or a fileset." ); | |||||
| throw new TaskException( "Specify at least one source - a file or a fileset." ); | |||||
| } | } | ||||
| initValidator(); | initValidator(); | ||||
| @@ -248,7 +248,7 @@ public class XMLValidateTask extends Task | |||||
| { | { | ||||
| String errorMsg = "File " + file + " cannot be read"; | String errorMsg = "File " + file + " cannot be read"; | ||||
| if( failOnError ) | if( failOnError ) | ||||
| throw new BuildException( errorMsg ); | |||||
| throw new TaskException( errorMsg ); | |||||
| else | else | ||||
| log( errorMsg, Project.MSG_ERR ); | log( errorMsg, Project.MSG_ERR ); | ||||
| } | } | ||||
| @@ -257,13 +257,13 @@ public class XMLValidateTask extends Task | |||||
| for( int i = 0; i < filesets.size(); i++ ) | for( int i = 0; i < filesets.size(); i++ ) | ||||
| { | { | ||||
| FileSet fs = ( FileSet )filesets.elementAt( i ); | |||||
| FileSet fs = (FileSet)filesets.elementAt( i ); | |||||
| DirectoryScanner ds = fs.getDirectoryScanner( project ); | DirectoryScanner ds = fs.getDirectoryScanner( project ); | ||||
| String[] files = ds.getIncludedFiles(); | String[] files = ds.getIncludedFiles(); | ||||
| for( int j = 0; j < files.length; j++ ) | for( int j = 0; j < files.length; j++ ) | ||||
| { | { | ||||
| File srcFile = new File( fs.getDir( project ), files[j] ); | |||||
| File srcFile = new File( fs.getDir( project ), files[ j ] ); | |||||
| doValidate( srcFile ); | doValidate( srcFile ); | ||||
| fileProcessed++; | fileProcessed++; | ||||
| } | } | ||||
| @@ -275,9 +275,9 @@ public class XMLValidateTask extends Task | |||||
| { | { | ||||
| LocalResolver resolver = new LocalResolver(); | LocalResolver resolver = new LocalResolver(); | ||||
| for( Enumeration i = dtdLocations.elements(); i.hasMoreElements(); ) | |||||
| for( Enumeration i = dtdLocations.elements(); i.hasMoreElements(); ) | |||||
| { | { | ||||
| DTDLocation location = ( DTDLocation )i.nextElement(); | |||||
| DTDLocation location = (DTDLocation)i.nextElement(); | |||||
| resolver.registerDTD( location ); | resolver.registerDTD( location ); | ||||
| } | } | ||||
| return resolver; | return resolver; | ||||
| @@ -302,7 +302,7 @@ public class XMLValidateTask extends Task | |||||
| log( "Could not set feature '" | log( "Could not set feature '" | ||||
| + feature | + feature | ||||
| + "' because the parser doesn't recognize it", | + "' because the parser doesn't recognize it", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| } | } | ||||
| catch( SAXNotSupportedException e ) | catch( SAXNotSupportedException e ) | ||||
| { | { | ||||
| @@ -310,7 +310,7 @@ public class XMLValidateTask extends Task | |||||
| log( "Could not set feature '" | log( "Could not set feature '" | ||||
| + feature | + feature | ||||
| + "' because the parser doesn't support it", | + "' because the parser doesn't support it", | ||||
| Project.MSG_WARN ); | |||||
| Project.MSG_WARN ); | |||||
| } | } | ||||
| return toReturn; | return toReturn; | ||||
| } | } | ||||
| @@ -327,7 +327,7 @@ public class XMLValidateTask extends Task | |||||
| InputSource is = new InputSource( new FileReader( afile ) ); | InputSource is = new InputSource( new FileReader( afile ) ); | ||||
| String uri = "file:" + afile.getAbsolutePath().replace( '\\', '/' ); | String uri = "file:" + afile.getAbsolutePath().replace( '\\', '/' ); | ||||
| for( int index = uri.indexOf( '#' ); index != -1; | for( int index = uri.indexOf( '#' ); index != -1; | ||||
| index = uri.indexOf( '#' ) ) | |||||
| index = uri.indexOf( '#' ) ) | |||||
| { | { | ||||
| uri = uri.substring( 0, index ) + "%23" + uri.substring( index + 1 ); | uri = uri.substring( 0, index ) + "%23" + uri.substring( index + 1 ); | ||||
| } | } | ||||
| @@ -337,17 +337,17 @@ public class XMLValidateTask extends Task | |||||
| catch( SAXException ex ) | catch( SAXException ex ) | ||||
| { | { | ||||
| if( failOnError ) | if( failOnError ) | ||||
| throw new BuildException( "Could not validate document " + afile ); | |||||
| throw new TaskException( "Could not validate document " + afile ); | |||||
| } | } | ||||
| catch( IOException ex ) | catch( IOException ex ) | ||||
| { | { | ||||
| throw new BuildException( "Could not validate document " + afile, ex ); | |||||
| throw new TaskException( "Could not validate document " + afile, ex ); | |||||
| } | } | ||||
| if( errorHandler.getFailure() ) | if( errorHandler.getFailure() ) | ||||
| { | { | ||||
| if( failOnError ) | if( failOnError ) | ||||
| throw new BuildException( afile + " is not a valid XML document." ); | |||||
| throw new TaskException( afile + " is not a valid XML document." ); | |||||
| else | else | ||||
| log( afile + " is not a valid XML document", Project.MSG_ERR ); | log( afile + " is not a valid XML document", Project.MSG_ERR ); | ||||
| } | } | ||||
| @@ -357,6 +357,7 @@ public class XMLValidateTask extends Task | |||||
| * init the parser : load the parser class, and set features if necessary | * init the parser : load the parser class, and set features if necessary | ||||
| */ | */ | ||||
| private void initValidator() | private void initValidator() | ||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| @@ -369,7 +370,7 @@ public class XMLValidateTask extends Task | |||||
| if( classpath != null ) | if( classpath != null ) | ||||
| { | { | ||||
| AntClassLoader loader = new AntClassLoader( project, classpath ); | AntClassLoader loader = new AntClassLoader( project, classpath ); | ||||
| // loader.addSystemPackageRoot("org.xml"); // needed to avoid conflict | |||||
| // loader.addSystemPackageRoot("org.xml"); // needed to avoid conflict | |||||
| readerClass = loader.loadClass( readerClassName ); | readerClass = loader.loadClass( readerClassName ); | ||||
| AntClassLoader.initializeClass( readerClass ); | AntClassLoader.initializeClass( readerClass ); | ||||
| } | } | ||||
| @@ -380,7 +381,7 @@ public class XMLValidateTask extends Task | |||||
| if( XMLReader.class.isAssignableFrom( readerClass ) ) | if( XMLReader.class.isAssignableFrom( readerClass ) ) | ||||
| { | { | ||||
| xmlReader = ( XMLReader )readerClass.newInstance(); | |||||
| xmlReader = (XMLReader)readerClass.newInstance(); | |||||
| log( "Using SAX2 reader " + readerClassName, Project.MSG_VERBOSE ); | log( "Using SAX2 reader " + readerClassName, Project.MSG_VERBOSE ); | ||||
| } | } | ||||
| else | else | ||||
| @@ -389,29 +390,29 @@ public class XMLValidateTask extends Task | |||||
| // see if it is a SAX1 Parser | // see if it is a SAX1 Parser | ||||
| if( Parser.class.isAssignableFrom( readerClass ) ) | if( Parser.class.isAssignableFrom( readerClass ) ) | ||||
| { | { | ||||
| Parser parser = ( Parser )readerClass.newInstance(); | |||||
| Parser parser = (Parser)readerClass.newInstance(); | |||||
| xmlReader = new ParserAdapter( parser ); | xmlReader = new ParserAdapter( parser ); | ||||
| log( "Using SAX1 parser " + readerClassName, Project.MSG_VERBOSE ); | log( "Using SAX1 parser " + readerClassName, Project.MSG_VERBOSE ); | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| throw new BuildException( INIT_FAILED_MSG | |||||
| + readerClassName | |||||
| + " implements nor SAX1 Parser nor SAX2 XMLReader." ); | |||||
| throw new TaskException( INIT_FAILED_MSG | |||||
| + readerClassName | |||||
| + " implements nor SAX1 Parser nor SAX2 XMLReader." ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| catch( ClassNotFoundException e ) | catch( ClassNotFoundException e ) | ||||
| { | { | ||||
| throw new BuildException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| throw new TaskException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| } | } | ||||
| catch( InstantiationException e ) | catch( InstantiationException e ) | ||||
| { | { | ||||
| throw new BuildException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| throw new TaskException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| } | } | ||||
| catch( IllegalAccessException e ) | catch( IllegalAccessException e ) | ||||
| { | { | ||||
| throw new BuildException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| throw new TaskException( INIT_FAILED_MSG + readerClassName, e ); | |||||
| } | } | ||||
| xmlReader.setEntityResolver( getEntityResolver() ); | xmlReader.setEntityResolver( getEntityResolver() ); | ||||
| @@ -425,17 +426,17 @@ public class XMLValidateTask extends Task | |||||
| boolean ok = setFeature( "http://xml.org/sax/features/validation", true, true ); | boolean ok = setFeature( "http://xml.org/sax/features/validation", true, true ); | ||||
| if( !ok ) | if( !ok ) | ||||
| { | { | ||||
| throw new BuildException( INIT_FAILED_MSG | |||||
| + readerClassName | |||||
| + " doesn't provide validation" ); | |||||
| throw new TaskException( INIT_FAILED_MSG | |||||
| + readerClassName | |||||
| + " doesn't provide validation" ); | |||||
| } | } | ||||
| } | } | ||||
| // set other features | // set other features | ||||
| Enumeration enum = features.keys(); | Enumeration enum = features.keys(); | ||||
| while( enum.hasMoreElements() ) | while( enum.hasMoreElements() ) | ||||
| { | { | ||||
| String featureId = ( String )enum.nextElement(); | |||||
| setFeature( featureId, ( ( Boolean )features.get( featureId ) ).booleanValue(), true ); | |||||
| String featureId = (String)enum.nextElement(); | |||||
| setFeature( featureId, ( (Boolean)features.get( featureId ) ).booleanValue(), true ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -542,13 +543,15 @@ public class XMLValidateTask extends Task | |||||
| } | } | ||||
| private class LocalResolver | private class LocalResolver | ||||
| implements EntityResolver | |||||
| implements EntityResolver | |||||
| { | { | ||||
| private Hashtable fileDTDs = new Hashtable(); | private Hashtable fileDTDs = new Hashtable(); | ||||
| private Hashtable resourceDTDs = new Hashtable(); | private Hashtable resourceDTDs = new Hashtable(); | ||||
| private Hashtable urlDTDs = new Hashtable(); | private Hashtable urlDTDs = new Hashtable(); | ||||
| public LocalResolver() { } | |||||
| public LocalResolver() | |||||
| { | |||||
| } | |||||
| public void registerDTD( String publicId, String location ) | public void registerDTD( String publicId, String location ) | ||||
| { | { | ||||
| @@ -599,7 +602,7 @@ public class XMLValidateTask extends Task | |||||
| public InputSource resolveEntity( String publicId, String systemId ) | public InputSource resolveEntity( String publicId, String systemId ) | ||||
| throws SAXException | throws SAXException | ||||
| { | { | ||||
| File dtdFile = ( File )fileDTDs.get( publicId ); | |||||
| File dtdFile = (File)fileDTDs.get( publicId ); | |||||
| if( dtdFile != null ) | if( dtdFile != null ) | ||||
| { | { | ||||
| try | try | ||||
| @@ -613,7 +616,7 @@ public class XMLValidateTask extends Task | |||||
| } | } | ||||
| } | } | ||||
| String dtdResourceName = ( String )resourceDTDs.get( publicId ); | |||||
| String dtdResourceName = (String)resourceDTDs.get( publicId ); | |||||
| if( dtdResourceName != null ) | if( dtdResourceName != null ) | ||||
| { | { | ||||
| InputStream is = this.getClass().getResourceAsStream( dtdResourceName ); | InputStream is = this.getClass().getResourceAsStream( dtdResourceName ); | ||||
| @@ -624,7 +627,7 @@ public class XMLValidateTask extends Task | |||||
| } | } | ||||
| } | } | ||||
| URL dtdUrl = ( URL )urlDTDs.get( publicId ); | |||||
| URL dtdUrl = (URL)urlDTDs.get( publicId ); | |||||
| if( dtdUrl != null ) | if( dtdUrl != null ) | ||||
| { | { | ||||
| try | try | ||||
| @@ -640,7 +643,7 @@ public class XMLValidateTask extends Task | |||||
| } | } | ||||
| log( "Could not resolve ( publicId: " + publicId + ", systemId: " + systemId + ") to a local entity", | log( "Could not resolve ( publicId: " + publicId + ", systemId: " + systemId + ") to a local entity", | ||||
| Project.MSG_INFO ); | |||||
| Project.MSG_INFO ); | |||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional.depend; | package org.apache.tools.ant.taskdefs.optional.depend; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| @@ -17,15 +18,14 @@ import java.net.URL; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.MatchingTask; | import org.apache.tools.ant.taskdefs.MatchingTask; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
| /** | /** | ||||
| * Generate a dependency file for a given set of classes | * Generate a dependency file for a given set of classes | ||||
| * | * | ||||
| @@ -152,7 +152,6 @@ public class Depend extends MatchingTask | |||||
| this.dump = dump; | this.dump = dump; | ||||
| } | } | ||||
| /** | /** | ||||
| * Set the source dirs to find the source Java files. | * Set the source dirs to find the source Java files. | ||||
| * | * | ||||
| @@ -190,10 +189,10 @@ public class Depend extends MatchingTask | |||||
| /** | /** | ||||
| * Does the work. | * Does the work. | ||||
| * | * | ||||
| * @exception BuildException Thrown in unrecovrable error. | |||||
| * @exception TaskException Thrown in unrecovrable error. | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -201,7 +200,7 @@ public class Depend extends MatchingTask | |||||
| String[] srcPathList = srcPath.list(); | String[] srcPathList = srcPath.list(); | ||||
| if( srcPathList.length == 0 ) | if( srcPathList.length == 0 ) | ||||
| { | { | ||||
| throw new BuildException( "srcdir attribute must be set!" ); | |||||
| throw new TaskException( "srcdir attribute must be set!" ); | |||||
| } | } | ||||
| if( destPath == null ) | if( destPath == null ) | ||||
| @@ -211,7 +210,7 @@ public class Depend extends MatchingTask | |||||
| if( cache != null && cache.exists() && !cache.isDirectory() ) | if( cache != null && cache.exists() && !cache.isDirectory() ) | ||||
| { | { | ||||
| throw new BuildException( "The cache, if specified, must point to a directory" ); | |||||
| throw new TaskException( "The cache, if specified, must point to a directory" ); | |||||
| } | } | ||||
| if( cache != null && !cache.exists() ) | if( cache != null && !cache.exists() ) | ||||
| @@ -224,16 +223,16 @@ public class Depend extends MatchingTask | |||||
| if( dump ) | if( dump ) | ||||
| { | { | ||||
| log( "Reverse Dependency Dump for " + affectedClassMap.size() + | log( "Reverse Dependency Dump for " + affectedClassMap.size() + | ||||
| " classes:", Project.MSG_DEBUG ); | |||||
| for( Enumeration e = affectedClassMap.keys(); e.hasMoreElements(); ) | |||||
| " classes:", Project.MSG_DEBUG ); | |||||
| for( Enumeration e = affectedClassMap.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )e.nextElement(); | |||||
| String className = (String)e.nextElement(); | |||||
| log( " Class " + className + " affects:", Project.MSG_DEBUG ); | log( " Class " + className + " affects:", Project.MSG_DEBUG ); | ||||
| Hashtable affectedClasses = ( Hashtable )affectedClassMap.get( className ); | |||||
| for( Enumeration e2 = affectedClasses.keys(); e2.hasMoreElements(); ) | |||||
| Hashtable affectedClasses = (Hashtable)affectedClassMap.get( className ); | |||||
| for( Enumeration e2 = affectedClasses.keys(); e2.hasMoreElements(); ) | |||||
| { | { | ||||
| String affectedClass = ( String )e2.nextElement(); | |||||
| ClassFileInfo info = ( ClassFileInfo )affectedClasses.get( affectedClass ); | |||||
| String affectedClass = (String)e2.nextElement(); | |||||
| ClassFileInfo info = (ClassFileInfo)affectedClasses.get( affectedClass ); | |||||
| log( " " + affectedClass + " in " + info.absoluteFile.getPath(), Project.MSG_DEBUG ); | log( " " + affectedClass + " in " + info.absoluteFile.getPath(), Project.MSG_DEBUG ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -241,14 +240,14 @@ public class Depend extends MatchingTask | |||||
| if( classpathDependencies != null ) | if( classpathDependencies != null ) | ||||
| { | { | ||||
| log( "Classpath file dependencies (Forward):", Project.MSG_DEBUG ); | log( "Classpath file dependencies (Forward):", Project.MSG_DEBUG ); | ||||
| for( Enumeration e = classpathDependencies.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = classpathDependencies.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )e.nextElement(); | |||||
| String className = (String)e.nextElement(); | |||||
| log( " Class " + className + " depends on:", Project.MSG_DEBUG ); | log( " Class " + className + " depends on:", Project.MSG_DEBUG ); | ||||
| Hashtable dependencies = ( Hashtable )classpathDependencies.get( className ); | |||||
| for( Enumeration e2 = dependencies.elements(); e2.hasMoreElements(); ) | |||||
| Hashtable dependencies = (Hashtable)classpathDependencies.get( className ); | |||||
| for( Enumeration e2 = dependencies.elements(); e2.hasMoreElements(); ) | |||||
| { | { | ||||
| File classpathFile = ( File )e2.nextElement(); | |||||
| File classpathFile = (File)e2.nextElement(); | |||||
| log( " " + classpathFile.getPath(), Project.MSG_DEBUG ); | log( " " + classpathFile.getPath(), Project.MSG_DEBUG ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -261,7 +260,7 @@ public class Depend extends MatchingTask | |||||
| outOfDateClasses = new Hashtable(); | outOfDateClasses = new Hashtable(); | ||||
| for( int i = 0; i < srcPathList.length; i++ ) | for( int i = 0; i < srcPathList.length; i++ ) | ||||
| { | { | ||||
| File srcDir = ( File )resolveFile( srcPathList[i] ); | |||||
| File srcDir = (File)resolveFile( srcPathList[ i ] ); | |||||
| if( srcDir.exists() ) | if( srcDir.exists() ) | ||||
| { | { | ||||
| DirectoryScanner ds = this.getDirectoryScanner( srcDir ); | DirectoryScanner ds = this.getDirectoryScanner( srcDir ); | ||||
| @@ -273,25 +272,25 @@ public class Depend extends MatchingTask | |||||
| // now check classpath file dependencies | // now check classpath file dependencies | ||||
| if( classpathDependencies != null ) | if( classpathDependencies != null ) | ||||
| { | { | ||||
| for( Enumeration e = classpathDependencies.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = classpathDependencies.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )e.nextElement(); | |||||
| String className = (String)e.nextElement(); | |||||
| if( !outOfDateClasses.containsKey( className ) ) | if( !outOfDateClasses.containsKey( className ) ) | ||||
| { | { | ||||
| ClassFileInfo info = ( ClassFileInfo )classFileInfoMap.get( className ); | |||||
| ClassFileInfo info = (ClassFileInfo)classFileInfoMap.get( className ); | |||||
| // if we have no info about the class - it may have been deleted already and we | // if we have no info about the class - it may have been deleted already and we | ||||
| // are using cached info. | // are using cached info. | ||||
| if( info != null ) | if( info != null ) | ||||
| { | { | ||||
| Hashtable dependencies = ( Hashtable )classpathDependencies.get( className ); | |||||
| for( Enumeration e2 = dependencies.elements(); e2.hasMoreElements(); ) | |||||
| Hashtable dependencies = (Hashtable)classpathDependencies.get( className ); | |||||
| for( Enumeration e2 = dependencies.elements(); e2.hasMoreElements(); ) | |||||
| { | { | ||||
| File classpathFile = ( File )e2.nextElement(); | |||||
| File classpathFile = (File)e2.nextElement(); | |||||
| if( classpathFile.lastModified() > info.absoluteFile.lastModified() ) | if( classpathFile.lastModified() > info.absoluteFile.lastModified() ) | ||||
| { | { | ||||
| log( "Class " + className + | log( "Class " + className + | ||||
| " is out of date with respect to " + classpathFile, Project.MSG_DEBUG ); | |||||
| " is out of date with respect to " + classpathFile, Project.MSG_DEBUG ); | |||||
| outOfDateClasses.put( className, className ); | outOfDateClasses.put( className, className ); | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -310,7 +309,7 @@ public class Depend extends MatchingTask | |||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| throw new BuildException( "Error", e ); | |||||
| throw new TaskException( "Error", e ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -328,14 +327,14 @@ public class Depend extends MatchingTask | |||||
| for( int i = 0; i < files.length; i++ ) | for( int i = 0; i < files.length; i++ ) | ||||
| { | { | ||||
| File srcFile = new File( srcDir, files[i] ); | |||||
| if( files[i].endsWith( ".java" ) ) | |||||
| File srcFile = new File( srcDir, files[ i ] ); | |||||
| if( files[ i ].endsWith( ".java" ) ) | |||||
| { | { | ||||
| String filePath = srcFile.getPath(); | String filePath = srcFile.getPath(); | ||||
| String className = filePath.substring( srcDir.getPath().length() + 1, | String className = filePath.substring( srcDir.getPath().length() + 1, | ||||
| filePath.length() - ".java".length() ); | |||||
| filePath.length() - ".java".length() ); | |||||
| className = ClassFileUtils.convertSlashName( className ); | className = ClassFileUtils.convertSlashName( className ); | ||||
| ClassFileInfo info = ( ClassFileInfo )classFileInfoMap.get( className ); | |||||
| ClassFileInfo info = (ClassFileInfo)classFileInfoMap.get( className ); | |||||
| if( info == null ) | if( info == null ) | ||||
| { | { | ||||
| // there was no class file. add this class to the list | // there was no class file. add this class to the list | ||||
| @@ -352,7 +351,6 @@ public class Depend extends MatchingTask | |||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Get the list of class files we are going to analyse. | * Get the list of class files we are going to analyse. | ||||
| * | * | ||||
| @@ -369,7 +367,7 @@ public class Depend extends MatchingTask | |||||
| for( int i = 0; i < classLocationsList.length; ++i ) | for( int i = 0; i < classLocationsList.length; ++i ) | ||||
| { | { | ||||
| File dir = new File( classLocationsList[i] ); | |||||
| File dir = new File( classLocationsList[ i ] ); | |||||
| if( dir.isDirectory() ) | if( dir.isDirectory() ) | ||||
| { | { | ||||
| addClassFiles( classFileList, dir, dir ); | addClassFiles( classFileList, dir, dir ); | ||||
| @@ -397,7 +395,7 @@ public class Depend extends MatchingTask | |||||
| for( int i = 0; i < length; ++i ) | for( int i = 0; i < length; ++i ) | ||||
| { | { | ||||
| File file = new File( dir, filesInDir[i] ); | |||||
| File file = new File( dir, filesInDir[ i ] ); | |||||
| if( file.isDirectory() ) | if( file.isDirectory() ) | ||||
| { | { | ||||
| addClassFiles( classFileList, file, root ); | addClassFiles( classFileList, file, root ); | ||||
| @@ -407,7 +405,7 @@ public class Depend extends MatchingTask | |||||
| ClassFileInfo info = new ClassFileInfo(); | ClassFileInfo info = new ClassFileInfo(); | ||||
| info.absoluteFile = file; | info.absoluteFile = file; | ||||
| info.relativeName = file.getPath().substring( root.getPath().length() + 1, | info.relativeName = file.getPath().substring( root.getPath().length() + 1, | ||||
| file.getPath().length() - 6 ); | |||||
| file.getPath().length() - 6 ); | |||||
| info.className = ClassFileUtils.convertSlashName( info.relativeName ); | info.className = ClassFileUtils.convertSlashName( info.relativeName ); | ||||
| classFileList.addElement( info ); | classFileList.addElement( info ); | ||||
| } | } | ||||
| @@ -419,17 +417,17 @@ public class Depend extends MatchingTask | |||||
| { | { | ||||
| int count = 0; | int count = 0; | ||||
| Hashtable affectedClasses = ( Hashtable )affectedClassMap.get( className ); | |||||
| Hashtable affectedClasses = (Hashtable)affectedClassMap.get( className ); | |||||
| if( affectedClasses != null ) | if( affectedClasses != null ) | ||||
| { | { | ||||
| for( Enumeration e = affectedClasses.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = affectedClasses.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String affectedClassName = ( String )e.nextElement(); | |||||
| ClassFileInfo affectedClassInfo = ( ClassFileInfo )affectedClasses.get( affectedClassName ); | |||||
| String affectedClassName = (String)e.nextElement(); | |||||
| ClassFileInfo affectedClassInfo = (ClassFileInfo)affectedClasses.get( affectedClassName ); | |||||
| if( affectedClassInfo.absoluteFile.exists() ) | if( affectedClassInfo.absoluteFile.exists() ) | ||||
| { | { | ||||
| log( "Deleting file " + affectedClassInfo.absoluteFile.getPath() + " since " + | log( "Deleting file " + affectedClassInfo.absoluteFile.getPath() + " since " + | ||||
| className + " out of date", Project.MSG_VERBOSE ); | |||||
| className + " out of date", Project.MSG_VERBOSE ); | |||||
| affectedClassInfo.absoluteFile.delete(); | affectedClassInfo.absoluteFile.delete(); | ||||
| count++; | count++; | ||||
| if( closure ) | if( closure ) | ||||
| @@ -445,15 +443,15 @@ public class Depend extends MatchingTask | |||||
| { | { | ||||
| // need to delete the main class | // need to delete the main class | ||||
| String topLevelClassName | String topLevelClassName | ||||
| = affectedClassName.substring( 0, affectedClassName.indexOf( "$" ) ); | |||||
| = affectedClassName.substring( 0, affectedClassName.indexOf( "$" ) ); | |||||
| log( "Top level class = " + topLevelClassName, Project.MSG_VERBOSE ); | log( "Top level class = " + topLevelClassName, Project.MSG_VERBOSE ); | ||||
| ClassFileInfo topLevelClassInfo | ClassFileInfo topLevelClassInfo | ||||
| = ( ClassFileInfo )classFileInfoMap.get( topLevelClassName ); | |||||
| = (ClassFileInfo)classFileInfoMap.get( topLevelClassName ); | |||||
| if( topLevelClassInfo != null && | if( topLevelClassInfo != null && | ||||
| topLevelClassInfo.absoluteFile.exists() ) | topLevelClassInfo.absoluteFile.exists() ) | ||||
| { | { | ||||
| log( "Deleting file " + topLevelClassInfo.absoluteFile.getPath() + " since " + | log( "Deleting file " + topLevelClassInfo.absoluteFile.getPath() + " since " + | ||||
| "one of its inner classes was removed", Project.MSG_VERBOSE ); | |||||
| "one of its inner classes was removed", Project.MSG_VERBOSE ); | |||||
| topLevelClassInfo.absoluteFile.delete(); | topLevelClassInfo.absoluteFile.delete(); | ||||
| count++; | count++; | ||||
| if( closure ) | if( closure ) | ||||
| @@ -472,11 +470,11 @@ public class Depend extends MatchingTask | |||||
| private int deleteAllAffectedFiles() | private int deleteAllAffectedFiles() | ||||
| { | { | ||||
| int count = 0; | int count = 0; | ||||
| for( Enumeration e = outOfDateClasses.elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = outOfDateClasses.elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )e.nextElement(); | |||||
| String className = (String)e.nextElement(); | |||||
| count += deleteAffectedFiles( className ); | count += deleteAffectedFiles( className ); | ||||
| ClassFileInfo classInfo = ( ClassFileInfo )classFileInfoMap.get( className ); | |||||
| ClassFileInfo classInfo = (ClassFileInfo)classFileInfoMap.get( className ); | |||||
| if( classInfo != null && classInfo.absoluteFile.exists() ) | if( classInfo != null && classInfo.absoluteFile.exists() ) | ||||
| { | { | ||||
| classInfo.absoluteFile.delete(); | classInfo.absoluteFile.delete(); | ||||
| @@ -486,7 +484,6 @@ public class Depend extends MatchingTask | |||||
| return count; | return count; | ||||
| } | } | ||||
| /** | /** | ||||
| * Determine the dependencies between classes. Class dependencies are | * Determine the dependencies between classes. Class dependencies are | ||||
| * determined by examining the class references in a class file to other | * determined by examining the class references in a class file to other | ||||
| @@ -495,7 +492,7 @@ public class Depend extends MatchingTask | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| private void determineDependencies() | private void determineDependencies() | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| affectedClassMap = new Hashtable(); | affectedClassMap = new Hashtable(); | ||||
| classFileInfoMap = new Hashtable(); | classFileInfoMap = new Hashtable(); | ||||
| @@ -514,9 +511,9 @@ public class Depend extends MatchingTask | |||||
| depCacheFileExists = depCacheFile.exists(); | depCacheFileExists = depCacheFile.exists(); | ||||
| depCacheFileLastModified = depCacheFile.lastModified(); | depCacheFileLastModified = depCacheFile.lastModified(); | ||||
| } | } | ||||
| for( Enumeration e = getClassFiles( destPath ).elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = getClassFiles( destPath ).elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| ClassFileInfo info = ( ClassFileInfo )e.nextElement(); | |||||
| ClassFileInfo info = (ClassFileInfo)e.nextElement(); | |||||
| log( "Adding class info for " + info.className, Project.MSG_DEBUG ); | log( "Adding class info for " + info.className, Project.MSG_DEBUG ); | ||||
| classFileInfoMap.put( info.className, info ); | classFileInfoMap.put( info.className, info ); | ||||
| @@ -529,7 +526,7 @@ public class Depend extends MatchingTask | |||||
| { | { | ||||
| // depFile exists and is newer than the class file | // depFile exists and is newer than the class file | ||||
| // need to get dependency list from the map. | // need to get dependency list from the map. | ||||
| dependencyList = ( Vector )dependencyMap.get( info.className ); | |||||
| dependencyList = (Vector)dependencyMap.get( info.className ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -562,11 +559,11 @@ public class Depend extends MatchingTask | |||||
| // This class depends on each class in the dependency list. For each | // This class depends on each class in the dependency list. For each | ||||
| // one of those, add this class into their affected classes list | // one of those, add this class into their affected classes list | ||||
| for( Enumeration depEnum = dependencyList.elements(); depEnum.hasMoreElements(); ) | |||||
| for( Enumeration depEnum = dependencyList.elements(); depEnum.hasMoreElements(); ) | |||||
| { | { | ||||
| String dependentClass = ( String )depEnum.nextElement(); | |||||
| String dependentClass = (String)depEnum.nextElement(); | |||||
| Hashtable affectedClasses = ( Hashtable )affectedClassMap.get( dependentClass ); | |||||
| Hashtable affectedClasses = (Hashtable)affectedClassMap.get( dependentClass ); | |||||
| if( affectedClasses == null ) | if( affectedClasses == null ) | ||||
| { | { | ||||
| affectedClasses = new Hashtable(); | affectedClasses = new Hashtable(); | ||||
| @@ -586,15 +583,15 @@ public class Depend extends MatchingTask | |||||
| Hashtable classpathFileCache = new Hashtable(); | Hashtable classpathFileCache = new Hashtable(); | ||||
| Object nullFileMarker = new Object(); | Object nullFileMarker = new Object(); | ||||
| for( Enumeration e = dependencyMap.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = dependencyMap.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )e.nextElement(); | |||||
| Vector dependencyList = ( Vector )dependencyMap.get( className ); | |||||
| String className = (String)e.nextElement(); | |||||
| Vector dependencyList = (Vector)dependencyMap.get( className ); | |||||
| Hashtable dependencies = new Hashtable(); | Hashtable dependencies = new Hashtable(); | ||||
| classpathDependencies.put( className, dependencies ); | classpathDependencies.put( className, dependencies ); | ||||
| for( Enumeration e2 = dependencyList.elements(); e2.hasMoreElements(); ) | |||||
| for( Enumeration e2 = dependencyList.elements(); e2.hasMoreElements(); ) | |||||
| { | { | ||||
| String dependency = ( String )e2.nextElement(); | |||||
| String dependency = (String)e2.nextElement(); | |||||
| Object classpathFileObject = classpathFileCache.get( dependency ); | Object classpathFileObject = classpathFileCache.get( dependency ); | ||||
| if( classpathFileObject == null ) | if( classpathFileObject == null ) | ||||
| { | { | ||||
| @@ -621,8 +618,8 @@ public class Depend extends MatchingTask | |||||
| classpathFileObject = new File( classFilePath ); | classpathFileObject = new File( classFilePath ); | ||||
| } | } | ||||
| log( "Class " + className + | log( "Class " + className + | ||||
| " depends on " + classpathFileObject + | |||||
| " due to " + dependency, Project.MSG_DEBUG ); | |||||
| " depends on " + classpathFileObject + | |||||
| " due to " + dependency, Project.MSG_DEBUG ); | |||||
| } | } | ||||
| } | } | ||||
| classpathFileCache.put( dependency, classpathFileObject ); | classpathFileCache.put( dependency, classpathFileObject ); | ||||
| @@ -630,7 +627,7 @@ public class Depend extends MatchingTask | |||||
| if( classpathFileObject != null && classpathFileObject != nullFileMarker ) | if( classpathFileObject != null && classpathFileObject != nullFileMarker ) | ||||
| { | { | ||||
| // we need to add this jar to the list for this class. | // we need to add this jar to the list for this class. | ||||
| File jarFile = ( File )classpathFileObject; | |||||
| File jarFile = (File)classpathFileObject; | |||||
| dependencies.put( jarFile, jarFile ); | dependencies.put( jarFile, jarFile ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -713,13 +710,13 @@ public class Depend extends MatchingTask | |||||
| File depFile = new File( cache, CACHE_FILE_NAME ); | File depFile = new File( cache, CACHE_FILE_NAME ); | ||||
| pw = new PrintWriter( new FileWriter( depFile ) ); | pw = new PrintWriter( new FileWriter( depFile ) ); | ||||
| for( Enumeration deps = dependencyMap.keys(); deps.hasMoreElements(); ) | |||||
| for( Enumeration deps = dependencyMap.keys(); deps.hasMoreElements(); ) | |||||
| { | { | ||||
| String className = ( String )deps.nextElement(); | |||||
| String className = (String)deps.nextElement(); | |||||
| pw.println( CLASSNAME_PREPEND + className ); | pw.println( CLASSNAME_PREPEND + className ); | ||||
| Vector dependencyList = ( Vector )dependencyMap.get( className ); | |||||
| Vector dependencyList = (Vector)dependencyMap.get( className ); | |||||
| int size = dependencyList.size(); | int size = dependencyList.size(); | ||||
| for( int x = 0; x < size; x++ ) | for( int x = 0; x < size; x++ ) | ||||
| { | { | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional.ejb; | package org.apache.tools.ant.taskdefs.optional.ejb; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| @@ -24,14 +25,13 @@ import java.util.zip.ZipEntry; | |||||
| import javax.xml.parsers.SAXParser; | import javax.xml.parsers.SAXParser; | ||||
| import org.apache.bcel.*; | import org.apache.bcel.*; | ||||
| import org.apache.bcel.classfile.*; | import org.apache.bcel.classfile.*; | ||||
| import org.apache.tools.ant.*; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
| import org.apache.tools.ant.Location; | import org.apache.tools.ant.Location; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.*; | |||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.util.depend.Dependencies; | import org.apache.tools.ant.util.depend.Dependencies; | ||||
| @@ -39,7 +39,6 @@ import org.apache.tools.ant.util.depend.Filter; | |||||
| import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
| import org.xml.sax.SAXException; | import org.xml.sax.SAXException; | ||||
| /** | /** | ||||
| * A deployment tool which creates generic EJB jars. Generic jars contains only | * A deployment tool which creates generic EJB jars. Generic jars contains only | ||||
| * those classes and META-INF entries specified in the EJB 1.1 standard This | * those classes and META-INF entries specified in the EJB 1.1 standard This | ||||
| @@ -133,7 +132,6 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| this.genericJarSuffix = inString; | this.genericJarSuffix = inString; | ||||
| } | } | ||||
| /** | /** | ||||
| * Set the task which owns this tool | * Set the task which owns this tool | ||||
| * | * | ||||
| @@ -178,7 +176,6 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| return ddPrefix; | return ddPrefix; | ||||
| } | } | ||||
| /** | /** | ||||
| * Configure this tool for use in the ejbjar task. | * Configure this tool for use in the ejbjar task. | ||||
| * | * | ||||
| @@ -227,7 +224,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| // First the regular deployment descriptor | // First the regular deployment descriptor | ||||
| ejbFiles.put( META_DIR + EJB_DD, | ejbFiles.put( META_DIR + EJB_DD, | ||||
| new File( config.descriptorDir, descriptorFileName ) ); | |||||
| new File( config.descriptorDir, descriptorFileName ) ); | |||||
| // now the vendor specific files, if any | // now the vendor specific files, if any | ||||
| addVendorFiles( ejbFiles, ddPrefix ); | addVendorFiles( ejbFiles, ddPrefix ); | ||||
| @@ -260,7 +257,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| + " with " | + " with " | ||||
| + String.valueOf( ejbFiles.size() ) | + String.valueOf( ejbFiles.size() ) | ||||
| + " files", | + " files", | ||||
| Project.MSG_INFO ); | |||||
| Project.MSG_INFO ); | |||||
| // Use helper method to write the jarfile | // Use helper method to write the jarfile | ||||
| String publicId = getPublicId(); | String publicId = getPublicId(); | ||||
| @@ -271,26 +268,26 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| { | { | ||||
| // Log that the file is up to date... | // Log that the file is up to date... | ||||
| log( jarFile.toString() + " is up to date.", | log( jarFile.toString() + " is up to date.", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| } | } | ||||
| } | } | ||||
| catch( SAXException se ) | catch( SAXException se ) | ||||
| { | { | ||||
| String msg = "SAXException while parsing '" | String msg = "SAXException while parsing '" | ||||
| + descriptorFileName.toString() | |||||
| + "'. This probably indicates badly-formed XML." | |||||
| + " Details: " | |||||
| + se.getMessage(); | |||||
| + descriptorFileName.toString() | |||||
| + "'. This probably indicates badly-formed XML." | |||||
| + " Details: " | |||||
| + se.getMessage(); | |||||
| throw new BuildException( msg, se ); | throw new BuildException( msg, se ); | ||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "IOException while parsing'" | String msg = "IOException while parsing'" | ||||
| + descriptorFileName.toString() | |||||
| + "'. This probably indicates that the descriptor" | |||||
| + " doesn't exist. Details: " | |||||
| + ioe.getMessage(); | |||||
| + descriptorFileName.toString() | |||||
| + "'. This probably indicates that the descriptor" | |||||
| + " doesn't exist. Details: " | |||||
| + ioe.getMessage(); | |||||
| throw new BuildException( msg, ioe ); | throw new BuildException( msg, ioe ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -306,12 +303,11 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| if( ( destDir == null ) || ( !destDir.isDirectory() ) ) | if( ( destDir == null ) || ( !destDir.isDirectory() ) ) | ||||
| { | { | ||||
| String msg = "A valid destination directory must be specified " | String msg = "A valid destination directory must be specified " | ||||
| + "using the \"destdir\" attribute."; | |||||
| + "using the \"destdir\" attribute."; | |||||
| throw new BuildException( msg ); | throw new BuildException( msg ); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Returns a Classloader object which parses the passed in generic EjbJar | * Returns a Classloader object which parses the passed in generic EjbJar | ||||
| * classpath. The loader is used to dynamically load classes from | * classpath. The loader is used to dynamically load classes from | ||||
| @@ -320,6 +316,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| * @return The ClassLoaderForBuild value | * @return The ClassLoaderForBuild value | ||||
| */ | */ | ||||
| protected ClassLoader getClassLoaderForBuild() | protected ClassLoader getClassLoaderForBuild() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( classpathLoader != null ) | if( classpathLoader != null ) | ||||
| { | { | ||||
| @@ -382,9 +379,9 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| registerKnownDTDs( handler ); | registerKnownDTDs( handler ); | ||||
| // register any DTDs supplied by the user | // register any DTDs supplied by the user | ||||
| for( Iterator i = getConfig().dtdLocations.iterator(); i.hasNext(); ) | |||||
| for( Iterator i = getConfig().dtdLocations.iterator(); i.hasNext(); ) | |||||
| { | { | ||||
| EjbJar.DTDLocation dtdLocation = ( EjbJar.DTDLocation )i.next(); | |||||
| EjbJar.DTDLocation dtdLocation = (EjbJar.DTDLocation)i.next(); | |||||
| handler.registerDTD( dtdLocation.getPublicId(), dtdLocation.getLocation() ); | handler.registerDTD( dtdLocation.getPublicId(), dtdLocation.getLocation() ); | ||||
| } | } | ||||
| return handler; | return handler; | ||||
| @@ -400,7 +397,6 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| return destDir; | return destDir; | ||||
| } | } | ||||
| /** | /** | ||||
| * Using the EJB descriptor file name passed from the <code>ejbjar</code> | * Using the EJB descriptor file name passed from the <code>ejbjar</code> | ||||
| * task, this method returns the "basename" which will be used to name the | * task, this method returns the "basename" which will be used to name the | ||||
| @@ -433,7 +429,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| if( lastSeparatorIndex != -1 ) | if( lastSeparatorIndex != -1 ) | ||||
| { | { | ||||
| endBaseName = descriptorFileName.indexOf( config.baseNameTerminator, | endBaseName = descriptorFileName.indexOf( config.baseNameTerminator, | ||||
| lastSeparatorIndex ); | |||||
| lastSeparatorIndex ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -522,13 +518,13 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| // Create the file input stream, and buffer everything over | // Create the file input stream, and buffer everything over | ||||
| // to the jar output stream | // to the jar output stream | ||||
| byte[] byteBuffer = new byte[2 * 1024]; | |||||
| byte[] byteBuffer = new byte[ 2 * 1024 ]; | |||||
| int count = 0; | int count = 0; | ||||
| do | do | ||||
| { | { | ||||
| jStream.write( byteBuffer, 0, count ); | jStream.write( byteBuffer, 0, count ); | ||||
| count = iStream.read( byteBuffer, 0, byteBuffer.length ); | count = iStream.read( byteBuffer, 0, byteBuffer.length ); | ||||
| }while ( count != -1 ); | |||||
| } while( count != -1 ); | |||||
| //add it to list of files in jar | //add it to list of files in jar | ||||
| addedfiles.add( logicalFilename ); | addedfiles.add( logicalFilename ); | ||||
| @@ -537,8 +533,8 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| log( "WARNING: IOException while adding entry " + | log( "WARNING: IOException while adding entry " + | ||||
| logicalFilename + " to jarfile from " + inputFile.getPath() + " " + | |||||
| ioe.getClass().getName() + "-" + ioe.getMessage(), Project.MSG_WARN ); | |||||
| logicalFilename + " to jarfile from " + inputFile.getPath() + " " + | |||||
| ioe.getClass().getName() + "-" + ioe.getMessage(), Project.MSG_WARN ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -550,7 +546,8 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| iStream.close(); | iStream.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -566,16 +563,16 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| { | { | ||||
| // add in support classes if any | // add in support classes if any | ||||
| Project project = task.getProject(); | Project project = task.getProject(); | ||||
| for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); ) | |||||
| for( Iterator i = config.supportFileSets.iterator(); i.hasNext(); ) | |||||
| { | { | ||||
| FileSet supportFileSet = ( FileSet )i.next(); | |||||
| FileSet supportFileSet = (FileSet)i.next(); | |||||
| File supportBaseDir = supportFileSet.getDir( project ); | File supportBaseDir = supportFileSet.getDir( project ); | ||||
| DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner( project ); | DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner( project ); | ||||
| supportScanner.scan(); | supportScanner.scan(); | ||||
| String[] supportFiles = supportScanner.getIncludedFiles(); | String[] supportFiles = supportScanner.getIncludedFiles(); | ||||
| for( int j = 0; j < supportFiles.length; ++j ) | for( int j = 0; j < supportFiles.length; ++j ) | ||||
| { | { | ||||
| ejbFiles.put( supportFiles[j], new File( supportBaseDir, supportFiles[j] ) ); | |||||
| ejbFiles.put( supportFiles[ j ], new File( supportBaseDir, supportFiles[ j ] ) ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -591,7 +588,6 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| // nothing to add for generic tool. | // nothing to add for generic tool. | ||||
| }// end of writeJar | }// end of writeJar | ||||
| /** | /** | ||||
| * Add all available classes, that depend on Remote, Home, Bean, PK | * Add all available classes, that depend on Remote, Home, Bean, PK | ||||
| * | * | ||||
| @@ -610,7 +606,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| Iterator i = checkEntries.keySet().iterator(); | Iterator i = checkEntries.keySet().iterator(); | ||||
| while( i.hasNext() ) | while( i.hasNext() ) | ||||
| { | { | ||||
| String entryName = ( String )i.next(); | |||||
| String entryName = (String)i.next(); | |||||
| if( entryName.endsWith( ".class" ) ) | if( entryName.endsWith( ".class" ) ) | ||||
| newSet.add( entryName.substring( 0, entryName.length() - ".class".length() ).replace( File.separatorChar, '/' ) ); | newSet.add( entryName.substring( 0, entryName.length() - ".class".length() ).replace( File.separatorChar, '/' ) ); | ||||
| } | } | ||||
| @@ -621,7 +617,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| i = newSet.iterator(); | i = newSet.iterator(); | ||||
| while( i.hasNext() ) | while( i.hasNext() ) | ||||
| { | { | ||||
| String fileName = base + ( ( String )i.next() ).replace( '/', File.separatorChar ) + ".class"; | |||||
| String fileName = base + ( (String)i.next() ).replace( '/', File.separatorChar ) + ".class"; | |||||
| try | try | ||||
| { | { | ||||
| @@ -638,22 +634,22 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| visitor.clearDependencies(); | visitor.clearDependencies(); | ||||
| Dependencies.applyFilter( newSet, | Dependencies.applyFilter( newSet, | ||||
| new Filter() | |||||
| { | |||||
| public boolean accept( Object object ) | |||||
| { | |||||
| String fileName = base + ( ( String )object ).replace( '/', File.separatorChar ) + ".class"; | |||||
| return new File( fileName ).exists(); | |||||
| } | |||||
| } ); | |||||
| new Filter() | |||||
| { | |||||
| public boolean accept( Object object ) | |||||
| { | |||||
| String fileName = base + ( (String)object ).replace( '/', File.separatorChar ) + ".class"; | |||||
| return new File( fileName ).exists(); | |||||
| } | |||||
| } ); | |||||
| newSet.removeAll( set ); | newSet.removeAll( set ); | ||||
| set.addAll( newSet ); | set.addAll( newSet ); | ||||
| }while ( newSet.size() > 0 ); | |||||
| } while( newSet.size() > 0 ); | |||||
| i = set.iterator(); | i = set.iterator(); | ||||
| while( i.hasNext() ) | while( i.hasNext() ) | ||||
| { | { | ||||
| String next = ( ( String )i.next() ).replace( '/', File.separatorChar ); | |||||
| String next = ( (String)i.next() ).replace( '/', File.separatorChar ); | |||||
| checkEntries.put( next + ".class", new File( base + next + ".class" ) ); | checkEntries.put( next + ".class", new File( base + next + ".class" ) ); | ||||
| log( "dependent class: " + next + ".class" + " - " + base + next + ".class", Project.MSG_VERBOSE ); | log( "dependent class: " + next + ".class" + " - " + base + next + ".class", Project.MSG_VERBOSE ); | ||||
| } | } | ||||
| @@ -713,7 +709,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| config.manifest.lastModified() > lastBuild ) | config.manifest.lastModified() > lastBuild ) | ||||
| { | { | ||||
| log( "Build needed because manifest " + config.manifest + " is out of date", | log( "Build needed because manifest " + config.manifest + " is out of date", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -723,11 +719,11 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| // more recently than the destination jar. | // more recently than the destination jar. | ||||
| while( fileIter.hasNext() ) | while( fileIter.hasNext() ) | ||||
| { | { | ||||
| File currentFile = ( File )fileIter.next(); | |||||
| File currentFile = (File)fileIter.next(); | |||||
| if( lastBuild < currentFile.lastModified() ) | if( lastBuild < currentFile.lastModified() ) | ||||
| { | { | ||||
| log( "Build needed because " + currentFile.getPath() + " is out of date", | log( "Build needed because " + currentFile.getPath() + " is out of date", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| @@ -780,7 +776,8 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| descriptorStream.close(); | descriptorStream.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -892,13 +889,13 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| jarStream.setMethod( JarOutputStream.DEFLATED ); | jarStream.setMethod( JarOutputStream.DEFLATED ); | ||||
| // Loop through all the class files found and add them to the jar | // Loop through all the class files found and add them to the jar | ||||
| for( Iterator entryIterator = files.keySet().iterator(); entryIterator.hasNext(); ) | |||||
| for( Iterator entryIterator = files.keySet().iterator(); entryIterator.hasNext(); ) | |||||
| { | { | ||||
| String entryName = ( String )entryIterator.next(); | |||||
| File entryFile = ( File )files.get( entryName ); | |||||
| String entryName = (String)entryIterator.next(); | |||||
| File entryFile = (File)files.get( entryName ); | |||||
| log( "adding file '" + entryName + "'", | log( "adding file '" + entryName + "'", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| addFileToJar( jarStream, entryFile, entryName ); | addFileToJar( jarStream, entryFile, entryName ); | ||||
| @@ -913,17 +910,17 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| int entryIndex = entryName.lastIndexOf( entryFile.getName() ) - 1; | int entryIndex = entryName.lastIndexOf( entryFile.getName() ) - 1; | ||||
| if( entryIndex < 0 ) | if( entryIndex < 0 ) | ||||
| { | { | ||||
| entryName = innerfiles[i]; | |||||
| entryName = innerfiles[ i ]; | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| entryName = entryName.substring( 0, entryIndex ) + File.separatorChar + innerfiles[i]; | |||||
| entryName = entryName.substring( 0, entryIndex ) + File.separatorChar + innerfiles[ i ]; | |||||
| } | } | ||||
| // link the file | // link the file | ||||
| entryFile = new File( config.srcDir, entryName ); | entryFile = new File( config.srcDir, entryName ); | ||||
| log( "adding innerclass file '" + entryName + "'", | log( "adding innerclass file '" + entryName + "'", | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| addFileToJar( jarStream, entryFile, entryName ); | addFileToJar( jarStream, entryFile, entryName ); | ||||
| @@ -933,9 +930,9 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "IOException while processing ejb-jar file '" | String msg = "IOException while processing ejb-jar file '" | ||||
| + jarfile.toString() | |||||
| + "'. Details: " | |||||
| + ioe.getMessage(); | |||||
| + jarfile.toString() | |||||
| + "'. Details: " | |||||
| + ioe.getMessage(); | |||||
| throw new BuildException( msg, ioe ); | throw new BuildException( msg, ioe ); | ||||
| } | } | ||||
| finally | finally | ||||
| @@ -947,12 +944,12 @@ public class GenericDeploymentTool implements EJBDeploymentTool | |||||
| jarStream.close(); | jarStream.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Get the vendor specific name of the Jar that will be output. The | * Get the vendor specific name of the Jar that will be output. The | ||||
| * modification date of this jar will be checked against the dependent bean | * modification date of this jar will be checked against the dependent bean | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs.optional.ejb; | package org.apache.tools.ant.taskdefs.optional.ejb; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
| @@ -19,9 +20,10 @@ import java.util.jar.JarFile; | |||||
| import java.util.jar.JarOutputStream; | import java.util.jar.JarOutputStream; | ||||
| import javax.xml.parsers.SAXParser; | import javax.xml.parsers.SAXParser; | ||||
| import javax.xml.parsers.SAXParserFactory; | import javax.xml.parsers.SAXParserFactory; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import org.apache.tools.ant.taskdefs.Java; | import org.apache.tools.ant.taskdefs.Java; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
| @@ -29,27 +31,27 @@ import org.xml.sax.InputSource; | |||||
| public class WeblogicDeploymentTool extends GenericDeploymentTool | public class WeblogicDeploymentTool extends GenericDeploymentTool | ||||
| { | { | ||||
| public final static String PUBLICID_EJB11 | public final static String PUBLICID_EJB11 | ||||
| = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"; | |||||
| = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"; | |||||
| public final static String PUBLICID_EJB20 | public final static String PUBLICID_EJB20 | ||||
| = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"; | |||||
| = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"; | |||||
| public final static String PUBLICID_WEBLOGIC_EJB510 | public final static String PUBLICID_WEBLOGIC_EJB510 | ||||
| = "-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN"; | |||||
| = "-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN"; | |||||
| public final static String PUBLICID_WEBLOGIC_EJB600 | public final static String PUBLICID_WEBLOGIC_EJB600 | ||||
| = "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN"; | |||||
| = "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN"; | |||||
| protected final static String DEFAULT_WL51_EJB11_DTD_LOCATION | protected final static String DEFAULT_WL51_EJB11_DTD_LOCATION | ||||
| = "/weblogic/ejb/deployment/xml/ejb-jar.dtd"; | |||||
| = "/weblogic/ejb/deployment/xml/ejb-jar.dtd"; | |||||
| protected final static String DEFAULT_WL60_EJB11_DTD_LOCATION | protected final static String DEFAULT_WL60_EJB11_DTD_LOCATION | ||||
| = "/weblogic/ejb20/dd/xml/ejb11-jar.dtd"; | |||||
| = "/weblogic/ejb20/dd/xml/ejb11-jar.dtd"; | |||||
| protected final static String DEFAULT_WL60_EJB20_DTD_LOCATION | protected final static String DEFAULT_WL60_EJB20_DTD_LOCATION | ||||
| = "/weblogic/ejb20/dd/xml/ejb20-jar.dtd"; | |||||
| = "/weblogic/ejb20/dd/xml/ejb20-jar.dtd"; | |||||
| protected final static String DEFAULT_WL51_DTD_LOCATION | protected final static String DEFAULT_WL51_DTD_LOCATION | ||||
| = "/weblogic/ejb/deployment/xml/weblogic-ejb-jar.dtd"; | |||||
| = "/weblogic/ejb/deployment/xml/weblogic-ejb-jar.dtd"; | |||||
| protected final static String DEFAULT_WL60_51_DTD_LOCATION | protected final static String DEFAULT_WL60_51_DTD_LOCATION | ||||
| = "/weblogic/ejb20/dd/xml/weblogic510-ejb-jar.dtd"; | |||||
| = "/weblogic/ejb20/dd/xml/weblogic510-ejb-jar.dtd"; | |||||
| protected final static String DEFAULT_WL60_DTD_LOCATION | protected final static String DEFAULT_WL60_DTD_LOCATION | ||||
| = "/weblogic/ejb20/dd/xml/weblogic600-ejb-jar.dtd"; | |||||
| = "/weblogic/ejb20/dd/xml/weblogic600-ejb-jar.dtd"; | |||||
| protected final static String DEFAULT_COMPILER = "default"; | protected final static String DEFAULT_COMPILER = "default"; | ||||
| @@ -235,7 +237,6 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| this.alwaysRebuild = rebuild; | this.alwaysRebuild = rebuild; | ||||
| } | } | ||||
| /** | /** | ||||
| * Setter used to store the suffix for the generated weblogic jar file. | * Setter used to store the suffix for the generated weblogic jar file. | ||||
| * | * | ||||
| @@ -262,7 +263,6 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| this.weblogicDTD = inString; | this.weblogicDTD = inString; | ||||
| } | } | ||||
| /** | /** | ||||
| * Setter used to store the location of the ejb-jar DTD. This can be a file | * Setter used to store the location of the ejb-jar DTD. This can be a file | ||||
| * on the system or a resource on the classpath. | * on the system or a resource on the classpath. | ||||
| @@ -306,10 +306,10 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| /** | /** | ||||
| * Called to validate that the tool parameters have been configured. | * Called to validate that the tool parameters have been configured. | ||||
| * | * | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void validateConfigured() | public void validateConfigured() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| super.validateConfigured(); | super.validateConfigured(); | ||||
| } | } | ||||
| @@ -323,7 +323,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| * @exception IOException Description of Exception | * @exception IOException Description of Exception | ||||
| */ | */ | ||||
| protected ClassLoader getClassLoaderFromJar( File classjar ) | protected ClassLoader getClassLoaderFromJar( File classjar ) | ||||
| throws IOException | |||||
| throws IOException, TaskException | |||||
| { | { | ||||
| Path lookupPath = new Path( getTask().getProject() ); | Path lookupPath = new Path( getTask().getProject() ); | ||||
| lookupPath.setLocation( classjar ); | lookupPath.setLocation( classjar ); | ||||
| @@ -350,7 +350,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| String fileNameWithMETA = currentText; | String fileNameWithMETA = currentText; | ||||
| //trim the META_INF\ off of the file name | //trim the META_INF\ off of the file name | ||||
| String fileName = fileNameWithMETA.substring( META_DIR.length(), | String fileName = fileNameWithMETA.substring( META_DIR.length(), | ||||
| fileNameWithMETA.length() ); | |||||
| fileNameWithMETA.length() ); | |||||
| File descriptorFile = new File( srcDir, fileName ); | File descriptorFile = new File( srcDir, fileName ); | ||||
| ejbFiles.put( fileNameWithMETA, descriptorFile ); | ejbFiles.put( fileNameWithMETA, descriptorFile ); | ||||
| @@ -364,15 +364,14 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| handler.registerDTD( PUBLICID_WEBLOGIC_EJB510, weblogicDTD ); | handler.registerDTD( PUBLICID_WEBLOGIC_EJB510, weblogicDTD ); | ||||
| handler.registerDTD( PUBLICID_WEBLOGIC_EJB600, weblogicDTD ); | handler.registerDTD( PUBLICID_WEBLOGIC_EJB600, weblogicDTD ); | ||||
| for( Iterator i = getConfig().dtdLocations.iterator(); i.hasNext(); ) | |||||
| for( Iterator i = getConfig().dtdLocations.iterator(); i.hasNext(); ) | |||||
| { | { | ||||
| EjbJar.DTDLocation dtdLocation = ( EjbJar.DTDLocation )i.next(); | |||||
| EjbJar.DTDLocation dtdLocation = (EjbJar.DTDLocation)i.next(); | |||||
| handler.registerDTD( dtdLocation.getPublicId(), dtdLocation.getLocation() ); | handler.registerDTD( dtdLocation.getPublicId(), dtdLocation.getLocation() ); | ||||
| } | } | ||||
| return handler; | return handler; | ||||
| } | } | ||||
| /** | /** | ||||
| * Helper method to check to see if a weblogic EBJ1.1 jar needs to be | * Helper method to check to see if a weblogic EBJ1.1 jar needs to be | ||||
| * rebuilt using ejbc. Called from writeJar it sees if the "Bean" classes | * rebuilt using ejbc. Called from writeJar it sees if the "Bean" classes | ||||
| @@ -398,6 +397,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| * @return The RebuildRequired value | * @return The RebuildRequired value | ||||
| */ | */ | ||||
| protected boolean isRebuildRequired( File genericJarFile, File weblogicJarFile ) | protected boolean isRebuildRequired( File genericJarFile, File weblogicJarFile ) | ||||
| throws TaskException | |||||
| { | { | ||||
| boolean rebuild = false; | boolean rebuild = false; | ||||
| @@ -409,10 +409,10 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| try | try | ||||
| { | { | ||||
| log( "Checking if weblogic Jar needs to be rebuilt for jar " + weblogicJarFile.getName(), | log( "Checking if weblogic Jar needs to be rebuilt for jar " + weblogicJarFile.getName(), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| // Only go forward if the generic and the weblogic file both exist | // Only go forward if the generic and the weblogic file both exist | ||||
| if( genericJarFile.exists() && genericJarFile.isFile() | if( genericJarFile.exists() && genericJarFile.isFile() | ||||
| && weblogicJarFile.exists() && weblogicJarFile.isFile() ) | |||||
| && weblogicJarFile.exists() && weblogicJarFile.isFile() ) | |||||
| { | { | ||||
| //open jar files | //open jar files | ||||
| genericJar = new JarFile( genericJarFile ); | genericJar = new JarFile( genericJarFile ); | ||||
| @@ -423,31 +423,31 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| Hashtable replaceEntries = new Hashtable(); | Hashtable replaceEntries = new Hashtable(); | ||||
| //get the list of generic jar entries | //get the list of generic jar entries | ||||
| for( Enumeration e = genericJar.entries(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = genericJar.entries(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| JarEntry je = ( JarEntry )e.nextElement(); | |||||
| JarEntry je = (JarEntry)e.nextElement(); | |||||
| genericEntries.put( je.getName().replace( '\\', '/' ), je ); | genericEntries.put( je.getName().replace( '\\', '/' ), je ); | ||||
| } | } | ||||
| //get the list of weblogic jar entries | //get the list of weblogic jar entries | ||||
| for( Enumeration e = wlJar.entries(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = wlJar.entries(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| JarEntry je = ( JarEntry )e.nextElement(); | |||||
| JarEntry je = (JarEntry)e.nextElement(); | |||||
| wlEntries.put( je.getName(), je ); | wlEntries.put( je.getName(), je ); | ||||
| } | } | ||||
| //Cycle Through generic and make sure its in weblogic | //Cycle Through generic and make sure its in weblogic | ||||
| ClassLoader genericLoader = getClassLoaderFromJar( genericJarFile ); | ClassLoader genericLoader = getClassLoaderFromJar( genericJarFile ); | ||||
| for( Enumeration e = genericEntries.keys(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = genericEntries.keys(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| String filepath = ( String )e.nextElement(); | |||||
| String filepath = (String)e.nextElement(); | |||||
| if( wlEntries.containsKey( filepath ) ) | if( wlEntries.containsKey( filepath ) ) | ||||
| {// File name/path match | {// File name/path match | ||||
| // Check files see if same | // Check files see if same | ||||
| JarEntry genericEntry = ( JarEntry )genericEntries.get( filepath ); | |||||
| JarEntry wlEntry = ( JarEntry )wlEntries.get( filepath ); | |||||
| JarEntry genericEntry = (JarEntry)genericEntries.get( filepath ); | |||||
| JarEntry wlEntry = (JarEntry)wlEntries.get( filepath ); | |||||
| if( ( genericEntry.getCrc() != wlEntry.getCrc() ) || // Crc's Match | if( ( genericEntry.getCrc() != wlEntry.getCrc() ) || // Crc's Match | ||||
| ( genericEntry.getSize() != wlEntry.getSize() ) ) | |||||
| ( genericEntry.getSize() != wlEntry.getSize() ) ) | |||||
| {// Size Match | {// Size Match | ||||
| if( genericEntry.getName().endsWith( ".class" ) ) | if( genericEntry.getName().endsWith( ".class" ) ) | ||||
| @@ -504,12 +504,12 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| newJarStream.setLevel( 0 ); | newJarStream.setLevel( 0 ); | ||||
| //Copy files from old weblogic jar | //Copy files from old weblogic jar | ||||
| for( Enumeration e = wlEntries.elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = wlEntries.elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| byte[] buffer = new byte[1024]; | |||||
| byte[] buffer = new byte[ 1024 ]; | |||||
| int bytesRead; | int bytesRead; | ||||
| InputStream is; | InputStream is; | ||||
| JarEntry je = ( JarEntry )e.nextElement(); | |||||
| JarEntry je = (JarEntry)e.nextElement(); | |||||
| if( je.getCompressedSize() == -1 || | if( je.getCompressedSize() == -1 || | ||||
| je.getCompressedSize() == je.getSize() ) | je.getCompressedSize() == je.getSize() ) | ||||
| { | { | ||||
| @@ -525,7 +525,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| { | { | ||||
| log( "Updating Bean class from generic Jar " + je.getName(), Project.MSG_VERBOSE ); | log( "Updating Bean class from generic Jar " + je.getName(), Project.MSG_VERBOSE ); | ||||
| // Use the entry from the generic jar | // Use the entry from the generic jar | ||||
| je = ( JarEntry )replaceEntries.get( je.getName() ); | |||||
| je = (JarEntry)replaceEntries.get( je.getName() ); | |||||
| is = genericJar.getInputStream( je ); | is = genericJar.getInputStream( je ); | ||||
| } | } | ||||
| else | else | ||||
| @@ -555,16 +555,16 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| catch( ClassNotFoundException cnfe ) | catch( ClassNotFoundException cnfe ) | ||||
| { | { | ||||
| String cnfmsg = "ClassNotFoundException while processing ejb-jar file" | String cnfmsg = "ClassNotFoundException while processing ejb-jar file" | ||||
| + ". Details: " | |||||
| + cnfe.getMessage(); | |||||
| throw new BuildException( cnfmsg, cnfe ); | |||||
| + ". Details: " | |||||
| + cnfe.getMessage(); | |||||
| throw new TaskException( cnfmsg, cnfe ); | |||||
| } | } | ||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "IOException while processing ejb-jar file " | String msg = "IOException while processing ejb-jar file " | ||||
| + ". Details: " | |||||
| + ioe.getMessage(); | |||||
| throw new BuildException( msg, ioe ); | |||||
| + ". Details: " | |||||
| + ioe.getMessage(); | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -576,7 +576,8 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| genericJar.close(); | genericJar.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( wlJar != null ) | if( wlJar != null ) | ||||
| @@ -586,7 +587,8 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| wlJar.close(); | wlJar.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| } | } | ||||
| if( newJarStream != null ) | if( newJarStream != null ) | ||||
| @@ -596,7 +598,8 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| newJarStream.close(); | newJarStream.close(); | ||||
| } | } | ||||
| catch( IOException closeException ) | catch( IOException closeException ) | ||||
| {} | |||||
| { | |||||
| } | |||||
| weblogicJarFile.delete(); | weblogicJarFile.delete(); | ||||
| newWLJarFile.renameTo( weblogicJarFile ); | newWLJarFile.renameTo( weblogicJarFile ); | ||||
| @@ -623,12 +626,12 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| if( weblogicDD.exists() ) | if( weblogicDD.exists() ) | ||||
| { | { | ||||
| ejbFiles.put( META_DIR + WL_DD, | ejbFiles.put( META_DIR + WL_DD, | ||||
| weblogicDD ); | |||||
| weblogicDD ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| log( "Unable to locate weblogic deployment descriptor. It was expected to be in " + | log( "Unable to locate weblogic deployment descriptor. It was expected to be in " + | ||||
| weblogicDD.getPath(), Project.MSG_WARN ); | |||||
| weblogicDD.getPath(), Project.MSG_WARN ); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -636,14 +639,14 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| { | { | ||||
| log( "The old method for locating CMP files has been DEPRECATED.", Project.MSG_VERBOSE ); | log( "The old method for locating CMP files has been DEPRECATED.", Project.MSG_VERBOSE ); | ||||
| log( "Please adjust your weblogic descriptor and set newCMP=\"true\" " + | log( "Please adjust your weblogic descriptor and set newCMP=\"true\" " + | ||||
| "to use the new CMP descriptor inclusion mechanism. ", Project.MSG_VERBOSE ); | |||||
| "to use the new CMP descriptor inclusion mechanism. ", Project.MSG_VERBOSE ); | |||||
| // The the weblogic cmp deployment descriptor | // The the weblogic cmp deployment descriptor | ||||
| File weblogicCMPDD = new File( getConfig().descriptorDir, ddPrefix + WL_CMP_DD ); | File weblogicCMPDD = new File( getConfig().descriptorDir, ddPrefix + WL_CMP_DD ); | ||||
| if( weblogicCMPDD.exists() ) | if( weblogicCMPDD.exists() ) | ||||
| { | { | ||||
| ejbFiles.put( META_DIR + WL_CMP_DD, | ejbFiles.put( META_DIR + WL_CMP_DD, | ||||
| weblogicCMPDD ); | |||||
| weblogicCMPDD ); | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| @@ -654,28 +657,28 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| // mapping tool descriptors. | // mapping tool descriptors. | ||||
| try | try | ||||
| { | { | ||||
| File ejbDescriptor = ( File )ejbFiles.get( META_DIR + EJB_DD ); | |||||
| File ejbDescriptor = (File)ejbFiles.get( META_DIR + EJB_DD ); | |||||
| SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); | SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); | ||||
| saxParserFactory.setValidating( true ); | saxParserFactory.setValidating( true ); | ||||
| SAXParser saxParser = saxParserFactory.newSAXParser(); | SAXParser saxParser = saxParserFactory.newSAXParser(); | ||||
| DescriptorHandler handler = getWeblogicDescriptorHandler( ejbDescriptor.getParentFile() ); | DescriptorHandler handler = getWeblogicDescriptorHandler( ejbDescriptor.getParentFile() ); | ||||
| saxParser.parse( new InputSource | saxParser.parse( new InputSource | ||||
| ( new FileInputStream | ( new FileInputStream | ||||
| ( weblogicDD ) ), | |||||
| handler ); | |||||
| ( weblogicDD ) ), | |||||
| handler ); | |||||
| Hashtable ht = handler.getFiles(); | Hashtable ht = handler.getFiles(); | ||||
| Enumeration e = ht.keys(); | Enumeration e = ht.keys(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| String key = ( String )e.nextElement(); | |||||
| String key = (String)e.nextElement(); | |||||
| ejbFiles.put( key, ht.get( key ) ); | ejbFiles.put( key, ht.get( key ) ); | ||||
| } | } | ||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| String msg = "Exception while adding Vendor specific files: " + e.toString(); | String msg = "Exception while adding Vendor specific files: " + e.toString(); | ||||
| throw new BuildException( msg, e ); | |||||
| throw new TaskException( msg, e ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -698,11 +701,11 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| * @param jarFile Description of Parameter | * @param jarFile Description of Parameter | ||||
| * @param files Description of Parameter | * @param files Description of Parameter | ||||
| * @param publicId Description of Parameter | * @param publicId Description of Parameter | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| protected void writeJar( String baseName, File jarFile, Hashtable files, | protected void writeJar( String baseName, File jarFile, Hashtable files, | ||||
| String publicId ) | String publicId ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| // need to create a generic jar first. | // need to create a generic jar first. | ||||
| File genericJarFile = super.getVendorOutputJarFile( baseName ); | File genericJarFile = super.getVendorOutputJarFile( baseName ); | ||||
| @@ -715,7 +718,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| if( !keepGeneric ) | if( !keepGeneric ) | ||||
| { | { | ||||
| log( "deleting generic jar " + genericJarFile.toString(), | log( "deleting generic jar " + genericJarFile.toString(), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| genericJarFile.delete(); | genericJarFile.delete(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -751,7 +754,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| getTask().getProject().copyFile( sourceJar, destJar ); | |||||
| FileUtils.newFileUtils().copyFile( sourceJar, destJar ); | |||||
| if( !keepgenerated ) | if( !keepgenerated ) | ||||
| { | { | ||||
| sourceJar.delete(); | sourceJar.delete(); | ||||
| @@ -760,7 +763,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| } | } | ||||
| catch( IOException e ) | catch( IOException e ) | ||||
| { | { | ||||
| throw new BuildException( "Unable to write EJB jar", e ); | |||||
| throw new TaskException( "Unable to write EJB jar", e ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -768,7 +771,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| try | try | ||||
| { | { | ||||
| javaTask = ( Java )getTask().getProject().createTask( "java" ); | |||||
| javaTask = (Java)getTask().getProject().createTask( "java" ); | |||||
| javaTask.setTaskName( "ejbc" ); | javaTask.setTaskName( "ejbc" ); | ||||
| if( getJvmDebugLevel() != null ) | if( getJvmDebugLevel() != null ) | ||||
| @@ -835,18 +838,18 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| } | } | ||||
| log( "Calling " + ejbcClassName + " for " + sourceJar.toString(), | log( "Calling " + ejbcClassName + " for " + sourceJar.toString(), | ||||
| Project.MSG_VERBOSE ); | |||||
| Project.MSG_VERBOSE ); | |||||
| if( javaTask.executeJava() != 0 ) | if( javaTask.executeJava() != 0 ) | ||||
| { | { | ||||
| throw new BuildException( "Ejbc reported an error" ); | |||||
| throw new TaskException( "Ejbc reported an error" ); | |||||
| } | } | ||||
| } | } | ||||
| catch( Exception e ) | catch( Exception e ) | ||||
| { | { | ||||
| // Have to catch this because of the semantics of calling main() | // Have to catch this because of the semantics of calling main() | ||||
| String msg = "Exception while calling " + ejbcClassName + ". Details: " + e.toString(); | String msg = "Exception while calling " + ejbcClassName + ". Details: " + e.toString(); | ||||
| throw new BuildException( msg, e ); | |||||
| throw new TaskException( msg, e ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,12 +6,13 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| /** | /** | ||||
| * Commandline objects help handling command lines specifying processes to | * Commandline objects help handling command lines specifying processes to | ||||
| * execute. The class can be used to define a command line as nested elements or | * execute. The class can be used to define a command line as nested elements or | ||||
| @@ -44,10 +45,10 @@ public class Commandline implements Cloneable | |||||
| String[] tmp = translateCommandline( to_process ); | String[] tmp = translateCommandline( to_process ); | ||||
| if( tmp != null && tmp.length > 0 ) | if( tmp != null && tmp.length > 0 ) | ||||
| { | { | ||||
| setExecutable( tmp[0] ); | |||||
| setExecutable( tmp[ 0 ] ); | |||||
| for( int i = 1; i < tmp.length; i++ ) | for( int i = 1; i < tmp.length; i++ ) | ||||
| { | { | ||||
| createArgument().setValue( tmp[i] ); | |||||
| createArgument().setValue( tmp[ i ] ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -68,6 +69,7 @@ public class Commandline implements Cloneable | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public static String quoteArgument( String argument ) | public static String quoteArgument( String argument ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( argument.indexOf( "\"" ) > -1 ) | if( argument.indexOf( "\"" ) > -1 ) | ||||
| { | { | ||||
| @@ -104,7 +106,15 @@ public class Commandline implements Cloneable | |||||
| { | { | ||||
| result.append( ' ' ); | result.append( ' ' ); | ||||
| } | } | ||||
| result.append( quoteArgument( line[i] ) ); | |||||
| try | |||||
| { | |||||
| result.append( quoteArgument( line[ i ] ) ); | |||||
| } | |||||
| catch( TaskException e ) | |||||
| { | |||||
| } | |||||
| } | } | ||||
| return result.toString(); | return result.toString(); | ||||
| } | } | ||||
| @@ -113,7 +123,7 @@ public class Commandline implements Cloneable | |||||
| { | { | ||||
| if( to_process == null || to_process.length() == 0 ) | if( to_process == null || to_process.length() == 0 ) | ||||
| { | { | ||||
| return new String[0]; | |||||
| return new String[ 0 ]; | |||||
| } | } | ||||
| // parse with a simple finite state machine | // parse with a simple finite state machine | ||||
| @@ -129,50 +139,50 @@ public class Commandline implements Cloneable | |||||
| while( tok.hasMoreTokens() ) | while( tok.hasMoreTokens() ) | ||||
| { | { | ||||
| String nextTok = tok.nextToken(); | String nextTok = tok.nextToken(); | ||||
| switch ( state ) | |||||
| switch( state ) | |||||
| { | { | ||||
| case inQuote: | |||||
| if( "\'".equals( nextTok ) ) | |||||
| { | |||||
| state = normal; | |||||
| } | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| case inDoubleQuote: | |||||
| if( "\"".equals( nextTok ) ) | |||||
| { | |||||
| state = normal; | |||||
| } | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| default: | |||||
| if( "\'".equals( nextTok ) ) | |||||
| { | |||||
| state = inQuote; | |||||
| } | |||||
| else if( "\"".equals( nextTok ) ) | |||||
| { | |||||
| state = inDoubleQuote; | |||||
| } | |||||
| else if( " ".equals( nextTok ) ) | |||||
| { | |||||
| if( current.length() != 0 ) | |||||
| case inQuote: | |||||
| if( "\'".equals( nextTok ) ) | |||||
| { | { | ||||
| v.addElement( current.toString() ); | |||||
| current.setLength( 0 ); | |||||
| state = normal; | |||||
| } | } | ||||
| } | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| case inDoubleQuote: | |||||
| if( "\"".equals( nextTok ) ) | |||||
| { | |||||
| state = normal; | |||||
| } | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| default: | |||||
| if( "\'".equals( nextTok ) ) | |||||
| { | |||||
| state = inQuote; | |||||
| } | |||||
| else if( "\"".equals( nextTok ) ) | |||||
| { | |||||
| state = inDoubleQuote; | |||||
| } | |||||
| else if( " ".equals( nextTok ) ) | |||||
| { | |||||
| if( current.length() != 0 ) | |||||
| { | |||||
| v.addElement( current.toString() ); | |||||
| current.setLength( 0 ); | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| current.append( nextTok ); | |||||
| } | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| @@ -186,12 +196,11 @@ public class Commandline implements Cloneable | |||||
| throw new BuildException( "unbalanced quotes in " + to_process ); | throw new BuildException( "unbalanced quotes in " + to_process ); | ||||
| } | } | ||||
| String[] args = new String[v.size()]; | |||||
| String[] args = new String[ v.size() ]; | |||||
| v.copyInto( args ); | v.copyInto( args ); | ||||
| return args; | return args; | ||||
| } | } | ||||
| /** | /** | ||||
| * Sets the executable to run. | * Sets the executable to run. | ||||
| * | * | ||||
| @@ -205,7 +214,6 @@ public class Commandline implements Cloneable | |||||
| .replace( '\\', File.separatorChar ); | .replace( '\\', File.separatorChar ); | ||||
| } | } | ||||
| /** | /** | ||||
| * Returns all arguments defined by <code>addLine</code>, <code>addValue</code> | * Returns all arguments defined by <code>addLine</code>, <code>addValue</code> | ||||
| * or the argument object. | * or the argument object. | ||||
| @@ -217,15 +225,15 @@ public class Commandline implements Cloneable | |||||
| Vector result = new Vector( arguments.size() * 2 ); | Vector result = new Vector( arguments.size() * 2 ); | ||||
| for( int i = 0; i < arguments.size(); i++ ) | for( int i = 0; i < arguments.size(); i++ ) | ||||
| { | { | ||||
| Argument arg = ( Argument )arguments.elementAt( i ); | |||||
| Argument arg = (Argument)arguments.elementAt( i ); | |||||
| String[] s = arg.getParts(); | String[] s = arg.getParts(); | ||||
| for( int j = 0; j < s.length; j++ ) | for( int j = 0; j < s.length; j++ ) | ||||
| { | { | ||||
| result.addElement( s[j] ); | |||||
| result.addElement( s[ j ] ); | |||||
| } | } | ||||
| } | } | ||||
| String[] res = new String[result.size()]; | |||||
| String[] res = new String[ result.size() ]; | |||||
| result.copyInto( res ); | result.copyInto( res ); | ||||
| return res; | return res; | ||||
| } | } | ||||
| @@ -240,24 +248,22 @@ public class Commandline implements Cloneable | |||||
| final String[] args = getArguments(); | final String[] args = getArguments(); | ||||
| if( executable == null ) | if( executable == null ) | ||||
| return args; | return args; | ||||
| final String[] result = new String[args.length + 1]; | |||||
| result[0] = executable; | |||||
| final String[] result = new String[ args.length + 1 ]; | |||||
| result[ 0 ] = executable; | |||||
| System.arraycopy( args, 0, result, 1, args.length ); | System.arraycopy( args, 0, result, 1, args.length ); | ||||
| return result; | return result; | ||||
| } | } | ||||
| public String getExecutable() | public String getExecutable() | ||||
| { | { | ||||
| return executable; | return executable; | ||||
| } | } | ||||
| public void addArguments( String[] line ) | public void addArguments( String[] line ) | ||||
| { | { | ||||
| for( int i = 0; i < line.length; i++ ) | for( int i = 0; i < line.length; i++ ) | ||||
| { | { | ||||
| createArgument().setValue( line[i] ); | |||||
| createArgument().setValue( line[ i ] ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -318,7 +324,6 @@ public class Commandline implements Cloneable | |||||
| return getCommandline().length; | return getCommandline().length; | ||||
| } | } | ||||
| public String toString() | public String toString() | ||||
| { | { | ||||
| return toString( getCommandline() ); | return toString( getCommandline() ); | ||||
| @@ -421,7 +426,7 @@ public class Commandline implements Cloneable | |||||
| realPos = ( executable == null ? 0 : 1 ); | realPos = ( executable == null ? 0 : 1 ); | ||||
| for( int i = 0; i < position; i++ ) | for( int i = 0; i < position; i++ ) | ||||
| { | { | ||||
| Argument arg = ( Argument )arguments.elementAt( i ); | |||||
| Argument arg = (Argument)arguments.elementAt( i ); | |||||
| realPos += arg.getParts().length; | realPos += arg.getParts().length; | ||||
| } | } | ||||
| } | } | ||||
| @@ -82,7 +82,7 @@ public class FileSet extends DataType implements Cloneable | |||||
| } | } | ||||
| public void setDir( File dir ) | public void setDir( File dir ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -113,10 +113,10 @@ public class FileSet extends DataType implements Cloneable | |||||
| * Sets the name of the file containing the includes patterns. | * Sets the name of the file containing the includes patterns. | ||||
| * | * | ||||
| * @param excl The file to fetch the exclude patterns from. | * @param excl The file to fetch the exclude patterns from. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setExcludesfile( File excl ) | public void setExcludesfile( File excl ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -147,10 +147,10 @@ public class FileSet extends DataType implements Cloneable | |||||
| * Sets the name of the file containing the includes patterns. | * Sets the name of the file containing the includes patterns. | ||||
| * | * | ||||
| * @param incl The file to fetch the include patterns from. | * @param incl The file to fetch the include patterns from. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setIncludesfile( File incl ) | public void setIncludesfile( File incl ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -168,7 +168,7 @@ public class FileSet extends DataType implements Cloneable | |||||
| * if you make it a reference.</p> | * if you make it a reference.</p> | ||||
| * | * | ||||
| * @param r The new Refid value | * @param r The new Refid value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setRefid( Reference r ) | public void setRefid( Reference r ) | ||||
| throws TaskException | throws TaskException | ||||
| @@ -6,12 +6,13 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import java.util.Stack; | import java.util.Stack; | ||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.util.FileNameMapper; | import org.apache.tools.ant.util.FileNameMapper; | ||||
| import org.apache.myrmidon.api.TaskException; | |||||
| /** | /** | ||||
| * Element to define a FileNameMapper. | * Element to define a FileNameMapper. | ||||
| @@ -106,10 +107,10 @@ public class Mapper extends DataType implements Cloneable | |||||
| * You must not set any other attribute if you make it a reference.</p> | * You must not set any other attribute if you make it a reference.</p> | ||||
| * | * | ||||
| * @param r The new Refid value | * @param r The new Refid value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setRefid( Reference r ) | public void setRefid( Reference r ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( type != null || from != null || to != null ) | if( type != null || from != null || to != null ) | ||||
| { | { | ||||
| @@ -150,10 +151,10 @@ public class Mapper extends DataType implements Cloneable | |||||
| * Returns a fully configured FileNameMapper implementation. | * Returns a fully configured FileNameMapper implementation. | ||||
| * | * | ||||
| * @return The Implementation value | * @return The Implementation value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public FileNameMapper getImplementation() | public FileNameMapper getImplementation() | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -162,12 +163,12 @@ public class Mapper extends DataType implements Cloneable | |||||
| if( type == null && classname == null ) | if( type == null && classname == null ) | ||||
| { | { | ||||
| throw new BuildException( "one of the attributes type or classname is required" ); | |||||
| throw new TaskException( "one of the attributes type or classname is required" ); | |||||
| } | } | ||||
| if( type != null && classname != null ) | if( type != null && classname != null ) | ||||
| { | { | ||||
| throw new BuildException( "must not specify both type and classname attribute" ); | |||||
| throw new TaskException( "must not specify both type and classname attribute" ); | |||||
| } | } | ||||
| try | try | ||||
| @@ -185,23 +186,23 @@ public class Mapper extends DataType implements Cloneable | |||||
| else | else | ||||
| { | { | ||||
| AntClassLoader al = new AntClassLoader( getProject(), | AntClassLoader al = new AntClassLoader( getProject(), | ||||
| classpath ); | |||||
| classpath ); | |||||
| c = al.loadClass( classname ); | c = al.loadClass( classname ); | ||||
| AntClassLoader.initializeClass( c ); | AntClassLoader.initializeClass( c ); | ||||
| } | } | ||||
| FileNameMapper m = ( FileNameMapper )c.newInstance(); | |||||
| FileNameMapper m = (FileNameMapper)c.newInstance(); | |||||
| m.setFrom( from ); | m.setFrom( from ); | ||||
| m.setTo( to ); | m.setTo( to ); | ||||
| return m; | return m; | ||||
| } | } | ||||
| catch( BuildException be ) | |||||
| catch( TaskException be ) | |||||
| { | { | ||||
| throw be; | throw be; | ||||
| } | } | ||||
| catch( Throwable t ) | catch( Throwable t ) | ||||
| { | { | ||||
| throw new BuildException( "Error", t ); | |||||
| throw new TaskException( "Error", t ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| @@ -249,11 +250,11 @@ public class Mapper extends DataType implements Cloneable | |||||
| if( !( o instanceof Mapper ) ) | if( !( o instanceof Mapper ) ) | ||||
| { | { | ||||
| String msg = ref.getRefId() + " doesn\'t denote a mapper"; | String msg = ref.getRefId() + " doesn\'t denote a mapper"; | ||||
| throw new BuildException( msg ); | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| return ( Mapper )o; | |||||
| return (Mapper)o; | |||||
| } | } | ||||
| } | } | ||||
| @@ -270,15 +271,15 @@ public class Mapper extends DataType implements Cloneable | |||||
| { | { | ||||
| implementations = new Properties(); | implementations = new Properties(); | ||||
| implementations.put( "identity", | implementations.put( "identity", | ||||
| "org.apache.tools.ant.util.IdentityMapper" ); | |||||
| "org.apache.tools.ant.util.IdentityMapper" ); | |||||
| implementations.put( "flatten", | implementations.put( "flatten", | ||||
| "org.apache.tools.ant.util.FlatFileNameMapper" ); | |||||
| "org.apache.tools.ant.util.FlatFileNameMapper" ); | |||||
| implementations.put( "glob", | implementations.put( "glob", | ||||
| "org.apache.tools.ant.util.GlobPatternMapper" ); | |||||
| "org.apache.tools.ant.util.GlobPatternMapper" ); | |||||
| implementations.put( "merge", | implementations.put( "merge", | ||||
| "org.apache.tools.ant.util.MergingMapper" ); | |||||
| "org.apache.tools.ant.util.MergingMapper" ); | |||||
| implementations.put( "regexp", | implementations.put( "regexp", | ||||
| "org.apache.tools.ant.util.RegexpPatternMapper" ); | |||||
| "org.apache.tools.ant.util.RegexpPatternMapper" ); | |||||
| } | } | ||||
| public String getImplementation() | public String getImplementation() | ||||
| @@ -6,6 +6,7 @@ | |||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| @@ -14,9 +15,8 @@ import java.util.Enumeration; | |||||
| import java.util.Stack; | import java.util.Stack; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.ProjectHelper; | |||||
| /** | /** | ||||
| * Named collection of include/exclude tags. <p> | * Named collection of include/exclude tags. <p> | ||||
| @@ -50,6 +50,7 @@ public class PatternSet extends DataType | |||||
| * @param excludes the string containing the exclude patterns | * @param excludes the string containing the exclude patterns | ||||
| */ | */ | ||||
| public void setExcludes( String excludes ) | public void setExcludes( String excludes ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -69,10 +70,10 @@ public class PatternSet extends DataType | |||||
| * Sets the name of the file containing the excludes patterns. | * Sets the name of the file containing the excludes patterns. | ||||
| * | * | ||||
| * @param excludesFile The file to fetch the exclude patterns from. | * @param excludesFile The file to fetch the exclude patterns from. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setExcludesfile( File excludesFile ) | public void setExcludesfile( File excludesFile ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -88,6 +89,7 @@ public class PatternSet extends DataType | |||||
| * @param includes the string containing the include patterns | * @param includes the string containing the include patterns | ||||
| */ | */ | ||||
| public void setIncludes( String includes ) | public void setIncludes( String includes ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -107,10 +109,10 @@ public class PatternSet extends DataType | |||||
| * Sets the name of the file containing the includes patterns. | * Sets the name of the file containing the includes patterns. | ||||
| * | * | ||||
| * @param includesFile The file to fetch the include patterns from. | * @param includesFile The file to fetch the include patterns from. | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setIncludesfile( File includesFile ) | public void setIncludesfile( File includesFile ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -127,10 +129,10 @@ public class PatternSet extends DataType | |||||
| * if you make it a reference.</p> | * if you make it a reference.</p> | ||||
| * | * | ||||
| * @param r The new Refid value | * @param r The new Refid value | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| public void setRefid( Reference r ) | public void setRefid( Reference r ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| if( !includeList.isEmpty() || !excludeList.isEmpty() ) | if( !includeList.isEmpty() || !excludeList.isEmpty() ) | ||||
| { | { | ||||
| @@ -146,6 +148,7 @@ public class PatternSet extends DataType | |||||
| * @return The ExcludePatterns value | * @return The ExcludePatterns value | ||||
| */ | */ | ||||
| public String[] getExcludePatterns( Project p ) | public String[] getExcludePatterns( Project p ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -165,6 +168,7 @@ public class PatternSet extends DataType | |||||
| * @return The IncludePatterns value | * @return The IncludePatterns value | ||||
| */ | */ | ||||
| public String[] getIncludePatterns( Project p ) | public String[] getIncludePatterns( Project p ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -184,10 +188,11 @@ public class PatternSet extends DataType | |||||
| * @param p Description of Parameter | * @param p Description of Parameter | ||||
| */ | */ | ||||
| public void append( PatternSet other, Project p ) | public void append( PatternSet other, Project p ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| throw new BuildException( "Cannot append to a reference" ); | |||||
| throw new TaskException( "Cannot append to a reference" ); | |||||
| } | } | ||||
| String[] incl = other.getIncludePatterns( p ); | String[] incl = other.getIncludePatterns( p ); | ||||
| @@ -195,7 +200,7 @@ public class PatternSet extends DataType | |||||
| { | { | ||||
| for( int i = 0; i < incl.length; i++ ) | for( int i = 0; i < incl.length; i++ ) | ||||
| { | { | ||||
| createInclude().setName( incl[i] ); | |||||
| createInclude().setName( incl[ i ] ); | |||||
| } | } | ||||
| } | } | ||||
| @@ -204,7 +209,7 @@ public class PatternSet extends DataType | |||||
| { | { | ||||
| for( int i = 0; i < excl.length; i++ ) | for( int i = 0; i < excl.length; i++ ) | ||||
| { | { | ||||
| createExclude().setName( excl[i] ); | |||||
| createExclude().setName( excl[ i ] ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -215,6 +220,7 @@ public class PatternSet extends DataType | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public NameEntry createExclude() | public NameEntry createExclude() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -229,6 +235,7 @@ public class PatternSet extends DataType | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public NameEntry createExcludesFile() | public NameEntry createExcludesFile() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -243,6 +250,7 @@ public class PatternSet extends DataType | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public NameEntry createInclude() | public NameEntry createInclude() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -257,6 +265,7 @@ public class PatternSet extends DataType | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| */ | */ | ||||
| public NameEntry createIncludesFile() | public NameEntry createIncludesFile() | ||||
| throws TaskException | |||||
| { | { | ||||
| if( isReference() ) | if( isReference() ) | ||||
| { | { | ||||
| @@ -279,7 +288,7 @@ public class PatternSet extends DataType | |||||
| boolean hasPatterns() | boolean hasPatterns() | ||||
| { | { | ||||
| return includesFileList.size() > 0 || excludesFileList.size() > 0 | return includesFileList.size() > 0 || excludesFileList.size() > 0 | ||||
| || includeList.size() > 0 || excludeList.size() > 0; | |||||
| || includeList.size() > 0 || excludeList.size() > 0; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -290,6 +299,7 @@ public class PatternSet extends DataType | |||||
| * @return The Ref value | * @return The Ref value | ||||
| */ | */ | ||||
| private PatternSet getRef( Project p ) | private PatternSet getRef( Project p ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( !checked ) | if( !checked ) | ||||
| { | { | ||||
| @@ -302,11 +312,11 @@ public class PatternSet extends DataType | |||||
| if( !( o instanceof PatternSet ) ) | if( !( o instanceof PatternSet ) ) | ||||
| { | { | ||||
| String msg = ref.getRefId() + " doesn\'t denote a patternset"; | String msg = ref.getRefId() + " doesn\'t denote a patternset"; | ||||
| throw new BuildException( msg ); | |||||
| throw new TaskException( msg ); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| return ( PatternSet )o; | |||||
| return (PatternSet)o; | |||||
| } | } | ||||
| } | } | ||||
| @@ -336,9 +346,9 @@ public class PatternSet extends DataType | |||||
| return null; | return null; | ||||
| Vector tmpNames = new Vector(); | Vector tmpNames = new Vector(); | ||||
| for( Enumeration e = list.elements(); e.hasMoreElements(); ) | |||||
| for( Enumeration e = list.elements(); e.hasMoreElements(); ) | |||||
| { | { | ||||
| NameEntry ne = ( NameEntry )e.nextElement(); | |||||
| NameEntry ne = (NameEntry)e.nextElement(); | |||||
| String pattern = ne.evalName( p ); | String pattern = ne.evalName( p ); | ||||
| if( pattern != null && pattern.length() > 0 ) | if( pattern != null && pattern.length() > 0 ) | ||||
| { | { | ||||
| @@ -346,7 +356,7 @@ public class PatternSet extends DataType | |||||
| } | } | ||||
| } | } | ||||
| String result[] = new String[tmpNames.size()]; | |||||
| String result[] = new String[ tmpNames.size() ]; | |||||
| tmpNames.copyInto( result ); | tmpNames.copyInto( result ); | ||||
| return result; | return result; | ||||
| } | } | ||||
| @@ -357,21 +367,22 @@ public class PatternSet extends DataType | |||||
| * @param p Description of Parameter | * @param p Description of Parameter | ||||
| */ | */ | ||||
| private void readFiles( Project p ) | private void readFiles( Project p ) | ||||
| throws TaskException | |||||
| { | { | ||||
| if( includesFileList.size() > 0 ) | if( includesFileList.size() > 0 ) | ||||
| { | { | ||||
| Enumeration e = includesFileList.elements(); | Enumeration e = includesFileList.elements(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| NameEntry ne = ( NameEntry )e.nextElement(); | |||||
| NameEntry ne = (NameEntry)e.nextElement(); | |||||
| String fileName = ne.evalName( p ); | String fileName = ne.evalName( p ); | ||||
| if( fileName != null ) | if( fileName != null ) | ||||
| { | { | ||||
| File inclFile = resolveFile( fileName ); | File inclFile = resolveFile( fileName ); | ||||
| if( !inclFile.exists() ) | if( !inclFile.exists() ) | ||||
| throw new BuildException( "Includesfile " | |||||
| + inclFile.getAbsolutePath() | |||||
| + " not found." ); | |||||
| throw new TaskException( "Includesfile " | |||||
| + inclFile.getAbsolutePath() | |||||
| + " not found." ); | |||||
| readPatterns( inclFile, includeList, p ); | readPatterns( inclFile, includeList, p ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -383,15 +394,15 @@ public class PatternSet extends DataType | |||||
| Enumeration e = excludesFileList.elements(); | Enumeration e = excludesFileList.elements(); | ||||
| while( e.hasMoreElements() ) | while( e.hasMoreElements() ) | ||||
| { | { | ||||
| NameEntry ne = ( NameEntry )e.nextElement(); | |||||
| NameEntry ne = (NameEntry)e.nextElement(); | |||||
| String fileName = ne.evalName( p ); | String fileName = ne.evalName( p ); | ||||
| if( fileName != null ) | if( fileName != null ) | ||||
| { | { | ||||
| File exclFile = resolveFile( fileName ); | File exclFile = resolveFile( fileName ); | ||||
| if( !exclFile.exists() ) | if( !exclFile.exists() ) | ||||
| throw new BuildException( "Excludesfile " | |||||
| + exclFile.getAbsolutePath() | |||||
| + " not found." ); | |||||
| throw new TaskException( "Excludesfile " | |||||
| + exclFile.getAbsolutePath() | |||||
| + " not found." ); | |||||
| readPatterns( exclFile, excludeList, p ); | readPatterns( exclFile, excludeList, p ); | ||||
| } | } | ||||
| } | } | ||||
| @@ -406,10 +417,10 @@ public class PatternSet extends DataType | |||||
| * @param patternfile Description of Parameter | * @param patternfile Description of Parameter | ||||
| * @param patternlist Description of Parameter | * @param patternlist Description of Parameter | ||||
| * @param p Description of Parameter | * @param p Description of Parameter | ||||
| * @exception BuildException Description of Exception | |||||
| * @exception TaskException Description of Exception | |||||
| */ | */ | ||||
| private void readPatterns( File patternfile, Vector patternlist, Project p ) | private void readPatterns( File patternfile, Vector patternlist, Project p ) | ||||
| throws BuildException | |||||
| throws TaskException | |||||
| { | { | ||||
| BufferedReader patternReader = null; | BufferedReader patternReader = null; | ||||
| @@ -435,8 +446,8 @@ public class PatternSet extends DataType | |||||
| catch( IOException ioe ) | catch( IOException ioe ) | ||||
| { | { | ||||
| String msg = "An error occured while reading from pattern file: " | String msg = "An error occured while reading from pattern file: " | ||||
| + patternfile; | |||||
| throw new BuildException( msg, ioe ); | |||||
| + patternfile; | |||||
| throw new TaskException( msg, ioe ); | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||