蚂蚁BASEDIR和eclipse项目文件生成

蚂蚁BASEDIR和eclipse项目文件生成

本文介绍了蚂蚁BASEDIR和eclipse项目文件生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有Echo的日食项目文件的内容Ant目标,这里的想法是,以确保
该项目是轻松导入蚀。项目名称应与该目录中
其结账。我有这个至今

I have an ant target that echo's the content of an eclipse .project file, the idea here is to ensurethat the project is easily importable into eclipse. The project name should match the directory in whichits 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>

在Ant目标的任何想法,我应该使用剥离这条道路?

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

推荐答案

您可以先定义一个属性,基于路径的基名最后的目录。结果
(请参见蚂蚁基本名任务

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>

这篇关于蚂蚁BASEDIR和eclipse项目文件生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 13:31