blob: 7a1ff17ab94ad8870a450a2ae98a5549fa8dba58 [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 default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../antunit-base.xml" />
<mkdir dir="${output}"/>
<mkdir dir="${input}/a/b"/>
<mkdir dir="${input}/a/c"/>
<echo file="${input}/a/b/outer.xml"><![CDATA[
<project name="outer">
<import file="../c/inner.xml"/>
</project>
]]></echo>
<echo file="${input}/a/c/inner.xml"><![CDATA[
<project name="inner">
<target name="foo">
<echo>In inner</echo>
<echo>ant.file.inner is ${ant.file.inner}</echo>
<echo>type is ${ant.file.type.inner}</echo>
<loadproperties>
<url baseUrl="${ant.file.inner}" relativePath="test.properties"/>
</loadproperties>
<echo>foo is ${foo}</echo>
</target>
</project>]]></echo>
<echo file="${input}/a/c/test.properties"><![CDATA[
foo=bar
]]></echo>
<echo file="${input}/a/b/external-import.xml"><![CDATA[
<project name="external-import">
<import file="${output}/imported.xml"/>
</project>
]]></echo>
<echo file="${output}/imported.xml"><![CDATA[
<project name="imported">
<target name="bar">
<echo>In imported</echo>
</target>
</project>
]]></echo>
<jar destfile="${test.jar}">
<fileset dir="${input}"/>
</jar>
<delete dir="${input}"/>
<import>
<javaresource name="a/b/outer.xml">
<classpath location="${test.jar}"/>
</javaresource>
</import>
<import>
<javaresource name="a/b/outer.xml">
<classpath location="${test.jar}"/>
</javaresource>
</import>
<import>
<javaresource name="a/b/external-import.xml">
<classpath location="${test.jar}"/>
</javaresource>
</import>
<target name="testImportOfNestedFile" depends="foo">
<au:assertLogContains text="In inner"/>
<au:assertLogContains text="type is url"/>
<au:assertLogContains text="foo is bar"/>
</target>
<target name="testImportOfNestedFileWithAbsolutePath" depends="bar"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=50953">
<au:assertLogContains text="In imported"/>
</target>
<target name="tearDown">
<taskdef name="close"
classname="org.apache.tools.ant.taskdefs.CloseResources"/>
<close>
<javaresource name="a/b/outer.xml">
<classpath location="${test.jar}"/>
</javaresource>
</close>
<delete file="${test.jar}" quiet="true" deleteonexit="true"/>
<!-- Calling antunit-base.tearDown sometimes causes ISEs in <import> in Ant-Build-Matrix: -->
<delete dir="${input}"/>
<delete dir="${output}"/>
</target>
</project>