forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-test-elasticsearch.xml
171 lines (145 loc) · 5.25 KB
/
build-test-elasticsearch.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
<?xml version="1.0"?>
<project basedir="." name="portal-test-elasticsearch" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-test.xml" />
<macrodef name="prepare-elasticsearch">
<sequential>
<copy todir="${elasticsearch.dir}">
<fileset
dir="modules/apps/foundation/portal-search/portal-search-elasticsearch/src/main/resources/plugins/"
includes="analysis*${elasticsearch.version}.zip"
/>
</copy>
<chmod file="${elasticsearch.dir}/bin/**" perm="a+x" />
<if>
<os family="unix" />
<then>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./plugin install file:///${elasticsearch.dir}/analysis-icu-${elasticsearch.version}.zip" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./plugin install file:///${elasticsearch.dir}/analysis-kuromoji-${elasticsearch.version}.zip" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./plugin install file:///${elasticsearch.dir}/analysis-smartcn-${elasticsearch.version}.zip" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./plugin install file:///${elasticsearch.dir}/analysis-stempel-${elasticsearch.version}.zip" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${elasticsearch.dir}/bin" executable="cmd">
<arg value="/c" />
<arg line="plugin install file:///${elasticsearch.dir}/analysis-icu-${elasticsearch.version}.zip" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="cmd">
<arg value="/c" />
<arg line="plugin install file:///${elasticsearch.dir}/analysis-kuromoji-${elasticsearch.version}.zip" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="cmd">
<arg value="/c" />
<arg line="plugin install file:///${elasticsearch.dir}/analysis-smartcn-${elasticsearch.version}.zip" />
</exec>
<exec dir="${elasticsearch.dir}/bin" executable="cmd">
<arg value="/c" />
<arg line="plugin install file:///${elasticsearch.dir}/analysis-stempel-${elasticsearch.version}.zip" />
</exec>
</then>
</elseif>
</if>
</sequential>
</macrodef>
<macrodef name="unzip-elasticsearch">
<sequential>
<delete dir="${elasticsearch.dir}" />
<if>
<not>
<available file="${app.server.parent.dir}/${elasticsearch.zip.name}" />
</not>
<then>
<mirrors-get
dest="${app.server.parent.dir}/${elasticsearch.zip.name}"
src="${elasticsearch.zip.url}"
verbose="true"
/>
</then>
</if>
<unzip
dest="${app.server.parent.dir}"
src="${app.server.parent.dir}/${elasticsearch.zip.name}"
/>
</sequential>
</macrodef>
<target name="configure-elasticsearch-osgi-bundle-properties">
<echo file="${liferay.home}/osgi/configs/com.liferay.portal.search.elasticsearch.configuration.ElasticsearchConfiguration.cfg">operationMode=REMOTE
logExceptionsOnly=false</echo>
</target>
<target name="start-elasticsearch">
<unzip-elasticsearch />
<replace file="${elasticsearch.dir}/config/elasticsearch.yml">
<replacetoken><![CDATA[# cluster.name: my-application]]></replacetoken>
<replacevalue><![CDATA[cluster.name: LiferayElasticsearchCluster]]></replacevalue>
</replace>
<prepare-elasticsearch />
<antcall target="configure-elasticsearch-osgi-bundle-properties" />
<local name="elasticsearch.server.not.started" />
<if>
<os family="unix" />
<then>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="./elasticsearch -Des.insecure.allow.root=true -d -p pid" />
</exec>
<waitfor maxwait="10" maxwaitunit="second" timeoutproperty="elasticsearch.server.not.started">
<http url="http://localhost:9200/" />
</waitfor>
<fail if="elasticsearch.server.not.started" message="Elasticsearch server failed to initialize." />
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${elasticsearch.dir}/bin" executable="cmd" spawn="true">
<arg value="/c" />
<arg value="elasticsearch -d -p pid" />
</exec>
<waitfor maxwait="10" maxwaitunit="second" timeoutproperty="elasticsearch.server.not.started">
<http url="http://localhost:9200/" />
</waitfor>
<fail if="elasticsearch.server.not.started" message="Elasticsearch server failed to initialize." />
</then>
</elseif>
</if>
</target>
<target name="stop-elasticsearch">
<if>
<os family="unix" />
<then>
<loadfile property="pid" srcFile="${elasticsearch.dir}/bin/pid">
<filterchain>
<linecontainsregexp>
<regexp pattern="[0-9]*" />
</linecontainsregexp>
</filterchain>
</loadfile>
<exec dir="${elasticsearch.dir}/bin" executable="/bin/bash">
<arg value="-c" />
<arg value="kill ${pid}" />
</exec>
</then>
<elseif>
<os family="windows" />
<then>
<exec dir="${elasticsearch.dir}/bin" executable="cmd" spawn="true">
<arg value="/c" />
<arg value="for /f %x in (pid) do taskkill /f /pid %x" />
</exec>
</then>
</elseif>
</if>
</target>
</project>