forked from drewbrown/StackStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
160 lines (142 loc) · 6.22 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<project name="StackStudio" basedir="." default="deploy">
<property name="name" value="StackStudio" />
<property file="${user.home}/${name}.properties"/>
<property file="${user.home}/build.properties"/>
<property name="config.filename" value="${user.name}.properties"/>
<property file="${config.filename}"/>
<property file="build.properties"/>
<!-- bring in environment properties, for env specific IPs, etc. -->
<property name="env" value="devint" />
<property name="env.properties" value="resources/${env}.properties"/>
<property file="${env.properties}"/>
<property name="project.base.dir" value="${basedir}" />
<property name="src.flex" value="${project.base.dir}/app/flex" />
<property name="resources.flex" value="${src.flex}/resources" />
<property name="src" value="${project.base.dir}/src" />
<property name="test" value="${project.base.dir}/test" />
<property name="build" value="${project.base.dir}/build" />
<property name="classes" value="${build}/classes" />
<property name="jar.dir" value="${project.base.dir}/build/lib/" />
<property name="lib" value="${build}/lib" />
<property name="external" value="${build}/external" />
<property name="external.jars" value="${build}/external/lib" />
<property name="resources" value="${project.base.dir}/resources" />
<property name="hudson.url" value="jenkins.momentumsoftware.com:8080/" />
<property name="package.file" value="stackstudio2.tar.gz"/>
<property name="sstudio2.home" value="/home/stackstudio"/>
<property name="dist" value="${project.base.dir}/dist" />
<property name="dist.suffix" value=""/>
<property name="config" value="Config${dist.suffix}/${name}"/>
<property name="config.dir" value="${project.base.dir}/../${config}"/>
<target name="init">
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
<echo>Copying config files from ${config.dir}.</echo>
</target>
<condition property="have.config">
<available file="${config.dir}" type="dir"/>
</condition>
<target name="copy.config" if="have.config">
<echo>Copying config files.</echo>
<copy todir="${project.base.dir}" overwrite="true">
<fileset dir="${config.dir}" >
</fileset>
</copy>
</target>
<target name="deploy" depends="package">
<echo message="Deploying StackStudio to ${deploy.ip}"/>
<exec executable="scp" failonerror="true">
<arg line="${build}/${package.file} stackstudio@${deploy.ip}:/${sstudio2.home}"/>
</exec>
<exec executable="ssh" failonerror="true">
<arg line="stackstudio@${deploy.ip} sudo rm -r ${sstudio2.home}/StackStudio"/>
</exec>
<exec executable="ssh" failonerror="true">
<arg line="stackstudio@${deploy.ip} sudo tar xzf ${sstudio2.home}/${package.file} -C ${sstudio2.home}"/>
</exec>
<exec executable="ssh" failonerror="true">
<arg line="stackstudio@${deploy.ip} sudo chmod 755 ${sstudio2.home}/StackStudio"/>
</exec>
<exec executable="ssh" failonerror="true">
<arg line="stackstudio@${deploy.ip} sudo find ${sstudio2.home}/StackStudio -type d -exec chmod 755 {} \;" />
</exec>
<exec executable="ssh" failonerror="true">
<arg line="stackstudio@${deploy.ip} sudo find ${sstudio2.home}/StackStudio -type f -exec chmod 644 {} \;"/>
</exec>
<exec executable="ssh" failonerror="true">
<arg line="stackstudio@${deploy.ip} sudo chown -R stackstudio:stackstudio ${sstudio2.home}/StackStudio" />
</exec>
<exec executable="ssh" failonerror="true">
<arg line="stackstudio@${deploy.ip} sudo /etc/init.d/${sstudio.webserver} restart" />
</exec>
</target>
<available file=".git" type="dir" property="git.present"/>
<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo message="Current git revision =====> ${repository.version}"/>
</target>
<target name="clean">
<delete dir="${build}" />
<delete dir="${dist}"/>
</target>
<target name="grunt">
<exec executable="npm" failonerror="true">
<arg value="install"/>
</exec>
<exec executable="grunt" failonerror="true"/>
</target>
<target name="setBackend">
<copy file="${basedir}/backend.json.sample" tofile="${basedir}/backend.json">
<filterset>
<filter token="backend_endpoint" value="${backend.cloudmux}"/>
</filterset>
</copy>
</target>
<target name="package" depends="clean,init,grunt,setBackend">
<package destfile="${build}/${package.file}">
<include-patterns/>
<exclude-patterns/>
</package>
</target>
<target name="dist" depends="clean,init">
<subant antfile="${basedir}/build.xml">
<fileset dir="." includes="build.xml"/>
<property name="env" value="dist"/>
</subant>
<package destfile="${dist}/${package.file}">
<include-patterns/>
<exclude-patterns>
<exclude name="config/initializers/chargify_access.rb"/>
<exclude name="config/chargify.yml"/>
<exclude name="config/s3.yml"/>
</exclude-patterns>
</package>
</target>
<!-- define a macro for packaging, since we use the same tar with tweaks. -->
<macrodef name="package">
<attribute name="dist" default="false" />
<attribute name="destfile" default="${build}/${package.file}" />
<element name="include-patterns"/>
<element name="exclude-patterns"/>
<sequential>
<tar destfile="@{destfile}" compression="gzip" longfile="gnu">
<tarfileset dir="${project.base.dir}" prefix="StackStudio">
<include name="*/**"/>
<exclude name=".git/**"/>
<exclude name="resources/**"/>
<include-patterns/>
<exclude-patterns/>
</tarfileset>
</tar>
</sequential>
</macrodef>
</project>