问题
I'm developing a Java application using Eclipse Luna. I began looking into Ant scripts earlier today to develop a way of producing version numbers for the software as it changes. I'm pretty happy with it so far but the one remaining issue I seem to have is that I have an Ant script build.xml
which modifies the build number of a property file build_info.properties
whenever Eclipse recompiles the source code.
However, I've set Eclipse to rebuild automatically which means that any changes made to what it considers as the project's source files invokes this recompilation process, and so when build_info.properties
is modified, it causes everything to be recompiled again in a feedback loop.
What I'm wondering is if there's a way I can prevent this from happening while still having auto-rebuild enabled such that Eclipse won't recompile everything every time that build_info.properties
changes?
I've looked at this similar question but Robert's answer is not applicable to my situation and Javi's answer doesn't appear to work for me (I tried putting build_info.properties
in its own source folder and setting the folder's exclusion pattern to **
).
The relevant parts of build.xml
are given below:
<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>
来源:https://stackoverflow.com/questions/26633627/how-can-i-prevent-eclipse-from-auto-rebuilding-when-i-edit-certain-files