git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@482069 13f79535-47bb-0310-9956-ffa450edef68master
@@ -64,4 +64,4 @@ public class ExitStatusException extends BuildException { | |||||
public int getStatus() { | public int getStatus() { | ||||
return status; | return status; | ||||
} | } | ||||
} | |||||
} |
@@ -46,4 +46,4 @@ public class StringInputStream extends ReaderInputStream { | |||||
super(new StringReader(source), encoding); | super(new StringReader(source), encoding); | ||||
} | } | ||||
} | |||||
} |
@@ -214,4 +214,4 @@ public class Exit extends Task { | |||||
return (nestedCondition != null); | return (nestedCondition != null); | ||||
} | } | ||||
} | |||||
} |
@@ -230,4 +230,4 @@ public class LoadProperties extends Task { | |||||
throw new BuildException("expected a java resource as source"); | throw new BuildException("expected a java resource as source"); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -121,4 +121,4 @@ public class ResourceCount extends Task implements Condition { | |||||
property = p; | property = p; | ||||
} | } | ||||
} | |||||
} |
@@ -27,4 +27,4 @@ package org.apache.tools.ant.taskdefs; | |||||
* @ant.task ignore="true" | * @ant.task ignore="true" | ||||
*/ | */ | ||||
public class Transform extends ExecuteOn { | public class Transform extends ExecuteOn { | ||||
} | |||||
} |
@@ -1,35 +1,35 @@ | |||||
/* | |||||
* 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.types.Resource; | |||||
/** | |||||
* Extends Proxy interface for XSLT processors. | |||||
* | |||||
* @see XSLTProcess | |||||
* @since Ant 1.7 | |||||
*/ | |||||
public interface XSLTLiaison3 extends XSLTLiaison2 { | |||||
/** | |||||
* sets the stylesheet to use as a resource | |||||
* @param stylesheet the stylesheet to use as a resource | |||||
* @throws Exception if the stylesheet cannot be loaded | |||||
*/ | |||||
void setStylesheet(Resource stylesheet) throws Exception; | |||||
} | |||||
/* | |||||
* 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.types.Resource; | |||||
/** | |||||
* Extends Proxy interface for XSLT processors. | |||||
* | |||||
* @see XSLTProcess | |||||
* @since Ant 1.7 | |||||
*/ | |||||
public interface XSLTLiaison3 extends XSLTLiaison2 { | |||||
/** | |||||
* sets the stylesheet to use as a resource | |||||
* @param stylesheet the stylesheet to use as a resource | |||||
* @throws Exception if the stylesheet cannot be loaded | |||||
*/ | |||||
void setStylesheet(Resource stylesheet) throws Exception; | |||||
} |
@@ -1,183 +1,183 @@ | |||||
/* | |||||
* 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 org.apache.tools.ant.types.Path; | |||||
import org.apache.tools.ant.types.Reference; | |||||
import org.apache.tools.ant.AntClassLoader; | |||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.ProjectComponent; | |||||
import java.lang.reflect.Method; | |||||
import java.lang.reflect.Field; | |||||
/** | |||||
* test for a method | |||||
*/ | |||||
public class HasMethod extends ProjectComponent implements Condition { | |||||
private String classname; | |||||
private String method; | |||||
private String field; | |||||
private Path classpath; | |||||
private AntClassLoader loader; | |||||
private boolean ignoreSystemClasses = false; | |||||
/** | |||||
* Set the classpath to be used when searching for classes and resources. | |||||
* | |||||
* @param classpath an Ant Path object containing the search path. | |||||
*/ | |||||
public void setClasspath(Path classpath) { | |||||
createClasspath().append(classpath); | |||||
} | |||||
/** | |||||
* Classpath to be used when searching for classes and resources. | |||||
* | |||||
* @return an empty Path instance to be configured by Ant. | |||||
*/ | |||||
public Path createClasspath() { | |||||
if (this.classpath == null) { | |||||
this.classpath = new Path(getProject()); | |||||
} | |||||
return this.classpath.createPath(); | |||||
} | |||||
/** | |||||
* Set the classpath by reference. | |||||
* | |||||
* @param r a Reference to a Path instance to be used as the classpath | |||||
* value. | |||||
*/ | |||||
public void setClasspathRef(Reference r) { | |||||
createClasspath().setRefid(r); | |||||
} | |||||
/** | |||||
* Set the classname attribute. | |||||
* @param classname the name of the class to check. | |||||
*/ | |||||
public void setClassname(String classname) { | |||||
this.classname = classname; | |||||
} | |||||
/** | |||||
* Set the name of the method. | |||||
* @param method the name of the method to check. | |||||
*/ | |||||
public void setMethod(String method) { | |||||
this.method = method; | |||||
} | |||||
/** | |||||
* Set the name of the field. | |||||
* @param field the name of the field to check. | |||||
*/ | |||||
public void setField(String field) { | |||||
this.field = field; | |||||
} | |||||
/** | |||||
* Set whether to ignore system classes when looking for the class. | |||||
* @param ignoreSystemClasses a <code>boolean</code> value. | |||||
*/ | |||||
public void setIgnoreSystemClasses(boolean ignoreSystemClasses) { | |||||
this.ignoreSystemClasses = ignoreSystemClasses; | |||||
} | |||||
/** | |||||
* Check if a given class can be loaded. | |||||
*/ | |||||
private Class loadClass(String classname) { | |||||
try { | |||||
if (ignoreSystemClasses) { | |||||
loader = getProject().createClassLoader(classpath); | |||||
loader.setParentFirst(false); | |||||
loader.addJavaLibraries(); | |||||
if (loader != null) { | |||||
try { | |||||
return loader.findClass(classname); | |||||
} catch (SecurityException se) { | |||||
// class found but restricted name; this is | |||||
// actually the case we're looking for in JDK 1.3+, | |||||
// so catch the exception and return | |||||
return null; | |||||
} | |||||
} else { | |||||
return null; | |||||
} | |||||
} else if (loader != null) { | |||||
return loader.loadClass(classname); | |||||
} else { | |||||
ClassLoader l = this.getClass().getClassLoader(); | |||||
// Can return null to represent the bootstrap class loader. | |||||
// see API docs of Class.getClassLoader. | |||||
if (l != null) { | |||||
return Class.forName(classname, true, l); | |||||
} else { | |||||
return Class.forName(classname); | |||||
} | |||||
} | |||||
} catch (ClassNotFoundException e) { | |||||
throw new BuildException("class \"" + classname + "\" was not found"); | |||||
} catch (NoClassDefFoundError e) { | |||||
throw new BuildException("Could not load dependent class \"" + e.getMessage() | |||||
+ "\" for class \"" + classname + "\""); | |||||
} | |||||
} | |||||
/** {@inheritDoc}. */ | |||||
public boolean eval() throws BuildException { | |||||
if (classname == null) { | |||||
throw new BuildException("No classname defined"); | |||||
} | |||||
Class clazz = loadClass(classname); | |||||
if (method != null) { | |||||
return isMethodFound(clazz); | |||||
} | |||||
if (field != null) { | |||||
return isFieldFound(clazz); | |||||
} | |||||
throw new BuildException("Neither method nor field defined"); | |||||
} | |||||
private boolean isFieldFound(Class clazz) { | |||||
Field[] fields = clazz.getDeclaredFields(); | |||||
for (int i = 0; i < fields.length; i++) { | |||||
Field fieldEntry = fields[i]; | |||||
if (fieldEntry.getName().equals(field)) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
private boolean isMethodFound(Class clazz) { | |||||
Method[] methods = clazz.getDeclaredMethods(); | |||||
for (int i = 0; i < methods.length; i++) { | |||||
Method methodEntry = methods[i]; | |||||
if (methodEntry.getName().equals(method)) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
} | |||||
/* | |||||
* 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 org.apache.tools.ant.types.Path; | |||||
import org.apache.tools.ant.types.Reference; | |||||
import org.apache.tools.ant.AntClassLoader; | |||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.ProjectComponent; | |||||
import java.lang.reflect.Method; | |||||
import java.lang.reflect.Field; | |||||
/** | |||||
* test for a method | |||||
*/ | |||||
public class HasMethod extends ProjectComponent implements Condition { | |||||
private String classname; | |||||
private String method; | |||||
private String field; | |||||
private Path classpath; | |||||
private AntClassLoader loader; | |||||
private boolean ignoreSystemClasses = false; | |||||
/** | |||||
* Set the classpath to be used when searching for classes and resources. | |||||
* | |||||
* @param classpath an Ant Path object containing the search path. | |||||
*/ | |||||
public void setClasspath(Path classpath) { | |||||
createClasspath().append(classpath); | |||||
} | |||||
/** | |||||
* Classpath to be used when searching for classes and resources. | |||||
* | |||||
* @return an empty Path instance to be configured by Ant. | |||||
*/ | |||||
public Path createClasspath() { | |||||
if (this.classpath == null) { | |||||
this.classpath = new Path(getProject()); | |||||
} | |||||
return this.classpath.createPath(); | |||||
} | |||||
/** | |||||
* Set the classpath by reference. | |||||
* | |||||
* @param r a Reference to a Path instance to be used as the classpath | |||||
* value. | |||||
*/ | |||||
public void setClasspathRef(Reference r) { | |||||
createClasspath().setRefid(r); | |||||
} | |||||
/** | |||||
* Set the classname attribute. | |||||
* @param classname the name of the class to check. | |||||
*/ | |||||
public void setClassname(String classname) { | |||||
this.classname = classname; | |||||
} | |||||
/** | |||||
* Set the name of the method. | |||||
* @param method the name of the method to check. | |||||
*/ | |||||
public void setMethod(String method) { | |||||
this.method = method; | |||||
} | |||||
/** | |||||
* Set the name of the field. | |||||
* @param field the name of the field to check. | |||||
*/ | |||||
public void setField(String field) { | |||||
this.field = field; | |||||
} | |||||
/** | |||||
* Set whether to ignore system classes when looking for the class. | |||||
* @param ignoreSystemClasses a <code>boolean</code> value. | |||||
*/ | |||||
public void setIgnoreSystemClasses(boolean ignoreSystemClasses) { | |||||
this.ignoreSystemClasses = ignoreSystemClasses; | |||||
} | |||||
/** | |||||
* Check if a given class can be loaded. | |||||
*/ | |||||
private Class loadClass(String classname) { | |||||
try { | |||||
if (ignoreSystemClasses) { | |||||
loader = getProject().createClassLoader(classpath); | |||||
loader.setParentFirst(false); | |||||
loader.addJavaLibraries(); | |||||
if (loader != null) { | |||||
try { | |||||
return loader.findClass(classname); | |||||
} catch (SecurityException se) { | |||||
// class found but restricted name; this is | |||||
// actually the case we're looking for in JDK 1.3+, | |||||
// so catch the exception and return | |||||
return null; | |||||
} | |||||
} else { | |||||
return null; | |||||
} | |||||
} else if (loader != null) { | |||||
return loader.loadClass(classname); | |||||
} else { | |||||
ClassLoader l = this.getClass().getClassLoader(); | |||||
// Can return null to represent the bootstrap class loader. | |||||
// see API docs of Class.getClassLoader. | |||||
if (l != null) { | |||||
return Class.forName(classname, true, l); | |||||
} else { | |||||
return Class.forName(classname); | |||||
} | |||||
} | |||||
} catch (ClassNotFoundException e) { | |||||
throw new BuildException("class \"" + classname + "\" was not found"); | |||||
} catch (NoClassDefFoundError e) { | |||||
throw new BuildException("Could not load dependent class \"" + e.getMessage() | |||||
+ "\" for class \"" + classname + "\""); | |||||
} | |||||
} | |||||
/** {@inheritDoc}. */ | |||||
public boolean eval() throws BuildException { | |||||
if (classname == null) { | |||||
throw new BuildException("No classname defined"); | |||||
} | |||||
Class clazz = loadClass(classname); | |||||
if (method != null) { | |||||
return isMethodFound(clazz); | |||||
} | |||||
if (field != null) { | |||||
return isFieldFound(clazz); | |||||
} | |||||
throw new BuildException("Neither method nor field defined"); | |||||
} | |||||
private boolean isFieldFound(Class clazz) { | |||||
Field[] fields = clazz.getDeclaredFields(); | |||||
for (int i = 0; i < fields.length; i++) { | |||||
Field fieldEntry = fields[i]; | |||||
if (fieldEntry.getName().equals(field)) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
private boolean isMethodFound(Class clazz) { | |||||
Method[] methods = clazz.getDeclaredMethods(); | |||||
for (int i = 0; i < methods.length; i++) { | |||||
Method methodEntry = methods[i]; | |||||
if (methodEntry.getName().equals(method)) { | |||||
return true; | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
} |
@@ -311,4 +311,4 @@ public final class JarLibManifestTask extends Task { | |||||
return results; | return results; | ||||
} | } | ||||
} | |||||
} |
@@ -212,4 +212,4 @@ public class JJDoc extends Task { | |||||
return (getProject().getBaseDir() + "/" + optionalOutputFile) | return (getProject().getBaseDir() + "/" + optionalOutputFile) | ||||
.replace('\\', '/'); | .replace('\\', '/'); | ||||
} | } | ||||
} | |||||
} |
@@ -402,4 +402,4 @@ public class JJTree extends Task { | |||||
return root; | return root; | ||||
} | } | ||||
} | |||||
} |
@@ -1,38 +1,38 @@ | |||||
/* | |||||
* 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.optional.junit; | |||||
/** | |||||
* Constants, like filenames shared between various classes in this package. | |||||
*/ | |||||
public class Constants { | |||||
static final String HALT_ON_ERROR = "haltOnError="; | |||||
static final String HALT_ON_FAILURE = "haltOnFailure="; | |||||
static final String FILTERTRACE = "filtertrace="; | |||||
static final String CRASHFILE = "crashfile="; | |||||
static final String BEFORE_FIRST_TEST = "BeforeFirstTest"; | |||||
static final String PROPSFILE = "propsfile="; | |||||
static final String SHOWOUTPUT = "showoutput="; | |||||
static final String OUTPUT_TO_FORMATTERS = "outputtoformatters="; | |||||
static final String FORMATTER = "formatter="; | |||||
static final String LOGTESTLISTENEREVENTS = "logtestlistenerevents="; | |||||
static final String TESTSFILE = "testsfile="; | |||||
static final String TERMINATED_SUCCESSFULLY = "terminated successfully"; | |||||
} | |||||
/* | |||||
* 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.optional.junit; | |||||
/** | |||||
* Constants, like filenames shared between various classes in this package. | |||||
*/ | |||||
public class Constants { | |||||
static final String HALT_ON_ERROR = "haltOnError="; | |||||
static final String HALT_ON_FAILURE = "haltOnFailure="; | |||||
static final String FILTERTRACE = "filtertrace="; | |||||
static final String CRASHFILE = "crashfile="; | |||||
static final String BEFORE_FIRST_TEST = "BeforeFirstTest"; | |||||
static final String PROPSFILE = "propsfile="; | |||||
static final String SHOWOUTPUT = "showoutput="; | |||||
static final String OUTPUT_TO_FORMATTERS = "outputtoformatters="; | |||||
static final String FORMATTER = "formatter="; | |||||
static final String LOGTESTLISTENEREVENTS = "logtestlistenerevents="; | |||||
static final String TESTSFILE = "testsfile="; | |||||
static final String TERMINATED_SUCCESSFULLY = "terminated successfully"; | |||||
} |
@@ -1,52 +1,52 @@ | |||||
/* | |||||
* 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.rmic; | |||||
import org.apache.tools.ant.types.Commandline; | |||||
/** | |||||
* Run rmic in a new process with -Xnew set. | |||||
* This switches rmic to use a new compiler, one that doesnt work in-process | |||||
* on ant on java1.6. | |||||
* see: <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=38732"> | |||||
* http://issues.apache.org/bugzilla/show_bug.cgi?id=38732</a> | |||||
*/ | |||||
public class XNewRmic extends ForkingSunRmic { | |||||
/** | |||||
* the name of this adapter for users to select | |||||
*/ | |||||
public static final String COMPILER_NAME = "xnew"; | |||||
/** No-arg constructor. */ | |||||
public XNewRmic() { | |||||
} | |||||
/** | |||||
* Create a normal command line, then with -Xnew at the front | |||||
* @return a command line that hands off to thw | |||||
*/ | |||||
protected Commandline setupRmicCommand() { | |||||
String[] options = new String[] { | |||||
"-Xnew" | |||||
}; | |||||
Commandline commandline = super.setupRmicCommand(options); | |||||
return commandline; | |||||
} | |||||
} | |||||
/* | |||||
* 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.rmic; | |||||
import org.apache.tools.ant.types.Commandline; | |||||
/** | |||||
* Run rmic in a new process with -Xnew set. | |||||
* This switches rmic to use a new compiler, one that doesnt work in-process | |||||
* on ant on java1.6. | |||||
* see: <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=38732"> | |||||
* http://issues.apache.org/bugzilla/show_bug.cgi?id=38732</a> | |||||
*/ | |||||
public class XNewRmic extends ForkingSunRmic { | |||||
/** | |||||
* the name of this adapter for users to select | |||||
*/ | |||||
public static final String COMPILER_NAME = "xnew"; | |||||
/** No-arg constructor. */ | |||||
public XNewRmic() { | |||||
} | |||||
/** | |||||
* Create a normal command line, then with -Xnew at the front | |||||
* @return a command line that hands off to thw | |||||
*/ | |||||
protected Commandline setupRmicCommand() { | |||||
String[] options = new String[] { | |||||
"-Xnew" | |||||
}; | |||||
Commandline commandline = super.setupRmicCommand(options); | |||||
return commandline; | |||||
} | |||||
} |
@@ -104,4 +104,4 @@ public class FileResourceIterator implements Iterator { | |||||
return new FileResource(basedir, files[pos++]); | return new FileResource(basedir, files[pos++]); | ||||
} | } | ||||
} | |||||
} |
@@ -146,4 +146,4 @@ public class ChecksumAlgorithm implements Algorithm { | |||||
buf.append(">"); | buf.append(">"); | ||||
return buf.toString(); | return buf.toString(); | ||||
} | } | ||||
} | |||||
} |
@@ -199,4 +199,4 @@ public class DigestAlgorithm implements Algorithm { | |||||
buf.append(">"); | buf.append(">"); | ||||
return buf.toString(); | return buf.toString(); | ||||
} | } | ||||
} | |||||
} |
@@ -233,4 +233,4 @@ public class PropertiesfileCache implements Cache { | |||||
buf.append(">"); | buf.append(">"); | ||||
return buf.toString(); | return buf.toString(); | ||||
} | } | ||||
} | |||||
} |
@@ -1,306 +1,306 @@ | |||||
/* | |||||
* 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.util; | |||||
import java.io.BufferedReader; | |||||
import java.io.File; | |||||
import java.io.FileReader; | |||||
import java.io.IOException; | |||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.ProjectComponent; | |||||
import org.apache.tools.ant.Project; | |||||
import java.util.Map; | |||||
import java.util.HashMap; | |||||
import java.util.Iterator; | |||||
/** | |||||
* This is a common abstract base case for script runners. | |||||
* These classes need to implement executeScript, evalulateScript | |||||
* and supportsLanguage. | |||||
*/ | |||||
public abstract class ScriptRunnerBase { | |||||
/** Whether to keep the engine between calls to execute/eval */ | |||||
private boolean keepEngine = false; | |||||
/** Script language */ | |||||
private String language; | |||||
/** Script content */ | |||||
private String script = ""; | |||||
/** Project this runner is used in */ | |||||
private Project project; | |||||
/** Classloader to be used when running the script. */ | |||||
private ClassLoader scriptLoader; | |||||
/** Beans to be provided to the script */ | |||||
private Map beans = new HashMap(); | |||||
/** | |||||
* Add a list of named objects to the list to be exported to the script | |||||
* | |||||
* @param dictionary a map of objects to be placed into the script context | |||||
* indexed by String names. | |||||
*/ | |||||
public void addBeans(Map dictionary) { | |||||
for (Iterator i = dictionary.keySet().iterator(); i.hasNext();) { | |||||
String key = (String) i.next(); | |||||
try { | |||||
Object val = dictionary.get(key); | |||||
addBean(key, val); | |||||
} catch (BuildException ex) { | |||||
// The key is in the dictionary but cannot be retrieved | |||||
// This is usually due references that refer to tasks | |||||
// that have not been taskdefed in the current run. | |||||
// Ignore | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* Add a single object into the script context. | |||||
* | |||||
* @param key the name in the context this object is to stored under. | |||||
* @param bean the object to be stored in the script context. | |||||
*/ | |||||
public void addBean(String key, Object bean) { | |||||
boolean isValid = key.length() > 0 | |||||
&& Character.isJavaIdentifierStart(key.charAt(0)); | |||||
for (int i = 1; isValid && i < key.length(); i++) { | |||||
isValid = Character.isJavaIdentifierPart(key.charAt(i)); | |||||
} | |||||
if (isValid) { | |||||
beans.put(key, bean); | |||||
} | |||||
} | |||||
/** | |||||
* Get the beans used for the script. | |||||
* @return the map of beans. | |||||
*/ | |||||
protected Map getBeans() { | |||||
return beans; | |||||
} | |||||
/** | |||||
* Do the work. | |||||
* @param execName the name that will be passed to BSF for this script | |||||
* execution. | |||||
*/ | |||||
public abstract void executeScript(String execName); | |||||
/** | |||||
* Evalulate the script. | |||||
* @param execName the name that will be passed to BSF for this script | |||||
* execution. | |||||
* @return the result of evalulating the script. | |||||
*/ | |||||
public abstract Object evalulateScript(String execName); | |||||
/** | |||||
* Check if a script engine can be created for | |||||
* this language. | |||||
* @return true if a script engine can be created, false | |||||
* otherwise. | |||||
*/ | |||||
public abstract boolean supportsLanguage(); | |||||
/** | |||||
* Get the name of the manager prefix used for this | |||||
* scriptrunner. | |||||
* @return the prefix string. | |||||
*/ | |||||
public abstract String getManagerName(); | |||||
/** | |||||
* Defines the language (required). | |||||
* @param language the scripting language name for the script. | |||||
*/ | |||||
public void setLanguage(String language) { | |||||
this.language = language; | |||||
} | |||||
/** | |||||
* Get the script language | |||||
* @return the script language | |||||
*/ | |||||
public String getLanguage() { | |||||
return language; | |||||
} | |||||
/** | |||||
* Set the script classloader. | |||||
* @param classLoader the classloader to use. | |||||
*/ | |||||
public void setScriptClassLoader(ClassLoader classLoader) { | |||||
this.scriptLoader = classLoader; | |||||
} | |||||
/** | |||||
* Get the classloader used to load the script engine. | |||||
* @return the classloader. | |||||
*/ | |||||
protected ClassLoader getScriptClassLoader() { | |||||
return scriptLoader; | |||||
} | |||||
/** | |||||
* Whether to keep the script engine between calls. | |||||
* @param keepEngine if true, keep the engine. | |||||
*/ | |||||
public void setKeepEngine(boolean keepEngine) { | |||||
this.keepEngine = keepEngine; | |||||
} | |||||
/** | |||||
* Get the keep engine attribute. | |||||
* @return the attribute. | |||||
*/ | |||||
public boolean getKeepEngine() { | |||||
return keepEngine; | |||||
} | |||||
/** | |||||
* Load the script from an external file; optional. | |||||
* @param file the file containing the script source. | |||||
*/ | |||||
public void setSrc(File file) { | |||||
if (!file.exists()) { | |||||
throw new BuildException("file " + file.getPath() + " not found."); | |||||
} | |||||
BufferedReader in = null; | |||||
try { | |||||
in = new BufferedReader(new FileReader(file)); | |||||
script += FileUtils.readFully(in); | |||||
} catch (IOException ex) { | |||||
throw new BuildException(ex); | |||||
} finally { | |||||
FileUtils.close(in); | |||||
} | |||||
} | |||||
/** | |||||
* Set the script text. | |||||
* | |||||
* @param text a component of the script text to be added. | |||||
*/ | |||||
public void addText(String text) { | |||||
this.script += text; | |||||
} | |||||
/** | |||||
* Get the current script text content. | |||||
* @return the script text. | |||||
*/ | |||||
public String getScript() { | |||||
return script; | |||||
} | |||||
/** | |||||
* Clear the current script text content. | |||||
*/ | |||||
public void clearScript() { | |||||
this.script = ""; | |||||
} | |||||
/** | |||||
* Set the project for this runner. | |||||
* @param project the project. | |||||
*/ | |||||
public void setProject(Project project) { | |||||
this.project = project; | |||||
} | |||||
/** | |||||
* Get the project for this runner. | |||||
* @return the project. | |||||
*/ | |||||
public Project getProject() { | |||||
return project; | |||||
} | |||||
/** | |||||
* Bind the runner to a project component. | |||||
* Properties, targets and references are all added as beans; | |||||
* project is bound to project, and self to the component. | |||||
* @param component to become <code>self</code> | |||||
*/ | |||||
public void bindToComponent(ProjectComponent component) { | |||||
project = component.getProject(); | |||||
addBeans(project.getProperties()); | |||||
addBeans(project.getUserProperties()); | |||||
addBeans(project.getTargets()); | |||||
addBeans(project.getReferences()); | |||||
addBean("project", project); | |||||
addBean("self", component); | |||||
} | |||||
/** | |||||
* Bind the runner to a project component. | |||||
* The project and self are the only beans set. | |||||
* @param component to become <code>self</code> | |||||
*/ | |||||
public void bindToComponentMinimum(ProjectComponent component) { | |||||
project = component.getProject(); | |||||
addBean("project", project); | |||||
addBean("self", component); | |||||
} | |||||
/** | |||||
* Check if the language attribute is set. | |||||
* @throws BuildException if it is not. | |||||
*/ | |||||
protected void checkLanguage() { | |||||
if (language == null) { | |||||
throw new BuildException( | |||||
"script language must be specified"); | |||||
} | |||||
} | |||||
/** | |||||
* Replace the current context classloader with the | |||||
* script context classloader. | |||||
* @return the current context classloader. | |||||
*/ | |||||
protected ClassLoader replaceContextLoader() { | |||||
ClassLoader origContextClassLoader = | |||||
Thread.currentThread().getContextClassLoader(); | |||||
if (getScriptClassLoader() == null) { | |||||
setScriptClassLoader(getClass().getClassLoader()); | |||||
} | |||||
Thread.currentThread().setContextClassLoader(getScriptClassLoader()); | |||||
return origContextClassLoader; | |||||
} | |||||
/** | |||||
* Restore the context loader with the original context classloader. | |||||
* | |||||
* script context loader. | |||||
* @param origLoader the original context classloader. | |||||
*/ | |||||
protected void restoreContextLoader(ClassLoader origLoader) { | |||||
Thread.currentThread().setContextClassLoader( | |||||
origLoader); | |||||
} | |||||
} | |||||
/* | |||||
* 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.util; | |||||
import java.io.BufferedReader; | |||||
import java.io.File; | |||||
import java.io.FileReader; | |||||
import java.io.IOException; | |||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.ProjectComponent; | |||||
import org.apache.tools.ant.Project; | |||||
import java.util.Map; | |||||
import java.util.HashMap; | |||||
import java.util.Iterator; | |||||
/** | |||||
* This is a common abstract base case for script runners. | |||||
* These classes need to implement executeScript, evalulateScript | |||||
* and supportsLanguage. | |||||
*/ | |||||
public abstract class ScriptRunnerBase { | |||||
/** Whether to keep the engine between calls to execute/eval */ | |||||
private boolean keepEngine = false; | |||||
/** Script language */ | |||||
private String language; | |||||
/** Script content */ | |||||
private String script = ""; | |||||
/** Project this runner is used in */ | |||||
private Project project; | |||||
/** Classloader to be used when running the script. */ | |||||
private ClassLoader scriptLoader; | |||||
/** Beans to be provided to the script */ | |||||
private Map beans = new HashMap(); | |||||
/** | |||||
* Add a list of named objects to the list to be exported to the script | |||||
* | |||||
* @param dictionary a map of objects to be placed into the script context | |||||
* indexed by String names. | |||||
*/ | |||||
public void addBeans(Map dictionary) { | |||||
for (Iterator i = dictionary.keySet().iterator(); i.hasNext();) { | |||||
String key = (String) i.next(); | |||||
try { | |||||
Object val = dictionary.get(key); | |||||
addBean(key, val); | |||||
} catch (BuildException ex) { | |||||
// The key is in the dictionary but cannot be retrieved | |||||
// This is usually due references that refer to tasks | |||||
// that have not been taskdefed in the current run. | |||||
// Ignore | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* Add a single object into the script context. | |||||
* | |||||
* @param key the name in the context this object is to stored under. | |||||
* @param bean the object to be stored in the script context. | |||||
*/ | |||||
public void addBean(String key, Object bean) { | |||||
boolean isValid = key.length() > 0 | |||||
&& Character.isJavaIdentifierStart(key.charAt(0)); | |||||
for (int i = 1; isValid && i < key.length(); i++) { | |||||
isValid = Character.isJavaIdentifierPart(key.charAt(i)); | |||||
} | |||||
if (isValid) { | |||||
beans.put(key, bean); | |||||
} | |||||
} | |||||
/** | |||||
* Get the beans used for the script. | |||||
* @return the map of beans. | |||||
*/ | |||||
protected Map getBeans() { | |||||
return beans; | |||||
} | |||||
/** | |||||
* Do the work. | |||||
* @param execName the name that will be passed to BSF for this script | |||||
* execution. | |||||
*/ | |||||
public abstract void executeScript(String execName); | |||||
/** | |||||
* Evalulate the script. | |||||
* @param execName the name that will be passed to BSF for this script | |||||
* execution. | |||||
* @return the result of evalulating the script. | |||||
*/ | |||||
public abstract Object evalulateScript(String execName); | |||||
/** | |||||
* Check if a script engine can be created for | |||||
* this language. | |||||
* @return true if a script engine can be created, false | |||||
* otherwise. | |||||
*/ | |||||
public abstract boolean supportsLanguage(); | |||||
/** | |||||
* Get the name of the manager prefix used for this | |||||
* scriptrunner. | |||||
* @return the prefix string. | |||||
*/ | |||||
public abstract String getManagerName(); | |||||
/** | |||||
* Defines the language (required). | |||||
* @param language the scripting language name for the script. | |||||
*/ | |||||
public void setLanguage(String language) { | |||||
this.language = language; | |||||
} | |||||
/** | |||||
* Get the script language | |||||
* @return the script language | |||||
*/ | |||||
public String getLanguage() { | |||||
return language; | |||||
} | |||||
/** | |||||
* Set the script classloader. | |||||
* @param classLoader the classloader to use. | |||||
*/ | |||||
public void setScriptClassLoader(ClassLoader classLoader) { | |||||
this.scriptLoader = classLoader; | |||||
} | |||||
/** | |||||
* Get the classloader used to load the script engine. | |||||
* @return the classloader. | |||||
*/ | |||||
protected ClassLoader getScriptClassLoader() { | |||||
return scriptLoader; | |||||
} | |||||
/** | |||||
* Whether to keep the script engine between calls. | |||||
* @param keepEngine if true, keep the engine. | |||||
*/ | |||||
public void setKeepEngine(boolean keepEngine) { | |||||
this.keepEngine = keepEngine; | |||||
} | |||||
/** | |||||
* Get the keep engine attribute. | |||||
* @return the attribute. | |||||
*/ | |||||
public boolean getKeepEngine() { | |||||
return keepEngine; | |||||
} | |||||
/** | |||||
* Load the script from an external file; optional. | |||||
* @param file the file containing the script source. | |||||
*/ | |||||
public void setSrc(File file) { | |||||
if (!file.exists()) { | |||||
throw new BuildException("file " + file.getPath() + " not found."); | |||||
} | |||||
BufferedReader in = null; | |||||
try { | |||||
in = new BufferedReader(new FileReader(file)); | |||||
script += FileUtils.readFully(in); | |||||
} catch (IOException ex) { | |||||
throw new BuildException(ex); | |||||
} finally { | |||||
FileUtils.close(in); | |||||
} | |||||
} | |||||
/** | |||||
* Set the script text. | |||||
* | |||||
* @param text a component of the script text to be added. | |||||
*/ | |||||
public void addText(String text) { | |||||
this.script += text; | |||||
} | |||||
/** | |||||
* Get the current script text content. | |||||
* @return the script text. | |||||
*/ | |||||
public String getScript() { | |||||
return script; | |||||
} | |||||
/** | |||||
* Clear the current script text content. | |||||
*/ | |||||
public void clearScript() { | |||||
this.script = ""; | |||||
} | |||||
/** | |||||
* Set the project for this runner. | |||||
* @param project the project. | |||||
*/ | |||||
public void setProject(Project project) { | |||||
this.project = project; | |||||
} | |||||
/** | |||||
* Get the project for this runner. | |||||
* @return the project. | |||||
*/ | |||||
public Project getProject() { | |||||
return project; | |||||
} | |||||
/** | |||||
* Bind the runner to a project component. | |||||
* Properties, targets and references are all added as beans; | |||||
* project is bound to project, and self to the component. | |||||
* @param component to become <code>self</code> | |||||
*/ | |||||
public void bindToComponent(ProjectComponent component) { | |||||
project = component.getProject(); | |||||
addBeans(project.getProperties()); | |||||
addBeans(project.getUserProperties()); | |||||
addBeans(project.getTargets()); | |||||
addBeans(project.getReferences()); | |||||
addBean("project", project); | |||||
addBean("self", component); | |||||
} | |||||
/** | |||||
* Bind the runner to a project component. | |||||
* The project and self are the only beans set. | |||||
* @param component to become <code>self</code> | |||||
*/ | |||||
public void bindToComponentMinimum(ProjectComponent component) { | |||||
project = component.getProject(); | |||||
addBean("project", project); | |||||
addBean("self", component); | |||||
} | |||||
/** | |||||
* Check if the language attribute is set. | |||||
* @throws BuildException if it is not. | |||||
*/ | |||||
protected void checkLanguage() { | |||||
if (language == null) { | |||||
throw new BuildException( | |||||
"script language must be specified"); | |||||
} | |||||
} | |||||
/** | |||||
* Replace the current context classloader with the | |||||
* script context classloader. | |||||
* @return the current context classloader. | |||||
*/ | |||||
protected ClassLoader replaceContextLoader() { | |||||
ClassLoader origContextClassLoader = | |||||
Thread.currentThread().getContextClassLoader(); | |||||
if (getScriptClassLoader() == null) { | |||||
setScriptClassLoader(getClass().getClassLoader()); | |||||
} | |||||
Thread.currentThread().setContextClassLoader(getScriptClassLoader()); | |||||
return origContextClassLoader; | |||||
} | |||||
/** | |||||
* Restore the context loader with the original context classloader. | |||||
* | |||||
* script context loader. | |||||
* @param origLoader the original context classloader. | |||||
*/ | |||||
protected void restoreContextLoader(ClassLoader origLoader) { | |||||
Thread.currentThread().setContextClassLoader( | |||||
origLoader); | |||||
} | |||||
} |
@@ -1,139 +1,139 @@ | |||||
/* | |||||
* 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.util; | |||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.Project; | |||||
/** | |||||
* This is a helper class used by ScriptRunnerHelper to | |||||
* create a ScriptRunner based on a classloader and | |||||
* on a language. | |||||
*/ | |||||
public class ScriptRunnerCreator { | |||||
private static final String AUTO = "auto"; | |||||
private static final String OATAU = "org.apache.tools.ant.util"; | |||||
private static final String UTIL_OPT = OATAU + ".optional"; | |||||
private static final String BSF = "bsf"; | |||||
private static final String BSF_PACK = "org.apache.bsf"; | |||||
private static final String BSF_MANAGER = BSF_PACK + ".BSFManager"; | |||||
private static final String BSF_RUNNER = UTIL_OPT + ".ScriptRunner"; | |||||
private static final String JAVAX = "javax"; | |||||
private static final String JAVAX_MANAGER = "javax.script.ScriptEngineManager"; | |||||
private static final String JAVAX_RUNNER = UTIL_OPT + ".JavaxScriptRunner"; | |||||
private Project project; | |||||
private String manager; | |||||
private String language; | |||||
private ClassLoader scriptLoader = null; | |||||
/** | |||||
* Constructor for creator. | |||||
* @param project the current project. | |||||
*/ | |||||
public ScriptRunnerCreator(Project project) { | |||||
this.project = project; | |||||
} | |||||
/** | |||||
* Create a ScriptRunner. | |||||
* @param manager the script manager ("auto" | "bsf" | "javax") | |||||
* @param language the language. | |||||
* @param classLoader the classloader to use | |||||
* @return the created script runner. | |||||
* @throws BuildException if unable to create the ScriptRunner. | |||||
*/ | |||||
public ScriptRunnerBase createRunner( | |||||
String manager, String language, ClassLoader classLoader) { | |||||
this.manager = manager; | |||||
this.language = language; | |||||
this.scriptLoader = classLoader; | |||||
if (language == null) { | |||||
throw new BuildException("script language must be specified"); | |||||
} | |||||
if (!manager.equals(AUTO) && !manager.equals(JAVAX) && !manager.equals(BSF)) { | |||||
throw new BuildException( | |||||
"Unsupported language prefix " + manager); | |||||
} | |||||
// Check for bsf first then javax | |||||
// This version does not check if the scriptManager | |||||
// supports the language. | |||||
ScriptRunnerBase ret = null; | |||||
ret = createRunner(BSF, BSF_MANAGER, BSF_RUNNER); | |||||
if (ret == null) { | |||||
ret = createRunner(JAVAX, JAVAX_MANAGER, JAVAX_RUNNER); | |||||
} | |||||
if (ret != null) { | |||||
return ret; | |||||
} | |||||
if (JAVAX.equals(manager)) { | |||||
throw new BuildException( | |||||
"Unable to load the script engine manager " | |||||
+ "(" + JAVAX_MANAGER + ")"); | |||||
} else if (BSF.equals(manager)) { | |||||
throw new BuildException( | |||||
"Unable to load the BSF script engine manager " | |||||
+ "(" + BSF_MANAGER + ")"); | |||||
} else { | |||||
throw new BuildException( | |||||
"Unable to load a script engine manager " | |||||
+ "(" + BSF_MANAGER + " or " + JAVAX_MANAGER + ")"); | |||||
} | |||||
} | |||||
/** | |||||
* Create a script runner if the scriptManager matches the passed | |||||
* in manager. | |||||
* This checks if the script manager exists in the scriptLoader | |||||
* classloader and if so it creates and returns the script runner. | |||||
* @param checkManager check if the manager matchs this value. | |||||
* @param mangagerClass the name of the script manager class. | |||||
* @param runnerClass the name of ant's script runner for this manager. | |||||
* @return the script runner class. | |||||
* @throws BuildException if there is a problem creating the runner class. | |||||
*/ | |||||
private ScriptRunnerBase createRunner( | |||||
String checkManager, String managerClass, String runnerClass) { | |||||
ScriptRunnerBase runner = null; | |||||
if (!manager.equals(AUTO) && !manager.equals(checkManager)) { | |||||
return null; | |||||
} | |||||
if (scriptLoader.getResource( | |||||
LoaderUtils.classNameToResource(managerClass)) == null) { | |||||
return null; | |||||
} | |||||
try { | |||||
runner = (ScriptRunnerBase) Class.forName( | |||||
runnerClass, true, scriptLoader).newInstance(); | |||||
runner.setProject(project); | |||||
return runner; | |||||
} catch (Exception ex) { | |||||
ReflectUtil.throwBuildException(ex); | |||||
// NotReached | |||||
} | |||||
runner.setLanguage(language); | |||||
runner.setScriptClassLoader(scriptLoader); | |||||
return runner; | |||||
} | |||||
} | |||||
/* | |||||
* 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.util; | |||||
import org.apache.tools.ant.BuildException; | |||||
import org.apache.tools.ant.Project; | |||||
/** | |||||
* This is a helper class used by ScriptRunnerHelper to | |||||
* create a ScriptRunner based on a classloader and | |||||
* on a language. | |||||
*/ | |||||
public class ScriptRunnerCreator { | |||||
private static final String AUTO = "auto"; | |||||
private static final String OATAU = "org.apache.tools.ant.util"; | |||||
private static final String UTIL_OPT = OATAU + ".optional"; | |||||
private static final String BSF = "bsf"; | |||||
private static final String BSF_PACK = "org.apache.bsf"; | |||||
private static final String BSF_MANAGER = BSF_PACK + ".BSFManager"; | |||||
private static final String BSF_RUNNER = UTIL_OPT + ".ScriptRunner"; | |||||
private static final String JAVAX = "javax"; | |||||
private static final String JAVAX_MANAGER = "javax.script.ScriptEngineManager"; | |||||
private static final String JAVAX_RUNNER = UTIL_OPT + ".JavaxScriptRunner"; | |||||
private Project project; | |||||
private String manager; | |||||
private String language; | |||||
private ClassLoader scriptLoader = null; | |||||
/** | |||||
* Constructor for creator. | |||||
* @param project the current project. | |||||
*/ | |||||
public ScriptRunnerCreator(Project project) { | |||||
this.project = project; | |||||
} | |||||
/** | |||||
* Create a ScriptRunner. | |||||
* @param manager the script manager ("auto" | "bsf" | "javax") | |||||
* @param language the language. | |||||
* @param classLoader the classloader to use | |||||
* @return the created script runner. | |||||
* @throws BuildException if unable to create the ScriptRunner. | |||||
*/ | |||||
public ScriptRunnerBase createRunner( | |||||
String manager, String language, ClassLoader classLoader) { | |||||
this.manager = manager; | |||||
this.language = language; | |||||
this.scriptLoader = classLoader; | |||||
if (language == null) { | |||||
throw new BuildException("script language must be specified"); | |||||
} | |||||
if (!manager.equals(AUTO) && !manager.equals(JAVAX) && !manager.equals(BSF)) { | |||||
throw new BuildException( | |||||
"Unsupported language prefix " + manager); | |||||
} | |||||
// Check for bsf first then javax | |||||
// This version does not check if the scriptManager | |||||
// supports the language. | |||||
ScriptRunnerBase ret = null; | |||||
ret = createRunner(BSF, BSF_MANAGER, BSF_RUNNER); | |||||
if (ret == null) { | |||||
ret = createRunner(JAVAX, JAVAX_MANAGER, JAVAX_RUNNER); | |||||
} | |||||
if (ret != null) { | |||||
return ret; | |||||
} | |||||
if (JAVAX.equals(manager)) { | |||||
throw new BuildException( | |||||
"Unable to load the script engine manager " | |||||
+ "(" + JAVAX_MANAGER + ")"); | |||||
} else if (BSF.equals(manager)) { | |||||
throw new BuildException( | |||||
"Unable to load the BSF script engine manager " | |||||
+ "(" + BSF_MANAGER + ")"); | |||||
} else { | |||||
throw new BuildException( | |||||
"Unable to load a script engine manager " | |||||
+ "(" + BSF_MANAGER + " or " + JAVAX_MANAGER + ")"); | |||||
} | |||||
} | |||||
/** | |||||
* Create a script runner if the scriptManager matches the passed | |||||
* in manager. | |||||
* This checks if the script manager exists in the scriptLoader | |||||
* classloader and if so it creates and returns the script runner. | |||||
* @param checkManager check if the manager matchs this value. | |||||
* @param mangagerClass the name of the script manager class. | |||||
* @param runnerClass the name of ant's script runner for this manager. | |||||
* @return the script runner class. | |||||
* @throws BuildException if there is a problem creating the runner class. | |||||
*/ | |||||
private ScriptRunnerBase createRunner( | |||||
String checkManager, String managerClass, String runnerClass) { | |||||
ScriptRunnerBase runner = null; | |||||
if (!manager.equals(AUTO) && !manager.equals(checkManager)) { | |||||
return null; | |||||
} | |||||
if (scriptLoader.getResource( | |||||
LoaderUtils.classNameToResource(managerClass)) == null) { | |||||
return null; | |||||
} | |||||
try { | |||||
runner = (ScriptRunnerBase) Class.forName( | |||||
runnerClass, true, scriptLoader).newInstance(); | |||||
runner.setProject(project); | |||||
return runner; | |||||
} catch (Exception ex) { | |||||
ReflectUtil.throwBuildException(ex); | |||||
// NotReached | |||||
} | |||||
runner.setLanguage(language); | |||||
runner.setScriptClassLoader(scriptLoader); | |||||
return runner; | |||||
} | |||||
} |
@@ -1,191 +1,191 @@ | |||||
/* | |||||
* 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.util; | |||||
import org.apache.tools.ant.ProjectComponent; | |||||
import org.apache.tools.ant.types.Path; | |||||
import java.io.File; | |||||
import org.apache.tools.ant.types.Reference; | |||||
/** | |||||
* A class to help in creating, setting and getting | |||||
* script runners. | |||||
*/ | |||||
public class ScriptRunnerHelper { | |||||
private ClasspathUtils.Delegate cpDelegate = null; | |||||
private File srcFile; | |||||
private String manager = "auto"; | |||||
private String language; | |||||
private String text; | |||||
private boolean setBeans = true; | |||||
private ProjectComponent projectComponent; | |||||
private ClassLoader scriptLoader = null; | |||||
/** | |||||
* Set the project component associated with this helper. | |||||
* @param component the project component that owns this helper. | |||||
*/ | |||||
public void setProjectComponent(ProjectComponent component) { | |||||
this.projectComponent = component; | |||||
} | |||||
/** | |||||
* Create and set text on a script. | |||||
* @return the created or reused script runner. | |||||
*/ | |||||
public ScriptRunnerBase getScriptRunner() { | |||||
ScriptRunnerBase runner = getRunner(); | |||||
if (srcFile != null) { | |||||
runner.setSrc(srcFile); | |||||
} | |||||
if (text != null) { | |||||
runner.addText(text); | |||||
} | |||||
if (setBeans) { | |||||
runner.bindToComponent(projectComponent); | |||||
} else { | |||||
runner.bindToComponentMinimum(projectComponent); | |||||
} | |||||
return runner; | |||||
} | |||||
/** | |||||
* Classpath to be used when searching for classes and resources. | |||||
* | |||||
* @return an empty Path instance to be configured by Ant. | |||||
*/ | |||||
public Path createClasspath() { | |||||
return getClassPathDelegate().createClasspath(); | |||||
} | |||||
/** | |||||
* Set the classpath to be used when searching for classes and resources. | |||||
* | |||||
* @param classpath an Ant Path object containing the search path. | |||||
*/ | |||||
public void setClasspath(Path classpath) { | |||||
getClassPathDelegate().setClasspath(classpath); | |||||
} | |||||
/** | |||||
* Set the classpath by reference. | |||||
* | |||||
* @param r a Reference to a Path instance to be used as the classpath | |||||
* value. | |||||
*/ | |||||
public void setClasspathRef(Reference r) { | |||||
getClassPathDelegate().setClasspathref(r); | |||||
} | |||||
/** | |||||
* Load the script from an external file ; optional. | |||||
* | |||||
* @param file the file containing the script source. | |||||
*/ | |||||
public void setSrc(File file) { | |||||
this.srcFile = file; | |||||
} | |||||
/** | |||||
* The script text. | |||||
* | |||||
* @param text a component of the script text to be added. | |||||
*/ | |||||
public void addText(String text) { | |||||
this.text = text; | |||||
} | |||||
/** | |||||
* Defines the script manager - defaults to "auto". | |||||
* | |||||
* @param manager the scripting manager - "bsf" or "javax" or "auto" | |||||
*/ | |||||
public void setManager(String manager) { | |||||
this.manager = manager; | |||||
} | |||||
/** | |||||
* Defines the language (required). | |||||
* | |||||
* @param language the scripting language name for the script. | |||||
*/ | |||||
public void setLanguage(String language) { | |||||
this.language = language; | |||||
} | |||||
/** | |||||
* Get the language. | |||||
* @return the scripting language. | |||||
*/ | |||||
public String getLanguage() { | |||||
return language; | |||||
} | |||||
/** | |||||
* Set the setbeans attribute. | |||||
* If this is true, <script> will create variables in the | |||||
* script instance for all | |||||
* properties, targets and references of the current project. | |||||
* It this is false, only the project and self variables will | |||||
* be set. | |||||
* The default is true. | |||||
* @param setBeans the value to set. | |||||
*/ | |||||
public void setSetBeans(boolean setBeans) { | |||||
this.setBeans = setBeans; | |||||
} | |||||
/** | |||||
* Used when called by scriptdef. | |||||
* @param loader the loader used by scriptdef. | |||||
*/ | |||||
public void setClassLoader(ClassLoader loader) { | |||||
scriptLoader = loader; | |||||
} | |||||
private ClassLoader generateClassLoader() { | |||||
if (scriptLoader != null) { | |||||
return scriptLoader; | |||||
} | |||||
if (cpDelegate == null) { | |||||
scriptLoader = getClass().getClassLoader(); | |||||
return scriptLoader; | |||||
} | |||||
scriptLoader = cpDelegate.getClassLoader(); | |||||
return scriptLoader; | |||||
} | |||||
private ClasspathUtils.Delegate getClassPathDelegate() { | |||||
if (cpDelegate == null) { | |||||
cpDelegate = ClasspathUtils.getDelegate(projectComponent); | |||||
} | |||||
return cpDelegate; | |||||
} | |||||
/** | |||||
* Get a script runner. | |||||
*/ | |||||
private ScriptRunnerBase getRunner() { | |||||
return new ScriptRunnerCreator( | |||||
projectComponent.getProject()).createRunner( | |||||
manager, language, generateClassLoader()); | |||||
} | |||||
} | |||||
/* | |||||
* 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.util; | |||||
import org.apache.tools.ant.ProjectComponent; | |||||
import org.apache.tools.ant.types.Path; | |||||
import java.io.File; | |||||
import org.apache.tools.ant.types.Reference; | |||||
/** | |||||
* A class to help in creating, setting and getting | |||||
* script runners. | |||||
*/ | |||||
public class ScriptRunnerHelper { | |||||
private ClasspathUtils.Delegate cpDelegate = null; | |||||
private File srcFile; | |||||
private String manager = "auto"; | |||||
private String language; | |||||
private String text; | |||||
private boolean setBeans = true; | |||||
private ProjectComponent projectComponent; | |||||
private ClassLoader scriptLoader = null; | |||||
/** | |||||
* Set the project component associated with this helper. | |||||
* @param component the project component that owns this helper. | |||||
*/ | |||||
public void setProjectComponent(ProjectComponent component) { | |||||
this.projectComponent = component; | |||||
} | |||||
/** | |||||
* Create and set text on a script. | |||||
* @return the created or reused script runner. | |||||
*/ | |||||
public ScriptRunnerBase getScriptRunner() { | |||||
ScriptRunnerBase runner = getRunner(); | |||||
if (srcFile != null) { | |||||
runner.setSrc(srcFile); | |||||
} | |||||
if (text != null) { | |||||
runner.addText(text); | |||||
} | |||||
if (setBeans) { | |||||
runner.bindToComponent(projectComponent); | |||||
} else { | |||||
runner.bindToComponentMinimum(projectComponent); | |||||
} | |||||
return runner; | |||||
} | |||||
/** | |||||
* Classpath to be used when searching for classes and resources. | |||||
* | |||||
* @return an empty Path instance to be configured by Ant. | |||||
*/ | |||||
public Path createClasspath() { | |||||
return getClassPathDelegate().createClasspath(); | |||||
} | |||||
/** | |||||
* Set the classpath to be used when searching for classes and resources. | |||||
* | |||||
* @param classpath an Ant Path object containing the search path. | |||||
*/ | |||||
public void setClasspath(Path classpath) { | |||||
getClassPathDelegate().setClasspath(classpath); | |||||
} | |||||
/** | |||||
* Set the classpath by reference. | |||||
* | |||||
* @param r a Reference to a Path instance to be used as the classpath | |||||
* value. | |||||
*/ | |||||
public void setClasspathRef(Reference r) { | |||||
getClassPathDelegate().setClasspathref(r); | |||||
} | |||||
/** | |||||
* Load the script from an external file ; optional. | |||||
* | |||||
* @param file the file containing the script source. | |||||
*/ | |||||
public void setSrc(File file) { | |||||
this.srcFile = file; | |||||
} | |||||
/** | |||||
* The script text. | |||||
* | |||||
* @param text a component of the script text to be added. | |||||
*/ | |||||
public void addText(String text) { | |||||
this.text = text; | |||||
} | |||||
/** | |||||
* Defines the script manager - defaults to "auto". | |||||
* | |||||
* @param manager the scripting manager - "bsf" or "javax" or "auto" | |||||
*/ | |||||
public void setManager(String manager) { | |||||
this.manager = manager; | |||||
} | |||||
/** | |||||
* Defines the language (required). | |||||
* | |||||
* @param language the scripting language name for the script. | |||||
*/ | |||||
public void setLanguage(String language) { | |||||
this.language = language; | |||||
} | |||||
/** | |||||
* Get the language. | |||||
* @return the scripting language. | |||||
*/ | |||||
public String getLanguage() { | |||||
return language; | |||||
} | |||||
/** | |||||
* Set the setbeans attribute. | |||||
* If this is true, <script> will create variables in the | |||||
* script instance for all | |||||
* properties, targets and references of the current project. | |||||
* It this is false, only the project and self variables will | |||||
* be set. | |||||
* The default is true. | |||||
* @param setBeans the value to set. | |||||
*/ | |||||
public void setSetBeans(boolean setBeans) { | |||||
this.setBeans = setBeans; | |||||
} | |||||
/** | |||||
* Used when called by scriptdef. | |||||
* @param loader the loader used by scriptdef. | |||||
*/ | |||||
public void setClassLoader(ClassLoader loader) { | |||||
scriptLoader = loader; | |||||
} | |||||
private ClassLoader generateClassLoader() { | |||||
if (scriptLoader != null) { | |||||
return scriptLoader; | |||||
} | |||||
if (cpDelegate == null) { | |||||
scriptLoader = getClass().getClassLoader(); | |||||
return scriptLoader; | |||||
} | |||||
scriptLoader = cpDelegate.getClassLoader(); | |||||
return scriptLoader; | |||||
} | |||||
private ClasspathUtils.Delegate getClassPathDelegate() { | |||||
if (cpDelegate == null) { | |||||
cpDelegate = ClasspathUtils.getDelegate(projectComponent); | |||||
} | |||||
return cpDelegate; | |||||
} | |||||
/** | |||||
* Get a script runner. | |||||
*/ | |||||
private ScriptRunnerBase getRunner() { | |||||
return new ScriptRunnerCreator( | |||||
projectComponent.getProject()).createRunner( | |||||
manager, language, generateClassLoader()); | |||||
} | |||||
} |
@@ -58,4 +58,4 @@ public class ImplementationSpecificArgument extends Commandline.Argument { | |||||
return new String[0]; | return new String[0]; | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,64 +1,64 @@ | |||||
<?xml version="1.0"?> | |||||
<project name="delete-test" basedir="." default="all" | |||||
xmlns:au="antlib:org.apache.ant.antunit"> | |||||
<property name="working.dir" value="working"/> | |||||
<property name="existing.dir" value="working/exists"/> | |||||
<property name="nonexistent.dir" value="working/nonexists"/> | |||||
<target name="all"> | |||||
<au:antunit> | |||||
<fileset file="${ant.file}"/> | |||||
<au:plainlistener/> | |||||
</au:antunit> | |||||
</target> | |||||
<target name="init"> | |||||
<delete dir="${working.dir}"/> | |||||
<mkdir dir="${working.dir}"/> | |||||
<mkdir dir="${existing.dir}"/> | |||||
</target> | |||||
<target name="tearDown"> | |||||
<delete dir="${working.dir}"/> | |||||
</target> | |||||
<!--test that you can delete a fileset with a nonexistent dir without failure--> | |||||
<target name="testdelfileset" depends="init"> | |||||
<delete quiet="true" includeEmptyDirs="true"> | |||||
<fileset dir="${nonexistent.dir}"/> | |||||
</delete> | |||||
<au:assertFileExists file="${existing.dir}" /> | |||||
<delete quiet="true" includeEmptyDirs="true"> | |||||
<fileset dir="${existing.dir}"/> | |||||
</delete> | |||||
<au:assertFileDoesntExist file="${existing.dir}" /> | |||||
<mkdir dir="${existing.dir}"/> | |||||
<delete quiet="true" includeEmptyDirs="true"> | |||||
<fileset dir="${nonexistent.dir}"/> | |||||
<fileset dir="${existing.dir}"/> | |||||
</delete> | |||||
<au:assertFileDoesntExist file="${existing.dir}" /> | |||||
<mkdir dir="${existing.dir}"/> | |||||
<delete quiet="true" includeEmptyDirs="true"> | |||||
<fileset dir="${existing.dir}"/> | |||||
<fileset dir="${nonexistent.dir}"/> | |||||
</delete> | |||||
<au:assertFileDoesntExist file="${existing.dir}" /> | |||||
</target> | |||||
</project> | |||||
<?xml version="1.0"?> | |||||
<project name="delete-test" basedir="." default="all" | |||||
xmlns:au="antlib:org.apache.ant.antunit"> | |||||
<property name="working.dir" value="working"/> | |||||
<property name="existing.dir" value="working/exists"/> | |||||
<property name="nonexistent.dir" value="working/nonexists"/> | |||||
<target name="all"> | |||||
<au:antunit> | |||||
<fileset file="${ant.file}"/> | |||||
<au:plainlistener/> | |||||
</au:antunit> | |||||
</target> | |||||
<target name="init"> | |||||
<delete dir="${working.dir}"/> | |||||
<mkdir dir="${working.dir}"/> | |||||
<mkdir dir="${existing.dir}"/> | |||||
</target> | |||||
<target name="tearDown"> | |||||
<delete dir="${working.dir}"/> | |||||
</target> | |||||
<!--test that you can delete a fileset with a nonexistent dir without failure--> | |||||
<target name="testdelfileset" depends="init"> | |||||
<delete quiet="true" includeEmptyDirs="true"> | |||||
<fileset dir="${nonexistent.dir}"/> | |||||
</delete> | |||||
<au:assertFileExists file="${existing.dir}" /> | |||||
<delete quiet="true" includeEmptyDirs="true"> | |||||
<fileset dir="${existing.dir}"/> | |||||
</delete> | |||||
<au:assertFileDoesntExist file="${existing.dir}" /> | |||||
<mkdir dir="${existing.dir}"/> | |||||
<delete quiet="true" includeEmptyDirs="true"> | |||||
<fileset dir="${nonexistent.dir}"/> | |||||
<fileset dir="${existing.dir}"/> | |||||
</delete> | |||||
<au:assertFileDoesntExist file="${existing.dir}" /> | |||||
<mkdir dir="${existing.dir}"/> | |||||
<delete quiet="true" includeEmptyDirs="true"> | |||||
<fileset dir="${existing.dir}"/> | |||||
<fileset dir="${nonexistent.dir}"/> | |||||
</delete> | |||||
<au:assertFileDoesntExist file="${existing.dir}" /> | |||||
</target> | |||||
</project> |
@@ -1,161 +1,161 @@ | |||||
<?xml version="1.0"?> | |||||
<project name="war-test" basedir="." default="all" | |||||
xmlns:au="antlib:org.apache.ant.antunit"> | |||||
<property name="working.dir" value="working"/> | |||||
<target name="all"> | |||||
<au:antunit> | |||||
<fileset file="${ant.file}"/> | |||||
<au:plainlistener/> | |||||
</au:antunit> | |||||
</target> | |||||
<target name="init"> | |||||
<delete dir="${working.dir}"/> | |||||
<mkdir dir="${working.dir}"/> | |||||
<property name="warfile" location="${working.dir}/test.war"/> | |||||
<property name="web.xml" location="web.xml"/> | |||||
<property name="webxml.generated" location="${working.dir}/WEB-INF/web.xml"/> | |||||
<!--failing on duplicates is half our testing--> | |||||
<presetdef name="mkwar"> | |||||
<war destfile="${warfile}" duplicate="fail"/> | |||||
</presetdef> | |||||
<presetdef name="expandwar"> | |||||
<unzip src="${working.dir}/test.war" dest="${working.dir}"/> | |||||
</presetdef> | |||||
</target> | |||||
<target name="tearDown"> | |||||
<delete dir="${working.dir}"/> | |||||
</target> | |||||
<!--test that you can patch a fileset reference into a lib element--> | |||||
<target name="testlibrefs" depends="init"> | |||||
<mkwar webxml="${web.xml}"> | |||||
<fileset id="test" dir="." includes="web.xml"/> | |||||
<lib refid="test"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<!-- | |||||
This checks that as of Java EE 5, the web.xml attr is optional. | |||||
Here there is a web.xml, in the webinf fileset, rather than a fileset | |||||
--> | |||||
<target name="testWebXmlInWebinf" depends="init"> | |||||
<mkwar> | |||||
<webinf dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<target name="testWebXmlMissingFromUpdate" depends="init"> | |||||
<mkwar webxml="${web.xml}" /> | |||||
<!-- there is no web.xml file, but that is ok, as | |||||
we are updating --> | |||||
<mkwar update="true"> | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<target name="testWebXmlInImplicitUpdate" depends="init"> | |||||
<mkwar webxml="${web.xml}" /> | |||||
<!-- when we are implicitly updating, the web.xml file does not get | |||||
pulled in, but the command still succeeds.--> | |||||
<mkwar webxml="${web.xml}" > | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<target name="NotestWebXmlFilesetInImplicitUpdate" depends="init"> | |||||
<mkwar webxml="${web.xml}" /> | |||||
<!-- when we are implicitly updating, the web.xml file does not get | |||||
pulled in, but the command still succeeds.--> | |||||
<mkwar > | |||||
<webinf dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<target name="testDuplicateWebXml" depends="init"> | |||||
<mkwar webxml="${web.xml}" > | |||||
<webinf dir="." includes="web.xml"/> | |||||
<webinf file="${web.xml}"/> | |||||
<zipfileset file="${web.xml}" prefix="WEB-INF"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<target name="testDifferentDuplicateWebXml" depends="init"> | |||||
<copy file="${web.xml}" todir="${working.dir}" /> | |||||
<mkwar webxml="${web.xml}" > | |||||
<webinf dir="${working.dir}" includes="web.xml"/> | |||||
<webinf file="${web.xml}"/> | |||||
<zipfileset file="${web.xml}" prefix="WEB-INF"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
<au:assertLogContains text="The duplicate entry is"/> | |||||
</target> | |||||
<!-- | |||||
this target does not have a web.xml file. | |||||
Instead it pulls in | |||||
--> | |||||
<target name="testWebXmlOptional" depends="init"> | |||||
<mkwar needxmlfile="false"> | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${working.dir}/WEB-INF/classes/web.xml" /> | |||||
<au:assertFalse> | |||||
<available file="${webxml.generated}" /> | |||||
</au:assertFalse> | |||||
</target> | |||||
<target name="testWebXmlOptionalFailure" depends="init"> | |||||
<au:expectfailure> | |||||
<mkwar > | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
</au:expectfailure> | |||||
</target> | |||||
<target name="testWebXmlOptionalFailure2" depends="init"> | |||||
<au:expectfailure> | |||||
<mkwar needxmlfile="true"> | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
</au:expectfailure> | |||||
</target> | |||||
<target name="testClassesElement" depends="init"> | |||||
<mkwar needxmlfile="false"> | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${working.dir}/WEB-INF/classes/web.xml" /> | |||||
</target> | |||||
<target name="testLibElement" depends="init"> | |||||
<mkwar needxmlfile="false"> | |||||
<lib dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${working.dir}/WEB-INF/lib/web.xml" /> | |||||
</target> | |||||
</project> | |||||
<?xml version="1.0"?> | |||||
<project name="war-test" basedir="." default="all" | |||||
xmlns:au="antlib:org.apache.ant.antunit"> | |||||
<property name="working.dir" value="working"/> | |||||
<target name="all"> | |||||
<au:antunit> | |||||
<fileset file="${ant.file}"/> | |||||
<au:plainlistener/> | |||||
</au:antunit> | |||||
</target> | |||||
<target name="init"> | |||||
<delete dir="${working.dir}"/> | |||||
<mkdir dir="${working.dir}"/> | |||||
<property name="warfile" location="${working.dir}/test.war"/> | |||||
<property name="web.xml" location="web.xml"/> | |||||
<property name="webxml.generated" location="${working.dir}/WEB-INF/web.xml"/> | |||||
<!--failing on duplicates is half our testing--> | |||||
<presetdef name="mkwar"> | |||||
<war destfile="${warfile}" duplicate="fail"/> | |||||
</presetdef> | |||||
<presetdef name="expandwar"> | |||||
<unzip src="${working.dir}/test.war" dest="${working.dir}"/> | |||||
</presetdef> | |||||
</target> | |||||
<target name="tearDown"> | |||||
<delete dir="${working.dir}"/> | |||||
</target> | |||||
<!--test that you can patch a fileset reference into a lib element--> | |||||
<target name="testlibrefs" depends="init"> | |||||
<mkwar webxml="${web.xml}"> | |||||
<fileset id="test" dir="." includes="web.xml"/> | |||||
<lib refid="test"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<!-- | |||||
This checks that as of Java EE 5, the web.xml attr is optional. | |||||
Here there is a web.xml, in the webinf fileset, rather than a fileset | |||||
--> | |||||
<target name="testWebXmlInWebinf" depends="init"> | |||||
<mkwar> | |||||
<webinf dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<target name="testWebXmlMissingFromUpdate" depends="init"> | |||||
<mkwar webxml="${web.xml}" /> | |||||
<!-- there is no web.xml file, but that is ok, as | |||||
we are updating --> | |||||
<mkwar update="true"> | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<target name="testWebXmlInImplicitUpdate" depends="init"> | |||||
<mkwar webxml="${web.xml}" /> | |||||
<!-- when we are implicitly updating, the web.xml file does not get | |||||
pulled in, but the command still succeeds.--> | |||||
<mkwar webxml="${web.xml}" > | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<target name="NotestWebXmlFilesetInImplicitUpdate" depends="init"> | |||||
<mkwar webxml="${web.xml}" /> | |||||
<!-- when we are implicitly updating, the web.xml file does not get | |||||
pulled in, but the command still succeeds.--> | |||||
<mkwar > | |||||
<webinf dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<target name="testDuplicateWebXml" depends="init"> | |||||
<mkwar webxml="${web.xml}" > | |||||
<webinf dir="." includes="web.xml"/> | |||||
<webinf file="${web.xml}"/> | |||||
<zipfileset file="${web.xml}" prefix="WEB-INF"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
</target> | |||||
<target name="testDifferentDuplicateWebXml" depends="init"> | |||||
<copy file="${web.xml}" todir="${working.dir}" /> | |||||
<mkwar webxml="${web.xml}" > | |||||
<webinf dir="${working.dir}" includes="web.xml"/> | |||||
<webinf file="${web.xml}"/> | |||||
<zipfileset file="${web.xml}" prefix="WEB-INF"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${webxml.generated}" /> | |||||
<au:assertLogContains text="The duplicate entry is"/> | |||||
</target> | |||||
<!-- | |||||
this target does not have a web.xml file. | |||||
Instead it pulls in | |||||
--> | |||||
<target name="testWebXmlOptional" depends="init"> | |||||
<mkwar needxmlfile="false"> | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${working.dir}/WEB-INF/classes/web.xml" /> | |||||
<au:assertFalse> | |||||
<available file="${webxml.generated}" /> | |||||
</au:assertFalse> | |||||
</target> | |||||
<target name="testWebXmlOptionalFailure" depends="init"> | |||||
<au:expectfailure> | |||||
<mkwar > | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
</au:expectfailure> | |||||
</target> | |||||
<target name="testWebXmlOptionalFailure2" depends="init"> | |||||
<au:expectfailure> | |||||
<mkwar needxmlfile="true"> | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
</au:expectfailure> | |||||
</target> | |||||
<target name="testClassesElement" depends="init"> | |||||
<mkwar needxmlfile="false"> | |||||
<classes dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${working.dir}/WEB-INF/classes/web.xml" /> | |||||
</target> | |||||
<target name="testLibElement" depends="init"> | |||||
<mkwar needxmlfile="false"> | |||||
<lib dir="." includes="web.xml"/> | |||||
</mkwar> | |||||
<expandwar/> | |||||
<au:assertFileExists file="${working.dir}/WEB-INF/lib/web.xml" /> | |||||
</target> | |||||
</project> |
@@ -1,5 +1,5 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee" | |||||
version="2.5" metadata-complete="true"> | |||||
</web-app> | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee" | |||||
version="2.5" metadata-complete="true"> | |||||
</web-app> |
@@ -1,32 +1,32 @@ | |||||
<project xmlns:au="antlib:org.apache.ant.antunit" default="all"> | |||||
<target name="test-fileset-with-if"> | |||||
<fileset id="this.xml" dir="."> | |||||
<include if="trigger.include" name="fileset-test.xml"/> | |||||
</fileset> | |||||
<pathconvert refid="this.xml" property="this.xml.prop" pathsep="${line.separator}" setonempty="false"/> | |||||
<au:assertTrue message="fileset this.xml should not contain anything but contains ${this.xml.prop}"> | |||||
<not> | |||||
<isset property="this.xml.prop"/> | |||||
</not> | |||||
</au:assertTrue> | |||||
</target> | |||||
<target name="test-fileset-with-if-property-set"> | |||||
<property name="trigger.include" value="true"/> | |||||
<fileset id="this.xml" dir="."> | |||||
<include if="trigger.include" name="fileset-test.xml"/> | |||||
</fileset> | |||||
<pathconvert refid="this.xml" property="this.xml.prop" pathsep="${line.separator}" setonempty="false"/> | |||||
<au:assertPropertySet name="this.xml.prop" message="fileset should contain one file"/> | |||||
<echo>${this.xml.prop}</echo> | |||||
<au:assertLogContains text="fileset-test.xml"/> | |||||
</target> | |||||
<target name="all"> | |||||
<au:antunit> | |||||
<fileset dir="${basedir}" includes="fileset-test.xml"/> | |||||
<au:plainlistener/> | |||||
</au:antunit> | |||||
</target> | |||||
</project> | |||||
<project xmlns:au="antlib:org.apache.ant.antunit" default="all"> | |||||
<target name="test-fileset-with-if"> | |||||
<fileset id="this.xml" dir="."> | |||||
<include if="trigger.include" name="fileset-test.xml"/> | |||||
</fileset> | |||||
<pathconvert refid="this.xml" property="this.xml.prop" pathsep="${line.separator}" setonempty="false"/> | |||||
<au:assertTrue message="fileset this.xml should not contain anything but contains ${this.xml.prop}"> | |||||
<not> | |||||
<isset property="this.xml.prop"/> | |||||
</not> | |||||
</au:assertTrue> | |||||
</target> | |||||
<target name="test-fileset-with-if-property-set"> | |||||
<property name="trigger.include" value="true"/> | |||||
<fileset id="this.xml" dir="."> | |||||
<include if="trigger.include" name="fileset-test.xml"/> | |||||
</fileset> | |||||
<pathconvert refid="this.xml" property="this.xml.prop" pathsep="${line.separator}" setonempty="false"/> | |||||
<au:assertPropertySet name="this.xml.prop" message="fileset should contain one file"/> | |||||
<echo>${this.xml.prop}</echo> | |||||
<au:assertLogContains text="fileset-test.xml"/> | |||||
</target> | |||||
<target name="all"> | |||||
<au:antunit> | |||||
<fileset dir="${basedir}" includes="fileset-test.xml"/> | |||||
<au:plainlistener/> | |||||
</au:antunit> | |||||
</target> | |||||
</project> |
@@ -1,161 +1,161 @@ | |||||
/* | |||||
* 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.taskdefs.condition.Os; | |||||
import org.apache.tools.ant.util.JavaEnvUtils; | |||||
import org.apache.tools.ant.BuildFileTest; | |||||
/** | |||||
* Tests <bm:manifestclasspath>. | |||||
*/ | |||||
public class ManifestClassPathTest | |||||
extends BuildFileTest { | |||||
public void setUp() { | |||||
configureProject("src/etc/testcases/taskdefs/manifestclasspath.xml"); | |||||
} | |||||
public void testBadDirectory() { | |||||
expectBuildExceptionContaining("test-bad-directory", "bad-jar-dir", | |||||
"Jar's directory not found:"); | |||||
assertPropertyUnset("jar.classpath"); | |||||
} | |||||
public void testBadNoProperty() { | |||||
expectBuildExceptionContaining("test-bad-no-property", "no-property", | |||||
"Missing 'property' attribute!"); | |||||
assertPropertyUnset("jar.classpath"); | |||||
} | |||||
public void testBadPropertyExists() { | |||||
expectBuildExceptionContaining("test-bad-property-exists", | |||||
"property-exits", "Property 'jar.classpath' already set!"); | |||||
assertPropertyEquals("jar.classpath", "exists"); | |||||
} | |||||
public void testBadNoJarfile() { | |||||
expectBuildExceptionContaining("test-bad-no-jarfile", "no-jarfile", | |||||
"Missing 'jarfile' attribute!"); | |||||
assertPropertyUnset("jar.classpath"); | |||||
} | |||||
public void testBadNoClassPath() { | |||||
expectBuildExceptionContaining("test-bad-no-classpath", "no-classpath", | |||||
"Missing nested <classpath>!"); | |||||
assertPropertyUnset("jar.classpath"); | |||||
} | |||||
public void testParentLevel1() { | |||||
executeTarget("test-parent-level1"); | |||||
assertPropertyEquals("jar.classpath", "dsp-core/ " + | |||||
"dsp-pres/ " + | |||||
"dsp-void/ " + | |||||
"../generated/dsp-core/ " + | |||||
"../generated/dsp-pres/ " + | |||||
"../generated/dsp-void/ " + | |||||
"../resources/dsp-core/ " + | |||||
"../resources/dsp-pres/ " + | |||||
"../resources/dsp-void/"); | |||||
} | |||||
public void testParentLevel2() { | |||||
executeTarget("test-parent-level2"); | |||||
assertPropertyEquals("jar.classpath", "../dsp-core/ " + | |||||
"../dsp-pres/ " + | |||||
"../dsp-void/ " + | |||||
"../../generated/dsp-core/ " + | |||||
"../../generated/dsp-pres/ " + | |||||
"../../generated/dsp-void/ " + | |||||
"../../resources/dsp-core/ " + | |||||
"../../resources/dsp-pres/ " + | |||||
"../../resources/dsp-void/"); | |||||
} | |||||
public void testParentLevel2TooDeep() { | |||||
expectBuildExceptionContaining("test-parent-level2-too-deep", "nopath", | |||||
"No suitable relative path from "); | |||||
assertPropertyUnset("jar.classpath"); | |||||
} | |||||
public void testPseudoTahoeRefid() { | |||||
executeTarget("test-pseudo-tahoe-refid"); | |||||
assertPropertyEquals("jar.classpath", "classes/dsp-core/ " + | |||||
"classes/dsp-pres/ " + | |||||
"classes/dsp-void/ " + | |||||
"generated/dsp-core/ " + | |||||
"resources/dsp-core/ " + | |||||
"resources/dsp-pres/"); | |||||
} | |||||
public void testPseudoTahoeNested() { | |||||
executeTarget("test-pseudo-tahoe-nested"); | |||||
assertPropertyEquals("jar.classpath", "classes/dsp-core/ " + | |||||
"classes/dsp-pres/ " + | |||||
"classes/dsp-void/ " + | |||||
"generated/dsp-core/ " + | |||||
"resources/dsp-core/ " + | |||||
"resources/dsp-pres/"); | |||||
} | |||||
public void testParentLevel2WithJars() { | |||||
executeTarget("test-parent-level2-with-jars"); | |||||
assertPropertyEquals("jar.classpath", "../../lib/acme-core.jar " + | |||||
"../../lib/acme-pres.jar " + | |||||
"../dsp-core/ " + | |||||
"../dsp-pres/ " + | |||||
"../dsp-void/ " + | |||||
"../../generated/dsp-core/ " + | |||||
"../../generated/dsp-pres/ " + | |||||
"../../generated/dsp-void/ " + | |||||
"../../resources/dsp-core/ " + | |||||
"../../resources/dsp-pres/ " + | |||||
"../../resources/dsp-void/"); | |||||
} | |||||
public void testInternationalGerman() { | |||||
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) | |||||
{ | |||||
System.out.println("Test with international characters skipped under pre 1.4 jvm."); | |||||
return; | |||||
} | |||||
executeTarget("international-german"); | |||||
expectLogContaining("run-two-jars", "beta alpha"); | |||||
} | |||||
public void testInternationalHebrew() { | |||||
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) { | |||||
System.out.println("Test with international characters skipped under pre 1.4 jvm."); | |||||
return; | |||||
} | |||||
if (!Os.isFamily("windows")) { | |||||
executeTarget("international-hebrew"); | |||||
expectLogContaining("run-two-jars", "beta alpha"); | |||||
} else { | |||||
System.out.println("Test with hebrew path not attempted under Windows"); | |||||
} | |||||
} | |||||
} // END class ManifestClassPathTest | |||||
/* | |||||
* 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.taskdefs.condition.Os; | |||||
import org.apache.tools.ant.util.JavaEnvUtils; | |||||
import org.apache.tools.ant.BuildFileTest; | |||||
/** | |||||
* Tests <bm:manifestclasspath>. | |||||
*/ | |||||
public class ManifestClassPathTest | |||||
extends BuildFileTest { | |||||
public void setUp() { | |||||
configureProject("src/etc/testcases/taskdefs/manifestclasspath.xml"); | |||||
} | |||||
public void testBadDirectory() { | |||||
expectBuildExceptionContaining("test-bad-directory", "bad-jar-dir", | |||||
"Jar's directory not found:"); | |||||
assertPropertyUnset("jar.classpath"); | |||||
} | |||||
public void testBadNoProperty() { | |||||
expectBuildExceptionContaining("test-bad-no-property", "no-property", | |||||
"Missing 'property' attribute!"); | |||||
assertPropertyUnset("jar.classpath"); | |||||
} | |||||
public void testBadPropertyExists() { | |||||
expectBuildExceptionContaining("test-bad-property-exists", | |||||
"property-exits", "Property 'jar.classpath' already set!"); | |||||
assertPropertyEquals("jar.classpath", "exists"); | |||||
} | |||||
public void testBadNoJarfile() { | |||||
expectBuildExceptionContaining("test-bad-no-jarfile", "no-jarfile", | |||||
"Missing 'jarfile' attribute!"); | |||||
assertPropertyUnset("jar.classpath"); | |||||
} | |||||
public void testBadNoClassPath() { | |||||
expectBuildExceptionContaining("test-bad-no-classpath", "no-classpath", | |||||
"Missing nested <classpath>!"); | |||||
assertPropertyUnset("jar.classpath"); | |||||
} | |||||
public void testParentLevel1() { | |||||
executeTarget("test-parent-level1"); | |||||
assertPropertyEquals("jar.classpath", "dsp-core/ " + | |||||
"dsp-pres/ " + | |||||
"dsp-void/ " + | |||||
"../generated/dsp-core/ " + | |||||
"../generated/dsp-pres/ " + | |||||
"../generated/dsp-void/ " + | |||||
"../resources/dsp-core/ " + | |||||
"../resources/dsp-pres/ " + | |||||
"../resources/dsp-void/"); | |||||
} | |||||
public void testParentLevel2() { | |||||
executeTarget("test-parent-level2"); | |||||
assertPropertyEquals("jar.classpath", "../dsp-core/ " + | |||||
"../dsp-pres/ " + | |||||
"../dsp-void/ " + | |||||
"../../generated/dsp-core/ " + | |||||
"../../generated/dsp-pres/ " + | |||||
"../../generated/dsp-void/ " + | |||||
"../../resources/dsp-core/ " + | |||||
"../../resources/dsp-pres/ " + | |||||
"../../resources/dsp-void/"); | |||||
} | |||||
public void testParentLevel2TooDeep() { | |||||
expectBuildExceptionContaining("test-parent-level2-too-deep", "nopath", | |||||
"No suitable relative path from "); | |||||
assertPropertyUnset("jar.classpath"); | |||||
} | |||||
public void testPseudoTahoeRefid() { | |||||
executeTarget("test-pseudo-tahoe-refid"); | |||||
assertPropertyEquals("jar.classpath", "classes/dsp-core/ " + | |||||
"classes/dsp-pres/ " + | |||||
"classes/dsp-void/ " + | |||||
"generated/dsp-core/ " + | |||||
"resources/dsp-core/ " + | |||||
"resources/dsp-pres/"); | |||||
} | |||||
public void testPseudoTahoeNested() { | |||||
executeTarget("test-pseudo-tahoe-nested"); | |||||
assertPropertyEquals("jar.classpath", "classes/dsp-core/ " + | |||||
"classes/dsp-pres/ " + | |||||
"classes/dsp-void/ " + | |||||
"generated/dsp-core/ " + | |||||
"resources/dsp-core/ " + | |||||
"resources/dsp-pres/"); | |||||
} | |||||
public void testParentLevel2WithJars() { | |||||
executeTarget("test-parent-level2-with-jars"); | |||||
assertPropertyEquals("jar.classpath", "../../lib/acme-core.jar " + | |||||
"../../lib/acme-pres.jar " + | |||||
"../dsp-core/ " + | |||||
"../dsp-pres/ " + | |||||
"../dsp-void/ " + | |||||
"../../generated/dsp-core/ " + | |||||
"../../generated/dsp-pres/ " + | |||||
"../../generated/dsp-void/ " + | |||||
"../../resources/dsp-core/ " + | |||||
"../../resources/dsp-pres/ " + | |||||
"../../resources/dsp-void/"); | |||||
} | |||||
public void testInternationalGerman() { | |||||
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) | |||||
{ | |||||
System.out.println("Test with international characters skipped under pre 1.4 jvm."); | |||||
return; | |||||
} | |||||
executeTarget("international-german"); | |||||
expectLogContaining("run-two-jars", "beta alpha"); | |||||
} | |||||
public void testInternationalHebrew() { | |||||
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) { | |||||
System.out.println("Test with international characters skipped under pre 1.4 jvm."); | |||||
return; | |||||
} | |||||
if (!Os.isFamily("windows")) { | |||||
executeTarget("international-hebrew"); | |||||
expectLogContaining("run-two-jars", "beta alpha"); | |||||
} else { | |||||
System.out.println("Test with hebrew path not attempted under Windows"); | |||||
} | |||||
} | |||||
} // END class ManifestClassPathTest | |||||
@@ -211,4 +211,4 @@ public class StyleTest extends BuildFileTest { | |||||
content.indexOf(contains) > -1); | content.indexOf(contains) > -1); | ||||
} | } | ||||
} | |||||
} |
@@ -141,4 +141,4 @@ public class SubAntTest extends BuildFileTest { | |||||
} | } | ||||
} | |||||
} |
@@ -133,4 +133,4 @@ public class SyncTest extends BuildFileTest { | |||||
assertTrue("Didn't expect file " + f, | assertTrue("Didn't expect file " + f, | ||||
!getProject().resolveFile(f).exists()); | !getProject().resolveFile(f).exists()); | ||||
} | } | ||||
} | |||||
} |
@@ -1,43 +1,43 @@ | |||||
/* | |||||
* 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 org.apache.tools.ant.BuildFileTest; | |||||
/** | |||||
* Testcases for the <antversion> condition. | |||||
* | |||||
*/ | |||||
public class AntVersionTest extends BuildFileTest { | |||||
public AntVersionTest(String name) { | |||||
super(name); | |||||
} | |||||
public void setUp() throws Exception { | |||||
configureProject("src/etc/testcases/taskdefs/conditions/antversion.xml"); | |||||
} | |||||
public void testAtLeast() { | |||||
executeTarget("testatleast"); | |||||
} | |||||
public void testExactly() { | |||||
executeTarget("testexactly"); | |||||
} | |||||
} | |||||
/* | |||||
* 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 org.apache.tools.ant.BuildFileTest; | |||||
/** | |||||
* Testcases for the <antversion> condition. | |||||
* | |||||
*/ | |||||
public class AntVersionTest extends BuildFileTest { | |||||
public AntVersionTest(String name) { | |||||
super(name); | |||||
} | |||||
public void setUp() throws Exception { | |||||
configureProject("src/etc/testcases/taskdefs/conditions/antversion.xml"); | |||||
} | |||||
public void testAtLeast() { | |||||
executeTarget("testatleast"); | |||||
} | |||||
public void testExactly() { | |||||
executeTarget("testexactly"); | |||||
} | |||||
} |
@@ -42,4 +42,4 @@ public class JavahTest extends BuildFileTest { | |||||
.exists()); | .exists()); | ||||
} | } | ||||
} | |||||
} |
@@ -63,4 +63,4 @@ public class RpmTest extends TestCase { | |||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -1,49 +1,49 @@ | |||||
/* | |||||
* 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.optional.junit; | |||||
import junit.framework.TestCase; | |||||
import javax.xml.parsers.DocumentBuilder; | |||||
import org.apache.tools.ant.util.JAXPUtils; | |||||
import org.w3c.dom.Document; | |||||
import org.w3c.dom.NodeList; | |||||
import org.w3c.dom.Node; | |||||
import org.xml.sax.SAXException; | |||||
import java.io.InputStream; | |||||
import java.io.IOException; | |||||
public class DOMUtilTest extends TestCase { | |||||
public void testListChildNodes() throws SAXException, IOException { | |||||
DocumentBuilder db = JAXPUtils.getDocumentBuilder(); | |||||
InputStream is = this.getClass().getClassLoader().getResourceAsStream("taskdefs/optional/junit/matches.xml"); | |||||
Document doc = db.parse(is); | |||||
NodeList nl = DOMUtil.listChildNodes(doc.getFirstChild(), new FooNodeFilter(), true); | |||||
assertEquals(nl.getLength(), 3); | |||||
} | |||||
public class FooNodeFilter implements DOMUtil.NodeFilter { | |||||
public boolean accept(Node node) { | |||||
if (node.getNodeName().equals("foo")) { | |||||
return true; | |||||
} | |||||
return false; //To change body of implemented methods use File | Settings | File Templates. | |||||
} | |||||
} | |||||
} | |||||
/* | |||||
* 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.optional.junit; | |||||
import junit.framework.TestCase; | |||||
import javax.xml.parsers.DocumentBuilder; | |||||
import org.apache.tools.ant.util.JAXPUtils; | |||||
import org.w3c.dom.Document; | |||||
import org.w3c.dom.NodeList; | |||||
import org.w3c.dom.Node; | |||||
import org.xml.sax.SAXException; | |||||
import java.io.InputStream; | |||||
import java.io.IOException; | |||||
public class DOMUtilTest extends TestCase { | |||||
public void testListChildNodes() throws SAXException, IOException { | |||||
DocumentBuilder db = JAXPUtils.getDocumentBuilder(); | |||||
InputStream is = this.getClass().getClassLoader().getResourceAsStream("taskdefs/optional/junit/matches.xml"); | |||||
Document doc = db.parse(is); | |||||
NodeList nl = DOMUtil.listChildNodes(doc.getFirstChild(), new FooNodeFilter(), true); | |||||
assertEquals(nl.getLength(), 3); | |||||
} | |||||
public class FooNodeFilter implements DOMUtil.NodeFilter { | |||||
public boolean accept(Node node) { | |||||
if (node.getNodeName().equals("foo")) { | |||||
return true; | |||||
} | |||||
return false; //To change body of implemented methods use File | Settings | File Templates. | |||||
} | |||||
} | |||||
} |
@@ -39,4 +39,4 @@ public class SuiteMethodTest { | |||||
assertTrue(true); | assertTrue(true); | ||||
} | } | ||||
} | } | ||||
} | |||||
} |
@@ -38,4 +38,4 @@ public class JavaResourceTest extends BuildFileTest { | |||||
assertTrue(getProject().getProperty("manifest") | assertTrue(getProject().getProperty("manifest") | ||||
.startsWith("Manifest-Version:")); | .startsWith("Manifest-Version:")); | ||||
} | } | ||||
} | |||||
} |
@@ -41,4 +41,4 @@ public class TarResourceTest extends BuildFileTest { | |||||
assertTrue(FU.contentEquals(project.resolveFile("../../asf-logo.gif"), | assertTrue(FU.contentEquals(project.resolveFile("../../asf-logo.gif"), | ||||
project.resolveFile("testout/asf-logo.gif"))); | project.resolveFile("testout/asf-logo.gif"))); | ||||
} | } | ||||
} | |||||
} |
@@ -34,4 +34,4 @@ public class MockAlgorithm implements Algorithm { | |||||
public String toString() { | public String toString() { | ||||
return "MockAlgorithm@" + hashCode(); | return "MockAlgorithm@" + hashCode(); | ||||
} | } | ||||
} | |||||
} |
@@ -65,4 +65,4 @@ public class MockCache implements Cache { | |||||
private void log(String msg) { | private void log(String msg) { | ||||
if (debug) System.out.println(this+msg); | if (debug) System.out.println(this+msg); | ||||
} | } | ||||
}//class-MockCache | |||||
}//class-MockCache |
@@ -29,4 +29,4 @@ public class MockComparator implements Comparator { | |||||
public String toString() { | public String toString() { | ||||
return "MockComparator"; | return "MockComparator"; | ||||
} | } | ||||
}//class-MockCache | |||||
}//class-MockCache |
@@ -1014,4 +1014,4 @@ public class ModifiedSelectorTest extends BaseSelectorTest { | |||||
}//class-MockProject | }//class-MockProject | ||||
}//class-ModifiedSelectorTest | |||||
}//class-ModifiedSelectorTest |
@@ -1,96 +1,96 @@ | |||||
/* | |||||
* 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.util; | |||||
import java.io.*; | |||||
import junit.framework.TestCase; | |||||
/** | |||||
* Test for ReaderInputStream | |||||
*/ | |||||
public class ReaderInputStreamTest extends TestCase { | |||||
public ReaderInputStreamTest(String s) { | |||||
super(s); | |||||
} | |||||
public void testSimple() throws Exception { | |||||
compareBytes("abc", "utf-8"); | |||||
} | |||||
public void testSimple16() throws Exception { | |||||
compareBytes("a", "utf-16"); | |||||
} | |||||
public void testSimpleAbc16() throws Exception { | |||||
// THIS WILL FAIL. | |||||
//compareBytes("abc", "utf-16"); | |||||
byte[] bytes = new byte[40]; | |||||
int pos = 0; | |||||
ReaderInputStream r = new ReaderInputStream( | |||||
new StringReader("abc"), "utf-16"); | |||||
for (int i = 0; true; ++i) { | |||||
int res = r.read(); | |||||
if (res == -1) { | |||||
break; | |||||
} | |||||
bytes[pos++] = (byte) res; | |||||
} | |||||
bytes = "abc".getBytes("utf-16"); | |||||
// String n = new String(bytes, 0, pos, "utf-16"); | |||||
String n = new String(bytes, 0, bytes.length, "utf-16"); | |||||
System.out.println(n); | |||||
} | |||||
public void testReadZero() throws Exception { | |||||
ReaderInputStream r = new ReaderInputStream( | |||||
new StringReader("abc")); | |||||
byte[] bytes = new byte[30]; | |||||
// First read in zero bytes | |||||
r.read(bytes, 0, 0); | |||||
// Now read in the string | |||||
int readin = r.read(bytes, 0, 10); | |||||
// Make sure that the counts are the same | |||||
assertEquals("abc".getBytes().length, readin); | |||||
} | |||||
public void testPreample() throws Exception { | |||||
byte[] bytes = "".getBytes("utf-16"); | |||||
System.out.println("Preample len is " + bytes.length); | |||||
} | |||||
private void compareBytes(String s, String encoding) throws Exception { | |||||
byte[] expected = s.getBytes(encoding); | |||||
ReaderInputStream r = new ReaderInputStream( | |||||
new StringReader(s), encoding); | |||||
for (int i = 0; i < expected.length; ++i) { | |||||
int expect = expected[i] & 0xFF; | |||||
int read = r.read(); | |||||
if (expect != read) { | |||||
fail("Mismatch in ReaderInputStream at index " + i | |||||
+ " expecting " + expect + " got " + read + " for string " | |||||
+ s + " with encoding " + encoding); | |||||
} | |||||
} | |||||
if (r.read() != -1) { | |||||
fail("Mismatch in ReaderInputStream - EOF not seen for string " | |||||
+ s + " with encoding " + encoding); | |||||
} | |||||
} | |||||
} | |||||
/* | |||||
* 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.util; | |||||
import java.io.*; | |||||
import junit.framework.TestCase; | |||||
/** | |||||
* Test for ReaderInputStream | |||||
*/ | |||||
public class ReaderInputStreamTest extends TestCase { | |||||
public ReaderInputStreamTest(String s) { | |||||
super(s); | |||||
} | |||||
public void testSimple() throws Exception { | |||||
compareBytes("abc", "utf-8"); | |||||
} | |||||
public void testSimple16() throws Exception { | |||||
compareBytes("a", "utf-16"); | |||||
} | |||||
public void testSimpleAbc16() throws Exception { | |||||
// THIS WILL FAIL. | |||||
//compareBytes("abc", "utf-16"); | |||||
byte[] bytes = new byte[40]; | |||||
int pos = 0; | |||||
ReaderInputStream r = new ReaderInputStream( | |||||
new StringReader("abc"), "utf-16"); | |||||
for (int i = 0; true; ++i) { | |||||
int res = r.read(); | |||||
if (res == -1) { | |||||
break; | |||||
} | |||||
bytes[pos++] = (byte) res; | |||||
} | |||||
bytes = "abc".getBytes("utf-16"); | |||||
// String n = new String(bytes, 0, pos, "utf-16"); | |||||
String n = new String(bytes, 0, bytes.length, "utf-16"); | |||||
System.out.println(n); | |||||
} | |||||
public void testReadZero() throws Exception { | |||||
ReaderInputStream r = new ReaderInputStream( | |||||
new StringReader("abc")); | |||||
byte[] bytes = new byte[30]; | |||||
// First read in zero bytes | |||||
r.read(bytes, 0, 0); | |||||
// Now read in the string | |||||
int readin = r.read(bytes, 0, 10); | |||||
// Make sure that the counts are the same | |||||
assertEquals("abc".getBytes().length, readin); | |||||
} | |||||
public void testPreample() throws Exception { | |||||
byte[] bytes = "".getBytes("utf-16"); | |||||
System.out.println("Preample len is " + bytes.length); | |||||
} | |||||
private void compareBytes(String s, String encoding) throws Exception { | |||||
byte[] expected = s.getBytes(encoding); | |||||
ReaderInputStream r = new ReaderInputStream( | |||||
new StringReader(s), encoding); | |||||
for (int i = 0; i < expected.length; ++i) { | |||||
int expect = expected[i] & 0xFF; | |||||
int read = r.read(); | |||||
if (expect != read) { | |||||
fail("Mismatch in ReaderInputStream at index " + i | |||||
+ " expecting " + expect + " got " + read + " for string " | |||||
+ s + " with encoding " + encoding); | |||||
} | |||||
} | |||||
if (r.read() != -1) { | |||||
fail("Mismatch in ReaderInputStream - EOF not seen for string " | |||||
+ s + " with encoding " + encoding); | |||||
} | |||||
} | |||||
} |
@@ -1,10 +1,10 @@ | |||||
<?xml version="1.0"?> | |||||
<antlib> | |||||
<macrodef name="simple"> | |||||
<element name="some-tasks" optional="yes" implicit="yes"/> | |||||
<sequential> | |||||
<some-tasks/> | |||||
</sequential> | |||||
</macrodef> | |||||
</antlib> | |||||
<?xml version="1.0"?> | |||||
<antlib> | |||||
<macrodef name="simple"> | |||||
<element name="some-tasks" optional="yes" implicit="yes"/> | |||||
<sequential> | |||||
<some-tasks/> | |||||
</sequential> | |||||
</macrodef> | |||||
</antlib> | |||||
@@ -1,10 +1,10 @@ | |||||
<?xml version="1.0"?> | |||||
<antlib> | |||||
<macrodef name="simple"> | |||||
<element name="some-tasks" optional="yes" implicit="yes"/> | |||||
<sequential> | |||||
<some-tasks/> | |||||
</sequential> | |||||
</macrodef> | |||||
</antlib> | |||||
<?xml version="1.0"?> | |||||
<antlib> | |||||
<macrodef name="simple"> | |||||
<element name="some-tasks" optional="yes" implicit="yes"/> | |||||
<sequential> | |||||
<some-tasks/> | |||||
</sequential> | |||||
</macrodef> | |||||
</antlib> | |||||