diff --git a/src/main/org/apache/tools/ant/ExitStatusException.java b/src/main/org/apache/tools/ant/ExitStatusException.java index 4dd79f55d..7e5dad9e1 100644 --- a/src/main/org/apache/tools/ant/ExitStatusException.java +++ b/src/main/org/apache/tools/ant/ExitStatusException.java @@ -64,4 +64,4 @@ public class ExitStatusException extends BuildException { public int getStatus() { return status; } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/filters/StringInputStream.java b/src/main/org/apache/tools/ant/filters/StringInputStream.java index 436a1175b..e150e9651 100644 --- a/src/main/org/apache/tools/ant/filters/StringInputStream.java +++ b/src/main/org/apache/tools/ant/filters/StringInputStream.java @@ -46,4 +46,4 @@ public class StringInputStream extends ReaderInputStream { super(new StringReader(source), encoding); } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/taskdefs/Exit.java b/src/main/org/apache/tools/ant/taskdefs/Exit.java index 9d4a392d2..0fe817b17 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Exit.java +++ b/src/main/org/apache/tools/ant/taskdefs/Exit.java @@ -214,4 +214,4 @@ public class Exit extends Task { return (nestedCondition != null); } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java b/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java index be5e8cb4d..21b5a5906 100644 --- a/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java +++ b/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java @@ -230,4 +230,4 @@ public class LoadProperties extends Task { throw new BuildException("expected a java resource as source"); } } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/taskdefs/ResourceCount.java b/src/main/org/apache/tools/ant/taskdefs/ResourceCount.java index d3f4ba8dc..6592c0549 100755 --- a/src/main/org/apache/tools/ant/taskdefs/ResourceCount.java +++ b/src/main/org/apache/tools/ant/taskdefs/ResourceCount.java @@ -121,4 +121,4 @@ public class ResourceCount extends Task implements Condition { property = p; } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/taskdefs/Transform.java b/src/main/org/apache/tools/ant/taskdefs/Transform.java index 618f15aa2..5a0140230 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Transform.java +++ b/src/main/org/apache/tools/ant/taskdefs/Transform.java @@ -27,4 +27,4 @@ package org.apache.tools.ant.taskdefs; * @ant.task ignore="true" */ public class Transform extends ExecuteOn { -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison3.java b/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison3.java index 7622c3893..963093ff3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison3.java +++ b/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison3.java @@ -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; +} diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java b/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java index c3f8fe63e..ddc73d749 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/HasMethod.java @@ -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 boolean 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 boolean 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; + } + +} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java index 4f31d647b..90ba8ac85 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java @@ -311,4 +311,4 @@ public final class JarLibManifestTask extends Task { return results; } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java index 805b2db5c..ea5ef230f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java @@ -212,4 +212,4 @@ public class JJDoc extends Task { return (getProject().getBaseDir() + "/" + optionalOutputFile) .replace('\\', '/'); } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java index 626187135..121c39813 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java @@ -402,4 +402,4 @@ public class JJTree extends Task { return root; } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java index 48b6a6547..cee68e384 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java @@ -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"; +} diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java index 38bd822d6..a5b9ad61b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java @@ -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: - * http://issues.apache.org/bugzilla/show_bug.cgi?id=38732 - */ -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: + * http://issues.apache.org/bugzilla/show_bug.cgi?id=38732 + */ +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; + } + +} diff --git a/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java b/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java index 72ecdb618..a4bdbda65 100644 --- a/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java +++ b/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java @@ -104,4 +104,4 @@ public class FileResourceIterator implements Iterator { return new FileResource(basedir, files[pos++]); } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ChecksumAlgorithm.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ChecksumAlgorithm.java index 376b1af7a..10aee508e 100644 --- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ChecksumAlgorithm.java +++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/ChecksumAlgorithm.java @@ -146,4 +146,4 @@ public class ChecksumAlgorithm implements Algorithm { buf.append(">"); return buf.toString(); } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java index a233ffcc0..f309878c3 100644 --- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java +++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java @@ -199,4 +199,4 @@ public class DigestAlgorithm implements Algorithm { buf.append(">"); return buf.toString(); } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java index 858edce10..cbfcd9772 100644 --- a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java +++ b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/PropertiesfileCache.java @@ -233,4 +233,4 @@ public class PropertiesfileCache implements Cache { buf.append(">"); return buf.toString(); } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java b/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java index 809ba63a4..b9ed966ce 100644 --- a/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java +++ b/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java @@ -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 self - */ - 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 self - */ - 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 self + */ + 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 self + */ + 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); + } + +} diff --git a/src/main/org/apache/tools/ant/util/ScriptRunnerCreator.java b/src/main/org/apache/tools/ant/util/ScriptRunnerCreator.java index 85ca11466..673e42069 100644 --- a/src/main/org/apache/tools/ant/util/ScriptRunnerCreator.java +++ b/src/main/org/apache/tools/ant/util/ScriptRunnerCreator.java @@ -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; + } +} diff --git a/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java b/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java index 1c61456a4..b481513c5 100644 --- a/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java +++ b/src/main/org/apache/tools/ant/util/ScriptRunnerHelper.java @@ -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()); + } +} diff --git a/src/main/org/apache/tools/ant/util/facade/ImplementationSpecificArgument.java b/src/main/org/apache/tools/ant/util/facade/ImplementationSpecificArgument.java index ed1711f77..2b2b838ca 100644 --- a/src/main/org/apache/tools/ant/util/facade/ImplementationSpecificArgument.java +++ b/src/main/org/apache/tools/ant/util/facade/ImplementationSpecificArgument.java @@ -58,4 +58,4 @@ public class ImplementationSpecificArgument extends Commandline.Argument { return new String[0]; } } -} \ No newline at end of file +} diff --git a/src/tests/antunit/taskdefs/delete-test.xml b/src/tests/antunit/taskdefs/delete-test.xml index a93b29942..10f1b6f3a 100644 --- a/src/tests/antunit/taskdefs/delete-test.xml +++ b/src/tests/antunit/taskdefs/delete-test.xml @@ -1,64 +1,64 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/tests/antunit/taskdefs/war-test.xml b/src/tests/antunit/taskdefs/war-test.xml index 8de6cdd2e..0edac6e8b 100644 --- a/src/tests/antunit/taskdefs/war-test.xml +++ b/src/tests/antunit/taskdefs/war-test.xml @@ -1,161 +1,161 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/tests/antunit/taskdefs/web.xml b/src/tests/antunit/taskdefs/web.xml index 6ed2715e8..32ce65af5 100644 --- a/src/tests/antunit/taskdefs/web.xml +++ b/src/tests/antunit/taskdefs/web.xml @@ -1,5 +1,5 @@ - - - - + + + + diff --git a/src/tests/antunit/types/fileset-test.xml b/src/tests/antunit/types/fileset-test.xml index f7d265123..cf909cddc 100644 --- a/src/tests/antunit/types/fileset-test.xml +++ b/src/tests/antunit/types/fileset-test.xml @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - ${this.xml.prop} - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + ${this.xml.prop} + + + + + + + + + + diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java index 8d43c7f9b..b7b0c3048 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java @@ -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 !"); - 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 !"); + 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 + diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java index 092acab82..2c1778e69 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java @@ -211,4 +211,4 @@ public class StyleTest extends BuildFileTest { content.indexOf(contains) > -1); } -} \ No newline at end of file +} diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java index b66f9a00a..ede8b0e5b 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java @@ -141,4 +141,4 @@ public class SubAntTest extends BuildFileTest { } -} \ No newline at end of file +} diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java index c0bb04f55..62302d33b 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java @@ -133,4 +133,4 @@ public class SyncTest extends BuildFileTest { assertTrue("Didn't expect file " + f, !getProject().resolveFile(f).exists()); } -} \ No newline at end of file +} diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/AntVersionTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/AntVersionTest.java index e0cdbdd44..a2c5e440a 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/AntVersionTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/AntVersionTest.java @@ -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"); + } +} diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java index 2068647d2..ede33ece8 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java @@ -42,4 +42,4 @@ public class JavahTest extends BuildFileTest { .exists()); } -} \ No newline at end of file +} diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RpmTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RpmTest.java index aca68d2eb..17cf95322 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RpmTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RpmTest.java @@ -63,4 +63,4 @@ public class RpmTest extends TestCase { } } -} \ No newline at end of file +} diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java index 3fc971a10..8adde6a49 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java @@ -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. + } + } +} diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/SuiteMethodTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/SuiteMethodTest.java index 5f8fd917d..14a09661a 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/SuiteMethodTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/SuiteMethodTest.java @@ -39,4 +39,4 @@ public class SuiteMethodTest { assertTrue(true); } } -} \ No newline at end of file +} diff --git a/src/tests/junit/org/apache/tools/ant/types/resources/JavaResourceTest.java b/src/tests/junit/org/apache/tools/ant/types/resources/JavaResourceTest.java index 77a16be81..697fee63d 100755 --- a/src/tests/junit/org/apache/tools/ant/types/resources/JavaResourceTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/resources/JavaResourceTest.java @@ -38,4 +38,4 @@ public class JavaResourceTest extends BuildFileTest { assertTrue(getProject().getProperty("manifest") .startsWith("Manifest-Version:")); } -} \ No newline at end of file +} diff --git a/src/tests/junit/org/apache/tools/ant/types/resources/TarResourceTest.java b/src/tests/junit/org/apache/tools/ant/types/resources/TarResourceTest.java index a247bf604..c2157dc04 100755 --- a/src/tests/junit/org/apache/tools/ant/types/resources/TarResourceTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/resources/TarResourceTest.java @@ -41,4 +41,4 @@ public class TarResourceTest extends BuildFileTest { assertTrue(FU.contentEquals(project.resolveFile("../../asf-logo.gif"), project.resolveFile("testout/asf-logo.gif"))); } -} \ No newline at end of file +} diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/MockAlgorithm.java b/src/tests/junit/org/apache/tools/ant/types/selectors/MockAlgorithm.java index 12c9f0828..458c83fe8 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/MockAlgorithm.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/MockAlgorithm.java @@ -34,4 +34,4 @@ public class MockAlgorithm implements Algorithm { public String toString() { return "MockAlgorithm@" + hashCode(); } -} \ No newline at end of file +} diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/MockCache.java b/src/tests/junit/org/apache/tools/ant/types/selectors/MockCache.java index e60def23d..bcea69e52 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/MockCache.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/MockCache.java @@ -65,4 +65,4 @@ public class MockCache implements Cache { private void log(String msg) { if (debug) System.out.println(this+msg); } -}//class-MockCache \ No newline at end of file +}//class-MockCache diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/MockComparator.java b/src/tests/junit/org/apache/tools/ant/types/selectors/MockComparator.java index e77ec854f..a7c155396 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/MockComparator.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/MockComparator.java @@ -29,4 +29,4 @@ public class MockComparator implements Comparator { public String toString() { return "MockComparator"; } -}//class-MockCache \ No newline at end of file +}//class-MockCache diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java index adfa7ea8c..b1ebf05ff 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java @@ -1014,4 +1014,4 @@ public class ModifiedSelectorTest extends BaseSelectorTest { }//class-MockProject -}//class-ModifiedSelectorTest \ No newline at end of file +}//class-ModifiedSelectorTest diff --git a/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java b/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java index a7648cbde..5e421cedb 100644 --- a/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java @@ -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); + } + } +} diff --git a/src/tests/junit/org/example/tasks/antlib.xml b/src/tests/junit/org/example/tasks/antlib.xml index 593ed604c..f951d6f73 100644 --- a/src/tests/junit/org/example/tasks/antlib.xml +++ b/src/tests/junit/org/example/tasks/antlib.xml @@ -1,10 +1,10 @@ - - - - - - - - - - \ No newline at end of file + + + + + + + + + + diff --git a/src/tests/junit/org/example/tasks/antlib2.xml b/src/tests/junit/org/example/tasks/antlib2.xml index 593ed604c..f951d6f73 100644 --- a/src/tests/junit/org/example/tasks/antlib2.xml +++ b/src/tests/junit/org/example/tasks/antlib2.xml @@ -1,10 +1,10 @@ - - - - - - - - - - \ No newline at end of file + + + + + + + + + +