git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274775 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -16,8 +16,8 @@ | |||
| </fileset> | |||
| </path> | |||
| <target name="prepare"> | |||
| <available classname="org.apache.velocity.anakia.AnakiaTask" | |||
| <target name="prepare"> | |||
| <available classname="org.apache.velocity.anakia.AnakiaTask" | |||
| property="AnakiaTask.present"> | |||
| <classpath refid="anakia.classpath"/> | |||
| </available> | |||
| @@ -25,7 +25,7 @@ | |||
| <target depends="prepare" name="prepare-error" unless="AnakiaTask.present"> | |||
| <echo> | |||
| AnakiaTask is not present! Please check to make sure that | |||
| AnakiaTask is not present! Please check to make sure that | |||
| velocity.jar is in your classpath. | |||
| </echo> | |||
| </target> | |||
| @@ -34,7 +34,7 @@ | |||
| <taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask"> | |||
| <classpath refid="anakia.classpath"/> | |||
| </taskdef> | |||
| <anakia basedir="${docs.src}" destdir="${docs.dest}/" | |||
| extension=".html" style="./site.vsl" | |||
| projectFile="${project.file}" | |||
| @@ -45,12 +45,12 @@ | |||
| velocityPropertiesFile="${velocity.props}"> | |||
| </anakia> | |||
| </target> | |||
| <target name="javadocs"> | |||
| <ant antfile="build.xml" target="dist_javadocs"> | |||
| <property name="dist.javadocs" value="${docs.dest}/manual/api" /> | |||
| </ant> | |||
| </target> | |||
| <target name="all" depends="docs, javadocs"/> | |||
| </project> | |||
| @@ -64,7 +64,7 @@ public class ExitException extends SecurityException { | |||
| /** Status code */ | |||
| private int status; | |||
| /** | |||
| * Constructs an exit exception. | |||
| * @param status the status code returned via System.exit() | |||
| @@ -54,8 +54,8 @@ | |||
| package org.apache.tools.ant; | |||
| /** | |||
| * Magic names used within Ant. | |||
| * | |||
| * Magic names used within Ant. | |||
| * | |||
| * Not all magic names are here yet. | |||
| * | |||
| * @author Conor MacNeill | |||
| @@ -64,5 +64,9 @@ package org.apache.tools.ant; | |||
| public class MagicNames { | |||
| /** The name of the script repository used by the script repo task */ | |||
| public static final String SCRIPT_REPOSITORY = "org.apache.ant.scriptrepo"; | |||
| /** The name of the reference to the System Class Loader */ | |||
| public static final String SYSTEM_LOADER_REF = "ant.coreLoader"; | |||
| } | |||
| @@ -594,7 +594,7 @@ public class TokenFilter extends BaseFilterReader | |||
| * Abstract class that converts derived filter classes into | |||
| * ChainableReaderFilter's | |||
| */ | |||
| public static abstract class ChainableReaderFilter extends ProjectComponent | |||
| public abstract static class ChainableReaderFilter extends ProjectComponent | |||
| implements ChainableReader, Filter { | |||
| private boolean byLine = true; | |||
| @@ -54,11 +54,15 @@ | |||
| package org.apache.tools.ant.taskdefs; | |||
| import org.apache.tools.ant.*; | |||
| import org.apache.tools.ant.types.*; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.MagicNames; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.AntClassLoader; | |||
| import org.apache.tools.ant.types.Reference; | |||
| import org.apache.tools.ant.types.Path; | |||
| import java.io.*; | |||
| import java.util.*; | |||
| import java.io.File; | |||
| /** | |||
| * EXPERIMENTAL | |||
| @@ -66,11 +70,11 @@ import java.util.*; | |||
| * will be used to add classpath elements. | |||
| * | |||
| * The classpath is a regular path. Currently only file components are | |||
| * supported ( future extensions may allow URLs ). | |||
| * supported (future extensions may allow URLs). | |||
| * | |||
| * You can modify the core loader by not specifying any name or using | |||
| * "ant.coreLoader". ( the core loader is used to load system ant | |||
| * tasks and for taskdefs that don't specify an explicit path ). | |||
| * "ant.coreLoader". (the core loader is used to load system ant | |||
| * tasks and for taskdefs that don't specify an explicit path). | |||
| * | |||
| * Taskdef and typedef can use the loader you create if the name follows | |||
| * the "ant.loader.NAME" pattern. NAME will be used as a pathref when | |||
| @@ -93,58 +97,63 @@ import java.util.*; | |||
| * @author Costin Manolache | |||
| */ | |||
| public class Classloader extends Task { | |||
| public static final String SYSTEM_LOADER_REF="ant.coreLoader"; | |||
| /** @see MagicNames#SYSTEM_LOADER_REF */ | |||
| public static final String SYSTEM_LOADER_REF = MagicNames.SYSTEM_LOADER_REF; | |||
| private String name=null; | |||
| private String name = null; | |||
| private Path classpath; | |||
| private boolean reset=false; | |||
| private boolean parentFirst=true; | |||
| private String parentName=null; | |||
| private boolean reset = false; | |||
| private boolean parentFirst = true; | |||
| private String parentName = null; | |||
| /** | |||
| * Default constructor | |||
| */ | |||
| public Classloader() { | |||
| } | |||
| /** Name of the loader. If none, the default loader will be modified | |||
| * | |||
| * @param name | |||
| * @param name the name of this loader | |||
| */ | |||
| public void setName(String name) { | |||
| this.name=name; | |||
| this.name = name; | |||
| } | |||
| /** Reset the classloader, if it already exists. A new loader will | |||
| /** | |||
| * Reset the classloader, if it already exists. A new loader will | |||
| * be created and all the references to the old one will be removed. | |||
| * ( it is not possible to remove paths from a loader ). The new | |||
| * (it is not possible to remove paths from a loader). The new | |||
| * path will be used. | |||
| * | |||
| * @param b | |||
| * @param b true if the loader is to be reset. | |||
| */ | |||
| public void setReset(boolean b) { | |||
| this.reset=b; | |||
| this.reset = b; | |||
| } | |||
| public void setReverse(boolean b ) { | |||
| this.parentFirst= ! b; | |||
| public void setReverse(boolean b) { | |||
| this.parentFirst = !b; | |||
| } | |||
| public void setParentFirst(boolean b ) { | |||
| this.parentFirst= b; | |||
| public void setParentFirst(boolean b) { | |||
| this.parentFirst = b; | |||
| } | |||
| // TODO: add exceptions for delegation or reverse | |||
| // TODO | |||
| public void setParentName( String name ) { | |||
| this.parentName=name; | |||
| public void setParentName(String name) { | |||
| this.parentName = name; | |||
| } | |||
| /** Specify which path will be used. If the loader already exists | |||
| * and is an AntClassLoader ( or any other loader we can extend ), | |||
| * and is an AntClassLoader (or any other loader we can extend), | |||
| * the path will be added to the loader. | |||
| */ | |||
| public void setClasspathRef( Reference pathRef ) throws BuildException { | |||
| classpath=(Path)pathRef.getReferencedObject(project); | |||
| public void setClasspathRef(Reference pathRef) throws BuildException { | |||
| classpath = (Path) pathRef.getReferencedObject(project); | |||
| } | |||
| /** | |||
| @@ -171,71 +180,70 @@ public class Classloader extends Task { | |||
| public void execute() { | |||
| try { | |||
| // Gump friendly - don't mess with the core loader if only classpath | |||
| if( "only".equals( project.getProperty("build.sysclasspath")) && | |||
| (name==null || SYSTEM_LOADER_REF.equals( name ))) { | |||
| log( "Changing the system loader is disabled " + | |||
| "by build.sysclasspath=only", | |||
| Project.MSG_WARN); | |||
| if ("only".equals(project.getProperty("build.sysclasspath")) | |||
| && (name == null || SYSTEM_LOADER_REF.equals(name))) { | |||
| log("Changing the system loader is disabled " | |||
| + "by build.sysclasspath=only", Project.MSG_WARN); | |||
| return; | |||
| } | |||
| String loaderName=(name==null) ? SYSTEM_LOADER_REF : name; | |||
| String loaderName = (name == null) ? SYSTEM_LOADER_REF : name; | |||
| Object obj=project.getReference(loaderName); | |||
| if( reset ) { | |||
| Object obj = project.getReference(loaderName); | |||
| if (reset) { | |||
| // Are any other references held ? Can we 'close' the loader | |||
| // so it removes the locks on jars ? | |||
| obj=null; // a new one will be created. | |||
| obj = null; // a new one will be created. | |||
| } | |||
| // XXX maybe use reflection to addPathElement ( other patterns ?) | |||
| if( obj!=null && !(obj instanceof AntClassLoader )) { | |||
| log( "Referenced object is not an AntClassLoader", | |||
| // XXX maybe use reflection to addPathElement (other patterns ?) | |||
| if (obj != null && !(obj instanceof AntClassLoader)) { | |||
| log("Referenced object is not an AntClassLoader", | |||
| Project.MSG_ERR); | |||
| return; | |||
| } | |||
| AntClassLoader acl=(AntClassLoader)obj; | |||
| AntClassLoader acl = (AntClassLoader) obj; | |||
| if( acl==null ) { | |||
| if (acl == null) { | |||
| // Construct a new class loader | |||
| Object parent=null; | |||
| if( parentName != null ) { | |||
| parent=project.getReference(parentName); | |||
| if( !(parent instanceof ClassLoader) ) { | |||
| parent=null; | |||
| Object parent = null; | |||
| if (parentName != null) { | |||
| parent = project.getReference(parentName); | |||
| if (!(parent instanceof ClassLoader)) { | |||
| parent = null; | |||
| } | |||
| } | |||
| // TODO: allow user to request the system or no parent | |||
| if( parent==null ) { | |||
| parent=this.getClass().getClassLoader(); | |||
| if (parent == null) { | |||
| parent = this.getClass().getClassLoader(); | |||
| } | |||
| if( name==null ) { | |||
| if (name == null) { | |||
| // The core loader must be reverse | |||
| //reverse=true; | |||
| } | |||
| project.log("Setting parent loader " + name + " " + | |||
| parent + " " + parentFirst, Project.MSG_DEBUG); | |||
| project.log("Setting parent loader " + name + " " | |||
| + parent + " " + parentFirst, Project.MSG_DEBUG); | |||
| // The param is "parentFirst" | |||
| acl=new AntClassLoader( (ClassLoader)parent, | |||
| project, classpath, parentFirst ); | |||
| acl = new AntClassLoader((ClassLoader) parent, | |||
| project, classpath, parentFirst); | |||
| project.addReference( loaderName, acl ); | |||
| project.addReference(loaderName, acl); | |||
| if( name==null ) { | |||
| if (name == null) { | |||
| // This allows the core loader to load optional tasks | |||
| // without delegating | |||
| acl.addLoaderPackageRoot( "org.apache.tools.ant.taskdefs.optional"); | |||
| acl.addLoaderPackageRoot("org.apache.tools.ant.taskdefs.optional"); | |||
| project.setCoreLoader(acl); | |||
| } | |||
| } | |||
| if( classpath != null ) { | |||
| String list[]=classpath.list(); | |||
| for( int i=0; i<list.length; i++ ) { | |||
| File f= new File( list[i] ); | |||
| if( f.exists() ) { | |||
| if (classpath != null) { | |||
| String[] list = classpath.list(); | |||
| for (int i = 0; i < list.length; i++) { | |||
| File f = new File(list[i]); | |||
| if (f.exists()) { | |||
| acl.addPathElement(f.getAbsolutePath()); | |||
| log("Adding to class loader " + acl + " " + f.getAbsolutePath(), | |||
| Project.MSG_DEBUG); | |||
| @@ -245,7 +253,7 @@ public class Classloader extends Task { | |||
| // XXX add exceptions | |||
| } catch( Exception ex ) { | |||
| } catch (Exception ex) { | |||
| ex.printStackTrace(); | |||
| } | |||
| } | |||
| @@ -73,6 +73,9 @@ import org.apache.tools.ant.BuildException; | |||
| */ | |||
| public class GZip extends Pack { | |||
| /** | |||
| * perform the GZip compression operation. | |||
| */ | |||
| protected void pack() { | |||
| GZIPOutputStream zOut = null; | |||
| try { | |||
| @@ -67,7 +67,7 @@ import org.apache.tools.ant.Task; | |||
| public class LogStreamHandler extends PumpStreamHandler { | |||
| /** | |||
| * Creates a new instance of this class. | |||
| * Creates log stream handler | |||
| * | |||
| * @param task the task for whom to log | |||
| * @param outlevel the loglevel used to log standard output | |||
| @@ -78,6 +78,9 @@ public class LogStreamHandler extends PumpStreamHandler { | |||
| new LogOutputStream(task, errlevel)); | |||
| } | |||
| /** | |||
| * Stop the log stream handler. | |||
| */ | |||
| public void stop() { | |||
| super.stop(); | |||
| try { | |||
| @@ -72,76 +72,76 @@ import org.apache.tools.ant.util.StringUtils; | |||
| import org.apache.tools.ant.util.TeeOutputStream; | |||
| /** | |||
| * The Redirector class manages the setup and connection of | |||
| * The Redirector class manages the setup and connection of | |||
| * input and output redirection for an Ant task. | |||
| * | |||
| * @author Conor MacNeill | |||
| * @since Ant 1.6 | |||
| */ | |||
| public class Redirector { | |||
| /** | |||
| /** | |||
| * The file receiveing standard output. Will also receive standard error | |||
| * unless standard error is redirected or logError is true. | |||
| */ | |||
| private File out; | |||
| /** | |||
| * The file to which standard error is being redirected | |||
| * The file to which standard error is being redirected | |||
| */ | |||
| private File error; | |||
| /** | |||
| /** | |||
| * The file from which standard input is being taken. | |||
| */ | |||
| private File input; | |||
| /** | |||
| /** | |||
| * Indicates if standard error should be logged to Ant's log system | |||
| * rather than the output. This has no effect if standard error is | |||
| * rather than the output. This has no effect if standard error is | |||
| * redirected to a file or property. | |||
| */ | |||
| private boolean logError = false; | |||
| /** | |||
| * Buffer used to capture output for storage into a property | |||
| */ | |||
| private ByteArrayOutputStream baos = null; | |||
| /** | |||
| * Buffer used to capture error output for storage into a property | |||
| */ | |||
| private ByteArrayOutputStream errorBaos = null; | |||
| /** The name of the property into which output is to be stored */ | |||
| private String outputProperty; | |||
| /** The name of the property into which error output is to be stored */ | |||
| private String errorProperty; | |||
| /** String from which input is taken */ | |||
| private String inputString; | |||
| /** Flag which indicates if error and output files are to be appended. */ | |||
| private boolean append = false; | |||
| /** The task for which this redirector is working */ | |||
| /** The task for which this redirector is working */ | |||
| private Task managingTask; | |||
| /** The stream for output data */ | |||
| private OutputStream outputStream = null; | |||
| /** The stream for error output */ | |||
| private OutputStream errorStream = null; | |||
| /** The stream for input */ | |||
| private InputStream inputStream = null; | |||
| /** Stream which are used for line oriented output */ | |||
| /** Stream which are used for line oriented output */ | |||
| private PrintStream outPrintStream = null; | |||
| /** Stream which is used for line oriented error output */ | |||
| private PrintStream errorPrintStream = null; | |||
| /** | |||
| * Create a redirector instance for the given task | |||
| * | |||
| @@ -150,7 +150,7 @@ public class Redirector { | |||
| public Redirector(Task managingTask) { | |||
| this.managingTask = managingTask; | |||
| } | |||
| /** | |||
| * Set the input to use for the task | |||
| * | |||
| @@ -168,10 +168,10 @@ public class Redirector { | |||
| public void setInputString(String inputString) { | |||
| this.inputString = inputString; | |||
| } | |||
| /** | |||
| * File the output of the process is redirected to. If error is not | |||
| * File the output of the process is redirected to. If error is not | |||
| * redirected, it too will appear in the output | |||
| * | |||
| * @param out the file to which output stream is written | |||
| @@ -191,7 +191,7 @@ public class Redirector { | |||
| public void setLogError(boolean logError) { | |||
| this.logError = logError; | |||
| } | |||
| /** | |||
| * Set the file to which standard error is to be redirected. | |||
| * | |||
| @@ -205,7 +205,7 @@ public class Redirector { | |||
| * Property name whose value should be set to the output of | |||
| * the process. | |||
| * | |||
| * @param outputProperty the name of the property to be set with the | |||
| * @param outputProperty the name of the property to be set with the | |||
| * task's output. | |||
| */ | |||
| public void setOutputProperty(String outputProperty) { | |||
| @@ -227,7 +227,7 @@ public class Redirector { | |||
| * Property name whose value should be set to the error of | |||
| * the process. | |||
| * | |||
| * @param errorProperty the name of the property to be set | |||
| * @param errorProperty the name of the property to be set | |||
| * with the error output. | |||
| */ | |||
| public void setErrorProperty(String errorProperty) { | |||
| @@ -242,9 +242,9 @@ public class Redirector { | |||
| * | |||
| * @exception IOException if the value cannot be read form the stream. | |||
| */ | |||
| private void setPropertyFromBAOS(ByteArrayOutputStream baos, | |||
| private void setPropertyFromBAOS(ByteArrayOutputStream baos, | |||
| String propertyName) throws IOException { | |||
| BufferedReader in = | |||
| new BufferedReader(new StringReader(Execute.toString(baos))); | |||
| String line = null; | |||
| @@ -257,22 +257,22 @@ public class Redirector { | |||
| } | |||
| managingTask.getProject().setNewProperty(propertyName, val.toString()); | |||
| } | |||
| /** | |||
| * Create the input, error and output streams based on the | |||
| * Create the input, error and output streams based on the | |||
| * configuration options. | |||
| */ | |||
| public void createStreams() { | |||
| public void createStreams() { | |||
| if (out == null && outputProperty == null) { | |||
| outputStream = new LogOutputStream(managingTask, Project.MSG_INFO); | |||
| errorStream = new LogOutputStream(managingTask, Project.MSG_WARN); | |||
| } else { | |||
| if (out != null) { | |||
| try { | |||
| outputStream | |||
| outputStream | |||
| = new FileOutputStream(out.getAbsolutePath(), append); | |||
| managingTask.log("Output redirected to " + out, | |||
| managingTask.log("Output redirected to " + out, | |||
| Project.MSG_VERBOSE); | |||
| } catch (FileNotFoundException fne) { | |||
| throw new BuildException("Cannot write to " + out, fne); | |||
| @@ -280,10 +280,10 @@ public class Redirector { | |||
| throw new BuildException("Cannot write to " + out, ioe); | |||
| } | |||
| } | |||
| if (outputProperty != null) { | |||
| baos = new ByteArrayOutputStream(); | |||
| managingTask.log("Output redirected to property: " | |||
| managingTask.log("Output redirected to property: " | |||
| + outputProperty, Project.MSG_VERBOSE); | |||
| if (out == null) { | |||
| outputStream = baos; | |||
| @@ -293,19 +293,19 @@ public class Redirector { | |||
| } else { | |||
| baos = null; | |||
| } | |||
| errorStream = outputStream; | |||
| } | |||
| } | |||
| if (logError) { | |||
| errorStream = new LogOutputStream(managingTask, Project.MSG_WARN); | |||
| } | |||
| if (error != null) { | |||
| try { | |||
| errorStream | |||
| errorStream | |||
| = new FileOutputStream(error.getAbsolutePath(), append); | |||
| managingTask.log("Error redirected to " + error, | |||
| managingTask.log("Error redirected to " + error, | |||
| Project.MSG_VERBOSE); | |||
| } catch (FileNotFoundException fne) { | |||
| throw new BuildException("Cannot write to " + error, fne); | |||
| @@ -313,10 +313,10 @@ public class Redirector { | |||
| throw new BuildException("Cannot write to " + error, ioe); | |||
| } | |||
| } | |||
| if (errorProperty != null) { | |||
| errorBaos = new ByteArrayOutputStream(); | |||
| managingTask.log("Error redirected to property: " + errorProperty, | |||
| managingTask.log("Error redirected to property: " + errorProperty, | |||
| Project.MSG_VERBOSE); | |||
| if (error == null) { | |||
| errorStream = errorBaos; | |||
| @@ -341,21 +341,21 @@ public class Redirector { | |||
| inputStream = new ByteArrayInputStream(inputString.getBytes()); | |||
| } | |||
| } | |||
| /** | |||
| * Create the StreamHandler to use with our Execute instance. | |||
| * | |||
| * @return the execute stream handler to manage the input, output and | |||
| * error streams. | |||
| * | |||
| * | |||
| * @throws BuildException if the execute stream handler cannot be created. | |||
| */ | |||
| public ExecuteStreamHandler createHandler() throws BuildException { | |||
| createStreams(); | |||
| return new PumpStreamHandler(outputStream, errorStream, inputStream); | |||
| } | |||
| /** | |||
| * Pass output sent to System.out to specified output. | |||
| * | |||
| @@ -367,8 +367,8 @@ public class Redirector { | |||
| } | |||
| outPrintStream.println(line); | |||
| } | |||
| /** | |||
| /** | |||
| * Handle an input request | |||
| * | |||
| * @param buffer the buffer into which data is to be read. | |||
| @@ -376,19 +376,19 @@ public class Redirector { | |||
| * @param length the amount of data to read | |||
| * | |||
| * @return the number of bytes read | |||
| * | |||
| * | |||
| * @exception IOException if the data cannot be read | |||
| */ | |||
| protected int handleInput(byte[] buffer, int offset, int length) | |||
| protected int handleInput(byte[] buffer, int offset, int length) | |||
| throws IOException { | |||
| if (inputStream == null) { | |||
| return managingTask.getProject().defaultInput(buffer, offset, | |||
| return managingTask.getProject().defaultInput(buffer, offset, | |||
| length); | |||
| } else { | |||
| return inputStream.read(buffer, offset, length); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Process data due to a flush operation. | |||
| * | |||
| @@ -401,7 +401,7 @@ public class Redirector { | |||
| outPrintStream.print(line); | |||
| outPrintStream.flush(); | |||
| } | |||
| /** | |||
| * Process error output | |||
| * | |||
| @@ -413,7 +413,7 @@ public class Redirector { | |||
| } | |||
| errorPrintStream.println(line); | |||
| } | |||
| /** | |||
| * Handle a flush operation on the error stream | |||
| * | |||
| @@ -429,17 +429,17 @@ public class Redirector { | |||
| /** | |||
| * Get the output stream for the redirector | |||
| * | |||
| * @return the redirector's output stream or null if no output | |||
| * @return the redirector's output stream or null if no output | |||
| * has been configured | |||
| */ | |||
| public OutputStream getOutputStream() { | |||
| return outputStream; | |||
| } | |||
| /** | |||
| * Get the error stream for the redirector | |||
| * | |||
| * @return the redirector's error stream or null if no output | |||
| * @return the redirector's error stream or null if no output | |||
| * has been configured | |||
| */ | |||
| public OutputStream getErrorStream() { | |||
| @@ -449,15 +449,15 @@ public class Redirector { | |||
| /** | |||
| * Get the input stream for the redirector | |||
| * | |||
| * @return the redirector's input stream or null if no output | |||
| * @return the redirector's input stream or null if no output | |||
| * has been configured | |||
| */ | |||
| public InputStream getInputStream() { | |||
| return inputStream; | |||
| } | |||
| /** | |||
| * Complete redirection. | |||
| * Complete redirection. | |||
| * | |||
| * This opertaion will close any streams and create any specified | |||
| * property values. | |||
| @@ -468,13 +468,13 @@ public class Redirector { | |||
| public void complete() throws IOException { | |||
| System.out.flush(); | |||
| System.err.flush(); | |||
| if (inputStream != null) { | |||
| inputStream.close(); | |||
| } | |||
| outputStream.close(); | |||
| errorStream.close(); | |||
| if (baos != null) { | |||
| setPropertyFromBAOS(baos, outputProperty); | |||
| } | |||
| @@ -124,8 +124,8 @@ public class Rename extends Task { | |||
| try { | |||
| FileUtils.newFileUtils().rename(src, dest); | |||
| } catch (IOException e) { | |||
| throw new BuildException("Unable to rename " + src + " to " + | |||
| dest, e, getLocation()); | |||
| throw new BuildException("Unable to rename " + src + " to " | |||
| + dest, e, getLocation()); | |||
| } | |||
| } | |||
| } | |||
| @@ -75,6 +75,10 @@ import org.apache.tools.ant.TaskAdapter; | |||
| */ | |||
| public class Taskdef extends Typedef { | |||
| /** | |||
| * Default constuctor. | |||
| * | |||
| */ | |||
| public Taskdef() { | |||
| setAdapterClass(TaskAdapter.class); | |||
| setAdaptToClass(Task.class); | |||
| @@ -79,6 +79,7 @@ public interface XSLTLiaison { | |||
| /** | |||
| * set the stylesheet to use for the transformation. | |||
| * @param stylesheet the stylesheet to be used for transformation. | |||
| * @throws Exception thrown if any problems happens. | |||
| * @since Ant 1.4 | |||
| */ | |||
| void setStylesheet(File stylesheet) throws Exception; | |||
| @@ -118,7 +118,7 @@ public class FilesMatch implements Condition { | |||
| try { | |||
| matches = fu.contentEquals(file1, file2); | |||
| } catch (IOException ioe) { | |||
| throw new BuildException("when comparing files: " | |||
| throw new BuildException("when comparing files: " | |||
| + ioe.getMessage(), ioe); | |||
| } | |||
| return matches; | |||
| @@ -68,9 +68,16 @@ import org.apache.tools.ant.BuildException; | |||
| */ | |||
| public class Not extends ConditionBase implements Condition { | |||
| /** | |||
| * Evaluate condition | |||
| * | |||
| * @return true if the condition is true. | |||
| * @throws BuildException if the condition is not configured correctly. | |||
| */ | |||
| public boolean eval() throws BuildException { | |||
| if (countConditions() > 1) { | |||
| throw new BuildException("You must not nest more than one condition into <not>"); | |||
| throw new BuildException("You must not nest more than one " | |||
| + "condition into <not>"); | |||
| } | |||
| if (countConditions() < 1) { | |||
| throw new BuildException("You must nest a condition into <not>"); | |||
| @@ -63,7 +63,7 @@ import org.apache.tools.ant.taskdefs.LogOutputStream; | |||
| */ | |||
| class RedirectingOutputStream | |||
| extends LogOutputStream { | |||
| private final ChangeLogParser m_parser; | |||
| private final ChangeLogParser parser; | |||
| /** | |||
| @@ -73,7 +73,7 @@ class RedirectingOutputStream | |||
| */ | |||
| public RedirectingOutputStream(final ChangeLogParser parser) { | |||
| super(null, 0); | |||
| m_parser = parser; | |||
| this.parser = parser; | |||
| } | |||
| @@ -83,7 +83,7 @@ class RedirectingOutputStream | |||
| * @param line the line to log. | |||
| */ | |||
| protected void processLine(final String line) { | |||
| m_parser.stdout(line); | |||
| parser.stdout(line); | |||
| } | |||
| } | |||
| @@ -74,7 +74,7 @@ class RedirectingStreamHandler | |||
| String getErrors() { | |||
| try { | |||
| final ByteArrayOutputStream error | |||
| final ByteArrayOutputStream error | |||
| = (ByteArrayOutputStream) getErr(); | |||
| return error.toString("ASCII"); | |||
| @@ -63,6 +63,9 @@ import java.util.Date; | |||
| */ | |||
| public class CCMCheckin extends CCMCheck { | |||
| /** | |||
| * Default constructor - setup checkin command | |||
| */ | |||
| public CCMCheckin() { | |||
| super(); | |||
| setCcmAction(COMMAND_CHECKIN); | |||
| @@ -77,12 +77,16 @@ import org.apache.tools.ant.types.Path; | |||
| public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| /** Public Id of the standard deployment descriptor DTD. */ | |||
| protected static final String EJB_JAR_1_1_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"; | |||
| protected static final String EJB_JAR_2_0_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"; | |||
| protected static final String EJB_JAR_1_1_PUBLIC_ID | |||
| = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"; | |||
| protected static final String EJB_JAR_2_0_PUBLIC_ID | |||
| = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"; | |||
| /** Public Id of the JOnAS-specific deployment descriptor DTD. */ | |||
| protected static final String JONAS_EJB_JAR_2_4_PUBLIC_ID = "-//ObjectWeb//DTD JOnAS 2.4//EN"; | |||
| protected static final String JONAS_EJB_JAR_2_5_PUBLIC_ID = "-//ObjectWeb//DTD JOnAS 2.5//EN"; | |||
| protected static final String JONAS_EJB_JAR_2_4_PUBLIC_ID | |||
| = "-//ObjectWeb//DTD JOnAS 2.4//EN"; | |||
| protected static final String JONAS_EJB_JAR_2_5_PUBLIC_ID | |||
| = "-//ObjectWeb//DTD JOnAS 2.5//EN"; | |||
| /** RMI ORB. */ | |||
| protected static final String RMI_ORB = "RMI"; | |||
| @@ -104,8 +108,10 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| * Name of the JOnAS-specific deployment descriptor DTD (these files are | |||
| * stored in the ${JONAS_ROOT}/xml directory). | |||
| */ | |||
| protected static final String JONAS_EJB_JAR_2_4_DTD = "jonas-ejb-jar_2_4.dtd"; | |||
| protected static final String JONAS_EJB_JAR_2_5_DTD = "jonas-ejb-jar_2_5.dtd"; | |||
| protected static final String JONAS_EJB_JAR_2_4_DTD | |||
| = "jonas-ejb-jar_2_4.dtd"; | |||
| protected static final String JONAS_EJB_JAR_2_5_DTD | |||
| = "jonas-ejb-jar_2_5.dtd"; | |||
| /** Default JOnAS deployment descriptor name. */ | |||
| protected static final String JONAS_DD = "jonas-ejb-jar.xml"; | |||
| @@ -215,7 +221,10 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| */ | |||
| private String orb; | |||
| /** <code>true</code> if GenIC must not be run on the EJB JAR. The default is <code>false</code>. */ | |||
| /** | |||
| * <code>true</code> if GenIC must not be run on the EJB JAR. | |||
| * The default is <code>false</code>. | |||
| */ | |||
| private boolean nogenic = false; | |||
| /* -------------------- */ | |||
| @@ -365,7 +374,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| super.processDescriptor(descriptorName, saxParser); | |||
| if ( outputdir != null ) { | |||
| if (outputdir != null) { | |||
| // the method deleteOnExit() do not work because the directory is not empty | |||
| log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE); | |||
| deleteAllFiles(outputdir); | |||
| @@ -378,14 +387,14 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| // create the generic jar first | |||
| File genericJarFile = super.getVendorOutputJarFile(baseName); | |||
| super.writeJar(baseName, genericJarFile, ejbFiles, publicId); | |||
| // GenIC call on generic jar | |||
| addGenICGeneratedFiles(genericJarFile, ejbFiles); | |||
| // create the real jar | |||
| super.writeJar(baseName, getVendorOutputJarFile(baseName), ejbFiles, publicId); | |||
| if ( !keepgeneric ) { | |||
| if (!keepgeneric) { | |||
| log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE); | |||
| genericJarFile.delete(); | |||
| } | |||
| @@ -397,7 +406,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| jonasDescriptorName = getJonasDescriptorName(); | |||
| File jonasDD = new File(getConfig().descriptorDir, jonasDescriptorName); | |||
| if ( jonasDD.exists() ) { | |||
| if (jonasDD.exists()) { | |||
| ejbFiles.put(META_DIR + JONAS_DD, jonasDD); | |||
| } else { | |||
| log("Unable to locate the JOnAS deployment descriptor. It was expected to be in: " | |||
| @@ -431,18 +440,19 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| String remainder; // Filename appearing after the name terminator | |||
| int startOfFileName = descriptorName.lastIndexOf(File.separatorChar); | |||
| if ( startOfFileName != -1 ) { | |||
| if (startOfFileName != -1) { | |||
| // extract path info | |||
| path = descriptorName.substring(0, startOfFileName+1); | |||
| fileName = descriptorName.substring(startOfFileName+1); | |||
| path = descriptorName.substring(0, startOfFileName + 1); | |||
| fileName = descriptorName.substring(startOfFileName + 1); | |||
| } else { | |||
| // descriptorName is just a file without path | |||
| path = ""; | |||
| fileName = descriptorName; | |||
| } | |||
| if ( fileName.startsWith(EJB_DD) ) | |||
| if (fileName.startsWith(EJB_DD)) { | |||
| return path + JONAS_DD; | |||
| } | |||
| int endOfBaseName = descriptorName.indexOf(getConfig().baseNameTerminator, startOfFileName); | |||
| @@ -451,7 +461,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| * extension aren't found. These will ensure "jonas-" appears at the | |||
| * end of the name and before the '.' (if present). | |||
| */ | |||
| if ( endOfBaseName < 0 ) { | |||
| if (endOfBaseName < 0) { | |||
| // baseNameTerminator not found: the descriptor use the | |||
| // JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and | |||
| // not [Foo<baseNameTerminator>-ejb-jar.xml, | |||
| @@ -468,7 +478,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| baseName = descriptorName.substring(startOfFileName + 1, endOfBaseName + 1); | |||
| remainder = descriptorName.substring(endOfBaseName + 1); | |||
| if ( jonasConvention ) { | |||
| if (jonasConvention) { | |||
| jonasDescriptorName = path + "jonas-" + baseName + ".xml"; | |||
| } else { | |||
| jonasDescriptorName = path + baseName + "jonas-" + remainder; | |||
| @@ -484,10 +494,10 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| String baseName = null; | |||
| if ( getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR) ) { | |||
| if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)) { | |||
| // try to find JOnAS specific convention name | |||
| if ( descriptorFileName.indexOf(getConfig().baseNameTerminator) == -1 ) { | |||
| if (descriptorFileName.indexOf(getConfig().baseNameTerminator) == -1) { | |||
| // baseNameTerminator not found: the descriptor use the | |||
| // JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and | |||
| @@ -498,19 +508,19 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/'); | |||
| int endOfBaseName; | |||
| if ( lastSeparatorIndex != -1 ) { | |||
| if (lastSeparatorIndex != -1) { | |||
| endOfBaseName = descriptorFileName.indexOf(".xml", lastSeparatorIndex); | |||
| } else { | |||
| endOfBaseName = descriptorFileName.indexOf(".xml"); | |||
| } | |||
| if ( endOfBaseName != -1 ) { | |||
| if (endOfBaseName != -1) { | |||
| baseName = descriptorFileName.substring(0, endOfBaseName); | |||
| } | |||
| } | |||
| } | |||
| if ( baseName == null ) { | |||
| if (baseName == null) { | |||
| // else get standard baseName | |||
| baseName = super.getJarBaseName(descriptorFileName); | |||
| } | |||
| @@ -525,7 +535,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| jonasroot + File.separator + "xml" + File.separator + EJB_JAR_1_1_DTD); | |||
| handler.registerDTD(EJB_JAR_2_0_PUBLIC_ID, | |||
| jonasroot + File.separator + "xml" + File.separator + EJB_JAR_2_0_DTD); | |||
| handler.registerDTD(JONAS_EJB_JAR_2_4_PUBLIC_ID, | |||
| jonasroot + File.separator + "xml" + File.separator + JONAS_EJB_JAR_2_4_DTD); | |||
| handler.registerDTD(JONAS_EJB_JAR_2_5_PUBLIC_ID, | |||
| @@ -539,29 +549,32 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| * @param ejbFiles the hashtable. | |||
| */ | |||
| private void addGenICGeneratedFiles(File genericJarFile, Hashtable ejbFiles) { | |||
| // GenIC task | |||
| Java genicTask = null; | |||
| // GenIC class (3 GenIC classes for various versions of JOnAS | |||
| // are supported) | |||
| String genicClass = null; | |||
| Java genicTask = null; // GenIC task | |||
| String genicClass = null; // GenIC class (3 GenIC classes for various versions of JOnAS are supported) | |||
| if ( nogenic ) { | |||
| if (nogenic) { | |||
| return; | |||
| } | |||
| genicTask = (Java) getTask().getProject().createTask("java"); | |||
| genicTask.setTaskName("genic"); | |||
| genicTask.setFork(true); | |||
| // jonasroot | |||
| genicTask.createJvmarg().setValue("-Dinstall.root=" + jonasroot); | |||
| // java policy file | |||
| String jonasConfigDir = jonasroot + File.separator + "config"; | |||
| File javaPolicyFile = new File(jonasConfigDir, "java.policy"); | |||
| if ( javaPolicyFile.exists() ) { | |||
| if (javaPolicyFile.exists()) { | |||
| genicTask.createJvmarg().setValue("-Djava.security.policy=" | |||
| + javaPolicyFile.toString()); | |||
| } | |||
| // outputdir | |||
| try { | |||
| outputdir = createTempDir(); | |||
| @@ -570,121 +583,122 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| throw new BuildException(msg, aIOException); | |||
| } | |||
| log("Using temporary output directory: " + outputdir, Project.MSG_VERBOSE); | |||
| genicTask.createArg().setValue("-d"); | |||
| genicTask.createArg().setFile(outputdir); | |||
| // work around a bug of GenIC 2.5 | |||
| String key; | |||
| File f; | |||
| Enumeration keys = ejbFiles.keys(); | |||
| while ( keys.hasMoreElements() ) { | |||
| key = (String)keys.nextElement(); | |||
| while (keys.hasMoreElements()) { | |||
| key = (String) keys.nextElement(); | |||
| f = new File(outputdir + File.separator + key); | |||
| f.getParentFile().mkdirs(); | |||
| } | |||
| log("Worked around a bug of GenIC 2.5.", Project.MSG_VERBOSE); | |||
| // classpath | |||
| Path classpath = getCombinedClasspath(); | |||
| if ( classpath == null ) { | |||
| if (classpath == null) { | |||
| classpath = new Path(getTask().getProject()); | |||
| } | |||
| classpath.append(new Path(classpath.getProject(), jonasConfigDir)); | |||
| classpath.append(new Path(classpath.getProject(), outputdir.toString())); | |||
| // try to create the classpath for the correct ORB | |||
| if ( orb != null ) { | |||
| String orbJar = jonasroot + File.separator + "lib" + File.separator + orb + "_jonas.jar"; | |||
| if (orb != null) { | |||
| String orbJar = jonasroot + File.separator + "lib" | |||
| + File.separator + orb + "_jonas.jar"; | |||
| classpath.append(new Path(classpath.getProject(), orbJar)); | |||
| } | |||
| log("Using classpath: " + classpath.toString(), Project.MSG_VERBOSE); | |||
| genicTask.setClasspath(classpath); | |||
| // class name (search in the classpath provided for the ejbjar element) | |||
| genicClass = getGenicClassName(classpath); | |||
| if ( genicClass == null ) { | |||
| if (genicClass == null) { | |||
| log("Cannot find GenIC class in classpath.", Project.MSG_ERR); | |||
| throw new BuildException("GenIC class not found, please check the classpath."); | |||
| } else { | |||
| log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE); | |||
| genicTask.setClassname(genicClass); | |||
| } | |||
| // keepgenerated | |||
| if ( keepgenerated ) { | |||
| if (keepgenerated) { | |||
| genicTask.createArg().setValue("-keepgenerated"); | |||
| } | |||
| // nocompil | |||
| if ( nocompil ) { | |||
| if (nocompil) { | |||
| genicTask.createArg().setValue("-nocompil"); | |||
| } | |||
| // novalidation | |||
| if ( novalidation ) { | |||
| if (novalidation) { | |||
| genicTask.createArg().setValue("-novalidation"); | |||
| } | |||
| // javac | |||
| if ( javac != null ) { | |||
| if (javac != null) { | |||
| genicTask.createArg().setValue("-javac"); | |||
| genicTask.createArg().setLine(javac); | |||
| } | |||
| // javacopts | |||
| if ( javacopts != null && !javacopts.equals("") ) { | |||
| if (javacopts != null && !javacopts.equals("")) { | |||
| genicTask.createArg().setValue("-javacopts"); | |||
| genicTask.createArg().setLine(javacopts); | |||
| } | |||
| // rmicopts | |||
| if ( rmicopts != null && !rmicopts.equals("") ) { | |||
| if (rmicopts != null && !rmicopts.equals("")) { | |||
| genicTask.createArg().setValue("-rmicopts"); | |||
| genicTask.createArg().setLine(rmicopts); | |||
| } | |||
| // secpropag | |||
| if ( secpropag ) { | |||
| if (secpropag) { | |||
| genicTask.createArg().setValue("-secpropag"); | |||
| } | |||
| // verbose | |||
| if ( verbose ) { | |||
| if (verbose) { | |||
| genicTask.createArg().setValue("-verbose"); | |||
| } | |||
| // additionalargs | |||
| if ( additionalargs != null ) { | |||
| if (additionalargs != null) { | |||
| genicTask.createArg().setValue(additionalargs); | |||
| } | |||
| // the generated classes must not be added in the generic JAR! | |||
| // is that buggy on old JOnAS (2.4) ?? | |||
| genicTask.createArg().setValue("-noaddinjar"); | |||
| // input file to process by GenIC | |||
| genicTask.createArg().setValue(genericJarFile.getPath()); | |||
| // calling GenIC task | |||
| log("Calling " + genicClass + " for " + getConfig().descriptorDir + File.separator + descriptorName | |||
| + ".", Project.MSG_VERBOSE); | |||
| if ( genicTask.executeJava() != 0 ) { | |||
| log("Calling " + genicClass + " for " + getConfig().descriptorDir | |||
| + File.separator + descriptorName + ".", Project.MSG_VERBOSE); | |||
| if (genicTask.executeJava() != 0) { | |||
| // the method deleteOnExit() do not work because the directory is not empty | |||
| log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE); | |||
| deleteAllFiles(outputdir); | |||
| if ( !keepgeneric ) { | |||
| if (!keepgeneric) { | |||
| log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE); | |||
| genericJarFile.delete(); | |||
| } | |||
| throw new BuildException("GenIC reported an error."); | |||
| } | |||
| // add the generated files to the ejbFiles | |||
| addAllFiles(outputdir, "", ejbFiles); | |||
| } | |||
| @@ -698,41 +712,44 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| */ | |||
| String getGenicClassName(Path classpath) { | |||
| log("Looking for GenIC class in classpath: " + classpath.toString(), Project.MSG_VERBOSE); | |||
| log("Looking for GenIC class in classpath: " | |||
| + classpath.toString(), Project.MSG_VERBOSE); | |||
| AntClassLoader cl = classpath.getProject().createClassLoader(classpath); | |||
| try { | |||
| cl.loadClass(JonasDeploymentTool.GENIC_CLASS); | |||
| log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' in classpath.", Project.MSG_VERBOSE); | |||
| log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS | |||
| + "' in classpath.", Project.MSG_VERBOSE); | |||
| return JonasDeploymentTool.GENIC_CLASS; | |||
| } catch (ClassNotFoundException cnf1) { | |||
| log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' not found in classpath.", | |||
| log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS | |||
| + "' not found in classpath.", | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| try { | |||
| cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_1); | |||
| log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 + | |||
| "' in classpath.", Project.MSG_VERBOSE); | |||
| log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 | |||
| + "' in classpath.", Project.MSG_VERBOSE); | |||
| return JonasDeploymentTool.OLD_GENIC_CLASS_1; | |||
| } catch (ClassNotFoundException cnf2) { | |||
| log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 + | |||
| "' not found in classpath.", | |||
| log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 | |||
| + "' not found in classpath.", | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| try { | |||
| cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_2); | |||
| log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 + | |||
| "' in classpath.", Project.MSG_VERBOSE); | |||
| log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 | |||
| + "' in classpath.", Project.MSG_VERBOSE); | |||
| return JonasDeploymentTool.OLD_GENIC_CLASS_2; | |||
| } catch (ClassNotFoundException cnf3) { | |||
| log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 + | |||
| "' not found in classpath.", | |||
| log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 | |||
| + "' not found in classpath.", | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| return null; | |||
| @@ -742,26 +759,28 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| SAXParser saxParser) throws BuildException { | |||
| // jonasroot | |||
| if ( jonasroot == null ) { | |||
| if (jonasroot == null) { | |||
| throw new BuildException("The jonasroot attribut is not set."); | |||
| } else if ( !jonasroot.isDirectory() ) { | |||
| throw new BuildException("The jonasroot attribut '" + jonasroot + | |||
| "' is not a valid directory."); | |||
| } else if (!jonasroot.isDirectory()) { | |||
| throw new BuildException("The jonasroot attribut '" + jonasroot | |||
| + "' is not a valid directory."); | |||
| } | |||
| // orb | |||
| if ( orb != null && !orb.equals(RMI_ORB) && !orb.equals(JEREMIE_ORB) && !orb.equals(DAVID_ORB) ) { | |||
| throw new BuildException("The orb attribut '" + orb + "' is not valid (must be either " + | |||
| RMI_ORB + ", " + JEREMIE_ORB + " or " + DAVID_ORB + ")."); | |||
| if (orb != null && !orb.equals(RMI_ORB) && !orb.equals(JEREMIE_ORB) | |||
| && !orb.equals(DAVID_ORB)) { | |||
| throw new BuildException("The orb attribut '" + orb | |||
| + "' is not valid (must be either " | |||
| + RMI_ORB + ", " + JEREMIE_ORB + " or " + DAVID_ORB + ")."); | |||
| } | |||
| // additionalargs | |||
| if ( additionalargs != null && additionalargs.equals("") ) { | |||
| if (additionalargs != null && additionalargs.equals("")) { | |||
| throw new BuildException("Empty additionalargs attribut."); | |||
| } | |||
| // javac | |||
| if ( javac != null && javac.equals("") ) { | |||
| if (javac != null && javac.equals("")) { | |||
| throw new BuildException("Empty javac attribut."); | |||
| } | |||
| } | |||
| @@ -779,7 +798,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| private File createTempDir() throws IOException { | |||
| File tmpDir = File.createTempFile("genic", null, null); | |||
| tmpDir.delete(); | |||
| if ( !tmpDir.mkdir() ) { | |||
| if (!tmpDir.mkdir()) { | |||
| throw new IOException("Cannot create the temporary directory '" + tmpDir + "'."); | |||
| } | |||
| return tmpDir; | |||
| @@ -792,8 +811,8 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| * @param aFile file to delete. | |||
| */ | |||
| private void deleteAllFiles(File aFile) { | |||
| if ( aFile.isDirectory() ) { | |||
| File someFiles[] = aFile.listFiles(); | |||
| if (aFile.isDirectory()) { | |||
| File[] someFiles = aFile.listFiles(); | |||
| for (int i = 0; i < someFiles.length; i++) { | |||
| deleteAllFiles(someFiles[i]); | |||
| @@ -812,15 +831,15 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||
| */ | |||
| private void addAllFiles(File file, String rootDir, Hashtable hashtable) { | |||
| if ( !file.exists() ) { | |||
| if (!file.exists()) { | |||
| throw new IllegalArgumentException(); | |||
| } | |||
| String newRootDir; | |||
| if ( file.isDirectory() ) { | |||
| File files[] = file.listFiles(); | |||
| if (file.isDirectory()) { | |||
| File[] files = file.listFiles(); | |||
| for (int i = 0; i < files.length; i++) { | |||
| if ( rootDir.length() > 0 ) { | |||
| if (rootDir.length() > 0) { | |||
| newRootDir = rootDir + File.separator + files[i].getName(); | |||
| } else { | |||
| newRootDir = files[i].getName(); | |||
| @@ -96,7 +96,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements | |||
| * Description of the Field | |||
| */ | |||
| private File jonasroot; | |||
| /** | |||
| * Description of the Field | |||
| */ | |||
| @@ -106,7 +106,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements | |||
| * Description of the Field | |||
| */ | |||
| private String davidHost; | |||
| /** | |||
| * Description of the Field | |||
| */ | |||
| @@ -114,7 +114,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements | |||
| /** | |||
| * Set the host for the David ORB; required if | |||
| * Set the host for the David ORB; required if | |||
| * ORB==david. | |||
| * | |||
| *@param inValue The new davidhost value | |||
| @@ -125,7 +125,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements | |||
| /** | |||
| * Set the port for the David ORB; required if | |||
| * Set the port for the David ORB; required if | |||
| * ORB==david. | |||
| * | |||
| *@param inValue The new davidport value | |||
| @@ -147,11 +147,11 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements | |||
| /** | |||
| * | |||
| * | |||
| * Choose your ORB : RMI, JEREMIE, DAVID, ...; optional. | |||
| * If omitted, it defaults | |||
| * to the one present in classpath. The corresponding JOnAS JAR is | |||
| * automatically added to the classpath. If your orb is DAVID (RMI/IIOP) you must | |||
| * automatically added to the classpath. If your orb is DAVID (RMI/IIOP) you must | |||
| * specify davidhost and davidport properties. | |||
| * | |||
| *@param inValue RMI, JEREMIE, DAVID,... | |||
| @@ -217,21 +217,30 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements | |||
| if (jonasroot == null || jonasroot.isDirectory()) { | |||
| java.createJvmarg().setValue("-Dinstall.root=" + jonasroot); | |||
| java.createJvmarg().setValue("-Djava.security.policy=" + jonasroot + "/config/java.policy"); | |||
| java.createJvmarg().setValue("-Djava.security.policy=" + jonasroot | |||
| + "/config/java.policy"); | |||
| if ("DAVID".equals(orb)) { | |||
| java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBClass=org.objectweb.david.libs.binding.orbs.iiop.IIOPORB"); | |||
| java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBSingletonClass=org.objectweb.david.libs.binding.orbs.ORBSingletonClass"); | |||
| java.createJvmarg().setValue("-Djavax.rmi.CORBA.StubClass=org.objectweb.david.libs.stub_factories.rmi.StubDelegate"); | |||
| java.createJvmarg().setValue("-Djavax.rmi.CORBA.PortableRemoteObjectClass=org.objectweb.david.libs.binding.rmi.ORBPortableRemoteObjectDelegate"); | |||
| java.createJvmarg().setValue("-Djavax.rmi.CORBA.UtilClass=org.objectweb.david.libs.helpers.RMIUtilDelegate"); | |||
| java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBClass" | |||
| + "=org.objectweb.david.libs.binding.orbs.iiop.IIOPORB"); | |||
| java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBSingletonClass=" | |||
| + "org.objectweb.david.libs.binding.orbs.ORBSingletonClass"); | |||
| java.createJvmarg().setValue("-Djavax.rmi.CORBA.StubClass=" | |||
| + "org.objectweb.david.libs.stub_factories.rmi.StubDelegate"); | |||
| java.createJvmarg().setValue("-Djavax.rmi.CORBA.PortableRemoteObjectClass=" | |||
| + "org.objectweb.david.libs.binding.rmi.ORBPortableRemoteObjectDelegate"); | |||
| java.createJvmarg().setValue("-Djavax.rmi.CORBA.UtilClass=" | |||
| + "org.objectweb.david.libs.helpers.RMIUtilDelegate"); | |||
| java.createJvmarg().setValue("-Ddavid.CosNaming.default_method=0"); | |||
| java.createJvmarg().setValue("-Ddavid.rmi.ValueHandlerClass=com.sun.corba.se.internal.io.ValueHandlerImpl"); | |||
| java.createJvmarg().setValue("-Ddavid.rmi.ValueHandlerClass=" | |||
| + "com.sun.corba.se.internal.io.ValueHandlerImpl"); | |||
| if (davidHost != null) { | |||
| java.createJvmarg().setValue("-Ddavid.CosNaming.default_host=" + davidHost); | |||
| java.createJvmarg().setValue("-Ddavid.CosNaming.default_host=" | |||
| + davidHost); | |||
| } | |||
| if (davidPort != 0) { | |||
| java.createJvmarg().setValue("-Ddavid.CosNaming.default_port=" + davidPort); | |||
| java.createJvmarg().setValue("-Ddavid.CosNaming.default_port=" | |||
| + davidPort); | |||
| } | |||
| } | |||
| } | |||
| @@ -240,9 +249,9 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements | |||
| java.createArg().setLine("-n " + getServer()); | |||
| } | |||
| if (action.equals(ACTION_DEPLOY) || | |||
| action.equals(ACTION_UPDATE) || | |||
| action.equals("redeploy")) { | |||
| if (action.equals(ACTION_DEPLOY) | |||
| || action.equals(ACTION_UPDATE) | |||
| || action.equals("redeploy")) { | |||
| java.createArg().setLine("-a " + getTask().getSource()); | |||
| } else if (action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY)) { | |||
| java.createArg().setLine("-r " + getTask().getSource()); | |||
| @@ -87,7 +87,7 @@ import org.apache.tools.ant.util.FileUtils; | |||
| * <li> <strong>del</strong> - delete files from a remote server.</li> | |||
| * <li> <strong>list</strong> - create a file listing.</li> | |||
| * <li> <strong>chmod</strong> - change unix file permissions.</li> | |||
| * <li> <strong>rmdir</strong> - remove directories, if empty, from a | |||
| * <li> <strong>rmdir</strong> - remove directories, if empty, from a | |||
| * remote server.</li> | |||
| * </ul> | |||
| * <strong>Note:</strong> Some FTP servers - notably the Solaris server - seem | |||
| @@ -115,6 +115,9 @@ public class FTP | |||
| protected static final int CHMOD = 5; | |||
| protected static final int RM_DIR = 6; | |||
| /** Default port for FTP */ | |||
| public static final int DEFAULT_FTP_PORT = 21; | |||
| private String remotedir; | |||
| private String server; | |||
| private String userid; | |||
| @@ -129,7 +132,7 @@ public class FTP | |||
| private Vector dirCache = new Vector(); | |||
| private int transferred = 0; | |||
| private String remoteFileSep = "/"; | |||
| private int port = 21; | |||
| private int port = DEFAULT_FTP_PORT; | |||
| private boolean skipFailedTransfers = false; | |||
| private int skipped = 0; | |||
| private boolean ignoreNoncriticalErrors = false; | |||
| @@ -282,31 +285,49 @@ public class FTP | |||
| * Sets the remote directory where files will be placed. This may be a | |||
| * relative or absolute path, and must be in the path syntax expected by | |||
| * the remote server. No correction of path syntax will be performed. | |||
| * | |||
| * @param dir the remote directory name. | |||
| */ | |||
| public void setRemotedir(String dir) { | |||
| this.remotedir = dir; | |||
| } | |||
| /** Sets the FTP server to send files to. */ | |||
| /** | |||
| * Sets the FTP server to send files to. | |||
| * | |||
| * @param server the remote server name. | |||
| */ | |||
| public void setServer(String server) { | |||
| this.server = server; | |||
| } | |||
| /** Sets the FTP port used by the remote server. */ | |||
| /** | |||
| * Sets the FTP port used by the remote server. | |||
| * | |||
| * @param port the port on which the remote server is listening. | |||
| */ | |||
| public void setPort(int port) { | |||
| this.port = port; | |||
| } | |||
| /** Sets the login user id to use on the specified server. */ | |||
| /** | |||
| * Sets the login user id to use on the specified server. | |||
| * | |||
| * @param userid remote system userid. | |||
| */ | |||
| public void setUserid(String userid) { | |||
| this.userid = userid; | |||
| } | |||
| /** Sets the login password for the given user id. */ | |||
| /** | |||
| * Sets the login password for the given user id. | |||
| * | |||
| * @param password the password on the remote system. | |||
| */ | |||
| public void setPassword(String password) { | |||
| this.password = password; | |||
| } | |||
| @@ -314,6 +335,8 @@ public class FTP | |||
| /** | |||
| * If true, uses binary mode, otherwise text mode (default is binary). | |||
| * | |||
| * @param binary if true use binary mode in transfers. | |||
| */ | |||
| public void setBinary(boolean binary) { | |||
| this.binary = binary; | |||
| @@ -324,6 +347,8 @@ public class FTP | |||
| * Specifies whether to use passive mode. Set to true if you are behind a | |||
| * firewall and cannot connect without it. Passive mode is disabled by | |||
| * default. | |||
| * | |||
| * @param passive true is passive mode should be used. | |||
| */ | |||
| public void setPassive(boolean passive) { | |||
| this.passive = passive; | |||
| @@ -333,6 +358,8 @@ public class FTP | |||
| /** | |||
| * Set to true to receive notification about each file as it is | |||
| * transferred. | |||
| * | |||
| * @param verbose true if verbose notifications are required. | |||
| */ | |||
| public void setVerbose(boolean verbose) { | |||
| this.verbose = verbose; | |||
| @@ -340,8 +367,10 @@ public class FTP | |||
| /** | |||
| * A synonym for <tt>depends</tt>. Set to true to transmit only new or changed | |||
| * files. | |||
| * A synonym for <tt>depends</tt>. Set to true to transmit only new | |||
| * or changed files. | |||
| * | |||
| * @param newer if true only transfer newer files. | |||
| */ | |||
| public void setNewer(boolean newer) { | |||
| this.newerOnly = newer; | |||
| @@ -350,6 +379,8 @@ public class FTP | |||
| /** | |||
| * Set to true to preserve modification times for "gotten" files. | |||
| * | |||
| * @param preserveLastModified if true preserver modification times. | |||
| */ | |||
| public void setPreserveLastModified(boolean preserveLastModified) { | |||
| this.preserveLastModified = preserveLastModified; | |||
| @@ -359,6 +390,8 @@ public class FTP | |||
| /** | |||
| * Set to true to transmit only files that are new or changed from their | |||
| * remote counterparts. The default is to transmit all files. | |||
| * | |||
| * @param depends if true only transfer newer files. | |||
| */ | |||
| public void setDepends(boolean depends) { | |||
| this.newerOnly = depends; | |||
| @@ -370,6 +403,8 @@ public class FTP | |||
| * Unix standard forward slash, but can be manually overridden using this | |||
| * call if the remote server requires some other separator. Only the first | |||
| * character of the string is used. | |||
| * | |||
| * @param separator the file separator on the remote system. | |||
| */ | |||
| public void setSeparator(String separator) { | |||
| remoteFileSep = separator; | |||
| @@ -377,16 +412,22 @@ public class FTP | |||
| /** | |||
| * Sets the file permission mode (Unix only) for files sent to the server. | |||
| * Sets the file permission mode (Unix only) for files sent to the | |||
| * server. | |||
| * | |||
| * @param theMode unix style file mode for the files sent to the remote | |||
| * system. | |||
| */ | |||
| public void setChmod(String theMode) { | |||
| this.chmod = theMode; | |||
| } | |||
| /** Sets the default mask for file creation on a unix server. */ | |||
| /** | |||
| * Sets the default mask for file creation on a unix server. | |||
| * | |||
| * @param theUmask unix style umask for files created on the remote server. | |||
| */ | |||
| public void setUmask(String theUmask) { | |||
| this.umask = theUmask; | |||
| } | |||
| @@ -394,6 +435,9 @@ public class FTP | |||
| /** | |||
| * A set of files to upload or download | |||
| * | |||
| * @param set the set of files to be added to the list of files to be | |||
| * transferred. | |||
| */ | |||
| public void addFileset(FileSet set) { | |||
| filesets.addElement(set); | |||
| @@ -409,6 +453,10 @@ public class FTP | |||
| * work and also to encapsulate operations on the type in its own | |||
| * class. | |||
| * @ant.attribute ignore="true" | |||
| * | |||
| * @param action the FTP action to be performed. | |||
| * | |||
| * @throws BuildException if the action is not a valid action. | |||
| */ | |||
| public void setAction(String action) throws BuildException { | |||
| log("DEPRECATED - The setAction(String) method has been deprecated." | |||
| @@ -424,6 +472,10 @@ public class FTP | |||
| /** | |||
| * Sets the FTP action to be taken. Currently accepts "put", "get", "del", | |||
| * "mkdir", "chmod" and "list". | |||
| * | |||
| * @param action the FTP action to be performed. | |||
| * | |||
| * @throws BuildException if the action is not a valid action. | |||
| */ | |||
| public void setAction(Action action) throws BuildException { | |||
| this.action = action.getAction(); | |||
| @@ -433,8 +485,10 @@ public class FTP | |||
| /** | |||
| * The output file for the "list" action. This attribute is ignored for | |||
| * any other actions. | |||
| * | |||
| * @param listing file in which to store the listing. | |||
| */ | |||
| public void setListing(File listing) throws BuildException { | |||
| public void setListing(File listing) { | |||
| this.listing = listing; | |||
| } | |||
| @@ -443,6 +497,8 @@ public class FTP | |||
| * If true, enables unsuccessful file put, delete and get | |||
| * operations to be skipped with a warning and the remainder | |||
| * of the files still transferred. | |||
| * | |||
| * @param skipFailedTransfers true if failures in transfers are ignored. | |||
| */ | |||
| public void setSkipFailedTransfers(boolean skipFailedTransfers) { | |||
| this.skipFailedTransfers = skipFailedTransfers; | |||
| @@ -452,13 +508,20 @@ public class FTP | |||
| /** | |||
| * set the flag to skip errors on directory creation. | |||
| * (and maybe later other server specific errors) | |||
| * | |||
| * @param ignoreNoncriticalErrors true if non-critical errors should not | |||
| * cause a failure. | |||
| */ | |||
| public void setIgnoreNoncriticalErrors(boolean ignoreNoncriticalErrors) { | |||
| this.ignoreNoncriticalErrors = ignoreNoncriticalErrors; | |||
| } | |||
| /** Checks to see that all required parameters are set. */ | |||
| /** | |||
| * Checks to see that all required parameters are set. | |||
| * | |||
| * @throws BuildException if the configuration is not valid. | |||
| */ | |||
| protected void checkConfiguration() throws BuildException { | |||
| if (server == null) { | |||
| throw new BuildException("server attribute must be set!"); | |||
| @@ -490,6 +553,14 @@ public class FTP | |||
| /** | |||
| * For each file in the fileset, do the appropriate action: send, get, | |||
| * delete, or list. | |||
| * | |||
| * @param ftp the FTPClient instance used to perform FTP actions | |||
| * @param fs the fileset on which the actions are performed. | |||
| * | |||
| * @return the number of files to be transferred. | |||
| * | |||
| * @throws IOException if there is a problem reading a file | |||
| * @throws BuildException if there is a problem in the configuration. | |||
| */ | |||
| protected int transferFiles(FTPClient ftp, FileSet fs) | |||
| throws IOException, BuildException { | |||
| @@ -537,46 +608,26 @@ public class FTP | |||
| for (int i = 0; i < dsfiles.length; i++) { | |||
| switch (action) { | |||
| case SEND_FILES: | |||
| { | |||
| sendFile(ftp, dir, dsfiles[i]); | |||
| break; | |||
| } | |||
| case GET_FILES: | |||
| { | |||
| getFile(ftp, dir, dsfiles[i]); | |||
| break; | |||
| } | |||
| case DEL_FILES: | |||
| { | |||
| delFile(ftp, dsfiles[i]); | |||
| break; | |||
| } | |||
| case LIST_FILES: | |||
| { | |||
| listFile(ftp, bw, dsfiles[i]); | |||
| break; | |||
| } | |||
| case CHMOD: | |||
| { | |||
| doSiteCommand(ftp, "chmod " + chmod + " " + dsfiles[i]); | |||
| transferred++; | |||
| break; | |||
| } | |||
| case RM_DIR: | |||
| { | |||
| rmDir(ftp, dsfiles[i]); | |||
| break; | |||
| } | |||
| default: | |||
| { | |||
| throw new BuildException("unknown ftp action " + action); | |||
| } | |||
| } | |||
| } | |||
| } finally { | |||
| @@ -592,6 +643,11 @@ public class FTP | |||
| /** | |||
| * Sends all files specified by the configured filesets to the remote | |||
| * server. | |||
| * | |||
| * @param ftp the FTPClient instance used to perform FTP actions | |||
| * | |||
| * @throws IOException if there is a problem reading a file | |||
| * @throws BuildException if there is a problem in the configuration. | |||
| */ | |||
| protected void transferFiles(FTPClient ftp) | |||
| throws IOException, BuildException { | |||
| @@ -611,12 +667,11 @@ public class FTP | |||
| } | |||
| } | |||
| log(transferred + " " + ACTION_TARGET_STRS[action] + " " + | |||
| COMPLETED_ACTION_STRS[action]); | |||
| log(transferred + " " + ACTION_TARGET_STRS[action] + " " | |||
| + COMPLETED_ACTION_STRS[action]); | |||
| if (skipped != 0) { | |||
| log(skipped + " " + ACTION_TARGET_STRS[action] + | |||
| " were not successfully " | |||
| + COMPLETED_ACTION_STRS[action]); | |||
| log(skipped + " " + ACTION_TARGET_STRS[action] | |||
| + " were not successfully " + COMPLETED_ACTION_STRS[action]); | |||
| } | |||
| } | |||
| @@ -627,6 +682,10 @@ public class FTP | |||
| * Unix-style paths with forward-slash separators. This can be overridden | |||
| * with the <code>separator</code> task parameter. No attempt is made to | |||
| * determine what syntax is appropriate for the remote host. | |||
| * | |||
| * @param file the remote file name to be resolved | |||
| * | |||
| * @return the filename as it will appear on the server. | |||
| */ | |||
| protected String resolveFile(String file) { | |||
| return file.replace(System.getProperty("file.separator").charAt(0), | |||
| @@ -638,6 +697,11 @@ public class FTP | |||
| * Creates all parent directories specified in a complete relative | |||
| * pathname. Attempts to create existing directories will not cause | |||
| * errors. | |||
| * | |||
| * @param ftp the FTP client instance to use to execute FTP actions on | |||
| * the remote server. | |||
| * @param filename the name of the file whose parents should be created. | |||
| * | |||
| */ | |||
| protected void createParents(FTPClient ftp, String filename) | |||
| throws IOException, BuildException { | |||
| @@ -647,7 +711,7 @@ public class FTP | |||
| return; | |||
| } | |||
| Vector parents = new Vector(); | |||
| String dirname; | |||
| @@ -662,35 +726,35 @@ public class FTP | |||
| // find first non cached dir | |||
| int i = parents.size() - 1; | |||
| if (i >= 0) { | |||
| String cwd = ftp.printWorkingDirectory(); | |||
| String parent = dir.getParent(); | |||
| if (parent != null) { | |||
| if (!ftp.changeWorkingDirectory(resolveFile(parent))) { | |||
| throw new BuildException("could not change to " | |||
| throw new BuildException("could not change to " | |||
| + "directory: " + ftp.getReplyString()); | |||
| } | |||
| } | |||
| while (i >= 0) { | |||
| dir = (File) parents.elementAt(i--); | |||
| // check if dir exists by trying to change into it. | |||
| if (!ftp.changeWorkingDirectory(dir.getName())) { | |||
| // could not change to it - try to create it | |||
| log("creating remote directory " | |||
| log("creating remote directory " | |||
| + resolveFile(dir.getPath()), Project.MSG_VERBOSE); | |||
| if(!ftp.makeDirectory(dir.getName())) { | |||
| if (!ftp.makeDirectory(dir.getName())) { | |||
| handleMkDirFailure(ftp); | |||
| } | |||
| if (!ftp.changeWorkingDirectory(dir.getName())) { | |||
| throw new BuildException("could not change to " | |||
| throw new BuildException("could not change to " | |||
| + "directory: " + ftp.getReplyString()); | |||
| } | |||
| } | |||
| dirCache.addElement(dir); | |||
| } | |||
| ftp.changeWorkingDirectory(cwd); | |||
| ftp.changeWorkingDirectory(cwd); | |||
| } | |||
| } | |||
| @@ -717,8 +781,8 @@ public class FTP | |||
| + "assuming out of date.", Project.MSG_VERBOSE); | |||
| return false; | |||
| } else { | |||
| throw new BuildException("could not date test remote file: " + | |||
| ftp.getReplyString()); | |||
| throw new BuildException("could not date test remote file: " | |||
| + ftp.getReplyString()); | |||
| } | |||
| } | |||
| @@ -734,24 +798,24 @@ public class FTP | |||
| /** Sends a site command to the ftp server */ | |||
| protected void doSiteCommand(FTPClient ftp, String TheCMD) | |||
| protected void doSiteCommand(FTPClient ftp, String theCMD) | |||
| throws IOException, BuildException { | |||
| boolean rc; | |||
| String MyReply[] = null; | |||
| String myReply[] = null; | |||
| log("Doing Site Command: " + TheCMD, Project.MSG_VERBOSE); | |||
| log("Doing Site Command: " + theCMD, Project.MSG_VERBOSE); | |||
| rc = ftp.sendSiteCommand(TheCMD); | |||
| rc = ftp.sendSiteCommand(theCMD); | |||
| if (rc == false) { | |||
| log("Failed to issue Site Command: " + TheCMD, Project.MSG_WARN); | |||
| log("Failed to issue Site Command: " + theCMD, Project.MSG_WARN); | |||
| } else { | |||
| MyReply = ftp.getReplyStrings(); | |||
| myReply = ftp.getReplyStrings(); | |||
| for (int x = 0; x < MyReply.length; x++) { | |||
| if (MyReply[x].indexOf("200") == -1) { | |||
| log(MyReply[x], Project.MSG_WARN); | |||
| for (int x = 0; x < myReply.length; x++) { | |||
| if (myReply[x].indexOf("200") == -1) { | |||
| log(myReply[x], Project.MSG_WARN); | |||
| } | |||
| } | |||
| } | |||
| @@ -794,7 +858,7 @@ public class FTP | |||
| if (!success) { | |||
| String s = "could not put file: " + ftp.getReplyString(); | |||
| if (skipFailedTransfers == true) { | |||
| if (skipFailedTransfers) { | |||
| log(s, Project.MSG_WARN); | |||
| skipped++; | |||
| } else { | |||
| @@ -802,7 +866,8 @@ public class FTP | |||
| } | |||
| } else { | |||
| if (chmod != null) {// see if we should issue a chmod command | |||
| // see if we should issue a chmod command | |||
| if (chmod != null) { | |||
| doSiteCommand(ftp, "chmod " + chmod + " " + filename); | |||
| } | |||
| log("File " + file.getAbsolutePath() + " copied to " + server, | |||
| @@ -831,7 +896,7 @@ public class FTP | |||
| if (!ftp.deleteFile(resolveFile(filename))) { | |||
| String s = "could not delete file: " + ftp.getReplyString(); | |||
| if (skipFailedTransfers == true) { | |||
| if (skipFailedTransfers) { | |||
| log(s, Project.MSG_WARN); | |||
| skipped++; | |||
| } else { | |||
| @@ -854,7 +919,7 @@ public class FTP | |||
| if (!ftp.removeDirectory(resolveFile(dirname))) { | |||
| String s = "could not remove directory: " + ftp.getReplyString(); | |||
| if (skipFailedTransfers == true) { | |||
| if (skipFailedTransfers) { | |||
| log(s, Project.MSG_WARN); | |||
| skipped++; | |||
| } else { | |||
| @@ -904,7 +969,7 @@ public class FTP | |||
| if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { | |||
| String s = "could not get file: " + ftp.getReplyString(); | |||
| if (skipFailedTransfers == true) { | |||
| if (skipFailedTransfers) { | |||
| log(s, Project.MSG_WARN); | |||
| skipped++; | |||
| } else { | |||
| @@ -984,13 +1049,15 @@ public class FTP | |||
| subdir = st.nextToken(); | |||
| log("Checking " + subdir, Project.MSG_DEBUG); | |||
| if (!ftp.changeWorkingDirectory(subdir)) { | |||
| if(!ftp.makeDirectory(subdir)) { | |||
| if (!ftp.makeDirectory(subdir)) { | |||
| // codes 521, 550 and 553 can be produced by FTP Servers | |||
| // to indicate that an attempt to create a directory has | |||
| // failed because the directory already exists. | |||
| int rc = ftp.getReplyCode(); | |||
| if (!(ignoreNoncriticalErrors && (rc == 550 || rc == 553 || rc==521))) { | |||
| throw new BuildException("could not create directory: " + ftp.getReplyString()); | |||
| if (!(ignoreNoncriticalErrors | |||
| && (rc == 550 || rc == 553 || rc == 521))) { | |||
| throw new BuildException("could not create directory: " | |||
| + ftp.getReplyString()); | |||
| } | |||
| if (verbose) { | |||
| log("Directory already exists"); | |||
| @@ -1016,17 +1083,21 @@ public class FTP | |||
| */ | |||
| private void handleMkDirFailure(FTPClient ftp) | |||
| throws BuildException { | |||
| int rc=ftp.getReplyCode(); | |||
| int rc = ftp.getReplyCode(); | |||
| if (!(ignoreNoncriticalErrors | |||
| && (rc == 550 || rc == 553 || rc == 521))) { | |||
| throw new BuildException("could not create directory: " + | |||
| ftp.getReplyString()); | |||
| throw new BuildException("could not create directory: " | |||
| + ftp.getReplyString()); | |||
| } | |||
| } | |||
| /** Runs the task. */ | |||
| public void execute() | |||
| throws BuildException { | |||
| /** | |||
| * Runs the task. | |||
| * | |||
| * @throws BuildException if the task fails or is not configured | |||
| * correctly. | |||
| */ | |||
| public void execute() throws BuildException { | |||
| checkConfiguration(); | |||
| FTPClient ftp = null; | |||
| @@ -1054,8 +1125,8 @@ public class FTP | |||
| if (binary) { | |||
| ftp.setFileType(org.apache.commons.net.ftp.FTP.IMAGE_FILE_TYPE); | |||
| if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { | |||
| throw new BuildException("could not set transfer type: " + | |||
| ftp.getReplyString()); | |||
| throw new BuildException("could not set transfer type: " | |||
| + ftp.getReplyString()); | |||
| } | |||
| } | |||
| @@ -1064,8 +1135,7 @@ public class FTP | |||
| ftp.enterLocalPassiveMode(); | |||
| if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { | |||
| throw new BuildException("could not enter into passive " | |||
| + "mode: " + | |||
| ftp.getReplyString()); | |||
| + "mode: " + ftp.getReplyString()); | |||
| } | |||
| } | |||
| @@ -1087,8 +1157,7 @@ public class FTP | |||
| ftp.changeWorkingDirectory(remotedir); | |||
| if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { | |||
| throw new BuildException("could not change remote " | |||
| + "directory: " + | |||
| ftp.getReplyString()); | |||
| + "directory: " + ftp.getReplyString()); | |||
| } | |||
| } | |||
| log(ACTION_STRS[action] + " " + ACTION_TARGET_STRS[action]); | |||
| @@ -1118,28 +1187,35 @@ public class FTP | |||
| */ | |||
| public static class Action extends EnumeratedAttribute { | |||
| private static final String[] validActions = { | |||
| private static final String[] VALID_ACTIONS = { | |||
| "send", "put", "recv", "get", "del", "delete", "list", "mkdir", | |||
| "chmod", "rmdir" | |||
| }; | |||
| /** | |||
| * Get the valid values | |||
| * | |||
| * @return an array of the valid FTP actions. | |||
| */ | |||
| public String[] getValues() { | |||
| return validActions; | |||
| return VALID_ACTIONS; | |||
| } | |||
| /** | |||
| * Get the symbolic equivalent of the action value. | |||
| * | |||
| * @return the SYMBOL representing the given action. | |||
| */ | |||
| public int getAction() { | |||
| String actionL = getValue().toLowerCase(Locale.US); | |||
| if (actionL.equals("send") || | |||
| actionL.equals("put")) { | |||
| if (actionL.equals("send") || actionL.equals("put")) { | |||
| return SEND_FILES; | |||
| } else if (actionL.equals("recv") || | |||
| actionL.equals("get")) { | |||
| } else if (actionL.equals("recv") || actionL.equals("get")) { | |||
| return GET_FILES; | |||
| } else if (actionL.equals("del") || | |||
| actionL.equals("delete")) { | |||
| } else if (actionL.equals("del") || actionL.equals("delete")) { | |||
| return DEL_FILES; | |||
| } else if (actionL.equals("list")) { | |||
| return LIST_FILES; | |||