Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build nuisance: RevisionAccessor.java is generated by build. Unclear if it needs to be committed. #309

Open
orionlee opened this issue Dec 28, 2022 · 2 comments
Labels
build Build related files or issues

Comments

@orionlee
Copy link
Collaborator

orionlee commented Dec 28, 2022

Build process automatically (re-)generates src/org/aavso/tools/vstar/ui/resources/RevisionAccessor.java, containing revision information.

RevisionAccessor.java is thus modified and appears as a modified file that needs to be committed. It is unclear if / when it should be committed.

In principle, since the fie is generated by build (ant build [*]), it should not need to be in the git repo to begin with. However, some workflows, e.g., eclipse build, do not generate it (because they are not ant driven). and will breakdown if we simply remove it from git repo (and add it to .gitignore list).

[*] It's in compile_src target, before the actual javac happens

VStar/build.xml

Lines 76 to 91 in 0115ad7

<target name="compile_src" depends="init,antlr4" description="Compile the source">
<!-- Update git revision -->
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="rev-parse" />
<arg value="--short" />
<arg value="HEAD" />
</exec>
<condition property="git_revision" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater" />
</and>
</condition>
<copy file="${ui_resources}/RevisionAccessor.java.template" tofile="${ui_resources}/RevisionAccessor.java" overwrite="true" />
<replace file="${ui_resources}/RevisionAccessor.java" token="@revision@" value="${git_revision}" />
<replace file="${ui_resources}/RevisionAccessor.java" token="@build_time@" value="${BUILD_TIME}" />

@orionlee
Copy link
Collaborator Author

One workaround to the problem is to

  1. generate and store the revision information in a resource file to be bundled to the jar
  2. modify RevisionAccessor.java to read the values from the resource file
  3. Further RevisionAccessor.java so that if the resource file is missing (for eclipse build case), it does not throw exception, and provide some dummy placeholder value instead.

@dbenn dbenn added the build Build related files or issues label Dec 29, 2022
@dbenn
Copy link
Collaborator

dbenn commented Dec 29, 2022

This seems like a good solution @orionlee

@dbenn dbenn changed the title Build nuisance: RevisionAccessor.java is generated by build. Unclear it it needs to be committed Build nuisance: RevisionAccessor.java is generated by build. Unclear if it needs to be committed. Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build related files or issues
Projects
Development

No branches or pull requests

2 participants