source: branches/4.2/ant/common.xml @ 6584

Revision 6584, 3.5 KB checked in by curtis, 10 years ago (diff)

Backport recent bugfixes to 4.2 branch.

Line 
1<!--
2common.xml
3
4Ant build file for logic common to every component.
5All component build files inherit from this build file.
6Download Apache Ant from http://ant.apache.org/.
7Type "ant -p" for a list of targets.
8-->
9
10<project>
11  <import file="${root.dir}/ant/global.xml"/>
12  <property file="${root.dir}/ant/common.properties"/>
13
14  <!-- Main build targets -->
15
16  <target name="clean" description="remove all build files except artifacts">
17    <delete dir="${build.dir}"/>
18  </target>
19
20  <!-- Internal build targets -->
21
22  <target name="init-title">
23    <echo>----------=========== ${component.name} ===========----------</echo>
24  </target>
25
26  <target name="init-timestamp">
27    <tstamp>
28      <format property="DATE" pattern="d MMMMM yyyy"/>
29      <format property="YEAR" pattern="yyyy"/>
30    </tstamp>
31  </target>
32
33  <target name="init-version">
34    <!-- check for SVN versioning information -->
35    <property name="svn.path" value="${basedir}/.svn/entries"/>
36    <available file="${svn.path}" property="svn.present"/>
37    <if>
38      <isset property="svn.present"/>
39      <then>
40        <loadfile property="svn.entries" srcFile="${svn.path}"/>
41        <propertyregex property="svn.revision" input="${svn.entries}"
42          regexp="([^\n]*\n){3}([^\n]*)" select="\2"/>
43        <propertyregex property="svn.url" input="${svn.entries}"
44          regexp="([^\n]*\n){4}([^\n]*)" select="\2"/>
45        <propertyregex property="svn.root" input="${svn.entries}"
46          regexp="([^\n]*\n){5}([^\n]*)" select="\2"/>
47        <propertyregex property="svn.date" input="${svn.entries}"
48          regexp="([^\n]*\n){9}([^\n]*)" select="\2"/>
49        <propertyregex property="svn.changed" input="${svn.entries}"
50          regexp="([^\n]*\n){10}([^\n]*)" select="\2"/>
51      </then>
52    </if>
53
54    <!-- check for Git versioning information -->
55    <property name="git.path" value="${root.dir}/.git"/>
56    <available file="${git.path}" property="git.present"/>
57    <if>
58      <isset property="git.present"/>
59      <then>
60        <exec executable="git" outputproperty="git.info"
61          failifexecutionfails="false">
62          <arg value="show"/>
63          <arg value="-s"/>
64          <arg value="HEAD"/>
65        </exec>
66        <propertyregex property="git.commit" input="${git.info}"
67          regexp="commit ([a-f0-9]+)" select="\1"/>
68        <propertyregex property="svn.revision" input="${git.info}"
69          regexp=".*git-svn-id: [^@]+@([0-9]+)" select="\1"/>
70        <propertyregex property="svn.url"
71          input="${git.info}" regexp=".*git-svn-id: ([^@]+)" select="\1"/>
72        <propertyregex property="svn.root" input="${svn.url}"
73          regexp="(.*)(/trunk)|(/branches)|(/tags).*" select="\1"/>
74        <propertyregex property="svn.date"
75          input="${git.info}" regexp="Date: +([^\n]*)" select="\1"/>
76        <property name="svn.changed" value="unknown"/>
77      </then>
78    </if>
79
80    <!-- set release version from repository URL -->
81    <property name="release.version" value="unknown"/>
82    <if>
83      <isset property="svn.url"/>
84      <then>
85        <propertyregex property="release.version" override="true"
86          input="${svn.url}" regexp=".*/(trunk).*" replace="\1"/>
87        <propertyregex property="release.version" override="true"
88          input="${svn.url}" regexp=".*/branches/([^/]*).*"
89          replace="dev \1"/>
90        <propertyregex property="release.version" override="true"
91          defaultValue="${release.version}"
92          input="${svn.url}" regexp=".*/tags/loci-tools-([^/]*).*"
93          replace="stable \1"/>
94      </then>
95    </if>
96  </target>
97
98</project>
Note: See TracBrowser for help on using the repository browser.