Skip to main content
summaryrefslogblamecommitdiffstats
blob: fe2843027be32a9440c0798f9478b74c1477d87e (plain) (tree)














































































                                                                                                                                                                                                                                                       











                                                                                              


























































































                                                                                                                                                                                          
<project name="Generates OSEE Application Server Runtime Bundle" default="run">

	<target name="setup">
		<propertyregex property="updateSiteFile" input="${masterZip}" defaultvalue="${masterZip}" regexp="-Master-" replace="-Update-" casesensitive="false" override="true" />
		<property name="tempAppServerFolder" value="${buildDirectory}/${buildLabel}/${updateSiteFile}_tmp" />
		<mkdir dir="${tempAppServerFolder}" />

		<unzip src="${buildDirectory}/${buildLabel}/${updateSiteFile}" dest="${tempAppServerFolder}">
			<patternset includes="plugins/*" excludes="features/*,*.jar,*.xml,**/*source_*" />
		</unzip>

		<property name="configFolder" value="${tempAppServerFolder}/configuration" />
		<property name="pluginsFolder" value="${tempAppServerFolder}/plugins" />

		<mkdir dir="${configFolder}" />

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

	<target name="generateConfig">
		<generateConfigIni configPath="${configFolder}" pluginsPath="${pluginsFolder}" />
	</target>

	<target name="pack">
		<propertyregex property="serverRuntimeFile" input="${masterZip}" defaultvalue="server-runtime.zip" regexp="-Master-" replace="-osgi-runtime-" casesensitive="false" override="true" />
		<zip destfile="${buildDirectory}/../${serverRuntimeFile}">
			<fileset dir="${tempAppServerFolder}" />
		</zip>
	</target>

	<target name="cleanup">
		<delete dir="${tempAppServerFolder}" quiet="true" />
	</target>

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

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

	<target name="generateDemoLaunch">
		<createLaunch 
			filepath="${tempAppServerFolder}/runDemo.sh" 
			connection.id="h2" 
			serverport="8089" 
			launcher="${launcherJar}" 
			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="${tempAppServerFolder}/runDemo.sh" tofile="${tempAppServerFolder}/runDemo.bat" overwrite="true" />
		<replaceregexp file="${tempAppServerFolder}/runDemo.bat" match="\\" replace="^" flags="g" />

		<!-- Copy Demo Files -->
		<dirname property="dependencies.basedir" file="${ant.file}" />
		<property name="demoFiles" value="${dependencies.basedir}/../demo" />
		<property name="demoTarget" value="${tempAppServerFolder}/demo" />

		<mkdir dir="${demoTarget}" />
		<copy todir="${demoTarget}" >
			 <fileset dir="${demoFiles}"/>
		</copy>
		
		<unzip src="${demoTarget}/h2.zip" dest="${demoTarget}" />

		<mkdir dir="${demoTarget}/binary_data" />
		<unzip src="${demoTarget}/binary_data.zip" dest="${demoTarget}/binary_data" />

		<delete file="${demoTarget}/h2.zip" failonerror="false" />
		<delete file="${demoTarget}/binary_data.zip" failonerror="false" />
	</target>

	<target name="generateLocalPostgresLaunch">
		<createLaunch 
			filepath="${tempAppServerFolder}/runPostgresqlLocal.sh" 
			connection.id="postgresqlLocalhost" 
			serverport="8089" 
			launcher="${launcherJar}" />
	</target>

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

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

	<!-- *************************************************************** -->
	<!--   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 property="projectAndVersion" override="true" input="@{bundle}" regexp="[^${file.separator}]+$" select="\0" casesensitive="false" />
					<propertyregex property="projectName" override="true" input="${projectAndVersion}" 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>
					<echo file="@{configPath}/config.ini" message="${projectName}@start" append="true" />
					<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="isexecutable" 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
</echo>
			<if>
				<equals arg1="executable" arg2="true" />
				<then>
					<chmod file="@{filepath}" perm="ugo+rx" />
				</then>
			</if>
		</sequential>
	</macrodef>
</project>

Back to the top