forked from iMattPro/abbc3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
134 lines (114 loc) · 4.23 KB
/
build.xml
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?xml version="1.0" encoding="UTF-8"?>
<project name="Advanced BBCode Box" description="Builds an extension.zip from a git repository" default="all">
<property name="vendor-name" value="vse" />
<property name="extension-name" value="abbc3" />
<!--
Only set this to "true" if you have dependencies in the composer.json,
otherwise use "false".
-->
<property name="has-dependencies" value="false" />
<target name="clean-package">
<!--
Remove some unnecessary files/directories
${dir}/ is the folder of your extension, e.g. ext/nickvergessen/newspage/
-->
<delete dir="${dir}/tests" />
<delete dir="${dir}/vendor" />
<delete dir="${dir}/node_modules" />
<delete dir="${dir}/develop" />
<delete dir="${dir}/.github" />
<delete file="${dir}/.codeclimate.yml" />
<delete file="${dir}/.gitignore" />
<delete file="${dir}/.gitattributes" />
<delete file="${dir}/build.xml" />
<delete file="${dir}/composer.lock" />
<delete file="${dir}/composer.phar" />
<delete file="${dir}/phpunit.xml.dist" />
<delete file="${dir}/README.md" />
<delete file="${dir}/package.json" />
<delete file="${dir}/package-lock.json" />
</target>
<!--
DO NOT EDIT BELOW THIS LINE!!!!
-->
<property name="version" value="HEAD" override="true" />
<property name="build-directory" value="build" override="true" />
<property name="package-directory" value="${build-directory}/package/${vendor-name}/${extension-name}" />
<!-- These are the main targets which you will probably want to use -->
<target name="all" depends="prepare-structure,package" />
<!--
Clean up the build directory
-->
<target name="clean">
<delete dir="${build-directory}" />
</target>
<!--
Recreate the necessary folders
-->
<target name="prepare-structure" depends="clean">
<mkdir dir="${build-directory}" />
<mkdir dir="${build-directory}/checkout" />
<mkdir dir="${build-directory}/package" />
<mkdir dir="${build-directory}/package/${vendor-name}" />
<mkdir dir="${build-directory}/package/${vendor-name}/${extension-name}" />
<mkdir dir="${build-directory}/upload" />
</target>
<!--
The real packaging
-->
<target name="package">
<echo msg="Extracting ${version}" />
<phingcall target="git-checkout">
<property name="archive-version" value="${version}" />
</phingcall>
<if>
<equals arg1="${has-dependencies}" arg2="1" />
<then>
<exec dir="${package-directory}" command="php composer.phar install --no-dev"
checkreturn="true" />
</then>
</if>
<phingcall target="npm-build-task">
<property name="dir" value="${package-directory}" />
</phingcall>
<phingcall target="clean-package">
<property name="dir" value="${package-directory}" />
</phingcall>
<!-- Try setting the package version property from composer.json -->
<exec dir="${package-directory}"
command='php -r "\$j = json_decode(file_get_contents(\"composer.json\")); echo (isset(\$j->version) ? \$j->version : \"${version}\");"'
checkreturn="true"
outputProperty='package-version' />
<phingcall target="wrap-package">
<property name="destination-filename" value="${build-directory}/upload/${vendor-name}_${extension-name}_${package-version}" />
</phingcall>
</target>
<!--
Checkout a given version and install/clean the dependencies
-->
<target name="git-checkout">
<echo msg="Getting archive for ${archive-version}" />
<exec command="git archive ${archive-version} --format zip --output ${build-directory}/checkout/${archive-version}.zip"
checkreturn="true" />
<unzip file="${build-directory}/checkout/${archive-version}.zip" todir="${package-directory}" />
</target>
<!--
Create the zip and tar ball
-->
<target name="wrap-package">
<echo msg="Creating archives (${vendor-name}/${extension-name} ${version})" />
<zip basedir="${build-directory}/package/" destfile="${destination-filename}.zip" />
</target>
<!--
npm installation
-->
<target name="npm-install" description="npm-install target: install node modules">
<exec command="npm install" dir="${package-directory}" passthru="true" checkreturn="true" />
</target>
<!--
Run npm build task
-->
<target name="npm-build-task" depends="npm-install">
<exec command="npm run build" dir="${package-directory}" passthru="true" checkreturn="true" />
</target>
</project>