git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268237 13f79535-47bb-0310-9956-ffa450edef68master
@@ -51,7 +51,6 @@ | |||||
* information on the Apache Software Foundation, please see | * information on the Apache Software Foundation, please see | ||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
import java.util.EventObject; | import java.util.EventObject; | ||||
@@ -64,7 +63,6 @@ public class BuildEvent extends EventObject { | |||||
private int priority = Project.MSG_VERBOSE; | private int priority = Project.MSG_VERBOSE; | ||||
private Throwable exception; | private Throwable exception; | ||||
/** | /** | ||||
* Construct a BuildEvent for a project level event | * Construct a BuildEvent for a project level event | ||||
* | * | ||||
@@ -163,4 +161,4 @@ public class BuildEvent extends EventObject { | |||||
public Throwable getException() { | public Throwable getException() { | ||||
return exception; | return exception; | ||||
} | } | ||||
} | |||||
} |
@@ -51,7 +51,6 @@ | |||||
* information on the Apache Software Foundation, please see | * information on the Apache Software Foundation, please see | ||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
/** | /** | ||||
@@ -59,7 +58,6 @@ package org.apache.tools.ant; | |||||
* | * | ||||
* @author James Duncan Davidson | * @author James Duncan Davidson | ||||
*/ | */ | ||||
public class BuildException extends RuntimeException { | public class BuildException extends RuntimeException { | ||||
/** Exception that might have caused this one. */ | /** Exception that might have caused this one. */ | ||||
@@ -71,18 +69,16 @@ public class BuildException extends RuntimeException { | |||||
/** | /** | ||||
* Constructs a build exception with no descriptive information. | * Constructs a build exception with no descriptive information. | ||||
*/ | */ | ||||
public BuildException() { | public BuildException() { | ||||
super(); | |||||
super(); | |||||
} | } | ||||
/** | /** | ||||
* Constructs an exception with the given descriptive message. | * Constructs an exception with the given descriptive message. | ||||
* @param msg Description of or information about the exception. | * @param msg Description of or information about the exception. | ||||
*/ | */ | ||||
public BuildException(String msg) { | public BuildException(String msg) { | ||||
super(msg); | |||||
super(msg); | |||||
} | } | ||||
/** | /** | ||||
@@ -91,10 +87,9 @@ public class BuildException extends RuntimeException { | |||||
* @param msg Description of or information about the exception. | * @param msg Description of or information about the exception. | ||||
* @param cause Throwable that might have cause this one. | * @param cause Throwable that might have cause this one. | ||||
*/ | */ | ||||
public BuildException(String msg, Throwable cause) { | public BuildException(String msg, Throwable cause) { | ||||
super(msg); | |||||
this.cause = cause; | |||||
super(msg); | |||||
this.cause = cause; | |||||
} | } | ||||
/** | /** | ||||
@@ -104,20 +99,18 @@ public class BuildException extends RuntimeException { | |||||
* @param cause Exception that might have cause this one. | * @param cause Exception that might have cause this one. | ||||
* @param location Location in the project file where the error occured. | * @param location Location in the project file where the error occured. | ||||
*/ | */ | ||||
public BuildException(String msg, Throwable cause, Location location) { | public BuildException(String msg, Throwable cause, Location location) { | ||||
this(msg, cause); | this(msg, cause); | ||||
this.location = location; | |||||
this.location = location; | |||||
} | } | ||||
/** | /** | ||||
* Constructs an exception with the given exception as a root cause. | * Constructs an exception with the given exception as a root cause. | ||||
* @param cause Exception that might have caused this one. | * @param cause Exception that might have caused this one. | ||||
*/ | */ | ||||
public BuildException(Throwable cause) { | public BuildException(Throwable cause) { | ||||
super(cause.toString()); | |||||
this.cause = cause; | |||||
super(cause.toString()); | |||||
this.cause = cause; | |||||
} | } | ||||
/** | /** | ||||
@@ -126,10 +119,9 @@ public class BuildException extends RuntimeException { | |||||
* @param msg Description of or information about the exception. | * @param msg Description of or information about the exception. | ||||
* @param location Location in the project file where the error occured. | * @param location Location in the project file where the error occured. | ||||
*/ | */ | ||||
public BuildException(String msg, Location location) { | public BuildException(String msg, Location location) { | ||||
super(msg); | |||||
this.location = location; | |||||
super(msg); | |||||
this.location = location; | |||||
} | } | ||||
/** | /** | ||||
@@ -138,10 +130,9 @@ public class BuildException extends RuntimeException { | |||||
* @param cause Exception that might have cause this one. | * @param cause Exception that might have cause this one. | ||||
* @param location Location in the project file where the error occured. | * @param location Location in the project file where the error occured. | ||||
*/ | */ | ||||
public BuildException(Throwable cause, Location location) { | public BuildException(Throwable cause, Location location) { | ||||
this(cause); | this(cause); | ||||
this.location = location; | |||||
this.location = location; | |||||
} | } | ||||
/** | /** | ||||
@@ -68,7 +68,7 @@ public class DefaultLogger implements BuildLogger { | |||||
protected PrintStream err; | protected PrintStream err; | ||||
protected int msgOutputLevel; | protected int msgOutputLevel; | ||||
private long startTime = System.currentTimeMillis(); | private long startTime = System.currentTimeMillis(); | ||||
protected static String lSep = System.getProperty("line.separator"); | protected static String lSep = System.getProperty("line.separator"); | ||||
protected boolean emacsMode = false; | protected boolean emacsMode = false; | ||||
@@ -55,8 +55,8 @@ | |||||
package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | |||||
import java.io.FilenameFilter; | import java.io.FilenameFilter; | ||||
import java.io.IOException; | |||||
/** | /** | ||||
* Filters filenames to determine whether or not the file is desirable. | * Filters filenames to determine whether or not the file is desirable. | ||||
@@ -64,7 +64,6 @@ import java.io.FilenameFilter; | |||||
* @author Jason Hunter [jhunter@servlets.com] | * @author Jason Hunter [jhunter@servlets.com] | ||||
* @author james@x180.com | * @author james@x180.com | ||||
*/ | */ | ||||
public class DesirableFilter implements FilenameFilter { | public class DesirableFilter implements FilenameFilter { | ||||
/** | /** | ||||
@@ -73,40 +72,40 @@ public class DesirableFilter implements FilenameFilter { | |||||
*/ | */ | ||||
public boolean accept(File dir, String name) { | public boolean accept(File dir, String name) { | ||||
// emacs save file | |||||
if (name.endsWith("~")) { | |||||
return false; | |||||
} | |||||
// emacs autosave file | |||||
if (name.startsWith("#") && name.endsWith("#")) { | |||||
return false; | |||||
} | |||||
// openwindows text editor does this I think | |||||
if (name.startsWith("%") && name.endsWith("%")) { | |||||
return false; | |||||
} | |||||
/* CVS stuff -- hopefully there won't be a case with | |||||
* an all cap file/dir named "CVS" that somebody wants | |||||
* to keep around... | |||||
*/ | |||||
if (name.equals("CVS")) { | |||||
return false; | |||||
} | |||||
/* If we are going to ignore CVS might as well ignore | |||||
* this one as well... | |||||
*/ | |||||
if (name.equals(".cvsignore")){ | |||||
return false; | |||||
} | |||||
// emacs save file | |||||
if (name.endsWith("~")) { | |||||
return false; | |||||
} | |||||
// emacs autosave file | |||||
if (name.startsWith("#") && name.endsWith("#")) { | |||||
return false; | |||||
} | |||||
// openwindows text editor does this I think | |||||
if (name.startsWith("%") && name.endsWith("%")) { | |||||
return false; | |||||
} | |||||
/* CVS stuff -- hopefully there won't be a case with | |||||
* an all cap file/dir named "CVS" that somebody wants | |||||
* to keep around... | |||||
*/ | |||||
if (name.equals("CVS")) { | |||||
return false; | |||||
} | |||||
/* If we are going to ignore CVS might as well ignore | |||||
* this one as well... | |||||
*/ | |||||
if (name.equals(".cvsignore")){ | |||||
return false; | |||||
} | |||||
// default | |||||
return true; | |||||
// default | |||||
return true; | |||||
} | } | ||||
} | } | ||||
@@ -7,96 +7,96 @@ import java.io.*; | |||||
* directory scanner. | * directory scanner. | ||||
*/ | */ | ||||
public interface FileScanner { | public interface FileScanner { | ||||
/** | |||||
* Adds an array with default exclusions to the current exclusions set. | |||||
* | |||||
*/ | |||||
public void addDefaultExcludes(); | |||||
/** | |||||
* Gets the basedir that is used for scanning. This is the directory that | |||||
* is scanned recursively. | |||||
* | |||||
* @return the basedir that is used for scanning | |||||
*/ | |||||
public File getBasedir(); | |||||
/** | |||||
* Get the names of the directories that matched at least one of the include | |||||
* patterns, an matched also at least one of the exclude patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the directories | |||||
*/ | |||||
public String[] getExcludedDirectories(); | |||||
/** | |||||
* Get the names of the files that matched at least one of the include | |||||
* patterns, an matched also at least one of the exclude patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the files | |||||
*/ | |||||
public String[] getExcludedFiles(); | |||||
/** | |||||
* Get the names of the directories that matched at least one of the include | |||||
* patterns, an matched none of the exclude patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the directories | |||||
*/ | |||||
public String[] getIncludedDirectories(); | |||||
/** | |||||
* Get the names of the files that matched at least one of the include | |||||
* patterns, an matched none of the exclude patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the files | |||||
*/ | |||||
public String[] getIncludedFiles(); | |||||
/** | |||||
* Get the names of the directories that matched at none of the include | |||||
* patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the directories | |||||
*/ | |||||
public String[] getNotIncludedDirectories(); | |||||
/** | |||||
* Get the names of the files that matched at none of the include patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the files | |||||
*/ | |||||
public String[] getNotIncludedFiles(); | |||||
/** | |||||
* Scans the base directory for files that match at least one include | |||||
* pattern, and don't match any exclude patterns. | |||||
* | |||||
* @exception IllegalStateException when basedir was set incorrecly | |||||
*/ | |||||
public void scan(); | |||||
/** | |||||
* Sets the basedir for scanning. This is the directory that is scanned | |||||
* recursively. | |||||
* | |||||
* @param basedir the (non-null) basedir for scanning | |||||
*/ | |||||
public void setBasedir(String basedir); | |||||
/** | |||||
* Sets the basedir for scanning. This is the directory that is scanned | |||||
* recursively. | |||||
* | |||||
* @param basedir the basedir for scanning | |||||
*/ | |||||
public void setBasedir(File basedir); | |||||
/** | |||||
* Sets the set of exclude patterns to use. | |||||
* | |||||
* @param excludes list of exclude patterns | |||||
*/ | |||||
public void setExcludes(String[] excludes); | |||||
/** | |||||
* Sets the set of include patterns to use. | |||||
* | |||||
* @param includes list of include patterns | |||||
*/ | |||||
public void setIncludes(String[] includes); | |||||
} | |||||
/** | |||||
* Adds an array with default exclusions to the current exclusions set. | |||||
* | |||||
*/ | |||||
public void addDefaultExcludes(); | |||||
/** | |||||
* Gets the basedir that is used for scanning. This is the directory that | |||||
* is scanned recursively. | |||||
* | |||||
* @return the basedir that is used for scanning | |||||
*/ | |||||
public File getBasedir(); | |||||
/** | |||||
* Get the names of the directories that matched at least one of the include | |||||
* patterns, an matched also at least one of the exclude patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the directories | |||||
*/ | |||||
public String[] getExcludedDirectories(); | |||||
/** | |||||
* Get the names of the files that matched at least one of the include | |||||
* patterns, an matched also at least one of the exclude patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the files | |||||
*/ | |||||
public String[] getExcludedFiles(); | |||||
/** | |||||
* Get the names of the directories that matched at least one of the include | |||||
* patterns, an matched none of the exclude patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the directories | |||||
*/ | |||||
public String[] getIncludedDirectories(); | |||||
/** | |||||
* Get the names of the files that matched at least one of the include | |||||
* patterns, an matched none of the exclude patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the files | |||||
*/ | |||||
public String[] getIncludedFiles(); | |||||
/** | |||||
* Get the names of the directories that matched at none of the include | |||||
* patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the directories | |||||
*/ | |||||
public String[] getNotIncludedDirectories(); | |||||
/** | |||||
* Get the names of the files that matched at none of the include patterns. | |||||
* The names are relative to the basedir. | |||||
* | |||||
* @return the names of the files | |||||
*/ | |||||
public String[] getNotIncludedFiles(); | |||||
/** | |||||
* Scans the base directory for files that match at least one include | |||||
* pattern, and don't match any exclude patterns. | |||||
* | |||||
* @exception IllegalStateException when basedir was set incorrecly | |||||
*/ | |||||
public void scan(); | |||||
/** | |||||
* Sets the basedir for scanning. This is the directory that is scanned | |||||
* recursively. | |||||
* | |||||
* @param basedir the (non-null) basedir for scanning | |||||
*/ | |||||
public void setBasedir(String basedir); | |||||
/** | |||||
* Sets the basedir for scanning. This is the directory that is scanned | |||||
* recursively. | |||||
* | |||||
* @param basedir the basedir for scanning | |||||
*/ | |||||
public void setBasedir(File basedir); | |||||
/** | |||||
* Sets the set of exclude patterns to use. | |||||
* | |||||
* @param excludes list of exclude patterns | |||||
*/ | |||||
public void setExcludes(String[] excludes); | |||||
/** | |||||
* Sets the set of include patterns to use. | |||||
* | |||||
* @param includes list of include patterns | |||||
*/ | |||||
public void setIncludes(String[] includes); | |||||
} |
@@ -55,57 +55,57 @@ | |||||
package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
/** | /** | ||||
* Stores the file name and line number in a file. | |||||
* Stores the file name and line number in a file. | |||||
*/ | */ | ||||
public class Location { | public class Location { | ||||
private String fileName; | |||||
private int lineNumber; | |||||
private int columnNumber; | |||||
private String fileName; | |||||
private int lineNumber; | |||||
private int columnNumber; | |||||
public static final Location UNKNOWN_LOCATION = new Location(); | |||||
public static final Location UNKNOWN_LOCATION = new Location(); | |||||
/** | |||||
* Creates an "unknown" location. | |||||
*/ | |||||
private Location() { | |||||
this(null, 0, 0); | |||||
} | |||||
/** | |||||
* Creates an "unknown" location. | |||||
*/ | |||||
private Location() { | |||||
this(null, 0, 0); | |||||
} | |||||
/** | |||||
* Creates a location consisting of a file name but no line number. | |||||
*/ | |||||
public Location(String fileName) { | |||||
this(fileName, 0, 0); | |||||
} | |||||
/** | |||||
* Creates a location consisting of a file name but no line number. | |||||
*/ | |||||
public Location(String fileName) { | |||||
this(fileName, 0, 0); | |||||
} | |||||
/** | |||||
* Creates a location consisting of a file name and line number. | |||||
*/ | |||||
public Location(String fileName, int lineNumber, int columnNumber) { | |||||
this.fileName = fileName; | |||||
this.lineNumber = lineNumber; | |||||
this.columnNumber = columnNumber; | |||||
} | |||||
/** | |||||
* Creates a location consisting of a file name and line number. | |||||
*/ | |||||
public Location(String fileName, int lineNumber, int columnNumber) { | |||||
this.fileName = fileName; | |||||
this.lineNumber = lineNumber; | |||||
this.columnNumber = columnNumber; | |||||
} | |||||
/** | |||||
* Returns the file name, line number and a trailing space. An error | |||||
* message can be appended easily. For unknown locations, returns | |||||
* an empty string. | |||||
*/ | |||||
public String toString() { | |||||
StringBuffer buf = new StringBuffer(); | |||||
/** | |||||
* Returns the file name, line number and a trailing space. An error | |||||
* message can be appended easily. For unknown locations, returns | |||||
* an empty string. | |||||
*/ | |||||
public String toString() { | |||||
StringBuffer buf = new StringBuffer(); | |||||
if (fileName != null) { | |||||
buf.append(fileName); | |||||
if (fileName != null) { | |||||
buf.append(fileName); | |||||
if (lineNumber != 0) { | |||||
buf.append(":"); | |||||
buf.append(lineNumber); | |||||
} | |||||
if (lineNumber != 0) { | |||||
buf.append(":"); | |||||
buf.append(lineNumber); | |||||
} | |||||
buf.append(": "); | |||||
} | |||||
buf.append(": "); | |||||
} | |||||
return buf.toString(); | |||||
} | |||||
} | |||||
return buf.toString(); | |||||
} | |||||
} |
@@ -316,7 +316,7 @@ public class Project { | |||||
public void setBaseDir(File baseDir) { | public void setBaseDir(File baseDir) { | ||||
this.baseDir = baseDir; | this.baseDir = baseDir; | ||||
setProperty( "basedir", baseDir.getAbsolutePath()); | |||||
setProperty( "basedir", baseDir.getAbsolutePath()); | |||||
String msg = "Project base dir set to: " + baseDir; | String msg = "Project base dir set to: " + baseDir; | ||||
log(msg, MSG_VERBOSE); | log(msg, MSG_VERBOSE); | ||||
} | } | ||||
@@ -429,7 +429,7 @@ public class Project { | |||||
public Task createTask(String taskType) throws BuildException { | public Task createTask(String taskType) throws BuildException { | ||||
Class c = (Class) taskClassDefinitions.get(taskType); | Class c = (Class) taskClassDefinitions.get(taskType); | ||||
if (c == null) | |||||
if (c == null) | |||||
return null; | return null; | ||||
try { | try { | ||||
Object o = c.newInstance(); | Object o = c.newInstance(); | ||||
@@ -462,7 +462,7 @@ public class Project { | |||||
public Object createDataType(String typeName) throws BuildException { | public Object createDataType(String typeName) throws BuildException { | ||||
Class c = (Class) dataClassDefinitions.get(typeName); | Class c = (Class) dataClassDefinitions.get(typeName); | ||||
if (c == null) | |||||
if (c == null) | |||||
return null; | return null; | ||||
try { | try { | ||||
@@ -139,9 +139,9 @@ public class Target { | |||||
try { | try { | ||||
project.fireTaskStarted(task); | project.fireTaskStarted(task); | ||||
task.maybeConfigure(); | task.maybeConfigure(); | ||||
task.execute(); | |||||
task.execute(); | |||||
project.fireTaskFinished(task, null); | project.fireTaskFinished(task, null); | ||||
} | |||||
} | |||||
catch(RuntimeException exc) { | catch(RuntimeException exc) { | ||||
if (exc instanceof BuildException) { | if (exc instanceof BuildException) { | ||||
BuildException be = (BuildException) exc; | BuildException be = (BuildException) exc; | ||||
@@ -160,11 +160,11 @@ public abstract class Task { | |||||
* what we are doing. | * what we are doing. | ||||
*/ | */ | ||||
public void setDescription( String desc ) { | public void setDescription( String desc ) { | ||||
description=desc; | |||||
description=desc; | |||||
} | } | ||||
public String getDescription() { | public String getDescription() { | ||||
return description; | |||||
return description; | |||||
} | } | ||||
/** | /** | ||||
@@ -71,20 +71,20 @@ public class TaskAdapter extends Task { | |||||
* Do the execution. | * Do the execution. | ||||
*/ | */ | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
Method executeM=null; | |||||
try { | |||||
Class c=proxy.getClass(); | |||||
executeM=c.getMethod( "execute", new Class[0] ); | |||||
if( executeM == null ) { | |||||
log("No execute in " + proxy.getClass(), Project.MSG_ERR); | |||||
throw new BuildException("No execute in " + proxy.getClass()); | |||||
} | |||||
executeM.invoke(proxy, null); | |||||
return; | |||||
} catch( Exception ex ) { | |||||
log("Error in " + proxy.getClass(), Project.MSG_ERR); | |||||
throw new BuildException( ex ); | |||||
} | |||||
Method executeM=null; | |||||
try { | |||||
Class c=proxy.getClass(); | |||||
executeM=c.getMethod( "execute", new Class[0] ); | |||||
if( executeM == null ) { | |||||
log("No execute in " + proxy.getClass(), Project.MSG_ERR); | |||||
throw new BuildException("No execute in " + proxy.getClass()); | |||||
} | |||||
executeM.invoke(proxy, null); | |||||
return; | |||||
} catch( Exception ex ) { | |||||
log("Error in " + proxy.getClass(), Project.MSG_ERR); | |||||
throw new BuildException( ex ); | |||||
} | |||||
} | } | ||||
@@ -238,9 +238,9 @@ public class Ant extends Task { | |||||
reinit(); | reinit(); | ||||
} | } | ||||
Property p=(Property)p1.createTask("property"); | |||||
p.setUserProperty(true); | |||||
properties.addElement( p ); | |||||
return p; | |||||
Property p=(Property)p1.createTask("property"); | |||||
p.setUserProperty(true); | |||||
properties.addElement( p ); | |||||
return p; | |||||
} | } | ||||
} | } |
@@ -221,10 +221,10 @@ public class Execute { | |||||
* @param wd the working directory of the process. | * @param wd the working directory of the process. | ||||
*/ | */ | ||||
public void setWorkingDirectory(File wd) { | public void setWorkingDirectory(File wd) { | ||||
if (wd == null || wd.getAbsolutePath().equals(antWorkingDirectory)) | |||||
workingDirectory = null; | |||||
else | |||||
workingDirectory = wd; | |||||
if (wd == null || wd.getAbsolutePath().equals(antWorkingDirectory)) | |||||
workingDirectory = null; | |||||
else | |||||
workingDirectory = wd; | |||||
} | } | ||||
/** | /** | ||||
@@ -383,11 +383,12 @@ public class Execute { | |||||
* Launches the given command in a new process, in the given working | * Launches the given command in a new process, in the given working | ||||
* directory | * directory | ||||
*/ | */ | ||||
public Process exec(Project project, String[] cmd, String[] env, File workingDir) throws IOException | |||||
public Process exec(Project project, String[] cmd, String[] env, File workingDir) | |||||
throws IOException | |||||
{ | { | ||||
try { | |||||
Object[] arguments = { cmd, env, workingDir }; | |||||
return (Process)_execWithCWD.invoke(Runtime.getRuntime(), arguments); | |||||
try { | |||||
Object[] arguments = { cmd, env, workingDir }; | |||||
return (Process)_execWithCWD.invoke(Runtime.getRuntime(), arguments); | |||||
} | } | ||||
catch ( InvocationTargetException exc ) { | catch ( InvocationTargetException exc ) { | ||||
Throwable realexc = exc.getTargetException(); | Throwable realexc = exc.getTargetException(); | ||||
@@ -400,16 +401,16 @@ public class Execute { | |||||
else { | else { | ||||
throw new IOException(realexc.getMessage()); | throw new IOException(realexc.getMessage()); | ||||
} | } | ||||
} | |||||
} | |||||
catch ( Exception exc ) { | catch ( Exception exc ) { | ||||
// IllegalAccess, IllegalArgument, ClassCast | |||||
throw new IOException(exc.getMessage()); | |||||
} | |||||
// IllegalAccess, IllegalArgument, ClassCast | |||||
throw new IOException(exc.getMessage()); | |||||
} | |||||
} | } | ||||
private Method _execWithCWD; | private Method _execWithCWD; | ||||
} | } | ||||
/** | /** | ||||
* A command launcher that proxies another command launcher. | * A command launcher that proxies another command launcher. | ||||
* | * | ||||
@@ -458,13 +459,13 @@ public class Execute { | |||||
// Use cmd.exe to change to the specified directory before running | // Use cmd.exe to change to the specified directory before running | ||||
// the command | // the command | ||||
String[] newcmd = new String[cmd.length+5]; | |||||
newcmd[0] = "cmd"; | |||||
newcmd[1] = "/c"; | |||||
newcmd[2] = "cd"; | |||||
newcmd[3] = workingDir.getAbsolutePath(); | |||||
newcmd[4] = "&&"; | |||||
System.arraycopy(cmd, 0, newcmd, 5, cmd.length); | |||||
String[] newcmd = new String[cmd.length+5]; | |||||
newcmd[0] = "cmd"; | |||||
newcmd[1] = "/c"; | |||||
newcmd[2] = "cd"; | |||||
newcmd[3] = workingDir.getAbsolutePath(); | |||||
newcmd[4] = "&&"; | |||||
System.arraycopy(cmd, 0, newcmd, 5, cmd.length); | |||||
return exec(project, newcmd, env); | return exec(project, newcmd, env); | ||||
} | } | ||||
} | } | ||||
@@ -490,13 +491,13 @@ public class Execute { | |||||
return exec(project, cmd, env); | return exec(project, cmd, env); | ||||
} | } | ||||
System.getProperties().put("user.dir", workingDir.getAbsolutePath()); | |||||
try { | |||||
return exec(project, cmd, env); | |||||
} | |||||
System.getProperties().put("user.dir", workingDir.getAbsolutePath()); | |||||
try { | |||||
return exec(project, cmd, env); | |||||
} | |||||
finally { | finally { | ||||
System.getProperties().put("user.dir", antWorkingDirectory); | System.getProperties().put("user.dir", antWorkingDirectory); | ||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -533,11 +534,11 @@ public class Execute { | |||||
String antRun = project.resolveFile(antHome + File.separator + _script).toString(); | String antRun = project.resolveFile(antHome + File.separator + _script).toString(); | ||||
// Build the command | // Build the command | ||||
String[] newcmd = new String[cmd.length + 2]; | |||||
newcmd[0] = antRun; | |||||
newcmd[1] = workingDir.getAbsolutePath(); | |||||
System.arraycopy(cmd, 0, newcmd, 2, cmd.length); | |||||
String[] newcmd = new String[cmd.length + 2]; | |||||
newcmd[0] = antRun; | |||||
newcmd[1] = workingDir.getAbsolutePath(); | |||||
System.arraycopy(cmd, 0, newcmd, 2, cmd.length); | |||||
return exec(project, newcmd, env); | return exec(project, newcmd, env); | ||||
} | } | ||||
@@ -116,25 +116,25 @@ public class ExecuteWatchdog implements Runnable { | |||||
* Watches the process and terminates it, if it runs for to long. | * Watches the process and terminates it, if it runs for to long. | ||||
*/ | */ | ||||
public synchronized void run() { | public synchronized void run() { | ||||
try { | |||||
// This isn't a Task, don't have a Project object to log. | |||||
// project.log("ExecuteWatchdog: timeout = "+timeout+" msec", Project.MSG_VERBOSE); | |||||
final long until = System.currentTimeMillis() + timeout; | |||||
long now; | |||||
while (watch && until > (now = System.currentTimeMillis())) { | |||||
try { | |||||
wait(until - now); | |||||
} catch (InterruptedException e) {} | |||||
} | |||||
if (watch) { | |||||
process.destroy(); | |||||
} | |||||
stop(); | |||||
} catch(Exception e) { | |||||
try { | |||||
// This isn't a Task, don't have a Project object to log. | |||||
// project.log("ExecuteWatchdog: timeout = "+timeout+" msec", Project.MSG_VERBOSE); | |||||
final long until = System.currentTimeMillis() + timeout; | |||||
long now; | |||||
while (watch && until > (now = System.currentTimeMillis())) { | |||||
try { | |||||
wait(until - now); | |||||
} catch (InterruptedException e) {} | |||||
} | |||||
if (watch) { | |||||
process.destroy(); | |||||
} | |||||
stop(); | |||||
} catch(Exception e) { | |||||
caught = e; | caught = e; | ||||
} | } | ||||
} | } | ||||
public void checkException() throws BuildException { | public void checkException() throws BuildException { | ||||
if (caught != null) { | if (caught != null) { | ||||
throw new BuildException("Exception in ExecuteWatchdog.run: " | throw new BuildException("Exception in ExecuteWatchdog.run: " | ||||
@@ -110,58 +110,57 @@ public class Expand extends MatchingTask { | |||||
private void expandFile(Touch touch, File srcF, File dir) { | private void expandFile(Touch touch, File srcF, File dir) { | ||||
ZipInputStream zis = null; | ZipInputStream zis = null; | ||||
try { | |||||
log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); | |||||
// code from WarExpand | |||||
zis = new ZipInputStream(new FileInputStream(srcF)); | |||||
ZipEntry ze = null; | |||||
while ((ze = zis.getNextEntry()) != null) { | |||||
File f = new File(dir, project.translatePath(ze.getName())); | |||||
try { | |||||
log("expand-file " + ze.getName() , Project.MSG_VERBOSE ); | |||||
// create intermediary directories - sometimes zip don't add them | |||||
File dirF=new File(f.getParent()); | |||||
dirF.mkdirs(); | |||||
if (ze.isDirectory()) { | |||||
f.mkdirs(); | |||||
} else { | |||||
byte[] buffer = new byte[1024]; | |||||
int length = 0; | |||||
FileOutputStream fos = new FileOutputStream(f); | |||||
while ((length = zis.read(buffer)) >= 0) { | |||||
fos.write(buffer, 0, length); | |||||
} | |||||
fos.close(); | |||||
} | |||||
try { | |||||
log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); | |||||
// code from WarExpand | |||||
zis = new ZipInputStream(new FileInputStream(srcF)); | |||||
ZipEntry ze = null; | |||||
while ((ze = zis.getNextEntry()) != null) { | |||||
File f = new File(dir, project.translatePath(ze.getName())); | |||||
try { | |||||
log("expand-file " + ze.getName() , Project.MSG_VERBOSE ); | |||||
// create intermediary directories - sometimes zip don't add them | |||||
File dirF=new File(f.getParent()); | |||||
dirF.mkdirs(); | |||||
if (ze.isDirectory()) { | |||||
f.mkdirs(); | |||||
} else { | |||||
byte[] buffer = new byte[1024]; | |||||
int length = 0; | |||||
FileOutputStream fos = new FileOutputStream(f); | |||||
while ((length = zis.read(buffer)) >= 0) { | |||||
fos.write(buffer, 0, length); | |||||
} | |||||
fos.close(); | |||||
} | |||||
if (project.getJavaVersion() != Project.JAVA_1_1) { | if (project.getJavaVersion() != Project.JAVA_1_1) { | ||||
touch.setFile(f); | touch.setFile(f); | ||||
touch.setMillis(ze.getTime()); | touch.setMillis(ze.getTime()); | ||||
touch.touch(); | touch.touch(); | ||||
} | } | ||||
} catch( FileNotFoundException ex ) { | |||||
log("Unable to expand to file " + f.getPath(), Project.MSG_WARN); | |||||
} | |||||
} | |||||
log("expand complete", Project.MSG_VERBOSE ); | |||||
} catch (IOException ioe) { | |||||
throw new BuildException("Error while expanding " + srcF.getPath(), ioe); | |||||
} finally { | |||||
if (zis != null) { | |||||
try { | |||||
zis.close(); | |||||
} | |||||
catch (IOException e) {} | |||||
} | |||||
} | |||||
} catch( FileNotFoundException ex ) { | |||||
log("Unable to expand to file " + f.getPath(), Project.MSG_WARN); | |||||
} | |||||
} | |||||
log("expand complete", Project.MSG_VERBOSE ); | |||||
} catch (IOException ioe) { | |||||
throw new BuildException("Error while expanding " + srcF.getPath(), ioe); | |||||
} finally { | |||||
if (zis != null) { | |||||
try { | |||||
zis.close(); | |||||
} | |||||
catch (IOException e) {} | |||||
} | |||||
} | |||||
} | } | ||||
/** | /** | ||||
* Set the destination directory. File will be unzipped into the | * Set the destination directory. File will be unzipped into the | ||||
* destination directory. | * destination directory. | ||||
@@ -169,7 +168,7 @@ public class Expand extends MatchingTask { | |||||
* @param d Path to the directory. | * @param d Path to the directory. | ||||
*/ | */ | ||||
public void setDest(File d) { | public void setDest(File d) { | ||||
this.dest=d; | |||||
this.dest=d; | |||||
} | } | ||||
/** | /** | ||||
@@ -178,6 +177,6 @@ public class Expand extends MatchingTask { | |||||
* @param s Path to zip-file. | * @param s Path to zip-file. | ||||
*/ | */ | ||||
public void setSrc(File s) { | public void setSrc(File s) { | ||||
this.source = s; | |||||
this.source = s; | |||||
} | } | ||||
} | } |
@@ -114,7 +114,7 @@ public class Filter extends Task { | |||||
Project proj = getProject(); | Project proj = getProject(); | ||||
Enumeration enum = props.propertyNames(); | |||||
Enumeration enum = props.propertyNames(); | |||||
while (enum.hasMoreElements()) { | while (enum.hasMoreElements()) { | ||||
String strPropName = (String)enum.nextElement(); | String strPropName = (String)enum.nextElement(); | ||||
String strValue = props.getProperty(strPropName); | String strValue = props.getProperty(strPropName); | ||||
@@ -103,17 +103,17 @@ public class GZip extends Task { | |||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
String msg = "Problem creating gzip " + ioe.getMessage(); | String msg = "Problem creating gzip " + ioe.getMessage(); | ||||
throw new BuildException(msg, ioe, location); | throw new BuildException(msg, ioe, location); | ||||
} finally { | |||||
if (zOut != null) { | |||||
try { | |||||
} finally { | |||||
if (zOut != null) { | |||||
try { | |||||
// close up | // close up | ||||
zOut.close(); | |||||
} | |||||
catch (IOException e) {} | |||||
} | |||||
zOut.close(); | |||||
} | |||||
catch (IOException e) {} | |||||
} | |||||
} | } | ||||
} | } | ||||
private void zipFile(InputStream in, GZIPOutputStream zOut) | private void zipFile(InputStream in, GZIPOutputStream zOut) | ||||
throws IOException | throws IOException | ||||
{ | { | ||||
@@ -71,39 +71,39 @@ public class Jar extends Zip { | |||||
public Jar() { | public Jar() { | ||||
super(); | super(); | ||||
archiveType = "jar"; | |||||
archiveType = "jar"; | |||||
emptyBehavior = "create"; | emptyBehavior = "create"; | ||||
} | } | ||||
public void setJarfile(File jarFile) { | public void setJarfile(File jarFile) { | ||||
super.setZipfile(jarFile); | |||||
super.setZipfile(jarFile); | |||||
} | } | ||||
public void setManifest(File manifestFile) { | public void setManifest(File manifestFile) { | ||||
manifest = manifestFile; | |||||
manifest = manifestFile; | |||||
} | } | ||||
protected void initZipOutputStream(ZipOutputStream zOut) | protected void initZipOutputStream(ZipOutputStream zOut) | ||||
throws IOException, BuildException | |||||
throws IOException, BuildException | |||||
{ | { | ||||
// add manifest first | |||||
if (manifest != null) { | |||||
// add manifest first | |||||
if (manifest != null) { | |||||
zipDir(new File(manifest.getParent()), zOut, "META-INF/"); | zipDir(new File(manifest.getParent()), zOut, "META-INF/"); | ||||
super.zipFile(manifest, zOut, "META-INF/MANIFEST.MF"); | |||||
} else { | |||||
String s = "/org/apache/tools/ant/defaultManifest.mf"; | |||||
InputStream in = this.getClass().getResourceAsStream(s); | |||||
super.zipFile(manifest, zOut, "META-INF/MANIFEST.MF"); | |||||
} else { | |||||
String s = "/org/apache/tools/ant/defaultManifest.mf"; | |||||
InputStream in = this.getClass().getResourceAsStream(s); | |||||
if ( in == null ) | if ( in == null ) | ||||
throw new BuildException ( "Could not find: " + s ); | |||||
zipDir(null, zOut, "META-INF/"); | |||||
zipFile(in, zOut, "META-INF/MANIFEST.MF", System.currentTimeMillis()); | |||||
} | |||||
} | |||||
throw new BuildException ( "Could not find: " + s ); | |||||
zipDir(null, zOut, "META-INF/"); | |||||
zipFile(in, zOut, "META-INF/MANIFEST.MF", System.currentTimeMillis()); | |||||
} | |||||
} | |||||
protected boolean isUpToDate(FileScanner[] scanners, File zipFile) throws BuildException | protected boolean isUpToDate(FileScanner[] scanners, File zipFile) throws BuildException | ||||
{ | { | ||||
File[] files = grabFiles(scanners); | File[] files = grabFiles(scanners); | ||||
if (manifest != null) { | if (manifest != null) { | ||||
// just add the manifest file to the mix | // just add the manifest file to the mix | ||||
@@ -51,9 +51,10 @@ | |||||
* information on the Apache Software Foundation, please see | * information on the Apache Software Foundation, please see | ||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import java.io.*; | |||||
import java.util.*; | |||||
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.Project; | import org.apache.tools.ant.Project; | ||||
@@ -62,9 +63,6 @@ import org.apache.tools.ant.types.Commandline; | |||||
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 java.io.*; | |||||
import java.util.*; | |||||
/** | /** | ||||
* This task makes it easy to generate Javadoc documentation for a collection | * This task makes it easy to generate Javadoc documentation for a collection | ||||
* of source code. | * of source code. | ||||
@@ -407,7 +405,7 @@ public class Javadoc extends Task { | |||||
LinkArgument le = createLink(); | LinkArgument le = createLink(); | ||||
le.setOffline(true); | le.setOffline(true); | ||||
String linkOfflineError = "The linkoffline attribute must include a URL and " + | String linkOfflineError = "The linkoffline attribute must include a URL and " + | ||||
"a package-list file location separated by a space"; | |||||
"a package-list file location separated by a space"; | |||||
if (src.trim().length() == 0) { | if (src.trim().length() == 0) { | ||||
throw new BuildException(linkOfflineError); | throw new BuildException(linkOfflineError); | ||||
} | } | ||||
@@ -582,7 +580,7 @@ public class Javadoc extends Task { | |||||
} else { | } else { | ||||
toExecute.createArgument().setValue("-classpath"); | toExecute.createArgument().setValue("-classpath"); | ||||
toExecute.createArgument().setValue(sourcePath.toString() + | toExecute.createArgument().setValue(sourcePath.toString() + | ||||
System.getProperty("path.separator") + classpath.toString()); | |||||
System.getProperty("path.separator") + classpath.toString()); | |||||
} | } | ||||
if (version && doclet == null) | if (version && doclet == null) | ||||
@@ -672,15 +670,15 @@ public class Javadoc extends Task { | |||||
if (group != null) { | if (group != null) { | ||||
StringTokenizer tok = new StringTokenizer(group, ",", false); | StringTokenizer tok = new StringTokenizer(group, ",", false); | ||||
while (tok.hasMoreTokens()) { | while (tok.hasMoreTokens()) { | ||||
String grp = tok.nextToken().trim(); | |||||
int space = grp.indexOf(" "); | |||||
if (space > 0){ | |||||
String name = grp.substring(0, space); | |||||
String pkgList = grp.substring(space + 1); | |||||
toExecute.createArgument().setValue("-group"); | |||||
toExecute.createArgument().setValue(name); | |||||
toExecute.createArgument().setValue(pkgList); | |||||
} | |||||
String grp = tok.nextToken().trim(); | |||||
int space = grp.indexOf(" "); | |||||
if (space > 0){ | |||||
String name = grp.substring(0, space); | |||||
String pkgList = grp.substring(space + 1); | |||||
toExecute.createArgument().setValue("-group"); | |||||
toExecute.createArgument().setValue(name); | |||||
toExecute.createArgument().setValue(pkgList); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -724,7 +722,7 @@ public class Javadoc extends Task { | |||||
} | } | ||||
} | } | ||||
if (packageList != null) { | |||||
if (packageList != null) { | |||||
toExecute.createArgument().setValue("@" + packageList); | toExecute.createArgument().setValue("@" + packageList); | ||||
} | } | ||||
log("Javadoc args: " + toExecute, Project.MSG_VERBOSE); | log("Javadoc args: " + toExecute, Project.MSG_VERBOSE); | ||||
@@ -835,48 +833,48 @@ public class Javadoc extends Task { | |||||
} | } | ||||
protected Vector findPackages(File srcDir) { | protected Vector findPackages(File srcDir) { | ||||
Vector foundPkgs = new Vector(); | |||||
if ((srcDir != null) && (srcDir.isDirectory())) { | |||||
scan(srcDir, "", foundPkgs); | |||||
} | |||||
return foundPkgs; | |||||
Vector foundPkgs = new Vector(); | |||||
if ((srcDir != null) && (srcDir.isDirectory())) { | |||||
scan(srcDir, "", foundPkgs); | |||||
} | |||||
return foundPkgs; | |||||
} | } | ||||
protected void scan(File srcDir, String vpath, Vector pkgs) { | protected void scan(File srcDir, String vpath, Vector pkgs) { | ||||
foundJavaFile = false; | |||||
File dir = new File(srcDir, vpath); | |||||
if (!dir.isDirectory()) { | |||||
return; | |||||
} | |||||
String[] files = dir.list(new FilenameFilter () { | |||||
public boolean accept(File dir1, String name) { | |||||
if (name.endsWith(".java")) { | |||||
foundJavaFile = true; | |||||
return false; | |||||
} | |||||
File d = new File(dir1, name); | |||||
if (d.isDirectory() | |||||
&& d.getName().indexOf("-") == -1) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
}); | |||||
foundJavaFile = false; | |||||
File dir = new File(srcDir, vpath); | |||||
if (!dir.isDirectory()) { | |||||
return; | |||||
} | |||||
if (foundJavaFile && vpath.length() > 0) { | |||||
String newPkg = vpath.substring(1).replace(File.separatorChar, '.'); | |||||
if (!pkgs.contains(newPkg)) { | |||||
pkgs.addElement(newPkg); | |||||
} | |||||
} | |||||
for (int i=0; i<files.length; i++) { | |||||
scan(srcDir, vpath + File.separator + files[i], pkgs); | |||||
} | |||||
return; | |||||
String[] files = dir.list(new FilenameFilter () { | |||||
public boolean accept(File dir1, String name) { | |||||
if (name.endsWith(".java")) { | |||||
foundJavaFile = true; | |||||
return false; | |||||
} | |||||
File d = new File(dir1, name); | |||||
if (d.isDirectory() | |||||
&& d.getName().indexOf("-") == -1) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
}); | |||||
if (foundJavaFile && vpath.length() > 0) { | |||||
String newPkg = vpath.substring(1).replace(File.separatorChar, '.'); | |||||
if (!pkgs.contains(newPkg)) { | |||||
pkgs.addElement(newPkg); | |||||
} | |||||
} | |||||
for (int i=0; i<files.length; i++) { | |||||
scan(srcDir, vpath + File.separator + files[i], pkgs); | |||||
} | |||||
return; | |||||
} | } | ||||
} | } |
@@ -57,8 +57,8 @@ public class JikesOutputParser implements ExecuteStreamHandler { | |||||
* @param task - task in whichs context we are called | * @param task - task in whichs context we are called | ||||
*/ | */ | ||||
protected JikesOutputParser(Task task, boolean emacsMode) { | protected JikesOutputParser(Task task, boolean emacsMode) { | ||||
super(); | |||||
this.task = task; | |||||
super(); | |||||
this.task = task; | |||||
this.emacsMode = emacsMode; | this.emacsMode = emacsMode; | ||||
} | } | ||||
@@ -74,24 +74,24 @@ public class JikesOutputParser implements ExecuteStreamHandler { | |||||
} | } | ||||
private void parseStandardOutput(BufferedReader reader) throws IOException { | private void parseStandardOutput(BufferedReader reader) throws IOException { | ||||
String line; | |||||
String lower; | |||||
// We assume, that every output, jike does, stands for an error/warning | |||||
// XXX | |||||
// Is this correct? | |||||
String line; | |||||
String lower; | |||||
// We assume, that every output, jike does, stands for an error/warning | |||||
// XXX | |||||
// Is this correct? | |||||
// TODO: | // TODO: | ||||
// A warning line, that shows code, which contains a variable | // A warning line, that shows code, which contains a variable | ||||
// error will cause some trouble. The parser should definitely | // error will cause some trouble. The parser should definitely | ||||
// be much better. | // be much better. | ||||
while ((line = reader.readLine()) != null) { | |||||
lower = line.toLowerCase(); | |||||
if (line.trim().equals("")) | |||||
continue; | |||||
if (lower.indexOf("error") != -1) | |||||
setError(true); | |||||
else if (lower.indexOf("warning") != -1) | |||||
while ((line = reader.readLine()) != null) { | |||||
lower = line.toLowerCase(); | |||||
if (line.trim().equals("")) | |||||
continue; | |||||
if (lower.indexOf("error") != -1) | |||||
setError(true); | |||||
else if (lower.indexOf("warning") != -1) | |||||
setError(false); | setError(false); | ||||
else { | else { | ||||
// If we don't know the type of the line | // If we don't know the type of the line | ||||
@@ -104,7 +104,7 @@ public class JikesOutputParser implements ExecuteStreamHandler { | |||||
setError(true); | setError(true); | ||||
} | } | ||||
log(line); | log(line); | ||||
} | |||||
} | |||||
} | } | ||||
private void parseEmacsOutput(BufferedReader reader) throws IOException { | private void parseEmacsOutput(BufferedReader reader) throws IOException { | ||||
@@ -130,6 +130,6 @@ public class JikesOutputParser implements ExecuteStreamHandler { | |||||
* @return if errors ocured | * @return if errors ocured | ||||
*/ | */ | ||||
protected boolean getErrorFlag() { | protected boolean getErrorFlag() { | ||||
return errorFlag; | |||||
return errorFlag; | |||||
} | } | ||||
} | } |
@@ -119,7 +119,7 @@ public abstract class MatchingTask extends Task { | |||||
"Please use the includes attribute.", | "Please use the includes attribute.", | ||||
Project.MSG_WARN); | Project.MSG_WARN); | ||||
if (itemString == null || itemString.equals("*") | if (itemString == null || itemString.equals("*") | ||||
|| itemString.equals(".")) { | |||||
|| itemString.equals(".")) { | |||||
createInclude().setName("**"); | createInclude().setName("**"); | ||||
} else { | } else { | ||||
StringTokenizer tok = new StringTokenizer(itemString, ", "); | StringTokenizer tok = new StringTokenizer(itemString, ", "); | ||||
@@ -76,7 +76,7 @@ public class Mkdir extends Task { | |||||
if (dir.isFile()) { | if (dir.isFile()) { | ||||
throw new BuildException("Unable to create directory as a file already exists with that name: " + dir.getAbsolutePath()); | throw new BuildException("Unable to create directory as a file already exists with that name: " + dir.getAbsolutePath()); | ||||
} | } | ||||
if (!dir.exists()) { | if (!dir.exists()) { | ||||
boolean result = dir.mkdirs(); | boolean result = dir.mkdirs(); | ||||
if (result == false) { | if (result == false) { | ||||
@@ -325,12 +325,14 @@ public class SQLExec extends Task { | |||||
try { | try { | ||||
Class dc; | Class dc; | ||||
if (classpath != null) { | if (classpath != null) { | ||||
log("Loading " + driver + " using AntClassLoader with classpath " + classpath, Project.MSG_VERBOSE); | |||||
log( "Loading " + driver + " using AntClassLoader with classpath " + classpath, | |||||
Project.MSG_VERBOSE ); | |||||
loader = new AntClassLoader(project, classpath, false); | loader = new AntClassLoader(project, classpath, false); | ||||
dc = loader.loadClass(driver); | dc = loader.loadClass(driver); | ||||
} | } | ||||
else { | else { | ||||
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(); | ||||
@@ -364,7 +366,7 @@ public class SQLExec extends Task { | |||||
PrintStream out = System.out; | PrintStream out = System.out; | ||||
try { | try { | ||||
if (output != null) { | if (output != null) { | ||||
log("Opening PrintStream to output file " + output, Project.MSG_VERBOSE); | |||||
log("Opening PrintStream to output file " + output, Project.MSG_VERBOSE); | |||||
out = new PrintStream(new BufferedOutputStream(new FileOutputStream(output))); | out = new PrintStream(new BufferedOutputStream(new FileOutputStream(output))); | ||||
} | } | ||||
@@ -124,14 +124,14 @@ public class Tar extends MatchingTask { | |||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
String msg = "Problem creating TAR: " + ioe.getMessage(); | String msg = "Problem creating TAR: " + ioe.getMessage(); | ||||
throw new BuildException(msg, ioe, location); | throw new BuildException(msg, ioe, location); | ||||
} finally { | |||||
if (tOut != null) { | |||||
try { | |||||
} finally { | |||||
if (tOut != null) { | |||||
try { | |||||
// close up | // close up | ||||
tOut.close(); | |||||
} | |||||
catch (IOException e) {} | |||||
} | |||||
tOut.close(); | |||||
} | |||||
catch (IOException e) {} | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -87,52 +87,52 @@ public class Taskdef extends Task { | |||||
} | } | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
if (name==null || value==null ) { | |||||
String msg = "name or classname attributes of taskdef element " | |||||
+ "are undefined"; | |||||
throw new BuildException(msg); | |||||
} | |||||
try { | |||||
ClassLoader loader = null; | |||||
if (classpath != null) { | |||||
AntClassLoader al = new AntClassLoader(project, classpath, | |||||
false); | |||||
// need to load Task via system classloader or the new | |||||
// task we want to define will never be a Task but always | |||||
// be wrapped into a TaskAdapter. | |||||
al.addSystemPackageRoot("org.apache.tools.ant"); | |||||
loader = al; | |||||
} else { | |||||
loader = this.getClass().getClassLoader(); | |||||
} | |||||
if (name==null || value==null ) { | |||||
String msg = "name or classname attributes of taskdef element " | |||||
+ "are undefined"; | |||||
throw new BuildException(msg); | |||||
} | |||||
try { | |||||
ClassLoader loader = null; | |||||
if (classpath != null) { | |||||
AntClassLoader al = new AntClassLoader(project, classpath, | |||||
false); | |||||
// need to load Task via system classloader or the new | |||||
// task we want to define will never be a Task but always | |||||
// be wrapped into a TaskAdapter. | |||||
al.addSystemPackageRoot("org.apache.tools.ant"); | |||||
loader = al; | |||||
} else { | |||||
loader = this.getClass().getClassLoader(); | |||||
} | |||||
Class taskClass = null; | |||||
if (loader != null) { | |||||
taskClass = loader.loadClass(value); | |||||
} else { | |||||
taskClass = Class.forName(value); | |||||
} | |||||
project.addTaskDefinition(name, taskClass); | |||||
} catch (ClassNotFoundException cnfe) { | |||||
String msg = "taskdef class " + value + | |||||
" cannot be found"; | |||||
throw new BuildException(msg, cnfe, location); | |||||
} catch (NoClassDefFoundError ncdfe) { | |||||
String msg = "taskdef class " + value + | |||||
" cannot be found"; | |||||
throw new BuildException(msg, ncdfe, location); | |||||
} | |||||
Class taskClass = null; | |||||
if (loader != null) { | |||||
taskClass = loader.loadClass(value); | |||||
} else { | |||||
taskClass = Class.forName(value); | |||||
} | |||||
project.addTaskDefinition(name, taskClass); | |||||
} catch (ClassNotFoundException cnfe) { | |||||
String msg = "taskdef class " + value + | |||||
" cannot be found"; | |||||
throw new BuildException(msg, cnfe, location); | |||||
} catch (NoClassDefFoundError ncdfe) { | |||||
String msg = "taskdef class " + value + | |||||
" cannot be found"; | |||||
throw new BuildException(msg, ncdfe, location); | |||||
} | |||||
} | } | ||||
public void setName( String name) { | public void setName( String name) { | ||||
this.name = name; | |||||
this.name = name; | |||||
} | } | ||||
public String getClassname() { | public String getClassname() { | ||||
return value; | |||||
return value; | |||||
} | } | ||||
public void setClassname(String v) { | public void setClassname(String v) { | ||||
value = v; | |||||
value = v; | |||||
} | } | ||||
} | } |
@@ -136,7 +136,7 @@ public class Untar extends Task { | |||||
} | } | ||||
} | } | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
throw new BuildException("Error while expanding " + srcF.getPath(), | |||||
throw new BuildException("Error while expanding " + srcF.getPath(), | |||||
ioe, location); | ioe, location); | ||||
} finally { | } finally { | ||||
if (tis != null) { | if (tis != null) { | ||||
@@ -77,12 +77,12 @@ public class War extends Jar { | |||||
public War() { | public War() { | ||||
super(); | super(); | ||||
archiveType = "war"; | |||||
archiveType = "war"; | |||||
emptyBehavior = "create"; | emptyBehavior = "create"; | ||||
} | } | ||||
public void setWarfile(File warFile) { | public void setWarfile(File warFile) { | ||||
super.setZipfile(warFile); | |||||
super.setZipfile(warFile); | |||||
} | } | ||||
public void setWebxml(File descr) { | public void setWebxml(File descr) { | ||||
@@ -124,16 +124,16 @@ public class War extends Jar { | |||||
* special way of nested lib, classes or webinf filesets. | * special way of nested lib, classes or webinf filesets. | ||||
*/ | */ | ||||
protected void initZipOutputStream(ZipOutputStream zOut) | protected void initZipOutputStream(ZipOutputStream zOut) | ||||
throws IOException, BuildException | |||||
throws IOException, BuildException | |||||
{ | { | ||||
// add deployment descriptor first | |||||
if (deploymentDescriptor != null) { | |||||
// add deployment descriptor first | |||||
if (deploymentDescriptor != null) { | |||||
zipDir(new File(deploymentDescriptor.getParent()), zOut, | zipDir(new File(deploymentDescriptor.getParent()), zOut, | ||||
"WEB-INF/"); | "WEB-INF/"); | ||||
super.zipFile(deploymentDescriptor, zOut, "WEB-INF/web.xml"); | |||||
} else { | |||||
super.zipFile(deploymentDescriptor, zOut, "WEB-INF/web.xml"); | |||||
} else { | |||||
throw new BuildException("webxml attribute is required", location); | throw new BuildException("webxml attribute is required", location); | ||||
} | |||||
} | |||||
addFiles(libFileSets, zOut, "WEB-INF/lib/"); | addFiles(libFileSets, zOut, "WEB-INF/lib/"); | ||||
addFiles(classesFileSets, zOut, "WEB-INF/classes/"); | addFiles(classesFileSets, zOut, "WEB-INF/classes/"); | ||||
@@ -54,13 +54,13 @@ | |||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import org.apache.tools.ant.*; | |||||
import java.io.*; | import java.io.*; | ||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import java.util.Hashtable; | import java.util.Hashtable; | ||||
import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
import java.util.Vector; | import java.util.Vector; | ||||
import org.apache.tools.ant.*; | |||||
/** | /** | ||||
@@ -100,7 +100,7 @@ public class XSLTProcess extends MatchingTask { | |||||
/** | /** | ||||
* Creates a new XSLTProcess Task. | * Creates a new XSLTProcess Task. | ||||
**/ | |||||
**/ | |||||
public XSLTProcess() { | public XSLTProcess() { | ||||
} //-- XSLTProcess | } //-- XSLTProcess | ||||
@@ -109,35 +109,35 @@ public class XSLTProcess extends MatchingTask { | |||||
*/ | */ | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
DirectoryScanner scanner; | |||||
String[] list; | |||||
String[] dirs; | |||||
DirectoryScanner scanner; | |||||
String[] list; | |||||
String[] dirs; | |||||
if (baseDir == null) | |||||
baseDir = project.resolveFile("."); | |||||
if (baseDir == null) | |||||
baseDir = project.resolveFile("."); | |||||
//-- make sure Source directory exists... | //-- make sure Source directory exists... | ||||
if (destDir == null ) { | |||||
String msg = "destdir attributes must be set!"; | |||||
throw new BuildException(msg); | |||||
} | |||||
scanner = getDirectoryScanner(baseDir); | |||||
log("Transforming into "+destDir, Project.MSG_INFO); | |||||
if (destDir == null ) { | |||||
String msg = "destdir attributes must be set!"; | |||||
throw new BuildException(msg); | |||||
} | |||||
scanner = getDirectoryScanner(baseDir); | |||||
log("Transforming into "+destDir, Project.MSG_INFO); | |||||
// if processor wasn't specified, default it to xslp or xalan, | // if processor wasn't specified, default it to xslp or xalan, | ||||
// depending on which is in the classpath | // depending on which is in the classpath | ||||
if (liaison == null) { | if (liaison == null) { | ||||
try { | |||||
setProcessor("xslp"); | |||||
} catch (Throwable e1) { | |||||
try { | |||||
setProcessor("xalan"); | |||||
} catch (Throwable e2) { | |||||
throw new BuildException(e2); | |||||
} | |||||
} | |||||
try { | |||||
setProcessor("xslp"); | |||||
} catch (Throwable e1) { | |||||
try { | |||||
setProcessor("xalan"); | |||||
} catch (Throwable e2) { | |||||
throw new BuildException(e2); | |||||
} | |||||
} | |||||
} | } | ||||
log("Using "+liaison.getClass().toString(), Project.MSG_VERBOSE); | |||||
log("Using "+liaison.getClass().toString(), Project.MSG_VERBOSE); | |||||
long styleSheetLastModified = 0; | long styleSheetLastModified = 0; | ||||
if (xslFile != null) { | if (xslFile != null) { | ||||
@@ -153,24 +153,24 @@ public class XSLTProcess extends MatchingTask { | |||||
} | } | ||||
} | } | ||||
// Process all the files marked for styling | |||||
list = scanner.getIncludedFiles(); | |||||
for (int i = 0;i < list.length; ++i) { | |||||
// Process all the files marked for styling | |||||
list = scanner.getIncludedFiles(); | |||||
for (int i = 0;i < list.length; ++i) { | |||||
process( baseDir, list[i], destDir, styleSheetLastModified ); | process( baseDir, list[i], destDir, styleSheetLastModified ); | ||||
} | |||||
} | |||||
// Process all the directoried marked for styling | |||||
dirs = scanner.getIncludedDirectories(); | |||||
for (int j = 0;j < dirs.length;++j){ | |||||
list=new File(baseDir,dirs[j]).list(); | |||||
for (int i = 0;i < list.length;++i) | |||||
// Process all the directoried marked for styling | |||||
dirs = scanner.getIncludedDirectories(); | |||||
for (int j = 0;j < dirs.length;++j){ | |||||
list=new File(baseDir,dirs[j]).list(); | |||||
for (int i = 0;i < list.length;++i) | |||||
process( baseDir, list[i], destDir, styleSheetLastModified ); | process( baseDir, list[i], destDir, styleSheetLastModified ); | ||||
} | |||||
} | |||||
} //-- execute | } //-- execute | ||||
/** | /** | ||||
* Set the base directory. | * Set the base directory. | ||||
**/ | |||||
**/ | |||||
public void setBasedir(File dir) { | public void setBasedir(File dir) { | ||||
baseDir = dir; | baseDir = dir; | ||||
} //-- setSourceDir | } //-- setSourceDir | ||||
@@ -179,7 +179,7 @@ public class XSLTProcess extends MatchingTask { | |||||
* Set the destination directory into which the XSL result | * Set the destination directory into which the XSL result | ||||
* files should be copied to | * files should be copied to | ||||
* @param dirName the name of the destination directory | * @param dirName the name of the destination directory | ||||
**/ | |||||
**/ | |||||
public void setDestdir(File dir) { | public void setDestdir(File dir) { | ||||
destDir = dir; | destDir = dir; | ||||
} //-- setDestDir | } //-- setDestDir | ||||
@@ -187,16 +187,16 @@ public class XSLTProcess extends MatchingTask { | |||||
/** | /** | ||||
* Set the desired file extension to be used for the target | * Set the desired file extension to be used for the target | ||||
* @param name the extension to use | * @param name the extension to use | ||||
**/ | |||||
**/ | |||||
public void setExtension(String name) { | public void setExtension(String name) { | ||||
targetExtension = name; | |||||
targetExtension = name; | |||||
} //-- setDestDir | } //-- setDestDir | ||||
/** | /** | ||||
* Sets the file to use for styling relative to the base directory. | * Sets the file to use for styling relative to the base directory. | ||||
*/ | */ | ||||
public void setStyle(String xslFile) { | public void setStyle(String xslFile) { | ||||
this.xslFile = new File(xslFile); | |||||
this.xslFile = new File(xslFile); | |||||
} | } | ||||
/** | /** | ||||
@@ -204,10 +204,14 @@ public class XSLTProcess extends MatchingTask { | |||||
*/ | */ | ||||
public void setProcessor(String processor) throws Exception { | public void setProcessor(String processor) throws Exception { | ||||
if (processor.equals("xslp")) { | |||||
liaison = (XSLTLiaison) Class.forName("org.apache.tools.ant.taskdefs.optional.XslpLiaison").newInstance(); | |||||
} else if (processor.equals("xalan")) { | |||||
liaison = (XSLTLiaison) Class.forName("org.apache.tools.ant.taskdefs.optional.XalanLiaison").newInstance(); | |||||
if (processor.equals("xslp")) { | |||||
final Class clazz = | |||||
Class.forName("org.apache.tools.ant.taskdefs.optional.XslpLiaison"); | |||||
liaison = (XSLTLiaison) clazz.newInstance(); | |||||
} else if (processor.equals("xalan")) { | |||||
final Class clazz = | |||||
Class.forName("org.apache.tools.ant.taskdefs.optional.XalanLiaison"); | |||||
liaison = (XSLTLiaison)clazz.newInstance(); | |||||
} else { | } else { | ||||
liaison = (XSLTLiaison) Class.forName(processor).newInstance(); | liaison = (XSLTLiaison) Class.forName(processor).newInstance(); | ||||
} | } | ||||
@@ -215,103 +219,103 @@ public class XSLTProcess extends MatchingTask { | |||||
} | } | ||||
/* | /* | ||||
private void process(File sourceDir, File destDir) | |||||
throws BuildException | |||||
{ | |||||
private void process(File sourceDir, File destDir) | |||||
throws BuildException | |||||
{ | |||||
if (!sourceDir.isDirectory()) { | |||||
throw new BuildException(sourceDir.getName() + | |||||
" is not a directory!"); | |||||
} | |||||
else if (!destDir.isDirectory()) { | |||||
throw new BuildException(destDir.getName() + | |||||
" is not a directory!"); | |||||
} | |||||
String[] list = sourceDir.list(new DesirableFilter()); | |||||
if (list == null) { | |||||
return; //-- nothing to do | |||||
} | |||||
for (int i = 0; i < list.length; i++) { | |||||
String filename = list[i]; | |||||
File inFile = new File(sourceDir, filename); | |||||
//-- if inFile is a directory, recursively process it | |||||
if (inFile.isDirectory()) { | |||||
if (!excluded(filename)) { | |||||
new File(destDir, filename).mkdir(); | |||||
process(inFile, new File(destDir, filename)); | |||||
} | |||||
} | |||||
//-- process XML files | |||||
else if (hasXMLFileExtension(filename) && ! excluded(filename)) { | |||||
//-- replace extension with the target extension | |||||
int idx = filename.lastIndexOf('.'); | |||||
File outFile = new File(destDir, | |||||
filename.substring(0,idx) + targetExt); | |||||
if ((inFile.lastModified() > outFile.lastModified()) || | |||||
(xslFile != null && xslFile.lastModified() > outFile.lastModified())) | |||||
{ | |||||
processXML(inFile, outFile); | |||||
} | |||||
} | |||||
else { | |||||
File outFile = new File(destDir, filename); | |||||
if (inFile.lastModified() > outFile.lastModified()) { | |||||
try { | |||||
copyFile(inFile, outFile); | |||||
} | |||||
catch(java.io.IOException ex) { | |||||
String err = "error copying file: "; | |||||
err += inFile.getAbsolutePath(); | |||||
err += "; " + ex.getMessage(); | |||||
throw new BuildException(err, ex); | |||||
} | |||||
//filecopyList.put(srcFile.getAbsolutePath(), | |||||
//destFile.getAbsolutePath()); | |||||
} | |||||
} | |||||
} //-- </for> | |||||
} //-- process(File, File) | |||||
if (!sourceDir.isDirectory()) { | |||||
throw new BuildException(sourceDir.getName() + | |||||
" is not a directory!"); | |||||
} | |||||
else if (!destDir.isDirectory()) { | |||||
throw new BuildException(destDir.getName() + | |||||
" is not a directory!"); | |||||
} | |||||
String[] list = sourceDir.list(new DesirableFilter()); | |||||
if (list == null) { | |||||
return; //-- nothing to do | |||||
} | |||||
for (int i = 0; i < list.length; i++) { | |||||
String filename = list[i]; | |||||
File inFile = new File(sourceDir, filename); | |||||
//-- if inFile is a directory, recursively process it | |||||
if (inFile.isDirectory()) { | |||||
if (!excluded(filename)) { | |||||
new File(destDir, filename).mkdir(); | |||||
process(inFile, new File(destDir, filename)); | |||||
} | |||||
} | |||||
//-- process XML files | |||||
else if (hasXMLFileExtension(filename) && ! excluded(filename)) { | |||||
//-- replace extension with the target extension | |||||
int idx = filename.lastIndexOf('.'); | |||||
File outFile = new File(destDir, | |||||
filename.substring(0,idx) + targetExt); | |||||
if ((inFile.lastModified() > outFile.lastModified()) || | |||||
(xslFile != null && xslFile.lastModified() > outFile.lastModified())) | |||||
{ | |||||
processXML(inFile, outFile); | |||||
} | |||||
} | |||||
else { | |||||
File outFile = new File(destDir, filename); | |||||
if (inFile.lastModified() > outFile.lastModified()) { | |||||
try { | |||||
copyFile(inFile, outFile); | |||||
} | |||||
catch(java.io.IOException ex) { | |||||
String err = "error copying file: "; | |||||
err += inFile.getAbsolutePath(); | |||||
err += "; " + ex.getMessage(); | |||||
throw new BuildException(err, ex); | |||||
} | |||||
//filecopyList.put(srcFile.getAbsolutePath(), | |||||
//destFile.getAbsolutePath()); | |||||
} | |||||
} | |||||
} //-- </for> | |||||
} //-- process(File, File) | |||||
*/ | */ | ||||
/** | /** | ||||
* Processes the given input XML file and stores the result | * Processes the given input XML file and stores the result | ||||
* in the given resultFile. | * in the given resultFile. | ||||
**/ | |||||
**/ | |||||
private void process(File baseDir, String xmlFile, File destDir, | private void process(File baseDir, String xmlFile, File destDir, | ||||
long styleSheetLastModified) | long styleSheetLastModified) | ||||
throws BuildException { | throws BuildException { | ||||
String fileExt=targetExtension; | |||||
File outFile=null; | |||||
File inFile=null; | |||||
String fileExt=targetExtension; | |||||
File outFile=null; | |||||
File inFile=null; | |||||
try { | |||||
inFile = new File(baseDir,xmlFile); | |||||
outFile = new File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt); | |||||
if (inFile.lastModified() > outFile.lastModified() || | |||||
try { | |||||
inFile = new File(baseDir,xmlFile); | |||||
outFile = new File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt); | |||||
if (inFile.lastModified() > outFile.lastModified() || | |||||
styleSheetLastModified > outFile.lastModified()) { | styleSheetLastModified > outFile.lastModified()) { | ||||
ensureDirectoryFor( outFile ); | ensureDirectoryFor( outFile ); | ||||
//-- command line status | |||||
log("Processing " + xmlFile + " to " + outFile, Project.MSG_VERBOSE); | |||||
//-- command line status | |||||
log("Processing " + xmlFile + " to " + outFile, Project.MSG_VERBOSE); | |||||
liaison.transform(inFile.toString(), outFile.toString()); | |||||
} | |||||
liaison.transform(inFile.toString(), outFile.toString()); | |||||
} | |||||
} | } | ||||
catch (Exception ex) { | catch (Exception ex) { | ||||
// If failed to process document, must delete target document, | |||||
// or it will not attempt to process it the second time | |||||
log("Failed to process " + inFile, Project.MSG_INFO); | |||||
outFile.delete(); | |||||
// If failed to process document, must delete target document, | |||||
// or it will not attempt to process it the second time | |||||
log("Failed to process " + inFile, Project.MSG_INFO); | |||||
outFile.delete(); | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
@@ -51,13 +51,8 @@ | |||||
* information on the Apache Software Foundation, please see | * information on the Apache Software Foundation, please see | ||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import org.apache.tools.ant.*; | |||||
import org.apache.tools.ant.types.*; | |||||
import org.apache.tools.ant.util.*; | |||||
import java.io.*; | import java.io.*; | ||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import java.util.Hashtable; | import java.util.Hashtable; | ||||
@@ -65,6 +60,9 @@ import java.util.Stack; | |||||
import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
import java.util.Vector; | import java.util.Vector; | ||||
import java.util.zip.*; | import java.util.zip.*; | ||||
import org.apache.tools.ant.*; | |||||
import org.apache.tools.ant.types.*; | |||||
import org.apache.tools.ant.util.*; | |||||
/** | /** | ||||
* Create a ZIP archive. | * Create a ZIP archive. | ||||
@@ -73,7 +71,6 @@ import java.util.zip.*; | |||||
* @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> | * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> | ||||
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
*/ | */ | ||||
public class Zip extends MatchingTask { | public class Zip extends MatchingTask { | ||||
private File zipFile; | private File zipFile; | ||||
@@ -135,7 +132,8 @@ public class Zip extends MatchingTask { | |||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
if (baseDir == null && filesets.size() == 0 && "zip".equals(archiveType)) | if (baseDir == null && filesets.size() == 0 && "zip".equals(archiveType)) | ||||
throw new BuildException("basedir attribute must be set, or at least one fileset must be given!"); | |||||
throw new BuildException( "basedir attribute must be set, or at least " + | |||||
"one fileset must be given!" ); | |||||
if (zipFile == null) { | if (zipFile == null) { | ||||
throw new BuildException("You must specify the " + archiveType + " file to create!"); | throw new BuildException("You must specify the " + archiveType + " file to create!"); | ||||
@@ -157,29 +155,29 @@ public class Zip extends MatchingTask { | |||||
log("Building "+ archiveType +": "+ zipFile.getAbsolutePath()); | log("Building "+ archiveType +": "+ zipFile.getAbsolutePath()); | ||||
try { | |||||
ZipOutputStream zOut = new ZipOutputStream(new FileOutputStream(zipFile)); | |||||
try { | |||||
if (doCompress) { | |||||
zOut.setMethod(ZipOutputStream.DEFLATED); | |||||
} else { | |||||
zOut.setMethod(ZipOutputStream.STORED); | |||||
} | |||||
initZipOutputStream(zOut); | |||||
try { | |||||
ZipOutputStream zOut = new ZipOutputStream(new FileOutputStream(zipFile)); | |||||
try { | |||||
if (doCompress) { | |||||
zOut.setMethod(ZipOutputStream.DEFLATED); | |||||
} else { | |||||
zOut.setMethod(ZipOutputStream.STORED); | |||||
} | |||||
initZipOutputStream(zOut); | |||||
for (int j = 0; j < scanners.length; j++) { | for (int j = 0; j < scanners.length; j++) { | ||||
addFiles(scanners[j], zOut, ""); | addFiles(scanners[j], zOut, ""); | ||||
} | } | ||||
} finally { | |||||
zOut.close (); | |||||
} | |||||
} catch (IOException ioe) { | |||||
String msg = "Problem creating " + archiveType + ": " + ioe.getMessage(); | |||||
} finally { | |||||
zOut.close (); | |||||
} | |||||
} catch (IOException ioe) { | |||||
String msg = "Problem creating " + archiveType + ": " + ioe.getMessage(); | |||||
// delete a bogus ZIP file | // delete a bogus ZIP file | ||||
if (!zipFile.delete()) { | |||||
msg += " (and the archive is probably corrupt but I could not delete it)"; | |||||
} | |||||
if (!zipFile.delete()) { | |||||
msg += " (and the archive is probably corrupt but I could not delete it)"; | |||||
} | |||||
throw new BuildException(msg, ioe, location); | throw new BuildException(msg, ioe, location); | ||||
} | } | ||||
@@ -317,13 +315,13 @@ public class Zip extends MatchingTask { | |||||
} | } | ||||
addedDirs.put(vPath, vPath); | addedDirs.put(vPath, vPath); | ||||
ZipEntry ze = new ZipEntry (vPath); | |||||
if (dir != null) ze.setTime (dir.lastModified ()); | |||||
ze.setSize (0); | |||||
ze.setMethod (ZipEntry.STORED); | |||||
// This is faintly ridiculous: | |||||
ze.setCrc (emptyCrc); | |||||
zOut.putNextEntry (ze); | |||||
ZipEntry ze = new ZipEntry (vPath); | |||||
if (dir != null) ze.setTime (dir.lastModified ()); | |||||
ze.setSize (0); | |||||
ze.setMethod (ZipEntry.STORED); | |||||
// This is faintly ridiculous: | |||||
ze.setCrc (emptyCrc); | |||||
zOut.putNextEntry (ze); | |||||
} | } | ||||
protected void zipFile(InputStream in, ZipOutputStream zOut, String vPath, | protected void zipFile(InputStream in, ZipOutputStream zOut, String vPath, | ||||
@@ -51,7 +51,6 @@ | |||||
* information on the Apache Software Foundation, please see | * information on the Apache Software Foundation, please see | ||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
import java.io.*; | import java.io.*; | ||||
@@ -51,13 +51,12 @@ | |||||
* information on the Apache Software Foundation, please see | * information on the Apache Software Foundation, please see | ||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
import org.apache.tools.ant.*; | |||||
import com.ibm.bsf.*; | |||||
import java.io.*; | import java.io.*; | ||||
import java.util.*; | import java.util.*; | ||||
import com.ibm.bsf.*; | |||||
import org.apache.tools.ant.*; | |||||
/** | /** | ||||
* Execute a script | * Execute a script | ||||
@@ -76,7 +75,7 @@ public class Script extends Task { | |||||
for (Enumeration e=dictionary.keys(); e.hasMoreElements(); ) { | for (Enumeration e=dictionary.keys(); e.hasMoreElements(); ) { | ||||
String key = (String)e.nextElement(); | String key = (String)e.nextElement(); | ||||
boolean isValid = key.length()>0 && | |||||
boolean isValid = key.length()>0 && | |||||
Character.isJavaIdentifierStart(key.charAt(0)); | Character.isJavaIdentifierStart(key.charAt(0)); | ||||
for (int i=1; isValid && i<key.length(); i++) | for (int i=1; isValid && i<key.length(); i++) | ||||
@@ -109,7 +108,7 @@ public class Script extends Task { | |||||
// execute the script | // execute the script | ||||
manager.exec(language, "<ANT>", 0, 0, script); | manager.exec(language, "<ANT>", 0, 0, script); | ||||
} catch (BSFException be) { | } catch (BSFException be) { | ||||
Throwable t = be; | |||||
Throwable t = be; | |||||
Throwable te = be.getTargetException(); | Throwable te = be.getTargetException(); | ||||
if (te != null) { | if (te != null) { | ||||
if (te instanceof BuildException) { | if (te instanceof BuildException) { | ||||
@@ -128,7 +127,7 @@ public class Script extends Task { | |||||
* @param msg Sets the value for the script variable. | * @param msg Sets the value for the script variable. | ||||
*/ | */ | ||||
public void setLanguage(String language) { | public void setLanguage(String language) { | ||||
this.language = language; | |||||
this.language = language; | |||||
} | } | ||||
/** | /** | ||||
@@ -151,7 +150,7 @@ public class Script extends Task { | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new BuildException(e); | throw new BuildException(e); | ||||
} | } | ||||
script += new String(data); | script += new String(data); | ||||
} | } | ||||
@@ -161,6 +160,6 @@ public class Script extends Task { | |||||
* @param msg Sets the value for the script variable. | * @param msg Sets the value for the script variable. | ||||
*/ | */ | ||||
public void addText(String text) { | public void addText(String text) { | ||||
this.script += text; | |||||
this.script += text; | |||||
} | } | ||||
} | } |
@@ -1,4 +1,4 @@ | |||||
/* -*-Java-*- | |||||
/* | |||||
******************************************************************* | ******************************************************************* | ||||
* | * | ||||
* File: Csharp.java | * File: Csharp.java | ||||
@@ -85,12 +85,12 @@ package org.apache.tools.ant.taskdefs.optional.dotnet; | |||||
// imports | // imports | ||||
// ==================================================================== | // ==================================================================== | ||||
import java.io.*; | |||||
import java.text.*; | |||||
import java.util.*; | |||||
import org.apache.tools.ant.*; | import org.apache.tools.ant.*; | ||||
import org.apache.tools.ant.taskdefs.*; | import org.apache.tools.ant.taskdefs.*; | ||||
import org.apache.tools.ant.types.*; | import org.apache.tools.ant.types.*; | ||||
import java.io.*; | |||||
import java.util.*; | |||||
import java.text.*; | |||||
// ==================================================================== | // ==================================================================== | ||||
@@ -232,23 +232,23 @@ The first pass is just a proof of concept; enough to test. | |||||
<p> | <p> | ||||
TODO | TODO | ||||
<ol> | <ol> | ||||
<li>get PATH incorporated into reference/module lookup | |||||
<li>is Win32Icon broken? | |||||
<li>all the missing options | |||||
<li>get PATH incorporated into reference/module lookup | |||||
<li>is Win32Icon broken? | |||||
<li>all the missing options | |||||
</ol> | </ol> | ||||
<p> | <p> | ||||
History | History | ||||
<Table> | |||||
<tr><td>0.2</td> | |||||
<td> Slightly different</td> | |||||
<td> Split command execution to a separate class; | |||||
</tr> | |||||
<tr><td>0.1</td> | |||||
<td> "I can't believe it's so rudimentary"</td> | |||||
<td> First pass; minimal builds only support; | |||||
</tr> | |||||
</table> | |||||
<Table> | |||||
<tr><td>0.2</td> | |||||
<td> Slightly different</td> | |||||
<td> Split command execution to a separate class; | |||||
</tr> | |||||
<tr><td>0.1</td> | |||||
<td> "I can't believe it's so rudimentary"</td> | |||||
<td> First pass; minimal builds only support; | |||||
</tr> | |||||
</table> | |||||
@version 0.2 | @version 0.2 | ||||
@author Steve Loughran steve_l@iseran.com | @author Steve Loughran steve_l@iseran.com | ||||
@@ -258,7 +258,7 @@ History | |||||
public class CSharp | public class CSharp | ||||
extends org.apache.tools.ant.taskdefs.MatchingTask { | extends org.apache.tools.ant.taskdefs.MatchingTask { | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** constructor inits everything and set up the search pattern | /** constructor inits everything and set up the search pattern | ||||
*/ | */ | ||||
@@ -283,7 +283,7 @@ public class CSharp | |||||
protected static final String csc_file_pattern="*."+csc_file_ext; | protected static final String csc_file_pattern="*."+csc_file_ext; | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** list of reference classes. (pretty much a classpath equivalent) | /** list of reference classes. (pretty much a classpath equivalent) | ||||
*/ | */ | ||||
@@ -335,14 +335,14 @@ public class CSharp | |||||
//bail on no references listed | //bail on no references listed | ||||
if (refpath.length()==0) | if (refpath.length()==0) | ||||
return null; | return null; | ||||
StringBuffer s=new StringBuffer("/reference:"); | StringBuffer s=new StringBuffer("/reference:"); | ||||
s.append(refpath); | s.append(refpath); | ||||
return new String(s); | return new String(s); | ||||
} | |||||
} | |||||
*/ | */ | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/* optimise flag | /* optimise flag | ||||
*/ | */ | ||||
@@ -366,9 +366,9 @@ public class CSharp | |||||
*/ | */ | ||||
protected String getOptimizeParameter() { | protected String getOptimizeParameter() { | ||||
return "/optimize"+(_optimize?"+":"-"); | return "/optimize"+(_optimize?"+":"-"); | ||||
} | |||||
//============================================================================= | |||||
} | |||||
//============================================================================= | |||||
/** incremental build flag */ | /** incremental build flag */ | ||||
protected boolean _incremental; | protected boolean _incremental; | ||||
@@ -390,9 +390,9 @@ public class CSharp | |||||
*/ | */ | ||||
protected String getIncrementalParameter() { | protected String getIncrementalParameter() { | ||||
return "/incremental"+(_incremental?"+":"-"); | return "/incremental"+(_incremental?"+":"-"); | ||||
} | |||||
} | |||||
//============================================================================= | |||||
//============================================================================= | |||||
/** debug flag. Controls generation of debug information. | /** debug flag. Controls generation of debug information. | ||||
*/ | */ | ||||
@@ -404,7 +404,7 @@ public class CSharp | |||||
public void setDebug(boolean f) | public void setDebug(boolean f) | ||||
{_debug=f;} | {_debug=f;} | ||||
/** query the debug flag | /** query the debug flag | ||||
* @return true if debug is turned on | * @return true if debug is turned on | ||||
*/ | */ | ||||
@@ -417,15 +417,15 @@ public class CSharp | |||||
*/ | */ | ||||
protected String getDebugParameter() { | protected String getDebugParameter() { | ||||
return "/debug"+(_debug?"+":"-"); | return "/debug"+(_debug?"+":"-"); | ||||
} | |||||
} | |||||
//============================================================================= | |||||
//============================================================================= | |||||
/** output XML documentation flag | /** output XML documentation flag | ||||
*/ | |||||
*/ | |||||
protected File _docFile; | protected File _docFile; | ||||
/** file for generated XML documentation | /** file for generated XML documentation | ||||
* @param output file | * @param output file | ||||
*/ | */ | ||||
@@ -443,9 +443,9 @@ public class CSharp | |||||
return "/doc:"+_docFile.toString(); | return "/doc:"+_docFile.toString(); | ||||
else | else | ||||
return null; | return null; | ||||
} | |||||
//============================================================================= | |||||
} | |||||
//============================================================================= | |||||
/** warning level: 0-4, with 4 being most verbose | /** warning level: 0-4, with 4 being most verbose | ||||
*/ | */ | ||||
private int _warnLevel; | private int _warnLevel; | ||||
@@ -466,9 +466,9 @@ public class CSharp | |||||
*/ | */ | ||||
protected String getWarnLevelParameter() { | protected String getWarnLevelParameter() { | ||||
return "/warn:"+_warnLevel; | return "/warn:"+_warnLevel; | ||||
} | |||||
} | |||||
//============================================================================= | |||||
//============================================================================= | |||||
/** enable unsafe code flag. Clearly set to false by default | /** enable unsafe code flag. Clearly set to false by default | ||||
*/ | */ | ||||
@@ -484,9 +484,9 @@ public class CSharp | |||||
*/ | */ | ||||
protected String getUnsafeParameter(){ | protected String getUnsafeParameter(){ | ||||
return _unsafe?"/unsafe":null; | return _unsafe?"/unsafe":null; | ||||
} | |||||
//============================================================================= | |||||
} | |||||
//============================================================================= | |||||
/** main class (or null for automatic choice) | /** main class (or null for automatic choice) | ||||
*/ | */ | ||||
protected String _mainClass; | protected String _mainClass; | ||||
@@ -504,9 +504,9 @@ public class CSharp | |||||
return "/main:"+_mainClass; | return "/main:"+_mainClass; | ||||
else | else | ||||
return null; | return null; | ||||
} | |||||
} | |||||
//============================================================================= | |||||
//============================================================================= | |||||
/** source directory upon which the search pattern is applied | /** source directory upon which the search pattern is applied | ||||
*/ | */ | ||||
private File _srcDir; | private File _srcDir; | ||||
@@ -518,7 +518,7 @@ public class CSharp | |||||
_srcDir = project.resolveFile(srcDirName); | _srcDir = project.resolveFile(srcDirName); | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** destination directory (null means use the source directory) | /** destination directory (null means use the source directory) | ||||
*/ | */ | ||||
private File _destDir; | private File _destDir; | ||||
@@ -529,9 +529,9 @@ public class CSharp | |||||
public void setDestDir(String dirName) { | public void setDestDir(String dirName) { | ||||
_destDir = project.resolveFile(dirName); | _destDir = project.resolveFile(dirName); | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** type of target. Should be one of exe|library|module|winexe|(null) | /** type of target. Should be one of exe|library|module|winexe|(null) | ||||
default is exe; the actual value (if not null) is fed to the command line. | default is exe; the actual value (if not null) is fed to the command line. | ||||
<br>See /target | <br>See /target | ||||
@@ -548,7 +548,7 @@ public class CSharp | |||||
targetType=targetType.toLowerCase(); | targetType=targetType.toLowerCase(); | ||||
if(targetType.equals("exe") || targetType.equals("library") || | if(targetType.equals("exe") || targetType.equals("library") || | ||||
targetType.equals("module") ||targetType.equals("winexe") ) { | targetType.equals("module") ||targetType.equals("winexe") ) { | ||||
_targetType=targetType; | |||||
_targetType=targetType; | |||||
} | } | ||||
else | else | ||||
throw new BuildException("targetType " +targetType+" is not a valid type"); | throw new BuildException("targetType " +targetType+" is not a valid type"); | ||||
@@ -556,7 +556,7 @@ public class CSharp | |||||
public String getTargetType() { | public String getTargetType() { | ||||
return _targetType; | return _targetType; | ||||
} | |||||
} | |||||
/** get the argument or null for no argument needed | /** get the argument or null for no argument needed | ||||
*/ | */ | ||||
@@ -565,14 +565,14 @@ public class CSharp | |||||
return "/target:"+_targetType; | return "/target:"+_targetType; | ||||
else | else | ||||
return null; | return null; | ||||
} | |||||
} | |||||
//============================================================================= | |||||
//============================================================================= | |||||
/* icon for incorporation into apps | /* icon for incorporation into apps | ||||
*/ | */ | ||||
protected File _win32icon; | |||||
protected File _win32icon; | |||||
/** | /** | ||||
* Set the win32 icon | * Set the win32 icon | ||||
@@ -591,7 +591,7 @@ public class CSharp | |||||
return null; | return null; | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** defines list 'RELEASE;WIN32;NO_SANITY_CHECKS;;SOMETHING_ELSE' | /** defines list 'RELEASE;WIN32;NO_SANITY_CHECKS;;SOMETHING_ELSE' | ||||
* | * | ||||
*/ | */ | ||||
@@ -614,7 +614,7 @@ public class CSharp | |||||
else return "/DEFINE:"+_definitions; | else return "/DEFINE:"+_definitions; | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** list of extra modules to refer to | /** list of extra modules to refer to | ||||
* | * | ||||
*/ | */ | ||||
@@ -637,7 +637,7 @@ public class CSharp | |||||
else return "/addmodule:"+_additionalModules; | else return "/addmodule:"+_additionalModules; | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** output file. If not supplied this is derived from the | /** output file. If not supplied this is derived from the | ||||
* source file | * source file | ||||
*/ | */ | ||||
@@ -661,7 +661,7 @@ public class CSharp | |||||
return "/out:"+f.toString(); | return "/out:"+f.toString(); | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** flag to control action on execution trouble | /** flag to control action on execution trouble | ||||
*/ | */ | ||||
@@ -679,7 +679,7 @@ public class CSharp | |||||
return _failOnError; | return _failOnError; | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** reset all contents. | /** reset all contents. | ||||
*/ | */ | ||||
public void Clear() { | public void Clear() { | ||||
@@ -701,7 +701,7 @@ public class CSharp | |||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** do the work by building the command line and then calling it | /** do the work by building the command line and then calling it | ||||
*/ | */ | ||||
@@ -1,11 +1,11 @@ | |||||
/* -*-Java-*- | |||||
/* | |||||
******************************************************************* | ******************************************************************* | ||||
* | * | ||||
* File: Csharp.java | * File: Csharp.java | ||||
* RCS: $Header$ | * RCS: $Header$ | ||||
* Author: Steve Loughran | * Author: Steve Loughran | ||||
* Created: July 21, 2000 | * Created: July 21, 2000 | ||||
* Modified: $Modtime: 00-11-01 10:25 $ | |||||
* Modified: $Modtime: 00-11-01 10:25 $ | |||||
* Language: Java | * Language: Java | ||||
* Status: Experimental | * Status: Experimental | ||||
* | * | ||||
@@ -85,12 +85,12 @@ package org.apache.tools.ant.taskdefs.optional.dotnet; | |||||
// imports | // imports | ||||
// ==================================================================== | // ==================================================================== | ||||
import java.io.*; | |||||
import java.text.*; | |||||
import java.util.*; | |||||
import org.apache.tools.ant.*; | import org.apache.tools.ant.*; | ||||
import org.apache.tools.ant.taskdefs.*; | import org.apache.tools.ant.taskdefs.*; | ||||
import org.apache.tools.ant.types.*; | import org.apache.tools.ant.types.*; | ||||
import java.io.*; | |||||
import java.util.*; | |||||
import java.text.*; | |||||
/** | /** | ||||
Task to assemble .net 'Intermediate Language' files. | Task to assemble .net 'Intermediate Language' files. | ||||
@@ -213,7 +213,7 @@ import java.text.*; | |||||
public class Ilasm | public class Ilasm | ||||
extends org.apache.tools.ant.taskdefs.MatchingTask { | extends org.apache.tools.ant.taskdefs.MatchingTask { | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** constructor inits everything and set up the search pattern | /** constructor inits everything and set up the search pattern | ||||
*/ | */ | ||||
@@ -241,7 +241,7 @@ public class Ilasm | |||||
*/ | */ | ||||
protected static final String exe_title="ilasm"; | protected static final String exe_title="ilasm"; | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** reset all contents. | /** reset all contents. | ||||
*/ | */ | ||||
public void Clear() { | public void Clear() { | ||||
@@ -257,7 +257,7 @@ public class Ilasm | |||||
_owner=null; | _owner=null; | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** source directory upon which the search pattern is applied | /** source directory upon which the search pattern is applied | ||||
*/ | */ | ||||
private File _srcDir; | private File _srcDir; | ||||
@@ -270,7 +270,7 @@ public class Ilasm | |||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** type of target. Should be one of exe|library|module|winexe|(null) | /** type of target. Should be one of exe|library|module|winexe|(null) | ||||
default is exe; the actual value (if not null) is fed to the command line. | default is exe; the actual value (if not null) is fed to the command line. | ||||
<br>See /target | <br>See /target | ||||
@@ -286,7 +286,7 @@ public class Ilasm | |||||
throws BuildException { | throws BuildException { | ||||
targetType=targetType.toLowerCase(); | targetType=targetType.toLowerCase(); | ||||
if(targetType.equals("exe") || targetType.equals("library")) { | if(targetType.equals("exe") || targetType.equals("library")) { | ||||
_targetType=targetType; | |||||
_targetType=targetType; | |||||
} | } | ||||
else | else | ||||
throw new BuildException("targetType " +targetType+" is not a valid type"); | throw new BuildException("targetType " +targetType+" is not a valid type"); | ||||
@@ -294,7 +294,7 @@ public class Ilasm | |||||
public String getTargetType() { | public String getTargetType() { | ||||
return _targetType; | return _targetType; | ||||
} | |||||
} | |||||
/** get the argument or null for no argument needed | /** get the argument or null for no argument needed | ||||
*/ | */ | ||||
@@ -309,9 +309,9 @@ public class Ilasm | |||||
return "/dll"; | return "/dll"; | ||||
else | else | ||||
return null; | return null; | ||||
} | |||||
//============================================================================= | |||||
} | |||||
//============================================================================= | |||||
/** owner string is a slightly trivial barrier to disassembly | /** owner string is a slightly trivial barrier to disassembly | ||||
*/ | */ | ||||
@@ -328,7 +328,7 @@ public class Ilasm | |||||
return null; | return null; | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** test for a string containing something useful | /** test for a string containing something useful | ||||
* @param string to test | * @param string to test | ||||
* @returns true if the argument is not null or empty | * @returns true if the argument is not null or empty | ||||
@@ -336,7 +336,7 @@ public class Ilasm | |||||
protected boolean notEmpty(String s) | protected boolean notEmpty(String s) | ||||
{return s!=null && s.length()!=0;} | {return s!=null && s.length()!=0;} | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** verbose flag | /** verbose flag | ||||
*/ | */ | ||||
@@ -350,7 +350,7 @@ public class Ilasm | |||||
return _verbose?null:"/quiet"; | return _verbose?null:"/quiet"; | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** listing flag | /** listing flag | ||||
*/ | */ | ||||
@@ -364,7 +364,7 @@ public class Ilasm | |||||
return _listing?"/listing":"/nolisting"; | return _listing?"/listing":"/nolisting"; | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** output file. If not supplied this is derived from the | /** output file. If not supplied this is derived from the | ||||
* source file | * source file | ||||
*/ | */ | ||||
@@ -388,7 +388,7 @@ public class Ilasm | |||||
return "/output="+f.toString(); | return "/output="+f.toString(); | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** resource file (.res format) to include in the app. | /** resource file (.res format) to include in the app. | ||||
*/ | */ | ||||
@@ -406,7 +406,7 @@ public class Ilasm | |||||
return null; | return null; | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** flag to control action on execution trouble | /** flag to control action on execution trouble | ||||
*/ | */ | ||||
@@ -424,7 +424,7 @@ public class Ilasm | |||||
return _failOnError; | return _failOnError; | ||||
} | } | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** debug flag. Controls generation of debug information. | /** debug flag. Controls generation of debug information. | ||||
*/ | */ | ||||
@@ -436,7 +436,7 @@ public class Ilasm | |||||
public void setDebug(boolean f) | public void setDebug(boolean f) | ||||
{_debug=f;} | {_debug=f;} | ||||
/** query the debug flag | /** query the debug flag | ||||
* @return true if debug is turned on | * @return true if debug is turned on | ||||
*/ | */ | ||||
@@ -449,9 +449,9 @@ public class Ilasm | |||||
*/ | */ | ||||
protected String getDebugParameter() { | protected String getDebugParameter() { | ||||
return _debug?"/debug":null; | return _debug?"/debug":null; | ||||
} | |||||
} | |||||
//============================================================================= | |||||
//============================================================================= | |||||
/** This is the execution entry point. Build a list of files and | /** This is the execution entry point. Build a list of files and | ||||
* call ilasm on each of them. | * call ilasm on each of them. | ||||
*/ | */ | ||||
@@ -475,7 +475,7 @@ public class Ilasm | |||||
} // end execute | } // end execute | ||||
//============================================================================= | |||||
//============================================================================= | |||||
/** do the work by building the command line and then calling it | /** do the work by building the command line and then calling it | ||||
*/ | */ | ||||
@@ -504,7 +504,4 @@ public class Ilasm | |||||
//now run the command of exe + settings + file | //now run the command of exe + settings + file | ||||
command.runCommand(); | command.runCommand(); | ||||
} // end executeOneFile | } // end executeOneFile | ||||
} //class | } //class |
@@ -1,4 +1,4 @@ | |||||
/* -*-Java-*- | |||||
/* | |||||
******************************************************************* | ******************************************************************* | ||||
* | * | ||||
* File: CSharp.java | * File: CSharp.java | ||||
@@ -78,12 +78,12 @@ package org.apache.tools.ant.taskdefs.optional.dotnet; | |||||
// imports | // imports | ||||
import java.io.*; | |||||
import java.text.*; | |||||
import java.util.*; | |||||
import org.apache.tools.ant.*; | import org.apache.tools.ant.*; | ||||
import org.apache.tools.ant.taskdefs.*; | import org.apache.tools.ant.taskdefs.*; | ||||
import org.apache.tools.ant.types.*; | import org.apache.tools.ant.types.*; | ||||
import java.io.*; | |||||
import java.util.*; | |||||
import java.text.*; | |||||
@@ -232,6 +232,4 @@ public class NetCommand { | |||||
throw new BuildException(_title+" failed: " + e, e, _owner.getLocation()); | throw new BuildException(_title+" failed: " + e, e, _owner.getLocation()); | ||||
} | } | ||||
} | } | ||||
} //class | } //class |
@@ -51,7 +51,6 @@ | |||||
* information on the Apache Software Foundation, please see | * information on the Apache Software Foundation, please see | ||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs.optional.ejb; | package org.apache.tools.ant.taskdefs.optional.ejb; | ||||
import java.io.*; | import java.io.*; | ||||
@@ -345,9 +344,9 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||||
// now the vendor specific files, if any | // now the vendor specific files, if any | ||||
addVendorFiles(ejbFiles, baseName); | addVendorFiles(ejbFiles, baseName); | ||||
// add any inherited files | |||||
checkAndAddInherited(ejbFiles); | |||||
// add any inherited files | |||||
checkAndAddInherited(ejbFiles); | |||||
// Lastly create File object for the Jar files. If we are using | // Lastly create File object for the Jar files. If we are using | ||||
// a flat destination dir, then we need to redefine baseName! | // a flat destination dir, then we need to redefine baseName! | ||||
@@ -1,23 +1,76 @@ | |||||
/* | |||||
* The Apache Software License, Version 1.1 | |||||
* | |||||
* Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
* reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in | |||||
* the documentation and/or other materials provided with the | |||||
* distribution. | |||||
* | |||||
* 3. The end-user documentation included with the redistribution, if | |||||
* any, must include the following acknowlegement: | |||||
* "This product includes software developed by the | |||||
* Apache Software Foundation (http://www.apache.org/)." | |||||
* Alternately, this acknowlegement may appear in the software itself, | |||||
* if and wherever such third-party acknowlegements normally appear. | |||||
* | |||||
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
* Foundation" must not be used to endorse or promote products derived | |||||
* from this software without prior written permission. For written | |||||
* permission, please contact apache@apache.org. | |||||
* | |||||
* 5. Products derived from this software may not be called "Apache" | |||||
* nor may "Apache" appear in their names without prior written | |||||
* permission of the Apache Group. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
* SUCH DAMAGE. | |||||
* ==================================================================== | |||||
* | |||||
* This software consists of voluntary contributions made by many | |||||
* individuals on behalf of the Apache Software Foundation. For more | |||||
* information on the Apache Software Foundation, please see | |||||
* <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.tools.ant.taskdefs.optional.ejb; | package org.apache.tools.ant.taskdefs.optional.ejb; | ||||
import java.io.*; | import java.io.*; | ||||
public class InnerClassFilenameFilter implements FilenameFilter { | public class InnerClassFilenameFilter implements FilenameFilter { | ||||
private String baseClassName; | |||||
private String baseClassName; | |||||
InnerClassFilenameFilter(String baseclass){ | |||||
int extidx = baseclass.lastIndexOf(".class"); | |||||
if (extidx == -1) { | |||||
extidx = baseclass.length()-1; | |||||
} | |||||
baseClassName = baseclass.substring(0,extidx); | |||||
} | |||||
InnerClassFilenameFilter(String baseclass){ | |||||
int extidx = baseclass.lastIndexOf(".class"); | |||||
if (extidx == -1) { | |||||
extidx = baseclass.length()-1; | |||||
} | |||||
baseClassName = baseclass.substring(0,extidx); | |||||
} | |||||
public boolean accept (File Dir, String filename){ | |||||
if ((filename.lastIndexOf(".") != filename.lastIndexOf(".class")) | |||||
|| (filename.indexOf(baseClassName + "$") != 0)) { | |||||
return false; | |||||
} | |||||
return true; | |||||
} | |||||
public boolean accept (File Dir, String filename){ | |||||
if ((filename.lastIndexOf(".") != filename.lastIndexOf(".class")) | |||||
|| (filename.indexOf(baseClassName + "$") != 0)) { | |||||
return false; | |||||
} | |||||
return true; | |||||
} | |||||
} | } |
@@ -54,18 +54,18 @@ package org.apache.tools.ant.taskdefs.optional.ide; | |||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.Project; | |||||
import org.apache.tools.ant.Task; | |||||
import org.apache.tools.ant.types.PatternSet; | |||||
import com.ibm.ivj.util.base.ExportCodeSpec; | import com.ibm.ivj.util.base.ExportCodeSpec; | ||||
import com.ibm.ivj.util.base.IvjException; | import com.ibm.ivj.util.base.IvjException; | ||||
import com.ibm.ivj.util.base.Package; | import com.ibm.ivj.util.base.Package; | ||||
import java.io.File; | import java.io.File; | ||||
import java.util.Vector; | |||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import java.util.Vector; | |||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.Project; | |||||
import org.apache.tools.ant.Task; | |||||
import org.apache.tools.ant.types.PatternSet; | |||||
/** | /** | ||||
* Export packages from the Visual Age for Java workspace. | * Export packages from the Visual Age for Java workspace. | ||||
@@ -96,145 +96,145 @@ import java.util.Enumeration; | |||||
*/ | */ | ||||
public class VAJExport extends Task { | public class VAJExport extends Task { | ||||
protected File destDir; | |||||
protected boolean exportSources = true; | |||||
protected boolean exportResources = true; | |||||
protected boolean exportClasses = false; | |||||
protected boolean exportDebugInfo = false; | |||||
protected boolean useDefaultExcludes = true; | |||||
protected PatternSet patternSet = new PatternSet(); | |||||
/** | |||||
* add a name entry on the exclude list | |||||
*/ | |||||
public PatternSet.NameEntry createExclude() { | |||||
return patternSet.createExclude(); | |||||
} | |||||
/** | |||||
* add a name entry on the include list | |||||
*/ | |||||
public PatternSet.NameEntry createInclude() { | |||||
return patternSet.createInclude(); | |||||
} | |||||
/** | |||||
* do the export | |||||
*/ | |||||
public void execute() throws BuildException { | |||||
// first off, make sure that we've got a destdir | |||||
if (destDir == null) { | |||||
throw new BuildException("destdir attribute must be set!"); | |||||
} | |||||
VAJWorkspaceScanner ds = this.getWorkspaceScanner(); | |||||
Package[] packages = ds.getIncludedPackages(); | |||||
export(packages); | |||||
} | |||||
/** | |||||
* export the array of Packages | |||||
*/ | |||||
public void export(Package[] packages) { | |||||
try { | |||||
String dest = destDir.getAbsolutePath(); | |||||
log("Exporting " + packages.length + " package(s) to " + dest); | |||||
for (int i = 0; i < packages.length; i++) { | |||||
log(" " + packages[i].getName(), Project.MSG_VERBOSE); | |||||
} | |||||
ExportCodeSpec exportSpec = new ExportCodeSpec(); | |||||
exportSpec.setPackages(packages); | |||||
exportSpec.includeJava(exportSources); | |||||
exportSpec.includeClass(exportClasses); | |||||
exportSpec.includeResources(exportResources); | |||||
exportSpec.includeClassDebugInfo(exportDebugInfo); | |||||
exportSpec.useSubdirectories(true); | |||||
exportSpec.overwriteFiles(true); | |||||
exportSpec.setExportDirectory(dest); | |||||
VAJUtil.getWorkspace().exportData(exportSpec); | |||||
} catch (IvjException ex) { | |||||
throw VAJUtil.createBuildException("Exporting failed!", ex); | |||||
} | |||||
} | |||||
/** | |||||
* Returns the directory scanner needed to access the files to process. | |||||
*/ | |||||
protected VAJWorkspaceScanner getWorkspaceScanner() { | |||||
VAJWorkspaceScanner scanner = new VAJWorkspaceScanner(); | |||||
scanner.setIncludes(patternSet.getIncludePatterns(getProject())); | |||||
scanner.setExcludes(patternSet.getExcludePatterns(getProject())); | |||||
if (useDefaultExcludes) | |||||
scanner.addDefaultExcludes(); | |||||
scanner.scan(); | |||||
return scanner; | |||||
} | |||||
/** | |||||
* Sets whether default exclusions should be used or not. | |||||
* | |||||
* @param useDefaultExcludes "true"|"on"|"yes" when default exclusions | |||||
* should be used, "false"|"off"|"no" when they | |||||
* shouldn't be used. | |||||
*/ | |||||
public void setDefaultexcludes(boolean useDefaultExcludes) { | |||||
this.useDefaultExcludes = useDefaultExcludes; | |||||
} | |||||
/** | |||||
* Set the destination directory into which the Java source | |||||
* files should be compiled. | |||||
*/ | |||||
public void setDestdir(File destDir) { | |||||
this.destDir = destDir; | |||||
} | |||||
/** | |||||
* Sets the set of exclude patterns. Patterns may be separated by a comma | |||||
* or a space. | |||||
* | |||||
* @param excludes the string containing the exclude patterns | |||||
*/ | |||||
public void setExcludes(String excludes) { | |||||
patternSet.setExcludes(excludes); | |||||
} | |||||
/** | |||||
*/ | |||||
public void setExportClasses(boolean doExport) { | |||||
exportClasses = doExport; | |||||
} | |||||
/** | |||||
*/ | |||||
public void setExportDebugInfo(boolean doExport) { | |||||
exportDebugInfo = doExport; | |||||
} | |||||
/** | |||||
*/ | |||||
public void setExportResources(boolean doExport) { | |||||
exportResources = doExport; | |||||
} | |||||
/** | |||||
*/ | |||||
public void setExportSources(boolean doExport) { | |||||
exportSources = doExport; | |||||
} | |||||
/** | |||||
* Sets the set of include patterns. Patterns may be separated by a comma | |||||
* or a space. | |||||
* | |||||
* @param includes the string containing the include patterns | |||||
*/ | |||||
public void setIncludes(String includes) { | |||||
patternSet.setIncludes(includes); | |||||
} | |||||
} | |||||
protected File destDir; | |||||
protected boolean exportSources = true; | |||||
protected boolean exportResources = true; | |||||
protected boolean exportClasses = false; | |||||
protected boolean exportDebugInfo = false; | |||||
protected boolean useDefaultExcludes = true; | |||||
protected PatternSet patternSet = new PatternSet(); | |||||
/** | |||||
* add a name entry on the exclude list | |||||
*/ | |||||
public PatternSet.NameEntry createExclude() { | |||||
return patternSet.createExclude(); | |||||
} | |||||
/** | |||||
* add a name entry on the include list | |||||
*/ | |||||
public PatternSet.NameEntry createInclude() { | |||||
return patternSet.createInclude(); | |||||
} | |||||
/** | |||||
* do the export | |||||
*/ | |||||
public void execute() throws BuildException { | |||||
// first off, make sure that we've got a destdir | |||||
if (destDir == null) { | |||||
throw new BuildException("destdir attribute must be set!"); | |||||
} | |||||
VAJWorkspaceScanner ds = this.getWorkspaceScanner(); | |||||
Package[] packages = ds.getIncludedPackages(); | |||||
export(packages); | |||||
} | |||||
/** | |||||
* export the array of Packages | |||||
*/ | |||||
public void export(Package[] packages) { | |||||
try { | |||||
String dest = destDir.getAbsolutePath(); | |||||
log("Exporting " + packages.length + " package(s) to " + dest); | |||||
for (int i = 0; i < packages.length; i++) { | |||||
log(" " + packages[i].getName(), Project.MSG_VERBOSE); | |||||
} | |||||
ExportCodeSpec exportSpec = new ExportCodeSpec(); | |||||
exportSpec.setPackages(packages); | |||||
exportSpec.includeJava(exportSources); | |||||
exportSpec.includeClass(exportClasses); | |||||
exportSpec.includeResources(exportResources); | |||||
exportSpec.includeClassDebugInfo(exportDebugInfo); | |||||
exportSpec.useSubdirectories(true); | |||||
exportSpec.overwriteFiles(true); | |||||
exportSpec.setExportDirectory(dest); | |||||
VAJUtil.getWorkspace().exportData(exportSpec); | |||||
} catch (IvjException ex) { | |||||
throw VAJUtil.createBuildException("Exporting failed!", ex); | |||||
} | |||||
} | |||||
/** | |||||
* Returns the directory scanner needed to access the files to process. | |||||
*/ | |||||
protected VAJWorkspaceScanner getWorkspaceScanner() { | |||||
VAJWorkspaceScanner scanner = new VAJWorkspaceScanner(); | |||||
scanner.setIncludes(patternSet.getIncludePatterns(getProject())); | |||||
scanner.setExcludes(patternSet.getExcludePatterns(getProject())); | |||||
if (useDefaultExcludes) | |||||
scanner.addDefaultExcludes(); | |||||
scanner.scan(); | |||||
return scanner; | |||||
} | |||||
/** | |||||
* Sets whether default exclusions should be used or not. | |||||
* | |||||
* @param useDefaultExcludes "true"|"on"|"yes" when default exclusions | |||||
* should be used, "false"|"off"|"no" when they | |||||
* shouldn't be used. | |||||
*/ | |||||
public void setDefaultexcludes(boolean useDefaultExcludes) { | |||||
this.useDefaultExcludes = useDefaultExcludes; | |||||
} | |||||
/** | |||||
* Set the destination directory into which the Java source | |||||
* files should be compiled. | |||||
*/ | |||||
public void setDestdir(File destDir) { | |||||
this.destDir = destDir; | |||||
} | |||||
/** | |||||
* Sets the set of exclude patterns. Patterns may be separated by a comma | |||||
* or a space. | |||||
* | |||||
* @param excludes the string containing the exclude patterns | |||||
*/ | |||||
public void setExcludes(String excludes) { | |||||
patternSet.setExcludes(excludes); | |||||
} | |||||
/** | |||||
*/ | |||||
public void setExportClasses(boolean doExport) { | |||||
exportClasses = doExport; | |||||
} | |||||
/** | |||||
*/ | |||||
public void setExportDebugInfo(boolean doExport) { | |||||
exportDebugInfo = doExport; | |||||
} | |||||
/** | |||||
*/ | |||||
public void setExportResources(boolean doExport) { | |||||
exportResources = doExport; | |||||
} | |||||
/** | |||||
*/ | |||||
public void setExportSources(boolean doExport) { | |||||
exportSources = doExport; | |||||
} | |||||
/** | |||||
* Sets the set of include patterns. Patterns may be separated by a comma | |||||
* or a space. | |||||
* | |||||
* @param includes the string containing the include patterns | |||||
*/ | |||||
public void setIncludes(String includes) { | |||||
patternSet.setIncludes(includes); | |||||
} | |||||
} |
@@ -54,20 +54,20 @@ package org.apache.tools.ant.taskdefs.optional.ide; | |||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
import org.apache.tools.ant.Task; | |||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.DirectoryScanner; | |||||
import org.apache.tools.ant.types.FileSet; | |||||
import com.ibm.ivj.util.base.ImportCodeSpec; | import com.ibm.ivj.util.base.ImportCodeSpec; | ||||
import com.ibm.ivj.util.base.IvjException; | import com.ibm.ivj.util.base.IvjException; | ||||
import com.ibm.ivj.util.base.Project; | import com.ibm.ivj.util.base.Project; | ||||
import com.ibm.ivj.util.base.ProjectEdition; | import com.ibm.ivj.util.base.ProjectEdition; | ||||
import com.ibm.ivj.util.base.Type; | import com.ibm.ivj.util.base.Type; | ||||
import java.io.File; | import java.io.File; | ||||
import java.util.Vector; | |||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import java.util.Vector; | |||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.DirectoryScanner; | |||||
import org.apache.tools.ant.Task; | |||||
import org.apache.tools.ant.types.FileSet; | |||||
/** | /** | ||||
* Import source, class files, and resources to the Visual Age for Java | * Import source, class files, and resources to the Visual Age for Java | ||||
@@ -123,218 +123,220 @@ import java.util.Enumeration; | |||||
* @author: Glenn McAllister, inspired by a similar task written by Peter Kelley | * @author: Glenn McAllister, inspired by a similar task written by Peter Kelley | ||||
*/ | */ | ||||
public class VAJImport extends Task { | public class VAJImport extends Task { | ||||
protected Vector filesets = new Vector(); | |||||
protected boolean importSources = true; | |||||
protected boolean importResources = true; | |||||
protected boolean importClasses = false; | |||||
protected String importProject = null; | |||||
protected Project vajproject = null; | |||||
protected Vector filesets = new Vector(); | |||||
protected boolean importSources = true; | |||||
protected boolean importResources = true; | |||||
protected boolean importClasses = false; | |||||
protected String importProject = null; | |||||
protected Project vajproject = null; | |||||
/** | |||||
* The VisualAge for Java Project name to import into. | |||||
*/ | |||||
public void setProject(String projectName) { | |||||
this.importProject = projectName; | |||||
} | |||||
/** | |||||
* The VisualAge for Java Project name to import into. | |||||
*/ | |||||
public void setProject(String projectName) { | |||||
this.importProject = projectName; | |||||
} | |||||
/** | |||||
* Adds a set of files (nested fileset attribute). | |||||
*/ | |||||
public void addFileset(FileSet set) { | |||||
filesets.addElement(set); | |||||
} | |||||
/** | |||||
* Adds a set of files (nested fileset attribute). | |||||
*/ | |||||
public void addFileset(FileSet set) { | |||||
filesets.addElement(set); | |||||
} | |||||
/** | |||||
* Import .class files. | |||||
*/ | |||||
public void setImportClasses(boolean importClasses) { | |||||
this.importClasses = importClasses; | |||||
} | |||||
/** | |||||
* Import .class files. | |||||
*/ | |||||
public void setImportClasses(boolean importClasses) { | |||||
this.importClasses = importClasses; | |||||
} | |||||
/** | |||||
* Import resource files (anything that doesn't end in | |||||
* .class or .java) | |||||
*/ | |||||
public void setImportResources(boolean importResources) { | |||||
this.importResources = importResources; | |||||
} | |||||
/** | |||||
* Import resource files (anything that doesn't end in | |||||
* .class or .java) | |||||
*/ | |||||
public void setImportResources(boolean importResources) { | |||||
this.importResources = importResources; | |||||
} | |||||
/** | |||||
* Import .java files | |||||
*/ | |||||
public void setImportSources(boolean importSources) { | |||||
this.importSources = importSources; | |||||
} | |||||
/** | |||||
* Import .java files | |||||
*/ | |||||
public void setImportSources(boolean importSources) { | |||||
this.importSources = importSources; | |||||
} | |||||
/** | |||||
* Do the import. | |||||
*/ | |||||
public void execute() throws BuildException { | |||||
if (filesets.size() == 0) { | |||||
throw new BuildException("At least one fileset is required!"); | |||||
} | |||||
/** | |||||
* Do the import. | |||||
*/ | |||||
public void execute() throws BuildException { | |||||
if (filesets.size() == 0) { | |||||
throw new BuildException("At least one fileset is required!"); | |||||
} | |||||
if (importProject == null || "".equals(importProject)) { | |||||
throw new BuildException("The VisualAge for Java Project name is required!"); | |||||
} | |||||
if (importProject == null || "".equals(importProject)) { | |||||
throw new BuildException("The VisualAge for Java Project name is required!"); | |||||
} | |||||
vajproject = getVAJProject(); | |||||
if (vajproject == null) { | |||||
try { | |||||
vajproject = VAJUtil.getWorkspace().createProject(this.importProject, true); | |||||
} catch (IvjException e) { | |||||
throw VAJUtil.createBuildException( "Error while creating Project " + | |||||
importProject + ": ", | |||||
e ); | |||||
} | |||||
} | |||||
vajproject = getVAJProject(); | |||||
if (vajproject == null) { | |||||
try { | |||||
vajproject = VAJUtil.getWorkspace().createProject(this.importProject, true); | |||||
} catch (IvjException e) { | |||||
throw VAJUtil.createBuildException( | |||||
"Error while creating Project " + importProject + ": ", | |||||
e); | |||||
} | |||||
} | |||||
for (Enumeration e = filesets.elements(); e.hasMoreElements();) { | |||||
importFileset((FileSet) e.nextElement()); | |||||
} | |||||
} | |||||
for (Enumeration e = filesets.elements(); e.hasMoreElements();) { | |||||
importFileset((FileSet) e.nextElement()); | |||||
} | |||||
} | |||||
/** | |||||
* Try to get the project we want from the Workspace. | |||||
*/ | |||||
protected Project getVAJProject() { | |||||
Project found = null; | |||||
Project[] currentProjects = VAJUtil.getWorkspace().getProjects(); | |||||
/** | |||||
* Try to get the project we want from the Workspace. | |||||
*/ | |||||
protected Project getVAJProject() { | |||||
Project found = null; | |||||
Project[] currentProjects = VAJUtil.getWorkspace().getProjects(); | |||||
for (int i = 0; i < currentProjects.length; i++) { | |||||
Project p = currentProjects[i]; | |||||
if (p.getName().equals(this.importProject)) { | |||||
found = p; | |||||
break; | |||||
} | |||||
} | |||||
for (int i = 0; i < currentProjects.length; i++) { | |||||
Project p = currentProjects[i]; | |||||
if (p.getName().equals(this.importProject)) { | |||||
found = p; | |||||
break; | |||||
} | |||||
} | |||||
return found; | |||||
} | |||||
return found; | |||||
} | |||||
/** | |||||
* Import all files from the fileset into the Project in the | |||||
* Workspace. | |||||
*/ | |||||
protected void importFileset(FileSet fileset) { | |||||
DirectoryScanner ds = fileset.getDirectoryScanner(this.project); | |||||
if (ds.getIncludedFiles().length == 0) { | |||||
return; | |||||
} | |||||
/** | |||||
* Import all files from the fileset into the Project in the | |||||
* Workspace. | |||||
*/ | |||||
protected void importFileset(FileSet fileset) { | |||||
DirectoryScanner ds = fileset.getDirectoryScanner(this.project); | |||||
if (ds.getIncludedFiles().length == 0) { | |||||
return; | |||||
} | |||||
Vector classes = new Vector(); | |||||
Vector sources = new Vector(); | |||||
Vector resources = new Vector(); | |||||
Vector classes = new Vector(); | |||||
Vector sources = new Vector(); | |||||
Vector resources = new Vector(); | |||||
String[] classesArr = null; | |||||
String[] sourcesArr = null; | |||||
String[] resourcesArr = null; | |||||
String[] classesArr = null; | |||||
String[] sourcesArr = null; | |||||
String[] resourcesArr = null; | |||||
StringBuffer msg = new StringBuffer(); | |||||
msg.append("Importing "); | |||||
String connector = ""; | |||||
StringBuffer msg = new StringBuffer(); | |||||
msg.append("Importing "); | |||||
String connector = ""; | |||||
ImportCodeSpec importSpec = new ImportCodeSpec(); | |||||
importSpec.setDefaultProject(vajproject); | |||||
ImportCodeSpec importSpec = new ImportCodeSpec(); | |||||
importSpec.setDefaultProject(vajproject); | |||||
scan( | |||||
fileset.getDir(this.project), | |||||
ds.getIncludedFiles(), | |||||
classes, | |||||
sources, | |||||
resources); | |||||
scan( | |||||
fileset.getDir(this.project), | |||||
ds.getIncludedFiles(), | |||||
classes, | |||||
sources, | |||||
resources); | |||||
if (importClasses) { | |||||
classesArr = new String[classes.size()]; | |||||
classes.copyInto(classesArr); | |||||
importSpec.setClassFiles(classesArr); | |||||
if (classesArr.length > 0) { | |||||
logFiles(classes, "class"); | |||||
msg.append( classesArr.length ); | |||||
msg.append( " class " ); | |||||
msg.append( classesArr.length > 1 ? "files" : "file" ); | |||||
connector = ", "; | |||||
} | |||||
} | |||||
if (importClasses) { | |||||
classesArr = new String[classes.size()]; | |||||
classes.copyInto(classesArr); | |||||
importSpec.setClassFiles(classesArr); | |||||
if (classesArr.length > 0) { | |||||
logFiles(classes, "class"); | |||||
msg.append( classesArr.length ); | |||||
msg.append( " class " ); | |||||
msg.append( classesArr.length > 1 ? "files" : "file" ); | |||||
connector = ", "; | |||||
} | |||||
} | |||||
if (importSources) { | |||||
sourcesArr = new String[sources.size()]; | |||||
sources.copyInto(sourcesArr); | |||||
importSpec.setJavaFiles(sourcesArr); | |||||
if (sourcesArr.length > 0) { | |||||
logFiles(sources, "source"); | |||||
msg.append( connector ); | |||||
msg.append( sourcesArr.length ); | |||||
msg.append( " source " ); | |||||
msg.append( sourcesArr.length > 1 ? "files" : "file" ); | |||||
connector = ", "; | |||||
} | |||||
} | |||||
if (importSources) { | |||||
sourcesArr = new String[sources.size()]; | |||||
sources.copyInto(sourcesArr); | |||||
importSpec.setJavaFiles(sourcesArr); | |||||
if (sourcesArr.length > 0) { | |||||
logFiles(sources, "source"); | |||||
msg.append( connector ); | |||||
msg.append( sourcesArr.length ); | |||||
msg.append( " source " ); | |||||
msg.append( sourcesArr.length > 1 ? "files" : "file" ); | |||||
connector = ", "; | |||||
} | |||||
} | |||||
if (importResources) { | |||||
String resourcePath = fileset.getDir(this.project).getAbsolutePath(); | |||||
resourcesArr = new String[resources.size()]; | |||||
resources.copyInto(resourcesArr); | |||||
importSpec.setResourcePath(resourcePath); | |||||
importSpec.setResourceFiles(resourcesArr); | |||||
if (resourcesArr.length > 0) { | |||||
logFiles(resources, "resource"); | |||||
log( " (relative to resource path '" + resourcePath + "')", | |||||
org.apache.tools.ant.Project.MSG_VERBOSE ); | |||||
if (importResources) { | |||||
String resourcePath = fileset.getDir(this.project).getAbsolutePath(); | |||||
resourcesArr = new String[resources.size()]; | |||||
resources.copyInto(resourcesArr); | |||||
importSpec.setResourcePath(resourcePath); | |||||
importSpec.setResourceFiles(resourcesArr); | |||||
if (resourcesArr.length > 0) { | |||||
logFiles(resources, "resource"); | |||||
log( " (relative to resource path '" + resourcePath + "')", org.apache.tools.ant.Project.MSG_VERBOSE ); | |||||
msg.append( connector ); | |||||
msg.append( resourcesArr.length ); | |||||
msg.append( " resource " ); | |||||
msg.append( resourcesArr.length > 1 ? "files" : "file" ); | |||||
} | |||||
} | |||||
msg.append( connector ); | |||||
msg.append( resourcesArr.length ); | |||||
msg.append( " resource " ); | |||||
msg.append( resourcesArr.length > 1 ? "files" : "file" ); | |||||
} | |||||
} | |||||
msg.append( " into the " ); | |||||
msg.append( importProject ); | |||||
msg.append( " project." ); | |||||
msg.append( " into the " ); | |||||
msg.append( importProject ); | |||||
msg.append( " project." ); | |||||
log(msg.toString()); | |||||
try { | |||||
Type[] importedTypes = VAJUtil.getWorkspace().importData(importSpec); | |||||
if (importedTypes == null) { | |||||
throw new BuildException("Unable to import into Workspace!"); | |||||
} | |||||
} catch (IvjException ivje) { | |||||
VAJUtil.createBuildException("Error while importing into Workspace: ", ivje); | |||||
} | |||||
} | |||||
log(msg.toString()); | |||||
try { | |||||
Type[] importedTypes = VAJUtil.getWorkspace().importData(importSpec); | |||||
if (importedTypes == null) { | |||||
throw new BuildException("Unable to import into Workspace!"); | |||||
} | |||||
} catch (IvjException ivje) { | |||||
VAJUtil.createBuildException("Error while importing into Workspace: ", ivje); | |||||
} | |||||
} | |||||
/** | |||||
* Sort the files into classes, sources, and resources. | |||||
*/ | |||||
protected void scan( | |||||
File dir, | |||||
String[] files, | |||||
Vector classes, | |||||
Vector sources, | |||||
Vector resources) { | |||||
for (int i = 0; i < files.length; i++) { | |||||
String file = (new File(dir, files[i])).getAbsolutePath(); | |||||
if (file.endsWith(".java") || file.endsWith(".JAVA")) { | |||||
sources.addElement(file); | |||||
} else | |||||
if (file.endsWith(".class") || file.endsWith(".CLASS")) { | |||||
classes.addElement(file); | |||||
} else { | |||||
// for resources VA expects the path relative to the resource path | |||||
resources.addElement(files[i]); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* Logs a list of file names to the message log | |||||
* @param fileNames java.util.Vector file names to be logged | |||||
* @param type java.lang.String file type | |||||
*/ | |||||
protected void logFiles(Vector fileNames, String fileType) { | |||||
log( fileType + " files found for import:", org.apache.tools.ant.Project.MSG_VERBOSE); | |||||
for ( Enumeration e = fileNames.elements(); e.hasMoreElements(); ) { | |||||
log( " " + e.nextElement(), org.apache.tools.ant.Project.MSG_VERBOSE ); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* Sort the files into classes, sources, and resources. | |||||
*/ | |||||
protected void scan( | |||||
File dir, | |||||
String[] files, | |||||
Vector classes, | |||||
Vector sources, | |||||
Vector resources) { | |||||
for (int i = 0; i < files.length; i++) { | |||||
String file = (new File(dir, files[i])).getAbsolutePath(); | |||||
if (file.endsWith(".java") || file.endsWith(".JAVA")) { | |||||
sources.addElement(file); | |||||
} else | |||||
if (file.endsWith(".class") || file.endsWith(".CLASS")) { | |||||
classes.addElement(file); | |||||
} else { | |||||
// for resources VA expects the path relative to the resource path | |||||
resources.addElement(files[i]); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* Logs a list of file names to the message log | |||||
* @param fileNames java.util.Vector file names to be logged | |||||
* @param type java.lang.String file type | |||||
*/ | |||||
protected void logFiles(Vector fileNames, String fileType) { | |||||
log( fileType + " files found for import:", org.apache.tools.ant.Project.MSG_VERBOSE); | |||||
for ( Enumeration e = fileNames.elements(); e.hasMoreElements(); ) { | |||||
log( " " + e.nextElement(), org.apache.tools.ant.Project.MSG_VERBOSE ); | |||||
} | |||||
} | |||||
} |
@@ -54,15 +54,15 @@ package org.apache.tools.ant.taskdefs.optional.ide; | |||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.Project; | |||||
import org.apache.tools.ant.Task; | |||||
import com.ibm.ivj.util.base.IvjException; | import com.ibm.ivj.util.base.IvjException; | ||||
import com.ibm.ivj.util.base.ProjectEdition; | import com.ibm.ivj.util.base.ProjectEdition; | ||||
import java.util.Vector; | |||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import java.util.Vector; | |||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.Project; | |||||
import org.apache.tools.ant.Task; | |||||
/** | /** | ||||
* Load specific project versions into the Visual Age for Java workspace. | * Load specific project versions into the Visual Age for Java workspace. | ||||
@@ -79,175 +79,175 @@ import java.util.Enumeration; | |||||
*/ | */ | ||||
public class VAJLoadProjects extends Task { | public class VAJLoadProjects extends Task { | ||||
Vector projectDescriptions = new Vector(); | |||||
Vector expandedProjectDescriptions = new Vector(); | |||||
/** | |||||
* Class to maintain VisualAge for Java Workspace Project descriptions. | |||||
*/ | |||||
public class VAJProjectDescription { | |||||
private String name; | |||||
private String version; | |||||
private boolean projectFound; | |||||
public VAJProjectDescription() { | |||||
} | |||||
public VAJProjectDescription(String n, String v) { | |||||
name = n; | |||||
version = v; | |||||
} | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public String getVersion() { | |||||
return version; | |||||
} | |||||
public boolean projectFound() { | |||||
return projectFound; | |||||
} | |||||
public void setName(String newName) { | |||||
if (newName == null || newName.equals("")) { | |||||
throw new BuildException("name attribute must be set"); | |||||
} | |||||
name = newName; | |||||
} | |||||
public void setVersion(String newVersion) { | |||||
if (newVersion == null || newVersion.equals("")) { | |||||
throw new BuildException("version attribute must be set"); | |||||
} | |||||
version = newVersion; | |||||
} | |||||
public void setProjectFound() { | |||||
projectFound = true; | |||||
} | |||||
} | |||||
Vector projectDescriptions = new Vector(); | |||||
Vector expandedProjectDescriptions = new Vector(); | |||||
/** | |||||
* Class to maintain VisualAge for Java Workspace Project descriptions. | |||||
*/ | |||||
public class VAJProjectDescription { | |||||
private String name; | |||||
private String version; | |||||
private boolean projectFound; | |||||
public VAJProjectDescription() { | |||||
} | |||||
public VAJProjectDescription(String n, String v) { | |||||
name = n; | |||||
version = v; | |||||
} | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public String getVersion() { | |||||
return version; | |||||
} | |||||
public boolean projectFound() { | |||||
return projectFound; | |||||
} | |||||
public void setName(String newName) { | |||||
if (newName == null || newName.equals("")) { | |||||
throw new BuildException("name attribute must be set"); | |||||
} | |||||
name = newName; | |||||
} | |||||
public void setVersion(String newVersion) { | |||||
if (newVersion == null || newVersion.equals("")) { | |||||
throw new BuildException("version attribute must be set"); | |||||
} | |||||
version = newVersion; | |||||
} | |||||
public void setProjectFound() { | |||||
projectFound = true; | |||||
} | |||||
} | |||||
/** | |||||
* Add a project description entry on the project list. | |||||
*/ | |||||
public VAJProjectDescription createProject() { | |||||
VAJProjectDescription d = new VAJProjectDescription(); | |||||
projectDescriptions.addElement(d); | |||||
return d; | |||||
} | |||||
/** | |||||
* Load specified projects. | |||||
*/ | |||||
public void execute() { | |||||
expandDescriptions(); | |||||
log( | |||||
"Loading " + expandedProjectDescriptions.size() + " project(s) into workspace"); | |||||
for (Enumeration e = expandedProjectDescriptions.elements(); | |||||
e.hasMoreElements(); | |||||
) { | |||||
VAJProjectDescription d = (VAJProjectDescription) e.nextElement(); | |||||
ProjectEdition pe = findProjectEdition(d.getName(), d.getVersion()); | |||||
try { | |||||
log( | |||||
"Loading " + d.getName() + ", Version " + d.getVersion() + ", into Workspace", | |||||
Project.MSG_VERBOSE); | |||||
pe.loadIntoWorkspace(); | |||||
} catch (IvjException ex) { | |||||
throw VAJUtil.createBuildException( | |||||
"Project " + d.getName() + " could not be loaded.", | |||||
ex); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
*/ | |||||
public void expandDescriptions() { | |||||
String[] projectNames; | |||||
try { | |||||
projectNames = VAJUtil.getWorkspace().getRepository().getProjectNames(); | |||||
} catch (IvjException e) { | |||||
throw VAJUtil.createBuildException("VA Exception occured: ", e); | |||||
} | |||||
for (int i = 0; i < projectNames.length; i++) { | |||||
for (Enumeration e = projectDescriptions.elements(); e.hasMoreElements();) { | |||||
VAJProjectDescription d = (VAJProjectDescription) e.nextElement(); | |||||
String pattern = d.getName(); | |||||
if (VAJWorkspaceScanner.match(pattern, projectNames[i])) { | |||||
d.setProjectFound(); | |||||
expandedProjectDescriptions.addElement( | |||||
new VAJProjectDescription(projectNames[i], d.getVersion())); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
for (Enumeration e = projectDescriptions.elements(); e.hasMoreElements();) { | |||||
VAJProjectDescription d = (VAJProjectDescription) e.nextElement(); | |||||
if (!d.projectFound()) { | |||||
log("No Projects match the name " + d.getName(), Project.MSG_WARN); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
*/ | |||||
public static Vector findMatchingProjects(String pattern) { | |||||
String[] projectNames; | |||||
try { | |||||
projectNames = VAJUtil.getWorkspace().getRepository().getProjectNames(); | |||||
} catch (IvjException e) { | |||||
throw VAJUtil.createBuildException("VA Exception occured: ", e); | |||||
} | |||||
Vector matchingProjects = new Vector(); | |||||
for (int i = 0; i < projectNames.length; i++) { | |||||
if (VAJWorkspaceScanner.match(pattern, projectNames[i])) { | |||||
matchingProjects.addElement(projectNames[i]); | |||||
} | |||||
} | |||||
return matchingProjects; | |||||
} | |||||
/** | |||||
* Finds a specific project edition in the repository. | |||||
* | |||||
* @param name project name | |||||
* @param versionName project version name | |||||
* @return com.ibm.ivj.util.base.ProjectEdition | |||||
*/ | |||||
public static ProjectEdition findProjectEdition( | |||||
String name, | |||||
String versionName) { | |||||
try { | |||||
ProjectEdition[] editions = null; | |||||
editions = VAJUtil.getWorkspace().getRepository().getProjectEditions(name); | |||||
if (editions == null) { | |||||
throw new BuildException("Project " + name + " doesn't exist"); | |||||
} | |||||
ProjectEdition pe = null; | |||||
for (int i = 0; i < editions.length && pe == null; i++) { | |||||
if (versionName.equals(editions[i].getVersionName())) { | |||||
pe = editions[i]; | |||||
} | |||||
} | |||||
if (pe == null) { | |||||
throw new BuildException( | |||||
"Version " + versionName + " of Project " + name + " doesn't exist"); | |||||
} | |||||
return pe; | |||||
} catch (IvjException e) { | |||||
throw VAJUtil.createBuildException("VA Exception occured: ", e); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* Add a project description entry on the project list. | |||||
*/ | |||||
public VAJProjectDescription createProject() { | |||||
VAJProjectDescription d = new VAJProjectDescription(); | |||||
projectDescriptions.addElement(d); | |||||
return d; | |||||
} | |||||
/** | |||||
* Load specified projects. | |||||
*/ | |||||
public void execute() { | |||||
expandDescriptions(); | |||||
log( | |||||
"Loading " + expandedProjectDescriptions.size() + " project(s) into workspace"); | |||||
for (Enumeration e = expandedProjectDescriptions.elements(); | |||||
e.hasMoreElements(); | |||||
) { | |||||
VAJProjectDescription d = (VAJProjectDescription) e.nextElement(); | |||||
ProjectEdition pe = findProjectEdition(d.getName(), d.getVersion()); | |||||
try { | |||||
log( "Loading " + d.getName() + ", Version " + d.getVersion() + | |||||
", into Workspace", | |||||
Project.MSG_VERBOSE ); | |||||
pe.loadIntoWorkspace(); | |||||
} catch (IvjException ex) { | |||||
throw VAJUtil.createBuildException( "Project " + d.getName() + | |||||
" could not be loaded.", | |||||
ex ); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
*/ | |||||
public void expandDescriptions() { | |||||
String[] projectNames; | |||||
try { | |||||
projectNames = VAJUtil.getWorkspace().getRepository().getProjectNames(); | |||||
} catch (IvjException e) { | |||||
throw VAJUtil.createBuildException("VA Exception occured: ", e); | |||||
} | |||||
for (int i = 0; i < projectNames.length; i++) { | |||||
for (Enumeration e = projectDescriptions.elements(); e.hasMoreElements();) { | |||||
VAJProjectDescription d = (VAJProjectDescription) e.nextElement(); | |||||
String pattern = d.getName(); | |||||
if (VAJWorkspaceScanner.match(pattern, projectNames[i])) { | |||||
d.setProjectFound(); | |||||
expandedProjectDescriptions. | |||||
addElement(new VAJProjectDescription(projectNames[i], d.getVersion())); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
for (Enumeration e = projectDescriptions.elements(); e.hasMoreElements();) { | |||||
VAJProjectDescription d = (VAJProjectDescription) e.nextElement(); | |||||
if (!d.projectFound()) { | |||||
log("No Projects match the name " + d.getName(), Project.MSG_WARN); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
*/ | |||||
public static Vector findMatchingProjects(String pattern) { | |||||
String[] projectNames; | |||||
try { | |||||
projectNames = VAJUtil.getWorkspace().getRepository().getProjectNames(); | |||||
} catch (IvjException e) { | |||||
throw VAJUtil.createBuildException("VA Exception occured: ", e); | |||||
} | |||||
Vector matchingProjects = new Vector(); | |||||
for (int i = 0; i < projectNames.length; i++) { | |||||
if (VAJWorkspaceScanner.match(pattern, projectNames[i])) { | |||||
matchingProjects.addElement(projectNames[i]); | |||||
} | |||||
} | |||||
return matchingProjects; | |||||
} | |||||
/** | |||||
* Finds a specific project edition in the repository. | |||||
* | |||||
* @param name project name | |||||
* @param versionName project version name | |||||
* @return com.ibm.ivj.util.base.ProjectEdition | |||||
*/ | |||||
public static ProjectEdition findProjectEdition( | |||||
String name, | |||||
String versionName) { | |||||
try { | |||||
ProjectEdition[] editions = null; | |||||
editions = VAJUtil.getWorkspace().getRepository().getProjectEditions(name); | |||||
if (editions == null) { | |||||
throw new BuildException("Project " + name + " doesn't exist"); | |||||
} | |||||
ProjectEdition pe = null; | |||||
for (int i = 0; i < editions.length && pe == null; i++) { | |||||
if (versionName.equals(editions[i].getVersionName())) { | |||||
pe = editions[i]; | |||||
} | |||||
} | |||||
if (pe == null) { | |||||
throw new BuildException( "Version " + versionName + " of Project " + | |||||
name + " doesn't exist" ); | |||||
} | |||||
return pe; | |||||
} catch (IvjException e) { | |||||
throw VAJUtil.createBuildException("VA Exception occured: ", e); | |||||
} | |||||
} | |||||
} |
@@ -54,9 +54,9 @@ package org.apache.tools.ant.taskdefs.optional.ide; | |||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
import com.ibm.ivj.util.base.Workspace; | |||||
import com.ibm.ivj.util.base.ToolEnv; | |||||
import com.ibm.ivj.util.base.IvjException; | import com.ibm.ivj.util.base.IvjException; | ||||
import com.ibm.ivj.util.base.ToolEnv; | |||||
import com.ibm.ivj.util.base.Workspace; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
/** | /** | ||||
@@ -66,43 +66,43 @@ import org.apache.tools.ant.BuildException; | |||||
* @author Wolf Siberski, TUI Infotec GmbH | * @author Wolf Siberski, TUI Infotec GmbH | ||||
*/ | */ | ||||
class VAJUtil { | class VAJUtil { | ||||
static private Workspace workspace; | |||||
/** | |||||
* Wraps IvjException into a BuildException | |||||
* | |||||
* @return org.apache.tools.ant.BuildException | |||||
* @param errMsg Additional error message | |||||
* @param e IvjException which is wrapped | |||||
*/ | |||||
public static BuildException createBuildException( | |||||
String errMsg, | |||||
IvjException e) { | |||||
errMsg = errMsg + "\n" + e.getMessage(); | |||||
String[] errors = e.getErrors(); | |||||
if (errors != null) { | |||||
for (int i = 0; i < errors.length; i++) { | |||||
errMsg = errMsg + "\n" + errors[i]; | |||||
} | |||||
} | |||||
return new BuildException(errMsg); | |||||
} | |||||
/** | |||||
* Insert the method's description here. | |||||
* Creation date: (19.09.2000 13:41:21) | |||||
* @return com.ibm.ivj.util.base.Workspace | |||||
*/ | |||||
public static Workspace getWorkspace() { | |||||
if (workspace == null) { | |||||
workspace = ToolEnv.connectToWorkspace(); | |||||
if (workspace == null) { | |||||
throw new BuildException( | |||||
"Unable to connect to Workspace! " | |||||
+ "Make sure you are running in VisualAge for Java."); | |||||
} | |||||
} | |||||
static private Workspace workspace; | |||||
/** | |||||
* Wraps IvjException into a BuildException | |||||
* | |||||
* @return org.apache.tools.ant.BuildException | |||||
* @param errMsg Additional error message | |||||
* @param e IvjException which is wrapped | |||||
*/ | |||||
public static BuildException createBuildException( | |||||
String errMsg, | |||||
IvjException e) { | |||||
errMsg = errMsg + "\n" + e.getMessage(); | |||||
String[] errors = e.getErrors(); | |||||
if (errors != null) { | |||||
for (int i = 0; i < errors.length; i++) { | |||||
errMsg = errMsg + "\n" + errors[i]; | |||||
} | |||||
} | |||||
return new BuildException(errMsg); | |||||
} | |||||
/** | |||||
* Insert the method's description here. | |||||
* Creation date: (19.09.2000 13:41:21) | |||||
* @return com.ibm.ivj.util.base.Workspace | |||||
*/ | |||||
public static Workspace getWorkspace() { | |||||
if (workspace == null) { | |||||
workspace = ToolEnv.connectToWorkspace(); | |||||
if (workspace == null) { | |||||
throw new BuildException( | |||||
"Unable to connect to Workspace! " | |||||
+ "Make sure you are running in VisualAge for Java."); | |||||
} | |||||
} | |||||
return workspace; | |||||
} | |||||
} | |||||
return workspace; | |||||
} | |||||
} |
@@ -1,5 +1,3 @@ | |||||
package org.apache.tools.ant.taskdefs.optional.ide; | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
@@ -53,15 +51,16 @@ package org.apache.tools.ant.taskdefs.optional.ide; | |||||
* information on the Apache Software Foundation, please see | * information on the Apache Software Foundation, please see | ||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs.optional.ide; | |||||
import org.apache.tools.ant.DirectoryScanner; | |||||
import com.ibm.ivj.util.base.IvjException; | import com.ibm.ivj.util.base.IvjException; | ||||
import com.ibm.ivj.util.base.Package; | import com.ibm.ivj.util.base.Package; | ||||
import com.ibm.ivj.util.base.Project; | import com.ibm.ivj.util.base.Project; | ||||
import java.io.File; | |||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
import java.util.Vector; | |||||
import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
import java.io.File; | |||||
import java.util.Vector; | |||||
import org.apache.tools.ant.DirectoryScanner; | |||||
/** | /** | ||||
* Class for scanning a Visual Age for Java workspace for packages matching | * Class for scanning a Visual Age for Java workspace for packages matching | ||||
@@ -88,162 +87,160 @@ import java.io.File; | |||||
*/ | */ | ||||
public class VAJWorkspaceScanner extends DirectoryScanner { | public class VAJWorkspaceScanner extends DirectoryScanner { | ||||
/** | |||||
* Patterns that should be excluded by default. | |||||
* | |||||
* @see #addDefaultExcludes() | |||||
*/ | |||||
private final static String[] DEFAULTEXCLUDES = | |||||
{ | |||||
"IBM*/**", | |||||
"Java class libraries/**", | |||||
"Sun class libraries*/**", | |||||
"JSP Page Compile Generated Code/**", | |||||
"VisualAge*/**", | |||||
}; | |||||
/** | |||||
* Patterns that should be excluded by default. | |||||
* | |||||
* @see #addDefaultExcludes() | |||||
*/ | |||||
private final static String[] DEFAULTEXCLUDES = | |||||
{ | |||||
"IBM*/**", | |||||
"Java class libraries/**", | |||||
"Sun class libraries*/**", | |||||
"JSP Page Compile Generated Code/**", | |||||
"VisualAge*/**", | |||||
}; | |||||
/** | |||||
* The packages that where found and matched at least one includes, and | |||||
* matched no excludes. | |||||
*/ | |||||
private Vector packagesIncluded = new Vector(); | |||||
/** | |||||
* The packages that where found and matched at least one includes, and | |||||
* matched no excludes. | |||||
*/ | |||||
private Vector packagesIncluded = new Vector(); | |||||
/** | |||||
* Adds the array with default exclusions to the current exclusions set. | |||||
*/ | |||||
public void addDefaultExcludes() { | |||||
int excludesLength = excludes == null ? 0 : excludes.length; | |||||
String[] newExcludes; | |||||
newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length]; | |||||
if (excludesLength > 0) { | |||||
System.arraycopy(excludes, 0, newExcludes, 0, excludesLength); | |||||
} | |||||
for (int i = 0; i < DEFAULTEXCLUDES.length; i++) { | |||||
newExcludes[i + excludesLength] = | |||||
DEFAULTEXCLUDES[i].replace('/', File.separatorChar).replace( | |||||
'\\', | |||||
File.separatorChar); | |||||
} | |||||
excludes = newExcludes; | |||||
} | |||||
/** | |||||
* Finds all Projects specified in include patterns. | |||||
* | |||||
* @return the projects | |||||
*/ | |||||
public Vector findMatchingProjects() { | |||||
Project[] projects = VAJUtil.getWorkspace().getProjects(); | |||||
/** | |||||
* Adds the array with default exclusions to the current exclusions set. | |||||
*/ | |||||
public void addDefaultExcludes() { | |||||
int excludesLength = excludes == null ? 0 : excludes.length; | |||||
String[] newExcludes; | |||||
newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length]; | |||||
if (excludesLength > 0) { | |||||
System.arraycopy(excludes, 0, newExcludes, 0, excludesLength); | |||||
} | |||||
for (int i = 0; i < DEFAULTEXCLUDES.length; i++) { | |||||
newExcludes[i + excludesLength] = DEFAULTEXCLUDES[i]. | |||||
replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ); | |||||
} | |||||
excludes = newExcludes; | |||||
} | |||||
/** | |||||
* Finds all Projects specified in include patterns. | |||||
* | |||||
* @return the projects | |||||
*/ | |||||
public Vector findMatchingProjects() { | |||||
Project[] projects = VAJUtil.getWorkspace().getProjects(); | |||||
Vector matchingProjects = new Vector(); | |||||
Vector matchingProjects = new Vector(); | |||||
boolean allProjectsMatch = false; | |||||
for (int i = 0; i < projects.length; i++) { | |||||
Project project = projects[i]; | |||||
for (int j = 0; j < includes.length && !allProjectsMatch; j++) { | |||||
StringTokenizer tok = new StringTokenizer(includes[j], File.separator); | |||||
String projectNamePattern = tok.nextToken(); | |||||
if (projectNamePattern.equals("**")) { | |||||
// if an include pattern starts with '**', | |||||
// all projects match | |||||
allProjectsMatch = true; | |||||
} else | |||||
if (match(projectNamePattern, project.getName())) { | |||||
matchingProjects.addElement(project); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
boolean allProjectsMatch = false; | |||||
for (int i = 0; i < projects.length; i++) { | |||||
Project project = projects[i]; | |||||
for (int j = 0; j < includes.length && !allProjectsMatch; j++) { | |||||
StringTokenizer tok = new StringTokenizer(includes[j], File.separator); | |||||
String projectNamePattern = tok.nextToken(); | |||||
if (projectNamePattern.equals("**")) { | |||||
// if an include pattern starts with '**', | |||||
// all projects match | |||||
allProjectsMatch = true; | |||||
} else | |||||
if (match(projectNamePattern, project.getName())) { | |||||
matchingProjects.addElement(project); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
if (allProjectsMatch) { | |||||
matchingProjects = new Vector(); | |||||
for (int i = 0; i < projects.length; i++) { | |||||
matchingProjects.addElement(projects[i]); | |||||
} | |||||
} | |||||
if (allProjectsMatch) { | |||||
matchingProjects = new Vector(); | |||||
for (int i = 0; i < projects.length; i++) { | |||||
matchingProjects.addElement(projects[i]); | |||||
} | |||||
} | |||||
return matchingProjects; | |||||
} | |||||
/** | |||||
* Get the names of the packages that matched at least one of the include | |||||
* patterns, and didn't match one of the exclude patterns. | |||||
* | |||||
* @return the matching packages | |||||
*/ | |||||
public Package[] getIncludedPackages() { | |||||
int count = packagesIncluded.size(); | |||||
Package[] packages = new Package[count]; | |||||
for (int i = 0; i < count; i++) { | |||||
packages[i] = (Package) packagesIncluded.elementAt(i); | |||||
} | |||||
return packages; | |||||
} | |||||
/** | |||||
* Matches a string against a pattern. The pattern contains two special | |||||
* characters: | |||||
* '*' which means zero or more characters, | |||||
* '?' which means one and only one character. | |||||
* | |||||
* @param pattern the (non-null) pattern to match against | |||||
* @param str the (non-null) string that must be matched against the | |||||
* pattern | |||||
* | |||||
* @return <code>true</code> when the string matches against the pattern, | |||||
* <code>false</code> otherwise. | |||||
*/ | |||||
protected static boolean match(String pattern, String str) { | |||||
return DirectoryScanner.match(pattern, str); | |||||
} | |||||
/** | |||||
* Scans the workspace for packages that match at least one include | |||||
* pattern, and don't match any exclude patterns. | |||||
* | |||||
*/ | |||||
public void scan() { | |||||
if (includes == null) { | |||||
// No includes supplied, so set it to 'matches all' | |||||
includes = new String[1]; | |||||
includes[0] = "**"; | |||||
} | |||||
if (excludes == null) { | |||||
excludes = new String[0]; | |||||
} | |||||
return matchingProjects; | |||||
} | |||||
/** | |||||
* Get the names of the packages that matched at least one of the include | |||||
* patterns, and didn't match one of the exclude patterns. | |||||
* | |||||
* @return the matching packages | |||||
*/ | |||||
public Package[] getIncludedPackages() { | |||||
int count = packagesIncluded.size(); | |||||
Package[] packages = new Package[count]; | |||||
for (int i = 0; i < count; i++) { | |||||
packages[i] = (Package) packagesIncluded.elementAt(i); | |||||
} | |||||
return packages; | |||||
} | |||||
/** | |||||
* Matches a string against a pattern. The pattern contains two special | |||||
* characters: | |||||
* '*' which means zero or more characters, | |||||
* '?' which means one and only one character. | |||||
* | |||||
* @param pattern the (non-null) pattern to match against | |||||
* @param str the (non-null) string that must be matched against the | |||||
* pattern | |||||
* | |||||
* @return <code>true</code> when the string matches against the pattern, | |||||
* <code>false</code> otherwise. | |||||
*/ | |||||
protected static boolean match(String pattern, String str) { | |||||
return DirectoryScanner.match(pattern, str); | |||||
} | |||||
/** | |||||
* Scans the workspace for packages that match at least one include | |||||
* pattern, and don't match any exclude patterns. | |||||
* | |||||
*/ | |||||
public void scan() { | |||||
if (includes == null) { | |||||
// No includes supplied, so set it to 'matches all' | |||||
includes = new String[1]; | |||||
includes[0] = "**"; | |||||
} | |||||
if (excludes == null) { | |||||
excludes = new String[0]; | |||||
} | |||||
// only scan projects which are included in at least one include pattern | |||||
Vector matchingProjects = findMatchingProjects(); | |||||
for (Enumeration e = matchingProjects.elements(); e.hasMoreElements();) { | |||||
Project project = (Project) e.nextElement(); | |||||
scanProject(project); | |||||
} | |||||
} | |||||
/** | |||||
* Scans a project for packages that match at least one include | |||||
* pattern, and don't match any exclude patterns. | |||||
* | |||||
*/ | |||||
public void scanProject(Project project) { | |||||
try { | |||||
Package[] packages = project.getPackages(); | |||||
if (packages != null) { | |||||
for (int i = 0; i < packages.length; i++) { | |||||
Package item = packages[i]; | |||||
// replace '.' by file seperator because the patterns are | |||||
// using file seperator syntax (and we can use the match | |||||
// methods this way). | |||||
String name = | |||||
project.getName() | |||||
+ File.separator | |||||
+ item.getName().replace('.', File.separatorChar); | |||||
if (isIncluded(name) && !isExcluded(name)) { | |||||
packagesIncluded.addElement(item); | |||||
} | |||||
} | |||||
} | |||||
} catch (IvjException e) { | |||||
throw VAJUtil.createBuildException("VA Exception occured: ", e); | |||||
} | |||||
} | |||||
} | |||||
// only scan projects which are included in at least one include pattern | |||||
Vector matchingProjects = findMatchingProjects(); | |||||
for (Enumeration e = matchingProjects.elements(); e.hasMoreElements();) { | |||||
Project project = (Project) e.nextElement(); | |||||
scanProject(project); | |||||
} | |||||
} | |||||
/** | |||||
* Scans a project for packages that match at least one include | |||||
* pattern, and don't match any exclude patterns. | |||||
* | |||||
*/ | |||||
public void scanProject(Project project) { | |||||
try { | |||||
Package[] packages = project.getPackages(); | |||||
if (packages != null) { | |||||
for (int i = 0; i < packages.length; i++) { | |||||
Package item = packages[i]; | |||||
// replace '.' by file seperator because the patterns are | |||||
// using file seperator syntax (and we can use the match | |||||
// methods this way). | |||||
String name = | |||||
project.getName() | |||||
+ File.separator | |||||
+ item.getName().replace('.', File.separatorChar); | |||||
if (isIncluded(name) && !isExcluded(name)) { | |||||
packagesIncluded.addElement(item); | |||||
} | |||||
} | |||||
} | |||||
} catch (IvjException e) { | |||||
throw VAJUtil.createBuildException("VA Exception occured: ", e); | |||||
} | |||||
} | |||||
} |
@@ -51,7 +51,6 @@ | |||||
* information on the Apache Software Foundation, please see | * information on the Apache Software Foundation, please see | ||||
* <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs.optional.jlink; | package org.apache.tools.ant.taskdefs.optional.jlink; | ||||
import java.io .*; | import java.io .*; | ||||
@@ -65,66 +64,66 @@ import java.io .*; | |||||
*/ | */ | ||||
class ConstantPool extends Object{ | class ConstantPool extends Object{ | ||||
static final | |||||
byte UTF8 = 1, UNUSED = 2, INTEGER = 3, FLOAT = 4, LONG = 5, DOUBLE = 6, | |||||
CLASS = 7, STRING = 8, FIELDREF = 9, METHODREF = 10, | |||||
INTERFACEMETHODREF = 11, NAMEANDTYPE = 12; | |||||
static final | |||||
byte UTF8 = 1, UNUSED = 2, INTEGER = 3, FLOAT = 4, LONG = 5, DOUBLE = 6, | |||||
CLASS = 7, STRING = 8, FIELDREF = 9, METHODREF = 10, | |||||
INTERFACEMETHODREF = 11, NAMEANDTYPE = 12; | |||||
byte[] types; | |||||
byte[] types; | |||||
Object[] values; | |||||
Object[] values; | |||||
ConstantPool( DataInput data ) throws IOException { | |||||
super(); | |||||
ConstantPool( DataInput data ) throws IOException { | |||||
super(); | |||||
int count = data .readUnsignedShort(); | |||||
types = new byte [ count ]; | |||||
values = new Object [ count ]; | |||||
// read in all constant pool entries. | |||||
for ( int i = 1; i < count; i++ ) { | |||||
byte type = data .readByte(); | |||||
types[i] = type; | |||||
switch (type) | |||||
{ | |||||
case UTF8 : | |||||
values[i] = data .readUTF(); | |||||
break; | |||||
case UNUSED : | |||||
break; | |||||
case INTEGER : | |||||
values[i] = new Integer( data .readInt() ); | |||||
break; | |||||
case FLOAT : | |||||
values[i] = new Float( data .readFloat() ); | |||||
break; | |||||
case LONG : | |||||
values[i] = new Long( data .readLong() ); | |||||
++i; | |||||
break; | |||||
case DOUBLE : | |||||
values[i] = new Double( data .readDouble() ); | |||||
++i; | |||||
break; | |||||
case CLASS : | |||||
case STRING : | |||||
values[i] = new Integer( data .readUnsignedShort() ); | |||||
break; | |||||
case FIELDREF : | |||||
case METHODREF : | |||||
case INTERFACEMETHODREF : | |||||
case NAMEANDTYPE : | |||||
values[i] = new Integer( data .readInt() ); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
int count = data .readUnsignedShort(); | |||||
types = new byte [ count ]; | |||||
values = new Object [ count ]; | |||||
// read in all constant pool entries. | |||||
for ( int i = 1; i < count; i++ ) { | |||||
byte type = data .readByte(); | |||||
types[i] = type; | |||||
switch (type) | |||||
{ | |||||
case UTF8 : | |||||
values[i] = data .readUTF(); | |||||
break; | |||||
case UNUSED : | |||||
break; | |||||
case INTEGER : | |||||
values[i] = new Integer( data .readInt() ); | |||||
break; | |||||
case FLOAT : | |||||
values[i] = new Float( data .readFloat() ); | |||||
break; | |||||
case LONG : | |||||
values[i] = new Long( data .readLong() ); | |||||
++i; | |||||
break; | |||||
case DOUBLE : | |||||
values[i] = new Double( data .readDouble() ); | |||||
++i; | |||||
break; | |||||
case CLASS : | |||||
case STRING : | |||||
values[i] = new Integer( data .readUnsignedShort() ); | |||||
break; | |||||
case FIELDREF : | |||||
case METHODREF : | |||||
case INTERFACEMETHODREF : | |||||
case NAMEANDTYPE : | |||||
values[i] = new Integer( data .readInt() ); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
@@ -135,25 +134,25 @@ class ConstantPool extends Object{ | |||||
*/ | */ | ||||
public class ClassNameReader extends Object{ | public class ClassNameReader extends Object{ | ||||
public static | |||||
String getClassName( InputStream input ) throws IOException { | |||||
DataInputStream data = new DataInputStream( input ); | |||||
// verify this is a valid class file. | |||||
int cookie = data .readInt(); | |||||
if ( cookie != 0xCAFEBABE ) { | |||||
return null; | |||||
} | |||||
int version = data .readInt(); | |||||
// read the constant pool. | |||||
ConstantPool constants = new ConstantPool( data ); | |||||
Object[] values = constants .values; | |||||
// read access flags and class index. | |||||
int accessFlags = data .readUnsignedShort(); | |||||
int classIndex = data .readUnsignedShort(); | |||||
Integer stringIndex = (Integer) values[classIndex]; | |||||
String className = (String) values[stringIndex .intValue()]; | |||||
return className; | |||||
} | |||||
public static | |||||
String getClassName( InputStream input ) throws IOException { | |||||
DataInputStream data = new DataInputStream( input ); | |||||
// verify this is a valid class file. | |||||
int cookie = data .readInt(); | |||||
if ( cookie != 0xCAFEBABE ) { | |||||
return null; | |||||
} | |||||
int version = data .readInt(); | |||||
// read the constant pool. | |||||
ConstantPool constants = new ConstantPool( data ); | |||||
Object[] values = constants .values; | |||||
// read access flags and class index. | |||||
int accessFlags = data .readUnsignedShort(); | |||||
int classIndex = data .readUnsignedShort(); | |||||
Integer stringIndex = (Integer) values[classIndex]; | |||||
String className = (String) values[stringIndex .intValue()]; | |||||
return className; | |||||
} | |||||
} | } | ||||
@@ -177,7 +177,7 @@ public class JlinkTask extends MatchingTask { | |||||
throw new BuildException( ex, location ); | throw new BuildException( ex, location ); | ||||
} | } | ||||
} | } | ||||
private boolean haveAddFiles(){ | private boolean haveAddFiles(){ | ||||
return haveEntries(addfiles); | return haveEntries(addfiles); | ||||
} | } | ||||
@@ -185,7 +185,7 @@ public class JlinkTask extends MatchingTask { | |||||
private boolean haveMergeFiles(){ | private boolean haveMergeFiles(){ | ||||
return haveEntries(mergefiles); | return haveEntries(mergefiles); | ||||
} | } | ||||
private boolean haveEntries(Path p){ | private boolean haveEntries(Path p){ | ||||
if (p == null){ | if (p == null){ | ||||
return false; | return false; | ||||
@@ -65,74 +65,74 @@ | |||||
package org.apache.tools.ant.taskdefs.optional.jlink; | package org.apache.tools.ant.taskdefs.optional.jlink; | ||||
import java.io .*; | import java.io .*; | ||||
import java.util.zip .*; | |||||
import java.util .Vector; | |||||
import java.util .Enumeration; | import java.util .Enumeration; | ||||
import java.util .Vector; | |||||
import java.util.zip .*; | |||||
public class jlink extends Object{ | public class jlink extends Object{ | ||||
/** | |||||
/** | |||||
* The file that will be created by this instance of jlink. | * The file that will be created by this instance of jlink. | ||||
*/ | |||||
public void setOutfile( String outfile ) { | |||||
if ( outfile == null ) { | |||||
return ; | |||||
} | |||||
this .outfile = outfile; | |||||
} | |||||
*/ | |||||
public void setOutfile( String outfile ) { | |||||
if ( outfile == null ) { | |||||
return ; | |||||
} | |||||
this .outfile = outfile; | |||||
} | |||||
/** | |||||
/** | |||||
* Adds a file to be merged into the output. | * Adds a file to be merged into the output. | ||||
*/ | |||||
public void addMergeFile( String mergefile ) { | |||||
if ( mergefile == null ) { | |||||
return ; | |||||
} | |||||
mergefiles .addElement( mergefile ); | |||||
} | |||||
*/ | |||||
public void addMergeFile( String mergefile ) { | |||||
if ( mergefile == null ) { | |||||
return ; | |||||
} | |||||
mergefiles .addElement( mergefile ); | |||||
} | |||||
/** | |||||
/** | |||||
* Adds a file to be added into the output. | * Adds a file to be added into the output. | ||||
*/ | |||||
public void addAddFile( String addfile ) { | |||||
if ( addfile == null ) { | |||||
return ; | |||||
} | |||||
addfiles .addElement( addfile ); | |||||
} | |||||
*/ | |||||
public void addAddFile( String addfile ) { | |||||
if ( addfile == null ) { | |||||
return ; | |||||
} | |||||
addfiles .addElement( addfile ); | |||||
} | |||||
/** | |||||
/** | |||||
* Adds several files to be merged into the output. | * Adds several files to be merged into the output. | ||||
*/ | |||||
public void addMergeFiles( String[] mergefiles ) { | |||||
if ( mergefiles == null ) { | |||||
return ; | |||||
} | |||||
for ( int i = 0; i < mergefiles .length; i++ ) { | |||||
addMergeFile( mergefiles[i] ); | |||||
} | |||||
} | |||||
*/ | |||||
public void addMergeFiles( String[] mergefiles ) { | |||||
if ( mergefiles == null ) { | |||||
return ; | |||||
} | |||||
for ( int i = 0; i < mergefiles .length; i++ ) { | |||||
addMergeFile( mergefiles[i] ); | |||||
} | |||||
} | |||||
/** | |||||
/** | |||||
* Adds several file to be added into the output. | * Adds several file to be added into the output. | ||||
*/ | |||||
public void addAddFiles( String[] addfiles ) { | |||||
if ( addfiles == null ) { | |||||
return ; | |||||
} | |||||
for ( int i = 0; i < addfiles .length; i++ ) { | |||||
addAddFile( addfiles[i] ); | |||||
} | |||||
} | |||||
*/ | |||||
public void addAddFiles( String[] addfiles ) { | |||||
if ( addfiles == null ) { | |||||
return ; | |||||
} | |||||
for ( int i = 0; i < addfiles .length; i++ ) { | |||||
addAddFile( addfiles[i] ); | |||||
} | |||||
} | |||||
/** | |||||
/** | |||||
* Determines whether output will be compressed. | * Determines whether output will be compressed. | ||||
*/ | |||||
public void setCompression( boolean compress ) { | |||||
this .compression = compress; | |||||
} | |||||
*/ | |||||
public void setCompression( boolean compress ) { | |||||
this .compression = compress; | |||||
} | |||||
/** | |||||
/** | |||||
* Performs the linking of files. | * Performs the linking of files. | ||||
* Addfiles are added to the output as-is. For example, a | * Addfiles are added to the output as-is. For example, a | ||||
* jar file is added to the output as a jar file. | * jar file is added to the output as a jar file. | ||||
@@ -146,104 +146,105 @@ public class jlink extends Object{ | |||||
* provide multiple, disjoint directories, as | * provide multiple, disjoint directories, as | ||||
* addfiles: they will all be added in a rational | * addfiles: they will all be added in a rational | ||||
* manner to outfile. | * manner to outfile. | ||||
*/ | |||||
public void link() throws Exception { | |||||
ZipOutputStream output = new ZipOutputStream( new FileOutputStream( outfile ) ); | |||||
if ( compression ) { | |||||
output .setMethod( ZipOutputStream .DEFLATED ); | |||||
output .setLevel( Deflater .DEFAULT_COMPRESSION ); | |||||
} else { | |||||
output .setMethod( ZipOutputStream .STORED ); | |||||
} | |||||
Enumeration merges = mergefiles .elements(); | |||||
while ( merges .hasMoreElements() ) { | |||||
String path = (String) merges .nextElement(); | |||||
File f = new File( path ); | |||||
if ( f.getName().endsWith( ".jar" ) || f.getName().endsWith( ".zip" ) ) { | |||||
//Do the merge | |||||
mergeZipJarContents( output, f ); | |||||
} | |||||
else { | |||||
//Add this file to the addfiles Vector and add it later at the top level of the output file. | |||||
addAddFile( path ); | |||||
} | |||||
} | |||||
Enumeration adds = addfiles .elements(); | |||||
while ( adds .hasMoreElements() ) { | |||||
String name = (String) adds .nextElement(); | |||||
File f = new File( name ); | |||||
if ( f .isDirectory() ) { | |||||
//System.out.println("in jlink: adding directory contents of " + f.getPath()); | |||||
addDirContents( output, f, f.getName() + '/', compression ); | |||||
} | |||||
else { | |||||
addFile( output, f, "", compression ); | |||||
} | |||||
} | |||||
if ( output != null ) { | |||||
try { | |||||
output .close(); | |||||
} catch( IOException ioe ) {} | |||||
} | |||||
} | |||||
*/ | |||||
public void link() throws Exception { | |||||
ZipOutputStream output = new ZipOutputStream( new FileOutputStream( outfile ) ); | |||||
if ( compression ) { | |||||
output .setMethod( ZipOutputStream .DEFLATED ); | |||||
output .setLevel( Deflater .DEFAULT_COMPRESSION ); | |||||
} else { | |||||
output .setMethod( ZipOutputStream .STORED ); | |||||
} | |||||
Enumeration merges = mergefiles .elements(); | |||||
while ( merges .hasMoreElements() ) { | |||||
String path = (String) merges .nextElement(); | |||||
File f = new File( path ); | |||||
if ( f.getName().endsWith( ".jar" ) || f.getName().endsWith( ".zip" ) ) { | |||||
//Do the merge | |||||
mergeZipJarContents( output, f ); | |||||
} | |||||
else { | |||||
//Add this file to the addfiles Vector and add it | |||||
//later at the top level of the output file. | |||||
addAddFile( path ); | |||||
} | |||||
} | |||||
Enumeration adds = addfiles .elements(); | |||||
while ( adds .hasMoreElements() ) { | |||||
String name = (String) adds .nextElement(); | |||||
File f = new File( name ); | |||||
if ( f .isDirectory() ) { | |||||
//System.out.println("in jlink: adding directory contents of " + f.getPath()); | |||||
addDirContents( output, f, f.getName() + '/', compression ); | |||||
} | |||||
else { | |||||
addFile( output, f, "", compression ); | |||||
} | |||||
} | |||||
if ( output != null ) { | |||||
try { | |||||
output .close(); | |||||
} catch( IOException ioe ) {} | |||||
} | |||||
} | |||||
public static void main( String[] args ) { | |||||
// jlink output input1 ... inputN | |||||
if ( args .length < 2 ) { | |||||
System .out .println( "usage: jlink output input1 ... inputN" ); | |||||
System .exit( 1 ); | |||||
} | |||||
jlink linker = new jlink(); | |||||
linker .setOutfile( args[0] ); | |||||
//To maintain compatibility with the command-line version, we will only add files to be merged. | |||||
for ( int i = 1; i < args .length; i++ ) { | |||||
linker .addMergeFile( args[i] ); | |||||
} | |||||
try { | |||||
linker .link(); | |||||
} catch( Exception ex ) { | |||||
System .err .print( ex .getMessage() ); | |||||
} | |||||
} | |||||
public static void main( String[] args ) { | |||||
// jlink output input1 ... inputN | |||||
if ( args .length < 2 ) { | |||||
System .out .println( "usage: jlink output input1 ... inputN" ); | |||||
System .exit( 1 ); | |||||
} | |||||
jlink linker = new jlink(); | |||||
linker .setOutfile( args[0] ); | |||||
//To maintain compatibility with the command-line version, we will only add files to be merged. | |||||
for ( int i = 1; i < args .length; i++ ) { | |||||
linker .addMergeFile( args[i] ); | |||||
} | |||||
try { | |||||
linker .link(); | |||||
} catch( Exception ex ) { | |||||
System .err .print( ex .getMessage() ); | |||||
} | |||||
} | |||||
/* | /* | ||||
* Actually performs the merging of f into the output. | * Actually performs the merging of f into the output. | ||||
* f should be a zip or jar file. | * f should be a zip or jar file. | ||||
*/ | */ | ||||
private void mergeZipJarContents( ZipOutputStream output, File f ) throws IOException { | |||||
//Check to see that the file with name "name" exists. | |||||
if ( ! f .exists() ) { | |||||
return ; | |||||
} | |||||
ZipFile zipf = new ZipFile( f ); | |||||
Enumeration entries = zipf.entries(); | |||||
while (entries.hasMoreElements()){ | |||||
ZipEntry inputEntry = (ZipEntry) entries.nextElement(); | |||||
//Ignore manifest entries. They're bound to cause conflicts between | |||||
//files that are being merged. User should supply their own | |||||
//manifest file when doing the merge. | |||||
String inputEntryName = inputEntry.getName(); | |||||
int index = inputEntryName.indexOf("META-INF"); | |||||
if (index < 0){ | |||||
//META-INF not found in the name of the entry. Go ahead and process it. | |||||
try { | |||||
output.putNextEntry(processEntry(zipf, inputEntry)); | |||||
} catch (ZipException ex){ | |||||
//If we get here, it could be because we are trying to put a | |||||
//directory entry that already exists. | |||||
//For example, we're trying to write "com", but a previous | |||||
//entry from another mergefile was called "com". | |||||
//In that case, just ignore the error and go on to the | |||||
//next entry. | |||||
String mess = ex.getMessage(); | |||||
if (mess.indexOf("duplicate") >= 0){ | |||||
//It was the duplicate entry. | |||||
continue; | |||||
} else { | |||||
//I hate to admit it, but we don't know what happened here. Throw the Exception. | |||||
throw ex; | |||||
} | |||||
} | |||||
private void mergeZipJarContents( ZipOutputStream output, File f ) throws IOException { | |||||
//Check to see that the file with name "name" exists. | |||||
if ( ! f .exists() ) { | |||||
return ; | |||||
} | |||||
ZipFile zipf = new ZipFile( f ); | |||||
Enumeration entries = zipf.entries(); | |||||
while (entries.hasMoreElements()){ | |||||
ZipEntry inputEntry = (ZipEntry) entries.nextElement(); | |||||
//Ignore manifest entries. They're bound to cause conflicts between | |||||
//files that are being merged. User should supply their own | |||||
//manifest file when doing the merge. | |||||
String inputEntryName = inputEntry.getName(); | |||||
int index = inputEntryName.indexOf("META-INF"); | |||||
if (index < 0){ | |||||
//META-INF not found in the name of the entry. Go ahead and process it. | |||||
try { | |||||
output.putNextEntry(processEntry(zipf, inputEntry)); | |||||
} catch (ZipException ex){ | |||||
//If we get here, it could be because we are trying to put a | |||||
//directory entry that already exists. | |||||
//For example, we're trying to write "com", but a previous | |||||
//entry from another mergefile was called "com". | |||||
//In that case, just ignore the error and go on to the | |||||
//next entry. | |||||
String mess = ex.getMessage(); | |||||
if (mess.indexOf("duplicate") >= 0){ | |||||
//It was the duplicate entry. | |||||
continue; | |||||
} else { | |||||
//I hate to admit it, but we don't know what happened here. Throw the Exception. | |||||
throw ex; | |||||
} | |||||
} | |||||
InputStream in = zipf.getInputStream(inputEntry); | InputStream in = zipf.getInputStream(inputEntry); | ||||
int len = buffer.length; | int len = buffer.length; | ||||
int count = -1; | int count = -1; | ||||
@@ -252,168 +253,168 @@ public class jlink extends Object{ | |||||
} | } | ||||
in.close(); | in.close(); | ||||
output.closeEntry(); | output.closeEntry(); | ||||
} | |||||
} | |||||
zipf .close(); | |||||
} | |||||
} | |||||
} | |||||
zipf .close(); | |||||
} | |||||
/* | /* | ||||
* Adds contents of a directory to the output. | * Adds contents of a directory to the output. | ||||
*/ | */ | ||||
private void addDirContents( ZipOutputStream output, File dir, String prefix, boolean compress ) throws IOException { | |||||
String[] contents = dir .list(); | |||||
for ( int i = 0; i < contents .length; ++i ) { | |||||
String name = contents[i]; | |||||
File file = new File( dir, name ); | |||||
if ( file .isDirectory() ) { | |||||
addDirContents( output, file, prefix + name + '/', compress ); | |||||
} | |||||
else { | |||||
addFile( output, file, prefix, compress ); | |||||
} | |||||
} | |||||
} | |||||
private void addDirContents( ZipOutputStream output, File dir, String prefix, boolean compress ) throws IOException { | |||||
String[] contents = dir .list(); | |||||
for ( int i = 0; i < contents .length; ++i ) { | |||||
String name = contents[i]; | |||||
File file = new File( dir, name ); | |||||
if ( file .isDirectory() ) { | |||||
addDirContents( output, file, prefix + name + '/', compress ); | |||||
} | |||||
else { | |||||
addFile( output, file, prefix, compress ); | |||||
} | |||||
} | |||||
} | |||||
/* | /* | ||||
* Gets the name of an entry in the file. This is the real name | * Gets the name of an entry in the file. This is the real name | ||||
* which for a class is the name of the package with the class | * which for a class is the name of the package with the class | ||||
* name appended. | * name appended. | ||||
*/ | */ | ||||
private String getEntryName( File file, String prefix ) { | |||||
String name = file .getName(); | |||||
if ( ! name .endsWith( ".class" ) ) { | |||||
// see if the file is in fact a .class file, and determine its actual name. | |||||
try { | |||||
InputStream input = new FileInputStream( file ); | |||||
String className = ClassNameReader .getClassName( input ); | |||||
input .close(); | |||||
if ( className != null ) { | |||||
return className .replace( '.', '/' ) + ".class"; | |||||
} | |||||
} catch( IOException ioe ) {} | |||||
} | |||||
System.out.println("From " + file.getPath() + " and prefix " + prefix + ", creating entry " + prefix+name); | |||||
return (prefix + name); | |||||
} | |||||
private String getEntryName( File file, String prefix ) { | |||||
String name = file .getName(); | |||||
if ( ! name .endsWith( ".class" ) ) { | |||||
// see if the file is in fact a .class file, and determine its actual name. | |||||
try { | |||||
InputStream input = new FileInputStream( file ); | |||||
String className = ClassNameReader .getClassName( input ); | |||||
input .close(); | |||||
if ( className != null ) { | |||||
return className .replace( '.', '/' ) + ".class"; | |||||
} | |||||
} catch( IOException ioe ) {} | |||||
} | |||||
System.out.println("From " + file.getPath() + " and prefix " + prefix + ", creating entry " + prefix+name); | |||||
return (prefix + name); | |||||
} | |||||
/* | /* | ||||
* Adds a file to the output stream. | * Adds a file to the output stream. | ||||
*/ | */ | ||||
private void addFile( ZipOutputStream output, File file, String prefix, boolean compress) throws IOException { | |||||
//Make sure file exists | |||||
long checksum = 0; | |||||
if ( ! file .exists() ) { | |||||
return ; | |||||
} | |||||
ZipEntry entry = new ZipEntry( getEntryName( file, prefix ) ); | |||||
entry .setTime( file .lastModified() ); | |||||
entry .setSize( file .length() ); | |||||
private void addFile( ZipOutputStream output, File file, String prefix, boolean compress) throws IOException { | |||||
//Make sure file exists | |||||
long checksum = 0; | |||||
if ( ! file .exists() ) { | |||||
return ; | |||||
} | |||||
ZipEntry entry = new ZipEntry( getEntryName( file, prefix ) ); | |||||
entry .setTime( file .lastModified() ); | |||||
entry .setSize( file .length() ); | |||||
if (! compress){ | if (! compress){ | ||||
entry.setCrc(calcChecksum(file)); | |||||
entry.setCrc(calcChecksum(file)); | |||||
} | } | ||||
FileInputStream input = new FileInputStream( file ); | |||||
addToOutputStream(output, input, entry); | |||||
} | |||||
FileInputStream input = new FileInputStream( file ); | |||||
addToOutputStream(output, input, entry); | |||||
} | |||||
/* | /* | ||||
* A convenience method that several other methods might call. | * A convenience method that several other methods might call. | ||||
*/ | */ | ||||
private void addToOutputStream(ZipOutputStream output, InputStream input, ZipEntry ze) throws IOException{ | |||||
try { | |||||
output.putNextEntry(ze); | |||||
} catch (ZipException zipEx) { | |||||
//This entry already exists. So, go with the first one. | |||||
input.close(); | |||||
return; | |||||
} | |||||
int numBytes = -1; | |||||
while((numBytes = input.read(buffer)) > 0){ | |||||
output.write(buffer, 0, numBytes); | |||||
} | |||||
output.closeEntry(); | |||||
input.close(); | |||||
} | |||||
private void addToOutputStream(ZipOutputStream output, InputStream input, ZipEntry ze) throws IOException{ | |||||
try { | |||||
output.putNextEntry(ze); | |||||
} catch (ZipException zipEx) { | |||||
//This entry already exists. So, go with the first one. | |||||
input.close(); | |||||
return; | |||||
} | |||||
int numBytes = -1; | |||||
while((numBytes = input.read(buffer)) > 0){ | |||||
output.write(buffer, 0, numBytes); | |||||
} | |||||
output.closeEntry(); | |||||
input.close(); | |||||
} | |||||
/* | /* | ||||
* A method that does the work on a given entry in a mergefile. | * A method that does the work on a given entry in a mergefile. | ||||
* The big deal is to set the right parameters in the ZipEntry | * The big deal is to set the right parameters in the ZipEntry | ||||
* on the output stream. | * on the output stream. | ||||
*/ | */ | ||||
private ZipEntry processEntry( ZipFile zip, ZipEntry inputEntry ) throws IOException{ | |||||
/* | |||||
First, some notes. | |||||
On MRJ 2.2.2, getting the size, compressed size, and CRC32 from the | |||||
ZipInputStream does not work for compressed (deflated) files. Those calls return -1. | |||||
For uncompressed (stored) files, those calls do work. | |||||
However, using ZipFile.getEntries() works for both compressed and | |||||
uncompressed files. | |||||
Now, from some simple testing I did, it seems that the value of CRC-32 is | |||||
independent of the compression setting. So, it should be easy to pass this | |||||
information on to the output entry. | |||||
*/ | |||||
String name = inputEntry .getName(); | |||||
if ( ! (inputEntry .isDirectory() || name .endsWith( ".class" )) ) { | |||||
try { | |||||
InputStream input = zip.getInputStream( zip .getEntry( name ) ); | |||||
String className = ClassNameReader .getClassName( input ); | |||||
input .close(); | |||||
if ( className != null ) { | |||||
name = className .replace( '.', '/' ) + ".class"; | |||||
} | |||||
} catch( IOException ioe ) {} | |||||
} | |||||
ZipEntry outputEntry = new ZipEntry( name ); | |||||
outputEntry.setTime(inputEntry .getTime() ); | |||||
outputEntry.setExtra(inputEntry.getExtra()); | |||||
outputEntry.setComment(inputEntry.getComment()); | |||||
private ZipEntry processEntry( ZipFile zip, ZipEntry inputEntry ) throws IOException{ | |||||
/* | |||||
First, some notes. | |||||
On MRJ 2.2.2, getting the size, compressed size, and CRC32 from the | |||||
ZipInputStream does not work for compressed (deflated) files. Those calls return -1. | |||||
For uncompressed (stored) files, those calls do work. | |||||
However, using ZipFile.getEntries() works for both compressed and | |||||
uncompressed files. | |||||
Now, from some simple testing I did, it seems that the value of CRC-32 is | |||||
independent of the compression setting. So, it should be easy to pass this | |||||
information on to the output entry. | |||||
*/ | |||||
String name = inputEntry .getName(); | |||||
if ( ! (inputEntry .isDirectory() || name .endsWith( ".class" )) ) { | |||||
try { | |||||
InputStream input = zip.getInputStream( zip .getEntry( name ) ); | |||||
String className = ClassNameReader .getClassName( input ); | |||||
input .close(); | |||||
if ( className != null ) { | |||||
name = className .replace( '.', '/' ) + ".class"; | |||||
} | |||||
} catch( IOException ioe ) {} | |||||
} | |||||
ZipEntry outputEntry = new ZipEntry( name ); | |||||
outputEntry.setTime(inputEntry .getTime() ); | |||||
outputEntry.setExtra(inputEntry.getExtra()); | |||||
outputEntry.setComment(inputEntry.getComment()); | |||||
outputEntry.setTime(inputEntry.getTime()); | outputEntry.setTime(inputEntry.getTime()); | ||||
if (compression){ | |||||
outputEntry.setMethod(ZipEntry.DEFLATED); | |||||
if (compression){ | |||||
outputEntry.setMethod(ZipEntry.DEFLATED); | |||||
//Note, don't need to specify size or crc for compressed files. | //Note, don't need to specify size or crc for compressed files. | ||||
} else { | |||||
outputEntry.setMethod(ZipEntry.STORED); | |||||
} else { | |||||
outputEntry.setMethod(ZipEntry.STORED); | |||||
outputEntry.setCrc(inputEntry.getCrc()); | outputEntry.setCrc(inputEntry.getCrc()); | ||||
outputEntry.setSize(inputEntry.getSize()); | |||||
} | |||||
return outputEntry; | |||||
} | |||||
outputEntry.setSize(inputEntry.getSize()); | |||||
} | |||||
return outputEntry; | |||||
} | |||||
/* | /* | ||||
* Necessary in the case where you add a entry that | * Necessary in the case where you add a entry that | ||||
* is not compressed. | * is not compressed. | ||||
*/ | */ | ||||
private long calcChecksum(File f) throws IOException { | |||||
BufferedInputStream in = new BufferedInputStream(new FileInputStream(f)); | |||||
return calcChecksum(in, f.length()); | |||||
} | |||||
private long calcChecksum(File f) throws IOException { | |||||
BufferedInputStream in = new BufferedInputStream(new FileInputStream(f)); | |||||
return calcChecksum(in, f.length()); | |||||
} | |||||
/* | /* | ||||
* Necessary in the case where you add a entry that | * Necessary in the case where you add a entry that | ||||
* is not compressed. | * is not compressed. | ||||
*/ | */ | ||||
private long calcChecksum(InputStream in, long size) throws IOException{ | |||||
CRC32 crc = new CRC32(); | |||||
int len = buffer.length; | |||||
int count = -1; | |||||
int haveRead = 0; | |||||
private long calcChecksum(InputStream in, long size) throws IOException{ | |||||
CRC32 crc = new CRC32(); | |||||
int len = buffer.length; | |||||
int count = -1; | |||||
int haveRead = 0; | |||||
while((count=in.read(buffer, 0, len)) > 0){ | while((count=in.read(buffer, 0, len)) > 0){ | ||||
haveRead += count; | haveRead += count; | ||||
crc.update(buffer, 0, count); | crc.update(buffer, 0, count); | ||||
} | } | ||||
in.close(); | in.close(); | ||||
return crc.getValue(); | return crc.getValue(); | ||||
} | |||||
} | |||||
private String outfile = null; | |||||
private String outfile = null; | |||||
private Vector mergefiles = new Vector( 10 ); | |||||
private Vector mergefiles = new Vector( 10 ); | |||||
private Vector addfiles = new Vector( 10 ); | |||||
private Vector addfiles = new Vector( 10 ); | |||||
private boolean compression = false; | |||||
byte[] buffer = new byte[8192]; | |||||
private boolean compression = false; | |||||
byte[] buffer = new byte[8192]; | |||||
} | } | ||||
@@ -137,11 +137,11 @@ public class JUnitTask extends Task { | |||||
} | } | ||||
public void setJvm(String value) { | public void setJvm(String value) { | ||||
commandline.setVm(value); | |||||
commandline.setVm(value); | |||||
} | } | ||||
public Commandline.Argument createJvmarg() { | public Commandline.Argument createJvmarg() { | ||||
return commandline.createVmArgument(); | |||||
return commandline.createVmArgument(); | |||||
} | } | ||||
public Path createClasspath() { | public Path createClasspath() { | ||||
@@ -54,12 +54,12 @@ | |||||
package org.apache.tools.ant.taskdefs.optional.net; | package org.apache.tools.ant.taskdefs.optional.net; | ||||
import org.apache.tools.ant.*; | |||||
import org.apache.tools.ant.types.*; | |||||
import com.oroinc.net.ftp.*; | |||||
import java.io.*; | import java.io.*; | ||||
import java.net.*; | import java.net.*; | ||||
import java.util.*; | import java.util.*; | ||||
import com.oroinc.net.ftp.*; | |||||
import org.apache.tools.ant.*; | |||||
import org.apache.tools.ant.types.*; | |||||
/** | /** | ||||
* Basic FTP client that performs the following actions: | * Basic FTP client that performs the following actions: | ||||
@@ -79,7 +79,7 @@ public class FTP | |||||
{ | { | ||||
protected final static int SEND_FILES = 0; | protected final static int SEND_FILES = 0; | ||||
protected final static int GET_FILES = 1; | protected final static int GET_FILES = 1; | ||||
protected final static int DEL_FILES = 2; | |||||
protected final static int DEL_FILES = 2; | |||||
protected final static int LIST_FILES = 3; | protected final static int LIST_FILES = 3; | ||||
private String remotedir; | private String remotedir; | ||||
@@ -110,11 +110,11 @@ public class FTP | |||||
"retrieved", | "retrieved", | ||||
"deleted", | "deleted", | ||||
"listed" | "listed" | ||||
}; | |||||
}; | |||||
protected class FTPDirectoryScanner extends DirectoryScanner { | protected class FTPDirectoryScanner extends DirectoryScanner { | ||||
protected FTPClient ftp = null; | protected FTPClient ftp = null; | ||||
public FTPDirectoryScanner(FTPClient ftp) { | public FTPDirectoryScanner(FTPClient ftp) { | ||||
super(); | super(); | ||||
this.ftp = ftp; | this.ftp = ftp; | ||||
@@ -197,7 +197,7 @@ public class FTP | |||||
throw new BuildException("Error while communicating with FTP server: ", e); | throw new BuildException("Error while communicating with FTP server: ", e); | ||||
} | } | ||||
} | } | ||||
} | |||||
} | |||||
/** | /** | ||||
* Sets the remote directory where files will be placed. This may | * Sets the remote directory where files will be placed. This may | ||||
@@ -343,7 +343,7 @@ public class FTP | |||||
*/ | */ | ||||
public void setListing(File listing) throws BuildException { | public void setListing(File listing) throws BuildException { | ||||
this.listing = listing; | this.listing = listing; | ||||
} | |||||
} | |||||
/** | /** | ||||
@@ -385,8 +385,8 @@ public class FTP | |||||
ds = new FTPDirectoryScanner(ftp); | ds = new FTPDirectoryScanner(ftp); | ||||
fs.setupDirectoryScanner(ds, project); | fs.setupDirectoryScanner(ds, project); | ||||
ds.scan(); | ds.scan(); | ||||
} | |||||
} | |||||
String[] dsfiles = ds.getIncludedFiles(); | String[] dsfiles = ds.getIncludedFiles(); | ||||
String dir = null; | String dir = null; | ||||
if ((ds.getBasedir() == null) && ((action == SEND_FILES) || (action == GET_FILES))) { | if ((ds.getBasedir() == null) && ((action == SEND_FILES) || (action == GET_FILES))) { | ||||
@@ -410,29 +410,29 @@ public class FTP | |||||
for (int i = 0; i < dsfiles.length; i++) | for (int i = 0; i < dsfiles.length; i++) | ||||
{ | { | ||||
switch (action) { | switch (action) { | ||||
case SEND_FILES: { | |||||
sendFile(ftp, dir, dsfiles[i]); | |||||
break; | |||||
} | |||||
case SEND_FILES: { | |||||
sendFile(ftp, dir, dsfiles[i]); | |||||
break; | |||||
} | |||||
case GET_FILES: { | |||||
getFile(ftp, dir, dsfiles[i]); | |||||
break; | |||||
} | |||||
case GET_FILES: { | |||||
getFile(ftp, dir, dsfiles[i]); | |||||
break; | |||||
} | |||||
case DEL_FILES: { | |||||
delFile(ftp, dsfiles[i]); | |||||
break; | |||||
} | |||||
case DEL_FILES: { | |||||
delFile(ftp, dsfiles[i]); | |||||
break; | |||||
} | |||||
case LIST_FILES: { | |||||
listFile(ftp, bw, dsfiles[i]); | |||||
break; | |||||
} | |||||
case LIST_FILES: { | |||||
listFile(ftp, bw, dsfiles[i]); | |||||
break; | |||||
} | |||||
default: { | |||||
throw new BuildException("unknown ftp action " + action ); | |||||
} | |||||
default: { | |||||
throw new BuildException("unknown ftp action " + action ); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -516,8 +516,8 @@ public class FTP | |||||
(ftp.getReplyCode() != 550)) | (ftp.getReplyCode() != 550)) | ||||
{ | { | ||||
throw new BuildException( | throw new BuildException( | ||||
"could not create directory: " + | |||||
ftp.getReplyString()); | |||||
"could not create directory: " + | |||||
ftp.getReplyString()); | |||||
} | } | ||||
dirCache.addElement(dir); | dirCache.addElement(dir); | ||||
} | } | ||||
@@ -537,8 +537,8 @@ public class FTP | |||||
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | ||||
{ | { | ||||
throw new BuildException( | throw new BuildException( | ||||
"could not date test remote file: " + | |||||
ftp.getReplyString()); | |||||
"could not date test remote file: " + | |||||
ftp.getReplyString()); | |||||
} | } | ||||
if (files == null) | if (files == null) | ||||
@@ -590,8 +590,8 @@ public class FTP | |||||
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | ||||
{ | { | ||||
throw new BuildException( | throw new BuildException( | ||||
"could not transfer file: " + | |||||
ftp.getReplyString()); | |||||
"could not transfer file: " + | |||||
ftp.getReplyString()); | |||||
} | } | ||||
log("File " + file.getAbsolutePath() + " copied to " + server, | log("File " + file.getAbsolutePath() + " copied to " + server, | ||||
@@ -619,7 +619,7 @@ public class FTP | |||||
* Delete a file from the remote host. | * Delete a file from the remote host. | ||||
*/ | */ | ||||
protected void delFile(FTPClient ftp, String filename) | protected void delFile(FTPClient ftp, String filename) | ||||
throws IOException, BuildException { | |||||
throws IOException, BuildException { | |||||
if (verbose) { | if (verbose) { | ||||
log("deleting " + filename); | log("deleting " + filename); | ||||
} | } | ||||
@@ -657,23 +657,23 @@ public class FTP | |||||
log("transferring " + filename + " to " + file.getAbsolutePath()); | log("transferring " + filename + " to " + file.getAbsolutePath()); | ||||
} | } | ||||
File pdir = new File(file.getParent()); // stay 1.1 compatible | |||||
File pdir = new File(file.getParent()); // stay 1.1 compatible | |||||
if (!pdir.exists()) { | if (!pdir.exists()) { | ||||
pdir.mkdirs(); | pdir.mkdirs(); | ||||
} | |||||
} | |||||
outstream = new BufferedOutputStream(new FileOutputStream(file)); | outstream = new BufferedOutputStream(new FileOutputStream(file)); | ||||
ftp.retrieveFile(resolveFile(filename), outstream); | ftp.retrieveFile(resolveFile(filename), outstream); | ||||
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | ||||
{ | { | ||||
throw new BuildException( | throw new BuildException( | ||||
"could not transfer file: " + | |||||
ftp.getReplyString()); | |||||
"could not transfer file: " + | |||||
ftp.getReplyString()); | |||||
} | } | ||||
log("File " + file.getAbsolutePath() + " copied from " + server, | log("File " + file.getAbsolutePath() + " copied from " + server, | ||||
Project.MSG_VERBOSE); | |||||
Project.MSG_VERBOSE); | |||||
transferred++; | transferred++; | ||||
} | } | ||||
@@ -753,8 +753,8 @@ public class FTP | |||||
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | ||||
{ | { | ||||
throw new BuildException( | throw new BuildException( | ||||
"could not set transfer type: " + | |||||
ftp.getReplyString()); | |||||
"could not set transfer type: " + | |||||
ftp.getReplyString()); | |||||
} | } | ||||
} | } | ||||
@@ -765,8 +765,8 @@ public class FTP | |||||
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | ||||
{ | { | ||||
throw new BuildException( | throw new BuildException( | ||||
"could not enter into passive mode: " + | |||||
ftp.getReplyString()); | |||||
"could not enter into passive mode: " + | |||||
ftp.getReplyString()); | |||||
} | } | ||||
} | } | ||||
@@ -777,8 +777,8 @@ public class FTP | |||||
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) | ||||
{ | { | ||||
throw new BuildException( | throw new BuildException( | ||||
"could not change remote directory: " + | |||||
ftp.getReplyString()); | |||||
"could not change remote directory: " + | |||||
ftp.getReplyString()); | |||||
} | } | ||||
} | } | ||||
@@ -793,18 +793,18 @@ public class FTP | |||||
finally | finally | ||||
{ | { | ||||
/* | /* | ||||
if (ftp != null && ftp.isConnected()) | |||||
{ | |||||
try | |||||
{ | |||||
// this hangs - I don't know why. | |||||
ftp.disconnect(); | |||||
} | |||||
catch(IOException ex) | |||||
{ | |||||
// ignore it | |||||
} | |||||
} | |||||
if (ftp != null && ftp.isConnected()) | |||||
{ | |||||
try | |||||
{ | |||||
// this hangs - I don't know why. | |||||
ftp.disconnect(); | |||||
} | |||||
catch(IOException ex) | |||||
{ | |||||
// ignore it | |||||
} | |||||
} | |||||
*/ | */ | ||||
} | } | ||||
} | } | ||||
@@ -54,13 +54,13 @@ | |||||
package org.apache.tools.ant.taskdefs.optional.vss; | package org.apache.tools.ant.taskdefs.optional.vss; | ||||
import java.io.File; | |||||
import org.apache.tools.ant.*; | import org.apache.tools.ant.*; | ||||
import org.apache.tools.ant.taskdefs.Execute; | import org.apache.tools.ant.taskdefs.Execute; | ||||
import org.apache.tools.ant.taskdefs.LogStreamHandler; | import org.apache.tools.ant.taskdefs.LogStreamHandler; | ||||
import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
import java.io.File; | |||||
/** | /** | ||||
* A base class for creating tasks for executing commands on Visual SourceSafe. | * A base class for creating tasks for executing commands on Visual SourceSafe. | ||||
* <p> | * <p> | ||||
@@ -149,7 +149,6 @@ public abstract class MSVSS extends Task { | |||||
return m_vssPath; | return m_vssPath; | ||||
} | } | ||||
protected int run(Commandline cmd) { | protected int run(Commandline cmd) { | ||||
try { | try { | ||||
Execute exe = new Execute(new LogStreamHandler(this, | Execute exe = new Execute(new LogStreamHandler(this, | ||||
@@ -168,7 +167,7 @@ public abstract class MSVSS extends Task { | |||||
* Constant for the thing to execute | * Constant for the thing to execute | ||||
*/ | */ | ||||
private static final String SS_EXE = "ss"; | private static final String SS_EXE = "ss"; | ||||
/** */ | |||||
/** */ | |||||
public static final String PROJECT_PREFIX = "$"; | public static final String PROJECT_PREFIX = "$"; | ||||
/** | /** | ||||
@@ -188,25 +187,25 @@ public abstract class MSVSS extends Task { | |||||
*/ | */ | ||||
public static final String COMMAND_HISTORY = "History"; | public static final String COMMAND_HISTORY = "History"; | ||||
/** */ | |||||
/** */ | |||||
public static final String FLAG_LOGIN = "-Y"; | public static final String FLAG_LOGIN = "-Y"; | ||||
/** */ | |||||
/** */ | |||||
public static final String FLAG_OVERRIDE_WORKING_DIR = "-GL"; | public static final String FLAG_OVERRIDE_WORKING_DIR = "-GL"; | ||||
/** */ | |||||
/** */ | |||||
public static final String FLAG_AUTORESPONSE = "-I"; | public static final String FLAG_AUTORESPONSE = "-I"; | ||||
/** */ | |||||
/** */ | |||||
public static final String FLAG_RECURSION = "-R"; | public static final String FLAG_RECURSION = "-R"; | ||||
/** */ | |||||
/** */ | |||||
public static final String FLAG_VERSION = "-V"; | public static final String FLAG_VERSION = "-V"; | ||||
/** */ | |||||
/** */ | |||||
public static final String FLAG_VERSION_DATE = "-Vd"; | public static final String FLAG_VERSION_DATE = "-Vd"; | ||||
/** */ | |||||
/** */ | |||||
public static final String FLAG_VERSION_LABEL = "-VL"; | public static final String FLAG_VERSION_LABEL = "-VL"; | ||||
/** */ | |||||
/** */ | |||||
public static final String FLAG_WRITABLE = "-W"; | public static final String FLAG_WRITABLE = "-W"; | ||||
/** */ | |||||
/** */ | |||||
public static final String VALUE_NO = "-N"; | public static final String VALUE_NO = "-N"; | ||||
/** */ | |||||
/** */ | |||||
public static final String VALUE_YES = "-Y"; | public static final String VALUE_YES = "-Y"; | ||||
} | } | ||||
@@ -54,10 +54,10 @@ | |||||
package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.Project; | |||||
import java.util.Stack; | import java.util.Stack; | ||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.Project; | |||||
/** | /** | ||||
* Base class for those classes that can appear inside the build file | * Base class for those classes that can appear inside the build file | ||||
@@ -95,14 +95,14 @@ public abstract class DataType { | |||||
* in commenting what we are doing. | * in commenting what we are doing. | ||||
*/ | */ | ||||
public void setDescription( String desc ) { | public void setDescription( String desc ) { | ||||
description=desc; | |||||
description=desc; | |||||
} | } | ||||
/** | /** | ||||
* Return the description for the current data type. | * Return the description for the current data type. | ||||
*/ | */ | ||||
public String getDescription() { | public String getDescription() { | ||||
return description; | |||||
return description; | |||||
} | } | ||||
/** | /** | ||||
@@ -166,7 +166,8 @@ public abstract class DataType { | |||||
* only attribute if it is set. | * only attribute if it is set. | ||||
*/ | */ | ||||
protected BuildException tooManyAttributes() { | protected BuildException tooManyAttributes() { | ||||
return new BuildException("You must not specify more than one attribute when using refid"); | |||||
return new BuildException( "You must not specify more than one attribute" + | |||||
" when using refid" ); | |||||
} | } | ||||
/** | /** | ||||