Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant - How to set ${ant.project.name} to project folder name?

Tags:

ant

How to set ${ant.project.name} value? I want to set it as: ${ant.project.name}=${basedir}

I don't want to set the project name from build.xml. My idea is - it should take the name of the folder automatically.

Is this possible?

like image 353
Faisal Avatar asked Dec 12 '22 20:12

Faisal


1 Answers

The ANT property ant.project.name is designed to return the string that appears at the top of your build file. It has special meaning and shouldn't really be changed.

The following example demonstrates how you could use an alternative property (This should work on windows as well):

<project name="demo" default="run">

    <basename property="my.project.name" file="${basedir}"/>

    <target name="run">
        <echo message="ant.project.name=${ant.project.name}"/>
        <echo message="my.project.name=${my.project.name}"/>
    </target>

</project>

Has the following output

run:
     [echo] ant.project.name=demo
     [echo] my.project.name=myprojectdirname
like image 67
Mark O'Connor Avatar answered Dec 14 '22 10:12

Mark O'Connor