开发者

Can Eclipse not hard-code ECLIPSE_HOME when exporting build.xml?

I have an Eclipse project that I'm attempting to set up to build both with Eclipse and externally with Ant. It seems like a good way to do this is to have Eclipse generate a build.xml file that I can then use with ant.

I'd like to set it up so the build.xml can be regenerated from Eclipse whenever the need arises, which means no hand-editing the build.xml file. But Eclipse writes one entry in there that has a hard-coded path to a directory on my computer, which makes it unsuitable for checking in to a source repository.

Specifically it's this entry that's the trouble:

<property name="开发者_如何学JAVAECLIPSE_HOME" value="D:/Eclipse/Eclipse Galileo (3.5) SR1"/>

Is there some way to have Eclipse not output this line, or to make it a relative reference or something that makes sense to check in?


Alternatively, due to Ant's immutable properties, you can override the value of ECLIPSE_HOME on the command line:

ant -DECLIPSE_HOME=c:/Eclipse/MyEclipseVersion build


Usually when you are checking build files into a repository you keep the variables that may be unique for each user into a separate file, ex: build.properties, that each user can modify and not commit it.

You import that file by using the following syntax:

<property file="./build.properties" /> 


You can better access environment variables from ant:

<property environment="env"/>

<target name="deploy-dev" depends="war-dev">
<copy file="${deploy}/" tofile="${env.TOMCAT_HOME}/webapps/" />
</target>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜