git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@112757 13f79535-47bb-0310-9956-ffa450edef68
390 lines
14 KiB
XML
390 lines
14 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<!--
|
|
=============================================================================
|
|
Cactus plugin for Maven.
|
|
=============================================================================
|
|
-->
|
|
<project xmlns:j="jelly:core" xmlns:dvsl="dvsl"
|
|
xmlns:cactus="jelly:org.apache.maven.cactus.CactusTagLibrary">
|
|
|
|
<!-- Import all the jelly scripts found in the maven.cactus.conf.dir
|
|
directory. They are jelly scripts to start/stop the different
|
|
containers. -->
|
|
<fileScanner var="scanner">
|
|
<fileset dir="${maven.cactus.scripts.dir}" includes="*.jelly"/>
|
|
</fileScanner>
|
|
|
|
<j:forEach var="script" items="${scanner.iterator()}">
|
|
<j:import inherit="true" uri="${script.toURL().toString()}"/>
|
|
</j:forEach>
|
|
|
|
<!--
|
|
========================================================================
|
|
Initialization. Creates objects useful for several goals.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:init" description="Creates objects useful for several goals">
|
|
|
|
<taskdef name="junit"
|
|
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
|
|
|
|
<!-- Classpath containing all Cactus jars that are needed on Cactus
|
|
client side -->
|
|
<path id="cactus.classpath.clientside">
|
|
<path refid="maven.dependency.classpath"/>
|
|
<pathelement location="${maven.build.dest}"/>
|
|
<pathelement location="${maven.cactus.classes.dir}"/>
|
|
<pathelement location="${maven.cactus.build.resources.dir}"/>
|
|
<pathelement path="${plugin.getDependencyPath('junit')}"/>
|
|
<pathelement path="${plugin.getDependencyPath('cactus:cactus')}"/>
|
|
<pathelement path="${plugin.getDependencyPath('commons-httpclient')}"/>
|
|
<pathelement path="${plugin.getDependencyPath('commons-logging')}"/>
|
|
<pathelement path="${plugin.getDependencyPath('aspectj:aspectjrt')}"/>
|
|
<pathElement path="${plugin.getDependencyPath('httpunit')}"/>
|
|
<pathElement path="${plugin.getDependencyPath('nekohtml')}"/>
|
|
<!-- These 2 jars should not be needed but it won't work without
|
|
them -->
|
|
<pathelement path="${plugin.getDependencyPath('xml-apis')}"/>
|
|
<pathelement path="${plugin.getDependencyPath('xerces')}"/>
|
|
</path>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Compile Cactus tests.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:compile" prereqs="java:compile"
|
|
description="Compile Cactus tests">
|
|
|
|
<mkdir dir="${maven.cactus.build.dir}"/>
|
|
<mkdir dir="${maven.cactus.classes.dir}"/>
|
|
|
|
<javac
|
|
destdir="${maven.cactus.classes.dir}"
|
|
excludes="**/package.html"
|
|
debug="${maven.compile.debug}"
|
|
deprecation="${maven.compile.deprecation}"
|
|
optimize="${maven.compile.optimize}">
|
|
<classpath>
|
|
<pathelement path="${maven.build.dest}"/>
|
|
<path refid="maven.dependency.classpath"/>
|
|
<pathelement path="${plugin.getDependencyPath('cactus:cactus')}"/>
|
|
<pathelement path="${plugin.getDependencyPath('junit')}"/>
|
|
<pathElement path="${plugin.getDependencyPath('httpunit')}"/>
|
|
</classpath>
|
|
<src>
|
|
<path location="${maven.cactus.src.dir}"/>
|
|
</src>
|
|
</javac>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Create the Cactus webapp (i.e. add Cactus related jars/config/test
|
|
classes to either the project war or the project webapp).
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:webapp" description="Create the Cactus webapp">
|
|
|
|
<available file="${maven.cactus.prewar.dir}/${pom.artifactId}.war"
|
|
property="maven.cactus.prewar.exists"/>
|
|
|
|
<j:choose>
|
|
|
|
<j:when test="${maven.cactus.prewar.exists}">
|
|
|
|
<!-- Expand the project war -->
|
|
<unwar src="${maven.cactus.prewar.dir}/${pom.artifactId}.war"
|
|
dest="${maven.cactus.build.dir}/${pom.artifactId}"/>
|
|
<attainGoal name="cactus:webapp-update"/>
|
|
|
|
</j:when>
|
|
|
|
<j:otherwise>
|
|
|
|
<available file="${maven.cactus.prewar.dir}/${pom.artifactId}/WEB-INF"
|
|
type="dir" property="maven.cactus.prewebapp.exists"/>
|
|
|
|
<j:choose>
|
|
<j:when test="${maven.cactus.prewebapp.exists}">
|
|
|
|
<copy todir="${maven.cactus.build.dir}/${pom.artifactId}">
|
|
<fileset dir="${maven.cactus.prewar.dir}/${pom.artifactId}"/>
|
|
</copy>
|
|
<attainGoal name="cactus:webapp-update"/>
|
|
|
|
</j:when>
|
|
<j:otherwise>
|
|
<echo>
|
|
Either a war or a webapp must exist. Please call the War plugin
|
|
first.
|
|
</echo>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Generate a web.xml which is the merge betweem the user project web.xml
|
|
and the webapp elements needed by Cactus.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:merge-webxml" prereqs="init-dvsl-tag"
|
|
description="Generate a web.xml which is the merge betweem the user project web.xml and the webapp elements needed by Cactus">
|
|
|
|
<j:set var="warWebXml"
|
|
value="${pom.getPluginContext('maven-war-plugin').getVariable('maven.war.webxml')}"/>
|
|
|
|
<available file="${warWebXml}"
|
|
property="maven.cactus.webxml.exists"/>
|
|
|
|
<j:choose>
|
|
<j:when test="${maven.cactus.webxml.exists}">
|
|
<j:set var="webxml" value="${warWebXml}"/>
|
|
</j:when>
|
|
<j:otherwise>
|
|
<j:set var="webxml" value="${maven.cactus.emptywebxml}"/>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
<dvsl:dvsl
|
|
basedir="${basedir}"
|
|
style="${maven.cactus.webxml.dvsl}"
|
|
toolboxFile="${plugin.dir}/toolbox.props"
|
|
in="${webxml}"
|
|
out="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/web.xml">
|
|
</dvsl:dvsl>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Generate an expanded Cactus webapp from a project expanded webapp.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:webapp-update" prereqs="cactus:compile"
|
|
description="Generate an expanded Cactus webapp from a project expanded webapp">
|
|
|
|
<!-- Copy Cactus configuration files -->
|
|
<copy todir="${maven.cactus.build.dir}/${pom.artifactId}"
|
|
file="${maven.cactus.jspRedirector}"/>
|
|
|
|
<!-- Create the web.xml which is result of merging the project web.xml
|
|
and the elements needed by Cactus -->
|
|
<attainGoal name="cactus:merge-webxml"/>
|
|
|
|
<!-- Copy Cactus jars -->
|
|
<copy todir="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/lib"
|
|
file="${plugin.getDependencyPath('cactus:cactus')}"/>
|
|
<copy todir="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/lib"
|
|
file="${plugin.getDependencyPath('aspectj:aspectjrt')}"/>
|
|
<copy todir="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/lib"
|
|
file="${plugin.getDependencyPath('commons-logging')}"/>
|
|
<copy todir="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/lib"
|
|
file="${plugin.getDependencyPath('junit')}"/>
|
|
<copy todir="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/lib"
|
|
file="${plugin.getDependencyPath('httpunit')}"/>
|
|
|
|
<!-- Copy Cactus tests -->
|
|
<copy todir="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/classes">
|
|
<fileset dir="${maven.cactus.classes.dir}"/>
|
|
</copy>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Test initialization.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:test-init" description="Test initialization">
|
|
|
|
<path id="cactus.scanner.classpath">
|
|
<path refid="maven.dependency.classpath"/>
|
|
<pathElement location="${maven.build.dest}"/>
|
|
<pathElement location="${maven.cactus.classes.dir}"/>
|
|
<pathElement location="${plugin.getDependencyPath('cactus:cactus')}"/>
|
|
<pathElement location="${plugin.getDependencyPath('commons-logging')}"/>
|
|
<pathElement location="${plugin.getDependencyPath('junit')}"/>
|
|
<pathElement location="${plugin.getDependencyPath('commons-httpclient')}"/>
|
|
<pathElement location="${plugin.getDependencyPath('aspectj:aspectjrt')}"/>
|
|
<pathElement location="${plugin.getDependencyPath('httpunit')}"/>
|
|
<pathElement location="${plugin.getDependencyPath('nekohtml')}"/>
|
|
<j:forEach var="lib" items="${pom.dependencies}">
|
|
<pathElement location="${maven.repo.local}/${lib.artifactDirectory}/jars/${lib.artifact}"/>
|
|
</j:forEach>
|
|
</path>
|
|
|
|
<cactus:scanner var="cactusScanner" classpathref="cactus.scanner.classpath">
|
|
<fileset dir="${maven.cactus.classes.dir}">
|
|
<include name="${maven.cactus.test.fileset.include}"/>
|
|
<exclude name="${maven.cactus.test.fileset.exclude}"/>
|
|
</fileset>
|
|
</cactus:scanner>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Start the Cactus tests using the <junit> Ant task with the JUnit
|
|
Text Test Runner.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:test-text" prereqs="cactus:test-init,cactus:init"
|
|
description="Start the tests using the text runner">
|
|
|
|
<mkdir dir="${maven.cactus.test.reportsDirectory}"/>
|
|
<mkdir dir="${maven.cactus.build.resources.dir}"/>
|
|
|
|
<copy todir="${maven.cactus.build.resources.dir}"
|
|
file="${maven.cactus.configFile}" filtering="on">
|
|
<filterset>
|
|
<filter token="maven.cactus.port" value="${maven.cactus.port}"/>
|
|
</filterset>
|
|
</copy>
|
|
|
|
<junit printSummary="yes" fork="true" dir="${basedir}"
|
|
failureProperty="maven.cactus.test.failure">
|
|
|
|
<formatter type="xml"/>
|
|
<formatter type="plain" usefile="${maven.cactus.junit.usefile}"/>
|
|
<classpath refid="cactus.classpath.clientside"/>
|
|
|
|
<j:forEach var="test" items="${cactusScanner.iterator()}">
|
|
<test name="${test}" todir="${maven.cactus.test.reportsDirectory}"/>
|
|
</j:forEach>
|
|
|
|
</junit>
|
|
|
|
<j:if test="${maven.cactus.test.failure}">
|
|
<j:set var="cactusignore__" value="${maven.cactus.test.failure.ignore}X"/>
|
|
<j:if test="${cactusignore__ == 'X'}">
|
|
<fail message="There were test failures."/>
|
|
</j:if>
|
|
</j:if>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Start the Cactus tests using the <junit> Ant task with the JUnit
|
|
Swing Test Runner.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:test-swing" prereqs="cactus:test-init,cactus:init"
|
|
description="Start the tests using the swing runner">
|
|
|
|
<mkdir dir="${maven.cactus.build.resources.dir}"/>
|
|
|
|
<copy todir="${maven.cactus.build.resources.dir}"
|
|
file="${maven.cactus.configFile}" filtering="on">
|
|
<filterset>
|
|
<filter token="maven.cactus.port" value="${maven.cactus.port}"/>
|
|
</filterset>
|
|
</copy>
|
|
|
|
<!-- Copy the JUnit excluded.properties - This is needed because the
|
|
the Commons logging package need to be excluded from being loaded
|
|
by the special JUnit classloader. Otherwise, it fails. -->
|
|
<copy todir="${maven.cactus.build.resources.dir}/junit/runner"
|
|
file="${maven.cactus.testrunner.swing.excluded}"/>
|
|
|
|
<java classname="junit.swingui.TestRunner" fork="true" dir="${basedir}">
|
|
|
|
<j:forEach var="test" items="${cactusScanner.iterator()}">
|
|
<jvmarg value="-Dmaven.cactus.test.${test}"/>
|
|
</j:forEach>
|
|
<arg line="org.apache.maven.cactus.DynamicTestAll"/>
|
|
|
|
<classpath>
|
|
<path refid="cactus.classpath.clientside"/>
|
|
<pathelement location="${plugin.dir}"/>
|
|
</classpath>
|
|
</java>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Generate Cactus test report (xdoc format). Run maven xdoc:transform
|
|
to then transform into HTML.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:generate" prereqs="init-dvsl-tag"
|
|
description="Generate HTML report">
|
|
|
|
<mkdir dir="${maven.cactus.test.reportsDirectory}"/>
|
|
|
|
<!-- Consolidate the reports into a single -->
|
|
<junitreport todir="${maven.cactus.test.reportsDirectory}">
|
|
<fileset dir="${maven.cactus.test.reportsDirectory}">
|
|
<include name="TEST-*.xml"/>
|
|
</fileset>
|
|
</junitreport>
|
|
|
|
<!-- Convert single report into an xdoc -->
|
|
<dvsl:dvsl
|
|
basedir="${basedir}"
|
|
style="${plugin.dir}/cactus.dvsl"
|
|
toolboxFile="${plugin.dir}/toolbox.props"
|
|
in="${maven.cactus.test.reportsDirectory}/TESTS-TestSuites.xml"
|
|
out="${maven.gen.docs}/cactus-report.xml">
|
|
</dvsl:dvsl>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Execute a single Cactus test case defined using the 'testcase'
|
|
variable.
|
|
|
|
NOTE: This assumes that the server was already started and that the
|
|
Cactus war has already been deployed.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:single" prereqs="war:war,cactus:compile,cactus:init"
|
|
description="Execute a single test defined using the 'testcase' variable">
|
|
|
|
<j:choose>
|
|
<j:when test="${empty(testcase)}">
|
|
<echo>
|
|
You must define the test case to run via -Dtestcase=classname
|
|
Example: maven -Dtestcase=MyTest cactus:single
|
|
</echo>
|
|
</j:when>
|
|
<j:otherwise>
|
|
|
|
<junit printSummary="yes" fork="true" dir="${basedir}"
|
|
failureProperty="maven.cactus.test.failure">
|
|
|
|
<formatter type="xml"/>
|
|
<formatter type="plain" usefile="${maven.cactus.junit.usefile}"/>
|
|
<classpath refid="cactus.classpath.clientside"/>
|
|
<test name="${testcase}"
|
|
todir="${maven.cactus.test.reportsDirectory}"/>
|
|
|
|
</junit>
|
|
|
|
<j:if test="${maven.cactus.test.failure}">
|
|
<j:set var="cactusignore__"
|
|
value="${maven.cactus.test.failure.ignore}X"/>
|
|
<j:if test="${cactusignore__ == 'X'}">
|
|
<fail message="There were test failures."/>
|
|
</j:if>
|
|
</j:if>
|
|
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
</goal>
|
|
|
|
</project>
|