This is a first cut of the generalization of <available> and <uptodate> that is on the list for Ant2. This task supports a single condition and sets a property if it holds true - conditions can be containers for other conditions in turn, giving it the opportunity to support boolean logic. Built in conditions as of now: * <available> and <uptodate> (slightly modified the tasks to allow them to be used as conditions) * containers <and>, <or> and <not> * New conditions <equals> (compares to Strings) and <os> which should give easier access to os.name. More extensive documentation to follow. Take a look at Ant's build file, it uses the task to detect whether javamail is available now. I had to perform some ugly tricks to make sure that project gets passed to every object that will need it - this will be very different in the future I hope. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269456 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -89,7 +89,7 @@ | |||||
| Check to see what optional dependencies are available | Check to see what optional dependencies are available | ||||
| =================================================================== | =================================================================== | ||||
| --> | --> | ||||
| <target name="check_for_optional_packages_1"> | |||||
| <target name="check_for_optional_packages"> | |||||
| <available property="jdk1.2+" classname="java.lang.ThreadLocal" /> | <available property="jdk1.2+" classname="java.lang.ThreadLocal" /> | ||||
| <available property="jdk1.3+" classname="java.lang.StrictMath" /> | <available property="jdk1.3+" classname="java.lang.StrictMath" /> | ||||
| <available property="jdk1.4+" classname="java.lang.CharSequence" /> | <available property="jdk1.4+" classname="java.lang.CharSequence" /> | ||||
| @@ -147,22 +147,18 @@ | |||||
| <available property="jdepend.present" | <available property="jdepend.present" | ||||
| classname="jdepend.framework.JDepend" | classname="jdepend.framework.JDepend" | ||||
| classpathref="classpath"/> | classpathref="classpath"/> | ||||
| <available property="jaf.present" | |||||
| classname="javax.activation.DataHandler" | |||||
| classpathref="classpath"/> | |||||
| <available property="log4j.present" | <available property="log4j.present" | ||||
| classname="org.apache.log4j.Category" | classname="org.apache.log4j.Category" | ||||
| classpathref="classpath"/> | classpathref="classpath"/> | ||||
| </target> | |||||
| <target name="check_for_optional_packages" | |||||
| depends="check_for_optional_packages_1" | |||||
| if="jaf.present"> | |||||
| <available property="javamail.complete" | |||||
| classname="javax.mail.Transport" | |||||
| classpathref="classpath"/> | |||||
| <condition property="javamail.complete"> | |||||
| <and> | |||||
| <available classname="javax.activation.DataHandler" | |||||
| classpathref="classpath"/> | |||||
| <available classname="javax.mail.Transport" | |||||
| classpathref="classpath"/> | |||||
| </and> | |||||
| </condition> | |||||
| </target> | </target> | ||||
| <!-- | <!-- | ||||
| @@ -237,7 +237,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| /** | /** | ||||
| * Create a classloader for the given project using the classpath given. | * Create a classloader for the given project using the classpath given. | ||||
| * | * | ||||
| * @param project the project to ehich this classloader is to belong. | |||||
| * @param project the project to which this classloader is to belong. | |||||
| * @param classpath the classpath to use to load the classes. This | * @param classpath the classpath to use to load the classes. This | ||||
| * is combined with the system classpath in a manner | * is combined with the system classpath in a manner | ||||
| * determined by the value of ${build.sysclasspath} | * determined by the value of ${build.sysclasspath} | ||||
| @@ -71,6 +71,21 @@ public class TaskAdapter extends Task { | |||||
| * Do the execution. | * Do the execution. | ||||
| */ | */ | ||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| Method setProjectM = null; | |||||
| try { | |||||
| Class c = proxy.getClass(); | |||||
| setProjectM = | |||||
| c.getMethod( "setProject", new Class[] {Project.class}); | |||||
| if(setProjectM != null) { | |||||
| setProjectM.invoke(proxy, new Object[] {project}); | |||||
| } | |||||
| } catch( Exception ex ) { | |||||
| log("Error setting project in " + proxy.getClass(), | |||||
| Project.MSG_ERR); | |||||
| throw new BuildException( ex ); | |||||
| } | |||||
| Method executeM=null; | Method executeM=null; | ||||
| try { | try { | ||||
| Class c=proxy.getClass(); | Class c=proxy.getClass(); | ||||
| @@ -57,6 +57,7 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.*; | import java.io.*; | ||||
| import java.util.*; | import java.util.*; | ||||
| import org.apache.tools.ant.*; | import org.apache.tools.ant.*; | ||||
| import org.apache.tools.ant.taskdefs.condition.Condition; | |||||
| import org.apache.tools.ant.types.*; | import org.apache.tools.ant.types.*; | ||||
| /** | /** | ||||
| @@ -65,7 +66,7 @@ import org.apache.tools.ant.types.*; | |||||
| * @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> | ||||
| */ | */ | ||||
| public class Available extends Task { | |||||
| public class Available extends Task implements Condition { | |||||
| private String property; | private String property; | ||||
| private String classname; | private String classname; | ||||
| @@ -133,7 +134,13 @@ public class Available extends Task { | |||||
| if (property == null) { | if (property == null) { | ||||
| throw new BuildException("property attribute is required", location); | throw new BuildException("property attribute is required", location); | ||||
| } | } | ||||
| if (eval()) { | |||||
| this.project.setProperty(property, value); | |||||
| } | |||||
| } | |||||
| public boolean eval() throws BuildException { | |||||
| if (classname == null && file == null && resource == null) { | if (classname == null && file == null && resource == null) { | ||||
| throw new BuildException("At least one of (classname|file|resource) is required", location); | throw new BuildException("At least one of (classname|file|resource) is required", location); | ||||
| } | } | ||||
| @@ -145,28 +152,30 @@ public class Available extends Task { | |||||
| } | } | ||||
| if (classpath != null) { | if (classpath != null) { | ||||
| classpath.setProject(project); | |||||
| this.loader = new AntClassLoader(project, classpath); | this.loader = new AntClassLoader(project, classpath); | ||||
| } | } | ||||
| if ((classname != null) && !checkClass(classname)) { | if ((classname != null) && !checkClass(classname)) { | ||||
| log("Unable to load class " + classname + " to set property " + property, Project.MSG_VERBOSE); | log("Unable to load class " + classname + " to set property " + property, Project.MSG_VERBOSE); | ||||
| return; | |||||
| return false; | |||||
| } | } | ||||
| if ((file != null) && !checkFile()) { | if ((file != null) && !checkFile()) { | ||||
| log("Unable to find " + file + " to set property " + property, Project.MSG_VERBOSE); | log("Unable to find " + file + " to set property " + property, Project.MSG_VERBOSE); | ||||
| return; | |||||
| return false; | |||||
| } | } | ||||
| if ((resource != null) && !checkResource(resource)) { | if ((resource != null) && !checkResource(resource)) { | ||||
| log("Unable to load resource " + resource + " to set property " + property, Project.MSG_VERBOSE); | log("Unable to load resource " + resource + " to set property " + property, Project.MSG_VERBOSE); | ||||
| return; | |||||
| return false; | |||||
| } | } | ||||
| this.project.setProperty(property, value); | |||||
| if (loader != null) { | if (loader != null) { | ||||
| loader.cleanup(); | loader.cleanup(); | ||||
| } | } | ||||
| return true; | |||||
| } | } | ||||
| private boolean checkFile() { | private boolean checkFile() { | ||||
| @@ -0,0 +1,110 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.taskdefs.condition.Condition; | |||||
| import org.apache.tools.ant.taskdefs.condition.ConditionBase; | |||||
| /** | |||||
| * <condition> task as a generalization of <available> and | |||||
| * <uptodate> | |||||
| * | |||||
| * <p>This task supports boolean logic as well as pluggable conditions | |||||
| * to decide, whether a property should be set.</p> | |||||
| * | |||||
| * <p>This task does not extend Task to take advantage of | |||||
| * ConditionBase.</p> | |||||
| * | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de>Stefan Bodewig</a> | |||||
| * @version $Revision$ | |||||
| */ | |||||
| public class ConditionTask extends ConditionBase { | |||||
| private String property; | |||||
| private String value = "true"; | |||||
| /** | |||||
| * The name of the property to set. Required. | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| public void setProperty(String p) {property = p;} | |||||
| /** | |||||
| * The value for the property to set. Defaults to "true". | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| public void setValue(String v) {value = v;} | |||||
| /** | |||||
| * See whether our nested condition holds and set the property. | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| public void execute() throws BuildException { | |||||
| if (countConditions() > 1) { | |||||
| throw new BuildException("You must not nest more than one condition into <condition>"); | |||||
| } | |||||
| if (countConditions() < 1) { | |||||
| throw new BuildException("You must nest a condition into <condition>"); | |||||
| } | |||||
| Condition c = (Condition) getConditions().nextElement(); | |||||
| if (c.eval()) { | |||||
| getProject().setProperty(property, value); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -55,6 +55,7 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import org.apache.tools.ant.*; | import org.apache.tools.ant.*; | ||||
| import org.apache.tools.ant.taskdefs.condition.Condition; | |||||
| import org.apache.tools.ant.types.*; | import org.apache.tools.ant.types.*; | ||||
| import org.apache.tools.ant.util.*; | import org.apache.tools.ant.util.*; | ||||
| import java.io.*; | import java.io.*; | ||||
| @@ -71,7 +72,7 @@ import java.util.Vector; | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | ||||
| */ | */ | ||||
| public class UpToDate extends MatchingTask { | |||||
| public class UpToDate extends MatchingTask implements Condition { | |||||
| private String _property; | private String _property; | ||||
| private String _value; | private String _value; | ||||
| @@ -137,11 +138,9 @@ public class UpToDate extends MatchingTask { | |||||
| } | } | ||||
| /** | /** | ||||
| * Sets property to true if target files have a more recent timestamp than | |||||
| * each of the corresponding source files. | |||||
| * Evaluate all target and source files, see if the targets are up-to-date. | |||||
| */ | */ | ||||
| public void execute() throws BuildException { | |||||
| public boolean eval() { | |||||
| if (sourceFileSets.size() == 0) { | if (sourceFileSets.size() == 0) { | ||||
| throw new BuildException("At least one <srcfiles> element must be set"); | throw new BuildException("At least one <srcfiles> element must be set"); | ||||
| } | } | ||||
| @@ -151,7 +150,7 @@ public class UpToDate extends MatchingTask { | |||||
| } | } | ||||
| // if not there then it can't be up to date | // if not there then it can't be up to date | ||||
| if (_targetFile != null && !_targetFile.exists()) return; | |||||
| if (_targetFile != null && !_targetFile.exists()) return false; | |||||
| Enumeration enum = sourceFileSets.elements(); | Enumeration enum = sourceFileSets.elements(); | ||||
| boolean upToDate = true; | boolean upToDate = true; | ||||
| @@ -161,7 +160,16 @@ public class UpToDate extends MatchingTask { | |||||
| upToDate = upToDate && scanDir(fs.getDir(project), | upToDate = upToDate && scanDir(fs.getDir(project), | ||||
| ds.getIncludedFiles()); | ds.getIncludedFiles()); | ||||
| } | } | ||||
| return upToDate; | |||||
| } | |||||
| /** | |||||
| * Sets property to true if target files have a more recent timestamp than | |||||
| * each of the corresponding source files. | |||||
| */ | |||||
| public void execute() throws BuildException { | |||||
| boolean upToDate = eval(); | |||||
| if (upToDate) { | if (upToDate) { | ||||
| this.project.setProperty(_property, this.getValue()); | this.project.setProperty(_property, this.getValue()); | ||||
| if (mapperElement == null) { | if (mapperElement == null) { | ||||
| @@ -0,0 +1,83 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs.condition; | |||||
| import java.util.Enumeration; | |||||
| import org.apache.tools.ant.BuildException; | |||||
| /** | |||||
| * <and> condition container. | |||||
| * | |||||
| * <p>Iterates over all conditions and returns false as soon as one | |||||
| * evaluates to false.</p> | |||||
| * | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de>Stefan Bodewig</a> | |||||
| * @version $Revision$ | |||||
| */ | |||||
| public class And extends ConditionBase implements Condition { | |||||
| public boolean eval() throws BuildException { | |||||
| Enumeration enum = getConditions(); | |||||
| while (enum.hasMoreElements()) { | |||||
| Condition c = (Condition) enum.nextElement(); | |||||
| if (!c.eval()) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return true; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,71 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs.condition; | |||||
| import org.apache.tools.ant.BuildException; | |||||
| /** | |||||
| * Interface for conditions to use inside the <condition> task. | |||||
| * | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de>Stefan Bodewig</a> | |||||
| * @version $Revision$ | |||||
| */ | |||||
| public interface Condition { | |||||
| /** | |||||
| * Is this condition true? | |||||
| */ | |||||
| public boolean eval() throws BuildException; | |||||
| } | |||||
| @@ -0,0 +1,177 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs.condition; | |||||
| import java.util.Enumeration; | |||||
| import java.util.NoSuchElementException; | |||||
| import java.util.Vector; | |||||
| import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.Task; | |||||
| import org.apache.tools.ant.taskdefs.Available; | |||||
| import org.apache.tools.ant.taskdefs.UpToDate; | |||||
| /** | |||||
| * Baseclass for the <condition> task as well as several | |||||
| * conditions - ensures that the types of conditions inside the task | |||||
| * and the "container" conditions are in sync. | |||||
| * | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de>Stefan Bodewig</a> | |||||
| * @version $Revision$ | |||||
| */ | |||||
| public abstract class ConditionBase { | |||||
| private Vector conditions = new Vector(); | |||||
| private Project project; | |||||
| public void setProject(Project p) { | |||||
| this.project = p; | |||||
| } | |||||
| protected Project getProject() {return project;} | |||||
| /** | |||||
| * Count the conditions. | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| protected int countConditions() {return conditions.size();} | |||||
| /** | |||||
| * Iterate through all conditions. | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| protected final Enumeration getConditions() { | |||||
| return new ConditionEnumeration(); | |||||
| } | |||||
| /** | |||||
| * Add an <available> condition. | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| public void addAvailable(Available a) {conditions.addElement(a);} | |||||
| /** | |||||
| * Add an <uptodate> condition. | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| public void addUptodate(UpToDate u) {conditions.addElement(u);} | |||||
| /** | |||||
| * Add an <not> condition "container". | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| public void addNot(Not n) {conditions.addElement(n);} | |||||
| /** | |||||
| * Add an <and> condition "container". | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| public void addAnd(And a) {conditions.addElement(a);} | |||||
| /** | |||||
| * Add an <or> condition "container". | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| public void addOr(Or o) {conditions.addElement(o);} | |||||
| /** | |||||
| * Add an <equals> condition. | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| public void addEquals(Equals e) {conditions.addElement(e);} | |||||
| /** | |||||
| * Add an <os> condition. | |||||
| * | |||||
| * @since 1.1 | |||||
| */ | |||||
| public void addOs(Os o) {conditions.addElement(o);} | |||||
| /** | |||||
| * 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 Task) { | |||||
| ((Task) o).setProject(getProject()); | |||||
| } else if (o instanceof ConditionBase) { | |||||
| ((ConditionBase) o).setProject(getProject()); | |||||
| } | |||||
| return o; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,78 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs.condition; | |||||
| import org.apache.tools.ant.BuildException; | |||||
| /** | |||||
| * Simple String comparison condition. | |||||
| * | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de>Stefan Bodewig</a> | |||||
| * @version $Revision$ | |||||
| */ | |||||
| public class Equals implements Condition { | |||||
| private String arg1, arg2; | |||||
| public void setArg1(String a1) {arg1 = a1;} | |||||
| public void setArg2(String a2) {arg2 = a2;} | |||||
| public boolean eval() throws BuildException { | |||||
| if (arg1 == null || arg2 == null) { | |||||
| throw new BuildException("both arg1 and arg2 are required in equals"); | |||||
| } | |||||
| return arg1.equals(arg2); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,80 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs.condition; | |||||
| import org.apache.tools.ant.BuildException; | |||||
| /** | |||||
| * <not> condition. | |||||
| * | |||||
| * Evaluates to true if the single condition nested into it is false | |||||
| * and vice versa. | |||||
| * | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de>Stefan Bodewig</a> | |||||
| * @version $Revision$ | |||||
| */ | |||||
| public class Not extends ConditionBase implements Condition { | |||||
| public boolean eval() throws BuildException { | |||||
| if (countConditions() > 1) { | |||||
| throw new BuildException("You must not nest more than one condition into <not>"); | |||||
| } | |||||
| if (countConditions() < 1) { | |||||
| throw new BuildException("You must nest a condition into <not>"); | |||||
| } | |||||
| return !((Condition) getConditions().nextElement()).eval(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,83 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs.condition; | |||||
| import java.util.Enumeration; | |||||
| import org.apache.tools.ant.BuildException; | |||||
| /** | |||||
| * <or> condition container. | |||||
| * | |||||
| * <p>Iterates over all conditions and returns true as soon as one | |||||
| * evaluates to true.</p> | |||||
| * | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de>Stefan Bodewig</a> | |||||
| * @version $Revision$ | |||||
| */ | |||||
| public class Or extends ConditionBase implements Condition { | |||||
| public boolean eval() throws BuildException { | |||||
| Enumeration enum = getConditions(); | |||||
| while (enum.hasMoreElements()) { | |||||
| Condition c = (Condition) enum.nextElement(); | |||||
| if (c.eval()) { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,90 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs.condition; | |||||
| import org.apache.tools.ant.BuildException; | |||||
| /** | |||||
| * Condition that tests the OS type. | |||||
| * | |||||
| * @author <a href="mailto:stefan.bodewig@epost.de>Stefan Bodewig</a> | |||||
| * @version $Revision$ | |||||
| */ | |||||
| public class Os implements Condition { | |||||
| private String family; | |||||
| public void setFamily(String f) {family = f.toLowerCase();} | |||||
| public boolean eval() throws BuildException { | |||||
| String osName = System.getProperty("os.name").toLowerCase(); | |||||
| String pathSep = System.getProperty("path.separator"); | |||||
| if (family != null) { | |||||
| if (family.equals("windows")) { | |||||
| return osName.indexOf("windows") > -1; | |||||
| } else if (family.equals("dos")) { | |||||
| return pathSep.equals(";"); | |||||
| } else if (family.equals("mac")) { | |||||
| return osName.indexOf("mac") > -1; | |||||
| } else if (family.equals("unix")) { | |||||
| return pathSep.equals(":") | |||||
| && (!osName.startsWith("mac") || osName.endsWith("x")); | |||||
| } | |||||
| throw new BuildException("Don\'t know how to detect os family \"" | |||||
| + family + "\""); | |||||
| } | |||||
| return false; | |||||
| } | |||||
| } | |||||
| @@ -51,6 +51,7 @@ pathconvert=org.apache.tools.ant.taskdefs.PathConvert | |||||
| ear=org.apache.tools.ant.taskdefs.Ear | ear=org.apache.tools.ant.taskdefs.Ear | ||||
| parallel=org.apache.tools.ant.taskdefs.Parallel | parallel=org.apache.tools.ant.taskdefs.Parallel | ||||
| sequential=org.apache.tools.ant.taskdefs.Sequential | sequential=org.apache.tools.ant.taskdefs.Sequential | ||||
| condition=org.apache.tools.ant.taskdefs.ConditionTask | |||||
| # optional tasks | # optional tasks | ||||
| script=org.apache.tools.ant.taskdefs.optional.Script | script=org.apache.tools.ant.taskdefs.optional.Script | ||||
| @@ -138,6 +138,11 @@ public class Path extends DataType implements Cloneable { | |||||
| elements = new Vector(); | elements = new Vector(); | ||||
| } | } | ||||
| public void setProject(Project p) { | |||||
| this.project = p; | |||||
| } | |||||
| public Project getProject() {return project;} | |||||
| /** | /** | ||||
| * Adds a element definition to the path. | * Adds a element definition to the path. | ||||
| * @param location the location of the element to add (must not be | * @param location the location of the element to add (must not be | ||||
| @@ -285,7 +290,11 @@ public class Path extends DataType implements Cloneable { | |||||
| addUnlessPresent(result, parts[j]); | addUnlessPresent(result, parts[j]); | ||||
| } | } | ||||
| } else if (o instanceof Path) { | } else if (o instanceof Path) { | ||||
| String[] parts = ((Path) o).list(); | |||||
| Path p = (Path) o; | |||||
| if (p.getProject() == null) { | |||||
| p.setProject(project); | |||||
| } | |||||
| String[] parts = p.list(); | |||||
| for (int j=0; j<parts.length; j++) { | for (int j=0; j<parts.length; j++) { | ||||
| addUnlessPresent(result, parts[j]); | addUnlessPresent(result, parts[j]); | ||||
| } | } | ||||