blob: 71deab19df050d916647953b36dd54b46bffaf36 [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.
*
* Contributors:
* Rick Curtis- initial API and implementation
#******************************************************************************/-->
<project name="eclipselink.jpa.test.jse" default="test" basedir=".">
<property name="jse.el.root" value="${basedir}/../.."/>
<property name="jse.jpa.root" value="${basedir}/.."/>
<property name="jse.src.dir" value="${basedir}/src"/>
<property name="jse.classes.dir" value="${basedir}/classes" />
<!-- Use common property name to allow override -->
<property name="reports.dir" value="${basedir}/reports" />
<property name="jse.el.plugins.dir" value="${jse.el.root}/plugins"/>
<property name="jse.jpa.plugins.dir" value="${jse.jpa.root}/plugins"/>
<!-- Not sure if there is a better way to refer to dependencies? -->
<property name="jse.eclipselink.jar" value="${jse.el.root}/eclipselink.jar"/>
<property name="javax.transaction" value="${jse.el.plugins.dir}/javax.transaction_1.1.0.v201002051055.jar"/>
<property name="javax.validation" value="${jse.el.plugins.dir}/javax.validation.api_2.0.1.Final.jar"/>
<property name="javax.persistence" value="${jse.jpa.plugins.dir}/javax.persistence_2.2.0.v201708071007.jar"/>
<property file="${user.home}/build.properties"/>
<property file="${test.properties}" />
<property file="./antbuild.properties" />
<property file="./test.properties" />
<!-- JVM used to run tests -->
<property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
<property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
<path id="compile.jse.path">
<pathelement path="${jse.el.root}/eclipselink.jar" />
<pathelement path="${javax.transaction}" />
<pathelement path="${javax.validation}" />
<pathelement path="${javax.persistence}" />
<pathelement path="${junit.lib}" />
</path>
<path id="run.jse.path">
<pathelement path="${jse.classes.dir}" />
<pathelement path="${jse.eclipselink.jar}" />
<pathelement path="${javax.transaction}" />
<pathelement path="${javax.validation}" />
<pathelement path="${javax.persistence}" />
<pathelement path="${junit.lib}" />
<pathelement path="${jdbc.driver.jar}" />
</path>
<pathconvert property="jse.compile.cp" refid="compile.jse.path"/>
<pathconvert property="jse.run.cp" refid="run.jse.path"/>
<echo message="jse.el.root = ${jse.el.root}"/>
<echo message="jse.jpa.root = ${jse.jpa.root}"/>
<echo message="jse.eclipselink.jar = ${jse.eclipselink.jar}"/>
<echo message="jse.classes.dir = ${jse.classes.dir}"/>
<echo message="jse.src.dir = ${jse.src.dir}"/>
<echo message="compile classpath = ${jse.compile.cp}"/>
<echo message="run classpath = ${jse.run.cp}"/>
<echo message="report dir = ${reports.dir}"/>
<echo message="basedir = ${basedir}"/>
<echo message="junitlib = ${junit.lib}"/>
<echo message="jse.run.cp = ${jse.run.cp}"/>
<target name="test-no-report" depends="test-run"/>
<target name="test" depends="test-run, test-report"/>
<target name="test-run" depends="compile, weave">
<mkdir dir="${reports.dir}"/>
<property name="rmi.port" value="1099"/>
<property name="additional.jvmargs" value="-Ddummy2=dummy"/>
<property name="debugargs" value="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7777"/>
<property name="rmi" value="-Djava.naming.provider.url=rmi://localhost:${rmi.port} -Djava.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory"/>
<junit jvm="${test.junit.jvm.exec}" printsummary="on" haltonfailure="false" failureproperty="fail" fork="yes" dir="${jse.classes.dir}" forkmode="once">
<jvmarg line="${additional.jvmargs} ${rmi}"/>
<sysproperty key="javax.persistence.jdbc.url" value="${db.url}"/>
<sysproperty key="javax.persistence.jdbc.driver" value="${db.driver}"/>
<sysproperty key="javax.persistence.jdbc.user" value="${db.user}"/>
<sysproperty key="javax.persistence.jdbc.password" value="${db.pwd}"/>
<sysproperty key="rmi.port" value="${rmi.port}"/>
<classpath>
<path refid="run.jse.path" />
</classpath>
<formatter type="xml"/>
<batchtest todir="${reports.dir}">
<fileset dir="${jse.src.dir}">
<include name="**/Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="test-report">
<junitreport todir="./reports">
<fileset dir="./reports">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="./reports/html"/>
</junitreport>
<echo message="JUNIT results in ${user.dir}/reports/html"/>
<fail if="fail" message="Test failures detected, please check the results."/>
</target>
<!--
Ideally we could do something smart here to have different weaving targets to weave with different properties.
We can cross that bridge when / if it is needed.
-->
<target name="weave">
<weave source="${jse.classes.dir}" target="${jse.classes.dir}" loglevel="WARNING">
<classpath>
<path refid="compile.jse.path" />
</classpath>
</weave>
</target>
<target name="compile">
<mkdir dir="${jse.classes.dir}"/>
<copy todir="${jse.classes.dir}/META-INF">
<fileset dir="${jse.src.dir}/META-INF" includes="**/*" excludes=".git*"/>
</copy>
<javac debug="true" destdir="${jse.classes.dir}" includeantruntime="false" source="${javac.version}" target="${javac.version}">
<classpath refid="compile.jse.path"/>
<src path="src"/>
</javac>
</target>
<target name="clean">
<delete dir="${jse.classes.dir}" />
<delete dir="${reports.dir}" />
</target>
<taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask">
<classpath>
<path refid="compile.jse.path" />
</classpath>
</taskdef>
</project>