Insert git-describe, date and time in assembly at compile time in eclipse

I use the external build function in eclipse to call a bash script that will auto-generate the BuildInfo.java class for my project (I looked at stackoverflow here for a way to embed git-describe and date in an eclipse (not ant!), But could not find any- either), my script looks like this:

#!/bin/bash VERSION=$(git describe --tag) DATE=$(date "+%Y-%m-%d") TIME=$(date "+%H:%M") echo "Version $VERSION, built on $DATE $TIME" cat > src/com/bla/bla/BuildInfo.java <<DELIM package com.bla.bla; // Auto-generated, triggered by project build public class BuildInfo { public static String version = new String("$VERSION"); public static String date = new String("$DATE"); public static String time = new String("$TIME"); } DELIM 

I am setting up an external builder to execute each build (even automatic) before the java / android collectors. This scheme really works fine when I make the complete project clean, however when I update another file, although Eclipse is doing my external builder and the BuildInfo class is really being restored, Eclipse still uses the old cached version of the class for the final result, so I see old information, which can sometimes be worse than not having design information at all.

You have an idea, how can I say that Eclipse has generated this file, and it should not cache it at all, but load it from disk after the completion of my external builder and before the java linker? Is there another elegant solution for getting this data in an assembly?

Thanks!

+4
source share
1 answer

In Eclipse, you can specify resources that have changed since running a custom built-in tool.

Go to your built-in tool, select "Edit" on the "Update" tab. Select Update resources after completion, Specific resources ... and add the automatically generated BuildInfo.java.

+4
source

Source: https://habr.com/ru/post/1399950/


All Articles