<?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

      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.
-->
<project name="testproject" default="def" basedir=".">

  <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>


</project>
