How to find substring in apache ant property value?

Viewed 23

I have multiple files under a directory. All these files have similar names e.g. com.xyz.projname1.xml, com.xyz.projname2.xml, etc.
When I try to get the filename in a for loop, it returns the absolute path of com.xyz.projname1.xml.
I just want to check if the absolute path contains 'projname1'.

<target name="update-proj-version-and-name">
    <for param="file" >
        <path>
            <fileset dir="${project.dir.target}/artifact/" casesensitive="no">
                <include name="*.xml"/>
            </fileset>
        </path>
        <sequential>
            <property name="proj.file.name" value="@{file}"/>
            <echo>proj name - ${proj.file.name}</echo>

            <!-- Here I need to check if ${proj.file.name} contains 'projname1' then invoke one of our macrodef -->
            
        </sequential>
    </for>
</target>

Can you please help?

Thanks, Ranjeet

0 Answers
Related