blob: 37829c56b772999ed25ef60667d909aea62ae8ee [file] [log] [blame]
<?xml version="1.0"?>
<!--
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
https://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.
-->
<project name="testproject" default="def" basedir=".">
<import file="../../../buildfiletest-base.xml"/>
<target name="def">
<fail>This build-file is intended to be run from the test cases</fail>
</target>
<target name="simple">
<scriptdef name="scripttest" language="javascript">
<attribute name="attr1"/>
<element name="fileset" type="fileset"/>
<![CDATA[
project.log("Attribute attr1 = " + attributes.get("attr1"));
project.log("Fileset basedir = "
+ elements.get("fileset").get(0).getDir(project));
]]>
</scriptdef>
<fileset id="testfileset" dir="."/>
<scripttest attr1="test">
<fileset refid="testfileset"/>
</scripttest>
</target>
<target name="nolang">
<scriptdef name="nolang">
<![CDATA[
java.lang.System.out.println("Hello");
]]>
</scriptdef>
</target>
<target name="noname">
<scriptdef language="javascript">
<![CDATA[
java.lang.System.out.println("Hello");
]]>
</scriptdef>
</target>
<target name="nestedbyclassname">
<scriptdef name="scripttest" language="javascript">
<attribute name="attr1"/>
<element name="fileset" classname="org.apache.tools.ant.types.FileSet"/>
<![CDATA[
project.log("Attribute attr1 = " + attributes.get("attr1"));
project.log("Fileset basedir = "
+ elements.get("fileset").get(0).getDir(project));
]]>
</scriptdef>
<fileset id="testfileset" dir="."/>
<scripttest attr1="test">
<fileset refid="testfileset"/>
</scripttest>
</target>
<target name="noelement">
<scriptdef name="scripttest" language="javascript">
<attribute name="attr1"/>
<element name="fileset" type="fileset"/>
<![CDATA[
java.lang.System.out.println("Attribute attr1 = " + attributes.get("attr1"));
]]>
</scriptdef>
<scripttest attr1="test">
</scripttest>
</target>
<target name="exception">
<scriptdef name="scripttest" language="javascript">
<attribute name="attr1"/>
<element name="fileset" classname="org.apache.tools.ant.types.FileSet"/>
<![CDATA[
java.lang.System.out.println("Attribute attr1 = " + attributes.get("attr1"));
java.lang.System.out.println("Fileset basedir = "
+ elements.get("fileset").get(0).getDir(project));
]]>
</scriptdef>
<scripttest attr1="test">
</scripttest>
</target>
<target name="doubledef">
<scriptdef name="task1" language="javascript">
<![CDATA[
project.log("Task1");
]]>
</scriptdef>
<scriptdef name="task2" language="javascript">
<![CDATA[
project.log("Task2");
]]>
</scriptdef>
<task1/>
<task2/>
</target>
<target name="doubleAttributeDef">
<scriptdef name="scripttest" language="javascript">
<attribute name="attr1"/>
<attribute name="attr1"/>
</scriptdef>
</target>
<target name="property">
<scriptdef name="scripttest" language="javascript">
<attribute name="attr1"/>
<![CDATA[
project.log("Attribute value = " + attributes.get("attr1"));
]]>
</scriptdef>
<property name="testproperty" value="test"/>
<scripttest attr1="${testproperty}">
</scripttest>
</target>
<target name="useBeanshell">
<script language="beanshell"><![CDATA[
self.log("I'm here", org.apache.tools.ant.Project.MSG_INFO);
]]></script>
</target>
<target name="useSrcAndEncoding">
<mkdir dir="${output}"/>
<property name="useSrcAndEncoding.encoding" value="UTF-8"/>
<property name="useSrcAndEncoding.reader.encoding" value="${useSrcAndEncoding.encoding}"
description="Set a different encoding to raise a failure (ex. ISO-8859-1)"/>
<property name="useSrcAndEncoding.file" location="${output}/script.useSrcAndEncoding.js"/>
<property name="useSrcAndEncoding.expectedProp" value="eacute [&#233;]"/>
<echo file="${useSrcAndEncoding.file}" encoding="${useSrcAndEncoding.encoding}"
message="project.setNewProperty('useSrcAndEncoding.prop', '${useSrcAndEncoding.expectedProp}');"/>
<scriptdef name="useSrcAndEncoding" language="javascript" src="${useSrcAndEncoding.file}" encoding="${useSrcAndEncoding.reader.encoding}"/>
<useSrcAndEncoding/>
<condition property="useSrcAndEncoding.testOK" >
<equals arg1="${useSrcAndEncoding.expectedProp}" arg2="${useSrcAndEncoding.prop}"/>
</condition>
<fail message="expected &lt;${useSrcAndEncoding.expectedProp}&gt; but was &lt;${useSrcAndEncoding.prop}&gt;" unless="useSrcAndEncoding.testOK"/>
</target>
<target name="useCompiled">
<!-- Test with 'javax' manager, 'bsf' manager already compiles the script. -->
<scriptdef manager="javax" name="heavyscript" language="javascript" src="heavy-script.js" encoding="UTF-8" compiled="true"/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
<heavyscript/>
</target>
<target name="useNotCompiled">
<scriptdef manager="javax" name="heavyscriptNotCompiled" language="javascript" src="heavy-script.js" encoding="UTF-8" compiled="false"/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
<heavyscriptNotCompiled/>
</target>
</project>