You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2009/02/11 06:02:36 UTC

svn commit: r743227 [1/2] - in /ant/core/trunk/src: main/org/apache/tools/ant/ main/org/apache/tools/ant/input/ main/org/apache/tools/ant/listener/ main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/condition/ main/org/apache/tools/...

Author: bodewig
Date: Wed Feb 11 05:02:33 2009
New Revision: 743227

URL: http://svn.apache.org/viewvc?rev=743227&view=rev
Log:
fix linefeeds

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/TaskConfigurationChecker.java   (contents, props changed)
    ant/core/trunk/src/main/org/apache/tools/ant/input/SecureInputHandler.java   (contents, props changed)
    ant/core/trunk/src/main/org/apache/tools/ant/listener/ProfileLogger.java   (contents, props changed)
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/HostInfo.java   (contents, props changed)
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Retry.java   (contents, props changed)
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java   (contents, props changed)
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java   (contents, props changed)
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java   (contents, props changed)
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileProvider.java   (contents, props changed)
    ant/core/trunk/src/tests/antunit/core/location/location.xml   (contents, props changed)
    ant/core/trunk/src/tests/antunit/core/location/src/task/EchoLocation.java   (contents, props changed)
    ant/core/trunk/src/tests/antunit/taskdefs/condition/antversion-test.xml   (contents, props changed)
    ant/core/trunk/src/tests/antunit/taskdefs/condition/hasfreespace-test.xml   (contents, props changed)
    ant/core/trunk/src/tests/antunit/taskdefs/echoxml-test.xml   (contents, props changed)
    ant/core/trunk/src/tests/antunit/taskdefs/gzip-test.xml   (contents, props changed)
    ant/core/trunk/src/tests/antunit/taskdefs/hostinfo-test.xml   (contents, props changed)
    ant/core/trunk/src/tests/antunit/taskdefs/loadresource-test.xml   (contents, props changed)
    ant/core/trunk/src/tests/antunit/types/resources/files-test.xml   (contents, props changed)

Modified: ant/core/trunk/src/main/org/apache/tools/ant/TaskConfigurationChecker.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/TaskConfigurationChecker.java?rev=743227&r1=743226&r2=743227&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/TaskConfigurationChecker.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/TaskConfigurationChecker.java Wed Feb 11 05:02:33 2009
@@ -1,113 +1,113 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.tools.ant;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * <p>Helper class for the check of the configuration of a given task.
- * This class provides methods for making assumptions about the task configuration.
- * After collecting all violations with <tt>assert*</tt> and <tt>fail</tt>
- * methods the <tt>checkErrors</tt> will throw a BuildException with all collected
- * messages or does nothing if there wasn't any error.</p>
- *
- * <p>Example:</p>
- *
- * <pre>
- *     public class MyTask extends Task {
- *         ...
- *         public void execute() {
- *             TaskConfigurationChecker checker = TaskConfigurationChecker(this);
- *             checker.assertConfig(
- *                 srcdir != null,
- *                 "Attribute 'srcdir' must be set.
- *             );
- *             checker.assertConfig(
- *                 srcdir.exists(),
- *                 "Srcdir (" + srcdir + ") must exist."
- *             );
- *             if (someComplexCondition()) {
- *                 fail("Complex condition failed.");
- *             }
- *             checker.checkErrors();
- *         }
- *     }
- * </pre>
- *
- * @see <a href="http://martinfowler.com/eaaDev/Notification.html">Notification Pattern</a>
- */
-public class TaskConfigurationChecker {
-
-    /** List of all collected error messages. */
-    private List/*<String>*/ errors = new ArrayList();
-
-    /** Task for which the configuration should be checked. */
-    private final Task task;
-
-    /**
-     * Constructor.
-     * @param task which task should be checked
-     */
-    public TaskConfigurationChecker(Task task) {
-        this.task = task;
-    }
-
-    /**
-     * Asserts that a condition is true.
-     * @param condition     which condition to check
-     * @param errormessage  errormessage to throw if a condition failed
-     */
-    public void assertConfig(boolean condition, String errormessage) {
-        if (!condition) {
-            errors.add(errormessage);
-        }
-    }
-
-    /**
-     * Registers an error.
-     * @param errormessage the message for the registered error
-     */
-    public void fail(String errormessage) {
-        errors.add(errormessage);
-    }
-
-    /**
-     * Checks if there are any collected errors and throws a BuildException
-     * with all messages if there was one or more.
-     * @throws BuildException if one or more errors were registered
-     */
-    public void checkErrors() throws BuildException {
-        if (!errors.isEmpty()) {
-            StringBuffer sb = new StringBuffer();
-            sb.append("Configurationerror on <");
-            sb.append(task.getTaskName());
-            sb.append(">:");
-            sb.append(System.getProperty("line.separator"));
-            for (Iterator it = errors.iterator(); it.hasNext();) {
-                String msg = (String) it.next();
-                sb.append("- ");
-                sb.append(msg);
-                sb.append(System.getProperty("line.separator"));
-            }
-            throw new BuildException(sb.toString(), task.getLocation());
-        }
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.tools.ant;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * <p>Helper class for the check of the configuration of a given task.
+ * This class provides methods for making assumptions about the task configuration.
+ * After collecting all violations with <tt>assert*</tt> and <tt>fail</tt>
+ * methods the <tt>checkErrors</tt> will throw a BuildException with all collected
+ * messages or does nothing if there wasn't any error.</p>
+ *
+ * <p>Example:</p>
+ *
+ * <pre>
+ *     public class MyTask extends Task {
+ *         ...
+ *         public void execute() {
+ *             TaskConfigurationChecker checker = TaskConfigurationChecker(this);
+ *             checker.assertConfig(
+ *                 srcdir != null,
+ *                 "Attribute 'srcdir' must be set.
+ *             );
+ *             checker.assertConfig(
+ *                 srcdir.exists(),
+ *                 "Srcdir (" + srcdir + ") must exist."
+ *             );
+ *             if (someComplexCondition()) {
+ *                 fail("Complex condition failed.");
+ *             }
+ *             checker.checkErrors();
+ *         }
+ *     }
+ * </pre>
+ *
+ * @see <a href="http://martinfowler.com/eaaDev/Notification.html">Notification Pattern</a>
+ */
+public class TaskConfigurationChecker {
+
+    /** List of all collected error messages. */
+    private List/*<String>*/ errors = new ArrayList();
+
+    /** Task for which the configuration should be checked. */
+    private final Task task;
+
+    /**
+     * Constructor.
+     * @param task which task should be checked
+     */
+    public TaskConfigurationChecker(Task task) {
+        this.task = task;
+    }
+
+    /**
+     * Asserts that a condition is true.
+     * @param condition     which condition to check
+     * @param errormessage  errormessage to throw if a condition failed
+     */
+    public void assertConfig(boolean condition, String errormessage) {
+        if (!condition) {
+            errors.add(errormessage);
+        }
+    }
+
+    /**
+     * Registers an error.
+     * @param errormessage the message for the registered error
+     */
+    public void fail(String errormessage) {
+        errors.add(errormessage);
+    }
+
+    /**
+     * Checks if there are any collected errors and throws a BuildException
+     * with all messages if there was one or more.
+     * @throws BuildException if one or more errors were registered
+     */
+    public void checkErrors() throws BuildException {
+        if (!errors.isEmpty()) {
+            StringBuffer sb = new StringBuffer();
+            sb.append("Configurationerror on <");
+            sb.append(task.getTaskName());
+            sb.append(">:");
+            sb.append(System.getProperty("line.separator"));
+            for (Iterator it = errors.iterator(); it.hasNext();) {
+                String msg = (String) it.next();
+                sb.append("- ");
+                sb.append(msg);
+                sb.append(System.getProperty("line.separator"));
+            }
+            throw new BuildException(sb.toString(), task.getLocation());
+        }
+    }
+
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/TaskConfigurationChecker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/core/trunk/src/main/org/apache/tools/ant/input/SecureInputHandler.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/input/SecureInputHandler.java?rev=743227&r1=743226&r2=743227&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/input/SecureInputHandler.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/input/SecureInputHandler.java Wed Feb 11 05:02:33 2009
@@ -1,60 +1,60 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.tools.ant.input;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.util.ReflectUtil;
-
-/**
- * Prompts and requests input.  May loop until a valid input has
- * been entered. Doesn't echo input (requires Java6). If Java6 is not
- * available, fallsback to the DefaultHandler (insecure).
- * @since Ant 1.7.1
- */
-public class SecureInputHandler extends DefaultInputHandler {
-
-    /**
-     * Default no-args constructor
-     */
-    public SecureInputHandler() {
-    }
-
-    /**
-     * Handle the input
-     * @param request the request to handle
-     * @throws BuildException if not possible to read from console
-     */
-    public void handleInput(InputRequest request) throws BuildException {
-        String prompt = getPrompt(request);
-        try {
-            Class system = Class.forName("java.lang.System");
-            Object console = ReflectUtil.invokeStatic(system, "console");
-            do {
-                char[] input = (char[]) ReflectUtil.invoke(
-                    console, "readPassword", String.class, prompt,
-                    Object[].class, (Object[]) null);
-                request.setInput(new String(input));
-                /* for security zero char array after retrieving value */
-                java.util.Arrays.fill(input, ' ');
-            } while (!request.isInputValid());
-        } catch (Exception e) {
-            /* Java6 not present use default handler */
-            super.handleInput(request);
-        }
-    }
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.tools.ant.input;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.util.ReflectUtil;
+
+/**
+ * Prompts and requests input.  May loop until a valid input has
+ * been entered. Doesn't echo input (requires Java6). If Java6 is not
+ * available, fallsback to the DefaultHandler (insecure).
+ * @since Ant 1.7.1
+ */
+public class SecureInputHandler extends DefaultInputHandler {
+
+    /**
+     * Default no-args constructor
+     */
+    public SecureInputHandler() {
+    }
+
+    /**
+     * Handle the input
+     * @param request the request to handle
+     * @throws BuildException if not possible to read from console
+     */
+    public void handleInput(InputRequest request) throws BuildException {
+        String prompt = getPrompt(request);
+        try {
+            Class system = Class.forName("java.lang.System");
+            Object console = ReflectUtil.invokeStatic(system, "console");
+            do {
+                char[] input = (char[]) ReflectUtil.invoke(
+                    console, "readPassword", String.class, prompt,
+                    Object[].class, (Object[]) null);
+                request.setInput(new String(input));
+                /* for security zero char array after retrieving value */
+                java.util.Arrays.fill(input, ' ');
+            } while (!request.isInputValid());
+        } catch (Exception e) {
+            /* Java6 not present use default handler */
+            super.handleInput(request);
+        }
+    }
 }
\ No newline at end of file

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/input/SecureInputHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/core/trunk/src/main/org/apache/tools/ant/listener/ProfileLogger.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/listener/ProfileLogger.java?rev=743227&r1=743226&r2=743227&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/listener/ProfileLogger.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/listener/ProfileLogger.java Wed Feb 11 05:02:33 2009
@@ -1,112 +1,112 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.tools.ant.listener;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tools.ant.BuildEvent;
-import org.apache.tools.ant.DefaultLogger;
-import org.apache.tools.ant.util.StringUtils;
-
-/**
- * This is a special logger that is designed to profile builds.
- *
- * @since Ant1.8
- */
-public class ProfileLogger extends DefaultLogger {
-
-    private Map profileData = new HashMap(); // <Object, Date>
-
-    /**
-     * Logs a message to say that the target has started.
-     *
-     * @param event
-     *            An event with any relevant extra information. Must not be
-     *            <code>null</code>.
-     */
-    public void targetStarted(BuildEvent event) {
-        Date now = new Date();
-        String name = "Target " + event.getTarget().getName();
-        logStart(event, now, name);
-        profileData.put(event.getTarget(), now);
-    }
-
-    /**
-     * Logs a message to say that the target has finished.
-     *
-     * @param event
-     *            An event with any relevant extra information. Must not be
-     *            <code>null</code>.
-     */
-    public void targetFinished(BuildEvent event) {
-        Date start = (Date) profileData.remove(event.getTarget());
-        String name = "Target " + event.getTarget().getName();
-        logFinish(event, start, name);
-    }
-
-    /**
-     * Logs a message to say that the task has started.
-     *
-     * @param event
-     *            An event with any relevant extra information. Must not be
-     *            <code>null</code>.
-     */
-    public void taskStarted(BuildEvent event) {
-        String name = event.getTask().getTaskName();
-        Date now = new Date();
-        logStart(event, now, name);
-        profileData.put(event.getTask(), now);
-    }
-
-    /**
-     * Logs a message to say that the task has finished.
-     *
-     * @param event
-     *            An event with any relevant extra information. Must not be
-     *            <code>null</code>.
-     */
-    public void taskFinished(BuildEvent event) {
-        Date start = (Date) profileData.remove(event.getTask());
-        String name = event.getTask().getTaskName();
-        logFinish(event, start, name);
-    }
-
-    private void logFinish(BuildEvent event, Date start, String name) {
-        Date now = new Date();
-        String msg = null;
-        if (start != null) {
-            long diff = now.getTime() - start.getTime();
-            msg = StringUtils.LINE_SEP + name + ": finished" + now + " ("
-                    + diff + "ms)";
-        } else {
-            msg = StringUtils.LINE_SEP + name + ": finished" + now
-                    + " (unknown duration, start not detected)";
-        }
-        printMessage(msg, out, event.getPriority());
-        log(msg);
-    }
-
-    private void logStart(BuildEvent event, Date start, String name) {
-        String msg = StringUtils.LINE_SEP + name + ": started " + start;
-        printMessage(msg, out, event.getPriority());
-        log(msg);
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.tools.ant.listener;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.DefaultLogger;
+import org.apache.tools.ant.util.StringUtils;
+
+/**
+ * This is a special logger that is designed to profile builds.
+ *
+ * @since Ant1.8
+ */
+public class ProfileLogger extends DefaultLogger {
+
+    private Map profileData = new HashMap(); // <Object, Date>
+
+    /**
+     * Logs a message to say that the target has started.
+     *
+     * @param event
+     *            An event with any relevant extra information. Must not be
+     *            <code>null</code>.
+     */
+    public void targetStarted(BuildEvent event) {
+        Date now = new Date();
+        String name = "Target " + event.getTarget().getName();
+        logStart(event, now, name);
+        profileData.put(event.getTarget(), now);
+    }
+
+    /**
+     * Logs a message to say that the target has finished.
+     *
+     * @param event
+     *            An event with any relevant extra information. Must not be
+     *            <code>null</code>.
+     */
+    public void targetFinished(BuildEvent event) {
+        Date start = (Date) profileData.remove(event.getTarget());
+        String name = "Target " + event.getTarget().getName();
+        logFinish(event, start, name);
+    }
+
+    /**
+     * Logs a message to say that the task has started.
+     *
+     * @param event
+     *            An event with any relevant extra information. Must not be
+     *            <code>null</code>.
+     */
+    public void taskStarted(BuildEvent event) {
+        String name = event.getTask().getTaskName();
+        Date now = new Date();
+        logStart(event, now, name);
+        profileData.put(event.getTask(), now);
+    }
+
+    /**
+     * Logs a message to say that the task has finished.
+     *
+     * @param event
+     *            An event with any relevant extra information. Must not be
+     *            <code>null</code>.
+     */
+    public void taskFinished(BuildEvent event) {
+        Date start = (Date) profileData.remove(event.getTask());
+        String name = event.getTask().getTaskName();
+        logFinish(event, start, name);
+    }
+
+    private void logFinish(BuildEvent event, Date start, String name) {
+        Date now = new Date();
+        String msg = null;
+        if (start != null) {
+            long diff = now.getTime() - start.getTime();
+            msg = StringUtils.LINE_SEP + name + ": finished" + now + " ("
+                    + diff + "ms)";
+        } else {
+            msg = StringUtils.LINE_SEP + name + ": finished" + now
+                    + " (unknown duration, start not detected)";
+        }
+        printMessage(msg, out, event.getPriority());
+        log(msg);
+    }
+
+    private void logStart(BuildEvent event, Date start, String name) {
+        String msg = StringUtils.LINE_SEP + name + ": started " + start;
+        printMessage(msg, out, event.getPriority());
+        log(msg);
+    }
+
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/listener/ProfileLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/HostInfo.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/HostInfo.java?rev=743227&r1=743226&r2=743227&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/HostInfo.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/HostInfo.java Wed Feb 11 05:02:33 2009
@@ -1,247 +1,247 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
-package org.apache.tools.ant.taskdefs;
-
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-
-/**
- * Sets properties to the host provided, or localhost if no information is
- * provided. The default properties are NAME, FQDN, ADDR4, ADDR6;
- * 
- * @since Ant 1.8
- * @ant.task category="utility"
- */
-
-
-public class HostInfo extends Task {
-    private static final String DEF_REM_ADDR6 = "::";
-
-    private static final String DEF_REM_ADDR4 = "0.0.0.0";
-
-    private static final String DEF_LOCAL_ADDR6 = "::1";
-
-    private static final String DEF_LOCAL_ADDR4 = "127.0.0.1";
-
-    private static final String DEF_LOCAL_NAME = "localhost";
-    private static final String DEF_DOMAIN = "localdomain";
-
-    private static final String DOMAIN = "DOMAIN";
-
-    private static final String NAME = "NAME";
-
-    private static final String ADDR4 = "ADDR4";
-
-    private static final String ADDR6 = "ADDR6";
-
-    private String prefix = "";
-
-    private String host;
-
-    private InetAddress nameAddr;
-
-    private InetAddress best6;
-
-    private InetAddress best4;
-
-    private List inetAddrs;
-
-    /**
-     * Set a prefix for the properties. If the prefix does not end with a "."
-     * one is automatically added.
-     * 
-     * @param aPrefix
-     *            the prefix to use.
-     * @since Ant 1.8
-     */
-    public void setPrefix(String aPrefix) {
-        prefix = aPrefix;
-        if (!prefix.endsWith(".")) {
-            prefix += ".";
-        }
-    }
-
-    /**
-     * Set the host to be retrieved.
-     * 
-     * @param aHost
-     *            the name or the address of the host, data for the local host
-     *            will be retrieved if ommited.
-     * @since Ant 1.8
-     */
-    public void setHost(String aHost) {
-        host = aHost;
-    }
-
-    /**
-     * set the properties.
-     * 
-     * @throws BuildException
-     *             on error.
-     */
-    public void execute() throws BuildException {
-        if (host == null || "".equals(host)) {
-            executeLocal();
-        } else {
-            executeRemote();
-        }
-    }
-
-    private void executeLocal() {
-        try {
-            Enumeration interfaces = NetworkInterface.getNetworkInterfaces();
-            inetAddrs = new LinkedList();
-            while (interfaces.hasMoreElements()) {
-                NetworkInterface currentif = (NetworkInterface) interfaces
-                        .nextElement();
-                Enumeration addrs = currentif.getInetAddresses();
-                while (addrs.hasMoreElements())
-                {
-                    inetAddrs.add(addrs.nextElement());
-                }
-            }
-            selectAddresses();
-
-            if (nameAddr != null) {
-                setDomainAndName(nameAddr.getCanonicalHostName());
-            } else {
-                setProperty(DOMAIN, DEF_DOMAIN);
-                setProperty(NAME, DEF_LOCAL_NAME);
-            }
-            if (best4 != null) {
-                setProperty(ADDR4, best4.getHostAddress());
-            } else {
-                setProperty(ADDR4, DEF_LOCAL_ADDR4);
-            }
-            if (best6 != null) {
-                setProperty(ADDR6, best6.getHostAddress());
-            } else {
-                setProperty(ADDR6, DEF_LOCAL_ADDR6);
-            }
-        } catch (Exception e) {
-            log("Error retrieving local host information", e, Project.MSG_WARN);
-            setProperty(DOMAIN, DEF_DOMAIN);
-            setProperty(NAME, DEF_LOCAL_NAME);
-            setProperty(ADDR4, DEF_LOCAL_ADDR4);
-            setProperty(ADDR6, DEF_LOCAL_ADDR6);
-        }
-    }
-
-    private void selectAddresses() {
-        Iterator i = inetAddrs.iterator();
-        while (i.hasNext()) {
-            InetAddress current = (InetAddress) i.next();
-            if (!current.isMulticastAddress()) {
-                if (current instanceof Inet4Address) {
-                    best4 = selectBestAddress(best4, current);
-                } else if (current instanceof Inet6Address) {
-                    best6 = selectBestAddress(best6, current);
-                }
-            }
-        }
-        
-        nameAddr = selectBestAddress(best6, best4);
-    }
-
-    private InetAddress selectBestAddress(InetAddress bestSoFar,
-            InetAddress current) {
-        InetAddress best = bestSoFar;
-        if (best == null) {
-            // none selected so far, so this one is better.
-            best = current;
-        } else {
-            if (current.isLoopbackAddress()) {
-                // definitely not better than the previously selected address.
-            } else if (current.isLinkLocalAddress()) {
-                // link local considered better than loopback
-                if (best.isLoopbackAddress()) {
-                    best = current;
-                }
-            } else if (current.isSiteLocalAddress()) {
-                // site local considered better than link local (and loopback)
-                if (best.isLoopbackAddress() || best.isLinkLocalAddress()) {
-                    best = current;
-                }
-            } else {
-                // current is a global address, and therefore best (at least
-                // equally well)
-                best = current;
-            }
-        }
-        return best;
-    }
-
-    private void executeRemote() {
-        try {
-            inetAddrs = Arrays.asList(InetAddress.getAllByName(host));
-
-            selectAddresses();
-
-            if (nameAddr != null) {
-                setDomainAndName(nameAddr.getCanonicalHostName());
-            } else {
-                setDomainAndName(host);
-            }
-            if (best4 != null) {
-                setProperty(ADDR4, best4.getHostAddress());
-            } else {
-                setProperty(ADDR4, DEF_REM_ADDR4);
-            }
-            if (best6 != null) {
-                setProperty(ADDR6, best6.getHostAddress());
-            } else {
-                setProperty(ADDR6, DEF_REM_ADDR6);
-            }
-        } catch (Exception e) {
-            log("Error retrieving remote host information for host:" + host
-                    + ".", e, Project.MSG_WARN);
-            setDomainAndName(host);
-            setProperty(ADDR4, DEF_REM_ADDR4);
-            setProperty(ADDR6, DEF_REM_ADDR6);
-        }
-    }
-
-    private void setDomainAndName(String fqdn)
-    {
-        int idx = fqdn.indexOf('.');
-        if (idx > 0) {
-            setProperty(NAME, fqdn.substring(0, idx));
-            setProperty(DOMAIN, fqdn.substring(idx+1));
-        } else {
-            setProperty(NAME, fqdn);
-            setProperty(DOMAIN, DEF_DOMAIN);
-        }
-    }
-
-    private void setProperty(String name, String value) {
-        getProject().setNewProperty(prefix + name, value);
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.tools.ant.taskdefs;
+
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * Sets properties to the host provided, or localhost if no information is
+ * provided. The default properties are NAME, FQDN, ADDR4, ADDR6;
+ * 
+ * @since Ant 1.8
+ * @ant.task category="utility"
+ */
+
+
+public class HostInfo extends Task {
+    private static final String DEF_REM_ADDR6 = "::";
+
+    private static final String DEF_REM_ADDR4 = "0.0.0.0";
+
+    private static final String DEF_LOCAL_ADDR6 = "::1";
+
+    private static final String DEF_LOCAL_ADDR4 = "127.0.0.1";
+
+    private static final String DEF_LOCAL_NAME = "localhost";
+    private static final String DEF_DOMAIN = "localdomain";
+
+    private static final String DOMAIN = "DOMAIN";
+
+    private static final String NAME = "NAME";
+
+    private static final String ADDR4 = "ADDR4";
+
+    private static final String ADDR6 = "ADDR6";
+
+    private String prefix = "";
+
+    private String host;
+
+    private InetAddress nameAddr;
+
+    private InetAddress best6;
+
+    private InetAddress best4;
+
+    private List inetAddrs;
+
+    /**
+     * Set a prefix for the properties. If the prefix does not end with a "."
+     * one is automatically added.
+     * 
+     * @param aPrefix
+     *            the prefix to use.
+     * @since Ant 1.8
+     */
+    public void setPrefix(String aPrefix) {
+        prefix = aPrefix;
+        if (!prefix.endsWith(".")) {
+            prefix += ".";
+        }
+    }
+
+    /**
+     * Set the host to be retrieved.
+     * 
+     * @param aHost
+     *            the name or the address of the host, data for the local host
+     *            will be retrieved if ommited.
+     * @since Ant 1.8
+     */
+    public void setHost(String aHost) {
+        host = aHost;
+    }
+
+    /**
+     * set the properties.
+     * 
+     * @throws BuildException
+     *             on error.
+     */
+    public void execute() throws BuildException {
+        if (host == null || "".equals(host)) {
+            executeLocal();
+        } else {
+            executeRemote();
+        }
+    }
+
+    private void executeLocal() {
+        try {
+            Enumeration interfaces = NetworkInterface.getNetworkInterfaces();
+            inetAddrs = new LinkedList();
+            while (interfaces.hasMoreElements()) {
+                NetworkInterface currentif = (NetworkInterface) interfaces
+                        .nextElement();
+                Enumeration addrs = currentif.getInetAddresses();
+                while (addrs.hasMoreElements())
+                {
+                    inetAddrs.add(addrs.nextElement());
+                }
+            }
+            selectAddresses();
+
+            if (nameAddr != null) {
+                setDomainAndName(nameAddr.getCanonicalHostName());
+            } else {
+                setProperty(DOMAIN, DEF_DOMAIN);
+                setProperty(NAME, DEF_LOCAL_NAME);
+            }
+            if (best4 != null) {
+                setProperty(ADDR4, best4.getHostAddress());
+            } else {
+                setProperty(ADDR4, DEF_LOCAL_ADDR4);
+            }
+            if (best6 != null) {
+                setProperty(ADDR6, best6.getHostAddress());
+            } else {
+                setProperty(ADDR6, DEF_LOCAL_ADDR6);
+            }
+        } catch (Exception e) {
+            log("Error retrieving local host information", e, Project.MSG_WARN);
+            setProperty(DOMAIN, DEF_DOMAIN);
+            setProperty(NAME, DEF_LOCAL_NAME);
+            setProperty(ADDR4, DEF_LOCAL_ADDR4);
+            setProperty(ADDR6, DEF_LOCAL_ADDR6);
+        }
+    }
+
+    private void selectAddresses() {
+        Iterator i = inetAddrs.iterator();
+        while (i.hasNext()) {
+            InetAddress current = (InetAddress) i.next();
+            if (!current.isMulticastAddress()) {
+                if (current instanceof Inet4Address) {
+                    best4 = selectBestAddress(best4, current);
+                } else if (current instanceof Inet6Address) {
+                    best6 = selectBestAddress(best6, current);
+                }
+            }
+        }
+        
+        nameAddr = selectBestAddress(best6, best4);
+    }
+
+    private InetAddress selectBestAddress(InetAddress bestSoFar,
+            InetAddress current) {
+        InetAddress best = bestSoFar;
+        if (best == null) {
+            // none selected so far, so this one is better.
+            best = current;
+        } else {
+            if (current.isLoopbackAddress()) {
+                // definitely not better than the previously selected address.
+            } else if (current.isLinkLocalAddress()) {
+                // link local considered better than loopback
+                if (best.isLoopbackAddress()) {
+                    best = current;
+                }
+            } else if (current.isSiteLocalAddress()) {
+                // site local considered better than link local (and loopback)
+                if (best.isLoopbackAddress() || best.isLinkLocalAddress()) {
+                    best = current;
+                }
+            } else {
+                // current is a global address, and therefore best (at least
+                // equally well)
+                best = current;
+            }
+        }
+        return best;
+    }
+
+    private void executeRemote() {
+        try {
+            inetAddrs = Arrays.asList(InetAddress.getAllByName(host));
+
+            selectAddresses();
+
+            if (nameAddr != null) {
+                setDomainAndName(nameAddr.getCanonicalHostName());
+            } else {
+                setDomainAndName(host);
+            }
+            if (best4 != null) {
+                setProperty(ADDR4, best4.getHostAddress());
+            } else {
+                setProperty(ADDR4, DEF_REM_ADDR4);
+            }
+            if (best6 != null) {
+                setProperty(ADDR6, best6.getHostAddress());
+            } else {
+                setProperty(ADDR6, DEF_REM_ADDR6);
+            }
+        } catch (Exception e) {
+            log("Error retrieving remote host information for host:" + host
+                    + ".", e, Project.MSG_WARN);
+            setDomainAndName(host);
+            setProperty(ADDR4, DEF_REM_ADDR4);
+            setProperty(ADDR6, DEF_REM_ADDR6);
+        }
+    }
+
+    private void setDomainAndName(String fqdn)
+    {
+        int idx = fqdn.indexOf('.');
+        if (idx > 0) {
+            setProperty(NAME, fqdn.substring(0, idx));
+            setProperty(DOMAIN, fqdn.substring(idx+1));
+        } else {
+            setProperty(NAME, fqdn);
+            setProperty(DOMAIN, DEF_DOMAIN);
+        }
+    }
+
+    private void setProperty(String name, String value) {
+        getProject().setNewProperty(prefix + name, value);
+    }
+
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/HostInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Retry.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Retry.java?rev=743227&r1=743226&r2=743227&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Retry.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Retry.java Wed Feb 11 05:02:33 2009
@@ -1,89 +1,89 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.tools.ant.taskdefs;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.TaskContainer;
-import org.apache.tools.ant.util.StringUtils;
-
-/**
- * Retries the nested task a set number of times
- * @since Ant 1.7.1
- */
-public class Retry extends Task implements TaskContainer {
-
-    /**
-     * task to execute n times
-     */
-    private Task nestedTask;
-
-    /**
-     * set retryCount to 1 by default
-     */
-    private int retryCount = 1;
-
-    /**
-     * set the task
-     * @param t the task to retry.
-     */
-    public synchronized void addTask(Task t) {
-        if (nestedTask != null) {
-            throw new BuildException(
-                "The retry task container accepts a single nested task"
-                + " (which may be a sequential task container)");
-        }
-        nestedTask = t;
-    }
-
-    /**
-     * set the number of times to retry the task
-     * @param n the number to use.
-     */
-    public void setRetryCount(int n) {
-        retryCount = n;
-    }
-
-    /**
-     * perform the work
-     * @throws BuildException if there is an error.
-     */
-    public void execute() throws BuildException {
-        StringBuffer errorMessages = new StringBuffer();
-        for (int i = 0; i <= retryCount; i++) {
-            try {
-                nestedTask.perform();
-                break;
-            } catch (Exception e) {
-                errorMessages.append(e.getMessage());
-                if (i >= retryCount) {
-                    StringBuffer exceptionMessage = new StringBuffer();
-                    exceptionMessage.append("Task [").append(nestedTask.getTaskName());
-                    exceptionMessage.append("] failed after [").append(retryCount);
-                    exceptionMessage.append("] attempts; giving up.").append(StringUtils.LINE_SEP);
-                    exceptionMessage.append("Error messages:").append(StringUtils.LINE_SEP);
-                    exceptionMessage.append(errorMessages);
-                    throw new BuildException(exceptionMessage.toString(), getLocation());
-                }
-                log("Attempt [" + i + "]: error occurred; retrying...", e, Project.MSG_INFO);
-                errorMessages.append(StringUtils.LINE_SEP);
-            }
-        }
-    }
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.tools.ant.taskdefs;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.TaskContainer;
+import org.apache.tools.ant.util.StringUtils;
+
+/**
+ * Retries the nested task a set number of times
+ * @since Ant 1.7.1
+ */
+public class Retry extends Task implements TaskContainer {
+
+    /**
+     * task to execute n times
+     */
+    private Task nestedTask;
+
+    /**
+     * set retryCount to 1 by default
+     */
+    private int retryCount = 1;
+
+    /**
+     * set the task
+     * @param t the task to retry.
+     */
+    public synchronized void addTask(Task t) {
+        if (nestedTask != null) {
+            throw new BuildException(
+                "The retry task container accepts a single nested task"
+                + " (which may be a sequential task container)");
+        }
+        nestedTask = t;
+    }
+
+    /**
+     * set the number of times to retry the task
+     * @param n the number to use.
+     */
+    public void setRetryCount(int n) {
+        retryCount = n;
+    }
+
+    /**
+     * perform the work
+     * @throws BuildException if there is an error.
+     */
+    public void execute() throws BuildException {
+        StringBuffer errorMessages = new StringBuffer();
+        for (int i = 0; i <= retryCount; i++) {
+            try {
+                nestedTask.perform();
+                break;
+            } catch (Exception e) {
+                errorMessages.append(e.getMessage());
+                if (i >= retryCount) {
+                    StringBuffer exceptionMessage = new StringBuffer();
+                    exceptionMessage.append("Task [").append(nestedTask.getTaskName());
+                    exceptionMessage.append("] failed after [").append(retryCount);
+                    exceptionMessage.append("] attempts; giving up.").append(StringUtils.LINE_SEP);
+                    exceptionMessage.append("Error messages:").append(StringUtils.LINE_SEP);
+                    exceptionMessage.append(errorMessages);
+                    throw new BuildException(exceptionMessage.toString(), getLocation());
+                }
+                log("Attempt [" + i + "]: error occurred; retrying...", e, Project.MSG_INFO);
+                errorMessages.append(StringUtils.LINE_SEP);
+            }
+        }
+    }
 }
\ No newline at end of file

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Retry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java?rev=743227&r1=743226&r2=743227&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java Wed Feb 11 05:02:33 2009
@@ -1,101 +1,101 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-
-package org.apache.tools.ant.taskdefs.condition;
-
-import java.io.File;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.util.JavaEnvUtils;
-import org.apache.tools.ant.util.ReflectWrapper;
-import org.apache.tools.ant.util.StringUtils;
-
-/**
- * &lt;hasfreespace&gt;
- * <p>Condition returns true if selected partition
- * has the requested space, false otherwise.</p>
- * @since Ant 1.7
- */
-public class HasFreeSpace implements Condition {
-
-    private String partition;
-    private String needed;
-
-    /**
-     * Evaluate the condition.
-     * @return true if there enough free space.
-     * @throws BuildException if there is a problem.
-     */
-    public boolean eval() throws BuildException {
-        validate();
-        try {
-            if (JavaEnvUtils.isAtLeastJavaVersion("1.6")) {
-                //reflection to avoid bootstrap/build problems
-                File fs = new File(partition);
-                ReflectWrapper w = new ReflectWrapper(fs);
-                long free = ((Long) w.invoke("getFreeSpace")).longValue();
-                return free >= StringUtils.parseHumanSizes(needed);
-            } else {
-                throw new BuildException("HasFreeSpace condition not supported on Java5 or less.");
-            }
-        } catch (Exception e) {
-            throw new BuildException(e);
-        }
-    }
-
-    private void validate() throws BuildException {
-        if (null == partition) {
-            throw new BuildException("Please set the partition attribute.");
-        }
-        if (null == needed) {
-            throw new BuildException("Please set the needed attribute.");
-        }
-    }
-
-    /**
-     * The partition/device to check
-     * @return the partition.
-     */
-    public String getPartition() {
-        return partition;
-    }
-
-    /**
-     * Set the partition name.
-     * @param partition the name to use.
-     */
-    public void setPartition(String partition) {
-        this.partition = partition;
-    }
-
-    /**
-     * The amount of free space required
-     * @return the amount required
-     */
-    public String getNeeded() {
-        return needed;
-    }
-
-    /**
-     * Set the amount of space required.
-     * @param needed the amount required.
-     */
-    public void setNeeded(String needed) {
-        this.needed = needed;
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.tools.ant.taskdefs.condition;
+
+import java.io.File;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.util.JavaEnvUtils;
+import org.apache.tools.ant.util.ReflectWrapper;
+import org.apache.tools.ant.util.StringUtils;
+
+/**
+ * &lt;hasfreespace&gt;
+ * <p>Condition returns true if selected partition
+ * has the requested space, false otherwise.</p>
+ * @since Ant 1.7
+ */
+public class HasFreeSpace implements Condition {
+
+    private String partition;
+    private String needed;
+
+    /**
+     * Evaluate the condition.
+     * @return true if there enough free space.
+     * @throws BuildException if there is a problem.
+     */
+    public boolean eval() throws BuildException {
+        validate();
+        try {
+            if (JavaEnvUtils.isAtLeastJavaVersion("1.6")) {
+                //reflection to avoid bootstrap/build problems
+                File fs = new File(partition);
+                ReflectWrapper w = new ReflectWrapper(fs);
+                long free = ((Long) w.invoke("getFreeSpace")).longValue();
+                return free >= StringUtils.parseHumanSizes(needed);
+            } else {
+                throw new BuildException("HasFreeSpace condition not supported on Java5 or less.");
+            }
+        } catch (Exception e) {
+            throw new BuildException(e);
+        }
+    }
+
+    private void validate() throws BuildException {
+        if (null == partition) {
+            throw new BuildException("Please set the partition attribute.");
+        }
+        if (null == needed) {
+            throw new BuildException("Please set the needed attribute.");
+        }
+    }
+
+    /**
+     * The partition/device to check
+     * @return the partition.
+     */
+    public String getPartition() {
+        return partition;
+    }
+
+    /**
+     * Set the partition name.
+     * @param partition the name to use.
+     */
+    public void setPartition(String partition) {
+        this.partition = partition;
+    }
+
+    /**
+     * The amount of free space required
+     * @return the amount required
+     */
+    public String getNeeded() {
+        return needed;
+    }
+
+    /**
+     * Set the amount of space required.
+     * @param needed the amount required.
+     */
+    public void setNeeded(String needed) {
+        this.needed = needed;
+    }
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java?rev=743227&r1=743226&r2=743227&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java Wed Feb 11 05:02:33 2009
@@ -1,165 +1,165 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- */
-package org.apache.tools.ant.taskdefs.condition;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.Resource;
-import org.apache.tools.ant.types.ResourceCollection;
-import org.apache.tools.ant.types.resources.FileResource;
-import org.apache.tools.ant.util.FileUtils;
-
-/**
- * &lt;resourcecontains&gt;
- * Is a string contained in a resource (file currently)?
- * @since Ant 1.7.1
- */
-public class ResourceContains implements Condition {
-
-    private Project project;
-    private String substring;
-    private Resource resource;
-    private String refid;
-    private boolean casesensitive = true;
-
-    /**
-     * Set this condition's Project.
-     * @param project Project
-     */
-    public void setProject(Project project) {
-        this.project = project;
-    }
-
-    /**
-     * Get this condition's Project.
-     * @return Project
-     */
-    public Project getProject() {
-        return project;
-    }
-
-    /**
-     * Sets the resource to search
-     * @param r the value to use.
-     */
-    public void setResource(String r) {
-        this.resource = new FileResource(new File(r));
-    }
-
-    /**
-     * Sets the refid to search; should indicate a resource directly
-     * or by way of a single-element ResourceCollection.
-     * @param refid the value to use.
-     */
-    public void setRefid(String refid) {
-        this.refid = refid;
-    }
-
-    private void resolveRefid() {
-        try {
-            if (getProject() == null) {
-                throw new BuildException("Cannot retrieve refid; project unset");
-            }
-            Object o = getProject().getReference(refid);
-            if (!(o instanceof Resource)) {
-                if (o instanceof ResourceCollection) {
-                    ResourceCollection rc = (ResourceCollection) o;
-                    if (rc.size() == 1) {
-                        o = rc.iterator().next();
-                    }
-                } else {
-                    throw new BuildException(
-                        "Illegal value at '" + refid + "': " + String.valueOf(o));
-                }
-            }
-            this.resource = (Resource) o;
-        } finally {
-            refid = null;
-        }
-    }
-
-    /**
-     * Sets the substring to look for
-     * @param substring the value to use.
-     */
-    public void setSubstring(String substring) {
-        this.substring = substring;
-    }
-
-    /**
-     * Sets case sensitivity attribute.
-     * @param casesensitive the value to use.
-     */
-    public void setCasesensitive(boolean casesensitive) {
-        this.casesensitive = casesensitive;
-    }
-
-    private void validate() {
-        if (resource != null && refid != null) {
-            throw new BuildException("Cannot set both resource and refid");
-        }
-        if (resource == null && refid != null) {
-            resolveRefid();
-        }
-        if (resource == null || substring == null) {
-            throw new BuildException("both resource and substring are required "
-                                     + "in <resourcecontains>");
-        }
-    }
-
-    /**
-     * Evaluates the condition.
-     * @return true if the substring is contained in the resource
-     * @throws BuildException if there is a problem.
-     */
-    public synchronized boolean eval() throws BuildException {
-        validate();
-
-        if (substring.length() == 0) {
-            if (getProject() != null) {
-                getProject().log("Substring is empty; returning true",
-                                 Project.MSG_VERBOSE);
-            }
-            return true;
-        }
-        if (resource.getSize() == 0) {
-            return false;
-        }
-
-        BufferedReader reader = null;
-        try {
-            reader = new BufferedReader(new InputStreamReader(resource.getInputStream()));
-            String contents = FileUtils.safeReadFully(reader);
-            String sub = substring;
-            if (!casesensitive) {
-                contents = contents.toLowerCase();
-                sub = sub.toLowerCase();
-            }
-            return contents.indexOf(sub) >= 0;
-        } catch (IOException e) {
-            throw new BuildException("There was a problem accessing resource : " + resource);
-        } finally {
-            FileUtils.close(reader);
-        }
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.tools.ant.taskdefs.condition;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.types.resources.FileResource;
+import org.apache.tools.ant.util.FileUtils;
+
+/**
+ * &lt;resourcecontains&gt;
+ * Is a string contained in a resource (file currently)?
+ * @since Ant 1.7.1
+ */
+public class ResourceContains implements Condition {
+
+    private Project project;
+    private String substring;
+    private Resource resource;
+    private String refid;
+    private boolean casesensitive = true;
+
+    /**
+     * Set this condition's Project.
+     * @param project Project
+     */
+    public void setProject(Project project) {
+        this.project = project;
+    }
+
+    /**
+     * Get this condition's Project.
+     * @return Project
+     */
+    public Project getProject() {
+        return project;
+    }
+
+    /**
+     * Sets the resource to search
+     * @param r the value to use.
+     */
+    public void setResource(String r) {
+        this.resource = new FileResource(new File(r));
+    }
+
+    /**
+     * Sets the refid to search; should indicate a resource directly
+     * or by way of a single-element ResourceCollection.
+     * @param refid the value to use.
+     */
+    public void setRefid(String refid) {
+        this.refid = refid;
+    }
+
+    private void resolveRefid() {
+        try {
+            if (getProject() == null) {
+                throw new BuildException("Cannot retrieve refid; project unset");
+            }
+            Object o = getProject().getReference(refid);
+            if (!(o instanceof Resource)) {
+                if (o instanceof ResourceCollection) {
+                    ResourceCollection rc = (ResourceCollection) o;
+                    if (rc.size() == 1) {
+                        o = rc.iterator().next();
+                    }
+                } else {
+                    throw new BuildException(
+                        "Illegal value at '" + refid + "': " + String.valueOf(o));
+                }
+            }
+            this.resource = (Resource) o;
+        } finally {
+            refid = null;
+        }
+    }
+
+    /**
+     * Sets the substring to look for
+     * @param substring the value to use.
+     */
+    public void setSubstring(String substring) {
+        this.substring = substring;
+    }
+
+    /**
+     * Sets case sensitivity attribute.
+     * @param casesensitive the value to use.
+     */
+    public void setCasesensitive(boolean casesensitive) {
+        this.casesensitive = casesensitive;
+    }
+
+    private void validate() {
+        if (resource != null && refid != null) {
+            throw new BuildException("Cannot set both resource and refid");
+        }
+        if (resource == null && refid != null) {
+            resolveRefid();
+        }
+        if (resource == null || substring == null) {
+            throw new BuildException("both resource and substring are required "
+                                     + "in <resourcecontains>");
+        }
+    }
+
+    /**
+     * Evaluates the condition.
+     * @return true if the substring is contained in the resource
+     * @throws BuildException if there is a problem.
+     */
+    public synchronized boolean eval() throws BuildException {
+        validate();
+
+        if (substring.length() == 0) {
+            if (getProject() != null) {
+                getProject().log("Substring is empty; returning true",
+                                 Project.MSG_VERBOSE);
+            }
+            return true;
+        }
+        if (resource.getSize() == 0) {
+            return false;
+        }
+
+        BufferedReader reader = null;
+        try {
+            reader = new BufferedReader(new InputStreamReader(resource.getInputStream()));
+            String contents = FileUtils.safeReadFully(reader);
+            String sub = substring;
+            if (!casesensitive) {
+                contents = contents.toLowerCase();
+                sub = sub.toLowerCase();
+            }
+            return contents.indexOf(sub) >= 0;
+        } catch (IOException e) {
+            throw new BuildException("There was a problem accessing resource : " + resource);
+        } finally {
+            FileUtils.close(reader);
+        }
+    }
+}

Propchange: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
------------------------------------------------------------------------------
    svn:eol-style = native