then/else parts of if statement and loop body must always been enclosed in a block statement. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270631 13f79535-47bb-0310-9956-ffa450edef68remotes/1776816827838153613/tmp_25f451bd36ab3145e487fcb2cd5c62c571e5b602
| @@ -229,7 +229,9 @@ public class Cvs extends Task { | |||||
| null); | null); | ||||
| exe.setAntRun(project); | exe.setAntRun(project); | ||||
| if (dest == null) dest = project.getBaseDir(); | |||||
| if (dest == null) { | |||||
| dest = project.getBaseDir(); | |||||
| } | |||||
| exe.setWorkingDirectory(dest); | exe.setWorkingDirectory(dest); | ||||
| exe.setCommandline(toExecute.getCommandline()); | exe.setCommandline(toExecute.getCommandline()); | ||||
| @@ -237,8 +239,9 @@ public class Cvs extends Task { | |||||
| try { | try { | ||||
| int retCode = exe.execute(); | int retCode = exe.execute(); | ||||
| /*Throw an exception if cvs exited with error. (Iulian)*/ | /*Throw an exception if cvs exited with error. (Iulian)*/ | ||||
| if(failOnError && retCode != 0) | |||||
| if(failOnError && retCode != 0) { | |||||
| throw new BuildException("cvs exited with error code "+ retCode); | throw new BuildException("cvs exited with error code "+ retCode); | ||||
| } | |||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| throw new BuildException(e, location); | throw new BuildException(e, location); | ||||
| } finally { | } finally { | ||||
| @@ -258,8 +261,9 @@ public class Cvs extends Task { | |||||
| public void setCvsRoot(String root) { | public void setCvsRoot(String root) { | ||||
| // Check if not real cvsroot => set it to null | // Check if not real cvsroot => set it to null | ||||
| if (root != null) { | if (root != null) { | ||||
| if (root.trim().equals("")) | |||||
| if (root.trim().equals("")) { | |||||
| root = null; | root = null; | ||||
| } | |||||
| } | } | ||||
| this.cvsRoot = root; | this.cvsRoot = root; | ||||
| @@ -268,8 +272,9 @@ public class Cvs extends Task { | |||||
| public void setCvsRsh(String rsh) { | public void setCvsRsh(String rsh) { | ||||
| // Check if not real cvsrsh => set it to null | // Check if not real cvsrsh => set it to null | ||||
| if (rsh != null) { | if (rsh != null) { | ||||
| if (rsh.trim().equals("")) | |||||
| if (rsh.trim().equals("")) { | |||||
| rsh = null; | rsh = null; | ||||
| } | |||||
| } | } | ||||
| this.cvsRsh = rsh; | this.cvsRsh = rsh; | ||||
| @@ -266,11 +266,12 @@ public class Delete extends MatchingTask { | |||||
| if (!file.delete()) { | if (!file.delete()) { | ||||
| String message="Unable to delete file " + file.getAbsolutePath(); | String message="Unable to delete file " + file.getAbsolutePath(); | ||||
| if(failonerror) | |||||
| if(failonerror) { | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| else | |||||
| } else { | |||||
| log(message, | log(message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| @@ -337,7 +338,9 @@ public class Delete extends MatchingTask { | |||||
| protected void removeDir(File d) { | protected void removeDir(File d) { | ||||
| String[] list = d.list(); | String[] list = d.list(); | ||||
| if (list == null) list = new String[0]; | |||||
| if (list == null) { | |||||
| list = new String[0]; | |||||
| } | |||||
| for (int i = 0; i < list.length; i++) { | for (int i = 0; i < list.length; i++) { | ||||
| String s = list[i]; | String s = list[i]; | ||||
| File f = new File(d, s); | File f = new File(d, s); | ||||
| @@ -347,22 +350,24 @@ public class Delete extends MatchingTask { | |||||
| log("Deleting " + f.getAbsolutePath(), verbosity); | log("Deleting " + f.getAbsolutePath(), verbosity); | ||||
| if (!f.delete()) { | if (!f.delete()) { | ||||
| String message="Unable to delete file " + f.getAbsolutePath(); | String message="Unable to delete file " + f.getAbsolutePath(); | ||||
| if(failonerror) | |||||
| if(failonerror) { | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| else | |||||
| } else { | |||||
| log(message, | log(message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| log("Deleting directory " + d.getAbsolutePath(), verbosity); | log("Deleting directory " + d.getAbsolutePath(), verbosity); | ||||
| if (!d.delete()) { | if (!d.delete()) { | ||||
| String message="Unable to delete directory " + dir.getAbsolutePath(); | String message="Unable to delete directory " + dir.getAbsolutePath(); | ||||
| if(failonerror) | |||||
| if(failonerror) { | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| else | |||||
| } else { | |||||
| log(message, | log(message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -381,9 +386,9 @@ public class Delete extends MatchingTask { | |||||
| log("Deleting " + f.getAbsolutePath(), verbosity); | log("Deleting " + f.getAbsolutePath(), verbosity); | ||||
| if (!f.delete()) { | if (!f.delete()) { | ||||
| String message="Unable to delete file " + f.getAbsolutePath(); | String message="Unable to delete file " + f.getAbsolutePath(); | ||||
| if(failonerror) | |||||
| if(failonerror) { | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| else | |||||
| } else | |||||
| log(message, | log(message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | ||||
| } | } | ||||
| @@ -391,7 +396,8 @@ public class Delete extends MatchingTask { | |||||
| } | } | ||||
| if (dirs.length > 0 && includeEmpty) { | if (dirs.length > 0 && includeEmpty) { | ||||
| int dirCount = 0; | |||||
| in | |||||
| }t dirCount = 0; | |||||
| for (int j=dirs.length-1; j>=0; j--) { | for (int j=dirs.length-1; j>=0; j--) { | ||||
| File dir = new File(d, dirs[j]); | File dir = new File(d, dirs[j]); | ||||
| String[] dirFiles = dir.list(); | String[] dirFiles = dir.list(); | ||||
| @@ -400,11 +406,12 @@ public class Delete extends MatchingTask { | |||||
| if (!dir.delete()) { | if (!dir.delete()) { | ||||
| String message="Unable to delete directory " | String message="Unable to delete directory " | ||||
| + dir.getAbsolutePath(); | + dir.getAbsolutePath(); | ||||
| if(failonerror) | |||||
| if(failonerror) { | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| else | |||||
| } else { { | |||||
| log(message, | log(message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | ||||
| } | |||||
| } else { | } else { | ||||
| dirCount++; | dirCount++; | ||||
| } | } | ||||
| @@ -102,7 +102,9 @@ public class Exec extends Task { | |||||
| } | } | ||||
| // default directory to the project's base directory | // default directory to the project's base directory | ||||
| if (dir == null) dir = project.getBaseDir(); | |||||
| if (dir == null) { | |||||
| dir = project.getBaseDir(); | |||||
| } | |||||
| if (myos.toLowerCase().indexOf("windows") >= 0) { | if (myos.toLowerCase().indexOf("windows") >= 0) { | ||||
| if (!dir.equals(project.resolveFile("."))) { | if (!dir.equals(project.resolveFile("."))) { | ||||
| @@ -121,7 +123,9 @@ public class Exec extends Task { | |||||
| } | } | ||||
| } else { | } else { | ||||
| String ant = project.getProperty("ant.home"); | String ant = project.getProperty("ant.home"); | ||||
| if (ant == null) throw new BuildException("Property 'ant.home' not found", location); | |||||
| if (ant == null) { | |||||
| throw new BuildException("Property 'ant.home' not found", location); | |||||
| } | |||||
| String antRun = project.resolveFile(ant + "/bin/antRun").toString(); | String antRun = project.resolveFile(ant + "/bin/antRun").toString(); | ||||
| command = antRun + " " + dir + " " + command; | command = antRun + " " + dir + " " + command; | ||||
| @@ -203,7 +207,9 @@ public class Exec extends Task { | |||||
| } | } | ||||
| protected void logFlush() { | protected void logFlush() { | ||||
| if (fos != null) fos.close(); | |||||
| if (fos != null) { | |||||
| fos.close(); | |||||
| } | |||||
| } | } | ||||
| // Inner class for continually pumping the input stream during | // Inner class for continually pumping the input stream during | ||||
| @@ -189,8 +189,9 @@ public class Get extends Task { | |||||
| } | } | ||||
| if( is==null ) { | if( is==null ) { | ||||
| log( "Can't get " + source + " to " + dest); | log( "Can't get " + source + " to " + dest); | ||||
| if(ignoreErrors) | |||||
| if(ignoreErrors) { | |||||
| return; | return; | ||||
| } | |||||
| throw new BuildException( "Can't get " + source + " to " + dest, | throw new BuildException( "Can't get " + source + " to " + dest, | ||||
| location); | location); | ||||
| } | } | ||||
| @@ -200,9 +201,13 @@ public class Get extends Task { | |||||
| while ((length = is.read(buffer)) >= 0) { | while ((length = is.read(buffer)) >= 0) { | ||||
| fos.write(buffer, 0, length); | fos.write(buffer, 0, length); | ||||
| if (verbose) System.out.print("."); | |||||
| if (verbose) { | |||||
| System.out.print("."); | |||||
| } | |||||
| } | |||||
| if(verbose) { | |||||
| System.out.println(); | |||||
| } | } | ||||
| if(verbose) System.out.println(); | |||||
| fos.close(); | fos.close(); | ||||
| is.close(); | is.close(); | ||||
| @@ -215,13 +220,15 @@ public class Get extends Task { | |||||
| log("last modified = "+t.toString() | log("last modified = "+t.toString() | ||||
| +((remoteTimestamp==0)?" - using current time instead":"")); | +((remoteTimestamp==0)?" - using current time instead":"")); | ||||
| } | } | ||||
| if(remoteTimestamp!=0) | |||||
| if(remoteTimestamp!=0) { | |||||
| touchFile(dest,remoteTimestamp); | touchFile(dest,remoteTimestamp); | ||||
| } | |||||
| } | } | ||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| log("Error getting " + source + " to " + dest ); | log("Error getting " + source + " to " + dest ); | ||||
| if(ignoreErrors) | |||||
| if(ignoreErrors) { | |||||
| return; | return; | ||||
| } | |||||
| throw new BuildException(ioe, location); | throw new BuildException(ioe, location); | ||||
| } | } | ||||
| } | } | ||||
| @@ -182,8 +182,9 @@ public class Ilasm | |||||
| if(targetType.equals("exe") || targetType.equals("library")) { | if(targetType.equals("exe") || targetType.equals("library")) { | ||||
| _targetType=targetType; | _targetType=targetType; | ||||
| } | } | ||||
| else | |||||
| else { | |||||
| throw new BuildException("targetType " +targetType+" is not a valid type"); | throw new BuildException("targetType " +targetType+" is not a valid type"); | ||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -201,15 +202,17 @@ public class Ilasm | |||||
| */ | */ | ||||
| protected String getTargetTypeParameter() { | protected String getTargetTypeParameter() { | ||||
| if(!notEmpty(_targetType)) | |||||
| if(!notEmpty(_targetType)) { | |||||
| return null; | return null; | ||||
| if (_targetType.equals("exe")) | |||||
| } | |||||
| if (_targetType.equals("exe")) { | |||||
| return "/exe"; | return "/exe"; | ||||
| else | |||||
| if (_targetType.equals("library")) | |||||
| } else | |||||
| if (_targetType.equals("library")) { | |||||
| return "/dll"; | return "/dll"; | ||||
| else | |||||
| } else { | |||||
| return null; | return null; | ||||
| } | |||||
| } | } | ||||
| @@ -292,8 +295,9 @@ public class Ilasm | |||||
| * @return the argument string or null for no argument | * @return the argument string or null for no argument | ||||
| */ | */ | ||||
| protected String getOutputFileParameter() { | protected String getOutputFileParameter() { | ||||
| if (_outputFile==null || _outputFile.length()==0) | |||||
| if (_outputFile==null || _outputFile.length()==0) { | |||||
| return null; | return null; | ||||
| } | |||||
| File f = _outputFile; | File f = _outputFile; | ||||
| return "/output="+f.toString(); | return "/output="+f.toString(); | ||||
| } | } | ||||
| @@ -369,10 +373,11 @@ public class Ilasm | |||||
| /** get the argument or null for no argument needed | /** get the argument or null for no argument needed | ||||
| */ | */ | ||||
| protected String getKeyfileParameter() { | protected String getKeyfileParameter() { | ||||
| if(_keyfile!=null) | |||||
| if(_keyfile!=null) { | |||||
| return "/keyfile:"+_keyfile.toString(); | return "/keyfile:"+_keyfile.toString(); | ||||
| else | |||||
| } else { | |||||
| return null; | return null; | ||||
| } | |||||
| } | } | ||||
| /** any extra command options? | /** any extra command options? | ||||
| @@ -401,10 +406,11 @@ public class Ilasm | |||||
| * @return The ExtraOptions Parameter to CSC | * @return The ExtraOptions Parameter to CSC | ||||
| */ | */ | ||||
| protected String getExtraOptionsParameter() { | protected String getExtraOptionsParameter() { | ||||
| if (_extraOptions!=null && _extraOptions.length()!=0) | |||||
| if (_extraOptions!=null && _extraOptions.length()!=0) { | |||||
| return _extraOptions; | return _extraOptions; | ||||
| else | |||||
| } else { | |||||
| return null; | return null; | ||||
| } | |||||
| } | } | ||||
| @@ -414,8 +420,9 @@ public class Ilasm | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException { | throws BuildException { | ||||
| if (_srcDir == null) | |||||
| if (_srcDir == null) { | |||||
| _srcDir=project.resolveFile("."); | _srcDir=project.resolveFile("."); | ||||
| } | |||||
| //get dependencies list. | //get dependencies list. | ||||
| DirectoryScanner scanner = super.getDirectoryScanner(_srcDir); | DirectoryScanner scanner = super.getDirectoryScanner(_srcDir); | ||||
| @@ -638,8 +638,9 @@ public class FTP | |||||
| { | { | ||||
| File file = project.resolveFile(new File(dir, filename).getPath()); | File file = project.resolveFile(new File(dir, filename).getPath()); | ||||
| if (newerOnly && isUpToDate(ftp, file, resolveFile(filename))) | |||||
| if (newerOnly && isUpToDate(ftp, file, resolveFile(filename))) { | |||||
| return; | return; | ||||
| } | |||||
| if (verbose) | if (verbose) | ||||
| { | { | ||||
| @@ -729,8 +730,9 @@ public class FTP | |||||
| { | { | ||||
| File file = project.resolveFile(new File(dir, filename).getPath()); | File file = project.resolveFile(new File(dir, filename).getPath()); | ||||
| if (newerOnly && isUpToDate(ftp, file, resolveFile(filename))) | |||||
| if (newerOnly && isUpToDate(ftp, file, resolveFile(filename))) { | |||||
| return; | return; | ||||
| } | |||||
| if (verbose) | if (verbose) | ||||
| { | { | ||||
| @@ -194,12 +194,13 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||||
| String stubVersion = attributes.getStubVersion(); | String stubVersion = attributes.getStubVersion(); | ||||
| if (null != stubVersion) { | if (null != stubVersion) { | ||||
| if ("1.1".equals(stubVersion)) | |||||
| if ("1.1".equals(stubVersion)) { | |||||
| cmd.createArgument().setValue("-v1.1"); | cmd.createArgument().setValue("-v1.1"); | ||||
| else if ("1.2".equals(stubVersion)) | |||||
| } else if ("1.2".equals(stubVersion)) { | |||||
| cmd.createArgument().setValue("-v1.2"); | cmd.createArgument().setValue("-v1.2"); | ||||
| else | |||||
| } else { | |||||
| cmd.createArgument().setValue("-vcompat"); | cmd.createArgument().setValue("-vcompat"); | ||||
| } | |||||
| } | } | ||||
| if (null != attributes.getSourceBase()) { | if (null != attributes.getSourceBase()) { | ||||
| @@ -205,7 +205,9 @@ public class Commandline implements Cloneable { | |||||
| * Sets the executable to run. | * Sets the executable to run. | ||||
| */ | */ | ||||
| public void setExecutable(String executable) { | public void setExecutable(String executable) { | ||||
| if (executable == null || executable.length() == 0) return; | |||||
| if (executable == null || executable.length() == 0) { | |||||
| return; | |||||
| } | |||||
| this.executable = executable.replace('/', File.separatorChar) | this.executable = executable.replace('/', File.separatorChar) | ||||
| .replace('\\', File.separatorChar); | .replace('\\', File.separatorChar); | ||||
| } | } | ||||
| @@ -227,7 +229,9 @@ public class Commandline implements Cloneable { | |||||
| */ | */ | ||||
| public String[] getCommandline() { | public String[] getCommandline() { | ||||
| final String[] args = getArguments(); | final String[] args = getArguments(); | ||||
| if (executable == null) return args; | |||||
| if (executable == null) { | |||||
| return args; | |||||
| } | |||||
| final String[] result = new String[args.length+1]; | final String[] result = new String[args.length+1]; | ||||
| result[0] = executable; | result[0] = executable; | ||||
| System.arraycopy(args, 0, result, 1, args.length); | System.arraycopy(args, 0, result, 1, args.length); | ||||
| @@ -285,7 +289,9 @@ public class Commandline implements Cloneable { | |||||
| public static String toString(String [] line) { | public static String toString(String [] line) { | ||||
| // empty path return empty string | // empty path return empty string | ||||
| if (line == null || line.length == 0) return ""; | |||||
| if (line == null || line.length == 0) { | |||||
| return ""; | |||||
| } | |||||
| // path containing one or more elements | // path containing one or more elements | ||||
| final StringBuffer result = new StringBuffer(); | final StringBuffer result = new StringBuffer(); | ||||