You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ko...@excite.co.jp on 2004/01/13 07:16:11 UTC

Ant 1.6.0: for defining data type?

Hello,

Can I use <presetdef> task to pre-set data type like <fileset>?
It seems that it can be used for defining "my <fileset>", but
it cannot be used for using "my <fileset>". What I tried to do
is:

<?xml version="1.0"?>
<project>
    <presetdef name="java.fileset">
        <fileset>
	    <include name="**/*.java"/>
	    <include name="**/*.class"/>
	    <include name="**/*.jar"/>
	</fileset>
    </presetdef>

    <property name="java.dir" value="c:/somewhere"/>

    <target name="copy">
        <copy todir="to">
	    <java.fileset dir="${java.dir}"/>
        </copy>
    </target>

</project>

With above build.xml, I run ant with -debug option:

C:\> ant -debug
	:
 +Datatype java.fileset org.apache.tools.ant.types.FileSet
	:
BUILD SUCCESSFUL
Total time: 0 seconds

"java.fileset" seems to be defined correctly. But I run ant with
"copy" target option to actually use the new data type, I got
the following error:

C:\> ant copy
	:
BUILD FAILED
C:\build.xml:14: The <copy> type doesn't support the nested "java.fileset"
element.

Thank you,

Koji

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Ant 1.6.0: for defining data type?

Posted by Peter Reilly <pe...@corvil.com>.
Stefan Bodewig wrote:

>On Tue, 13 Jan 2004, koji sekiguchi <ko...@excite.co.jp>
>wrote:
>
>  
>
>>Can I use <presetdef> task to pre-set data type like <fileset>?
>>    
>>
>
>Yes and no.  You can define them, but not use the new types as nested
>elements that don't support type-polymorphism for filesets.  AFAIK
>there is no single task that would support it for now.
>
>  
>
>>What I tried to do is:
>>    <presetdef name="java.fileset">
>>        <fileset>
>>	    <include name="**/*.java"/>
>>	    <include name="**/*.class"/>
>>	    <include name="**/*.jar"/>
>>	</fileset>
>>    </presetdef>
>>
>>        <copy todir="to">
>>	    <java.fileset dir="${java.dir}"/>
>>        </copy>
>>    
>>
>
>Try
>
>  <java.fileset dir="${java.dir}" id="java.dir-fileset"/>
>
>  <copy todir="to">
>    <fileset refid="java.dir-fileset"/>
>  </copy>
>
>instead.  Not as compact, but should work.
>  
>
This does work.
However the following should also work:

    <presetdef name="java.fileset">
        <fileset>
	    <include name="**/*.java"/>
	    <include name="**/*.class"/>
	    <include name="**/*.jar"/>
	</fileset>
    </presetdef>

        <copy todir="to">
	    <fileset ant-type="java.fileset" dir="${java.dir}"/>
        </copy>

But does currently not due to a bug...


Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Ant 1.6.0: for defining data type?

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 13 Jan 2004, koji sekiguchi <ko...@excite.co.jp>
wrote:

> Can I use <presetdef> task to pre-set data type like <fileset>?

Yes and no.  You can define them, but not use the new types as nested
elements that don't support type-polymorphism for filesets.  AFAIK
there is no single task that would support it for now.

> What I tried to do is:
>     <presetdef name="java.fileset">
>         <fileset>
> 	    <include name="**/*.java"/>
> 	    <include name="**/*.class"/>
> 	    <include name="**/*.jar"/>
> 	</fileset>
>     </presetdef>
> 
>         <copy todir="to">
> 	    <java.fileset dir="${java.dir}"/>
>         </copy>

Try

  <java.fileset dir="${java.dir}" id="java.dir-fileset"/>

  <copy todir="to">
    <fileset refid="java.dir-fileset"/>
  </copy>

instead.  Not as compact, but should work.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org