在编辑某些文件时,如何防止Eclipse自动重建?

时间:2014-10-29 14:56:44

标签: java eclipse ant

我正在使用Eclipse Luna开发Java应用程序。我今天早些时候开始研究Ant脚本,以便开发一种在软件发生变化时为其生成版本号的方法。到目前为止我对它很满意,但我似乎还有一个问题就是我有一个Ant脚本build.xml,它会在Eclipse重新编译源代码时修改属性文件build_info.properties的内部版本号

但是,我已经将Eclipse设置为自动重建,这意味着对它认为是项目的源文件所做的任何更改都会调用此重新编译过程,因此当build_info.properties被修改时,它会导致所有内容被重新编译再次在反馈循环中。

我想知道的是,如果有一种方法可以阻止这种情况发生,同时仍然启用了自动重建,这样每次build_info.properties更改时Eclipse都不会重新编译所有内容?

我看过this similar question,但罗伯特的答案不适用于我的情况,Javi的答案似乎对我不起作用(我尝试将build_info.properties放在自己的源文件夹中并设置文件夹的排除模式为**)。

build.xml的相关部分如下:

<target name="compile" depends="updateRevision">
    <echo>Compiling...</echo>
    <antcall target="build">
    </antcall>
</target>

<target name="updateRevision" if="git.present">
    <exec executable="git" outputproperty="git.hash" failifexecutionfails="true" errorproperty="">
        <arg value="rev-parse" />
        <arg value="HEAD" />
    </exec>
    <propertyfile file="${propertyfile.name}">
        <entry key="build.revision.number" type="string" operation="=" value="${git.hash}" />
    </propertyfile>
</target>

<target name="build" depends="updateRevision">
    <propertyfile file="${propertyfile.name}">
        <entry key="build.build.number" type="int" operation="+" value="1" />
    </propertyfile>
</target>

0 个答案:

没有答案