Java 在编辑某些文件时,如何防止Eclipse自动重建?
我正在使用EclipseLuna开发一个Java应用程序。今天早些时候,我开始研究Ant脚本,以开发一种在软件更改时生成版本号的方法。到目前为止,我对它非常满意,但我似乎还有一个问题,那就是我有一个Ant脚本Java 在编辑某些文件时,如何防止Eclipse自动重建?,java,eclipse,ant,Java,Eclipse,Ant,我正在使用EclipseLuna开发一个Java应用程序。今天早些时候,我开始研究Ant脚本,以开发一种在软件更改时生成版本号的方法。到目前为止,我对它非常满意,但我似乎还有一个问题,那就是我有一个Ant脚本build.xml,每当Eclipse重新编译源代码时,它都会修改属性文件build\u info.properties的内部版本号 但是,我已经将Eclipse设置为自动重建,这意味着对它认为是项目源文件的任何更改都会调用此重新编译过程,因此当build\u info.properties
build.xml
,每当Eclipse重新编译源代码时,它都会修改属性文件build\u info.properties
的内部版本号
但是,我已经将Eclipse设置为自动重建,这意味着对它认为是项目源文件的任何更改都会调用此重新编译过程,因此当build\u info.properties
被修改时,它会导致在反馈循环中重新编译所有内容
我想知道的是,是否有一种方法可以在启用自动重建的同时防止这种情况发生,这样Eclipse就不会在每次build\u info.properties
更改时重新编译所有内容
我已经看过了,但是Robert的答案不适用于我的情况,Javi的答案似乎对我不起作用(我尝试将build\u 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>
编译。。。
我不确定这一点,但在不同的情况下,特定资源的行为应该改变,Eclipse会检查资源是否标记为派生资源。因此,您可以尝试将属性文件标记为派生的(资源的属性,有一个复选框)。@Thomas恐怕这似乎不起作用。