ant基础和eclipse .project文件生成 [英] ant basedir and eclipse .project file generation

查看:435
本文介绍了ant基础和eclipse .project文件生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ant目标,回显eclipse的项目文件的内容,这里的想法是确保
项目很容易导入到eclipse。项目名称应与
的结帐目录相匹配。我有这个到目前为止

I have an ant target that echo's the content of an eclipse .project file, the idea here is to ensure that the project is easily importable into eclipse. The project name should match the directory in which its checkout. I have this so far

<target name="eclipse" description="creates an eclipse .project file">
    <echo file=".project">
        <![CDATA[<?xml version="1.0" encoding="UTF-8"?>
        <projectDescription>
            <name>${basedir}</name>
            <comment></comment>
            <projects>
            </projects>
            <buildSpec>
                <buildCommand>
                    <name>org.eclipse.jdt.core.javabuilder</name>
                    <arguments>
                    </arguments>
                </buildCommand>
            </buildSpec>
            <natures>
                <nature>org.eclipse.jdt.core.javanature</nature>
            </natures>
        </projectDescription>
        ]]>
    </echo>    
</target>

问题是$ {basedir}评估为完整路径

The problem is the ${basedir} evaluates to a full path

<name>/home/assure/projects/MyProject</name>

但eclipse只需要最终的文件夹名称

but eclipse only needs the final folder name

<name>MyProject</name>

任何关于蚂蚁目标的想法我应该用来剥离这条路径?

Any ideas on the ant target i should use to strip this path?

推荐答案

您可以根据路径basename的最后一个目录定义属性。

(请参阅 Ant basename 任务

You could define a property first, based on the last directory of path "basename".
(see Ant basename Task)

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

允许您在脚本的其余部分重复使用该属性

That allows you to reuse that property in the rest of your script

<projectDescription>
    <name>${project.name}</name>

这篇关于ant基础和eclipse .project文件生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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