blob: 681c4659b7bf87895ba204758dfc19d09c854e28 [file] [log] [blame]
<!--/*******************************************************************************
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Ant naming conventions:
* - regardless of the actual OS platform,'/' is the directory separator
* (Ant will convert as appropriate).
* - multi-word properties use periods '.'
* - multi-word targets use hyphens '-'
* - multi-word macros use underscores '_'
* - multi-word macro attributes are concatenated
* e.g. 'runpathref'
* - multi-word tasks (taskdef) names are concatenated
* e.g. 'validateconnection'
* - OS environment variables are in ALLCAPS and have 'env' as a prefix
* e.g. ${env.XXX}.
* - Ant properties are lower case.
*
* Contributors:
* ??? - initial implementation
#******************************************************************************/-->
<!-- This ant project includes the following tasks:
- netweaver-setup : packs an application containing eclipselink.jar and other required libraries and deploys it to the server
- netweaver-reset : undeploys the application containing eclipselink.jar
- netweaver-deploy : adds NetWeaver specific resources and deploys ear
- netweaver-undeploy : undeploys ear
-->
<project name="Eclipse Persistence Services JPA NetWeaver Testing" basedir=".">
<!-- Allows a user to overide certain user specific properties. -->
<property file="${user.home}/netweaver.properties"/>
<property file="${jpatest.basedir}/netweaver.properties"/>
<property name="cpath" value="${netweaver.deployment.ant.dir}/tc~je~dc_ant.jar:
${netweaver.clientlib.dir}/sap.com~tc~exception~impl.jar:
${netweaver.clientlib.dir}/sap.com~tc~je~clientlib~impl.jar:
${netweaver.clientlib.dir}/sap.com~tc~logging~java~impl.jar:
${netweaver.deployment.dir}/lib/sap.com~tc~je~deployment14~impl.jar"/>
<taskdef name="sapdeploy" classname="com.sap.engine.services.dc.ant.deploy.SAPDeploy" classpath="${cpath}"/>
<taskdef name="sapundeploy" classname="com.sap.engine.services.dc.ant.undeploy.SAPUndeploy" classpath="${cpath}"/>
<condition property="netweaver.deployment.script.suffix" value="csh" else="${suffix}">
<and>
<isset property="is.unix"/>
<available file="${netweaver.deployment.dir}/scripts/make_SDA.csh"/>
</and>
</condition>
<echo message="suffix=${suffix}"/>
<macrodef name="make_sda">
<attribute name="source" />
<attribute name="target" />
<sequential>
<exec executable="${netweaver.deployment.dir}/scripts/make_SDA.${netweaver.deployment.script.suffix}" dir="${netweaver.deployment.dir}/scripts" failonerror="true">
<arg value="@{source}"/>
<arg value="-d"/>
<arg value="@{target}"/>
</exec>
</sequential>
</macrodef>
<target name="netweaver-install">
<echo message="*** build target netweaver-install - nothing done ***"/>
</target>
<target name="netweaver-start">
<echo message="*** build target netweaver-start - nothing done ***"/>
</target>
<target name="netweaver-setup">
<mkdir dir="${jpatest.basedir}/${build.dir}"/>
<dirname property="basedir" file="${jpatest.basedir}"/>
<!-- pack EAR file containing eclipselink.jar and other required libraries and convert it to SDA -->
<zip destfile="${jpatest.basedir}/${build.dir}/${netweaver.eclipselink.app}.ear">
<fileset dir="${eclipselink.home}" includes="eclipselink.jar"/>
<fileset file="${junit.lib}"/>
</zip>
<make_sda source="${basedir}/${build.dir}/${netweaver.eclipselink.app}.ear" target="${basedir}/${build.dir}/${netweaver.eclipselink.app}.sda" />
<!-- pack EAR file containing the test datasource and convert it to SDA -->
<copy overwrite="true" todir="${jpatest.basedir}/resource/${server.name}/setup/META-INF">
<fileset dir="${jpatest.basedir}/resource/${server.name}/templates/setup/META-INF" includes="*.*"/>
</copy>
<replace file="${jpatest.basedir}/resource/${server.name}/setup/META-INF/data-sources.xml" token='%%data-source-name%%' value="${netweaver.datasource.name}"/>
<replace file="${jpatest.basedir}/resource/${server.name}/setup/META-INF/data-sources.xml" token='%%driver-name%%' value="${netweaver.datasource.driver.deployname}"/>
<replace file="${jpatest.basedir}/resource/${server.name}/setup/META-INF/data-sources.xml" token='%%driver-class-name%%' value="${netweaver.datasource.driver.class}"/>
<replace file="${jpatest.basedir}/resource/${server.name}/setup/META-INF/data-sources.xml" token='%%url%%' value="${netweaver.datasource.url}"/>
<replace file="${jpatest.basedir}/resource/${server.name}/setup/META-INF/data-sources.xml" token='%%user-name%%' value="${netweaver.datasource.user}"/>
<replace file="${jpatest.basedir}/resource/${server.name}/setup/META-INF/data-sources.xml" token='%%password%%' value="${netweaver.datasource.password}"/>
<zip destfile="${jpatest.basedir}/${build.dir}/${netweaver.datasource.app}.ear">
<fileset dir="${jpatest.basedir}/resource/${server.name}/setup"/>
</zip>
<make_sda source="${basedir}/${build.dir}/${netweaver.datasource.app}.ear" target="${basedir}/${build.dir}/${netweaver.datasource.app}.sda" />
<!-- deploy the SDA -->
<sapdeploy versionrule="all">
<saperrorhandling erroraction="prerequisites" errorstrategy="stop"/>
<saperrorhandling erroraction="deploy" errorstrategy="stop"/>
<fileset dir="${build.dir}" includes="${netweaver.eclipselink.app}.sda,${netweaver.datasource.app}.sda"/>
<sapj2eeengine serverhost="${netweaver.host}" serverport="${netweaver.port}" username="${server.user}" userpassword="${server.pwd}"/>
</sapdeploy>
</target>
<target name="netweaver-reset">
<!-- undeploy the application containing eclipselink.jar -->
<copy overwrite="true" todir="${jpatest.basedir}/resource/${server.name}">
<fileset dir="${jpatest.basedir}/resource/${server.name}/templates/" includes="undeploy_eclipselink.txt"/>
</copy>
<replace file="${jpatest.basedir}/resource/${server.name}/undeploy_eclipselink.txt" token='%%eclipselink_app%%' value="${netweaver.eclipselink.app}"/>
<replace file="${jpatest.basedir}/resource/${server.name}/undeploy_eclipselink.txt" token='%%datasource_app%%' value="${netweaver.datasource.app}"/>
<sapundeploy undeploystrategy="IfDependingStop">
<saperrorhandling erroraction="prerequisites" errorstrategy="stop"/>
<saperrorhandling erroraction="undeploy" errorstrategy="stop"/>
<sapundeploylist listfilepath="${jpatest.basedir}/resource/${server.name}/undeploy_eclipselink.txt"/>
<sapj2eeengine serverhost="${netweaver.host}" serverport="${netweaver.port}" username="${server.user}" userpassword="${server.pwd}"/>
</sapundeploy>
</target>
<target name="netweaver-stop">
<echo message="*** build target netweaver-stop - nothing done ***"/>
</target>
<!-- add NetWeaver specific resources to the test application ear and deploy it to the server -->
<target name="netweaver-deploy">
<!-- add NetWeaver specific resources to the application EAR and convert it to SDA -->
<copy overwrite="true" todir="${jpatest.basedir}/resource/${server.name}/META-INF">
<fileset dir="${jpatest.basedir}/resource/${server.name}/templates/META-INF" includes="*.*"/>
</copy>
<replace dir="${jpatest.basedir}/resource/${server.name}/META-INF" token='%%eclipselinklib%%' value="${netweaver.eclipselink.app}"/>
<replace dir="${jpatest.basedir}/resource/${server.name}/META-INF" token='%%datasourcename%%' value="${netweaver.datasource.name}"/>
<ear destfile="${basedir}/${ear.name}" update="true">
<fileset dir="${jpatest.basedir}/resource/${server.name}" includes="META-INF/*.*"/>
</ear>
<dirname property="basedir" file="${jpatest.basedir}"/>
<echo message="ear.name=${ear.name}"/>
<echo message="application.name=${application.name}"/>
<make_sda source="${basedir}/${ear.name}" target="${basedir}/${build.dir}/${application.name}.sda"/>
<!-- deploy the SDA -->
<sapdeploy versionrule="all">
<saperrorhandling erroraction="prerequisites" errorstrategy="stop"/>
<saperrorhandling erroraction="deploy" errorstrategy="stop"/>
<fileset dir="${build.dir}" includes ="${application.name}.sda"/>
<sapj2eeengine serverhost="${netweaver.host}" serverport="${netweaver.port}" username="${server.user}" userpassword="${server.pwd}"/>
</sapdeploy>
</target>
<!-- undeploy the test application from the server -->
<target name="netweaver-undeploy">
<sapundeploy undeploystrategy="IfDependingStop">
<saperrorhandling erroraction="prerequisites" errorstrategy="stop"/>
<saperrorhandling erroraction="undeploy" errorstrategy="stop"/>
<sapundeploylist listfilepath="${jpatest.basedir}/resource/${server.name}/undeploy.txt"/>
<sapj2eeengine serverhost="${netweaver.host}" serverport="${netweaver.port}" username="${server.user}" userpassword="${server.pwd}"/>
</sapundeploy>
</target>
</project>