Search code examples
antant-contrib

Copy is not working in Ant Script


I have one variable defined in my properties file:

require.extensions = html, htm

and I am using that variable as below:

<for list="${require.extensions}" param="letter">
                <sequential>
                    <copy todir="${dir.publish.html}">                                          
                        <fileset dir="${project.dir}">
                            <include name="**/*.@{letter}"/>
                        </fileset>
                    </copy>
                </sequential>
            </for>

I want to copy all the file with extensions html and htm to ${project.dir} dir to ${dir.publish.html} dir

But currently it only copies html files and not htm files. Why So? As i am getting html and htm values in @{letter} out side but i can't use echo inside so i am not able to check the value of @{letter}. Is there any problem in my code ?


<copy todir="${dir.publish.html}">
    <fileset dir="${project.dir}">
        <include name="**/*.html"/>                         
            <include name="**/*.htm"/>
    </fileset>
</copy>

If i do this it will work. But want to make .html | .htm should be dynamically get inserted.


Solution

  • Given the documentation of the for task, the default delimiter usedto split the string into tokens is ,. This means that your list will contain two tokens: html and <space>htm. So your task copies all the files which end with .<space>htm.