You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by pt...@apache.org on 2008/03/05 23:02:17 UTC
svn commit: r634045 [2/3] - in /jakarta/cactus/trunk/integration/maven: ./
src/plugin-test/ src/plugin-test/testCactusSysProperties/
src/plugin-test/testCactusSysProperties/src/test-cactus/org/apache/cactus/integration/maven/test/
Modified: jakarta/cactus/trunk/integration/maven/plugin.jelly
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/maven/plugin.jelly?rev=634045&r1=634044&r2=634045&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/maven/plugin.jelly (original)
+++ jakarta/cactus/trunk/integration/maven/plugin.jelly Wed Mar 5 14:02:16 2008
@@ -1,1152 +1,1246 @@
-<?xml version="1.0"?>
-
-<!--
- =============================================================================
- Cactus plugin for Maven. It uses the Cactus/Ant Integration from the
- Cactus project.
- =============================================================================
--->
-
-<!--
- Note: There is significant refactoring required for the goals cactus:test,
- cactus:single, and cactus:match. The <cactus> tasks in each of those goals
- are mostly similar.
--->
-<project
- xmlns:j="jelly:core"
- xmlns:doc="doc"
- xmlns:util="jelly:util"
- xmlns:ant="jelly:ant"
- xmlns:define="jelly:define"
- xmlns:x="jelly:xml"
- xmlns:maven="jelly:maven"
- xmlns:test="test"
- xmlns:ear="ear"
- xmlns:cactustag="cactus"
- xmlns:cactus="jelly:org.apache.cactus.integration.maven.CactusTagLibrary">
-
-
- <!--
- ========================================================================
- Default goal.
- ========================================================================
- -->
- <goal name="cactus" description="Run all Cactus tests"
- prereqs="cactus:test"/>
-
- <!--
- ========================================================================
- Verify that the installed Maven has compatible versions of dependent
- plugins.
- ========================================================================
- -->
- <goal name="cactus:check-plugin-dependencies">
-
- <maven:get plugin="maven-war-plugin" property="plugin" var="warPlugin" />
- <j:if test="${warPlugin.currentVersion.compareTo('1.6.1') lt 0}">
- <ant:fail>
- Must have WAR plugin v1.6.1 or greater installed to use this version of the Cactus plugin.
- Try: maven plugin:download -DgroupId=maven -DartifactId=maven-war-plugin -Dversion=[version]
- </ant:fail>
- </j:if>
-
- <maven:get plugin="maven-ejb-plugin" property="plugin" var="ejbPlugin" />
- <j:if test="${warPlugin.currentVersion.compareTo('1.6') lt 0}">
- <ant:fail>
- Must have EJB plugin v1.6 or greater installed to use this version of the Cactus plugin.
- Try: maven plugin:download -DgroupId=maven -DartifactId=maven-ejb-plugin -Dversion=[version]
- </ant:fail>
- </j:if>
-
- <maven:get plugin="maven-ear-plugin" property="plugin" var="earPlugin" />
- <j:if test="${earPlugin.currentVersion.compareTo('1.6.1') lt 0}">
- <ant:fail>
- Must have EAR plugin v1.6.1 or greater installed to use this version of the Cactus plugin.
- Try: maven plugin:download -DgroupId=maven -DartifactId=maven-ear-plugin -Dversion=[version]
- </ant:fail>
- </j:if>
-
- </goal>
-
- <!--
- ========================================================================
- Initializations.
- ========================================================================
- -->
- <goal name="cactus:init" prereqs="cactus:check-plugin-dependencies">
-
- <!-- Compute the default location of the input war file to cactify -->
- <maven:get var="warBuildDir" plugin="maven-war-plugin" property="maven.war.build.dir"/>
- <maven:get var="warFinalName" plugin="maven-war-plugin" property="maven.war.final.name"/>
- <maven:property var="cactus.src.war" name="cactus.src.war"
- defaultValue="${warBuildDir}/${warFinalName}"/>
-
- <!-- Compute the default location of the input EJB file to cactify -->
- <maven:get var="ejbBuildDir" plugin="maven-ejb-plugin" property="maven.ejb.build.dir"/>
- <maven:get var="ejbFinalName" plugin="maven-ejb-plugin" property="maven.ejb.final.name"/>
- <maven:property var="cactus.src.ejb" name="cactus.src.ejb"
- defaultValue="${ejbBuildDir}/${ejbFinalName}"/>
-
- <!-- Not sure why but this is needed, otherwise the taskdefs below fail -->
- <!-- DEPRECATION: Should now use <maven:get>/<maven:set> instead. Once
- everyone has moved to Maven 1.0 final, we should make the change -->
- <test:dependency-handle/>
-
- <ant:path id="cactus.classpath">
- <ant:pathelement location="${plugin.getDependencyPath('org.apache.cactus:cactus.core.framework.uberjar.javaEE.14')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('org.apache.cactus:cactus.integration.ant')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('org.apache.cactus:cactus.integration.shared.api')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('commons-logging:commons-logging')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('junit:junit')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('commons-httpclient:commons-httpclient')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('aspectj:aspectjrt')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('httpunit:httpunit')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('htmlunit:htmlunit')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('nekohtml:nekohtml')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('xerces:xerces')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('xml-apis:xml-apis')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('rhino:js')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('org.codehaus.cargo:cargo-core-uberjar')}"/>
- <ant:pathelement location="${plugin.getDependencyPath('org.codehaus.cargo:cargo-ant')}"/>
-
-
- </ant:path>
-
- <ant:taskdef resource="cactus.tasks" classpathref="cactus.classpath"/>
- <ant:taskdef resource="cargo.tasks" classpathref="cactus.classpath"/>
-
- <ant:taskdef name="junit"
- classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
-
- <ant:property name="cactus.target.classes.dir"
- value="${maven.build.dir}/test-cactus-classes"/>
-
- <!-- Destination locations for the build -->
- <property name="target.dir" location="target"/>
- <property name="target.classes.dir" location="${target.dir}/classes"/>
- <property name="target.classes.java.dir"
- location="${target.classes.dir}/java"/>
- <property name="target.classes.cactus.dir"
- location="${target.classes.dir}/cactus"/>
- <property name="target.testreports.dir"
- location="${target.dir}/test-reports"/>
-
-
-
- <util:available file="${cactus.src.dir}">
- <j:set var="cactusSourcePresent" value="true"/>
- <ant:path id="cactus.compile.src.set">
- <ant:pathelement location="${cactus.src.dir}"/>
- </ant:path>
- </util:available>
-
- <!-- The Cactus scanner automatically discovers Cactus tests -->
-
- <ant:path id="cactus.scanner.classpath">
- <ant:pathElement location="${maven.build.dest}"/>
- <ant:pathElement location="${cactus.target.classes.dir}"/>
- <ant:path refid="maven.dependency.classpath"/>
- <ant:path refid="cactus.classpath"/>
- </ant:path>
-
- <ant:dirname property="cactus.war.dir" file="${cactus.war}"/>
- <ant:basename property="cactus.war.name" file="${cactus.war}"/>
-
- <ant:dirname property="cactus.ejb.dir" file="${cactus.src.ejb}"/>
- <ant:basename property="cactus.ejb.name" file="${cactus.src.ejb}"/>
-
- <!-- List of supported containers -->
- <!--<j:set var="cargo.containers"
- value="resin2x,resin3x,tomcat3x,tomcat4x,tomcat5x,orion1x,orion2x,jboss3x,weblogic7x"/>-->
- <!--util:tokenize var="cargo.containers" delim="," trim="true">${cargo.containersa}</util:tokenize-->
-
-
-
- </goal>
-
- <!--
- ========================================================================
- Preparations for executing the JUnit reports
- ========================================================================
- -->
- <goal name="cactus:init-report">
-
- <!-- Prepare the directories for the JUnit reports -->
- <ant:mkdir dir="${cactus.reports.dir}"/>
- <j:forEach var="containerId" items="${cargo.containers}">
- <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
- <j:set var="containerHome" value="${context.getVariable(containerDirVar)}"/>
-
- <j:if test="${containerHome != null and !containerHome.trim().equals('')}">
- <ant:mkdir dir="${cactus.reports.dir}/${containerId}"/>
- </j:if>
- </j:forEach>
-
-
- </goal>
-
- <!--
- ========================================================================
- Compiles the Cactus tests.
- ========================================================================
- -->
- <goal name="cactus:compile" prereqs="cactus:init,java:compile"
- description="Compiles the Cactus tests">
-
- <ant:mkdir dir="${cactus.target.classes.dir}"/>
-
- <j:choose>
- <j:when test="${cactusSourcePresent == 'true'}">
-
- <ant:javac destdir="${cactus.target.classes.dir}"
- excludes="**/package.html"
- debug="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.debug')}"
- deprecation="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.deprecation')}"
- optimize="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.optimize')}">
-
- <ant:src>
- <ant:path refid="cactus.compile.src.set"/>
- </ant:src>
-
- <ant:classpath>
- <ant:path refid="maven.dependency.classpath"/>
- <ant:path refid="cactus.classpath"/>
- <ant:pathelement path="${maven.build.dest}"/>
- </ant:classpath>
-
- <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.compilerargs') != null}">
- <ant:compilerarg line="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.compilerargs')}"/>
- </j:if>
-
- <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.encoding') != null}">
- <ant:setProperty name="encoding" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.encoding')}"/>
- </j:if>
-
- <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.executable') != null}">
- <ant:setProperty name="executable" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.executable')}"/>
- </j:if>
-
- <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.fork') != null}">
- <ant:setProperty name="fork" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.fork')}"/>
- </j:if>
-
- <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.source') != null}">
- <ant:setProperty name="source" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.source')}"/>
- </j:if>
-
- <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.target') != null}">
- <ant:setProperty name="target" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.target')}"/>
- </j:if>
-
- <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.verbose') != null}">
- <ant:setProperty name="verbose" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.verbose')}"/>
- </j:if>
- </ant:javac>
-
- <!-- Copy non java source files -->
- <ant:copy todir="${cactus.target.classes.dir}">
- <ant:fileset dir="${cactus.src.dir}">
- <ant:exclude name="**/*.java"/>
- <ant:exclude name="**/*.html"/>
- </ant:fileset>
- </ant:copy>
-
- </j:when>
- <j:otherwise>
- <ant:echo>No Cactus source files to compile.</ant:echo>
- </j:otherwise>
- </j:choose>
-
- </goal>
-
- <!--
- ========================================================================
- Generate a jar containing Cactus tests classes.
- ========================================================================
- -->
- <goal name="cactus:jar" prereqs="cactus:compile"
- description="Generate a Cactus jar">
-
- <ant:jar
- jarfile="${maven.build.dir}/${pom.artifactId}-cactus-${pom.currentVersion}.jar"
- basedir="${cactus.target.classes.dir}">
- <ant:manifest>
- <ant:attribute name="Built-By" value="${user.name}"/>
- <ant:attribute name="Created-By" value="Apache Jakarta Maven"/>
- <ant:attribute name="Package" value="${pom.package}"/>
- <ant:attribute name="Build-Jdk" value="${java.version}"/>
- <ant:attribute name="Extension-Name" value="${pom.artifactId}"/>
- <ant:attribute name="Specification-Version" value="${pom.specificationVersion}"/>
- <ant:attribute name="Specification-Vendor" value="${pom.organization.name}"/>
- <ant:attribute name="Specification-Title" value="${pom.shortDescription}"/>
- <ant:attribute name="Implementation-Version" value="${pom.currentVersion}"/>
- <ant:attribute name="Implementation-Vendor" value="${pom.organization.name}"/>
- <ant:attribute name="Implementation-Vendor-Id" value="${pom.organization.identifier}"/>
- </ant:manifest>
- </ant:jar>
-
- </goal>
-
- <!--
- ========================================================================
- Cactify an application war.
- ========================================================================
- -->
- <goal name="cactus:cactifywar" prereqs="cactus:compile"
- description="Cactify the application war">
-
- <!-- Generate the war artifact -->
- <attainGoal name="${cactus.build.goal.war}"/>
- <cactifywar version="${cactus.servlet.version}" destfile="${cactus.war}">
-
- <!-- Only specify a source war to cactify if we are not testing EJBs.
- The reason is to prevent adding EJB sources to the cactified war,
- which can lead to problems on some containers as the EJB classes
- will be present both in the cactified war and in the ejb-jar. -->
- <j:if test="${!isEjbProject}">
- <ant:setProperty name="srcfile" value="${cactus.src.war}"/>
- </j:if>
-
- <!-- Add the mergewebxml attribute if it has been defined by the
- user -->
- <j:if test="${context.getVariable('cactus.src.mergewebxml') != null}">
- <ant:setProperty name="mergewebxml" value="${cactus.src.mergewebxml}"/>
- </j:if>
-
- <ant:classes dir="${cactus.target.classes.dir}"/>
-
- <!-- Orion fails on a servlet filter that is not mapped to an actual
- resource, to trick it -->
- <filterredirector mapping="/test/filterRedirector.jsp"/>
-
- <!-- Files needed for JBoss -->
- <ant:classes dir="${plugin.resources}/jboss3x">
- <ant:include name="*.properties" if="cactus.home.jboss3x"/>
- </ant:classes>
- <ant:webinf dir="${plugin.resources}/jboss3x">
- <ant:include name="jboss-web.xml" if="cactus.home.jboss3x"/>
- </ant:webinf>
-
- <!-- Add all cactus related jars to the WEB-INF/lib dir. By default
- the CactifyWarTask only adds the pure Cactus jars but not
- related jars such as HttpUnit jars -->
- <lib file="${plugin.getDependencyPath('httpunit:httpunit')}"/>
-
- <!-- Add all user jars that have been marked to be included in the cactus
- test. For example, DBUnit would be a jar you would include in a
- Cactus test but not in a runtime war -->
- <j:forEach var="artifact" items="${pom.artifacts}">
- <j:set var="dep" value="${artifact.dependency}"/>
- <j:if test="${dep.getProperty('cactus.bundle')=='true'}">
- <lib file="${artifact.path}"/>
- </j:if>
- </j:forEach>
-
- <!-- Add cactus resources to the classes included in the war -->
- <util:tokenize var="resourcesList" delim=",">${cactus.resources.dirs}</util:tokenize>
- <j:forEach var="resourcesLabel" items="${resourcesList}">
- <j:set var="resourcesDirVarName"
- value="cactus.resources.${resourcesLabel}.dir"/>
- <j:choose>
- <j:when test="${context.getVariable(resourcesDirVarName) != null}">
- <j:set var="includesVarName"
- value="cactus.resources.${resourcesLabel}.includes"/>
- <j:choose>
- <j:when test="${context.getVariable(includesVarName) != null}">
- <j:set var="includes"
- value="${context.getVariable(includesVarName)}"/>
- </j:when>
- <j:otherwise>
- <j:set var="includes"
- value="**/*"/>
- </j:otherwise>
- </j:choose>
- <j:set var="excludesVarName"
- value="cactus.resources.${resourcesLabel}.excludes"/>
- <j:choose>
- <j:when test="${context.getVariable(excludesVarName) != null}">
- <j:set var="excludes"
- value="${context.getVariable(excludesVarName)}"/>
- </j:when>
- <j:otherwise>
- <j:set var="excludes"
- value=""/>
- </j:otherwise>
- </j:choose>
-
- <util:file var="resourceFile"
- name="${context.getVariable(resourcesDirVarName)}/"/>
- <j:choose>
- <j:when test="${resourceFile.exists() and resourceFile.isDirectory()}">
- <ant:classes dir="${context.getVariable(resourcesDirVarName)}">
- <ant:include name="${includes}"/>
- <ant:exclude name="${excludes}"/>
- </ant:classes>
- </j:when>
- <j:otherwise>
- <ant:echo>Skipping invalid directory ${context.getVariable(resourcesDirVarName)}.</ant:echo>
- </j:otherwise>
- </j:choose>
- </j:when>
- <j:otherwise>
- <ant:echo>You must set the directory with the ${resourcesDirVarName} property.</ant:echo>
- </j:otherwise>
- </j:choose>
- </j:forEach>
-
- </cactifywar>
-
- </goal>
- <!--
- ========================================================================
- Execute the Cactus tests on all containers which have been defined,
- i.e. which have a ${cactus.home.[container name]} property
- defined.
- ========================================================================
- -->
- <goal name="cactus:prepare" description="Prepare Cactus tests"
- prereqs="cactus:init">
- <j:forEach var="containerGroupId" items="${cargo.containers}">
- <j:set var="containerGroupName" value="cargo.container.${containerGroupId}.containerId"/>
- <j:set var="containerId" value="${context.getVariable(containerGroupName)}"/>
- <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
- <j:set var="containerDir" value="${context.getVariable(containerDirVar)}"/>
-
- <j:if test="${containerDir != null and !containerDir.trim().equals('')}">
-
- <!-- Prepare logging output files -->
- <ant:mkdir dir="${maven.build.dir}/${containerId}"/>
- <ant:touch file="${maven.build.dir}/${containerId}/cargo_start.log"/>
- <ant:touch file="${maven.build.dir}/${containerId}/container_start.log"/>
- <ant:touch file="${maven.build.dir}/${containerId}/cargo_stop.log"/>
- <ant:touch file="${maven.build.dir}/${containerId}/container_stop.log"/>
-
- <!-- Prepare logging config files-->
- <j:if test="${context.getVariable('cactus.logging.config.server') != null}">
- <j:set var="logging_server" value="${cactus.logging.config.server}"/>
- </j:if>
- <j:if test="${context.getVariable('cactus.logging.config.server') == null}">
- <ant:touch file="${maven.build.dir}/logging_server.properties"/>
- <j:set var="logging_server" value="${maven.build.dir}/logging_server.properties"/>
- </j:if>
- <j:if test="${context.getVariable('cactus.logging.config.client') != null}">
- <j:set var="logging_client" value="${context.getVariable('cactus.logging.config.client')}"/>
- </j:if>
- <j:if test="${context.getVariable('cactus.logging.config.client') == null}">
- <ant:touch file="${maven.build.dir}/logging_client.properties"/>
- <j:set var="logging_client" value="${maven.build.dir}/logging_client.properties"/>
- </j:if>
-
-
- <!-- Prepare config -->
- <j:set var="containerConfigDir" value="cactus.${containerId}.dir"/>
- <j:if test="${context.getVariable(containerConfigDir) != null}">
- <j:set var="configdir" value="${context.getVariable(containerConfigDir)}"/>
- </j:if>
- <j:if test="${context.getVariable(containerConfigDir) == null}">
- <ant:mkdir dir="${maven.build.dir}/${containerId}/config"/>
- <j:set var="configdir" value="${maven.build.dir}/${containerId}/config"/>
- </j:if>
-
-
- </j:if>
- </j:forEach>
-
- </goal>
- <!--
- ========================================================================
- Execute the Cactus tests on all containers which have been defined,
- i.e. which have a ${cactus.home.[container name]} property
- defined.
- ========================================================================
- -->
- <goal name="cactus:test" description="Run all Cactus tests"
- prereqs="cactus:init">
-
- <j:choose>
- <j:when test="${cactus.test.skip}">
- <ant:echo>Not runnnig Cactus tests because cactus.test.skip is true.</ant:echo>
- </j:when>
- <j:when test="${cactusSourcePresent}">
- <j:choose>
- <j:when test="${context.getVariable('cactus.is.ear') == 'true'}">
- <attainGoal name="cactus:test-ear"/>
- </j:when>
- <j:otherwise>
- <attainGoal name="cactus:test-war"/>
- </j:otherwise>
- </j:choose>
- </j:when>
- <j:otherwise>
- <ant:echo>No Cactus tests to run.</ant:echo>
- </j:otherwise>
- </j:choose>
-
- </goal>
-
-
- <!--
- ========================================================================
- Start up container.
- ========================================================================
- -->
- <goal name="cactus:start-container" prereqs="cactus:init, cactus:prepare"
- description="Start up a test container">
- <ant:echo> "Start up: ${containerId}" </ant:echo>
- <ant:cargo id="${containerId}" containerId="${containerId}" action="start"
- home="${containerDir}/" wait="false"
- log="${maven.build.dir}/${containerId}/cargo_start.log"
- output="${maven.build.dir}/${containerId}/container_start.log">
- <ant:configuration dir="${configdir}">
- <ant:property name="cargo.servlet.port" value="${cactus.port}"/>
- <ant:property name="cargo.logging" value="high"/>
-
- <j:if test="${hasWar}">
- <ant:war warfile="${cactus.war}"/>
- </j:if>
- <j:if test="${hasEar}">
- <ant:ear earfile="${cactus.ear}"/>
- </j:if>
-
- <!--<ant:ear earfile="${cactus.ear}"/> -->
- </ant:configuration>
- <ant:syspropertyset file="${logging_server}"/>
- <!-- Additional jars that will be added to the classpath used to start
- the container -->
- <ant:extraclasspath>
- <!-- pathelement location="${clover.jar}"/ -->
- </ant:extraclasspath>
-
- </ant:cargo>
- </goal>
-
- <!--
- ========================================================================
- Stop a container.
- ========================================================================
- -->
- <goal name="cactus:stop-container"
- description="Stop a test container">
-
- <ant:echo> "Stop: ${containerId}" </ant:echo>
- <!-- <ant:cargo refid="${containerId}" action="stop"
- log="${maven.build.dir}/${containerId}/cargo_stop.log"
- output="${maven.build.dir}/${containerId}/container_stop.log"/> -->
-
- <ant:cargo containerId="${containerId}" action="stop"
- homeDir="${containerDir}/"
- log="${maven.build.dir}/${containerId}/cargo_stop.log"
- output="${maven.build.dir}/${containerId}/container_stop.log">
- <ant:configuration dir="${configdir}">
- <ant:property name="cargo.servlet.port" value="${cactus.port}"/>
- <ant:property name="cargo.logging" value="high"/>
- </ant:configuration>
- <ant:syspropertyset file="${logging_server}"/>
- <!-- Additional jars that will be added to the classpath used to start
- the container -->
- <ant:extraclasspath>
- <!-- pathelement location="${clover.jar}"/ -->
- </ant:extraclasspath>
-
- </ant:cargo>
-
- <!--Reset dynamic properties -->
- </goal>
-
-
- <!--
- ========================================================================
- Execute the Cactus tests, packaging them in a WAR.
- ========================================================================
- -->
- <goal name="cactus:test-war"
- prereqs="cactus:init,cactus:prepare,cactus:init-report,cactus:cactifywar"
- description="Run all Cactus tests (packaged in a WAR)">
-
- <ant:echo> ----Running cactus:test-war----- </ant:echo>
- <j:set var="hasWar" value="true"/>
- <j:set var="hasEar" value="false"/>
- <cactus:scanner var="cactusScanner" classpathref="cactus.scanner.classpath">
- <fileset dir="${cactus.target.classes.dir}">
- <include name="${cactus.test.includes}"/>
- <exclude name="${cactus.test.excludes}"/>
- </fileset>
- </cactus:scanner>
- <j:forEach var="containerGroupId" items="${cargo.containers}">
- <j:set var="containerGroupName" value="cargo.container.${containerGroupId}.containerId"/>
- <j:set var="containerId" value="${context.getVariable(containerGroupName)}"/>
- <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
- <j:set var="containerDir" value="${context.getVariable(containerDirVar)}"/>
-
- <j:if test="${containerDir != null and !containerDir.trim().equals('')}">
- <attainGoal name="cactus:start-container"/>
-
- <!--Using cactustest to carry out the test -->
- <ant:echo> "Running test ..." +!${reports.dir}! + !${cactus.src.dir}!</ant:echo>
-
- <cactus warfile="${cactus.war}" printsummary="yes">
-
- <ant:classpath>
- <ant:pathelement path="${maven.build.dest}"/>
- <ant:pathelement location="${cactus.target.classes.dir}"/>
- <ant:path refid="maven.dependency.classpath"/>
- <ant:path refid="cactus.classpath"/>
- </ant:classpath>
-
- <containerset>
- <cargo containerId="${containerId}" home="${containerDir}/" wait="false" output="${maven.build.dir}/${containerId}/container_start.log" log="${maven.build.dir}/${containerId}/cargo_start.log">
- <configuration>
- <property name="cargo.servlet.port" value="${cactus.port}"/>
- <property name="cargo.logging" value="high"/>
- <deployable type="war" file="${cactus.war}"/>
- </configuration>
- </cargo>
- </containerset>
-
- <formatter type="xml"/>
- <batchtest todir="target/">
- <fileset dir="${cactus.src.dir}">
- <include name="**/Test*.java"/>
- </fileset>
- </batchtest>
- <!--j:forEach var="test" items="${cactusScanner.iterator()}">
- <test name="${test}"/>
- </j:forEach-->
- </cactus>
-
- </j:if>
- </j:forEach>
- </goal>
-
- <!--
- ========================================================================
- Execute a single Cactus test on all containers which have been defined,
- i.e. which have a ${cactus.home.[container name]} property
- defined. Specify the case with -Dtestcase=my.single.TestCase
- ========================================================================
- -->
- <goal name="cactus:single" prereqs="cactus:init,cactus:prepare,cactus:init-report,cactus:cactifywar"
- description="Run a single Cactus test">
-
- <!-- Run only a single testcase passed in via -Dtestcase=my.single.TestCase-->
- <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>
- <j:set var="hasWar" value="true"/>
- <j:set var="hasEar" value="false"/>
- <j:forEach var="containerId" items="${cargo.containers}">
- <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
- <j:set var="containerDir" value="${context.getVariable(containerDirVar)}"/>
- <ant:echo> ${containerDir}</ant:echo>
- <j:if test="${containerDir != null and !containerDir.trim().equals('')}">
-
- <attainGoal name="cactus:start-container"/>
-
- <!--Using cactustest to carry out the test -->
- <ant:echo> "Running test ..." </ant:echo>
- <cactustests fork="yes" failureproperty="tests.failed" haltonerror="true"
- servletport="${cactus.port}"
- warfile="${cactus.war}"
- todir="${cactus.reports.dir}/${containerId}"
- logs="${logging_client}">
-
- <!-- Pass any user-defined system properties -->
- <util:tokenize var="listOfProperties" delim=" ">
- ${cactus.sysproperties}
- </util:tokenize>
- <j:forEach var="someProperty" items="${listOfProperties}">
- <ant:sysproperty key="${someProperty}"
- value="${context.getVariable(someProperty)}"/>
- </j:forEach>
- <ant:classpath>
- <ant:pathelement path="${maven.build.dest}"/>
- <ant:pathelement location="${cactus.target.classes.dir}"/>
- <ant:path refid="maven.dependency.classpath"/>
- <ant:path refid="cactus.classpath"/>
- </ant:classpath>
- <ant:formatter type="plain" usefile="${cactus.junit.usefile}"/>
- <ant:formatter type="xml"/>
-
- <!-- Run only a single testcase passed in via -Dtestcase=my.single.TestCase-->
- <ant:test name="${testcase}"/>
-
- </cactustests>
-
- <attainGoal name="cactus:stop-container"/>
-
- </j:if>
- </j:forEach>
-
- </j:otherwise>
- </j:choose>
- </goal>
-
- <!--
- ========================================================================
- Execute a Cactus tests on all containers which have been defined,
- i.e. which have a ${cactus.home.[container name]} property
- defined. Specify the matching tests with -Dtestmatch=FooTest
- ========================================================================
- -->
- <goal name="cactus:match" prereqs="cactus:init,cactus:prepare,cactus:init-report,cactus:cactifywar"
- description="Execute all the Cactus tests matching the given 'testmatch' variable">
-
- <j:choose>
- <j:when test="${empty(testmatch)}">
- <echo>
- You must define the test case to match via -Dtestmatch=classname
- Example: maven -Dtestmatch=MyTest cactus:match
- </echo>
- </j:when>
-
- <j:otherwise>
- <j:set var="hasWar" value="true"/>
- <j:set var="hasEar" value="false"/>
- <j:forEach var="containerId" items="${cargo.containers}">
- <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
- <j:set var="containerDir" value="${context.getVariable(containerDirVar)}"/>
- <ant:echo> ${containerDir}</ant:echo>
- <j:if test="${containerDir != null and !containerDir.trim().equals('')}">
-
- <attainGoal name="cactus:start-container"/>
-
- <!--Using cactustest to carry out the test -->
- <ant:echo> "Running test ..." </ant:echo>
- <cactustests fork="yes" failureproperty="tests.failed" haltonerror="true"
- servletport="${cactus.port}"
- warfile="${cactus.war}"
- todir="${cactus.reports.dir}/${containerId}"
- logs="${logging_client}">
-
- <!-- Pass any user-defined system properties -->
- <util:tokenize var="listOfProperties" delim=" ">
- ${cactus.sysproperties}
- </util:tokenize>
- <j:forEach var="someProperty" items="${listOfProperties}">
- <ant:sysproperty key="${someProperty}"
- value="${context.getVariable(someProperty)}"/>
- </j:forEach>
- <ant:classpath>
- <ant:pathelement path="${maven.build.dest}"/>
- <ant:pathelement location="${cactus.target.classes.dir}"/>
- <ant:path refid="maven.dependency.classpath"/>
- <ant:path refid="cactus.classpath"/>
- </ant:classpath>
-
- <ant:formatter type="plain" usefile="${cactus.junit.usefile}"/>
- <ant:formatter type="xml"/>
-
- <!-- Run all testcases matched via -Dtestmatch=FooTest-->
- <ant:batchtest>
- <ant:fileset dir="${cactus.src.dir}">
- <include name="**/${testmatch}.java"/>
- </ant:fileset>
- </ant:batchtest>
-
- </cactustests>
-
- <attainGoal name="cactus:stop-container"/>
-
- </j:if>
- </j:forEach>
-
-
- </j:otherwise>
- </j:choose>
- </goal>
-
- <!--
- ========================================================================
- Initialization before cactifying the EAR
- ========================================================================
- -->
- <goal name="cactus:cactifyear-init">
- <j:set var="isEjbProject" value="true"/>
- </goal>
-
- <!--
- ========================================================================
- Generate a Cactified EAR
- ========================================================================
- -->
- <goal name="cactus:cactifyear"
- prereqs="cactus:cactifyear-init,cactus:cactifywar,cactus:generate-ear-descriptor"
- description="Create and cactify an EAR">
-
- <!-- Generate the ejb artifact -->
- <attainGoal name="${cactus.build.goal.ejb}"/>
-
- <ant:mkdir dir="${maven.build.dir}"/>
-
- <!-- Ensure that the ear properties are loaded in memory so that they can be
- referenced -->
- <attainGoal name="ear:load"/>
-
- <ant:available property="cactus.ear.manifest.available"
- file="${pom.getPluginContext('maven-ear-plugin').getVariable('maven.ear.manifest')}"/>
-
- <ant:available property="cactus.ear.src.available"
- file="${pom.getPluginContext('maven-ear-plugin').getVariable('maven.ear.src')}"/>
-
- <ant:ear destfile="${cactus.ear}"
- appxml="${maven.build.dir}/application.xml">
-
- <j:if test="${cactus.ear.src.available}">
- <fileset dir="${pom.getPluginContext('maven-ear-plugin').getVariable('maven.ear.src')}"
- casesensitive="false" excludes="**/META-INF/application.xml"/>
- </j:if>
-
- <!-- include cactus generated archives -->
- <ant:fileset dir="${cactus.war.dir}">
- <ant:include name="${cactus.war.name}"/>
- </ant:fileset>
- <ant:fileset dir="${cactus.ejb.dir}">
- <ant:include name="${cactus.ejb.name}"/>
- </ant:fileset>
-
- <!-- include marked dependencies -->
- <j:set var="tmpDependenciesDir" value="${maven.build.dir}/tmpEarDeps"/>
- <j:forEach var="lib" items="${pom.artifacts}">
- <j:set var="dep" value="${lib.dependency}"/>
- <j:set var="originalPath" value="${lib.file.name}"/>
- <j:if test="${dep.getProperty('ear.bundle')=='true' || dep.getProperty('ear.module')=='true'}">
- <ear:setPath lib="${lib}" var="bundledPath"/>
- <j:choose>
- <j:when test="${originalPath.equals(bundledPath)}">
- <ant:fileset dir="${lib.file.parent}">
- <ant:include name="${originalPath}"/>
- </ant:fileset>
- </j:when>
- <j:otherwise>
- <echo>Dependency ${lib.file.name} will be bundled as ${bundledPath}</echo>
- <ant:copy file="${lib.file.parent}/${lib.file.name}" tofile="${tmpDependenciesDir}/${bundledPath}"/>
- </j:otherwise>
- </j:choose>
- </j:if>
- </j:forEach>
-
- <!-- bundle all dependencies that were copied to a temporary dir -->
- <util:available file="${tmpDependenciesDir}">
- <ant:fileset dir="${tmpDependenciesDir}"/>
- </util:available>
-
- <j:if test="${cactus.ear.manifest.available}">
- <ant:setProperty name="manifest"
- value="${pom.getPluginContext('maven-ear-plugin').getVariable('maven.ear.manifest')}"/>
- </j:if>
-
- </ant:ear>
-
- </goal>
-
- <!--
- ========================================================================
- Execute the Cactus tests, packaging them in an EAR.
- ========================================================================
- -->
- <goal name="cactus:test-ear"
- prereqs="cactus:init,cactus:prepare,cactus:init-report,cactus:cactifyear"
- description="Run all Cactus tests (packaged in an EAR)">
-
- <cactus:scanner var="cactusScanner" classpathref="cactus.scanner.classpath">
- <fileset dir="${cactus.target.classes.dir}">
- <include name="${cactus.test.includes}"/>
- <exclude name="${cactus.test.excludes}"/>
- </fileset>
- </cactus:scanner>
-
-
- <j:set var="hasWar" value="false"/>
- <j:set var="hasEar" value="true"/>
- <j:forEach var="containerId" items="${cargo.containers}">
- <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
- <j:set var="containerDir" value="${context.getVariable(containerDirVar)}"/>
-
- <j:if test="${containerDir != null and !containerDir.trim().equals('')}">
-
- <attainGoal name="cactus:start-container"/>
-
- <!--Using cactustest to carry out the test -->
- <ant:echo> "Running test ..." </ant:echo>
- <cactustests fork="yes" failureproperty="tests.failed" haltonerror="true"
- servletport="${cactus.port}"
- earfile="${cactus.ear}"
- todir="${cactus.reports.dir}/${containerId}"
- logs="${logging_client}">
-
- <!-- Pass any user-defined system properties -->
- <util:tokenize var="listOfProperties" delim=" ">
- ${cactus.sysproperties}
- </util:tokenize>
- <j:forEach var="someProperty" items="${listOfProperties}">
- <ant:sysproperty key="${someProperty}"
- value="${context.getVariable(someProperty)}"/>
- </j:forEach>
- <ant:classpath>
- <ant:pathelement path="${maven.build.dest}"/>
- <ant:pathelement location="${cactus.target.classes.dir}"/>
- <ant:path refid="maven.dependency.classpath"/>
- <ant:path refid="cactus.classpath"/>
- </ant:classpath>
-
- <ant:formatter type="plain" usefile="${cactus.junit.usefile}"/>
- <ant:formatter type="xml"/>
-
- <j:forEach var="test" items="${cactusScanner.iterator()}">
- <test name="${test}"/>
- </j:forEach>
-
- </cactustests>
-
- <attainGoal name="cactus:stop-container"/>
-
- </j:if>
- </j:forEach>
-
- <cactustag:junitreport/>
-
- <j:if test="${cactus.halt.on.failure}">
- <ant:fail if="cactustests.failure">At least one test had a failure!</ant:fail>
- </j:if>
- <j:if test="${cactus.halt.on.error}">
- <ant:fail if="cactustests.error">At least one test had an error!</ant:fail>
- </j:if>
-
- </goal>
-
- <!--
- ========================================================================
- Creates ear descriptor - application.xml file
- ========================================================================
- -->
- <goal name="cactus:generate-ear-descriptor" prereqs="cactus:init">
-
- <mkdir dir="${maven.build.dir}"/>
-
- <ant:echo>Generating appxml file:[${maven.build.dir}/application.xml] version ${cactus.j2ee.version}</ant:echo>
-
- <j:file name="${maven.build.dir}/application.xml" outputMode="xml"
- prettyPrint="true" encoding="UTF-8">
-
- <j:switch on="${cactus.j2ee.version}">
- <j:case value="1.3">
- <x:doctype name="application"
- publicId="-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
- systemId="http://java.sun.com/dtd/application_1_3.dtd"/>
- </j:case>
- <j:default>
- <x:doctype name="application"
- publicId="-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN"
- systemId="http://java.sun.com/j2ee/dtds/application_1_2.dtd"/>
- </j:default>
- </j:switch>
-
- <x:element name="application">
- <x:element name="display-name">${pom.name} for Cactus</x:element>
-
- <!-- cactus war file -->
- <x:element name="module">
- <x:element name="web">
- <x:element name="web-uri">${cactus.war.name}</x:element>
- <x:element name="context-root">${pom.artifactId}</x:element>
- </x:element>
- </x:element>
-
- <!-- ejb module under test -->
- <x:element name="module">
- <x:element name="ejb">${cactus.ejb.name}</x:element>
- </x:element>
-
- <j:forEach var="lib" items="${pom.artifacts}">
- <j:set var="dep" value="${lib.dependency}"/>
- <ear:setPath lib="${lib}" var="bundledPath"/>
- <j:if test="${dep.getProperty('ear.bundle')=='true' || dep.getProperty('ear.module')=='true'}">
- <j:choose>
- <j:when test="${dep.type=='war'}">
- <x:element name="module">
- <x:element name="web">
- <x:element name="web-uri">${bundledPath}</x:element>
- <x:element name="context-root">${dep.getProperty('ear.appxml.war.context-root')}</x:element>
- </x:element>
- </x:element>
- </j:when>
- <j:when test="${dep.type=='ejb'}">
- <x:element name="module">
- <x:element name="ejb">${bundledPath}</x:element>
- </x:element>
- </j:when>
- <j:when test="${dep.type=='jar'}">
- <j:if test="${dep.getProperty('ear.module')=='true'}">
- <x:element name="module">
- <x:element name="java">${bundledPath}</x:element>
- </x:element>
- </j:if>
- </j:when>
- <j:when test="${dep.type=='rar'}">
- <x:element name="module">
- <x:element name="connector">${bundledPath}</x:element>
- </x:element>
- </j:when>
- <j:when test="${dep.type=='sar'}">
- <x:element name="module">
- <x:element name="connector">${bundledPath}</x:element>
- </x:element>
- </j:when>
- </j:choose>
- </j:if>
- </j:forEach>
-
- </x:element>
- </j:file>
-
- </goal>
-
- <!--
- ========================================================================
- Register a Cactus report.
- ========================================================================
- -->
- <goal name="maven-cactus-plugin:register">
- <doc:registerReport
- name="Cactus Unit Tests"
- pluginName="cactus"
- description="Report on the results of the Cactus unit tests."
- link="cactus-report"/>
- </goal>
-
- <!--
- ========================================================================
- Deregister a Cactus report.
- ========================================================================
- -->
- <goal name="maven-cactus-plugin:deregister">
- <doc:deregisterReport name="Cactus Unit Tests"/>
- </goal>
-
- <!--
- ========================================================================
- Generate a Cactus report.
- ========================================================================
- -->
- <goal name="cactus:report"
- description="Generate a report from the test results">
-
- <j:if test="${context.getVariable('cactus.execute.during.report') == 'true'}">
-
- <!-- When running reports, make sure Cactus tests do not fail the
- build -->
- <j:set var="cactus.halt.on.failure" value="false"/>
- <j:set var="cactus.halt.on.error" value="false"/>
- <attainGoal name="cactus:test"/>
-
- </j:if>
-
- <!-- Before running the report, check the required test suite xml file has
- been generated -->
- <util:file var="inputAsFile"
- name="${cactus.reports.dir}/TESTS-TestSuites-Cactus.xml"/>
- <j:choose>
- <j:when test="${inputAsFile.exists()}">
-
- <doc:jsl
- input="${cactus.reports.dir}/TESTS-TestSuites-Cactus.xml"
- output="cactus-report.xml"
- stylesheet="${plugin.resources}/cactus.jsl"
- outputMode="xml"
- prettyPrint="true"/>
-
- </j:when>
- <j:otherwise>
- <ant:mkdir dir="${maven.gen.docs}"/>
- <j:file name="${maven.gen.docs}/cactus-report.xml" prettyPrint="true"
- xmlns="cactus">
- <document>
- <properties>
- <title>Cactus Test Results</title>
- </properties>
- <body>
- <section name="Cactus test results">
- <p>
- No Cactus results to report. Make sure the Cactus tests are
- run before the report is generated.
- </p>
- </section>
- </body>
- </document>
- </j:file>
- <echo>You need to run Cactus tests before generating the report.</echo>
- </j:otherwise>
- </j:choose>
-
- </goal>
-
- <!--
- ========================================================================
- Install the Cactus jar in the local repository.
- ========================================================================
- -->
- <goal name="cactus:jar-install" prereqs="cactus:jar"
- description="Install the Cactus jar in the local repository">
-
- <ant:echo>
- id = '${pom.artifactId}'
- groupId = '${pom.groupId}'
- artifactDirectory = '${pom.artifactDirectory}'
- </ant:echo>
-
- <ant:property name="jardir__" value="${maven.repo.local}/${pom.artifactDirectory}/jars"/>
- <ant:mkdir dir="${jardir__}"/>
- <ant:copy
- file="${maven.build.dir}/${pom.artifactId}-cactus-${pom.currentVersion}.jar"
- todir="${jardir__}"
- overwrite="true"/>
- </goal>
-
- <!--
- ========================================================================
- Useful tag libraries to promote reuse of Jelly code snippets.
- ========================================================================
- -->
-
- <define:taglib uri="cactus">
-
- <!-- Use this tag to allow this plugin to be loaded into another -->
- <!-- DEPRECATION: No longer required. Dependent plugins should now use
- <maven:get>/<maven:set> instead. Once everyone has moved to Maven
- 1.0 final, we should make the change -->
- <define:tag name="dependency-handle">
- </define:tag>
-
- <!-- Consolidate the JUnit reports into a single one
- TODO: Change the Cactus stylesheet (cactus.jsl) to handle reports
- for several containers -->
- <define:tag name="junitreport">
-
- <ant:junitreport todir="${cactus.reports.dir}"
- tofile="TESTS-TestSuites-Cactus.xml">
-
- <j:forEach var="containerId" items="${cargo.containers}">
- <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
- <j:set var="containerDir" value="${context.getVariable(containerDirVar)}"/>
-
- <j:if test="${containerDir != null and !containerDir.trim().equals('')}">
- <ant:fileset dir="${cactus.reports.dir}/${containerId}">
- <ant:include name="TEST-*.xml"/>
- </ant:fileset>
- </j:if>
- </j:forEach>
-
-
- </ant:junitreport>
-
- </define:tag>
-
- </define:taglib>
-
-</project>
+<?xml version="1.0"?>
+
+<!--
+ =============================================================================
+ Cactus plugin for Maven. It uses the Cactus/Ant Integration from the
+ Cactus project.
+ =============================================================================
+-->
+
+<!--
+ Note: There is significant refactoring required for the goals cactus:test,
+ cactus:single, and cactus:match. The <cactus> tasks in each of those goals
+ are mostly similar.
+-->
+<project
+ xmlns:j="jelly:core"
+ xmlns:doc="doc"
+ xmlns:util="jelly:util"
+ xmlns:ant="jelly:ant"
+ xmlns:define="jelly:define"
+ xmlns:x="jelly:xml"
+ xmlns:maven="jelly:maven"
+ xmlns:test="test"
+ xmlns:ear="ear"
+ xmlns:cactustag="cactus"
+ xmlns:cactus="jelly:org.apache.cactus.integration.maven.CactusTagLibrary">
+
+
+ <!--
+ ========================================================================
+ Default goal.
+ ========================================================================
+ -->
+ <goal name="cactus" description="Run all Cactus tests"
+ prereqs="cactus:test"/>
+
+ <!--
+ ========================================================================
+ Verify that the installed Maven has compatible versions of dependent
+ plugins.
+ ========================================================================
+ -->
+ <goal name="cactus:check-plugin-dependencies">
+
+ <maven:get plugin="maven-war-plugin" property="plugin" var="warPlugin" />
+ <j:if test="${warPlugin.currentVersion.compareTo('1.6.1') lt 0}">
+ <ant:fail>
+ Must have WAR plugin v1.6.1 or greater installed to use this version of the Cactus plugin.
+ Try: maven plugin:download -DgroupId=maven -DartifactId=maven-war-plugin -Dversion=[version]
+ </ant:fail>
+ </j:if>
+
+ <maven:get plugin="maven-ejb-plugin" property="plugin" var="ejbPlugin" />
+ <j:if test="${warPlugin.currentVersion.compareTo('1.6') lt 0}">
+ <ant:fail>
+ Must have EJB plugin v1.6 or greater installed to use this version of the Cactus plugin.
+ Try: maven plugin:download -DgroupId=maven -DartifactId=maven-ejb-plugin -Dversion=[version]
+ </ant:fail>
+ </j:if>
+
+ <maven:get plugin="maven-ear-plugin" property="plugin" var="earPlugin" />
+ <j:if test="${earPlugin.currentVersion.compareTo('1.6.1') lt 0}">
+ <ant:fail>
+ Must have EAR plugin v1.6.1 or greater installed to use this version of the Cactus plugin.
+ Try: maven plugin:download -DgroupId=maven -DartifactId=maven-ear-plugin -Dversion=[version]
+ </ant:fail>
+ </j:if>
+
+ </goal>
+
+ <!--
+ ========================================================================
+ Initializations.
+ ========================================================================
+ -->
+ <goal name="cactus:init" prereqs="cactus:check-plugin-dependencies">
+
+ <!-- Compute the default location of the input war file to cactify -->
+ <maven:get var="warBuildDir" plugin="maven-war-plugin" property="maven.war.build.dir"/>
+ <maven:get var="warFinalName" plugin="maven-war-plugin" property="maven.war.final.name"/>
+ <maven:property var="cactus.src.war" name="cactus.src.war"
+ defaultValue="${warBuildDir}/${warFinalName}"/>
+
+ <!-- Compute the default location of the input EJB file to cactify -->
+ <maven:get var="ejbBuildDir" plugin="maven-ejb-plugin" property="maven.ejb.build.dir"/>
+ <maven:get var="ejbFinalName" plugin="maven-ejb-plugin" property="maven.ejb.final.name"/>
+ <maven:property var="cactus.src.ejb" name="cactus.src.ejb"
+ defaultValue="${ejbBuildDir}/${ejbFinalName}"/>
+
+ <!-- Not sure why but this is needed, otherwise the taskdefs below fail -->
+ <!-- DEPRECATION: Should now use <maven:get>/<maven:set> instead. Once
+ everyone has moved to Maven 1.0 final, we should make the change -->
+ <test:dependency-handle/>
+
+ <ant:path id="cactus.classpath">
+ <ant:pathelement location="${plugin.getDependencyPath('org.apache.cactus:cactus.core.framework.uberjar.javaEE.14')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('org.apache.cactus:cactus.integration.ant')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('org.apache.cactus:cactus.integration.shared.api')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('commons-logging:commons-logging')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('junit:junit')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('commons-httpclient:commons-httpclient')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('aspectj:aspectjrt')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('httpunit:httpunit')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('htmlunit:htmlunit')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('nekohtml:nekohtml')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('xerces:xerces')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('xml-apis:xml-apis')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('rhino:js')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('org.codehaus.cargo:cargo-core-uberjar')}"/>
+ <ant:pathelement location="${plugin.getDependencyPath('org.codehaus.cargo:cargo-ant')}"/>
+ </ant:path>
+
+ <ant:taskdef resource="cactus.tasks" classpathref="cactus.classpath"/>
+ <ant:taskdef resource="cargo.tasks" classpathref="cactus.classpath"/>
+
+ <ant:taskdef name="junit"
+ classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
+
+ <ant:property name="cactus.target.classes.dir"
+ value="${maven.build.dir}/test-cactus-classes"/>
+
+ <!-- Destination locations for the build -->
+ <property name="target.dir" location="target"/>
+ <property name="target.classes.dir" location="${target.dir}/classes"/>
+ <property name="target.classes.java.dir"
+ location="${target.classes.dir}/java"/>
+ <property name="target.classes.cactus.dir"
+ location="${target.classes.dir}/cactus"/>
+ <property name="target.testreports.dir"
+ location="${target.dir}/test-reports"/>
+
+
+
+ <util:available file="${cactus.src.dir}">
+ <j:set var="cactusSourcePresent" value="true"/>
+ <ant:path id="cactus.compile.src.set">
+ <ant:pathelement location="${cactus.src.dir}"/>
+ </ant:path>
+ </util:available>
+
+ <!-- The Cactus scanner automatically discovers Cactus tests -->
+
+ <ant:path id="cactus.scanner.classpath">
+ <ant:pathElement location="${maven.build.dest}"/>
+ <ant:pathElement location="${cactus.target.classes.dir}"/>
+ <ant:path refid="maven.dependency.classpath"/>
+ <ant:path refid="cactus.classpath"/>
+ </ant:path>
+
+ <ant:dirname property="cactus.war.dir" file="${cactus.war}"/>
+ <ant:basename property="cactus.war.name" file="${cactus.war}"/>
+
+ <ant:dirname property="cactus.ejb.dir" file="${cactus.src.ejb}"/>
+ <ant:basename property="cactus.ejb.name" file="${cactus.src.ejb}"/>
+
+ <!-- List of supported containers -->
+ <!--<j:set var="cargo.containers"
+ value="resin2x,resin3x,tomcat3x,tomcat4x,tomcat5x,orion1x,orion2x,jboss3x,weblogic7x"/>-->
+ <util:tokenize var="cargo.containers" delim="," trim="true">${cargo.containers}
+ </util:tokenize>
+
+
+
+ </goal>
+
+ <!--
+ ========================================================================
+ Preparations for executing the JUnit reports
+ ========================================================================
+ -->
+ <goal name="cactus:init-report">
+
+ <!-- Prepare the directories for the JUnit reports -->
+ <ant:mkdir dir="${cactus.reports.dir}"/>
+ <j:forEach var="containerId" items="${cargo.containers}">
+ <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
+ <j:set var="containerHome" value="${context.getVariable(containerDirVar)}"/>
+
+ <j:if test="${containerHome != null and !containerHome.trim().equals('')}">
+ <ant:mkdir dir="${cactus.reports.dir}/${containerId}"/>
+ </j:if>
+ </j:forEach>
+
+
+ </goal>
+
+ <!--
+ ========================================================================
+ Compiles the Cactus tests.
+ ========================================================================
+ -->
+ <goal name="cactus:compile" prereqs="cactus:init,java:compile"
+ description="Compiles the Cactus tests">
+
+ <ant:mkdir dir="${cactus.target.classes.dir}"/>
+
+ <j:choose>
+ <j:when test="${cactusSourcePresent == 'true'}">
+
+ <ant:javac destdir="${cactus.target.classes.dir}"
+ excludes="**/package.html"
+ debug="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.debug')}"
+ deprecation="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.deprecation')}"
+ optimize="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.optimize')}">
+
+ <ant:src>
+ <ant:path refid="cactus.compile.src.set"/>
+ </ant:src>
+
+ <ant:classpath>
+ <ant:path refid="maven.dependency.classpath"/>
+ <ant:path refid="cactus.classpath"/>
+ <ant:pathelement path="${maven.build.dest}"/>
+ </ant:classpath>
+
+ <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.compilerargs') != null}">
+ <ant:compilerarg line="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.compilerargs')}"/>
+ </j:if>
+
+ <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.encoding') != null}">
+ <ant:setProperty name="encoding" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.encoding')}"/>
+ </j:if>
+
+ <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.executable') != null}">
+ <ant:setProperty name="executable" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.executable')}"/>
+ </j:if>
+
+ <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.fork') != null}">
+ <ant:setProperty name="fork" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.fork')}"/>
+ </j:if>
+
+ <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.source') != null}">
+ <ant:setProperty name="source" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.source')}"/>
+ </j:if>
+
+ <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.target') != null}">
+ <ant:setProperty name="target" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.target')}"/>
+ </j:if>
+
+ <j:if test="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.verbose') != null}">
+ <ant:setProperty name="verbose" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.compile.verbose')}"/>
+ </j:if>
+ </ant:javac>
+
+ <!-- Copy non java source files -->
+ <ant:copy todir="${cactus.target.classes.dir}">
+ <ant:fileset dir="${cactus.src.dir}">
+ <ant:exclude name="**/*.java"/>
+ <ant:exclude name="**/*.html"/>
+ </ant:fileset>
+ </ant:copy>
+
+ </j:when>
+ <j:otherwise>
+ <ant:echo>No Cactus source files to compile.</ant:echo>
+ </j:otherwise>
+ </j:choose>
+
+ </goal>
+
+ <!--
+ ========================================================================
+ Generate a jar containing Cactus tests classes.
+ ========================================================================
+ -->
+ <goal name="cactus:jar" prereqs="cactus:compile"
+ description="Generate a Cactus jar">
+
+ <ant:jar
+ jarfile="${maven.build.dir}/${pom.artifactId}-cactus-${pom.currentVersion}.jar"
+ basedir="${cactus.target.classes.dir}">
+ <ant:manifest>
+ <ant:attribute name="Built-By" value="${user.name}"/>
+ <ant:attribute name="Created-By" value="Apache Jakarta Maven"/>
+ <ant:attribute name="Package" value="${pom.package}"/>
+ <ant:attribute name="Build-Jdk" value="${java.version}"/>
+ <ant:attribute name="Extension-Name" value="${pom.artifactId}"/>
+ <ant:attribute name="Specification-Version" value="${pom.specificationVersion}"/>
+ <ant:attribute name="Specification-Vendor" value="${pom.organization.name}"/>
+ <ant:attribute name="Specification-Title" value="${pom.shortDescription}"/>
+ <ant:attribute name="Implementation-Version" value="${pom.currentVersion}"/>
+ <ant:attribute name="Implementation-Vendor" value="${pom.organization.name}"/>
+ <ant:attribute name="Implementation-Vendor-Id" value="${pom.organization.identifier}"/>
+ </ant:manifest>
+ </ant:jar>
+
+ </goal>
+
+ <!--
+ ========================================================================
+ Cactify an application war.
+ ========================================================================
+ -->
+ <goal name="cactus:cactifywar" prereqs="cactus:compile"
+ description="Cactify the application war">
+
+ <!-- Generate the war artifact -->
+ <attainGoal name="${cactus.build.goal.war}"/>
+
+ <cactifywar version="${cactus.servlet.version}" destfile="${cactus.war}">
+
+ <!-- Only specify a source war to cactify if we are not testing EJBs.
+ The reason is to prevent adding EJB sources to the cactified war,
+ which can lead to problems on some containers as the EJB classes
+ will be present both in the cactified war and in the ejb-jar. -->
+ <j:if test="${!isEjbProject}">
+ <ant:setProperty name="srcfile" value="${cactus.src.war}"/>
+ </j:if>
+
+ <!-- Add the mergewebxml attribute if it has been defined by the
+ user -->
+ <j:if test="${context.getVariable('cactus.src.mergewebxml') != null}">
+ <ant:setProperty name="mergewebxml" value="${cactus.src.mergewebxml}"/>
+ </j:if>
+
+ <ant:classes dir="${cactus.target.classes.dir}"/>
+
+ <!-- Orion fails on a servlet filter that is not mapped to an actual
+ resource, to trick it -->
+ <filterredirector mapping="/test/filterRedirector.jsp"/>
+
+ <!-- Files needed for JBoss -->
+ <ant:classes dir="${plugin.resources}/jboss3x">
+ <ant:include name="*.properties" if="cactus.home.jboss3x"/>
+ </ant:classes>
+ <ant:webinf dir="${plugin.resources}/jboss3x">
+ <ant:include name="jboss-web.xml" if="cactus.home.jboss3x"/>
+ </ant:webinf>
+
+ <!-- Add all cactus related jars to the WEB-INF/lib dir. By default
+ the CactifyWarTask only adds the pure Cactus jars but not
+ related jars such as HttpUnit jars -->
+ <lib file="${plugin.getDependencyPath('httpunit:httpunit')}"/>
+
+ <!-- Add all user jars that have been marked to be included in the cactus
+ test. For example, DBUnit would be a jar you would include in a
+ Cactus test but not in a runtime war -->
+ <j:forEach var="artifact" items="${pom.artifacts}">
+ <j:set var="dep" value="${artifact.dependency}"/>
+ <j:if test="${dep.getProperty('cactus.bundle')=='true'}">
+ <lib file="${artifact.path}"/>
+ </j:if>
+ </j:forEach>
+
+ <!-- Add cactus resources to the classes included in the war -->
+ <util:tokenize var="resourcesList" delim=",">${cactus.resources.dirs}</util:tokenize>
+ <j:forEach var="resourcesLabel" items="${resourcesList}">
+ <j:set var="resourcesDirVarName"
+ value="cactus.resources.${resourcesLabel}.dir"/>
+ <j:choose>
+ <j:when test="${context.getVariable(resourcesDirVarName) != null}">
+ <j:set var="includesVarName"
+ value="cactus.resources.${resourcesLabel}.includes"/>
+ <j:choose>
+ <j:when test="${context.getVariable(includesVarName) != null}">
+ <j:set var="includes"
+ value="${context.getVariable(includesVarName)}"/>
+ </j:when>
+ <j:otherwise>
+ <j:set var="includes"
+ value="**/*"/>
+ </j:otherwise>
+ </j:choose>
+ <j:set var="excludesVarName"
+ value="cactus.resources.${resourcesLabel}.excludes"/>
+ <j:choose>
+ <j:when test="${context.getVariable(excludesVarName) != null}">
+ <j:set var="excludes"
+ value="${context.getVariable(excludesVarName)}"/>
+ </j:when>
+ <j:otherwise>
+ <j:set var="excludes"
+ value=""/>
+ </j:otherwise>
+ </j:choose>
+
+ <util:file var="resourceFile"
+ name="${context.getVariable(resourcesDirVarName)}/"/>
+ <j:choose>
+ <j:when test="${resourceFile.exists() and resourceFile.isDirectory()}">
+ <ant:classes dir="${context.getVariable(resourcesDirVarName)}">
+ <ant:include name="${includes}"/>
+ <ant:exclude name="${excludes}"/>
+ </ant:classes>
+ </j:when>
+ <j:otherwise>
+ <ant:echo>Skipping invalid directory ${context.getVariable(resourcesDirVarName)}.</ant:echo>
+ </j:otherwise>
+ </j:choose>
+ </j:when>
+ <j:otherwise>
+ <ant:echo>You must set the directory with the ${resourcesDirVarName} property.</ant:echo>
+ </j:otherwise>
+ </j:choose>
+ </j:forEach>
+
+ </cactifywar>
+
+ </goal>
+ <!--
+ ========================================================================
+ Execute the Cactus tests on all containers which have been defined,
+ i.e. which have a ${cactus.home.[container name]} property
+ defined.
+ ========================================================================
+ -->
+ <goal name="cactus:prepare" description="Prepare Cactus tests"
+ prereqs="cactus:init">
+ <j:forEach var="containerId" items="${cargo.containers}">
+ <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
+ <j:set var="containerDir" value="${context.getVariable(containerDirVar)}"/>
+
+ <j:if test="${containerDir != null and !containerDir.trim().equals('')}">
+
+ <!-- Prepare logging output files -->
+ <ant:mkdir dir="${maven.build.dir}/${containerId}"/>
+ <ant:touch file="${maven.build.dir}/${containerId}/cargo_start.log"/>
+ <ant:touch file="${maven.build.dir}/${containerId}/container_start.log"/>
+ <ant:touch file="${maven.build.dir}/${containerId}/cargo_stop.log"/>
+ <ant:touch file="${maven.build.dir}/${containerId}/container_stop.log"/>
+
+ <!-- Prepare logging config files-->
+ <j:if test="${context.getVariable('cactus.logging.config.server') != null}">
+ <j:set var="logging_server" value="${cactus.logging.config.server}"/>
+ </j:if>
+ <j:if test="${context.getVariable('cactus.logging.config.server') == null}">
+ <ant:touch file="${maven.build.dir}/logging_server.properties"/>
+ <j:set var="logging_server" value="${maven.build.dir}/logging_server.properties"/>
+ </j:if>
+
+ <j:if test="${context.getVariable('cactus.logging.config.client') != null}">
+ <j:set var="logging_client" value="${cactus.logging.config.client}"/>
+ </j:if>
+ <j:if test="${context.getVariable('cactus.logging.config.client') == null}">
+ <ant:touch file="${maven.build.dir}/logging_client.properties"/>
+ <j:set var="logging_client" value="${maven.build.dir}/logging_client.properties"/>
+ </j:if>
+
+
+ <!-- Prepare config -->
+ <j:set var="containerConfigDir" value="cactus.${containerId}.dir"/>
+ <j:if test="${context.getVariable(containerConfigDir) != null}">
+ <j:set var="configdir" value="${context.getVariable(containerConfigDir)}"/>
+ </j:if>
+ <j:if test="${context.getVariable(containerConfigDir) == null}">
+ <ant:mkdir dir="${maven.build.dir}/${containerId}/config"/>
+ <j:set var="configdir" value="${maven.build.dir}/${containerId}/config"/>
+ </j:if>
+
+
+ </j:if>
+ </j:forEach>
+
+ </goal>
+ <!--
+ ========================================================================
+ Execute the Cactus tests on all containers which have been defined,
+ i.e. which have a ${cactus.home.[container name]} property
+ defined.
+ ========================================================================
+ -->
+ <goal name="cactus:test" description="Run all Cactus tests"
+ prereqs="cactus:init">
+
+ <j:choose>
+ <j:when test="${cactus.test.skip}">
+ <ant:echo>Not runnnig Cactus tests because cactus.test.skip is true.</ant:echo>
+ </j:when>
+ <j:when test="${cactusSourcePresent}">
+ <j:choose>
+ <j:when test="${context.getVariable('cactus.is.ear') == 'true'}">
+ <attainGoal name="cactus:test-ear"/>
+ </j:when>
+ <j:otherwise>
+ <attainGoal name="cactus:test-war"/>
+ </j:otherwise>
+ </j:choose>
+ </j:when>
+ <j:otherwise>
+ <ant:echo>No Cactus tests to run.</ant:echo>
+ </j:otherwise>
+ </j:choose>
+
+ </goal>
+
+
+ <!--
+ ========================================================================
+ Start up container.
+ ========================================================================
+ -->
+ <goal name="cactus:start-container"
+ description="Start up a test container">
+ <ant:echo> "Start up: ${containerId}" </ant:echo>
+ <ant:cargo id="${containerId}" containerId="${containerId}" action="start"
+ home="${containerDir}/"
+ log="${maven.build.dir}/${containerId}/cargo_start.log"
+ output="${maven.build.dir}/${containerId}/container_start.log">
+ <ant:configuration dir="${configdir}">
+ <ant:property name="cargo.servlet.port" value="${cactus.port}"/>
+ <ant:property name="cargo.logging" value="high"/>
+
+ <j:if test="${hasWar}">
+ <ant:war warfile="${cactus.war}"/>
+ </j:if>
+ <j:if test="${hasEar}">
+ <ant:ear earfile="${cactus.ear}"/>
+ </j:if>
+
+ <!--<ant:ear earfile="${cactus.ear}"/> -->
+ </ant:configuration>
+ <ant:syspropertyset file="${logging_server}"/>
+ <!-- Additional jars that will be added to the classpath used to start
+ the container -->
+ <ant:extraclasspath>
+ <!-- pathelement location="${clover.jar}"/ -->
+ </ant:extraclasspath>
+
+ </ant:cargo>
+
+ </goal>
+
+ <!--
+ ========================================================================
+ Stop a container.
+ ========================================================================
+ -->
+ <goal name="cactus:stop-container"
+ description="Stop a test container">
+
+ <ant:echo> "Stop: ${containerId}" </ant:echo>
+ <!-- <ant:cargo refid="${containerId}" action="stop"
+ log="${maven.build.dir}/${containerId}/cargo_stop.log"
+ output="${maven.build.dir}/${containerId}/container_stop.log"/> -->
+
+ <ant:cargo containerId="${containerId}" action="stop"
+ homeDir="${containerDir}/"
+ log="${maven.build.dir}/${containerId}/cargo_stop.log"
+ output="${maven.build.dir}/${containerId}/container_stop.log">
+ <ant:configuration dir="${configdir}">
+ <ant:property name="cargo.servlet.port" value="${cactus.port}"/>
+ <ant:property name="cargo.logging" value="high"/>
+ </ant:configuration>
+ <ant:syspropertyset file="${logging_server}"/>
+ <!-- Additional jars that will be added to the classpath used to start
+ the container -->
+ <ant:extraclasspath>
+ <!-- pathelement location="${clover.jar}"/ -->
+ </ant:extraclasspath>
+
+ </ant:cargo>
+
+ <!--Reset dynamic properties -->
+ </goal>
+
+
+ <!--
+ ========================================================================
+ Execute the Cactus tests, packaging them in a WAR.
+ ========================================================================
+ -->
+ <goal name="cactus:test-war"
+ prereqs="cactus:init,cactus:prepare,cactus:init-report,cactus:cactifywar"
+ description="Run all Cactus tests (packaged in a WAR)">
+
+ <ant:echo> ----Running cactus:test-war----- </ant:echo>
+ <j:set var="hasWar" value="true"/>
+ <j:set var="hasEar" value="false"/>
+ <cactus:scanner var="cactusScanner" classpathref="cactus.scanner.classpath">
+ <fileset dir="${cactus.target.classes.dir}">
+ <include name="${cactus.test.includes}"/>
+ <exclude name="${cactus.test.excludes}"/>
+ </fileset>
+ </cactus:scanner>
+ <j:forEach var="containerId" items="${cargo.containers}">
+ <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
+ <j:set var="containerDir" value="${context.getVariable(containerDirVar)}"/>
+ <ant:echo> ${containerDir}</ant:echo>
+ <j:if test="${containerDir != null and !containerDir.trim().equals('')}">
+
+ <!--attainGoal name="cactus:start-container"/-->
+
+ <ant:echo> "Running test ..." </ant:echo>
+ <cactus warfile="${cactus.war}" printsummary="yes">
+
+ <!-- Pass any user-defined system properties -->
+ <util:tokenize var="listOfProperties" delim=" ">
+ ${cactus.sysproperties}
+ </util:tokenize>
+ <j:forEach var="someProperty" items="${listOfProperties}">
+ <ant:sysproperty key="${someProperty}"
+ value="${context.getVariable(someProperty)}"/>
+ </j:forEach>
+
+ <containerset>
+ <cargo id="${containerId}" containerId="${containerId}"
+ home="${containerDir}/"
+ log="${maven.build.dir}/${containerId}/cargo_start.log"
+ output="${maven.build.dir}/${containerId}/container_start.log">
+ <configuration dir="${configdir}">
+ <property name="cargo.servlet.port" value="8080"/>
+ <property name="cargo.logging" value="high"/>
+
+ <j:if test="${hasWar}">
+ <deployable type="war" file="${cactus.war}"/>
+ </j:if>
+ <j:if test="${hasEar}">
+ <deployable type="ear" file="${cactus.ear}"/>
+ </j:if>
+
+ <!--<ant:ear earfile="${cactus.ear}"/> -->
+ </configuration>
+ <syspropertyset file="${logging_server}"/>
+ <!-- Additional jars that will be added to the classpath used to start
+ the container -->
+ <extraclasspath>
+ <!-- pathelement location="${clover.jar}"/ -->
+ </extraclasspath>
+
+ </cargo>
+ </containerset>
+
+ <ant:classpath>
+ <ant:pathelement path="${maven.build.dest}"/>
+ <ant:pathelement location="${cactus.target.classes.dir}"/>
+ <ant:path refid="maven.dependency.classpath"/>
+ <ant:path refid="cactus.classpath"/>
+ </ant:classpath>
+ <formatter type="plain" usefile="${cactus.junit.usefile}"/>
+ <formatter type="xml"/>
+
+ <j:forEach var="test" items="${cactusScanner.iterator()}">
+ <test name="${test}"/>
+ </j:forEach>
+
+ </cactus>
+
+ <!--attainGoal name="cactus:stop-container"/!-->
+
+ </j:if>
+ </j:forEach>
+
+ </goal>
+
+ <!--
+ ========================================================================
+ Execute a single Cactus test on all containers which have been defined,
+ i.e. which have a ${cactus.home.[container name]} property
+ defined. Specify the case with -Dtestcase=my.single.TestCase
+ ========================================================================
+ -->
+ <goal name="cactus:single" prereqs="cactus:init,cactus:prepare,cactus:init-report,cactus:cactifywar"
+ description="Run a single Cactus test">
+
+ <!-- Run only a single testcase passed in via -Dtestcase=my.single.TestCase-->
+ <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>
+ <j:set var="hasWar" value="true"/>
+ <j:set var="hasEar" value="false"/>
+ <j:forEach var="containerId" items="${cargo.containers}">
+ <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
+ <j:set var="containerDir" value="${context.getVariable(containerDirVar)}"/>
+ <ant:echo> ${containerDir}</ant:echo>
+ <j:if test="${containerDir != null and !containerDir.trim().equals('')}">
+
+ <!--attainGoal name="cactus:start-container"/-->
+
+ <ant:echo> "Running test ..." </ant:echo>
+ <cactus fork="yes" failureproperty="tests.failed" haltonerror="true">
+ <containerset>
+ <cargo id="${containerId}" containerId="${containerId}"
+ home="${containerDir}/"
+ log="${maven.build.dir}/${containerId}/cargo_start.log"
+ output="${maven.build.dir}/${containerId}/container_start.log">
+ <configuration dir="${configdir}">
+ <property name="cargo.servlet.port" value="8080"/>
+ <property name="cargo.logging" value="high"/>
+
+ <j:if test="${hasWar}">
+ <deployable type="war" file="${cactus.war}"/>
+ </j:if>
+ <j:if test="${hasEar}">
+ <deployable type="ear" file="${cactus.ear}"/>
+ </j:if>
+
+ <!--<ant:ear earfile="${cactus.ear}"/> -->
+ </configuration>
+ <syspropertyset file="${logging_server}"/>
+ <!-- Additional jars that will be added to the classpath used to start
+ the container -->
+ <extraclasspath>
+ <!-- pathelement location="${clover.jar}"/ -->
+ </extraclasspath>
+
+ </cargo>
+ </containerset>
+
+ <!-- Pass any user-defined system properties -->
+ <util:tokenize var="listOfProperties" delim=" ">
+ ${cactus.sysproperties}
+ </util:tokenize>
+ <j:forEach var="someProperty" items="${listOfProperties}">
+ <ant:sysproperty key="${someProperty}"
+ value="${context.getVariable(someProperty)}"/>
+ </j:forEach>
+ <ant:classpath>
+ <ant:pathelement path="${maven.build.dest}"/>
+ <ant:pathelement location="${cactus.target.classes.dir}"/>
+ <ant:path refid="maven.dependency.classpath"/>
+ <ant:path refid="cactus.classpath"/>
+ </ant:classpath>
+ <ant:formatter type="plain" usefile="${cactus.junit.usefile}"/>
+ <ant:formatter type="xml"/>
+
+ <!-- Run only a single testcase passed in via -Dtestcase=my.single.TestCase-->
+ <ant:test name="${testcase}"/>
+
+ </cactus>
+
+ <!--attainGoal name="cactus:stop-container"/-->
+
+ </j:if>
+ </j:forEach>
+
+ </j:otherwise>
+ </j:choose>
+ </goal>
+
+ <!--
+ ========================================================================
+ Execute a Cactus tests on all containers which have been defined,
+ i.e. which have a ${cactus.home.[container name]} property
+ defined. Specify the matching tests with -Dtestmatch=FooTest
+ ========================================================================
+ -->
+ <goal name="cactus:match" prereqs="cactus:init,cactus:prepare,cactus:init-report,cactus:cactifywar"
+ description="Execute all the Cactus tests matching the given 'testmatch' variable">
+
+ <j:choose>
+ <j:when test="${empty(testmatch)}">
+ <echo>
+ You must define the test case to match via -Dtestmatch=classname
+ Example: maven -Dtestmatch=MyTest cactus:match
+ </echo>
+ </j:when>
+
+ <j:otherwise>
+ <j:set var="hasWar" value="true"/>
+ <j:set var="hasEar" value="false"/>
+ <j:forEach var="containerId" items="${cargo.containers}">
+ <j:set var="containerDirVar" value="cactus.home.${containerId}"/>
+ <j:set var="containerDir" value="${context.getVariable(containerDirVar)}"/>
+ <ant:echo> ${containerDir}</ant:echo>
+ <j:if test="${containerDir != null and !containerDir.trim().equals('')}">
+
+ <!--attainGoal name="cactus:start-container"-->
+
+ <ant:echo> "Running test ..." </ant:echo>
+ <cactus fork="yes" failureproperty="tests.failed" haltonerror="true">
+
+ <!-- Pass any user-defined system properties -->
+ <util:tokenize var="listOfProperties" delim=" ">
+ ${cactus.sysproperties}
+ </util:tokenize>
+ <j:forEach var="someProperty" items="${listOfProperties}">
+ <ant:sysproperty key="${someProperty}"
+ value="${context.getVariable(someProperty)}"/>
+ </j:forEach>
+ <ant:classpath>
+ <ant:pathelement path="${maven.build.dest}"/>
+ <ant:pathelement location="${cactus.target.classes.dir}"/>
+ <ant:path refid="maven.dependency.classpath"/>
+ <ant:path refid="cactus.classpath"/>
+ </ant:classpath>
+
+ <ant:formatter type="plain" usefile="${cactus.junit.usefile}"/>
+ <ant:formatter type="xml"/>
+
+ <containerset>
+ <cargo id="${containerId}" containerId="${containerId}"
+ home="${containerDir}/"
+ log="${maven.build.dir}/${containerId}/cargo_start.log"
+ output="${maven.build.dir}/${containerId}/container_start.log">
+ <configuration dir="${configdir}">
+ <property name="cargo.servlet.port" value="8080"/>
+ <property name="cargo.logging" value="high"/>
+
+ <j:if test="${hasWar}">
+ <deployable type="war" file="${cactus.war}"/>
+ </j:if>
+ <j:if test="${hasEar}">
+ <deployable type="ear" file="${cactus.ear}"/>
+ </j:if>
+
+ <!--<ant:ear earfile="${cactus.ear}"/> -->
+ </configuration>
+ <syspropertyset file="${logging_server}"/>
+ <!-- Additional jars that will be added to the classpath used to start
+ the container -->
+ <extraclasspath>
+ <!-- pathelement location="${clover.jar}"/ -->
+ </extraclasspath>
+
+ </cargo>
+ </containerset>
+
+ <!-- Run all testcases matched via -Dtestmatch=FooTest-->
+ <ant:batchtest>
+ <ant:fileset dir="${cactus.src.dir}">
+ <include name="**/${testmatch}.java"/>
+ </ant:fileset>
+ </ant:batchtest>
+
+ </cactus>
+
+ <!--attainGoal name="cactus:stop-container"/-->
+
+ </j:if>
+ </j:forEach>
+
+
+ </j:otherwise>
+ </j:choose>
+ </goal>
+
+ <!--
+ ========================================================================
+ Initialization before cactifying the EAR
+ ========================================================================
+ -->
+ <goal name="cactus:cactifyear-init">
+ <j:set var="isEjbProject" value="true"/>
+ </goal>
+
+ <!--
+ ========================================================================
+ Generate a Cactified EAR
+ ========================================================================
+ -->
+ <goal name="cactus:cactifyear"
+ prereqs="cactus:cactifyear-init,cactus:cactifywar,cactus:generate-ear-descriptor"
+ description="Create and cactify an EAR">
+
+ <!-- Generate the ejb artifact -->
+ <attainGoal name="${cactus.build.goal.ejb}"/>
+
+ <ant:mkdir dir="${maven.build.dir}"/>
+
+ <!-- Ensure that the ear properties are loaded in memory so that they can be
+ referenced -->
[... 390 lines stripped ...]
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org