-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
118 lines (103 loc) · 3.82 KB
/
build.xml
File metadata and controls
118 lines (103 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?xml version="1.0" encoding="UTF-8"?>
<project name="gn36/versionchecknotifier" default="rebuild-archive">
<property name="buildfolder" value="./build/" />
<property name="extvendor" value="gn36" />
<property name="extname" value="versionchecknotifier" />
<!-- AUTO CONFIG from here on -->
<property name="dir" value="${buildfolder}data/${extvendor}/${extname}/" />
<property name="zipfolder" value="${buildfolder}zip/" />
<exec dir="${project.basedir}"
command='php -r "\$j = json_decode(file_get_contents(\"composer.json\")); echo \$j->version;"'
checkreturn="true"
outputProperty='version' />
<!-- ======== FILESETS ========= -->
<fileset dir="${project.basedir}" id="extfiles">
<include name="**/*.php" />
<include name="**/*.yml" />
<include name="language/**/*.txt" />
<include name="composer.json" />
<include name="license.txt" />
<include name="README.md" />
<include name="**/*.jpg" />
<include name="**/*.jpeg" />
<include name="**/*.gif" />
<include name="**/*.png" />
<include name="**/*.css" />
<include name="**/*.html" />
<include name="**/*.js" />
<exclude name=".travis.yml" />
<exclude name="tests/**" />
<exclude name="travis/**" />
<exclude name=".git/**" />
<exclude name="build/**" />
</fileset>
<!-- ============================================== -->
<!-- ======== TARGETS ============================= -->
<!-- ============================================== -->
<!-- ======== PREPARE ========== -->
<target name="prepare">
<echo msg="creating build directory" />
<mkdir dir="${buildfolder}" />
<mkdir dir="${dir}" />
<mkdir dir="${zipfolder}" />
</target>
<!-- ======== BUILD ============= -->
<target name="build" depends="prepare">
<echo msg="copying files to build dir" />
<copy todir="${dir}">
<fileset refid="extfiles" />
</copy>
<!-- Install composer dependencies, if there are any. -->
<exec dir="${dir}"
command='php -r "\$j = json_decode(file_get_contents(\"composer.json\"), true); if (isset(\$j[\"require\"][\"php\"])) {unset(\$j[\"require\"][\"php\"]);} echo (count(\$j[\"require\"]));"'
checkreturn="true"
outputProperty='composer-has-dependencies' />
<if>
<equals arg1="${composer-has-dependencies}" arg2="1" trim="true" />
<then>
<!-- We have non-dev composer dependencies -->
<exec dir="."
command="git ls-tree ${revision} composer.phar"
checkreturn="true"
outputProperty='composer-ls-tree-output' />
<if>
<equals arg1="${composer-ls-tree-output}" arg2="" trim="true" />
<then>
<fail message="There are composer dependencies, but composer.phar is missing." />
</then>
<else>
<!-- Export the phar, install dependencies, delete phar. -->
<exec dir="."
command="git archive ${revision} composer.phar | tar -xf - -C ${dir}"
checkreturn="true" />
<exec dir="${dir}"
command="php composer.phar install --no-dev --optimize-autoloader"
checkreturn="true"
passthru="true" />
<delete file="${dir}/composer.phar" />
</else>
</if>
</then>
<else>
<!-- We do not have composer dependencies, do not ship composer files -->
<delete file="${dir}/composer.lock" />
<delete file="${dir}/composer.phar" />
</else>
</if>
</target>
<!-- ======= ARCHIVE ========== -->
<target name="archive" depends="build">
<zip destfile="${zipfolder}/${extvendor}-${extname}-${version}.zip" includeemptydirs="true" basedir="${dir}" />
</target>
<!-- ======= REBUILD ========== -->
<target name="rebuild">
<delete dir="${buildfolder}/data" />
<phingcall target="build" />
</target>
<!-- ======= REBUILD-ARCHIVE == -->
<target name="rebuild-archive">
<delete dir="${buildfolder}/data" />
<delete file="${zipfolder}/${extvendor}-${extname}-${version}.zip" />
<phingcall target="archive" />
</target>
</project>