-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-dist.xml
217 lines (199 loc) · 10.2 KB
/
build-dist.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?xml version="1.0" encoding="UTF-8"?>
<project name="lebetter deployment helper" basedir="." default="hint"
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<path id="maven-ant-tasks.classpath" path="${common.lib.path}"/>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
classpathref="maven-ant-tasks.classpath"/>
<tstamp/>
<property name="work.dir" value="target/dist"/>
<property name="snapshots.dir" value="snapshots"/>
<property name="package-portal.name" value="${snapshots.dir}/lb-portal-pack.zip"/>
<property name="package-fh.name" value="${snapshots.dir}/lb-fh-pack.zip"/>
<property name="package-nginx.name" value="${snapshots.dir}/lb-nginx-pack.zip"/>
<property file="build-dist-localhost.properties"/>
<target name="copy-dependencies">
<artifact:dependencies filesetId="dependencies.fileset">
<dependency groupId="org.ohm.lebetter" artifactId="lebetter-portal" version="1.1.0-SNAPSHOT" type="war"/>
<dependency groupId="org.ohm.lebetter" artifactId="lebetter-filehandler" version="1.1.0-SNAPSHOT" type="war"/>
<dependency groupId="org.ohm.lebetter" artifactId="lebetter-static-content" version="1.1.0-SNAPSHOT" classifier="files" type="tar.gz"/>
<dependency groupId="org.ohm.lebetter" artifactId="lebetter-db" version="1.1.0-SNAPSHOT" type="tar.gz"/>
<dependency groupId="org.ohm.lebetter" artifactId="lebetter-config" version="1.1.0-SNAPSHOT" classifier="nginx" type="tar.gz"/>
<dependency groupId="org.ohm.lebetter" artifactId="lebetter-config" version="1.1.0-SNAPSHOT" classifier="portal" type="tar.gz"/>
<dependency groupId="org.ohm.lebetter" artifactId="lebetter-config" version="1.1.0-SNAPSHOT" classifier="fh" type="tar.gz"/>
</artifact:dependencies>
<mkdir dir="${work.dir}/dependencies"/>
<copy flatten="true" todir="${work.dir}/dependencies" overwrite="true" verbose="true">
<fileset refid="dependencies.fileset"/>
</copy>
</target>
<target name="clean" description="removes build artifacts">
<delete dir="${work.dir}"/>
<delete dir="${snapshots.dir}"/>
</target>
<target name="make" depends="copy-dependencies" description="builds distribution package">
<mkdir dir="${work.dir}/pkg"/>
<move todir="${work.dir}/pkg" overwrite="true" verbose="true">
<fileset dir="${work.dir}/dependencies">
<include name="lebetter-portal-*.war"/>
</fileset>
<mapper type="merge" to="ROOT.war"/>
</move>
<move todir="${work.dir}/pkg" overwrite="true" verbose="true">
<fileset dir="${work.dir}/dependencies">
<include name="lebetter-filehandler-*.war"/>
</fileset>
<mapper type="merge" to="lb-fh.war"/>
</move>
<move todir="${work.dir}/pkg" overwrite="true" verbose="true">
<fileset dir="${work.dir}/dependencies">
<include name="lebetter-static-content-*.tar.gz"/>
</fileset>
<mapper type="merge" to="lb-static-content.tar.gz"/>
</move>
<move todir="${work.dir}/pkg" overwrite="true" verbose="true">
<fileset dir="${work.dir}/dependencies">
<include name="lebetter-config-*-portal.tar.gz"/>
</fileset>
<mapper type="merge" to="lb-portal-config.tar.gz"/>
</move>
<move todir="${work.dir}/pkg" overwrite="true" verbose="true">
<fileset dir="${work.dir}/dependencies">
<include name="lebetter-config-*-fh.tar.gz"/>
</fileset>
<mapper type="merge" to="lb-fh-config.tar.gz"/>
</move>
<move todir="${work.dir}/pkg" overwrite="true" verbose="true">
<fileset dir="${work.dir}/dependencies">
<include name="lebetter-db-*.tar.gz"/>
</fileset>
<mapper type="merge" to="lb-db.tar.gz"/>
</move>
<move todir="${work.dir}/pkg" overwrite="true" verbose="true">
<fileset dir="${work.dir}/dependencies">
<include name="lebetter-config-*-nginx.tar.gz"/>
</fileset>
<mapper type="merge" to="lb-nginx-config.tar.gz"/>
</move>
<mkdir dir="${snapshots.dir}"/>
<zip destfile="${package-portal.name}" compress="true" level="9">
<fileset dir="${work.dir}/pkg">
<include name="ROOT.war"/>
<include name="lb-portal-config.tar.gz"/>
<include name="lb-db.tar.gz"/>
</fileset>
</zip>
<zip destfile="${package-fh.name}" compress="true" level="9">
<fileset dir="${work.dir}/pkg">
<include name="lb-fh.war"/>
<include name="lb-fh-config.tar.gz"/>
</fileset>
</zip>
<zip destfile="${package-nginx.name}" compress="true" level="9">
<fileset dir="${work.dir}/pkg">
<include name="lb-nginx-config.tar.gz"/>
<include name="lb-static-content.tar.gz"/>
</fileset>
</zip>
</target>
<target name="deploy">
<echo message="Deploing packages"/>
<mkdir dir="${work.dir}/deploy"/>
<delete includeEmptyDirs="true">
<fileset dir="${nginx.home}" includes="**/*" defaultexcludes="false"/>
</delete>
<delete includeEmptyDirs="true">
<fileset dir="${tomcat.home}/webapps/ROOT" includes="**/*" defaultexcludes="false"/>
</delete>
<delete includeEmptyDirs="true">
<fileset dir="${tomcat.home}/webapps/lb-fh" includes="**/*" defaultexcludes="false"/>
</delete>
<antcall target="deploy-portalbin"/>
<antcall target="deploy-fhbin"/>
<antcall target="deploy-nginxbin"/>
</target>
<target name="deploy-config">
<echo message="Deploing config packages"/>
<antcall target="deploy-portalconfig"/>
<antcall target="deploy-fhconfig"/>
<antcall target="deploy-nginxconfig"/>
</target>
<target name="deploy-portalbin">
<echo message="Deploing portal files"/>
<unzip src="${package-portal.name}" dest="${work.dir}/deploy"/>
<unjar src="${work.dir}/deploy/ROOT.war" dest="${tomcat.home}/webapps/ROOT"/>
<chgrp group="webdev">
<dirset dir="${tomcat.home}/webapps/ROOT" includes="*"/>
<dirset dir="${tomcat.home}/webapps/ROOT" includes="**/*"/>
<fileset dir="${tomcat.home}/webapps/ROOT" includes="**/*"/>
</chgrp>
<chmod perm="775">
<fileset dir="${tomcat.home}/webapps/ROOT" includes="**/*.tml"/>
</chmod>
</target>
<target name="deploy-fhbin">
<echo message="Deploing fh files"/>
<unzip src="${package-fh.name}" dest="${work.dir}/deploy"/>
<unjar src="${work.dir}/deploy/lb-fh.war" dest="${tomcat.home}/webapps/lb-fh"/>
</target>
<target name="deploy-nginxbin">
<echo message="Deploing nginx html files"/>
<unzip src="${package-nginx.name}" dest="${work.dir}/deploy"/>
<gunzip src="${work.dir}/deploy/lb-static-content.tar.gz" dest="${work.dir}/deploy/lb-static-content.tar"/>
<untar src="${work.dir}/deploy/lb-static-content.tar" dest="${nginx.home}"/>
<chgrp group="webdev">
<dirset dir="${nginx.home}" includes="*"/>
<dirset dir="${nginx.home}" includes="**/*"/>
<fileset dir="${nginx.home}" includes="**/*"/>
</chgrp>
<chmod perm="775">
<dirset dir="${nginx.home}" includes="*"/>
<dirset dir="${nginx.home}" includes="**/*"/>
<fileset dir="${nginx.home}" includes="**/*"/>
</chmod>
<delete file="${work.dir}/deploy/lb-static-content.tar"/>
</target>
<target name="deploy-nginxconfig">
<echo message="Deploing nginx config files"/>
<unzip src="${package-nginx.name}" dest="${work.dir}/deploy"/>
<gunzip src="${work.dir}/deploy/lb-nginx-config.tar.gz" dest="${work.dir}/deploy/lb-nginx-config.tar"/>
<untar src="${work.dir}/deploy/lb-nginx-config.tar" dest="/"/>
<delete file="${work.dir}/deploy/lb-nginx-config.tar"/>
</target>
<target name="deploy-portalconfig">
<echo message="Deploing portal config files"/>
<unzip src="${package-portal.name}" dest="${work.dir}/deploy"/>
<gunzip src="${work.dir}/deploy/lb-portal-config.tar.gz" dest="${work.dir}/deploy/lb-portal-config.tar"/>
<untar src="${work.dir}/deploy/lb-portal-config.tar" dest="/"/>
<delete file="${work.dir}/deploy/lb-portal-config.tar"/>
</target>
<target name="deploy-fhconfig">
<echo message="Deploing fh config files"/>
<unzip src="${package-fh.name}" dest="${work.dir}/deploy"/>
<gunzip src="${work.dir}/deploy/lb-fh-config.tar.gz" dest="${work.dir}/deploy/lb-fh-config.tar"/>
<untar src="${work.dir}/deploy/lb-fh-config.tar" dest="/"/>
<delete file="${work.dir}/deploy/lb-fh-config.tar"/>
</target>
<target name="import-changeset">
<echo message="Importing new changeset"/>
<unzip src="${package-portal.name}" dest="${work.dir}/deploy"/>
<gunzip src="${work.dir}/deploy/lb-db.tar.gz" dest="${work.dir}/deploy/lb-db.tar"/>
<untar src="${work.dir}/deploy/lb-db.tar" dest="${work.dir}/deploy/db"/>
<chmod dir="${work.dir}/deploy/db" perm="u+x" includes="**/*.sh"/>
<exec executable="${work.dir}/deploy/db/importDBChangeset.sh">
<arg value="${db.properties.file}"/>
</exec>
</target>
<target name="deploy-local-idea" description="deploy distribution package locally from idea using maven">
<fail unless="tomcat.home" message="define 'tomcat.home' (path) property"/>
<exec executable="${maven.home}/bin/mvn" dir="lebetter-portal" resolveexecutable="true">
<arg value="-o"/>
<arg value="-P development-idea"/>
<arg value="-D webapp.dir.ext=${tomcat.home}/webapps/ROOT"/>
<arg value="war:exploded"/>
</exec>
</target>
<target name="hint">
<echo message="${tomcat.home} || add option '-projecthelp' to get list of main targets"/>
</target>
</project>