build.xml 2.39 KB
Newer Older
1
<?xml version="1.0" encoding="UTF-8"?>
Mathias Goebel's avatar
Mathias Goebel committed
2
<project default="xar" name="SADE">
Mathias Goebel's avatar
JENKINS    
Mathias Goebel committed
3
    <property environment="env"/>
Mathias Goebel's avatar
Mathias Goebel committed
4
    <property file="build.properties"/>
Mathias Goebel's avatar
Mathias Goebel committed
5
    <property name="build.dir" value="build"/>
Mathias Goebel's avatar
Mathias Goebel committed
6
7
8
9
10
11
12
13
14
15
16
17

    <!-- look for the current branch in .git folder -->
    <loadfile property="git.branch" srcfile=".git/HEAD">
        <filterchain>
            <headfilter lines="1" skip="0"/>
            <tokenfilter>
                <replaceregex pattern="^.*\/" replace="" flags="gi"/>
            </tokenfilter>
            <striplinebreaks/>
        </filterchain>
    </loadfile>

Mathias Goebel's avatar
Mathias Goebel committed
18
    <property name="jenkins.branch" value="${env.GIT_BRANCH}"/>
Mathias Goebel's avatar
Mathias Goebel committed
19

Mathias Goebel's avatar
Mathias Goebel committed
20
    <target name="xar">
Mathias Goebel's avatar
Mathias Goebel committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        <!-- START get local branch name -->
            <condition property="branch1" value="${git.branch}" else="${jenkins.branch}">
                <matches pattern="\$" string="${jenkins.branch}"/>
            </condition>
            <substring text="${branch1}" start="7" end="100" property="branch2"/>
            <condition property="branch3" value="${branch2}" else="${git.branch}">
                <not>
                    <equals arg1="${branch2}" arg2=""/>

                </not>
            </condition>
        <!-- END get local branch name -->

        <property name="namespace" value="${project.namespace}-${branch3}"/>
Mathias Goebel's avatar
Mathias Goebel committed
35
        <copy file="expath-pkg.xml.tmpl" tofile="expath-pkg.xml" filtering="true" overwrite="true">
Mathias Goebel's avatar
JENKINS    
Mathias Goebel committed
36
37
            <filterset>
                <filter token="project.version" value="${project.version}"/>
Mathias Goebel's avatar
Mathias Goebel committed
38
39
40
                <filter token="project.title" value="${project.title}"/>
                <filter token="project.abbrev" value="${project.abbrev}"/>
                <filter token="project.namespace" value="${project.namespace}"/>
Mathias Goebel's avatar
JENKINS    
Mathias Goebel committed
41
            </filterset>
Mathias Goebel's avatar
Mathias Goebel committed
42
        </copy>
Mathias Goebel's avatar
Mathias Goebel committed
43
        <mkdir dir="${build.dir}"/>
Mathias Goebel's avatar
Mathias Goebel committed
44
45
        <zip basedir="." destfile="${build.dir}/${project.abbrev}-${project.version}-${branch3}.xar"
            excludes="${build.dir}/*"/>
Mathias Goebel's avatar
Mathias Goebel committed
46
    </target>
Mathias Goebel's avatar
Mathias Goebel committed
47

Mathias Goebel's avatar
jenkins    
Mathias Goebel committed
48
    <scriptdef name="substring" language="javascript">
Mathias Goebel's avatar
Mathias Goebel committed
49
50
51
52
53
        <attribute name="text"/>
        <attribute name="start"/>
        <attribute name="end"/>
        <attribute name="property"/>
        <![CDATA[
Mathias Goebel's avatar
jenkins    
Mathias Goebel committed
54
55
56
57
58
59
         var text = attributes.get("text");
         var start = attributes.get("start");
         var end = attributes.get("end") || text.length();
         project.setProperty(attributes.get("property"), text.substring(start, end));
       ]]>
    </scriptdef>
Mathias Goebel's avatar
Mathias Goebel committed
60
</project>