Ant - 如何将 ${ant.project.name} 设置为项目文件夹名称? [英] Ant - How to set ${ant.project.name} to project folder name?

查看:26
本文介绍了Ant - 如何将 ${ant.project.name} 设置为项目文件夹名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置 ${ant.project.name} 值?我想将其设置为:${ant.project.name}=${basedir}

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

我不想从 build.xml 设置项目名称.我的想法是 - 它应该自动采用文件夹的名称.

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

这可能吗?

推荐答案

ANT 属性 ant.project.name 旨在返回出现在构建文件顶部的字符串.它有特殊的意义,不应该真正改变.

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.

以下示例演示了如何使用替代属性(这也适用于 Windows):

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>

有以下输出

run:
     [echo] ant.project.name=demo
     [echo] my.project.name=myprojectdirname

这篇关于Ant - 如何将 ${ant.project.name} 设置为项目文件夹名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆