Skip to main content
summaryrefslogtreecommitdiffstats
blob: 2fa7dd90a26480e65cfb31fc6414146fda24b9a5 (plain) (blame)
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
<project name="Generates OSEE Application Server Runtime Package" default="run">

	<target name="setup">
		<echo>Packaging Server Runtime</echo>
		<echo>Output-Path: ${output-path}</echo>
		<echo>P2-Content-Path: ${p2-content-path}</echo>
		<echo>Output-Name: ${output-name}</echo>
		<echo>Server-Path: ${server-path}</echo>
		<echo>Demo-Data-Path: ${demo-content-path}</echo>
		<echo />

		<condition property="os-separator-exp" value="\\" else="/">
			<os family="windows" />
		</condition>

		<mkdir dir="${server-path}" />

		<property name="server-config-path" value="${server-path}/configuration" />
		<property name="server-plugins-path" value="${server-path}/plugins" />

		<mkdir dir="${server-config-path}" />
		<mkdir dir="${server-plugins-path}" />

		<copy todir="${server-plugins-path}">
			<fileset dir="${p2-content-path}/plugins" excludes="**/*source_*.jar" />
		</copy>

		<pathconvert property="launcherBundlePath" setonempty="false">
			<path>
				<fileset dir="${server-plugins-path}">
					<include name="org.eclipse.equinox.launcher_*.jar" />
				</fileset>
			</path>
		</pathconvert>
		<propertyregex property="equinox-launcher-jar" override="true" input="${launcherBundlePath}" regexp="[^${os-separator-exp}]+$" select="\0" casesensitive="false" />
	</target>

	<target name="pack">
		<zip destfile="${output-path}/${output-name}.zip">
			<fileset dir="${server-path}" />
		</zip>
	</target>

	<target name="cleanup">
		<delete dir="${server-path}" quiet="true" />
	</target>

	<target name="generateConfig">
		<generateConfigIni configPath="${server-config-path}" pluginsPath="${server-plugins-path}" />
	</target>

	<!-- *************************************************************** -->
	<!--   MAIN RUN		                                                -->
	<!-- *************************************************************** -->
	<target name="run" depends="setup,generateConfig,generateLaunchScripts,pack" />

	<!-- *************************************************************** -->
	<!--   LAUNCH CONFIGS                                                -->
	<!-- *************************************************************** -->
	<target name="generateTemplate">
		<createLaunch filepath="${server-path}/runExample.sh" connection.id="[id from connection file]" serverport="8089" executable="false" launcher="${equinox-launcher-jar}" extraVMArgs="-Dosee.connection.info.uri=[custom connection file path] \${line.separator}-Dosee.application.server.data=[binary data path]" />
	</target>

	<target name="generateH2Launch">
		<createLaunch filepath="${server-path}/runH2.sh" connection.id="h2" serverport="8089" launcher="${equinox-launcher-jar}" extraVMArgs="-Dosee.db.embedded.server=0.0.0.0:8088" />
	</target>

	<target name="generateDemoLaunch">
		<createLaunch filepath="${server-path}/runDemo.sh" connection.id="osee.demo.h2" serverport="8089" launcher="${equinox-launcher-jar}" extraVMArgs="-Dosee.db.embedded.server=0.0.0.0:8088 \${line.separator}-Dosee.connection.info.uri=&quot;demo/osee.demo.db.connection.xml&quot; \${line.separator}-Dosee.application.server.data=&quot;demo/binary_data&quot;" />

		<copy file="${server-path}/runDemo.sh" tofile="${server-path}/runDemo.bat" overwrite="true" />
		<replaceregexp file="${server-path}/runDemo.bat" match="\\" replace="^" flags="g" />

		<!-- Copy Demo Files -->
		<property name="server-demo-path" value="${server-path}/demo" />

		<mkdir dir="${server-demo-path}" />
		<mkdir dir="${server-demo-path}/binary_data" />

		<unzip src="${demo-content-path}/h2.zip" dest="${server-demo-path}" />
		<unzip src="${demo-content-path}/binary_data.zip" dest="${server-demo-path}/binary_data" />
		<copy file="${demo-content-path}/osee.demo.db.connection.xml" tofile="${server-demo-path}/osee.demo.db.connection.xml" />
	</target>

	<target name="generateLocalPostgresLaunch">
		<createLaunch filepath="${server-path}/runPostgresqlLocal.sh" connection.id="postgresqlLocalhost" serverport="8089" launcher="${equinox-launcher-jar}" />
	</target>

	<target name="generateLaunchScripts" depends="generateTemplate,generateDemoLaunch,generateH2Launch,generateLocalPostgresLaunch" />

	<!-- *************************************************************** -->
	<!--   GENERATE CONFIG.INI                                           -->
	<!-- *************************************************************** -->
	<macrodef name="generateConfigIni">
		<attribute name="configPath" />
		<attribute name="pluginsPath" />
		<sequential>
			<echo file="@{configPath}/config.ini" append="false" message="osgi.bundles= \${line.separator}\${line.separator}" />

			<pathconvert property="serverBundles" setonempty="false" pathsep=";">
				<path>
					<fileset dir="@{pluginsPath}">
						<exclude name="org.eclipse.osgi_*.jar" />
						<exclude name="org.eclipse.equinox.launcher_*.jar" />
						<exclude name="*source_*.jar" />
					</fileset>
				</path>
			</pathconvert>

			<var name="isFirst" value="false" />
			<for param="bundle" delimiter=";" list="${serverBundles}" trim="true">
				<sequential>
					<propertyregex override="yes" property="jarFilename" input="@{bundle}" regexp="[^${os-separator-exp}]+$" select="\0" />

					<propertyregex property="projectName" override="true" input="${jarFilename}" regexp="(.*?)_" select="\1" casesensitive="false" />
					<if>
						<equals arg1="${isFirst}" arg2="true" />
						<then>
							<echo file="@{configPath}/config.ini" message=", \${line.separator}" append="true" />
							<var name="isFirst" value="false" />
						</then>
					</if>

					<if>
						<equals arg1="${projectName}" arg2="org.eclipse.osee.logback.config" />
						<then>
							<echo file="@{configPath}/config.ini" message="${projectName}" append="true" />
						</then>
						<elseif>
							<equals arg1="${projectName}" arg2="org.eclipse.osee.logger.slf4j" />
							<then>
								<echo file="@{configPath}/config.ini" message="${projectName}" append="true" />
							</then>
						</elseif>
						<elseif>
							<equals arg1="${projectName}" arg2="org.eclipse.osee.vaadin.themes" />
							<then>
								<echo file="@{configPath}/config.ini" message="${projectName}" append="true" />
							</then>
						</elseif>
						<elseif>
							<equals arg1="${projectName}" arg2="ch.qos.logback.slf4j" />
							<then>
								<echo file="@{configPath}/config.ini" message="${projectName}" append="true" />
							</then>
						</elseif>
						<else>
							<echo file="@{configPath}/config.ini" message="${projectName}@start" append="true" />
						</else>
					</if>

					<var name="isFirst" value="true" />
				</sequential>
			</for>
			<echo file="@{configPath}/config.ini" append="true">
osgi.noShutdown=true
eclipse.ignoreApp=true
equinox.ds.debug=true
osee.log.default=INFO
			</echo>
		</sequential>
	</macrodef>

	<!-- *************************************************************** -->
	<!--   GENERATE LAUNCH                                               -->
	<!-- *************************************************************** -->
	<macrodef name="createLaunch">
		<attribute name="filepath" />
		<attribute name="serverport" />
		<attribute name="connection.id" />
		<attribute name="launcher" />
		<attribute name="serverMaxMem" default="1024m" />
		<attribute name="executable" default="true" />
		<attribute name="extraVMArgs" default=" " />
		<sequential>
			<echo file="@{filepath}" append="false">java \
-Xmx@{serverMaxMem} \
-Dorg.osgi.service.http.port=@{serverport} \
-Dosee.db.connection.id=@{connection.id} \
@{extraVMArgs} \
-jar plugins/@{launcher} -console -consoleLog -clean
</echo>
			<if>
				<equals arg1="@{executable}" arg2="true" />
				<then>
					<chmod file="@{filepath}" perm="ugo+rx" />
				</then>
			</if>
		</sequential>
	</macrodef>
</project>

Back to the top