git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113110 13f79535-47bb-0310-9956-ffa450edef68
487 lines
18 KiB
XML
487 lines
18 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<!--
|
|
=============================================================================
|
|
Cactus plugin for Maven.
|
|
=============================================================================
|
|
-->
|
|
<project xmlns:j="jelly:core"
|
|
xmlns:doc="doc"
|
|
xmlns:cactus="jelly:org.apache.maven.cactus.CactusTagLibrary" >
|
|
|
|
<!-- Import all the jelly scripts found in the plugin-resources/scripts
|
|
directory. They are jelly scripts to start/stop the different
|
|
containers. -->
|
|
|
|
<fileScanner var="scanner">
|
|
<fileset dir="${plugin.resources}/scripts/" includes="*.jelly"/>
|
|
</fileScanner>
|
|
|
|
<j:forEach var="script" items="${scanner.iterator()}">
|
|
<j:import inherit="true" file="${script.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">
|
|
|
|
<!-- this seems required to setup the plugin context -->
|
|
<attainGoal name="war:init"/>
|
|
|
|
<j:set var="maven.cactus.prewar.dir" value="${pom.getPluginContext('maven-war-plugin').getVariable('maven.war.build.dir')}"/>
|
|
|
|
<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"
|
|
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>
|
|
|
|
<!-- FIXME: The Merge was done in DVSL. I removed it, but haven't been able to duplicate it with JSL.
|
|
You need to provide a Cactus'ed web.xml to use.
|
|
-->
|
|
<j:set var="cactuscheckwebxml" value="${maven.cactus.webxml}X"/>
|
|
<j:choose>
|
|
<j:when test="${cactuscheckwebxml == 'X'}">
|
|
<echo message="You should provide in your project.properties a maven.cactus.webxml web.xml file to use. Using default web.xml"/>
|
|
<copy toFile="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/web.xml" overwrite="true"
|
|
file="${plugin.resources}/conf/web.xml"/>
|
|
</j:when>
|
|
<j:otherwise>
|
|
<copy toFile="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/web.xml" overwrite="true"
|
|
file="${maven.cactus.webxml}"/>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
|
|
|
|
|
|
</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="${plugin.resources}/conf/web/jspRedirector.jsp"/>
|
|
|
|
<!-- 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 only one Cactus test using the <junit> Ant task with the JUnit
|
|
Text Test Runner.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:test-text-single" 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"/>
|
|
<test name="${mavencactustestcase}"
|
|
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>
|
|
|
|
</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. By default, the test reports go into the
|
|
standard test reports directory. If you have at least one Junit Test
|
|
then when you run maven site it will convert them. Otherwise you must
|
|
call cactus:generate.
|
|
========================================================================
|
|
-->
|
|
|
|
<goal name="cactus:generate"
|
|
description="Generate HTML report">
|
|
|
|
<mkdir dir="${maven.cactus.test.reportsDirectory}"/>
|
|
|
|
<!-- Consolidate the reports into a single -->
|
|
<!-- based on junit report plugin -->
|
|
<junitreport todir="${maven.build.dir}">
|
|
<fileset dir="${maven.cactus.test.reportsDirectory}">
|
|
<include name="TEST-*.xml"/>
|
|
</fileset>
|
|
</junitreport>
|
|
|
|
<doc:jsl
|
|
input="${maven.build.dir}/TESTS-TestSuites.xml"
|
|
output="junit-report.xml"
|
|
stylesheet="${plugin.resources}/junit.jsl"
|
|
omitXmlDeclaration="true"
|
|
outputMode="xml"
|
|
prettyPrint="true"
|
|
/>
|
|
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Execute all Cactus tests using the 'maven.cactus.container'
|
|
variable.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:test"
|
|
description="Execute all testcases">
|
|
|
|
<j:set var="containerHomeX" value="${maven.cactus.tomcat4x.home}X"/>
|
|
<j:if test="${containerHomeX != 'X'}">
|
|
<echo message="Attempting to run tomcat4x target: cactus:test-tomcat-4x"/>
|
|
<attainGoal name="cactus:test-tomcat-4x"/>
|
|
</j:if>
|
|
|
|
<j:set var="containerHomeX" value="${maven.cactus.resin2x.home}X"/>
|
|
<j:if test="${containerHomeX != 'X'}">
|
|
<echo message="Attempting to run resin2x target: cactus:test-resin-2x"/>
|
|
<attainGoal name="cactus:test-resin-2x"/>
|
|
</j:if>
|
|
|
|
<j:set var="containerHomeX" value="${maven.cactus.weblogic7x.home}X"/>
|
|
<j:if test="${containerHomeX != 'X'}">
|
|
<echo message="Attempting to run weblogic7x target: cactus:test-weblogin-7x"/>
|
|
<attainGoal name="cactus:test-weblogic-7x"/>
|
|
</j:if>
|
|
|
|
</goal>
|
|
|
|
|
|
<!--
|
|
========================================================================
|
|
Execute a single Cactus test case defined using the 'Dmavencactustestcase'
|
|
variable.
|
|
========================================================================
|
|
-->
|
|
<goal name="cactus:single"
|
|
description="Execute a single test defined using the 'mavencactustestcase' variable">
|
|
<j:set var="testcaseX" value="${mavencactustestcase}X"/>
|
|
<j:choose>
|
|
<j:when test="${testcaseX == 'X'}">
|
|
<echo>
|
|
You must define the test case to run via -Dmavencactustestcase=classname
|
|
Example: maven -Dmavencactustestcase=MyTest cactus:single
|
|
</echo>
|
|
</j:when>
|
|
<j:otherwise>
|
|
|
|
<j:set var="maven.cactus.testrunner" value="text-single"/>
|
|
|
|
<attainGoal name="cactus:test"/>
|
|
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
</goal>
|
|
|
|
<!--
|
|
========================================================================
|
|
Goals to register the Cactus test reports should to be included in the
|
|
Maven reports and produce the reports.
|
|
========================================================================
|
|
-->
|
|
|
|
<goal name="maven-cactus-plugin:register">
|
|
<doc:registerReport
|
|
name="Cactus Test Results"
|
|
link=""
|
|
description="Report on the Cactus unit tests."/>
|
|
</goal>
|
|
|
|
<goal name="maven-cactus-plugin:report">
|
|
<!-- here will be code to generate the reports. Not sure what will happen yet. -->
|
|
|
|
</goal>
|
|
|
|
</project>
|