git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272441 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -67,8 +67,7 @@ import org.apache.tools.ant.util.FileUtils; | |||
| * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a> | |||
| */ | |||
| public abstract class BaseFilterReader | |||
| extends FilterReader | |||
| { | |||
| extends FilterReader { | |||
| /** Have the parameters passed been interpreted? */ | |||
| private boolean initialized = false; | |||
| @@ -65,8 +65,7 @@ import org.apache.tools.ant.types.Parameterizable; | |||
| */ | |||
| public abstract class BaseParamFilterReader | |||
| extends BaseFilterReader | |||
| implements Parameterizable | |||
| { | |||
| implements Parameterizable { | |||
| /** The passed in parameter array. */ | |||
| private Parameter[] parameters; | |||
| @@ -86,8 +86,7 @@ import java.lang.reflect.Method; | |||
| */ | |||
| public final class ClassConstants | |||
| extends BaseFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| /** Data that must be read from, if not null. */ | |||
| private String queuedData = null; | |||
| @@ -74,8 +74,7 @@ import org.apache.tools.ant.Project; | |||
| */ | |||
| public final class ExpandProperties | |||
| extends BaseFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| /** Data that must be read from, if not null. */ | |||
| private String queuedData = null; | |||
| @@ -76,8 +76,7 @@ import org.apache.tools.ant.types.Parameter; | |||
| */ | |||
| public final class HeadFilter | |||
| extends BaseParamFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| /** Lines key to represent the number of lines to be returned. */ | |||
| private static final String LINES_KEY = "lines"; | |||
| @@ -84,8 +84,7 @@ import org.apache.tools.ant.types.Parameter; | |||
| */ | |||
| public final class LineContains | |||
| extends BaseParamFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| /** contains key */ | |||
| private static final String CONTAINS_KEY = "contains"; | |||
| @@ -84,8 +84,7 @@ import org.apache.tools.ant.util.regexp.Regexp; | |||
| */ | |||
| public final class LineContainsRegExp | |||
| extends BaseParamFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| /** contains key */ | |||
| private static final String REGEXP_KEY = "regexp"; | |||
| @@ -76,8 +76,7 @@ import org.apache.tools.ant.types.Parameter; | |||
| */ | |||
| public final class PrefixLines | |||
| extends BaseParamFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| /** prefix key */ | |||
| private static final String PREFIX_KEY = "prefix"; | |||
| @@ -81,8 +81,7 @@ import org.apache.tools.ant.types.Parameter; | |||
| */ | |||
| public final class ReplaceTokens | |||
| extends BaseParamFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| /** Default begin token character. */ | |||
| private static final char DEFAULT_BEGIN_TOKEN = '@'; | |||
| @@ -63,8 +63,7 @@ import java.io.StringReader; | |||
| * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a> | |||
| */ | |||
| public class StringInputStream | |||
| extends InputStream | |||
| { | |||
| extends InputStream { | |||
| /** Source string is stored as a StringReader */ | |||
| private StringReader in; | |||
| @@ -65,8 +65,7 @@ import java.io.Reader; | |||
| */ | |||
| public final class StripJavaComments | |||
| extends BaseFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| private int readAheadCh = -1; | |||
| private boolean inString = false; | |||
| @@ -72,8 +72,7 @@ import org.apache.tools.ant.types.Parameter; | |||
| */ | |||
| public final class StripLineBreaks | |||
| extends BaseParamFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| /** | |||
| * Linebreaks. What do to on funny IBM mainframes with odd line endings? | |||
| */ | |||
| @@ -87,8 +87,7 @@ import org.apache.tools.ant.types.Parameter; | |||
| */ | |||
| public final class StripLineComments | |||
| extends BaseParamFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| /** The type that param recognizes to set the comments. */ | |||
| private static final String COMMENTS_KEY = "comment"; | |||
| @@ -76,8 +76,7 @@ import org.apache.tools.ant.types.Parameter; | |||
| */ | |||
| public final class TabsToSpaces | |||
| extends BaseParamFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| /** The default tab length is 8 */ | |||
| private static final int DEFAULT_TAB_LENGTH = 8; | |||
| @@ -76,8 +76,7 @@ import org.apache.tools.ant.types.Parameter; | |||
| */ | |||
| public final class TailFilter | |||
| extends BaseParamFilterReader | |||
| implements ChainableReader | |||
| { | |||
| implements ChainableReader { | |||
| /** The name that param recognizes to set the number of lines. */ | |||
| private static final String LINES_KEY = "lines"; | |||
| @@ -330,36 +330,29 @@ public abstract class AbstractCvsTask extends Task { | |||
| + "Command line was [" | |||
| + actualCommandLine + "]", location); | |||
| } | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| if (failOnError) { | |||
| throw new BuildException(e, location); | |||
| } | |||
| else { | |||
| } else { | |||
| log("Caught exception: " + e.getMessage(), Project.MSG_WARN); | |||
| } | |||
| } | |||
| catch (BuildException e) { | |||
| } catch (BuildException e) { | |||
| if (failOnError) { | |||
| throw(e); | |||
| } | |||
| else { | |||
| } else { | |||
| Throwable t = e.getException(); | |||
| if (t == null) { | |||
| t = e; | |||
| } | |||
| log("Caught exception: " + t.getMessage(), Project.MSG_WARN); | |||
| } | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| if (failOnError) { | |||
| throw new BuildException(e, location); | |||
| } | |||
| else { | |||
| } else { | |||
| log("Caught exception: " + e.getMessage(), Project.MSG_WARN); | |||
| } | |||
| } | |||
| finally { | |||
| } finally { | |||
| // | |||
| // condition used to be if(output == null) outputStream.close(). This is | |||
| // not appropriate. Check if the stream itself is not null, then close(). | |||
| @@ -607,8 +600,7 @@ public abstract class AbstractCvsTask extends Task { | |||
| this.configureCommandline(c); | |||
| if (insertAtStart) { | |||
| vecCommandlines.insertElementAt(c, 0); | |||
| } | |||
| else { | |||
| } else { | |||
| vecCommandlines.addElement(c); | |||
| } | |||
| } | |||
| @@ -216,8 +216,7 @@ public class Ant extends Task { | |||
| logger.setOutputPrintStream(out); | |||
| logger.setErrorPrintStream(out); | |||
| newProject.addBuildListener(logger); | |||
| } | |||
| catch (IOException ex) { | |||
| } catch (IOException ex) { | |||
| log("Ant: Can't set output to " + output); | |||
| } | |||
| } | |||
| @@ -90,8 +90,7 @@ public class BZip2 extends Pack { | |||
| try { | |||
| // close up | |||
| zOut.close(); | |||
| } | |||
| catch (IOException e) {} | |||
| } catch (IOException e) {} | |||
| } | |||
| } | |||
| } | |||
| @@ -182,8 +182,7 @@ public class CallTarget extends Task { | |||
| protected void handleOutput(String line) { | |||
| if (callee != null) { | |||
| callee.handleOutput(line); | |||
| } | |||
| else { | |||
| } else { | |||
| super.handleOutput(line); | |||
| } | |||
| } | |||
| @@ -196,8 +195,7 @@ public class CallTarget extends Task { | |||
| protected void handleErrorOutput(String line) { | |||
| if (callee != null) { | |||
| callee.handleErrorOutput(line); | |||
| } | |||
| else { | |||
| } else { | |||
| super.handleErrorOutput(line); | |||
| } | |||
| } | |||
| @@ -227,8 +227,7 @@ public class DependSet extends MatchingTask { | |||
| log(targetFiles[i] + " does not exist.", Project.MSG_VERBOSE); | |||
| upToDate = false; | |||
| continue; | |||
| } | |||
| else { | |||
| } else { | |||
| allTargets.addElement(dest); | |||
| } | |||
| if (dest.lastModified() > now) { | |||
| @@ -118,8 +118,7 @@ public class Ear extends Jar { | |||
| protected void initZipOutputStream(ZipOutputStream zOut) | |||
| throws IOException, BuildException | |||
| { | |||
| throws IOException, BuildException { | |||
| // If no webxml file is specified, it's an error. | |||
| if (deploymentDescriptor == null && !isInUpdateMode()) { | |||
| throw new BuildException("appxml attribute is required", location); | |||
| @@ -129,8 +128,7 @@ public class Ear extends Jar { | |||
| } | |||
| protected void zipFile(File file, ZipOutputStream zOut, String vPath) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| // If the file being added is META-INF/application.xml, we | |||
| // warn if it's not the one specified in the "appxml" | |||
| // attribute - or if it's being added twice, meaning the same | |||
| @@ -120,8 +120,7 @@ public class Exec extends Task { | |||
| if (!dir.equals(project.resolveFile("."))) { | |||
| if (myos.toLowerCase().indexOf("nt") >= 0) { | |||
| command = "cmd /c cd " + dir + " && " + command; | |||
| } | |||
| else { | |||
| } else { | |||
| String ant = project.getProperty("ant.home"); | |||
| if (ant == null) { | |||
| throw new BuildException("Property 'ant.home' not found", location); | |||
| @@ -237,9 +236,7 @@ public class Exec extends Task { | |||
| this.parent = parent; | |||
| } | |||
| public void pumpStream() | |||
| throws IOException | |||
| { | |||
| public void pumpStream() throws IOException { | |||
| byte[] buf = new byte[BUFFER_SIZE]; | |||
| if (!endOfStream) { | |||
| String line = din.readLine(); | |||
| @@ -113,28 +113,24 @@ public class Execute { | |||
| // Try using a JDK 1.3 launcher | |||
| try { | |||
| vmLauncher = new Java13CommandLauncher(); | |||
| } | |||
| catch (NoSuchMethodException exc) { | |||
| } catch (NoSuchMethodException exc) { | |||
| // Ignore and keep trying | |||
| } | |||
| if (Os.isFamily("mac")) { | |||
| // Mac | |||
| shellLauncher = new MacCommandLauncher(new CommandLauncher()); | |||
| } | |||
| else if (Os.isFamily("os/2")) { | |||
| } else if (Os.isFamily("os/2")) { | |||
| // OS/2 - use same mechanism as Windows 2000 | |||
| shellLauncher = new WinNTCommandLauncher(new CommandLauncher()); | |||
| } | |||
| else if (Os.isFamily("windows")) { | |||
| } else if (Os.isFamily("windows")) { | |||
| // Windows. Need to determine which JDK we're running in | |||
| CommandLauncher baseLauncher; | |||
| if (System.getProperty("java.version").startsWith("1.1")) { | |||
| // JDK 1.1 | |||
| baseLauncher = new Java11CommandLauncher(); | |||
| } | |||
| else { | |||
| } else { | |||
| // JDK 1.2 | |||
| baseLauncher = new CommandLauncher(); | |||
| } | |||
| @@ -142,27 +138,23 @@ public class Execute { | |||
| if (!Os.isFamily("win9x")) { | |||
| // Windows XP/2000/NT | |||
| shellLauncher = new WinNTCommandLauncher(baseLauncher); | |||
| } | |||
| else { | |||
| } else { | |||
| // Windows 98/95 - need to use an auxiliary script | |||
| shellLauncher = new ScriptCommandLauncher("bin/antRun.bat", baseLauncher); | |||
| } | |||
| } | |||
| else if (Os.isFamily("netware")) { | |||
| } else if (Os.isFamily("netware")) { | |||
| // NetWare. Need to determine which JDK we're running in | |||
| CommandLauncher baseLauncher; | |||
| if (System.getProperty("java.version").startsWith("1.1")) { | |||
| // JDK 1.1 | |||
| baseLauncher = new Java11CommandLauncher(); | |||
| } | |||
| else { | |||
| } else { | |||
| // JDK 1.2 | |||
| baseLauncher = new CommandLauncher(); | |||
| } | |||
| shellLauncher = new PerlScriptCommandLauncher("bin/antRun.pl", baseLauncher); | |||
| } | |||
| else { | |||
| } else { | |||
| // Generic | |||
| shellLauncher = new ScriptCommandLauncher("bin/antRun", new CommandLauncher()); | |||
| } | |||
| @@ -198,12 +190,10 @@ public class Execute { | |||
| // contain embedded new lines). | |||
| if (var == null) { | |||
| var = lineSep + line; | |||
| } | |||
| else { | |||
| } else { | |||
| var += lineSep + line; | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| // New env var...append the previous one if we have it. | |||
| if (var != null) { | |||
| procEnvironment.addElement(var); | |||
| @@ -215,8 +205,7 @@ public class Execute { | |||
| if (var != null) { | |||
| procEnvironment.addElement(var); | |||
| } | |||
| } | |||
| catch (java.io.IOException exc) { | |||
| } catch (java.io.IOException exc) { | |||
| exc.printStackTrace(); | |||
| // Just try to see how much we got | |||
| } | |||
| @@ -229,31 +218,26 @@ public class Execute { | |||
| // Not sure | |||
| String[] cmd = {"cmd", "/c", "set" }; | |||
| return cmd; | |||
| } | |||
| else if (Os.isFamily("windows")) { | |||
| } else if (Os.isFamily("windows")) { | |||
| // Determine if we're running under XP/2000/NT or 98/95 | |||
| if (!Os.isFamily("win9x")) { | |||
| // Windows XP/2000/NT | |||
| String[] cmd = {"cmd", "/c", "set" }; | |||
| return cmd; | |||
| } | |||
| else { | |||
| } else { | |||
| // Windows 98/95 | |||
| String[] cmd = {"command.com", "/c", "set" }; | |||
| return cmd; | |||
| } | |||
| } | |||
| else if (Os.isFamily("unix")) { | |||
| } else if (Os.isFamily("unix")) { | |||
| // Generic UNIX | |||
| // Alternatively one could use: /bin/sh -c env | |||
| String[] cmd = {"/usr/bin/env"}; | |||
| return cmd; | |||
| } | |||
| else if (Os.isFamily("netware")) { | |||
| } else if (Os.isFamily("netware")) { | |||
| String[] cmd = {"env"}; | |||
| return cmd; | |||
| } | |||
| else { | |||
| } else { | |||
| // MAC OS 9 and previous | |||
| // TODO: I have no idea how to get it, someone must fix it | |||
| String[] cmd = null; | |||
| @@ -528,8 +512,7 @@ public class Execute { | |||
| throw new BuildException(cmdline[0] | |||
| + " failed with return code " + retval, task.getLocation()); | |||
| } | |||
| } | |||
| catch (java.io.IOException exc) { | |||
| } catch (java.io.IOException exc) { | |||
| throw new BuildException("Could not launch " + cmdline[0] + ": " | |||
| + exc, task.getLocation()); | |||
| } | |||
| @@ -540,8 +523,7 @@ public class Execute { | |||
| * a general purpose command launcher which can only launch commands in | |||
| * the current working directory. | |||
| */ | |||
| private static class CommandLauncher | |||
| { | |||
| private static class CommandLauncher { | |||
| /** | |||
| * Launches the given command in a new process. | |||
| * | |||
| @@ -610,10 +592,8 @@ public class Execute { | |||
| * A command launcher for JDK/JRE 1.3 (and higher). Uses the built-in | |||
| * Runtime.exec() command | |||
| */ | |||
| private static class Java13CommandLauncher extends CommandLauncher | |||
| { | |||
| public Java13CommandLauncher() throws NoSuchMethodException | |||
| { | |||
| private static class Java13CommandLauncher extends CommandLauncher { | |||
| public Java13CommandLauncher() throws NoSuchMethodException { | |||
| // Locate method Runtime.exec(String[] cmdarray, | |||
| // String[] envp, File dir) | |||
| _execWithCWD = Runtime.class.getMethod("exec", | |||
| @@ -624,9 +604,8 @@ public class Execute { | |||
| * Launches the given command in a new process, in the given working | |||
| * 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 { | |||
| if (project != null) { | |||
| project.log("Execute:Java13CommandLauncher: " + | |||
| @@ -635,20 +614,16 @@ public class Execute { | |||
| Object[] arguments = { cmd, env, workingDir }; | |||
| return (Process) _execWithCWD.invoke(Runtime.getRuntime(), | |||
| arguments); | |||
| } | |||
| catch (InvocationTargetException exc) { | |||
| } catch (InvocationTargetException exc) { | |||
| Throwable realexc = exc.getTargetException(); | |||
| if (realexc instanceof ThreadDeath) { | |||
| throw (ThreadDeath) realexc; | |||
| } | |||
| else if (realexc instanceof IOException) { | |||
| } else if (realexc instanceof IOException) { | |||
| throw (IOException) realexc; | |||
| } | |||
| else { | |||
| } else { | |||
| throw new BuildException("Unable to execute command", realexc); | |||
| } | |||
| } | |||
| catch (Exception exc) { | |||
| } catch (Exception exc) { | |||
| // IllegalAccess, IllegalArgument, ClassCast | |||
| throw new BuildException("Unable to execute command", exc); | |||
| } | |||
| @@ -662,10 +637,8 @@ public class Execute { | |||
| * | |||
| * Sub-classes override exec(args, env, workdir) | |||
| */ | |||
| private static class CommandLauncherProxy extends CommandLauncher | |||
| { | |||
| CommandLauncherProxy(CommandLauncher launcher) | |||
| { | |||
| private static class CommandLauncherProxy extends CommandLauncher { | |||
| CommandLauncherProxy(CommandLauncher launcher) { | |||
| _launcher = launcher; | |||
| } | |||
| @@ -673,8 +646,8 @@ public class Execute { | |||
| * Launches the given command in a new process. Delegates this | |||
| * method to the proxied launcher | |||
| */ | |||
| public Process exec(Project project, String[] cmd, String[] env) throws IOException | |||
| { | |||
| public Process exec(Project project, String[] cmd, String[] env) | |||
| throws IOException { | |||
| return _launcher.exec(project, cmd, env); | |||
| } | |||
| @@ -686,10 +659,8 @@ public class Execute { | |||
| * launching commands in directories other than the current working | |||
| * directory. | |||
| */ | |||
| private static class WinNTCommandLauncher extends CommandLauncherProxy | |||
| { | |||
| WinNTCommandLauncher(CommandLauncher launcher) | |||
| { | |||
| private static class WinNTCommandLauncher extends CommandLauncherProxy { | |||
| WinNTCommandLauncher(CommandLauncher launcher) { | |||
| super(launcher); | |||
| } | |||
| @@ -697,8 +668,8 @@ public class Execute { | |||
| * Launches the given command in a new process, in the given working | |||
| * 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 { | |||
| File commandDir = workingDir; | |||
| if (workingDir == null) { | |||
| if (project != null) { | |||
| @@ -728,10 +699,8 @@ public class Execute { | |||
| * A command launcher for Mac that uses a dodgy mechanism to change | |||
| * working directory before launching commands. | |||
| */ | |||
| private static class MacCommandLauncher extends CommandLauncherProxy | |||
| { | |||
| MacCommandLauncher(CommandLauncher launcher) | |||
| { | |||
| private static class MacCommandLauncher extends CommandLauncherProxy { | |||
| MacCommandLauncher(CommandLauncher launcher) { | |||
| super(launcher); | |||
| } | |||
| @@ -739,8 +708,8 @@ public class Execute { | |||
| * Launches the given command in a new process, in the given working | |||
| * 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 { | |||
| if (workingDir == null) { | |||
| return exec(project, cmd, env); | |||
| } | |||
| @@ -748,8 +717,7 @@ public class Execute { | |||
| System.getProperties().put("user.dir", workingDir.getAbsolutePath()); | |||
| try { | |||
| return exec(project, cmd, env); | |||
| } | |||
| finally { | |||
| } finally { | |||
| System.getProperties().put("user.dir", antWorkingDirectory); | |||
| } | |||
| } | |||
| @@ -759,10 +727,8 @@ public class Execute { | |||
| * A command launcher that uses an auxiliary script to launch commands | |||
| * in directories other than the current working directory. | |||
| */ | |||
| private static class ScriptCommandLauncher extends CommandLauncherProxy | |||
| { | |||
| ScriptCommandLauncher(String script, CommandLauncher launcher) | |||
| { | |||
| private static class ScriptCommandLauncher extends CommandLauncherProxy { | |||
| ScriptCommandLauncher(String script, CommandLauncher launcher) { | |||
| super(launcher); | |||
| _script = script; | |||
| } | |||
| @@ -771,8 +737,8 @@ public class Execute { | |||
| * Launches the given command in a new process, in the given working | |||
| * 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 { | |||
| if (project == null) { | |||
| if (workingDir == null) { | |||
| return exec(project, cmd, env); | |||
| @@ -783,7 +749,8 @@ public class Execute { | |||
| // Locate the auxiliary script | |||
| String antHome = project.getProperty("ant.home"); | |||
| if (antHome == null) { | |||
| throw new IOException("Cannot locate antRun script: Property 'ant.home' not found"); | |||
| throw new IOException("Cannot locate antRun script: " | |||
| + "Property 'ant.home' not found"); | |||
| } | |||
| String antRun = project.resolveFile(antHome + File.separator + _script).toString(); | |||
| @@ -808,10 +775,9 @@ public class Execute { | |||
| * A command launcher that uses an auxiliary perl script to launch commands | |||
| * in directories other than the current working directory. | |||
| */ | |||
| private static class PerlScriptCommandLauncher extends CommandLauncherProxy | |||
| { | |||
| PerlScriptCommandLauncher(String script, CommandLauncher launcher) | |||
| { | |||
| private static class PerlScriptCommandLauncher | |||
| extends CommandLauncherProxy { | |||
| PerlScriptCommandLauncher(String script, CommandLauncher launcher) { | |||
| super(launcher); | |||
| _script = script; | |||
| } | |||
| @@ -820,19 +786,21 @@ public class Execute { | |||
| * Launches the given command in a new process, in the given working | |||
| * 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 { | |||
| if (project == null) { | |||
| if (workingDir == null) { | |||
| return exec(project, cmd, env); | |||
| } | |||
| throw new IOException("Cannot locate antRun script: No project provided"); | |||
| throw new IOException("Cannot locate antRun script: " | |||
| + "No project provided"); | |||
| } | |||
| // Locate the auxiliary script | |||
| String antHome = project.getProperty("ant.home"); | |||
| if (antHome == null) { | |||
| throw new IOException("Cannot locate antRun script: Property 'ant.home' not found"); | |||
| throw new IOException("Cannot locate antRun script: " | |||
| + "Property 'ant.home' not found"); | |||
| } | |||
| String antRun = project.resolveFile(antHome + File.separator + _script).toString(); | |||
| @@ -166,8 +166,7 @@ public class Expand extends MatchingTask { | |||
| if (zis != null) { | |||
| try { | |||
| zis.close(); | |||
| } | |||
| catch (IOException e) {} | |||
| } catch (IOException e) {} | |||
| } | |||
| } | |||
| } | |||
| @@ -455,8 +455,7 @@ public class FixCRLF extends MatchingTask { | |||
| // End of multiLineComment on this line | |||
| endComment += 2; // Include the end token | |||
| lines.setState(LOOKING); | |||
| } | |||
| else { | |||
| } else { | |||
| endComment = linelen; | |||
| } | |||
| @@ -489,8 +488,7 @@ public class FixCRLF extends MatchingTask { | |||
| tablength - | |||
| (line.getColumn() | |||
| % tablength)); | |||
| } | |||
| else { | |||
| } else { | |||
| line.incColumn(); | |||
| } | |||
| } | |||
| @@ -548,8 +546,7 @@ public class FixCRLF extends MatchingTask { | |||
| try { | |||
| lines.close(); | |||
| lines = null; | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| throw new BuildException("Unable to close source file " | |||
| + srcFile); | |||
| } | |||
| @@ -627,8 +624,7 @@ public class FixCRLF extends MatchingTask { | |||
| * before the terminator is found. | |||
| */ | |||
| private void nextStateChange(OneLiner.BufferLine bufline) | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| int eol = bufline.length(); | |||
| int ptr = bufline.getNext(); | |||
| @@ -650,8 +646,7 @@ public class FixCRLF extends MatchingTask { | |||
| bufline.setState(IN_MULTI_COMMENT); | |||
| bufline.setLookahead(--ptr); | |||
| return; | |||
| } | |||
| else if (bufline.getChar(ptr) == '/') { | |||
| } else if (bufline.getChar(ptr) == '/') { | |||
| bufline.setState(IN_SINGLE_COMMENT); | |||
| bufline.setLookahead(--ptr); | |||
| return; | |||
| @@ -680,8 +675,7 @@ public class FixCRLF extends MatchingTask { | |||
| * before the terminator is found. | |||
| */ | |||
| private void endOfCharConst(OneLiner.BufferLine bufline, char terminator) | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| int ptr = bufline.getNext(); | |||
| int eol = bufline.length(); | |||
| char c; | |||
| @@ -689,8 +683,7 @@ public class FixCRLF extends MatchingTask { | |||
| while (ptr < eol) { | |||
| if ((c = bufline.getChar(ptr++)) == '\\') { | |||
| ptr++; | |||
| } | |||
| else { | |||
| } else { | |||
| if (c == terminator) { | |||
| bufline.setLookahead(ptr); | |||
| return; | |||
| @@ -714,8 +707,7 @@ public class FixCRLF extends MatchingTask { | |||
| * @param BufferedWriter outWriter Sink for the processed string | |||
| */ | |||
| private void notInConstant(OneLiner.BufferLine bufline, int end, | |||
| BufferedWriter outWriter) | |||
| { | |||
| BufferedWriter outWriter) { | |||
| // N.B. both column and string index are zero-based | |||
| // Process a string not part of a constant; | |||
| // i.e. convert tabs<->spaces as required | |||
| @@ -747,8 +739,7 @@ public class FixCRLF extends MatchingTask { | |||
| } catch (IOException e) { | |||
| throw new BuildException(e); | |||
| } // end of try-catch | |||
| } | |||
| else { // tabs == ADD | |||
| } else { // tabs == ADD | |||
| int tabCol; | |||
| linebuf2.setLength(0); | |||
| place = 0; | |||
| @@ -780,8 +771,7 @@ public class FixCRLF extends MatchingTask { | |||
| linebuf2.append(linestring.substring( | |||
| place, ++tabCol - placediff)); | |||
| linebuf2.append('\t'); | |||
| } | |||
| else { | |||
| } else { | |||
| linebuf2.append(linestring.substring( | |||
| place, nextStop - placediff)); | |||
| } // end of else | |||
| @@ -819,8 +809,7 @@ public class FixCRLF extends MatchingTask { | |||
| private boolean reachedEof = false; | |||
| public OneLiner(File srcFile) | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| try { | |||
| reader = new BufferedReader | |||
| (getReader(srcFile), INBUFLEN); | |||
| @@ -924,14 +913,12 @@ public class FixCRLF extends MatchingTask { | |||
| this.state = state; | |||
| } | |||
| public boolean hasMoreElements() | |||
| { | |||
| public boolean hasMoreElements() { | |||
| return !reachedEof; | |||
| } | |||
| public Object nextElement() | |||
| throws NoSuchElementException | |||
| { | |||
| throws NoSuchElementException { | |||
| if (!hasMoreElements()) { | |||
| throw new NoSuchElementException("OneLiner"); | |||
| } | |||
| @@ -955,8 +942,7 @@ public class FixCRLF extends MatchingTask { | |||
| private String eolStr; | |||
| public BufferLine(String line, String eolStr) | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| next = 0; | |||
| column = 0; | |||
| this.line = line; | |||
| @@ -87,8 +87,9 @@ public class GZip extends Pack { | |||
| try { | |||
| // close up | |||
| zOut.close(); | |||
| } catch (IOException e) { | |||
| // do nothing | |||
| } | |||
| catch (IOException e) {} | |||
| } | |||
| } | |||
| } | |||
| @@ -137,8 +137,7 @@ public class GenerateKey extends Task { | |||
| int start = 0; | |||
| while (-1 != end) | |||
| { | |||
| while (-1 != end) { | |||
| sb.append(string.substring(start, end)); | |||
| sb.append("\\,"); | |||
| start = end + 1; | |||
| @@ -306,8 +305,7 @@ public class GenerateKey extends Task { | |||
| sb.append("-keypass \""); | |||
| if (null != keypass) { | |||
| sb.append(keypass); | |||
| } | |||
| else { | |||
| } else { | |||
| sb.append(storepass); | |||
| } | |||
| sb.append("\" "); | |||
| @@ -150,8 +150,7 @@ public class Get extends Task { | |||
| Class.forName("sun.misc.BASE64Encoder").newInstance(); | |||
| encoding = encoder.encode (up.getBytes()); | |||
| } | |||
| catch (Exception ex) { // sun's base64 encoder isn't available | |||
| } catch (Exception ex) { // sun's base64 encoder isn't available | |||
| Base64Converter encoder = new Base64Converter(); | |||
| encoding = encoder.encode(up.getBytes()); | |||
| } | |||
| @@ -339,8 +338,7 @@ public class Get extends Task { | |||
| * <a HREF="gg@grtmail.com">Gautam Guliani</a> | |||
| *********************************************************************/ | |||
| class Base64Converter | |||
| { | |||
| class Base64Converter { | |||
| public final char [ ] alphabet = { | |||
| 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7 | |||
| @@ -353,13 +351,11 @@ public class Get extends Task { | |||
| '4', '5', '6', '7', '8', '9', '+', '/' }; // 56 to 63 | |||
| public String encode(String s) | |||
| { | |||
| public String encode(String s) { | |||
| return encode (s.getBytes()); | |||
| } | |||
| public String encode(byte[ ] octetString) | |||
| { | |||
| public String encode(byte[ ] octetString) { | |||
| int bits24; | |||
| int bits6; | |||
| @@ -384,8 +380,7 @@ public class Get extends Task { | |||
| out[outIndex++] = alphabet[bits6]; | |||
| } | |||
| if (octetString.length - i == 2) | |||
| { | |||
| if (octetString.length - i == 2) { | |||
| // store the octets | |||
| bits24 = (octetString[i] & 0xFF) << 16; | |||
| bits24 |= (octetString[i + 1] & 0xFF) << 8; | |||
| @@ -398,9 +393,7 @@ public class Get extends Task { | |||
| // padding | |||
| out[outIndex++] = '='; | |||
| } | |||
| else if (octetString.length - i == 1) | |||
| { | |||
| } else if (octetString.length - i == 1) { | |||
| // store the octets | |||
| bits24 = (octetString[i] & 0xFF) << 16; | |||
| bits6 = (bits24 & 0x00FC0000) >> 18; | |||
| @@ -151,10 +151,9 @@ public class Input extends Task { | |||
| } catch (IOException e) { | |||
| throw new BuildException("Failed to read input from Console.", e); | |||
| } | |||
| } | |||
| // not quite the original intention of this task but for the sake | |||
| // of testing ;-) | |||
| else { | |||
| } else { | |||
| // not quite the original intention of this task but for the sake | |||
| // of testing ;-) | |||
| if (accept != null && (!accept.contains(input))) { | |||
| throw new BuildException("Invalid input please reenter."); | |||
| } | |||
| @@ -163,8 +162,7 @@ public class Input extends Task { | |||
| if (addproperty != null) { | |||
| if (project.getProperty(addproperty) == null) { | |||
| project.setProperty(addproperty, input); | |||
| } | |||
| else { | |||
| } else { | |||
| log("Override ignored for " + addproperty, Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| @@ -176,8 +176,7 @@ public class Jar extends Zip { | |||
| try { | |||
| r = new FileReader(manifestFile); | |||
| newManifest = getManifest(r); | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| throw new BuildException("Unable to read manifest file: " | |||
| + manifestFile | |||
| + " (" + e.getMessage() + ")", e); | |||
| @@ -185,8 +184,7 @@ public class Jar extends Zip { | |||
| if (r != null) { | |||
| try { | |||
| r.close(); | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| // do nothing | |||
| } | |||
| } | |||
| @@ -199,13 +197,11 @@ public class Jar extends Zip { | |||
| Manifest newManifest = null; | |||
| try { | |||
| newManifest = new Manifest(r); | |||
| } | |||
| catch (ManifestException e) { | |||
| } catch (ManifestException e) { | |||
| log("Manifest is invalid: " + e.getMessage(), Project.MSG_ERR); | |||
| throw new BuildException("Invalid Manifest: " + manifestFile, | |||
| e, getLocation()); | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| throw new BuildException("Unable to read manifest file" | |||
| + " (" + e.getMessage() + ")", e); | |||
| } | |||
| @@ -225,8 +221,7 @@ public class Jar extends Zip { | |||
| } | |||
| protected void initZipOutputStream(ZipOutputStream zOut) | |||
| throws IOException, BuildException | |||
| { | |||
| throws IOException, BuildException { | |||
| String ls = System.getProperty("line.separator"); | |||
| try { | |||
| @@ -240,14 +235,12 @@ public class Jar extends Zip { | |||
| finalManifest.merge(filesetManifest); | |||
| finalManifest.merge(configuredManifest); | |||
| finalManifest.merge(manifest, !mergeManifestsMain); | |||
| } | |||
| else if (configuredManifest != null) { | |||
| } else if (configuredManifest != null) { | |||
| // configuredManifest is the final merge | |||
| finalManifest.merge(filesetManifest); | |||
| finalManifest.merge(configuredManifest, | |||
| !mergeManifestsMain); | |||
| } | |||
| else if (filesetManifest != null) { | |||
| } else if (filesetManifest != null) { | |||
| // filesetManifest is the final (and only) merge | |||
| finalManifest.merge(filesetManifest, !mergeManifestsMain); | |||
| } | |||
| @@ -280,12 +273,10 @@ public class Jar extends Zip { | |||
| super.zipFile(bais, zOut, "META-INF/MANIFEST.MF", | |||
| System.currentTimeMillis(), null); | |||
| super.initZipOutputStream(zOut); | |||
| } | |||
| catch (ManifestException e) { | |||
| } catch (ManifestException e) { | |||
| log("Manifest is invalid: " + e.getMessage(), Project.MSG_ERR); | |||
| throw new BuildException("Invalid Manifest", e, getLocation()); | |||
| } | |||
| finally { | |||
| } finally { | |||
| System.getProperties().put("line.separator", ls); | |||
| } | |||
| } | |||
| @@ -355,8 +346,7 @@ public class Jar extends Zip { | |||
| * Overriden from Zip class to deal with manifests | |||
| */ | |||
| protected void zipFile(File file, ZipOutputStream zOut, String vPath) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| if ("META-INF/MANIFEST.MF".equalsIgnoreCase(vPath)) { | |||
| filesetManifest(file, null); | |||
| } else { | |||
| @@ -369,8 +359,7 @@ public class Jar extends Zip { | |||
| */ | |||
| protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath, | |||
| long lastModified, File file) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| if ("META-INF/MANIFEST.MF".equalsIgnoreCase(vPath)) { | |||
| filesetManifest(file, is); | |||
| } else { | |||
| @@ -385,31 +374,26 @@ public class Jar extends Zip { | |||
| log("Found manifest " + file, Project.MSG_VERBOSE); | |||
| if (is != null) { | |||
| manifest = getManifest(new InputStreamReader(is)); | |||
| } | |||
| else { | |||
| } else { | |||
| manifest = getManifest(file); | |||
| } | |||
| } | |||
| else if (mergeManifests) { | |||
| } else if (mergeManifests) { | |||
| // we add this to our group of fileset manifests | |||
| log("Found manifest to merge in file " + file, | |||
| Project.MSG_VERBOSE); | |||
| try | |||
| { | |||
| try { | |||
| Manifest newManifest = getManifest(new InputStreamReader(is)); | |||
| if (filesetManifest == null) { | |||
| filesetManifest = newManifest; | |||
| } else { | |||
| filesetManifest.merge(newManifest); | |||
| } | |||
| } | |||
| catch (ManifestException e) { | |||
| } catch (ManifestException e) { | |||
| log("Manifest in file " + file + " is invalid: " + e.getMessage(), Project.MSG_ERR); | |||
| throw new BuildException("Invalid Manifest", e, getLocation()); | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| // assuming 'skip' otherwise | |||
| log("File " + file | |||
| + " includes a META-INF/MANIFEST.MF which will be ignored. " | |||
| @@ -451,26 +435,22 @@ public class Jar extends Zip { | |||
| Project.MSG_VERBOSE); | |||
| return false; | |||
| } | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| // any problems and we will rebuild | |||
| log("Updating jar since cannot read current jar manifest: " | |||
| + e.getClass().getName() + " - " + e.getMessage(), | |||
| Project.MSG_VERBOSE); | |||
| return false; | |||
| } | |||
| finally { | |||
| } finally { | |||
| if (theZipFile != null) { | |||
| try { | |||
| theZipFile.close(); | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| //ignore | |||
| } | |||
| } | |||
| } | |||
| } | |||
| else if (manifestFile.lastModified() > zipFile.lastModified()) { | |||
| } else if (manifestFile.lastModified() > zipFile.lastModified()) { | |||
| return false; | |||
| } | |||
| return super.isUpToDate(scanners, zipFile); | |||
| @@ -396,14 +396,12 @@ public class Java extends Task { | |||
| exe.execute(project); | |||
| } catch (IOException io) { | |||
| throw new BuildException(io, location); | |||
| } | |||
| finally { | |||
| } finally { | |||
| if (outStream != null) { | |||
| outStream.close(); | |||
| } | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| exe.execute(project); | |||
| } | |||
| } | |||
| @@ -776,8 +776,7 @@ public class Javadoc extends Task { | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| gotAll = true; | |||
| } | |||
| else { | |||
| } else { | |||
| int i; | |||
| for (i = 0; i < SCOPE_ELEMENTS.length; i++) { | |||
| if (next.equals (SCOPE_ELEMENTS[i])) | |||
| @@ -786,8 +785,7 @@ public class Javadoc extends Task { | |||
| if (i == SCOPE_ELEMENTS.length) { | |||
| throw new BuildException ("Unrecognised scope element: " | |||
| + next); | |||
| } | |||
| else { | |||
| } else { | |||
| if (elements[i]) { | |||
| getProject().log ("Repeated tag scope element: " | |||
| + next, Project.MSG_VERBOSE); | |||
| @@ -808,8 +806,7 @@ public class Javadoc extends Task { | |||
| } | |||
| if (gotAll) { | |||
| this.scope = "a"; | |||
| } | |||
| else { | |||
| } else { | |||
| StringBuffer buff = new StringBuffer (elements.length); | |||
| for (int i = 0; i < elements.length; i++) { | |||
| if (elements[i]) { | |||
| @@ -998,8 +995,7 @@ public class Javadoc extends Task { | |||
| if (doclet.getName() == null) { | |||
| throw new BuildException("The doclet name must be " | |||
| + "specified.", location); | |||
| } | |||
| else { | |||
| } else { | |||
| toExecute.createArgument().setValue("-doclet"); | |||
| toExecute.createArgument().setValue(doclet.getName()); | |||
| if (doclet.getPath() != null) { | |||
| @@ -1060,13 +1056,11 @@ public class Javadoc extends Task { | |||
| toExecute.createArgument() | |||
| .setValue(packageListLocation | |||
| .getAbsolutePath()); | |||
| } | |||
| else { | |||
| } else { | |||
| log("Warning: No package list was found at " | |||
| + packageListLocation, Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| toExecute.createArgument().setValue("-link"); | |||
| toExecute.createArgument().setValue(la.getHref()); | |||
| } | |||
| @@ -179,8 +179,7 @@ public class KeySubst extends Task { | |||
| } | |||
| public static void main(String[] args) | |||
| { | |||
| public static void main(String[] args) { | |||
| try { | |||
| Hashtable hash = new Hashtable(); | |||
| hash.put("VERSION", "1.0.3"); | |||
| @@ -198,8 +197,7 @@ public class KeySubst extends Task { | |||
| @return the string with the replacements in it. | |||
| */ | |||
| public static String replace(String origString, Hashtable keys) | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| StringBuffer finalString = new StringBuffer(); | |||
| int index = 0; | |||
| int i = 0; | |||
| @@ -178,8 +178,7 @@ public final class LoadFile extends Task { | |||
| bis = new BufferedInputStream(fis); | |||
| if (encoding == null) { | |||
| instream = new InputStreamReader(bis); | |||
| } | |||
| else { | |||
| } else { | |||
| instream = new InputStreamReader(bis, encoding); | |||
| } | |||
| @@ -203,15 +202,13 @@ public final class LoadFile extends Task { | |||
| final String message = "Unable to load file: " + ioe.toString(); | |||
| if (failOnError) { | |||
| throw new BuildException(message, ioe, location); | |||
| } | |||
| else { | |||
| } else { | |||
| log(message, Project.MSG_ERR); | |||
| } | |||
| } catch (final BuildException be) { | |||
| if (failOnError) { | |||
| throw be; | |||
| } | |||
| else { | |||
| } else { | |||
| log(be.getMessage(), Project.MSG_ERR); | |||
| } | |||
| } finally { | |||
| @@ -1068,8 +1068,7 @@ public class Manifest extends Task { | |||
| if (mode.getValue().equals("update") && manifestFile.exists()) { | |||
| if (current != null) { | |||
| toWrite.merge(current); | |||
| } | |||
| else if (error != null) { | |||
| } else if (error != null) { | |||
| throw error; | |||
| } | |||
| } | |||
| @@ -117,8 +117,7 @@ public abstract class Pack extends Task { | |||
| } | |||
| private void zipFile(InputStream in, OutputStream zOut) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| byte[] buffer = new byte[8 * 1024]; | |||
| int count = 0; | |||
| do { | |||
| @@ -128,8 +127,7 @@ public abstract class Pack extends Task { | |||
| } | |||
| protected void zipFile(File file, OutputStream zOut) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| FileInputStream fIn = new FileInputStream(file); | |||
| try { | |||
| zipFile(fIn, zOut); | |||
| @@ -112,8 +112,7 @@ public class Parallel extends Task | |||
| for (int i = 0; i < threads.length; ++i) { | |||
| try { | |||
| threads[i].join(); | |||
| } | |||
| catch (InterruptedException ie) { | |||
| } catch (InterruptedException ie) { | |||
| // who would interrupt me at a time like this? | |||
| } | |||
| } | |||
| @@ -142,12 +141,10 @@ public class Parallel extends Task | |||
| if (numExceptions == 1) { | |||
| if (firstException instanceof BuildException) { | |||
| throw (BuildException) firstException; | |||
| } | |||
| else { | |||
| } else { | |||
| throw new BuildException(firstException); | |||
| } | |||
| } | |||
| else if (numExceptions > 1) { | |||
| } else if (numExceptions > 1) { | |||
| throw new BuildException(exceptionMessage.toString(), | |||
| firstLocation); | |||
| } | |||
| @@ -175,8 +172,7 @@ public class Parallel extends Task | |||
| public void run() { | |||
| try { | |||
| task.perform(); | |||
| } | |||
| catch (Throwable t) { | |||
| } catch (Throwable t) { | |||
| exception = t; | |||
| } | |||
| } | |||
| @@ -65,8 +65,7 @@ import java.util.Vector; | |||
| * @since Ant 1.5 | |||
| */ | |||
| class ProcessDestroyer | |||
| extends Thread | |||
| { | |||
| extends Thread { | |||
| private Vector processes = new Vector(); | |||
| @@ -74,10 +73,8 @@ class ProcessDestroyer | |||
| * Constructs a <code>ProcessDestroyer</code> and registers it as | |||
| * a shutdown hook. | |||
| */ | |||
| public ProcessDestroyer() | |||
| { | |||
| try | |||
| { | |||
| public ProcessDestroyer() { | |||
| try { | |||
| // check to see if the method exists (support pre-JDK 1.3 VMs) | |||
| // | |||
| Class[] paramTypes = {Thread.class}; | |||
| @@ -88,9 +85,7 @@ class ProcessDestroyer | |||
| // | |||
| Object[] args = {this}; | |||
| addShutdownHook.invoke(Runtime.getRuntime(), args); | |||
| } | |||
| catch (Exception e) | |||
| { | |||
| } catch (Exception e) { | |||
| // it just won't be added as a shutdown hook... :( | |||
| } | |||
| } | |||
| @@ -103,8 +98,7 @@ class ProcessDestroyer | |||
| * @return <code>true</code> if the specified <code>Process</code> was | |||
| * successfully added | |||
| */ | |||
| public boolean add(Process process) | |||
| { | |||
| public boolean add(Process process) { | |||
| processes.addElement(process); | |||
| return processes.contains(process); | |||
| } | |||
| @@ -117,21 +111,17 @@ class ProcessDestroyer | |||
| * @return <code>true</code> if the specified <code>Process</code> was | |||
| * successfully removed | |||
| */ | |||
| public boolean remove(Process process) | |||
| { | |||
| public boolean remove(Process process) { | |||
| return processes.removeElement(process); | |||
| } | |||
| /** | |||
| * Invoked by the VM when it is exiting. | |||
| */ | |||
| public void run() | |||
| { | |||
| synchronized (processes) | |||
| { | |||
| public void run() { | |||
| synchronized (processes) { | |||
| Enumeration e = processes.elements(); | |||
| while (e.hasMoreElements()) | |||
| { | |||
| while (e.hasMoreElements()) { | |||
| ((Process) e.nextElement()).destroy(); | |||
| } | |||
| } | |||
| @@ -377,8 +377,7 @@ public class Property extends Task { | |||
| if (props.containsKey(propertyName)) { | |||
| fragment = props.getProperty(propertyName); | |||
| resolved = false; | |||
| } | |||
| else { | |||
| } else { | |||
| fragment = "${" + propertyName + "}"; | |||
| } | |||
| } | |||
| @@ -126,8 +126,7 @@ public class Replace extends MatchingTask { | |||
| } | |||
| //Inner class | |||
| public class Replacefilter | |||
| { | |||
| public class Replacefilter { | |||
| private String token; | |||
| private String value; | |||
| private String property; | |||
| @@ -173,18 +172,14 @@ public class Replace extends MatchingTask { | |||
| } | |||
| } | |||
| public String getReplaceValue() | |||
| { | |||
| public String getReplaceValue() { | |||
| if (property != null) { | |||
| return properties.getProperty(property); | |||
| } | |||
| else if (value != null) { | |||
| } else if (value != null) { | |||
| return value; | |||
| } | |||
| else if (Replace.this.value != null) { | |||
| } else if (Replace.this.value != null) { | |||
| return Replace.this.value.getText(); | |||
| } | |||
| else { | |||
| } else { | |||
| //Default is empty string | |||
| return new String(""); | |||
| } | |||
| @@ -319,13 +314,11 @@ public class Replace extends MatchingTask { | |||
| try { | |||
| properties.load(new FileInputStream(propertyFile)); | |||
| } | |||
| catch (FileNotFoundException e) { | |||
| } catch (FileNotFoundException e) { | |||
| String message = "Property file (" + propertyFile.getPath() | |||
| + ") not found."; | |||
| throw new BuildException(message); | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| String message = "Property file (" + propertyFile.getPath() | |||
| + ") cannot be loaded."; | |||
| throw new BuildException(message); | |||
| @@ -384,8 +377,7 @@ public class Replace extends MatchingTask { | |||
| //Preserve original string (buf) so we can compare the result | |||
| String newString = new String(buf); | |||
| if (token != null) | |||
| { | |||
| if (token != null) { | |||
| // line separators in values and tokens are "\n" | |||
| // in order to compare with the file contents, replace them | |||
| // as needed | |||
| @@ -484,8 +484,7 @@ public class SQLExec extends Task { | |||
| } | |||
| } | |||
| dc = loader.loadClass(driver); | |||
| } | |||
| else { | |||
| } else { | |||
| log("Loading " + driver + " using system loader.", | |||
| Project.MSG_VERBOSE); | |||
| dc = Class.forName(driver); | |||
| @@ -568,8 +567,7 @@ public class SQLExec extends Task { | |||
| conn.commit(); | |||
| } | |||
| } | |||
| } | |||
| finally { | |||
| } finally { | |||
| if (out != null && out != System.out) { | |||
| out.close(); | |||
| } | |||
| @@ -588,8 +586,7 @@ public class SQLExec extends Task { | |||
| } catch (SQLException ex) {} | |||
| } | |||
| throw new BuildException(e, location); | |||
| } | |||
| finally { | |||
| } finally { | |||
| try { | |||
| if (statement != null) { | |||
| statement.close(); | |||
| @@ -597,8 +594,7 @@ public class SQLExec extends Task { | |||
| if (conn != null) { | |||
| conn.close(); | |||
| } | |||
| } | |||
| catch (SQLException e) {} | |||
| } catch (SQLException e) {} | |||
| } | |||
| log(goodSql + " of " + totalSql + | |||
| @@ -697,8 +693,7 @@ public class SQLExec extends Task { | |||
| return false; | |||
| } | |||
| } | |||
| } | |||
| catch (SQLException e) { | |||
| } catch (SQLException e) { | |||
| // Could not get the required information | |||
| log("Failed to obtain required RDBMS information", Project.MSG_ERR); | |||
| return false; | |||
| @@ -721,8 +716,7 @@ public class SQLExec extends Task { | |||
| if (!statement.execute(sql)) { | |||
| log(statement.getUpdateCount() + " rows affected", | |||
| Project.MSG_VERBOSE); | |||
| } | |||
| else { | |||
| } else { | |||
| if (print) { | |||
| printResults(out); | |||
| } | |||
| @@ -735,8 +729,7 @@ public class SQLExec extends Task { | |||
| } | |||
| conn.clearWarnings(); | |||
| goodSql++; | |||
| } | |||
| catch (SQLException e) { | |||
| } catch (SQLException e) { | |||
| log("Failed to execute: " + sql, Project.MSG_ERR); | |||
| if (!onError.equals("continue")) { | |||
| throw e; | |||
| @@ -776,8 +769,7 @@ public class SQLExec extends Task { | |||
| if (first) { | |||
| first = false; | |||
| } | |||
| else { | |||
| } else { | |||
| line.append(","); | |||
| } | |||
| line.append(columnValue); | |||
| @@ -110,8 +110,7 @@ import org.apache.tools.ant.taskdefs.email.EmailTask; | |||
| * | |||
| * @ant.task name="mail" category="network" | |||
| */ | |||
| public class SendEmail extends EmailTask | |||
| { | |||
| public class SendEmail extends EmailTask { | |||
| /** | |||
| * Sets the mailport parameter of this build task. | |||
| * @param value mail port name. | |||
| @@ -145,8 +145,7 @@ public class Sleep extends Task { | |||
| public void doSleep(long millis) { | |||
| try { | |||
| Thread.sleep(millis); | |||
| } | |||
| catch (InterruptedException ie) { | |||
| } catch (InterruptedException ie) { | |||
| } | |||
| } | |||
| @@ -201,12 +200,10 @@ public class Sleep extends Task { | |||
| log("sleeping for " + sleepTime + " milliseconds", | |||
| Project.MSG_VERBOSE); | |||
| doSleep(sleepTime); | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| if (failOnError) { | |||
| throw new BuildException(e); | |||
| } | |||
| else { | |||
| } else { | |||
| String text = e.toString(); | |||
| log(text, Project.MSG_ERR); | |||
| } | |||
| @@ -130,8 +130,7 @@ public class StreamPumper implements Runnable { | |||
| * @see #isFinished() | |||
| **/ | |||
| public synchronized void waitFor() | |||
| throws InterruptedException | |||
| { | |||
| throws InterruptedException { | |||
| while (!isFinished()) { | |||
| wait(); | |||
| } | |||
| @@ -261,12 +261,10 @@ public class Tar extends MatchingTask { | |||
| tOut.setDebug(true); | |||
| if (longFileMode.isTruncateMode()) { | |||
| tOut.setLongFileMode(TarOutputStream.LONGFILE_TRUNCATE); | |||
| } | |||
| else if (longFileMode.isFailMode() || | |||
| } else if (longFileMode.isFailMode() || | |||
| longFileMode.isOmitMode()) { | |||
| tOut.setLongFileMode(TarOutputStream.LONGFILE_ERROR); | |||
| } | |||
| else { | |||
| } else { | |||
| // warn or GNU | |||
| tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU); | |||
| } | |||
| @@ -296,8 +294,7 @@ public class Tar extends MatchingTask { | |||
| try { | |||
| // close up | |||
| tOut.close(); | |||
| } | |||
| catch (IOException e) {} | |||
| } catch (IOException e) {} | |||
| } | |||
| } | |||
| } finally { | |||
| @@ -307,8 +304,7 @@ public class Tar extends MatchingTask { | |||
| protected void tarFile(File file, TarOutputStream tOut, String vPath, | |||
| TarFileSet tarFileSet) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| FileInputStream fIn = null; | |||
| String fullpath = tarFileSet.getFullpath(); | |||
| @@ -121,15 +121,13 @@ public class Tstamp extends Task { | |||
| } | |||
| } | |||
| public CustomFormat createFormat() | |||
| { | |||
| public CustomFormat createFormat() { | |||
| CustomFormat cts = new CustomFormat(prefix); | |||
| customFormats.addElement(cts); | |||
| return cts; | |||
| } | |||
| public class CustomFormat | |||
| { | |||
| public class CustomFormat { | |||
| private TimeZone timeZone; | |||
| private String propertyName; | |||
| private String pattern; | |||
| @@ -140,23 +138,19 @@ public class Tstamp extends Task { | |||
| private int field = Calendar.DATE; | |||
| private String prefix = ""; | |||
| public CustomFormat(String prefix) | |||
| { | |||
| public CustomFormat(String prefix) { | |||
| this.prefix = prefix; | |||
| } | |||
| public void setProperty(String propertyName) | |||
| { | |||
| public void setProperty(String propertyName) { | |||
| this.propertyName = prefix + propertyName; | |||
| } | |||
| public void setPattern(String pattern) | |||
| { | |||
| public void setPattern(String pattern) { | |||
| this.pattern = pattern; | |||
| } | |||
| public void setLocale(String locale) | |||
| { | |||
| public void setLocale(String locale) { | |||
| StringTokenizer st = new StringTokenizer(locale, " \t\n\r\f,"); | |||
| try { | |||
| language = st.nextToken(); | |||
| @@ -169,12 +163,10 @@ public class Tstamp extends Task { | |||
| getLocation()); | |||
| } | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| country = ""; | |||
| } | |||
| } | |||
| catch (NoSuchElementException e) { | |||
| } catch (NoSuchElementException e) { | |||
| throw new BuildException("bad locale format", e, | |||
| getLocation()); | |||
| } | |||
| @@ -207,8 +199,7 @@ public class Tstamp extends Task { | |||
| field = unit.getCalendarField(); | |||
| } | |||
| public void execute(Project project, Date date, Location location) | |||
| { | |||
| public void execute(Project project, Date date, Location location) { | |||
| if (propertyName == null) { | |||
| throw new BuildException("property attribute must be provided", | |||
| location); | |||
| @@ -222,12 +213,10 @@ public class Tstamp extends Task { | |||
| SimpleDateFormat sdf; | |||
| if (language == null) { | |||
| sdf = new SimpleDateFormat(pattern); | |||
| } | |||
| else if (variant == null) { | |||
| } else if (variant == null) { | |||
| sdf = new SimpleDateFormat(pattern, | |||
| new Locale(language, country)); | |||
| } | |||
| else { | |||
| } else { | |||
| sdf = new SimpleDateFormat(pattern, | |||
| new Locale(language, country, | |||
| variant)); | |||
| @@ -97,8 +97,7 @@ public class Untar extends Expand { | |||
| if (tis != null) { | |||
| try { | |||
| tis.close(); | |||
| } | |||
| catch (IOException e) {} | |||
| } catch (IOException e) {} | |||
| } | |||
| } | |||
| } | |||
| @@ -128,8 +128,7 @@ public class War extends Jar { | |||
| } | |||
| protected void initZipOutputStream(ZipOutputStream zOut) | |||
| throws IOException, BuildException | |||
| { | |||
| throws IOException, BuildException { | |||
| // If no webxml file is specified, it's an error. | |||
| if (deploymentDescriptor == null && !isInUpdateMode()) { | |||
| throw new BuildException("webxml attribute is required", location); | |||
| @@ -139,8 +138,7 @@ public class War extends Jar { | |||
| } | |||
| protected void zipFile(File file, ZipOutputStream zOut, String vPath) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| // If the file being added is WEB-INF/web.xml, we warn if it's | |||
| // not the one specified in the "webxml" attribute - or if | |||
| // it's being added twice, meaning the same file is specified | |||
| @@ -454,8 +454,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||
| configureLiaison(stylesheet); | |||
| liaison.transform(inFile, outFile); | |||
| } | |||
| } | |||
| 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); | |||
| @@ -282,22 +282,18 @@ public class Zip extends MatchingTask { | |||
| addingNewFiles = true; | |||
| doUpdate = doUpdate && zipFile.exists(); | |||
| if (doUpdate) | |||
| { | |||
| if (doUpdate) { | |||
| FileUtils fileUtils = FileUtils.newFileUtils(); | |||
| renamedFile = | |||
| fileUtils.createTempFile("zip", ".tmp", | |||
| fileUtils.getParentFile(zipFile)); | |||
| try | |||
| { | |||
| try { | |||
| if (!zipFile.renameTo(renamedFile)) { | |||
| throw new BuildException("Unable to rename old file to " | |||
| + "temporary file"); | |||
| } | |||
| } | |||
| catch (SecurityException e) | |||
| { | |||
| } catch (SecurityException e) { | |||
| throw new BuildException("Not allowed to rename old file to " | |||
| + "temporary file"); | |||
| } | |||
| @@ -369,8 +365,7 @@ public class Zip extends MatchingTask { | |||
| ZipFileSet oldFiles = new ZipFileSet(); | |||
| oldFiles.setSrc(renamedFile); | |||
| for (int i = 0; i < addedFiles.size(); i++) | |||
| { | |||
| for (int i = 0; i < addedFiles.size(); i++) { | |||
| PatternSet.NameEntry ne = oldFiles.createExclude(); | |||
| ne.setName((String) addedFiles.elementAt(i)); | |||
| } | |||
| @@ -485,14 +480,11 @@ public class Zip extends MatchingTask { | |||
| } | |||
| for (int i = 0; i < files.length; i++) { | |||
| File f = new File(thisBaseDir, files[i]); | |||
| if (fullpath.length() > 0) | |||
| { | |||
| if (fullpath.length() > 0) { | |||
| // Add this file at the specified location. | |||
| addParentDirs(null, fullpath, zOut, ""); | |||
| zipFile(f, zOut, fullpath); | |||
| } | |||
| else | |||
| { | |||
| } else { | |||
| // Add this file with the specified prefix. | |||
| String name = files[i].replace(File.separatorChar, '/'); | |||
| addParentDirs(thisBaseDir, name, zOut, prefix); | |||
| @@ -504,8 +496,7 @@ public class Zip extends MatchingTask { | |||
| protected void addZipEntries(ZipFileSet fs, DirectoryScanner ds, | |||
| ZipOutputStream zOut, String prefix, | |||
| String fullpath) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| log("adding zip entries: " + fullpath, Project.MSG_VERBOSE); | |||
| if (prefix.length() > 0 && fullpath.length() > 0) { | |||
| @@ -546,13 +537,11 @@ public class Zip extends MatchingTask { | |||
| } | |||
| protected void initZipOutputStream(ZipOutputStream zOut) | |||
| throws IOException, BuildException | |||
| { | |||
| throws IOException, BuildException { | |||
| } | |||
| protected void finalizeZipOutputStream(ZipOutputStream zOut) | |||
| throws IOException, BuildException | |||
| { | |||
| throws IOException, BuildException { | |||
| } | |||
| /** | |||
| @@ -603,8 +592,7 @@ public class Zip extends MatchingTask { | |||
| * @exception BuildException if it likes | |||
| */ | |||
| protected boolean isUpToDate(FileScanner[] scanners, File zipFile) | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| String[][] fileNames = grabFileNames(scanners); | |||
| File[] files = grabFiles(scanners, fileNames); | |||
| if (files.length == 0) { | |||
| @@ -676,8 +664,7 @@ public class Zip extends MatchingTask { | |||
| } | |||
| protected void zipDir(File dir, ZipOutputStream zOut, String vPath) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| if (addedDirs.get(vPath) != null) { | |||
| // don't add directories we've already added. | |||
| // no warning if we try, it is harmless in and of itself | |||
| @@ -706,30 +693,22 @@ public class Zip extends MatchingTask { | |||
| protected void zipFile(InputStream in, ZipOutputStream zOut, String vPath, | |||
| long lastModified, File file) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| if (entries.contains(vPath)) { | |||
| if (duplicate.equals("preserve")) | |||
| { | |||
| if (duplicate.equals("preserve")) { | |||
| log(vPath + " already added, skipping", Project.MSG_INFO); | |||
| return; | |||
| } | |||
| else if (duplicate.equals("fail")) | |||
| { | |||
| } else if (duplicate.equals("fail")) { | |||
| throw new BuildException("Duplicate file " + vPath | |||
| + " was found and the duplicate " | |||
| + "attribute is 'fail'."); | |||
| } | |||
| else | |||
| { | |||
| } else { | |||
| // duplicate equal to add, so we continue | |||
| log("duplicate file " + vPath | |||
| + " found, adding.", Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| else | |||
| { | |||
| } else { | |||
| log("adding entry " + vPath, Project.MSG_VERBOSE); | |||
| } | |||
| @@ -794,8 +773,7 @@ public class Zip extends MatchingTask { | |||
| } | |||
| protected void zipFile(File file, ZipOutputStream zOut, String vPath) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| if (file.equals(zipFile)) { | |||
| throw new BuildException("A zip file cannot include itself", | |||
| location); | |||
| @@ -111,8 +111,7 @@ public class CompilerAdapterFactory { | |||
| compilerType.equalsIgnoreCase("javac1.2")) { | |||
| if (isClassicCompilerSupported) { | |||
| return new Javac12(); | |||
| } | |||
| else { | |||
| } else { | |||
| throw new BuildException("This version of java does " | |||
| + "not support the classic compiler"); | |||
| } | |||
| @@ -131,8 +130,7 @@ public class CompilerAdapterFactory { | |||
| task.log("Modern compiler not found - looking for " | |||
| + "classic compiler", Project.MSG_WARN); | |||
| return new Javac12(); | |||
| } | |||
| else { | |||
| } else { | |||
| throw new BuildException("Unable to find a javac compiler;\n" | |||
| + "com.sun.tools.javac.Main is not on the classpath.\n" | |||
| + "Perhaps JAVA_HOME does not point to the JDK"); | |||
| @@ -100,15 +100,13 @@ public class Javac12 extends DefaultCompilerAdapter { | |||
| (Boolean) compile.invoke(compiler, | |||
| new Object[] {cmd.getArguments()}); | |||
| return ok.booleanValue(); | |||
| } | |||
| catch (ClassNotFoundException ex) { | |||
| } catch (ClassNotFoundException ex) { | |||
| throw new BuildException("Cannot use classic compiler, as it is " | |||
| + "not available. A common solution is " | |||
| + "to set the environment variable" | |||
| + " JAVA_HOME to your jdk directory.", | |||
| location); | |||
| } | |||
| catch (Exception ex) { | |||
| } catch (Exception ex) { | |||
| if (ex instanceof BuildException) { | |||
| throw (BuildException) ex; | |||
| } else { | |||
| @@ -88,15 +88,13 @@ public class Kjc extends DefaultCompilerAdapter { | |||
| (Boolean) compile.invoke(null, | |||
| new Object[] {cmd.getArguments()}); | |||
| return ok.booleanValue(); | |||
| } | |||
| catch (ClassNotFoundException ex) { | |||
| } catch (ClassNotFoundException ex) { | |||
| throw new BuildException("Cannot use kjc compiler, as it is not " | |||
| + "available. A common solution is to " | |||
| + "set the environment variable CLASSPATH " | |||
| + "to your kjc archive (kjc.jar).", | |||
| location); | |||
| } | |||
| catch (Exception ex) { | |||
| } catch (Exception ex) { | |||
| if (ex instanceof BuildException) { | |||
| throw (BuildException) ex; | |||
| } else { | |||
| @@ -147,14 +147,11 @@ class ChangeLogParser { | |||
| m_comment = m_comment.substring(0, end); | |||
| saveEntry(); | |||
| m_status = GET_FILE; | |||
| } | |||
| else if (line.startsWith("----------------------------")) { | |||
| } else if (line.startsWith("----------------------------")) { | |||
| final int end = m_comment.length() - lineSeparator.length(); //was -1 | |||
| m_comment = m_comment.substring(0, end); | |||
| m_status = GET_PREVIOUS_REV; | |||
| } | |||
| else | |||
| { | |||
| } else { | |||
| m_comment += line + lineSeparator; | |||
| } | |||
| } | |||
| @@ -180,8 +177,7 @@ class ChangeLogParser { | |||
| if (line.startsWith("revision")) { | |||
| m_revision = line.substring(9); | |||
| m_status = GET_DATE; | |||
| } | |||
| else if (line.startsWith("======")) { | |||
| } else if (line.startsWith("======")) { | |||
| //There was no revisions in this changelog | |||
| //entry so lets move unto next file | |||
| m_status = GET_FILE; | |||
| @@ -275,8 +275,7 @@ public class EchoProperties extends Task { | |||
| *@param header prepend this header to the property output | |||
| */ | |||
| protected void jdk10SaveProperties(Properties props, OutputStream os, | |||
| String header) | |||
| { | |||
| String header) { | |||
| props.save(os, header); | |||
| } | |||
| } | |||
| @@ -321,13 +321,7 @@ public class Javah extends Task { | |||
| com.sun.tools.javah.Main main | |||
| = new com.sun.tools.javah.Main(cmd.getArguments()); | |||
| main.run(); | |||
| } | |||
| //catch (ClassNotFoundException ex) { | |||
| // throw new BuildException("Cannot use javah because it is not available"+ | |||
| // " A common solution is to set the environment variable"+ | |||
| // " JAVA_HOME to your jdk directory.", location); | |||
| //} | |||
| catch (Exception ex) { | |||
| } catch (Exception ex) { | |||
| if (ex instanceof BuildException) { | |||
| throw (BuildException) ex; | |||
| } else { | |||
| @@ -146,8 +146,7 @@ import java.text.DecimalFormat; | |||
| * @author Jeremy Mawson <a href="mailto:jem@loftinspace.com.au">jem@loftinspace.com.au</a> | |||
| * @author Erik Hatcher <a href="mailto:ehatcher@apache.org">ehatcher@apache.org</a> | |||
| */ | |||
| public class PropertyFile extends Task | |||
| { | |||
| public class PropertyFile extends Task { | |||
| /* ======================================================================== | |||
| * | |||
| @@ -180,38 +179,31 @@ public class PropertyFile extends Task | |||
| * Methods | |||
| */ | |||
| public void execute() throws BuildException | |||
| { | |||
| public void execute() throws BuildException { | |||
| checkParameters(); | |||
| readFile(); | |||
| executeOperation(); | |||
| writeFile(); | |||
| } | |||
| public Entry createEntry() | |||
| { | |||
| public Entry createEntry() { | |||
| Entry e = new Entry(); | |||
| entries.addElement(e); | |||
| return e; | |||
| } | |||
| private void executeOperation() throws BuildException | |||
| { | |||
| for (Enumeration e = entries.elements(); e.hasMoreElements();) | |||
| { | |||
| private void executeOperation() throws BuildException { | |||
| for (Enumeration e = entries.elements(); e.hasMoreElements();) { | |||
| Entry entry = (Entry) e.nextElement(); | |||
| entry.executeOn(properties); | |||
| } | |||
| } | |||
| private void readFile() throws BuildException | |||
| { | |||
| private void readFile() throws BuildException { | |||
| // Create the PropertyFile | |||
| properties = new Properties(); | |||
| try | |||
| { | |||
| if (propertyfile.exists()) | |||
| { | |||
| try { | |||
| if (propertyfile.exists()) { | |||
| log("Updating property file: " | |||
| + propertyfile.getAbsolutePath()); | |||
| FileInputStream fis = null; | |||
| @@ -224,9 +216,7 @@ public class PropertyFile extends Task | |||
| fis.close(); | |||
| } | |||
| } | |||
| } | |||
| else | |||
| { | |||
| } else { | |||
| log("Creating new property file: " | |||
| + propertyfile.getAbsolutePath()); | |||
| FileOutputStream out = null; | |||
| @@ -244,29 +234,23 @@ public class PropertyFile extends Task | |||
| } | |||
| } | |||
| private void checkParameters() throws BuildException | |||
| { | |||
| if (!checkParam(propertyfile)) | |||
| { | |||
| private void checkParameters() throws BuildException { | |||
| if (!checkParam(propertyfile)) { | |||
| throw new BuildException("file token must not be null.", location); | |||
| } | |||
| } | |||
| public void setFile(File file) | |||
| { | |||
| public void setFile(File file) { | |||
| propertyfile = file; | |||
| } | |||
| public void setComment(String hdr) | |||
| { | |||
| public void setComment(String hdr) { | |||
| comment = hdr; | |||
| } | |||
| private void writeFile() throws BuildException | |||
| { | |||
| private void writeFile() throws BuildException { | |||
| BufferedOutputStream bos = null; | |||
| try | |||
| { | |||
| try { | |||
| bos = new BufferedOutputStream(new FileOutputStream(propertyfile)); | |||
| // Properties.store is not available in JDK 1.1 | |||
| @@ -287,8 +271,7 @@ public class PropertyFile extends Task | |||
| throw new BuildException(iae, location); | |||
| } catch (IOException ioe) { | |||
| throw new BuildException(ioe, location); | |||
| } | |||
| finally { | |||
| } finally { | |||
| if (bos != null) { | |||
| try { | |||
| bos.close(); | |||
| @@ -300,13 +283,11 @@ public class PropertyFile extends Task | |||
| /* | |||
| * Returns whether the given parameter has been defined. | |||
| */ | |||
| private boolean checkParam(String param) | |||
| { | |||
| private boolean checkParam(String param) { | |||
| return !((param == null) || (param.equals("null"))); | |||
| } | |||
| private boolean checkParam(File param) | |||
| { | |||
| private boolean checkParam(File param) { | |||
| return !(param == null); | |||
| } | |||
| @@ -314,8 +295,7 @@ public class PropertyFile extends Task | |||
| * Instance of this class represents nested elements of | |||
| * a task propertyfile. | |||
| */ | |||
| public static class Entry | |||
| { | |||
| public static class Entry { | |||
| private final static int DEFAULT_INT_VALUE = 0; | |||
| private final static String DEFAULT_DATE_VALUE = "now"; | |||
| private final static String DEFAULT_STRING_VALUE = ""; | |||
| @@ -328,28 +308,22 @@ public class PropertyFile extends Task | |||
| private String pattern = null; | |||
| private int field = Calendar.DATE; | |||
| public void setKey(String value) | |||
| { | |||
| public void setKey(String value) { | |||
| this.key = value; | |||
| } | |||
| public void setValue(String value) | |||
| { | |||
| public void setValue(String value) { | |||
| this.value = value; | |||
| } | |||
| public void setOperation(Operation value) | |||
| { | |||
| public void setOperation(Operation value) { | |||
| this.operation = Operation.toOperation(value.getValue()); | |||
| } | |||
| public void setType(Type value) | |||
| { | |||
| public void setType(Type value) { | |||
| this.type = Type.toType(value.getValue()); | |||
| } | |||
| public void setDefault(String value) | |||
| { | |||
| public void setDefault(String value) { | |||
| this.defaultValue = value; | |||
| } | |||
| public void setPattern(String value) | |||
| { | |||
| public void setPattern(String value) { | |||
| this.pattern = value; | |||
| } | |||
| @@ -360,27 +334,19 @@ public class PropertyFile extends Task | |||
| field = unit.getCalendarField(); | |||
| } | |||
| protected void executeOn(Properties props) throws BuildException | |||
| { | |||
| protected void executeOn(Properties props) throws BuildException { | |||
| checkParameters(); | |||
| // type may be null because it wasn't set | |||
| String oldValue = (String) props.get(key); | |||
| try { | |||
| if (type == Type.INTEGER_TYPE) | |||
| { | |||
| if (type == Type.INTEGER_TYPE) { | |||
| executeInteger(oldValue); | |||
| } | |||
| else if (type == Type.DATE_TYPE) | |||
| { | |||
| } else if (type == Type.DATE_TYPE) { | |||
| executeDate(oldValue); | |||
| } | |||
| else if (type == Type.STRING_TYPE) | |||
| { | |||
| } else if (type == Type.STRING_TYPE) { | |||
| executeString(oldValue); | |||
| } | |||
| else | |||
| { | |||
| } else { | |||
| throw new BuildException("Unknown operation type: " | |||
| + type); | |||
| } | |||
| @@ -405,8 +371,7 @@ public class PropertyFile extends Task | |||
| * <code>null</code> if the <code>key</code> was | |||
| * not contained in the property file. | |||
| */ | |||
| private void executeDate(String oldValue) throws BuildException | |||
| { | |||
| private void executeDate(String oldValue) throws BuildException { | |||
| Calendar currentValue = Calendar.getInstance(); | |||
| if (pattern == null) { | |||
| @@ -421,12 +386,12 @@ public class PropertyFile extends Task | |||
| if ("now".equals(currentStringValue)) { | |||
| currentValue.setTime(new Date()); | |||
| } | |||
| else { | |||
| } else { | |||
| try { | |||
| currentValue.setTime(fmt.parse(currentStringValue)); | |||
| } catch (ParseException pe) { | |||
| // swallow | |||
| } | |||
| catch (ParseException pe) { /* swollow */ } | |||
| } | |||
| if (operation != Operation.EQUALS_OPER) { | |||
| @@ -436,8 +401,7 @@ public class PropertyFile extends Task | |||
| if (operation == Operation.DECREMENT_OPER) { | |||
| offset = -1 * offset; | |||
| } | |||
| } | |||
| catch (NumberFormatException e) { | |||
| } catch (NumberFormatException e) { | |||
| throw new BuildException("Value not an integer on " + key); | |||
| } | |||
| currentValue.add(field, offset); | |||
| @@ -454,8 +418,7 @@ public class PropertyFile extends Task | |||
| * <code>null</code> if the <code>key</code> was | |||
| * not contained in the property file. | |||
| */ | |||
| private void executeInteger(String oldValue) throws BuildException | |||
| { | |||
| private void executeInteger(String oldValue) throws BuildException { | |||
| int currentValue = DEFAULT_INT_VALUE; | |||
| int newValue = DEFAULT_INT_VALUE; | |||
| @@ -464,25 +427,27 @@ public class PropertyFile extends Task | |||
| : new DecimalFormat(); | |||
| try { | |||
| currentValue = fmt.parse(getCurrentValue(oldValue)).intValue(); | |||
| } catch (NumberFormatException nfe) { | |||
| // swallow | |||
| } catch (ParseException pe) { | |||
| // swallow | |||
| } | |||
| catch (NumberFormatException nfe) { /* swollow */ } | |||
| catch (ParseException pe) { /* swollow */ } | |||
| if (operation == Operation.EQUALS_OPER) { | |||
| newValue = currentValue; | |||
| } | |||
| else { | |||
| } else { | |||
| int operationValue = 1; | |||
| try { | |||
| operationValue = fmt.parse(value).intValue(); | |||
| } catch (NumberFormatException nfe) { | |||
| // swallow | |||
| } catch (ParseException pe) { | |||
| // swallow | |||
| } | |||
| catch (NumberFormatException nfe) { /* swollow */ } | |||
| catch (ParseException pe) { /* swollow */ } | |||
| if (operation == Operation.INCREMENT_OPER) { | |||
| newValue = currentValue + operationValue; | |||
| } | |||
| else if (operation == Operation.DECREMENT_OPER) { | |||
| } else if (operation == Operation.DECREMENT_OPER) { | |||
| newValue = currentValue - operationValue; | |||
| } | |||
| } | |||
| @@ -497,8 +462,7 @@ public class PropertyFile extends Task | |||
| * <code>null</code> if the <code>key</code> was | |||
| * not contained in the property file. | |||
| */ | |||
| private void executeString(String oldValue) throws BuildException | |||
| { | |||
| private void executeString(String oldValue) throws BuildException { | |||
| String newValue = DEFAULT_STRING_VALUE; | |||
| String currentValue = getCurrentValue(oldValue); | |||
| @@ -509,8 +473,7 @@ public class PropertyFile extends Task | |||
| if (operation == Operation.EQUALS_OPER) { | |||
| newValue = currentValue; | |||
| } | |||
| else if (operation == Operation.INCREMENT_OPER) { | |||
| } else if (operation == Operation.INCREMENT_OPER) { | |||
| newValue = currentValue + value; | |||
| } | |||
| value = newValue; | |||
| @@ -524,17 +487,20 @@ public class PropertyFile extends Task | |||
| private void checkParameters() throws BuildException { | |||
| if (type == Type.STRING_TYPE && | |||
| operation == Operation.DECREMENT_OPER) { | |||
| throw new BuildException("- is not suported for string properties (key:" + key + ")"); | |||
| throw new BuildException("- is not suported for string " | |||
| + "properties (key:" + key + ")"); | |||
| } | |||
| if (value == null && defaultValue == null) { | |||
| throw new BuildException("value and/or default must be specified (key:" + key + ")"); | |||
| throw new BuildException("value and/or default must be " | |||
| + "specified (key:" + key + ")"); | |||
| } | |||
| if (key == null) { | |||
| throw new BuildException("key is mandatory"); | |||
| } | |||
| if (type == Type.STRING_TYPE && | |||
| pattern != null) { | |||
| throw new BuildException("pattern is not suported for string properties (key:" + key + ")"); | |||
| throw new BuildException("pattern is not suported for string " | |||
| + "properties (key:" + key + ")"); | |||
| } | |||
| } | |||
| @@ -572,8 +538,7 @@ public class PropertyFile extends Task | |||
| if (value != null && defaultValue != null && oldValue == null) { | |||
| ret = defaultValue; | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| ret = (oldValue == null) ? defaultValue : oldValue; | |||
| } | |||
| @@ -597,8 +562,7 @@ public class PropertyFile extends Task | |||
| public static int toOperation(String oper) { | |||
| if ("+".equals(oper)) { | |||
| return INCREMENT_OPER; | |||
| } | |||
| else if ("-".equals(oper)) { | |||
| } else if ("-".equals(oper)) { | |||
| return DECREMENT_OPER; | |||
| } | |||
| return EQUALS_OPER; | |||
| @@ -622,8 +586,7 @@ public class PropertyFile extends Task | |||
| public static int toType(String type) { | |||
| if ("int".equals(type)) { | |||
| return INTEGER_TYPE; | |||
| } | |||
| else if ("date".equals(type)) { | |||
| } else if ("date".equals(type)) { | |||
| return DATE_TYPE; | |||
| } | |||
| return STRING_TYPE; | |||
| @@ -145,16 +145,14 @@ public class Rpm extends Task { | |||
| if (error == null && output == null) { | |||
| streamhandler = new LogStreamHandler(this, Project.MSG_INFO, | |||
| Project.MSG_WARN); | |||
| } | |||
| else { | |||
| } else { | |||
| if (output != null) { | |||
| try { | |||
| outputstream = new PrintStream(new BufferedOutputStream(new FileOutputStream(output))); | |||
| } catch (IOException e) { | |||
| throw new BuildException(e, location); | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| outputstream = new LogOutputStream(this, Project.MSG_INFO); | |||
| } | |||
| if (error != null) { | |||
| @@ -163,8 +161,7 @@ public class Rpm extends Task { | |||
| } catch (IOException e) { | |||
| throw new BuildException(e, location); | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| errorstream = new LogOutputStream(this, Project.MSG_WARN); | |||
| } | |||
| streamhandler = new PumpStreamHandler(outputstream, errorstream); | |||
| @@ -254,8 +254,7 @@ public class XMLValidateTask extends Task { | |||
| if (file.exists() && file.canRead() && file.isFile()) { | |||
| doValidate(file); | |||
| fileProcessed++; | |||
| } | |||
| else { | |||
| } else { | |||
| String errorMsg = "File " + file + " cannot be read"; | |||
| if (failOnError) { | |||
| throw new BuildException(errorMsg); | |||
| @@ -479,8 +478,7 @@ public class XMLValidateTask extends Task { | |||
| } | |||
| private class LocalResolver | |||
| implements EntityResolver | |||
| { | |||
| implements EntityResolver { | |||
| private Hashtable fileDTDs = new Hashtable(); | |||
| private Hashtable resourceDTDs = new Hashtable(); | |||
| private Hashtable urlDTDs = new Hashtable(); | |||
| @@ -521,8 +519,7 @@ public class XMLValidateTask extends Task { | |||
| } | |||
| public InputSource resolveEntity(String publicId, String systemId) | |||
| throws SAXException | |||
| { | |||
| throws SAXException { | |||
| File dtdFile = (File) fileDTDs.get(publicId); | |||
| if (dtdFile != null) { | |||
| try { | |||
| @@ -350,8 +350,7 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler { | |||
| log("error procession stream , null pointer exception", Project.MSG_ERR); | |||
| npe.printStackTrace(); | |||
| throw new BuildException(npe.getClass().getName()); | |||
| } // end of catch | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| log("error procession stream " + e.getMessage(), Project.MSG_ERR); | |||
| throw new BuildException(e.getMessage()); | |||
| } // end of try-catch | |||
| @@ -133,8 +133,7 @@ public abstract class ClearCase extends Task { | |||
| exe.setWorkingDirectory(aProj.getBaseDir()); | |||
| exe.setCommandline(cmd.getCommandline()); | |||
| return exe.execute(); | |||
| } | |||
| catch (java.io.IOException e) { | |||
| } catch (java.io.IOException e) { | |||
| throw new BuildException(e, location); | |||
| } | |||
| } | |||
| @@ -231,8 +231,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
| if (borlandDD.exists()) { | |||
| log("Borland specific file found " + borlandDD, Project.MSG_VERBOSE); | |||
| ejbFiles.put(META_DIR + BAS_DD, borlandDD); | |||
| } | |||
| else { | |||
| } else { | |||
| log("Unable to locate borland deployment descriptor. It was expected to be in " + | |||
| borlandDD.getPath(), Project.MSG_WARN); | |||
| return; | |||
| @@ -265,8 +264,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
| Commandline.Argument arguments = javaTask.createArg(); | |||
| arguments.setLine(args); | |||
| Path classpath = getCombinedClasspath(); | |||
| if (classpath != null) | |||
| { | |||
| if (classpath != null) { | |||
| javaTask.setClasspath(classpath); | |||
| javaTask.setFork(true); | |||
| } | |||
| @@ -274,8 +272,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
| log("Calling " + VERIFY + " for " + sourceJar.toString(), | |||
| Project.MSG_VERBOSE); | |||
| javaTask.execute(); | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| //TO DO : delete the file if it is not a valid file. | |||
| String msg = "Exception while calling " + VERIFY + " Details: " | |||
| + e.toString(); | |||
| @@ -307,8 +304,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
| } | |||
| gentask.setTaskName("generate client"); | |||
| gentask.execute(); | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| //TO DO : delete the file if it is not a valid file. | |||
| String msg = "Exception while calling " + VERIFY + " Details: " | |||
| + e.toString(); | |||
| @@ -363,8 +359,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
| + result + ")"; | |||
| throw new BuildException(msg, getTask().getLocation()); | |||
| } | |||
| } | |||
| catch (java.io.IOException e) { | |||
| } catch (java.io.IOException e) { | |||
| log("java2iiop exception :" + e.getMessage(), Project.MSG_ERR); | |||
| throw new BuildException(e, getTask().getLocation()); | |||
| } | |||
| @@ -439,8 +434,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
| * @param is | |||
| * @exception java.io.IOException | |||
| */ | |||
| public void setProcessOutputStream(InputStream is) throws IOException | |||
| { | |||
| public void setProcessOutputStream(InputStream is) throws IOException { | |||
| try { | |||
| BufferedReader reader = new BufferedReader(new InputStreamReader(is)); | |||
| String javafile; | |||
| @@ -455,8 +449,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
| } // end of if () | |||
| } // end of while () | |||
| reader.close(); | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| String msg = "Exception while parsing java2iiop output. Details: " + e.toString(); | |||
| throw new BuildException(msg, e); | |||
| } | |||
| @@ -466,8 +459,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
| * @param param1 | |||
| * @exception java.io.IOException | |||
| */ | |||
| public void setProcessErrorStream(InputStream is) throws IOException | |||
| { | |||
| public void setProcessErrorStream(InputStream is) throws IOException { | |||
| BufferedReader reader = new BufferedReader(new InputStreamReader(is)); | |||
| String s = reader.readLine(); | |||
| if (s != null) { | |||
| @@ -80,8 +80,7 @@ import org.apache.tools.ant.types.Reference; | |||
| * | |||
| * @ant.task name="blgenclient" category="ejb" | |||
| */ | |||
| public class BorlandGenerateClient extends Task | |||
| { | |||
| public class BorlandGenerateClient extends Task { | |||
| final static String JAVA_MODE = "java"; | |||
| final static String FORK_MODE = "fork"; | |||
| @@ -118,8 +117,7 @@ public class BorlandGenerateClient extends Task | |||
| public void setClasspath(Path classpath) { | |||
| if (this.classpath == null) { | |||
| this.classpath = classpath; | |||
| } | |||
| else { | |||
| } else { | |||
| this.classpath.append(classpath); | |||
| } | |||
| } | |||
| @@ -167,8 +165,7 @@ public class BorlandGenerateClient extends Task | |||
| if (mode.equalsIgnoreCase(FORK_MODE)) { | |||
| executeFork(); | |||
| } // end of if () | |||
| else { | |||
| } else { | |||
| executeJava(); | |||
| } // end of else | |||
| } | |||
| @@ -207,8 +204,7 @@ public class BorlandGenerateClient extends Task | |||
| log("Calling EJBUtilities", Project.MSG_VERBOSE); | |||
| execTask.execute(); | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| // Have to catch this because of the semantics of calling main() | |||
| String msg = "Exception while calling generateclient Details: " + e.toString(); | |||
| throw new BuildException(msg, e); | |||
| @@ -242,8 +238,7 @@ public class BorlandGenerateClient extends Task | |||
| log("Calling java2iiop", Project.MSG_VERBOSE); | |||
| execTask.execute(); | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| // Have to catch this because of the semantics of calling main() | |||
| String msg = "Exception while calling generateclient Details: " | |||
| + e.toString(); | |||
| @@ -125,8 +125,7 @@ public class DDCreatorHelper { | |||
| String serName = null; | |||
| if (extIndex != -1) { | |||
| serName = descriptorName.substring(0, extIndex) + ".ser"; | |||
| } | |||
| else { | |||
| } else { | |||
| serName = descriptorName + ".ser"; | |||
| } | |||
| File serFile = new File(generatedFilesDirectory, serName); | |||
| @@ -141,8 +140,7 @@ public class DDCreatorHelper { | |||
| descriptorFile.getPath()}; | |||
| try { | |||
| weblogic.ejb.utils.DDCreator.main(args); | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| // there was an exception - run with no exit to get proper error | |||
| String[] newArgs = {"-d", generatedFilesDirectory.getPath(), | |||
| "-outputfile", serFile.getName(), | |||
| @@ -188,8 +188,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
| } | |||
| public InputSource resolveEntity(String publicId, String systemId) | |||
| throws SAXException | |||
| { | |||
| throws SAXException { | |||
| this.publicId = publicId; | |||
| File dtdFile = (File) fileDTDs.get(publicId); | |||
| @@ -273,20 +272,15 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
| currentText = ""; | |||
| if (name.equals(EJB_REF)) { | |||
| inEJBRef = true; | |||
| } | |||
| else if (parseState == STATE_LOOKING_EJBJAR && name.equals(EJB_JAR)) { | |||
| } else if (parseState == STATE_LOOKING_EJBJAR && name.equals(EJB_JAR)) { | |||
| parseState = STATE_IN_EJBJAR; | |||
| } | |||
| else if (parseState == STATE_IN_EJBJAR && name.equals(ENTERPRISE_BEANS)) { | |||
| } else if (parseState == STATE_IN_EJBJAR && name.equals(ENTERPRISE_BEANS)) { | |||
| parseState = STATE_IN_BEANS; | |||
| } | |||
| else if (parseState == STATE_IN_BEANS && name.equals(SESSION_BEAN)) { | |||
| } else if (parseState == STATE_IN_BEANS && name.equals(SESSION_BEAN)) { | |||
| parseState = STATE_IN_SESSION; | |||
| } | |||
| else if (parseState == STATE_IN_BEANS && name.equals(ENTITY_BEAN)) { | |||
| } else if (parseState == STATE_IN_BEANS && name.equals(ENTITY_BEAN)) { | |||
| parseState = STATE_IN_ENTITY; | |||
| } | |||
| else if (parseState == STATE_IN_BEANS && name.equals(MESSAGE_BEAN)) { | |||
| } else if (parseState == STATE_IN_BEANS && name.equals(MESSAGE_BEAN)) { | |||
| parseState = STATE_IN_MESSAGE; | |||
| } | |||
| } | |||
| @@ -307,20 +301,15 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
| this.currentElement = ""; | |||
| if (name.equals(EJB_REF)) { | |||
| inEJBRef = false; | |||
| } | |||
| else if (parseState == STATE_IN_ENTITY && name.equals(ENTITY_BEAN)) { | |||
| } else if (parseState == STATE_IN_ENTITY && name.equals(ENTITY_BEAN)) { | |||
| parseState = STATE_IN_BEANS; | |||
| } | |||
| else if (parseState == STATE_IN_SESSION && name.equals(SESSION_BEAN)) { | |||
| } else if (parseState == STATE_IN_SESSION && name.equals(SESSION_BEAN)) { | |||
| parseState = STATE_IN_BEANS; | |||
| } | |||
| else if (parseState == STATE_IN_MESSAGE && name.equals(MESSAGE_BEAN)) { | |||
| } else if (parseState == STATE_IN_MESSAGE && name.equals(MESSAGE_BEAN)) { | |||
| parseState = STATE_IN_BEANS; | |||
| } | |||
| else if (parseState == STATE_IN_BEANS && name.equals(ENTERPRISE_BEANS)) { | |||
| } else if (parseState == STATE_IN_BEANS && name.equals(ENTERPRISE_BEANS)) { | |||
| parseState = STATE_IN_EJBJAR; | |||
| } | |||
| else if (parseState == STATE_IN_EJBJAR && name.equals(EJB_JAR)) { | |||
| } else if (parseState == STATE_IN_EJBJAR && name.equals(EJB_JAR)) { | |||
| parseState = STATE_LOOKING_EJBJAR; | |||
| } | |||
| } | |||
| @@ -229,13 +229,11 @@ public class EjbcHelper { | |||
| primaryKeyClassSource.lastModified() > classModificationTime) { | |||
| return true; | |||
| } | |||
| } | |||
| catch (Throwable descriptorLoadException) { | |||
| } catch (Throwable descriptorLoadException) { | |||
| System.out.println("Exception occurred reading " + descriptorFile.getName() + " - continuing"); | |||
| // any problems - just regenerate | |||
| return true; | |||
| } | |||
| finally { | |||
| } finally { | |||
| if (fis != null) { | |||
| fis.close(); | |||
| } | |||
| @@ -257,8 +255,7 @@ public class EjbcHelper { | |||
| if (isRegenRequired(descriptorFile)) { | |||
| System.out.println("Running ejbc for " + descriptorFile.getName()); | |||
| regenerateSupportClasses(descriptorFile); | |||
| } | |||
| else { | |||
| } else { | |||
| System.out.println(descriptorFile.getName() + " is up to date"); | |||
| } | |||
| manifest += "Name: " + descriptorName.replace('\\', '/') + "\nEnterprise-Bean: True\n\n"; | |||
| @@ -285,8 +282,7 @@ public class EjbcHelper { | |||
| try { | |||
| weblogic.ejbc.main(args); | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| // run with no exit for better reporting | |||
| String[] newArgs = getCommandLine(true, descriptorFile); | |||
| weblogic.ejbc.main(newArgs); | |||
| @@ -1208,8 +1208,7 @@ public class IPlanetEjbc { | |||
| return -1; | |||
| } | |||
| latestModified = Math.max(latestModified, modified); | |||
| } | |||
| else { | |||
| } else { | |||
| pkFile = null; | |||
| } | |||
| @@ -293,8 +293,7 @@ public class IPlanetEjbcTask extends Task { | |||
| } catch (SAXException e) { | |||
| String msg = "Unable to create a SAXParser: " + e.getMessage(); | |||
| throw new BuildException(msg, e, location); | |||
| } | |||
| catch (ParserConfigurationException e) { | |||
| } catch (ParserConfigurationException e) { | |||
| String msg = "Unable to create a SAXParser: " + e.getMessage(); | |||
| throw new BuildException(msg, e, location); | |||
| } | |||
| @@ -114,8 +114,7 @@ public class WeblogicTOPLinkDeploymentTool extends WeblogicDeploymentTool { | |||
| if (toplinkDD.exists()) { | |||
| ejbFiles.put(META_DIR + toplinkDescriptor, | |||
| toplinkDD); | |||
| } | |||
| else { | |||
| } else { | |||
| log("Unable to locate toplink deployment descriptor. It was expected to be in " + | |||
| toplinkDD.getPath(), Project.MSG_WARN); | |||
| } | |||
| @@ -117,8 +117,7 @@ public class VAJAntTool { | |||
| if (args.length >= 2 && args[1] instanceof String) { | |||
| String projectName = (String) args[1]; | |||
| info = loadBuildData(projectName); | |||
| } | |||
| else { | |||
| } else { | |||
| info = new VAJBuildInfo(); | |||
| } | |||
| @@ -209,8 +209,7 @@ public class VAJAntToolGUI extends Frame { | |||
| if (error == null) { | |||
| getMessageTextArea().append(lineSeparator + "BUILD SUCCESSFUL"); | |||
| } | |||
| else { | |||
| } else { | |||
| logException(error); | |||
| } | |||
| @@ -232,8 +231,7 @@ public class VAJAntToolGUI extends Frame { | |||
| if (nested != null) { | |||
| nested.printStackTrace(System.err); | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| error.printStackTrace(System.err); | |||
| } | |||
| } | |||
| @@ -339,8 +337,7 @@ public class VAJAntToolGUI extends Frame { | |||
| try { | |||
| getBuildInfo().updateTargetList(); | |||
| fillList(); | |||
| } | |||
| catch (Throwable fileNotFound) { | |||
| } catch (Throwable fileNotFound) { | |||
| handleException(fileNotFound); | |||
| getTargetList().removeAll(); | |||
| getBuildButton().setEnabled(false); | |||
| @@ -370,8 +367,7 @@ public class VAJAntToolGUI extends Frame { | |||
| if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) { | |||
| getMessageFrame().dispose(); | |||
| } | |||
| } | |||
| catch (Throwable exc) { | |||
| } catch (Throwable exc) { | |||
| handleException(exc); | |||
| } | |||
| } | |||
| @@ -390,8 +386,7 @@ public class VAJAntToolGUI extends Frame { | |||
| if (e.getSource() == VAJAntToolGUI.this.getTargetList()) { | |||
| getBuildInfo().setTarget(getTargetList().getSelectedItem()); | |||
| } | |||
| } | |||
| catch (Throwable exc) { | |||
| } catch (Throwable exc) { | |||
| handleException(exc); | |||
| } | |||
| } | |||
| @@ -432,8 +427,7 @@ public class VAJAntToolGUI extends Frame { | |||
| if (e.getSource() == VAJAntToolGUI.this.getMessageFrame()) { | |||
| getMessageFrame().dispose(); | |||
| } | |||
| } | |||
| catch (Throwable exc) { | |||
| } catch (Throwable exc) { | |||
| handleException(exc); | |||
| } | |||
| } | |||
| @@ -524,8 +518,7 @@ public class VAJAntToolGUI extends Frame { | |||
| try { | |||
| getMessageFrame().show(); | |||
| getBuildInfo().executeProject(logger); | |||
| } | |||
| catch (Throwable exc) { | |||
| } catch (Throwable exc) { | |||
| logger.logException(exc); | |||
| } | |||
| return; | |||
| @@ -1346,8 +1339,7 @@ public class VAJAntToolGUI extends Frame { | |||
| private void saveBuildInfo() { | |||
| try { | |||
| VAJAntTool.saveBuildData(getBuildInfo()); | |||
| } | |||
| catch (Throwable exc) { | |||
| } catch (Throwable exc) { | |||
| // This Exception occurs when you try to write into a versioned project | |||
| handleException(exc); | |||
| } | |||
| @@ -350,8 +350,7 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| Type[] importedTypes = getWorkspace().importData(importSpec); | |||
| if (importedTypes == null) { | |||
| throw new BuildException("Unable to import into Workspace!"); | |||
| } | |||
| else { | |||
| } else { | |||
| log(importedTypes.length + " types imported", MSG_DEBUG); | |||
| for (int i = 0; i < importedTypes.length; i++) { | |||
| log(importedTypes[i].getPackage().getName() | |||
| @@ -428,11 +427,9 @@ abstract class VAJLocalUtil implements VAJUtil{ | |||
| * @param fileType type of files (Source/Class/Resource) | |||
| * @param summaryLog buffer for logging | |||
| */ | |||
| private void addFilesToImport( | |||
| ImportCodeSpec spec, boolean doImport, | |||
| private void addFilesToImport(ImportCodeSpec spec, boolean doImport, | |||
| Vector files, String fileType, | |||
| StringBuffer summaryLog) | |||
| { | |||
| StringBuffer summaryLog) { | |||
| if (doImport) { | |||
| String[] fileArr = new String[files.size()]; | |||
| @@ -80,8 +80,7 @@ import org.apache.tools.ant.types.Path; | |||
| * @see org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool | |||
| * @see org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy | |||
| */ | |||
| public abstract class AbstractHotDeploymentTool implements HotDeploymentTool | |||
| { | |||
| public abstract class AbstractHotDeploymentTool implements HotDeploymentTool { | |||
| /** The parent task **/ | |||
| private ServerDeploy task; | |||
| @@ -69,8 +69,7 @@ import org.apache.tools.ant.taskdefs.Java; | |||
| * @see org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool | |||
| * @see org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy | |||
| */ | |||
| public class GenericHotDeploymentTool extends AbstractHotDeploymentTool | |||
| { | |||
| public class GenericHotDeploymentTool extends AbstractHotDeploymentTool { | |||
| /** A Java task used to run the deployment tool **/ | |||
| private Java java; | |||
| @@ -63,8 +63,7 @@ import org.apache.tools.ant.BuildException; | |||
| * @see org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool | |||
| * @see org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy | |||
| */ | |||
| public interface HotDeploymentTool | |||
| { | |||
| public interface HotDeploymentTool { | |||
| /** The delete action String **/ | |||
| public static final String ACTION_DELETE = "delete"; | |||
| @@ -241,11 +241,9 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements | |||
| action.equals(ACTION_UPDATE) || | |||
| action.equals("redeploy")) { | |||
| java.createArg().setLine("-a " + getTask().getSource()); | |||
| } | |||
| else if (action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY)) { | |||
| } else if (action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY)) { | |||
| java.createArg().setLine("-r " + getTask().getSource()); | |||
| } | |||
| else if (action.equals(ACTION_LIST)) { | |||
| } else if (action.equals(ACTION_LIST)) { | |||
| java.createArg().setValue("-l"); | |||
| } | |||
| } | |||
| @@ -74,8 +74,7 @@ import org.apache.tools.ant.Task; | |||
| * @see org.apache.tools.ant.taskdefs.optional.j2ee.GenericHotDeploymentTool | |||
| * @see org.apache.tools.ant.taskdefs.optional.j2ee.WebLogicHotDeploymentTool | |||
| */ | |||
| public class ServerDeploy extends Task | |||
| { | |||
| public class ServerDeploy extends Task { | |||
| /** The action to be performed. IE: "deploy", "delete", etc... **/ | |||
| private String action; | |||
| @@ -96,8 +96,7 @@ public class WebLogicHotDeploymentTool extends AbstractHotDeploymentTool impleme | |||
| * tools is executed. | |||
| * @exception org.apache.tools.ant.BuildException if the attributes are invalid or incomplete. | |||
| */ | |||
| public void deploy() | |||
| { | |||
| public void deploy() { | |||
| Java java = (Java) getTask().getProject().createTask("java"); | |||
| java.setFork(true); | |||
| java.setFailonerror(true); | |||
| @@ -219,8 +219,7 @@ public class JJTree extends Task { | |||
| if (process.execute() != 0) { | |||
| throw new BuildException("JJTree failed."); | |||
| } | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| throw new BuildException("Failed to launch JJTree", e); | |||
| } | |||
| } | |||
| @@ -224,8 +224,7 @@ public class JavaCC extends Task { | |||
| // use the directory containing the target as the output directory | |||
| if (outputDirectory == null) { | |||
| outputDirectory = new File(target.getParent()); | |||
| } | |||
| else if (!outputDirectory.isDirectory()) { | |||
| } else if (!outputDirectory.isDirectory()) { | |||
| throw new BuildException("Outputdir not a directory."); | |||
| } | |||
| cmdl.createArgument().setValue("-OUTPUT_DIRECTORY:" | |||
| @@ -281,8 +280,7 @@ public class JavaCC extends Task { | |||
| * file. | |||
| * | |||
| */ | |||
| private File getOutputJavaFile(File outputdir, File srcfile) | |||
| { | |||
| private File getOutputJavaFile(File outputdir, File srcfile) { | |||
| String path = srcfile.getPath(); | |||
| // Extract file's base-name | |||
| @@ -295,8 +293,7 @@ public class JavaCC extends Task { | |||
| int startExtn = path.lastIndexOf('.'); | |||
| if (startExtn != -1) { | |||
| path = path.substring(0, startExtn) + ".java"; | |||
| } | |||
| else { | |||
| } else { | |||
| path += ".java"; | |||
| } | |||
| @@ -228,17 +228,14 @@ public class JDependTask extends Task { | |||
| } | |||
| public void setFormat(FormatAttribute ea) | |||
| { | |||
| public void setFormat(FormatAttribute ea) { | |||
| format = ea.getValue(); | |||
| } | |||
| public static class FormatAttribute extends EnumeratedAttribute | |||
| { | |||
| public static class FormatAttribute extends EnumeratedAttribute { | |||
| private String [] formats = new String[]{"xml", "text"}; | |||
| public String[] getValues() | |||
| { | |||
| public String[] getValues() { | |||
| return formats; | |||
| } | |||
| } | |||
| @@ -324,8 +321,7 @@ public class JDependTask extends Task { | |||
| FileWriter fw; | |||
| try { | |||
| fw = new FileWriter(getOutputFile().getPath()); | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| String msg = "JDepend Failed when creating the output file: " | |||
| + e.getMessage(); | |||
| log(msg); | |||
| @@ -349,8 +345,7 @@ public class JDependTask extends Task { | |||
| } | |||
| try { | |||
| jdepend.addDirectory(f.getPath()); | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| String msg = "JDepend Failed when adding a source directory: " | |||
| + e.getMessage(); | |||
| log(msg); | |||
| @@ -86,8 +86,7 @@ class ConstantPool { | |||
| for (int i = 1; i < count; i++) { | |||
| byte type = data.readByte(); | |||
| types[i] = type; | |||
| switch (type) | |||
| { | |||
| switch (type) { | |||
| case UTF8 : | |||
| values[i] = data.readUTF(); | |||
| break; | |||
| @@ -112,8 +112,7 @@ public class JlinkTask extends MatchingTask { | |||
| public void setMergefiles(Path mergefiles) { | |||
| if (this.mergefiles == null) { | |||
| this.mergefiles = mergefiles; | |||
| } | |||
| else { | |||
| } else { | |||
| this.mergefiles.append(mergefiles); | |||
| } | |||
| } | |||
| @@ -135,8 +134,7 @@ public class JlinkTask extends MatchingTask { | |||
| public void setAddfiles(Path addfiles) { | |||
| if (this.addfiles == null) { | |||
| this.addfiles = addfiles; | |||
| } | |||
| else { | |||
| } else { | |||
| this.addfiles.append(addfiles); | |||
| } | |||
| } | |||
| @@ -110,8 +110,7 @@ import org.apache.tools.ant.types.Reference; | |||
| * @author <a href="mailto:jayglanville@home.com">J D Glanville</a> | |||
| * @since 1.5 | |||
| */ | |||
| public class JspC extends MatchingTask | |||
| { | |||
| public class JspC extends MatchingTask { | |||
| /* ------------------------------------------------------------ */ | |||
| private Path classpath; | |||
| private Path src; | |||
| @@ -226,23 +225,19 @@ public class JspC extends MatchingTask | |||
| return failOnError; | |||
| } | |||
| /* ------------------------------------------------------------ */ | |||
| public String getIeplugin() | |||
| { | |||
| public String getIeplugin() { | |||
| return iepluginid; | |||
| } | |||
| /** Set the ieplugin id */ | |||
| public void setIeplugin(String iepluginid_) | |||
| { | |||
| public void setIeplugin(String iepluginid_) { | |||
| iepluginid = iepluginid_; | |||
| } | |||
| /* ------------------------------------------------------------ */ | |||
| public boolean isMapped() | |||
| { | |||
| public boolean isMapped() { | |||
| return mapped; | |||
| } | |||
| /** set the mapped flag */ | |||
| public void setMapped(boolean mapped_) | |||
| { | |||
| public void setMapped(boolean mapped_) { | |||
| mapped = mapped_; | |||
| } | |||
| @@ -338,8 +333,7 @@ public class JspC extends MatchingTask | |||
| //demand create vector of filesets | |||
| if (webApp == null) { | |||
| webApp = webappParam; | |||
| } | |||
| else { | |||
| } else { | |||
| throw new BuildException("Only one webapp can be specified"); | |||
| } | |||
| } | |||
| @@ -429,12 +423,10 @@ public class JspC extends MatchingTask | |||
| + dest); | |||
| doCompilation(compiler); | |||
| } | |||
| else { | |||
| } else { | |||
| if (filecount == 0) { | |||
| log("there were no files to compile", Project.MSG_INFO); | |||
| } | |||
| else { | |||
| } else { | |||
| log("all files are up to date", Project.MSG_VERBOSE); | |||
| } | |||
| } | |||
| @@ -468,8 +460,7 @@ public class JspC extends MatchingTask | |||
| if (!compiler.execute()) { | |||
| if (failOnError) { | |||
| throw new BuildException(FAIL_MSG, location); | |||
| } | |||
| else { | |||
| } else { | |||
| log(FAIL_MSG, Project.MSG_ERR); | |||
| } | |||
| } | |||
| @@ -121,8 +121,7 @@ public class JspNameMangler implements JspMangler { | |||
| char firstChar = className.charAt(0); | |||
| if (Character.isJavaIdentifierStart(firstChar)) { | |||
| modifiedClassName.append(firstChar); | |||
| } | |||
| else { | |||
| } else { | |||
| modifiedClassName.append(mangleChar(firstChar)); | |||
| } | |||
| // this is the rest | |||
| @@ -130,8 +129,7 @@ public class JspNameMangler implements JspMangler { | |||
| char subChar = className.charAt(i); | |||
| if (Character.isJavaIdentifierPart(subChar)) { | |||
| modifiedClassName.append(subChar); | |||
| } | |||
| else { | |||
| } else { | |||
| modifiedClassName.append(mangleChar(subChar)); | |||
| } | |||
| } | |||
| @@ -150,8 +148,7 @@ public class JspNameMangler implements JspMangler { | |||
| String filename = jspFile.getName(); | |||
| if (filename.endsWith(".jsp")) { | |||
| className = filename.substring(0, filename.length() - 4); | |||
| } | |||
| else { | |||
| } else { | |||
| className = filename; | |||
| } | |||
| return className; | |||
| @@ -113,8 +113,7 @@ import java.util.StringTokenizer; | |||
| * | |||
| */ | |||
| public class WLJspc extends MatchingTask | |||
| { | |||
| public class WLJspc extends MatchingTask { | |||
| //TODO Test on other versions of weblogic | |||
| //TODO add more attributes to the task, to take care of all jspc options | |||
| //TODO Test on Unix | |||
| @@ -83,8 +83,7 @@ public abstract class DefaultJspCompilerAdapter | |||
| */ | |||
| protected void logAndAddFilesToCompile(JspC jspc, | |||
| Vector compileList, | |||
| Commandline cmd) | |||
| { | |||
| Commandline cmd) { | |||
| jspc.log("Compilation args: " + cmd.toString(), Project.MSG_VERBOSE); | |||
| StringBuffer niceSourceList = new StringBuffer("File"); | |||
| @@ -73,8 +73,7 @@ import java.io.File; | |||
| * @author steve loughran | |||
| * @since ant1.5 | |||
| */ | |||
| public class JasperC extends DefaultJspCompilerAdapter | |||
| { | |||
| public class JasperC extends DefaultJspCompilerAdapter { | |||
| /** | |||
| * our execute method | |||
| */ | |||
| @@ -90,8 +89,7 @@ public class JasperC extends DefaultJspCompilerAdapter | |||
| Java java = (Java) (getJspc().getProject()).createTask("java"); | |||
| if (getJspc().getClasspath() != null) { | |||
| java.setClasspath(getJspc().getClasspath()); | |||
| } | |||
| else { | |||
| } else { | |||
| java.setClasspath(Path.systemClasspath); | |||
| } | |||
| java.setClassname("org.apache.jasper.JspC"); | |||
| @@ -105,8 +103,7 @@ public class JasperC extends DefaultJspCompilerAdapter | |||
| java.setFork(true); | |||
| java.execute(); | |||
| return true; | |||
| } | |||
| catch (Exception ex) { | |||
| } catch (Exception ex) { | |||
| //@todo implement failonerror support here? | |||
| if (ex instanceof BuildException) { | |||
| throw (BuildException) ex; | |||
| @@ -114,8 +111,7 @@ public class JasperC extends DefaultJspCompilerAdapter | |||
| throw new BuildException("Error running jsp compiler: ", | |||
| ex, getJspc().getLocation()); | |||
| } | |||
| } | |||
| finally { | |||
| } finally { | |||
| getJspc().deleteEmptyJavaFiles(); | |||
| } | |||
| } | |||
| @@ -91,8 +91,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||
| private static DocumentBuilder getDocumentBuilder() { | |||
| try { | |||
| return DocumentBuilderFactory.newInstance().newDocumentBuilder(); | |||
| } | |||
| catch (Exception exc) { | |||
| } catch (Exception exc) { | |||
| throw new ExceptionInInitializerError(exc); | |||
| } | |||
| } | |||
| @@ -69,16 +69,14 @@ import org.apache.tools.ant.taskdefs.email.EmailTask; | |||
| * @author ehatcher@apache.org Erik Hatcher | |||
| * @author paulo.gaspar@krankikom.de Paulo Gaspar | |||
| */ | |||
| public class MimeMail extends EmailTask | |||
| { | |||
| public class MimeMail extends EmailTask { | |||
| /** | |||
| * Executes this build task. | |||
| * | |||
| * @exception BuildException On error. | |||
| */ | |||
| public void execute() | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| log("DEPRECATED - The " + getTaskName() + " task is deprecated. " | |||
| + "Use the mail task instead."); | |||
| super.execute(); | |||
| @@ -120,8 +120,7 @@ public class TelnetTask extends Task { | |||
| * Connect and possibly login | |||
| * Iterate through the list of Reads and writes | |||
| */ | |||
| public void execute() throws BuildException | |||
| { | |||
| public void execute() throws BuildException { | |||
| /** A server name is required to continue */ | |||
| if (server == null) { | |||
| throw new BuildException("No Server Specified"); | |||
| @@ -149,8 +148,7 @@ public class TelnetTask extends Task { | |||
| } | |||
| /** Process each sub command */ | |||
| Enumeration tasksToRun = telnetTasks.elements(); | |||
| while (tasksToRun != null && tasksToRun.hasMoreElements()) | |||
| { | |||
| while (tasksToRun != null && tasksToRun.hasMoreElements()) { | |||
| TelnetSubTask task = (TelnetSubTask) tasksToRun.nextElement(); | |||
| if (task instanceof TelnetRead && defaultTimeout != null) { | |||
| ((TelnetRead) task).setDefaultTimeout(defaultTimeout); | |||
| @@ -163,8 +161,7 @@ public class TelnetTask extends Task { | |||
| * Process a 'typical' login. If it differs, use the read | |||
| * and write tasks explicitely | |||
| */ | |||
| private void login() | |||
| { | |||
| private void login() { | |||
| if (addCarriageReturn) { | |||
| telnet.sendString("\n", true); | |||
| } | |||
| @@ -197,8 +194,7 @@ public class TelnetTask extends Task { | |||
| /** | |||
| * Set the tcp port to connect to attribute | |||
| */ | |||
| public void setInitialCR(boolean b) | |||
| { | |||
| public void setInitialCR(boolean b) { | |||
| this.addCarriageReturn = b; | |||
| } | |||
| @@ -206,8 +202,7 @@ public class TelnetTask extends Task { | |||
| * Change the default timeout to wait for | |||
| * valid responses | |||
| */ | |||
| public void setTimeout(Integer i) | |||
| { | |||
| public void setTimeout(Integer i) { | |||
| this.defaultTimeout = i; | |||
| } | |||
| @@ -216,8 +211,7 @@ public class TelnetTask extends Task { | |||
| * Save it in our list, and return it. | |||
| */ | |||
| public TelnetSubTask createRead() | |||
| { | |||
| public TelnetSubTask createRead() { | |||
| TelnetSubTask task = (TelnetSubTask) new TelnetRead(); | |||
| telnetTasks.addElement(task); | |||
| return task; | |||
| @@ -227,8 +221,7 @@ public class TelnetTask extends Task { | |||
| * A subTask <write> tag was found. Create the object, | |||
| * Save it in our list, and return it. | |||
| */ | |||
| public TelnetSubTask createWrite() | |||
| { | |||
| public TelnetSubTask createWrite() { | |||
| TelnetSubTask task = (TelnetSubTask) new TelnetWrite(); | |||
| telnetTasks.addElement(task); | |||
| return task; | |||
| @@ -238,12 +231,10 @@ public class TelnetTask extends Task { | |||
| * This class is the parent of the Read and Write tasks. | |||
| * It handles the common attributes for both. | |||
| */ | |||
| public class TelnetSubTask | |||
| { | |||
| public class TelnetSubTask { | |||
| protected String taskString = ""; | |||
| public void execute(AntTelnetClient telnet) | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| throw new BuildException("Shouldn't be able instantiate a SubTask directly"); | |||
| } | |||
| /** | |||
| @@ -255,25 +246,21 @@ public class TelnetTask extends Task { | |||
| /** | |||
| * attribute assignment of properties | |||
| */ | |||
| public void setString(String s) | |||
| { | |||
| public void setString(String s) { | |||
| taskString += s; | |||
| } | |||
| } | |||
| /** | |||
| * This class sends text to the connected server | |||
| */ | |||
| public class TelnetWrite extends TelnetSubTask | |||
| { | |||
| public class TelnetWrite extends TelnetSubTask { | |||
| private boolean echoString = true; | |||
| public void execute(AntTelnetClient telnet) | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| telnet.sendString(taskString, echoString); | |||
| } | |||
| public void setEcho(boolean b) | |||
| { | |||
| public void setEcho(boolean b) { | |||
| echoString = b; | |||
| } | |||
| } | |||
| @@ -281,110 +268,93 @@ public class TelnetTask extends Task { | |||
| * This class reads the output from the connected server | |||
| * until the required string is found. | |||
| */ | |||
| public class TelnetRead extends TelnetSubTask | |||
| { | |||
| public class TelnetRead extends TelnetSubTask { | |||
| private Integer timeout = null; | |||
| public void execute(AntTelnetClient telnet) | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| telnet.waitForString(taskString, timeout); | |||
| } | |||
| /** | |||
| * Override any default timeouts | |||
| */ | |||
| public void setTimeout(Integer i) | |||
| { | |||
| public void setTimeout(Integer i) { | |||
| this.timeout = i; | |||
| } | |||
| /** | |||
| * Sets the default timeout if none has been set already | |||
| */ | |||
| public void setDefaultTimeout(Integer defaultTimeout) | |||
| { | |||
| public void setDefaultTimeout(Integer defaultTimeout) { | |||
| if (timeout == null) { | |||
| timeout = defaultTimeout; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * This class handles the abstraction of the telnet protocol. | |||
| * Currently it is a wrapper around <a href="www.oroinc.com">ORO</a>'s | |||
| * NetComponents | |||
| */ | |||
| public class AntTelnetClient extends TelnetClient | |||
| { | |||
| /** | |||
| * Read from the telnet session until the string we are | |||
| * waiting for is found | |||
| * @param s The string to wait on | |||
| */ | |||
| public void waitForString(String s) | |||
| { | |||
| waitForString(s, null); | |||
| } | |||
| public class AntTelnetClient extends TelnetClient { | |||
| /** | |||
| * Read from the telnet session until the string we are | |||
| * waiting for is found | |||
| * @param s The string to wait on | |||
| */ | |||
| public void waitForString(String s) { | |||
| waitForString(s, null); | |||
| } | |||
| /** | |||
| * Read from the telnet session until the string we are | |||
| * waiting for is found or the timeout has been reached | |||
| * @param s The string to wait on | |||
| * @param timeout The maximum number of seconds to wait | |||
| */ | |||
| public void waitForString(String s, Integer timeout) | |||
| { | |||
| InputStream is = this.getInputStream(); | |||
| try { | |||
| StringBuffer sb = new StringBuffer(); | |||
| if (timeout == null || timeout.intValue() == 0) | |||
| { | |||
| while (sb.toString().indexOf(s) == -1) | |||
| { | |||
| sb.append((char) is.read()); | |||
| } | |||
| } | |||
| else | |||
| { | |||
| Calendar endTime = Calendar.getInstance(); | |||
| endTime.add(Calendar.SECOND, timeout.intValue()); | |||
| while (sb.toString().indexOf(s) == -1) | |||
| { | |||
| while (Calendar.getInstance().before(endTime) && | |||
| is.available() == 0) { | |||
| Thread.sleep(250); | |||
| } | |||
| if (is.available() == 0) { | |||
| throw new BuildException("Response Timed-Out", getLocation()); | |||
| } | |||
| sb.append((char) is.read()); | |||
| } | |||
| } | |||
| log(sb.toString(), Project.MSG_INFO); | |||
| } catch (BuildException be) | |||
| { | |||
| throw be; | |||
| } catch (Exception e) | |||
| { | |||
| throw new BuildException(e, getLocation()); | |||
| /** | |||
| * Read from the telnet session until the string we are | |||
| * waiting for is found or the timeout has been reached | |||
| * @param s The string to wait on | |||
| * @param timeout The maximum number of seconds to wait | |||
| */ | |||
| public void waitForString(String s, Integer timeout) { | |||
| InputStream is = this.getInputStream(); | |||
| try { | |||
| StringBuffer sb = new StringBuffer(); | |||
| if (timeout == null || timeout.intValue() == 0) { | |||
| while (sb.toString().indexOf(s) == -1){ | |||
| sb.append((char) is.read()); | |||
| } | |||
| } else { | |||
| Calendar endTime = Calendar.getInstance(); | |||
| endTime.add(Calendar.SECOND, timeout.intValue()); | |||
| while (sb.toString().indexOf(s) == -1) { | |||
| while (Calendar.getInstance().before(endTime) && | |||
| is.available() == 0) { | |||
| Thread.sleep(250); | |||
| } | |||
| if (is.available() == 0) { | |||
| throw new BuildException("Response Timed-Out", getLocation()); | |||
| } | |||
| sb.append((char) is.read()); | |||
| } | |||
| } | |||
| log(sb.toString(), Project.MSG_INFO); | |||
| } catch (BuildException be) { | |||
| throw be; | |||
| } catch (Exception e) { | |||
| throw new BuildException(e, getLocation()); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Write this string to the telnet session. | |||
| * @param echoString Logs string sent | |||
| */ | |||
| public void sendString(String s, boolean echoString) | |||
| { | |||
| OutputStream os = this.getOutputStream(); | |||
| try { | |||
| os.write((s + "\n").getBytes()); | |||
| if (echoString) { | |||
| log(s, Project.MSG_INFO); | |||
| } | |||
| os.flush(); | |||
| } catch (Exception e) | |||
| { | |||
| throw new BuildException(e, getLocation()); | |||
| /** | |||
| * Write this string to the telnet session. | |||
| * @param echoString Logs string sent | |||
| */ | |||
| public void sendString(String s, boolean echoString) { | |||
| OutputStream os = this.getOutputStream(); | |||
| try { | |||
| os.write((s + "\n").getBytes()); | |||
| if (echoString) { | |||
| log(s, Project.MSG_INFO); | |||
| } | |||
| os.flush(); | |||
| } catch (Exception e) { | |||
| throw new BuildException(e, getLocation()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -131,8 +131,7 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||
| exe.setWorkingDirectory(aProj.getBaseDir()); | |||
| exe.setCommandline(cmd.getCommandline()); | |||
| return exe.execute(); | |||
| } | |||
| catch (java.io.IOException e) { | |||
| } catch (java.io.IOException e) { | |||
| String msg = "Failed executing: " + cmd.toString() | |||
| + ". Exception: " + e.getMessage(); | |||
| throw new BuildException(msg, location); | |||
| @@ -139,12 +139,10 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| try { | |||
| audioInputStream = AudioSystem.getAudioInputStream(file); | |||
| } | |||
| catch (UnsupportedAudioFileException uafe) { | |||
| } catch (UnsupportedAudioFileException uafe) { | |||
| project.log("Audio format is not yet supported: " | |||
| + uafe.getMessage()); | |||
| } | |||
| catch (IOException ioe) { | |||
| } catch (IOException ioe) { | |||
| ioe.printStackTrace(); | |||
| } | |||
| @@ -156,12 +154,10 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| audioClip = (Clip) AudioSystem.getLine(info); | |||
| audioClip.addLineListener(this); | |||
| audioClip.open(audioInputStream); | |||
| } | |||
| catch (LineUnavailableException e) { | |||
| } catch (LineUnavailableException e) { | |||
| project.log("The sound device is currently unavailable"); | |||
| return; | |||
| } | |||
| catch (IOException e) { | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| @@ -172,8 +168,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| } | |||
| audioClip.drain(); | |||
| audioClip.close(); | |||
| } | |||
| else { | |||
| } else { | |||
| project.log("Can't get data from file " + file.getName()); | |||
| } | |||
| } | |||
| @@ -189,8 +184,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| clip.loop(Clip.LOOP_CONTINUOUSLY); | |||
| try { | |||
| Thread.sleep(duration); | |||
| } | |||
| catch (InterruptedException e) { | |||
| } catch (InterruptedException e) { | |||
| } | |||
| } | |||
| @@ -202,8 +196,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| if (event.getType().equals(LineEvent.Type.STOP)) { | |||
| Line line = event.getLine(); | |||
| line.close(); | |||
| } | |||
| else if (event.getType().equals(LineEvent.Type.CLOSE)) { | |||
| } else if (event.getType().equals(LineEvent.Type.CLOSE)) { | |||
| /* | |||
| * There is a bug in JavaSound 0.90 (jdk1.3beta). | |||
| * It prevents correct termination of the VM. | |||
| @@ -111,8 +111,7 @@ import org.apache.tools.ant.types.Commandline; | |||
| * | |||
| * @ant.task name="vsslabel" category="scm" | |||
| */ | |||
| public class MSVSSLABEL extends MSVSS | |||
| { | |||
| public class MSVSSLABEL extends MSVSS { | |||
| private String m_AutoResponse = null; | |||
| private String m_Label = null; | |||
| private String m_Version = null; | |||
| @@ -306,22 +306,18 @@ public class FilterSet extends DataType implements Cloneable { | |||
| String strValue = props.getProperty(strPropName); | |||
| filters.addElement(new Filter(strPropName, strValue)); | |||
| } | |||
| } | |||
| catch (Exception e) { | |||
| } catch (Exception e) { | |||
| throw new BuildException("Could not read filters from file: " | |||
| + filtersFile); | |||
| } | |||
| finally { | |||
| } finally { | |||
| if (in != null) { | |||
| try { | |||
| in.close(); | |||
| } | |||
| catch (IOException ioex) { | |||
| } catch (IOException ioex) { | |||
| } | |||
| } | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| throw new BuildException("Must specify a file not a directory in " | |||
| + "the filtersfile attribute:" + filtersFile); | |||
| } | |||
| @@ -363,8 +359,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
| b.append(value); | |||
| i = index + beginToken.length() + token.length() | |||
| + endToken.length(); | |||
| } | |||
| else { | |||
| } else { | |||
| // just append beginToken and search further | |||
| b.append(beginToken); | |||
| i = index + beginToken.length(); | |||
| @@ -373,12 +368,10 @@ public class FilterSet extends DataType implements Cloneable { | |||
| b.append(line.substring(i)); | |||
| return b.toString(); | |||
| } | |||
| catch (StringIndexOutOfBoundsException e) { | |||
| } catch (StringIndexOutOfBoundsException e) { | |||
| return line; | |||
| } | |||
| } | |||
| else { | |||
| } else { | |||
| return line; | |||
| } | |||
| } | |||
| @@ -260,8 +260,7 @@ public class Path extends DataType implements Cloneable { | |||
| File f = null; | |||
| if (getProject() != null) { | |||
| f = getProject().resolveFile(list[i]); | |||
| } | |||
| else { | |||
| } else { | |||
| f = new File(list[i]); | |||
| } | |||
| @@ -384,8 +383,7 @@ public class Path extends DataType implements Cloneable { | |||
| String pathElement = tok.nextToken(); | |||
| try { | |||
| element.append(resolveFile(project, pathElement)); | |||
| } | |||
| catch (BuildException e) { | |||
| } catch (BuildException e) { | |||
| project.log("Dropping path element " + pathElement | |||
| + " as it is not valid relative to the project", | |||
| Project.MSG_VERBOSE); | |||
| @@ -585,8 +583,7 @@ public class Path extends DataType implements Cloneable { | |||
| kaffeJarFiles.setIncludes("*.jar"); | |||
| addFileset(kaffeJarFiles); | |||
| } | |||
| else if (Project.getJavaVersion() == Project.JAVA_1_1) { | |||
| } else if (Project.getJavaVersion() == Project.JAVA_1_1) { | |||
| addExisting(new Path(null, | |||
| System.getProperty("java.home") | |||
| + File.separator + "lib" | |||
| @@ -470,8 +470,7 @@ public class PatternSet extends DataType { | |||
| } | |||
| } | |||
| public String toString() | |||
| { | |||
| public String toString() { | |||
| return "patternSet{ includes: " + includeList + | |||
| " excludes: " + excludeList + " }"; | |||
| } | |||
| @@ -96,8 +96,7 @@ import org.apache.tools.ant.util.regexp.RegexpFactory; | |||
| * | |||
| * @ant.datatype name="regexp" | |||
| */ | |||
| public class RegularExpression extends DataType | |||
| { | |||
| public class RegularExpression extends DataType { | |||
| public final static String DATA_TYPE_NAME = "regexp"; | |||
| // The regular expression factory | |||
| @@ -105,13 +104,11 @@ public class RegularExpression extends DataType | |||
| private Regexp regexp; | |||
| public RegularExpression() | |||
| { | |||
| public RegularExpression() { | |||
| this.regexp = factory.newRegexp(); | |||
| } | |||
| public void setPattern(String pattern) | |||
| { | |||
| public void setPattern(String pattern) { | |||
| this.regexp.setPattern(pattern); | |||
| } | |||
| @@ -119,8 +116,7 @@ public class RegularExpression extends DataType | |||
| * Gets the pattern string for this RegularExpression in the | |||
| * given project. | |||
| */ | |||
| public String getPattern(Project p) | |||
| { | |||
| public String getPattern(Project p) { | |||
| if (isReference()) { | |||
| return getRef(p).getPattern(p); | |||
| } | |||
| @@ -128,8 +124,7 @@ public class RegularExpression extends DataType | |||
| return regexp.getPattern(); | |||
| } | |||
| public Regexp getRegexp(Project p) | |||
| { | |||
| public Regexp getRegexp(Project p) { | |||
| if (isReference()) { | |||
| return getRef(p).getRegexp(p); | |||
| } | |||
| @@ -140,10 +135,8 @@ public class RegularExpression extends DataType | |||
| * Get the RegularExpression this reference refers to in | |||
| * the given project. Check for circular references too | |||
| */ | |||
| public RegularExpression getRef(Project p) | |||
| { | |||
| if (!checked) | |||
| { | |||
| public RegularExpression getRef(Project p) { | |||
| if (!checked) { | |||
| Stack stk = new Stack(); | |||
| stk.push(this); | |||
| dieOnCircularReference(stk, p); | |||
| @@ -151,16 +144,12 @@ public class RegularExpression extends DataType | |||
| Object o = ref.getReferencedObject(p); | |||
| if (!(o instanceof RegularExpression)) | |||
| { | |||
| if (!(o instanceof RegularExpression)) { | |||
| String msg = ref.getRefId() + " doesn\'t denote a " | |||
| + DATA_TYPE_NAME; | |||
| throw new BuildException(msg); | |||
| } | |||
| else | |||
| { | |||
| } else { | |||
| return (RegularExpression) o; | |||
| } | |||
| } | |||
| } | |||
| @@ -70,19 +70,16 @@ import org.apache.tools.ant.Project; | |||
| * @see org.apache.oro.text.regex.Perl5Substitution | |||
| * @author Matthew Inger <a href="mailto:mattinger@mindless.com">mattinger@mindless.com</a> | |||
| */ | |||
| public class Substitution extends DataType | |||
| { | |||
| public class Substitution extends DataType { | |||
| public final static String DATA_TYPE_NAME = "substitition"; | |||
| private String expression; | |||
| public Substitution() | |||
| { | |||
| public Substitution() { | |||
| this.expression = null; | |||
| } | |||
| public void setExpression(String expression) | |||
| { | |||
| public void setExpression(String expression) { | |||
| this.expression = expression; | |||
| } | |||
| @@ -90,8 +87,7 @@ public class Substitution extends DataType | |||
| * Gets the pattern string for this RegularExpression in the | |||
| * given project. | |||
| */ | |||
| public String getExpression(Project p) | |||
| { | |||
| public String getExpression(Project p) { | |||
| if (isReference()) { | |||
| return getRef(p).getExpression(p); | |||
| } | |||
| @@ -103,10 +99,8 @@ public class Substitution extends DataType | |||
| * Get the RegularExpression this reference refers to in | |||
| * the given project. Check for circular references too | |||
| */ | |||
| public Substitution getRef(Project p) | |||
| { | |||
| if (!checked) | |||
| { | |||
| public Substitution getRef(Project p) { | |||
| if (!checked) { | |||
| Stack stk = new Stack(); | |||
| stk.push(this); | |||
| dieOnCircularReference(stk, p); | |||
| @@ -114,15 +108,11 @@ public class Substitution extends DataType | |||
| Object o = ref.getReferencedObject(p); | |||
| if (!(o instanceof Substitution)) | |||
| { | |||
| if (!(o instanceof Substitution)) { | |||
| String msg = ref.getRefId() + " doesn\'t denote a substitution"; | |||
| throw new BuildException(msg); | |||
| } | |||
| else | |||
| { | |||
| } else { | |||
| return (Substitution) o; | |||
| } | |||
| } | |||
| } | |||
| @@ -153,8 +153,7 @@ public class FileUtils { | |||
| * @throws IOException | |||
| */ | |||
| public void copyFile(String sourceFile, String destFile, FilterSetCollection filters) | |||
| throws IOException | |||
| { | |||
| throws IOException { | |||
| copyFile(new File(sourceFile), new File(destFile), filters, false, false); | |||
| } | |||