| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- ====================================================================== |
| ====================================================================== --> |
| <project name="project" default="default"> |
| <description> |
| - updates timestamp if the file is dirty (according to git) |
| This hacks around missing support for |
| - gitattributes: https://bugs.eclipse.org/342372 |
| - pre-commit hook: https://bugs.eclipse.org/299315 |
| [Update 2017-05-15: EGit now implements smudge/clean filters: https://bugs.eclipse.org/bugs/show_bug.cgi?id=342372#c101 |
| The Eclipse builder and this part of the script could be replaced by Git-native filters now |
| (if sombody writes a portable filter command that generates the version numbers in the right format)] |
| |
| - installs script if |
| 1. file got modified, and |
| 2. global Ant property of file name exists (with full OS path to file as value) |
| E.g. set property jdtbugzilla.user.js to C:\Users\[user]\AppData\Roaming\Mozilla\Firefox\Profiles\[random].default\gm_scripts\JDT_UI_Bugzilla_Add-On\jdtbugzilla.user.js |
| </description> |
| |
| <!-- ================================= |
| target: default |
| ================================= --> |
| <target name="default" description="install"> |
| <doinstall file="jdtbugzilla.user.js"/> |
| <doinstall file="eclipse_test_results.user.js"/> |
| <doinstall file="eclipse_wiki.user.js"/> |
| <doinstall file="always_show_directory_contents.user.js"/> |
| </target> |
| |
| <target name="dummy_clean"/> |
| |
| <macrodef name="doinstall"> |
| <attribute name="file"/> |
| <sequential> |
| <antcall target="update_time_stamp"> |
| <param name="file" value="@{file}"/> |
| </antcall> |
| <antcall target="undefined"> |
| <param name="file" value="@{file}"/> |
| </antcall> |
| <antcall target="copyfile"> |
| <param name="file" value="@{file}"/> |
| </antcall> |
| </sequential> |
| </macrodef> |
| |
| |
| <target name="undefined" unless="${file}"> |
| <echo>not copying ${file} because global Ant property "${file}" is undefined</echo> |
| </target> |
| |
| <target name="copyfile" if="${file}"> |
| <propertycopy name="filepath" from="${file}"/> |
| <copy file="${file}" tofile="${filepath}" verbose="true"/> |
| <!-- |
| <echo>copy file="${file}" tofile="${filepath}"</echo> |
| --> |
| </target> |
| |
| <target name="update_time_stamp" depends="up_to_date_check" unless="${isUpToDate}"> |
| <tstamp> |
| <format property="DTSTAMP" pattern="yyyyMMdd'T'HHmm" timezone="UTC"/> |
| </tstamp> |
| <replaceregexp file="${file}" match="(// @version\s+\d+\.)\d+T\d+" replace="\1${DTSTAMP}"/> |
| </target> |
| |
| <target name="up_to_date_check"> |
| <exec executable="git" outputproperty="gitstatus" failifexecutionfails="false"> |
| <arg value="status"/> |
| <arg value="-z"/> |
| <arg value="${file}"/> |
| </exec> |
| <condition property="isUpToDate"> |
| <or> |
| <not> |
| <isset property="gitstatus"/> |
| </not> |
| <equals arg1="${gitstatus}" arg2=""/> |
| </or> |
| </condition> |
| </target> |
| |
| <macrodef name="propertycopy"> |
| <attribute name="name"/> |
| <attribute name="from"/> |
| <sequential> |
| <property name="@{name}" value="${@{from}}"/> |
| </sequential> |
| </macrodef> |
| |
| </project> |