Browse Source

Fix bad coding style.

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@270629 13f79535-47bb-0310-9956-ffa450edef68
master
Stephane Bailliez 24 years ago
parent
commit
9f2aca50e3
20 changed files with 161 additions and 72 deletions
  1. +20
    -7
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  2. +14
    -5
      src/main/org/apache/tools/ant/taskdefs/SignJar.java
  3. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/Tar.java
  4. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/UpToDate.java
  5. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/War.java
  6. +11
    -4
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
  7. +15
    -7
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  8. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/AdaptxLiaison.java
  9. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java
  10. +7
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/Script.java
  11. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
  12. +16
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  13. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java
  14. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java
  15. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
  16. +32
    -16
      src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java
  17. +18
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java
  18. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/perforce/SimpleP4OutputHandler.java
  19. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java
  20. +2
    -1
      src/main/org/apache/tools/ant/types/Substitution.java

+ 20
- 7
src/main/org/apache/tools/ant/taskdefs/SQLExec.java View File

@@ -495,7 +495,9 @@ public class SQLExec extends Task {
throw new SQLException("No suitable Driver for "+url); throw new SQLException("No suitable Driver for "+url);
} }


if (!isValidRdbms(conn)) return;
if (!isValidRdbms(conn)) {
return;
}


conn.setAutoCommit(autocommit); conn.setAutoCommit(autocommit);


@@ -566,8 +568,12 @@ public class SQLExec extends Task {
while ((line=in.readLine()) != null){ while ((line=in.readLine()) != null){
line = line.trim(); line = line.trim();
line = project.replaceProperties(line); line = project.replaceProperties(line);
if (line.startsWith("//")) continue;
if (line.startsWith("--")) continue;
if (line.startsWith("//")) {
continue;
}
if (line.startsWith("--")) {
continue;
}
StringTokenizer st = new StringTokenizer(line); StringTokenizer st = new StringTokenizer(line);
if (st.hasMoreTokens()) { if (st.hasMoreTokens()) {
String token = st.nextToken(); String token = st.nextToken();
@@ -582,7 +588,9 @@ public class SQLExec extends Task {
// SQL defines "--" as a comment to EOL // SQL defines "--" as a comment to EOL
// and in Oracle it may contain a hint // and in Oracle it may contain a hint
// so we cannot just remove it, instead we must end it // so we cannot just remove it, instead we must end it
if (line.indexOf("--") >= 0) sql += "\n";
if (line.indexOf("--") >= 0) {
sql += "\n";
}


if (delimiterType.equals(DelimiterType.NORMAL) && sql.endsWith(delimiter) || if (delimiterType.equals(DelimiterType.NORMAL) && sql.endsWith(delimiter) ||
delimiterType.equals(DelimiterType.ROW) && line.equals(delimiter)) { delimiterType.equals(DelimiterType.ROW) && line.equals(delimiter)) {
@@ -606,8 +614,9 @@ public class SQLExec extends Task {
* Verify if connected to the correct RDBMS * Verify if connected to the correct RDBMS
**/ **/
protected boolean isValidRdbms(Connection conn) { protected boolean isValidRdbms(Connection conn) {
if (rdbms == null && version == null)
if (rdbms == null && version == null) {
return true; return true;
}
try { try {
DatabaseMetaData dmd = conn.getMetaData(); DatabaseMetaData dmd = conn.getMetaData();
@@ -648,7 +657,9 @@ public class SQLExec extends Task {
*/ */
protected void execSQL(String sql, PrintStream out) throws SQLException { protected void execSQL(String sql, PrintStream out) throws SQLException {
// Check and ignore empty statements // Check and ignore empty statements
if ("".equals(sql.trim())) return;
if ("".equals(sql.trim())) {
return;
}
try { try {
totalSql++; totalSql++;
@@ -672,7 +683,9 @@ public class SQLExec extends Task {
} }
catch (SQLException e) { catch (SQLException e) {
log("Failed to execute: " + sql, Project.MSG_ERR); log("Failed to execute: " + sql, Project.MSG_ERR);
if (!onError.equals("continue")) throw e;
if (!onError.equals("continue")) {
throw e;
}
log(e.toString(), Project.MSG_ERR); log(e.toString(), Project.MSG_ERR);
} }
} }


+ 14
- 5
src/main/org/apache/tools/ant/taskdefs/SignJar.java View File

@@ -199,7 +199,9 @@ public class SignJar extends Task {
throw new BuildException("storepass attribute must be set"); throw new BuildException("storepass attribute must be set");
} }


if(isUpToDate(jarSource, jarTarget)) return;
if(isUpToDate(jarSource, jarTarget)) {
return;
}


final StringBuffer sb = new StringBuffer(); final StringBuffer sb = new StringBuffer();


@@ -265,11 +267,18 @@ public class SignJar extends Task {


if( null != signedjarFile ) { if( null != signedjarFile ) {


if(!jarFile.exists()) return false;
if(!signedjarFile.exists()) return false;
if(jarFile.equals(signedjarFile)) return false;
if(signedjarFile.lastModified() > jarFile.lastModified())
if(!jarFile.exists()) {
return false;
}
if(!signedjarFile.exists()) {
return false;
}
if(jarFile.equals(signedjarFile)) {
return false;
}
if(signedjarFile.lastModified() > jarFile.lastModified()) {
return true; return true;
}
} else { } else {
if( lazy ) { if( lazy ) {
return isSigned(jarFile); return isSigned(jarFile);


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/Tar.java View File

@@ -333,8 +333,9 @@ public class Tar extends MatchingTask {


tOut.closeEntry(); tOut.closeEntry();
} finally { } finally {
if (fIn != null)
if (fIn != null) {
fIn.close(); fIn.close();
}
} }
} }




+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/UpToDate.java View File

@@ -155,7 +155,9 @@ public class UpToDate extends MatchingTask implements Condition {
} }


// if not there then it can't be up to date // if not there then it can't be up to date
if (_targetFile != null && !_targetFile.exists()) return false;
if (_targetFile != null && !_targetFile.exists()) {
return false;
}


Enumeration enum = sourceFileSets.elements(); Enumeration enum = sourceFileSets.elements();
boolean upToDate = true; boolean upToDate = true;


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/War.java View File

@@ -92,8 +92,9 @@ public class War extends Jar {
*/ */
public void setWebxml(File descr) { public void setWebxml(File descr) {
deploymentDescriptor = descr; deploymentDescriptor = descr;
if (!deploymentDescriptor.exists())
if (!deploymentDescriptor.exists()) {
throw new BuildException("Deployment descriptor: " + deploymentDescriptor + " does not exist."); throw new BuildException("Deployment descriptor: " + deploymentDescriptor + " does not exist.");
}


// Create a ZipFileSet for this file, and pass it up. // Create a ZipFileSet for this file, and pass it up.
ZipFileSet fs = new ZipFileSet(); ZipFileSet fs = new ZipFileSet();


+ 11
- 4
src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -194,8 +194,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
dirs = scanner.getIncludedDirectories(); dirs = scanner.getIncludedDirectories();
for (int j = 0;j < dirs.length;++j){ for (int j = 0;j < dirs.length;++j){
list=new File(baseDir,dirs[j]).list(); list=new File(baseDir,dirs[j]).list();
for (int i = 0;i < list.length;++i)
for (int i = 0;i < list.length;++i) {
process( baseDir, list[i], destDir, stylesheet ); process( baseDir, list[i], destDir, stylesheet );
}
} }
} //-- execute } //-- execute


@@ -386,7 +387,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
} }
}catch (Exception ex) { }catch (Exception ex) {
log("Failed to process " + inFile, Project.MSG_INFO); log("Failed to process " + inFile, Project.MSG_INFO);
if(outFile!=null)outFile.delete();
if(outFile!=null) {
outFile.delete();
}
throw new BuildException(ex); throw new BuildException(ex);
} }
} }
@@ -456,12 +459,16 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
} }


public String getName() throws BuildException{ public String getName() throws BuildException{
if(name==null)throw new BuildException("Name attribute is missing.");
if(name==null) {
throw new BuildException("Name attribute is missing.");
}
return name; return name;
} }


public String getExpression() throws BuildException{ public String getExpression() throws BuildException{
if(expression==null)throw new BuildException("Expression attribute is missing.");
if(expression==null) {
throw new BuildException("Expression attribute is missing.");
}
return expression; return expression;
} }
} }


+ 15
- 7
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -346,8 +346,9 @@ public class Zip extends MatchingTask {
// before we added any files, then we must swallow this exception. Otherwise, // before we added any files, then we must swallow this exception. Otherwise,
// the error that's reported will be the close() error, which is not the real // the error that's reported will be the close() error, which is not the real
// cause of the problem. // cause of the problem.
if (success)
if (success) {
throw ex; throw ex;
}
} }
} }
} catch (IOException ioe) { } catch (IOException ioe) {
@@ -395,15 +396,17 @@ public class Zip extends MatchingTask {
*/ */
protected void addFiles(FileScanner scanner, ZipOutputStream zOut, protected void addFiles(FileScanner scanner, ZipOutputStream zOut,
String prefix, String fullpath) throws IOException { String prefix, String fullpath) throws IOException {
if (prefix.length() > 0 && fullpath.length() > 0)
if (prefix.length() > 0 && fullpath.length() > 0) {
throw new BuildException("Both prefix and fullpath attributes may not be set on the same fileset."); throw new BuildException("Both prefix and fullpath attributes may not be set on the same fileset.");
}


File thisBaseDir = scanner.getBasedir(); File thisBaseDir = scanner.getBasedir();


// directories that matched include patterns // directories that matched include patterns
String[] dirs = scanner.getIncludedDirectories(); String[] dirs = scanner.getIncludedDirectories();
if (dirs.length > 0 && fullpath.length() > 0)
if (dirs.length > 0 && fullpath.length() > 0) {
throw new BuildException("fullpath attribute may only be specified for filesets that specify a single file."); throw new BuildException("fullpath attribute may only be specified for filesets that specify a single file.");
}
for (int i = 0; i < dirs.length; i++) { for (int i = 0; i < dirs.length; i++) {
if ("".equals(dirs[i])) { if ("".equals(dirs[i])) {
continue; continue;
@@ -417,8 +420,9 @@ public class Zip extends MatchingTask {


// files that matched include patterns // files that matched include patterns
String[] files = scanner.getIncludedFiles(); String[] files = scanner.getIncludedFiles();
if (files.length > 1 && fullpath.length() > 0)
if (files.length > 1 && fullpath.length() > 0) {
throw new BuildException("fullpath attribute may only be specified for filesets that specify a single file."); throw new BuildException("fullpath attribute may only be specified for filesets that specify a single file.");
}
for (int i = 0; i < files.length; i++) { for (int i = 0; i < files.length; i++) {
File f = new File(thisBaseDir, files[i]); File f = new File(thisBaseDir, files[i]);
if (fullpath.length() > 0) if (fullpath.length() > 0)
@@ -441,8 +445,9 @@ public class Zip extends MatchingTask {
ZipOutputStream zOut, String prefix, String fullpath) ZipOutputStream zOut, String prefix, String fullpath)
throws IOException throws IOException
{ {
if (prefix.length() > 0 && fullpath.length() > 0)
if (prefix.length() > 0 && fullpath.length() > 0) {
throw new BuildException("Both prefix and fullpath attributes may not be set on the same fileset."); throw new BuildException("Both prefix and fullpath attributes may not be set on the same fileset.");
}


ZipScanner zipScanner = (ZipScanner) ds; ZipScanner zipScanner = (ZipScanner) ds;
File zipSrc = fs.getSrc(); File zipSrc = fs.getSrc();
@@ -547,7 +552,9 @@ public class Zip extends MatchingTask {
} }
} }


if (!zipFile.exists()) return false;
if (!zipFile.exists()) {
return false;
}


SourceFileScanner sfs = new SourceFileScanner(this); SourceFileScanner sfs = new SourceFileScanner(this);
MergingMapper mm = new MergingMapper(); MergingMapper mm = new MergingMapper();
@@ -571,8 +578,9 @@ public class Zip extends MatchingTask {
Vector files = new Vector(); Vector files = new Vector();
for (int i = 0; i < fileNames.length; i++) { for (int i = 0; i < fileNames.length; i++) {
File thisBaseDir = scanners[i].getBasedir(); File thisBaseDir = scanners[i].getBasedir();
for (int j = 0; j < fileNames[i].length; j++)
for (int j = 0; j < fileNames[i].length; j++) {
files.addElement(new File(thisBaseDir, fileNames[i][j])); files.addElement(new File(thisBaseDir, fileNames[i][j]));
}
} }
File[] toret = new File[files.size()]; File[] toret = new File[files.size()];
files.copyInto(toret); files.copyInto(toret);


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/optional/AdaptxLiaison.java View File

@@ -95,8 +95,9 @@ public class AdaptxLiaison implements XSLTLiaison {
} }


public void setOutputtype(String type) throws Exception { public void setOutputtype(String type) throws Exception {
if (!type.equals("xml"))
if (!type.equals("xml")) {
throw new BuildException("Unsupported output type: " + type); throw new BuildException("Unsupported output type: " + type);
}
} }


} //-- AdaptxLiaison } //-- AdaptxLiaison

+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java View File

@@ -173,7 +173,9 @@ public class Rpm extends Task {
Execute exe = new Execute(streamhandler, null); Execute exe = new Execute(streamhandler, null);


exe.setAntRun(project); exe.setAntRun(project);
if (topDir == null) topDir = project.getBaseDir();
if (topDir == null) {
topDir = project.getBaseDir();
}
exe.setWorkingDirectory(topDir); exe.setWorkingDirectory(topDir);


exe.setCommandline(toExecute.getCommandline()); exe.setCommandline(toExecute.getCommandline());


+ 7
- 3
src/main/org/apache/tools/ant/taskdefs/optional/Script.java View File

@@ -83,10 +83,13 @@ public class Script extends Task {
boolean isValid = key.length()>0 && boolean isValid = key.length()>0 &&
Character.isJavaIdentifierStart(key.charAt(0)); Character.isJavaIdentifierStart(key.charAt(0));


for (int i=1; isValid && i<key.length(); i++)
for (int i=1; isValid && i<key.length(); i++) {
isValid = Character.isJavaIdentifierPart(key.charAt(i)); isValid = Character.isJavaIdentifierPart(key.charAt(i));
}


if (isValid) beans.put(key, dictionary.get(key));
if (isValid) {
beans.put(key, dictionary.get(key));
}
} }
} }


@@ -146,8 +149,9 @@ public class Script extends Task {
*/ */
public void setSrc(String fileName) { public void setSrc(String fileName) {
File file = new File(fileName); File file = new File(fileName);
if (!file.exists())
if (!file.exists()) {
throw new BuildException("file " + fileName + " not found."); throw new BuildException("file " + fileName + " not found.");
}


int count = (int)file.length(); int count = (int)file.length();
byte data[] = new byte[count]; byte data[] = new byte[count];


+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java View File

@@ -196,7 +196,9 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware
if(e.getLocator() != null) { if(e.getLocator() != null) {
if(e.getLocator().getSystemId() != null) { if(e.getLocator().getSystemId() != null) {
String url = e.getLocator().getSystemId(); String url = e.getLocator().getSystemId();
if(url.startsWith("file:///")) url = url.substring(8);
if(url.startsWith("file:///")) {
url = url.substring(8);
}
msg.append(url); msg.append(url);
} else { } else {
msg.append("Unknown file"); msg.append("Unknown file");


+ 16
- 9
src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java View File

@@ -256,10 +256,11 @@ public class XMLValidateTask extends Task {
} }
else { else {
String errorMsg = "File " + file + " cannot be read"; String errorMsg = "File " + file + " cannot be read";
if (failOnError)
if (failOnError) {
throw new BuildException(errorMsg); throw new BuildException(errorMsg);
else
} else {
log(errorMsg, Project.MSG_ERR); log(errorMsg, Project.MSG_ERR);
}
} }
} }


@@ -295,8 +296,9 @@ public class XMLValidateTask extends Task {
// loader.addSystemPackageRoot("org.xml"); // needed to avoid conflict // loader.addSystemPackageRoot("org.xml"); // needed to avoid conflict
readerClass = loader.loadClass(readerClassName); readerClass = loader.loadClass(readerClassName);
AntClassLoader.initializeClass(readerClass); AntClassLoader.initializeClass(readerClass);
} else
} else {
readerClass = Class.forName(readerClassName); readerClass = Class.forName(readerClassName);
}


// then check it implements XMLReader // then check it implements XMLReader
if (XMLReader.class.isAssignableFrom(readerClass)) { if (XMLReader.class.isAssignableFrom(readerClass)) {
@@ -357,17 +359,19 @@ public class XMLValidateTask extends Task {
xmlReader.setFeature(feature,value); xmlReader.setFeature(feature,value);
toReturn = true; toReturn = true;
} catch (SAXNotRecognizedException e) { } catch (SAXNotRecognizedException e) {
if (warn)
if (warn) {
log("Could not set feature '" log("Could not set feature '"
+ feature + feature
+ "' because the parser doesn't recognize it", + "' because the parser doesn't recognize it",
Project.MSG_WARN); Project.MSG_WARN);
}
} catch (SAXNotSupportedException e) { } catch (SAXNotSupportedException e) {
if (warn)
if (warn) {
log("Could not set feature '" log("Could not set feature '"
+ feature + feature
+ "' because the parser doesn't support it", + "' because the parser doesn't support it",
Project.MSG_WARN); Project.MSG_WARN);
}
} }
return toReturn; return toReturn;
} }
@@ -387,17 +391,19 @@ public class XMLValidateTask extends Task {
is.setSystemId(uri); is.setSystemId(uri);
xmlReader.parse(is); xmlReader.parse(is);
} catch (SAXException ex) { } catch (SAXException ex) {
if (failOnError)
if (failOnError) {
throw new BuildException("Could not validate document " + afile); throw new BuildException("Could not validate document " + afile);
}
} catch (IOException ex) { } catch (IOException ex) {
throw new BuildException("Could not validate document " + afile, ex); throw new BuildException("Could not validate document " + afile, ex);
} }


if (errorHandler.getFailure()) { if (errorHandler.getFailure()) {
if (failOnError)
if (failOnError) {
throw new BuildException(afile + " is not a valid XML document."); throw new BuildException(afile + " is not a valid XML document.");
else
} else {
log(afile + " is not a valid XML document",Project.MSG_ERR); log(afile + " is not a valid XML document",Project.MSG_ERR);
}
} }
} }


@@ -438,8 +444,9 @@ public class XMLValidateTask extends Task {
public void warning(SAXParseException exception) { public void warning(SAXParseException exception) {
// depending on implementation, XMLReader can yield hips of warning, // depending on implementation, XMLReader can yield hips of warning,
// only output then if user explicitely asked for it // only output then if user explicitely asked for it
if (warn)
if (warn) {
doLog(exception,Project.MSG_WARN); doLog(exception,Project.MSG_WARN);
}
} }


private void doLog(SAXParseException e, int logLevel) { private void doLog(SAXParseException e, int logLevel) {


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java View File

@@ -130,7 +130,8 @@ public class XalanLiaison implements XSLTLiaison {
} }


public void setOutputtype(String type) throws Exception { public void setOutputtype(String type) throws Exception {
if (!type.equals("xml"))
if (!type.equals("xml")) {
throw new BuildException("Unsupported output type: " + type); throw new BuildException("Unsupported output type: " + type);
}
} }
} //-- XalanLiaison } //-- XalanLiaison

+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java View File

@@ -105,8 +105,9 @@ public class XslpLiaison implements XSLTLiaison {
} }


public void setOutputtype(String type) throws Exception { public void setOutputtype(String type) throws Exception {
if (!type.equals("xml"))
if (!type.equals("xml")) {
throw new BuildException("Unsupported output type: " + type); throw new BuildException("Unsupported output type: " + type);
}
} }


} //-- XSLPLiaison } //-- XSLPLiaison

+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java View File

@@ -1036,9 +1036,10 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {






if (getCombinedClasspath() != null && getCombinedClasspath().toString().length() > 0)
if (getCombinedClasspath() != null && getCombinedClasspath().toString().length() > 0) {


args += " -cp " + getCombinedClasspath(); args += " -cp " + getCombinedClasspath();
}








+ 32
- 16
src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java View File

@@ -258,8 +258,9 @@ public class VAJAntToolGUI extends Frame {
public void messageLogged(BuildEvent event) { public void messageLogged(BuildEvent event) {
if (event.getPriority() <= getBuildInfo().getOutputMessageLevel()) { if (event.getPriority() <= getBuildInfo().getOutputMessageLevel()) {
String msg = ""; String msg = "";
if (event.getTask() != null)
if (event.getTask() != null) {
msg = "[" + event.getTask().getTaskName() + "] "; msg = "[" + event.getTask().getTaskName() + "] ";
}
getMessageTextArea().append(lineSeparator + msg + event.getMessage()); getMessageTextArea().append(lineSeparator + msg + event.getMessage());
} }
} }
@@ -345,22 +346,29 @@ public class VAJAntToolGUI extends Frame {
} }
} }
// MenuItems // MenuItems
if (e.getSource() == VAJAntToolGUI.this.getSaveMenuItem())
if (e.getSource() == VAJAntToolGUI.this.getSaveMenuItem()) {
saveBuildInfo(); saveBuildInfo();
if (e.getSource() == VAJAntToolGUI.this.getAboutMenuItem())
}
if (e.getSource() == VAJAntToolGUI.this.getAboutMenuItem()) {
getAboutDialog().show(); getAboutDialog().show();
if (e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem())
}
if (e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem()) {
getMessageFrame().show(); getMessageFrame().show();
}
/* #### About dialog #### */ /* #### About dialog #### */
if (e.getSource() == VAJAntToolGUI.this.getAboutOkButton())
if (e.getSource() == VAJAntToolGUI.this.getAboutOkButton()) {
getAboutDialog().dispose(); getAboutDialog().dispose();
}
/* #### Log frame #### */ /* #### Log frame #### */
if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton())
if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) {
getMessageFrame().dispose(); getMessageFrame().dispose();
if (e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton())
}
if (e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton()) {
getMessageTextArea().setText(""); getMessageTextArea().setText("");
if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton())
}
if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton()) {
getMessageFrame().dispose(); getMessageFrame().dispose();
}
} }
catch (Throwable exc) { catch (Throwable exc) {
handleException(exc); handleException(exc);
@@ -372,12 +380,15 @@ public class VAJAntToolGUI extends Frame {
*/ */
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
try { try {
if (e.getSource() == VAJAntToolGUI.this.getTargetList())
if (e.getSource() == VAJAntToolGUI.this.getTargetList()) {
getBuildButton().setEnabled(true); getBuildButton().setEnabled(true);
if (e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice())
}
if (e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice()) {
getBuildInfo().setOutputMessageLevel(getMessageOutputLevelChoice().getSelectedIndex()); getBuildInfo().setOutputMessageLevel(getMessageOutputLevelChoice().getSelectedIndex());
if (e.getSource() == VAJAntToolGUI.this.getTargetList())
}
if (e.getSource() == VAJAntToolGUI.this.getTargetList()) {
getBuildInfo().setTarget(getTargetList().getSelectedItem()); getBuildInfo().setTarget(getTargetList().getSelectedItem());
}
} }
catch (Throwable exc) { catch (Throwable exc) {
handleException(exc); handleException(exc);
@@ -388,18 +399,21 @@ public class VAJAntToolGUI extends Frame {
* PropertyChangeListener method * PropertyChangeListener method
*/ */
public void propertyChange(java.beans.PropertyChangeEvent evt) { public void propertyChange(java.beans.PropertyChangeEvent evt) {
if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("projectName")))
if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("projectName"))) {
connectProjectNameToLabel(); connectProjectNameToLabel();
if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("buildFileName")))
}
if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("buildFileName"))) {
connectBuildFileNameToTextField(); connectBuildFileNameToTextField();
}
} }


/** /**
* TextListener method * TextListener method
*/ */
public void textValueChanged(TextEvent e) { public void textValueChanged(TextEvent e) {
if (e.getSource() == VAJAntToolGUI.this.getBuildFileTextField())
if (e.getSource() == VAJAntToolGUI.this.getBuildFileTextField()) {
connectTextFieldToBuildFileName(); connectTextFieldToBuildFileName();
}
} }


/** /**
@@ -411,10 +425,12 @@ public class VAJAntToolGUI extends Frame {
dispose(); dispose();
System.exit(0); System.exit(0);
} }
if (e.getSource() == VAJAntToolGUI.this.getAboutDialog())
if (e.getSource() == VAJAntToolGUI.this.getAboutDialog()) {
getAboutDialog().dispose(); getAboutDialog().dispose();
if (e.getSource() == VAJAntToolGUI.this.getMessageFrame())
}
if (e.getSource() == VAJAntToolGUI.this.getMessageFrame()) {
getMessageFrame().dispose(); getMessageFrame().dispose();
}
} }
catch (Throwable exc) { catch (Throwable exc) {
handleException(exc); handleException(exc);


+ 18
- 9
src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java View File

@@ -123,15 +123,18 @@ public class TelnetTask extends Task {
public void execute() throws BuildException public void execute() throws BuildException
{ {
/** A server name is required to continue */ /** A server name is required to continue */
if (server== null)
if (server== null) {
throw new BuildException("No Server Specified"); throw new BuildException("No Server Specified");
}
/** A userid and password must appear together /** A userid and password must appear together
* if they appear. They are not required. * if they appear. They are not required.
*/ */
if (userid == null && password != null)
if (userid == null && password != null) {
throw new BuildException("No Userid Specified"); throw new BuildException("No Userid Specified");
if (password == null && userid != null)
}
if (password == null && userid != null) {
throw new BuildException("No Password Specified"); throw new BuildException("No Password Specified");
}


/** Create the telnet client object */ /** Create the telnet client object */
telnet = new AntTelnetClient(); telnet = new AntTelnetClient();
@@ -141,15 +144,17 @@ public class TelnetTask extends Task {
throw new BuildException("Can't connect to "+server); throw new BuildException("Can't connect to "+server);
} }
/** Login if userid and password were specified */ /** Login if userid and password were specified */
if (userid != null && password != null)
if (userid != null && password != null) {
login(); login();
}
/** Process each sub command */ /** Process each sub command */
Enumeration tasksToRun = telnetTasks.elements(); Enumeration tasksToRun = telnetTasks.elements();
while (tasksToRun!=null && tasksToRun.hasMoreElements()) while (tasksToRun!=null && tasksToRun.hasMoreElements())
{ {
TelnetSubTask task = (TelnetSubTask) tasksToRun.nextElement(); TelnetSubTask task = (TelnetSubTask) tasksToRun.nextElement();
if (task instanceof TelnetRead && defaultTimeout != null)
if (task instanceof TelnetRead && defaultTimeout != null) {
((TelnetRead)task).setDefaultTimeout(defaultTimeout); ((TelnetRead)task).setDefaultTimeout(defaultTimeout);
}
task.execute(telnet); task.execute(telnet);
} }
} }
@@ -160,8 +165,9 @@ public class TelnetTask extends Task {
*/ */
private void login() private void login()
{ {
if (addCarriageReturn)
if (addCarriageReturn) {
telnet.sendString("\n", true); telnet.sendString("\n", true);
}
telnet.waitForString("ogin:"); telnet.waitForString("ogin:");
telnet.sendString(userid, true); telnet.sendString(userid, true);
telnet.waitForString("assword:"); telnet.waitForString("assword:");
@@ -287,8 +293,9 @@ public class TelnetTask extends Task {
*/ */
public void setDefaultTimeout(Integer defaultTimeout) public void setDefaultTimeout(Integer defaultTimeout)
{ {
if (timeout == null)
if (timeout == null) {
timeout = defaultTimeout; timeout = defaultTimeout;
}
} }
} }
/** /**
@@ -336,8 +343,9 @@ public class TelnetTask extends Task {
is.available() == 0) { is.available() == 0) {
Thread.sleep(250); Thread.sleep(250);
} }
if (is.available() == 0)
if (is.available() == 0) {
throw new BuildException("Response Timed-Out", getLocation()); throw new BuildException("Response Timed-Out", getLocation());
}
sb.append((char) is.read()); sb.append((char) is.read());
} }
} }
@@ -361,8 +369,9 @@ public class TelnetTask extends Task {
OutputStream os =this.getOutputStream(); OutputStream os =this.getOutputStream();
try { try {
os.write((s + "\n").getBytes()); os.write((s + "\n").getBytes());
if (echoString)
if (echoString) {
log(s, Project.MSG_INFO); log(s, Project.MSG_INFO);
}
os.flush(); os.flush();
} catch (Exception e) } catch (Exception e)
{ {


+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/optional/perforce/SimpleP4OutputHandler.java View File

@@ -69,7 +69,9 @@ public class SimpleP4OutputHandler extends P4HandlerAdapter {
} }


public void process(String line) throws BuildException { public void process(String line) throws BuildException {
if(parent.util.match("/^exit/",line)) return;
if(parent.util.match("/^exit/",line)) {
return;
}


//Throw exception on errors (except up-to-date) //Throw exception on errors (except up-to-date)
//p4 -s is unpredicatable. For example a server down //p4 -s is unpredicatable. For example a server down


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java View File

@@ -434,8 +434,9 @@ public abstract class TreeBasedTask extends StarTeamTask {
if (null != this.label) { if (null != this.label) {
Label[] allLabels = v.getLabels(); Label[] allLabels = v.getLabels();
for (int i = 0; i < allLabels.length; i++) { for (int i = 0; i < allLabels.length; i++) {
if (allLabels[i].getName().equals(this.label))
if (allLabels[i].getName().equals(this.label)) {
return allLabels[i].getID(); return allLabels[i].getID();
}
} }
throw new BuildException("Error: label " throw new BuildException("Error: label "
+ this.label + this.label


+ 2
- 1
src/main/org/apache/tools/ant/types/Substitution.java View File

@@ -93,8 +93,9 @@ public class Substitution extends DataType
*/ */
public String getExpression(Project p) public String getExpression(Project p)
{ {
if (isReference())
if (isReference()) {
return getRef(p).getExpression(p); return getRef(p).getExpression(p);
}


return expression; return expression;
} }


Loading…
Cancel
Save