cleanups. Make sure <uptodate> honors property immutability rules. Remove redundant Enumeration class from ConditionBase (IntrospectionHelper will have taken care of it now). git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272364 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -90,6 +90,8 @@ import java.util.Enumeration; | |||||
| * | * | ||||
| * @author costin@dnt.ro | * @author costin@dnt.ro | ||||
| * | * | ||||
| * @since Ant 1.1 | |||||
| * | |||||
| * @ant.task category="control" | * @ant.task category="control" | ||||
| */ | */ | ||||
| public class Ant extends Task { | public class Ant extends Task { | ||||
| @@ -79,6 +79,8 @@ import java.io.IOException; | |||||
| * | * | ||||
| * @version $Revision$ | * @version $Revision$ | ||||
| * | * | ||||
| * @since Ant 1.1 | |||||
| * | |||||
| * @ant.task category="xml" | * @ant.task category="xml" | ||||
| */ | */ | ||||
| @@ -73,6 +73,8 @@ import org.apache.tools.ant.util.StringUtils; | |||||
| * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> | * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> | ||||
| * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a> | * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a> | ||||
| * | * | ||||
| * @since Ant 1.1 | |||||
| * | |||||
| * @ant.task category="control" | * @ant.task category="control" | ||||
| */ | */ | ||||
| public class Available extends Task implements Condition { | public class Available extends Task implements Condition { | ||||
| @@ -79,6 +79,8 @@ import org.apache.tools.ant.BuildException; | |||||
| * | * | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * | * | ||||
| * @since Ant 1.2 | |||||
| * | |||||
| * @ant.task name="antcall" category="control" | * @ant.task name="antcall" category="control" | ||||
| */ | */ | ||||
| public class CallTarget extends Task { | public class CallTarget extends Task { | ||||
| @@ -71,6 +71,8 @@ import org.apache.tools.ant.types.PatternSet; | |||||
| * @author Mariusz Nowostawski (Marni) <a href="mailto:mnowostawski@infoscience.otago.ac.nz">mnowostawski@infoscience.otago.ac.nz</a> | * @author Mariusz Nowostawski (Marni) <a href="mailto:mnowostawski@infoscience.otago.ac.nz">mnowostawski@infoscience.otago.ac.nz</a> | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * | * | ||||
| * @since Ant 1.1 | |||||
| * | |||||
| * @ant.task category="filesystem" | * @ant.task category="filesystem" | ||||
| */ | */ | ||||
| public class Chmod extends ExecuteOn { | public class Chmod extends ExecuteOn { | ||||
| @@ -71,6 +71,8 @@ import org.apache.tools.ant.taskdefs.condition.ConditionBase; | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @version $Revision$ | * @version $Revision$ | ||||
| * | * | ||||
| * @since Ant 1.4 | |||||
| * | |||||
| * @ant.task category="control" | * @ant.task category="control" | ||||
| */ | */ | ||||
| public class ConditionTask extends ConditionBase { | public class ConditionTask extends ConditionBase { | ||||
| @@ -75,7 +75,9 @@ import java.io.IOException; | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @author <a href="mailto:mariusz@rakiura.org">Mariusz Nowostawski</a> | * @author <a href="mailto:mariusz@rakiura.org">Mariusz Nowostawski</a> | ||||
| * | * | ||||
| * @ant.task name="execon" | |||||
| * @since Ant 1.2 | |||||
| * | |||||
| * @ant.task name="apply" category="control" | |||||
| */ | */ | ||||
| public class ExecuteOn extends ExecTask { | public class ExecuteOn extends ExecTask { | ||||
| @@ -69,6 +69,8 @@ import java.util.zip.GZIPInputStream; | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a> | * @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a> | ||||
| * | * | ||||
| * @since Ant 1.1 | |||||
| * | |||||
| * @ant.task category="packaging" | * @ant.task category="packaging" | ||||
| */ | */ | ||||
| @@ -68,6 +68,8 @@ import java.util.zip.GZIPOutputStream; | |||||
| * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> | * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> | ||||
| * @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a> | * @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a> | ||||
| * | * | ||||
| * @since Ant 1.1 | |||||
| * | |||||
| * @ant.task category="packaging" | * @ant.task category="packaging" | ||||
| */ | */ | ||||
| @@ -58,7 +58,5 @@ package org.apache.tools.ant.taskdefs; | |||||
| * Has been merged into ExecuteOn, empty class for backwards compatibility. | * Has been merged into ExecuteOn, empty class for backwards compatibility. | ||||
| * | * | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * | |||||
| * @ant.task name="apply" category="control" | |||||
| */ | */ | ||||
| public class Transform extends ExecuteOn {} | public class Transform extends ExecuteOn {} | ||||
| @@ -77,6 +77,8 @@ import java.util.Vector; | |||||
| * @author Hiroaki Nakamura <a href="mailto:hnakamur@mc.neweb.ne.jp">hnakamur@mc.neweb.ne.jp</a> | * @author Hiroaki Nakamura <a href="mailto:hnakamur@mc.neweb.ne.jp">hnakamur@mc.neweb.ne.jp</a> | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * | * | ||||
| * @since Ant 1.2 | |||||
| * | |||||
| * @ant.task category="control" | * @ant.task category="control" | ||||
| */ | */ | ||||
| @@ -162,15 +164,19 @@ public class UpToDate extends Task implements Condition { | |||||
| */ | */ | ||||
| public boolean eval() { | public boolean eval() { | ||||
| if (sourceFileSets.size() == 0 && _sourceFile == null) { | if (sourceFileSets.size() == 0 && _sourceFile == null) { | ||||
| throw new BuildException("At least one srcfile or a nested <srcfiles> element must be set."); | |||||
| throw new BuildException("At least one srcfile or a nested " | |||||
| + "<srcfiles> element must be set."); | |||||
| } | } | ||||
| if (sourceFileSets.size() > 0 && _sourceFile != null) { | if (sourceFileSets.size() > 0 && _sourceFile != null) { | ||||
| throw new BuildException("Cannot specify both the srcfile attribute and a nested <srcfiles> element."); | |||||
| throw new BuildException("Cannot specify both the srcfile " | |||||
| + "attribute and a nested <srcfiles> " | |||||
| + "element."); | |||||
| } | } | ||||
| if (_targetFile == null && mapperElement == null) { | if (_targetFile == null && mapperElement == null) { | ||||
| throw new BuildException("The targetfile attribute or a nested mapper element must be set."); | |||||
| throw new BuildException("The targetfile attribute or a nested " | |||||
| + "mapper element must be set."); | |||||
| } | } | ||||
| // if the target file is not there, then it can't be up-to-date | // if the target file is not there, then it can't be up-to-date | ||||
| @@ -180,8 +186,9 @@ public class UpToDate extends Task implements Condition { | |||||
| // if the source file isn't there, throw an exception | // if the source file isn't there, throw an exception | ||||
| if (_sourceFile != null && !_sourceFile.exists()) { | if (_sourceFile != null && !_sourceFile.exists()) { | ||||
| throw new BuildException(_sourceFile.getAbsolutePath() + " not found."); | |||||
| } | |||||
| throw new BuildException(_sourceFile.getAbsolutePath() | |||||
| + " not found."); | |||||
| } | |||||
| Enumeration enum = sourceFileSets.elements(); | Enumeration enum = sourceFileSets.elements(); | ||||
| boolean upToDate = true; | boolean upToDate = true; | ||||
| @@ -216,10 +223,10 @@ public class UpToDate extends Task implements Condition { | |||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| boolean upToDate = eval(); | boolean upToDate = eval(); | ||||
| if (upToDate) { | if (upToDate) { | ||||
| this.project.setProperty(_property, this.getValue()); | |||||
| this.project.setNewProperty(_property, getValue()); | |||||
| if (mapperElement == null) { | if (mapperElement == null) { | ||||
| log("File \"" + _targetFile.getAbsolutePath() + "\" is up-to-date.", | |||||
| Project.MSG_VERBOSE); | |||||
| log("File \"" + _targetFile.getAbsolutePath() | |||||
| + "\" is up-to-date.", Project.MSG_VERBOSE); | |||||
| } else { | } else { | ||||
| log("All target files are up-to-date.", | log("All target files are up-to-date.", | ||||
| Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
| * reserved. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -65,6 +65,7 @@ import org.apache.tools.ant.BuildException; | |||||
| * evaluates to false.</p> | * evaluates to false.</p> | ||||
| * | * | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @since Ant 1.4 | |||||
| * @version $Revision$ | * @version $Revision$ | ||||
| */ | */ | ||||
| public class And extends ConditionBase implements Condition { | public class And extends ConditionBase implements Condition { | ||||
| @@ -70,6 +70,7 @@ import org.apache.tools.ant.taskdefs.UpToDate; | |||||
| * and the "container" conditions are in sync. | * and the "container" conditions are in sync. | ||||
| * | * | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @since Ant 1.4 | |||||
| * @version $Revision$ | * @version $Revision$ | ||||
| */ | */ | ||||
| public abstract class ConditionBase extends ProjectComponent { | public abstract class ConditionBase extends ProjectComponent { | ||||
| @@ -88,7 +89,7 @@ public abstract class ConditionBase extends ProjectComponent { | |||||
| * @since 1.1 | * @since 1.1 | ||||
| */ | */ | ||||
| protected final Enumeration getConditions() { | protected final Enumeration getConditions() { | ||||
| return new ConditionEnumeration(); | |||||
| return conditions.elements(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -182,31 +183,4 @@ public abstract class ConditionBase extends ProjectComponent { | |||||
| */ | */ | ||||
| public void addContains(Contains test) {conditions.addElement(test);} | public void addContains(Contains test) {conditions.addElement(test);} | ||||
| /** | |||||
| * Inner class that configures those conditions with a project | |||||
| * instance that need it. | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| private class ConditionEnumeration implements Enumeration { | |||||
| private int currentElement = 0; | |||||
| public boolean hasMoreElements() { | |||||
| return countConditions() > currentElement; | |||||
| } | |||||
| public Object nextElement() throws NoSuchElementException { | |||||
| Object o = null; | |||||
| try { | |||||
| o = conditions.elementAt(currentElement++); | |||||
| } catch (ArrayIndexOutOfBoundsException e) { | |||||
| throw new NoSuchElementException(); | |||||
| } | |||||
| if (o instanceof ProjectComponent) { | |||||
| ((ProjectComponent) o).setProject(getProject()); | |||||
| } | |||||
| return o; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -101,7 +101,8 @@ public class Contains implements Condition { | |||||
| */ | */ | ||||
| public boolean eval() throws BuildException { | public boolean eval() throws BuildException { | ||||
| if (string == null || subString == null) { | if (string == null || subString == null) { | ||||
| throw new BuildException("both string and substring are required in contains"); | |||||
| throw new BuildException("both string and substring are required " | |||||
| + "in contains"); | |||||
| } | } | ||||
| return caseSensitive | return caseSensitive | ||||
| @@ -60,6 +60,7 @@ import org.apache.tools.ant.BuildException; | |||||
| * Simple String comparison condition. | * Simple String comparison condition. | ||||
| * | * | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @since Ant 1.4 | |||||
| * @version $Revision$ | * @version $Revision$ | ||||
| */ | */ | ||||
| public class Equals implements Condition { | public class Equals implements Condition { | ||||
| @@ -96,7 +97,8 @@ public class Equals implements Condition { | |||||
| public boolean eval() throws BuildException { | public boolean eval() throws BuildException { | ||||
| if (arg1 == null || arg2 == null) { | if (arg1 == null || arg2 == null) { | ||||
| throw new BuildException("both arg1 and arg2 are required in equals"); | |||||
| throw new BuildException("both arg1 and arg2 are required in " | |||||
| + "equals"); | |||||
| } | } | ||||
| if (trim) { | if (trim) { | ||||
| @@ -59,8 +59,8 @@ import java.io.File; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| /** | /** | ||||
| * Compares two files for bitwise equality based on size and content. Timestamps | |||||
| * are not looked at at all. | |||||
| * Compares two files for bitwise equality based on size and | |||||
| * content. Timestamps are not looked at at all. | |||||
| * | * | ||||
| * @author Steve Loughran | * @author Steve Loughran | ||||
| * @version $Revision$ | * @version $Revision$ | ||||
| @@ -109,7 +109,8 @@ public class FilesMatch implements Condition { | |||||
| //validate | //validate | ||||
| if (file1 == null || file2 == null) { | if (file1 == null || file2 == null) { | ||||
| throw new BuildException("both file1 and file2 are required in filesmatch"); | |||||
| throw new BuildException("both file1 and file2 are required in " | |||||
| + "filesmatch"); | |||||
| } | } | ||||
| //#now match the files | //#now match the files | ||||
| @@ -117,7 +118,8 @@ public class FilesMatch implements Condition { | |||||
| try { | try { | ||||
| matches=fu.contentEquals(file1, file2); | matches=fu.contentEquals(file1, file2); | ||||
| } catch(IOException ioe) { | } catch(IOException ioe) { | ||||
| throw new BuildException("when comparing files", ioe); | |||||
| throw new BuildException("when comparing files: "+ioe.getMessage(), | |||||
| ioe); | |||||
| } | } | ||||
| return matches; | return matches; | ||||
| } | } | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
| * reserved. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -69,9 +69,10 @@ import java.net.URL; | |||||
| * url - the URL of the request. | * url - the URL of the request. | ||||
| * | * | ||||
| * @author <a href="mailto:denis@network365.com">Denis Hennessy</a> | * @author <a href="mailto:denis@network365.com">Denis Hennessy</a> | ||||
| * @since Ant 1.5 | |||||
| */ | */ | ||||
| public class Http extends ProjectComponent implements Condition { | public class Http extends ProjectComponent implements Condition { | ||||
| String spec = null; | |||||
| private String spec = null; | |||||
| public void setUrl(String url) { | public void setUrl(String url) { | ||||
| spec = url; | spec = url; | ||||
| @@ -79,7 +80,7 @@ public class Http extends ProjectComponent implements Condition { | |||||
| public boolean eval() throws BuildException { | public boolean eval() throws BuildException { | ||||
| if (spec == null) { | if (spec == null) { | ||||
| throw new BuildException("No url specified in HTTP task"); | |||||
| throw new BuildException("No url specified in http condition"); | |||||
| } | } | ||||
| log("Checking for " + spec, Project.MSG_VERBOSE); | log("Checking for " + spec, Project.MSG_VERBOSE); | ||||
| try { | try { | ||||
| @@ -89,7 +90,8 @@ public class Http extends ProjectComponent implements Condition { | |||||
| if (conn instanceof HttpURLConnection) { | if (conn instanceof HttpURLConnection) { | ||||
| HttpURLConnection http = (HttpURLConnection) conn; | HttpURLConnection http = (HttpURLConnection) conn; | ||||
| int code = http.getResponseCode(); | int code = http.getResponseCode(); | ||||
| log("Result code for " + spec + " was " + code, Project.MSG_VERBOSE); | |||||
| log("Result code for " + spec + " was " + code, | |||||
| Project.MSG_VERBOSE); | |||||
| if (code > 0 && code < 500) { | if (code > 0 && code < 500) { | ||||
| return true; | return true; | ||||
| } else { | } else { | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
| * reserved. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -61,6 +61,7 @@ import org.apache.tools.ant.ProjectComponent; | |||||
| * Condition that tests whether a given property has been set. | * Condition that tests whether a given property has been set. | ||||
| * | * | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @since Ant 1.5 | |||||
| * @version $Revision$ | * @version $Revision$ | ||||
| */ | */ | ||||
| public class IsSet extends ProjectComponent implements Condition { | public class IsSet extends ProjectComponent implements Condition { | ||||
| @@ -70,7 +71,8 @@ public class IsSet extends ProjectComponent implements Condition { | |||||
| public boolean eval() throws BuildException { | public boolean eval() throws BuildException { | ||||
| if (property == null) { | if (property == null) { | ||||
| throw new BuildException("No property specified for isset condition"); | |||||
| throw new BuildException("No property specified for isset " | |||||
| + "condition"); | |||||
| } | } | ||||
| return getProject().getProperty(property) != null; | return getProject().getProperty(property) != null; | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
| * reserved. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -63,6 +63,7 @@ import org.apache.tools.ant.BuildException; | |||||
| * and vice versa. | * and vice versa. | ||||
| * | * | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @since Ant 1.4 | |||||
| * @version $Revision$ | * @version $Revision$ | ||||
| */ | */ | ||||
| public class Not extends ConditionBase implements Condition { | public class Not extends ConditionBase implements Condition { | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
| * reserved. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -65,6 +65,7 @@ import org.apache.tools.ant.BuildException; | |||||
| * evaluates to true.</p> | * evaluates to true.</p> | ||||
| * | * | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @since Ant 1.4 | |||||
| * @version $Revision$ | * @version $Revision$ | ||||
| */ | */ | ||||
| public class Or extends ConditionBase implements Condition { | public class Or extends ConditionBase implements Condition { | ||||
| @@ -63,6 +63,7 @@ import java.util.Locale; | |||||
| * | * | ||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a> | * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a> | ||||
| * @since Ant 1.4 | |||||
| * @version $Revision$ | * @version $Revision$ | ||||
| */ | */ | ||||
| public class Os implements Condition { | public class Os implements Condition { | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
| * reserved. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -66,10 +66,11 @@ import java.io.IOException; | |||||
| * port - the port number of the socket. | * port - the port number of the socket. | ||||
| * | * | ||||
| * @author <a href="mailto:denis@network365.com">Denis Hennessy</a> | * @author <a href="mailto:denis@network365.com">Denis Hennessy</a> | ||||
| * @since Ant 1.5 | |||||
| */ | */ | ||||
| public class Socket extends ProjectComponent implements Condition { | public class Socket extends ProjectComponent implements Condition { | ||||
| String server = null; | |||||
| int port = 0; | |||||
| private String server = null; | |||||
| private int port = 0; | |||||
| public void setServer(String server) { | public void setServer(String server) { | ||||
| this.server = server; | this.server = server; | ||||
| @@ -81,12 +82,14 @@ public class Socket extends ProjectComponent implements Condition { | |||||
| public boolean eval() throws BuildException { | public boolean eval() throws BuildException { | ||||
| if (server == null) { | if (server == null) { | ||||
| throw new BuildException("No server specified in Socket task"); | |||||
| throw new BuildException("No server specified in socket " | |||||
| + "condition"); | |||||
| } | } | ||||
| if (port == 0) { | if (port == 0) { | ||||
| throw new BuildException("No port specified in Socket task"); | |||||
| throw new BuildException("No port specified in socket condition"); | |||||
| } | } | ||||
| log("Checking for listener at " + server + ":" + port, Project.MSG_VERBOSE); | |||||
| log("Checking for listener at " + server + ":" + port, | |||||
| Project.MSG_VERBOSE); | |||||
| try { | try { | ||||
| java.net.Socket socket = new java.net.Socket(server, port); | java.net.Socket socket = new java.net.Socket(server, port); | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||