git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@320941 13f79535-47bb-0310-9956-ffa450edef68
451 lines
18 KiB
XML
451 lines
18 KiB
XML
<?xml version="1.0"?>
|
|
<!--
|
|
/*
|
|
* Copyright 2001-2004 The Apache Software Foundation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
-->
|
|
|
|
|
|
<project xmlns:j="jelly:core"
|
|
xmlns:maven="jelly:maven"
|
|
xmlns:u="jelly:util"
|
|
xmlns:define="jelly:define" xmlns:ant="jelly:ant">
|
|
|
|
<goal name="test"
|
|
description="Test the application"
|
|
prereqs="test:test"/>
|
|
|
|
<goal name="test:prepare-filesystem"
|
|
description="Create the needed directory structure">
|
|
<mkdir dir="${maven.test.dest}"/>
|
|
<mkdir dir="${maven.test.reportsDirectory}"/>
|
|
</goal>
|
|
|
|
<goal name="test:compile"
|
|
description="Compile the TestCases and TestSuites"
|
|
prereqs="java:compile,java:jar-resources,test:prepare-filesystem,test:test-resources">
|
|
|
|
<j:set var="maven.test.searchdir" value="${maven.test.dest}"/>
|
|
<j:if test="${context.getVariable('maven.test.search.classdir') == null}">
|
|
<j:set var="maven.test.searchdir" value="${pom.build.unitTestSourceDirectory}"/>
|
|
</j:if>
|
|
|
|
<j:if test="${unitTestSourcesPresent == 'true' and context.getVariable('maven.test.skip') != 'true'}">
|
|
|
|
<javac
|
|
destdir="${maven.test.dest}"
|
|
excludes="**/package.html"
|
|
debug="${maven.compile.debug}"
|
|
deprecation="${maven.compile.deprecation}"
|
|
optimize="${maven.compile.optimize}">
|
|
<j:if test="${context.getVariable('maven.test.source') != null}">
|
|
<setProperty name="source" value="${maven.test.source}" />
|
|
</j:if>
|
|
<classpath>
|
|
<pathelement path="${maven.test.dest}"/>
|
|
<pathelement path="${maven.build.dest}"/>
|
|
<path refid="maven.dependency.classpath"/>
|
|
<pathelement path="${plugin.getDependencyPath('junit')}"/>
|
|
<j:if test="${!context.getVariable('maven.junit.fork').toString().trim().equalsIgnoreCase('no') and !context.getVariable('maven.test.excludeXmlApis').toString().trim().equalsIgnoreCase('yes') }">
|
|
<pathelement path="${plugin.getDependencyPath('xerces:xmlParserAPIs')}"/>
|
|
<pathelement path="${plugin.getDependencyPath('xerces:xercesImpl')}"/>
|
|
</j:if>
|
|
</classpath>
|
|
<src>
|
|
<path refid="maven.test.compile.src.set"/>
|
|
</src>
|
|
|
|
<!--
|
|
|
|
|
| Source Modifications.
|
|
|
|
|
-->
|
|
|
|
<j:forEach var="sm" items="${pom.build.sourceModifications}">
|
|
<ant:available property="classPresent" classname="${sm.className}"/>
|
|
<j:if test="${classPresent != 'true'}">
|
|
<j:forEach var="exclude" items="${sm.excludes}">
|
|
<ant:exclude name="${exclude}"/>
|
|
</j:forEach>
|
|
<j:forEach var="include" items="${sm.includes}">
|
|
<ant:include name="${include}"/>
|
|
</j:forEach>
|
|
</j:if>
|
|
</j:forEach>
|
|
|
|
<j:if test="${context.getVariable('maven.compile.compilerargs') != null}">
|
|
<compilerarg line="${maven.compile.compilerargs}" />
|
|
</j:if>
|
|
|
|
<j:if test="${context.getVariable('maven.compile.encoding') != null}">
|
|
<setProperty name="encoding" value="${maven.compile.encoding}" />
|
|
</j:if>
|
|
|
|
<j:if test="${context.getVariable('maven.compile.executable') != null}">
|
|
<setProperty name="executable" value="${maven.compile.executable}" />
|
|
</j:if>
|
|
|
|
<j:if test="${context.getVariable('maven.compile.fork') != null}">
|
|
<setProperty name="fork" value="${maven.compile.fork}" />
|
|
</j:if>
|
|
|
|
<j:if test="${context.getVariable('maven.compile.source') != null}">
|
|
<setProperty name="source" value="${maven.compile.source}" />
|
|
</j:if>
|
|
|
|
<j:if test="${context.getVariable('maven.compile.verbose') != null}">
|
|
<setProperty name="verbose" value="${maven.compile.verbose}" />
|
|
</j:if>
|
|
</javac>
|
|
</j:if>
|
|
|
|
<j:if test="${!unitTestSourcesPresent}">
|
|
<echo>No test source files to compile.</echo>
|
|
</j:if>
|
|
|
|
</goal>
|
|
|
|
<goal name="test:test"
|
|
description="Test the application"
|
|
prereqs="test:compile">
|
|
|
|
<j:if test="${unitTestSourcesPresent == 'true' and context.getVariable('maven.test.skip') != 'true'}">
|
|
|
|
<taskdef
|
|
name="junit"
|
|
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"
|
|
/>
|
|
|
|
<junit printSummary="${maven.junit.printSummary}"
|
|
failureProperty="maven.test.failure"
|
|
fork="${maven.junit.fork}"
|
|
forkmode="${maven.junit.forkmode}">
|
|
|
|
<j:if test="${context.getVariable('maven.junit.jvm') != null}">
|
|
<setProperty name="jvm" value="${maven.junit.jvm}" />
|
|
</j:if>
|
|
<j:if test="${!context.getVariable('maven.junit.fork').toString().trim().equalsIgnoreCase('no')}">
|
|
<setProperty name="dir" value="${maven.junit.dir}" />
|
|
</j:if>
|
|
<sysproperty key="basedir" value="${basedir}"/>
|
|
<u:tokenize var="listOfProperties" delim=" ">${maven.junit.sysproperties}</u:tokenize>
|
|
<j:forEach var="someProperty" items="${listOfProperties}">
|
|
<sysproperty key="${someProperty}" value="${context.getVariable(someProperty)}"/>
|
|
</j:forEach>
|
|
<u:tokenize var="listOfEnv" delim=" ">${maven.junit.envvars}</u:tokenize>
|
|
<j:forEach var="someEnv" items="${listOfEnv}">
|
|
<env key="${someEnv}" value="${context.getVariable(someEnv)}"/>
|
|
</j:forEach>
|
|
<u:tokenize var="listOfJvmArgs" delim=" ">${maven.junit.jvmargs}</u:tokenize>
|
|
<j:forEach var="somejvmarg" items="${listOfJvmArgs}">
|
|
<jvmarg value="${somejvmarg}"/>
|
|
</j:forEach>
|
|
<formatter type="xml"/>
|
|
<formatter type="${maven.junit.format}" usefile="${maven.junit.usefile}"/>
|
|
<classpath>
|
|
<pathelement location="${maven.test.dest}"/>
|
|
<pathelement location="${maven.build.dest}"/>
|
|
<path refid="maven.dependency.classpath"/>
|
|
<pathelement path="${plugin.getDependencyPath('junit')}"/>
|
|
<j:if test="${!context.getVariable('maven.junit.fork').toString().trim().equalsIgnoreCase('no') and !context.getVariable('maven.test.excludeXmlApis').toString().trim().equalsIgnoreCase('yes') }">
|
|
<pathelement path="${plugin.getDependencyPath('xerces:xmlParserAPIs')}"/>
|
|
<pathelement path="${plugin.getDependencyPath('xerces:xercesImpl')}"/>
|
|
</j:if>
|
|
</classpath>
|
|
<batchtest todir="${maven.test.reportsDirectory}">
|
|
<fileset dir="${maven.test.searchdir}">
|
|
<j:forEach var="pat" items="${pom.build.unitTest.includes}">
|
|
<include name="${pat}"/>
|
|
</j:forEach>
|
|
<j:forEach var="pat" items="${pom.build.unitTest.excludes}">
|
|
<exclude name="${pat}"/>
|
|
</j:forEach>
|
|
<!-- KEEP ALL ABSTRACT TESTS FROM BEING RUN! -->
|
|
<exclude name="**/*AbstractTestCase.java"/>
|
|
</fileset>
|
|
</batchtest>
|
|
</junit>
|
|
|
|
<j:if test="${maven.test.failure}">
|
|
<j:if test="${context.getVariable('maven.test.failure.ignore') != 'true'}">
|
|
<fail message="There were test failures."/>
|
|
</j:if>
|
|
</j:if>
|
|
|
|
</j:if>
|
|
|
|
<j:if test="${!unitTestSourcesPresent}">
|
|
<echo>No tests to run.</echo>
|
|
</j:if>
|
|
|
|
</goal>
|
|
|
|
<goal name="test:ui"
|
|
description="Starts the Swing TestRunner front end"
|
|
prereqs="test:compile">
|
|
|
|
<java classname="junit.swingui.TestRunner" fork="yes">
|
|
<sysproperty key="basedir" value="${basedir}"/>
|
|
<u:tokenize var="listOfProperties" delim=" ">${maven.junit.sysproperties}</u:tokenize>
|
|
<j:forEach var="someProperty" items="${listOfProperties}">
|
|
<sysproperty key="${someProperty}" value="${context.getVariable(someProperty)}"/>
|
|
</j:forEach>
|
|
<u:tokenize var="listOfEnv" delim=" ">${maven.junit.envvars}</u:tokenize>
|
|
<j:forEach var="someEnv" items="${listOfEnv}">
|
|
<env key="${someEnv}" value="${context.getVariable(someEnv)}"/>
|
|
</j:forEach>
|
|
<u:tokenize var="listOfJvmArgs" delim=" ">${maven.junit.jvmargs}</u:tokenize>
|
|
<j:forEach var="somejvmarg" items="${listOfJvmArgs}">
|
|
<jvmarg value="${somejvmarg}"/>
|
|
</j:forEach>
|
|
<classpath>
|
|
<pathelement location="${maven.test.dest}"/>
|
|
<pathelement location="${maven.build.dest}"/>
|
|
<path refid="maven.dependency.classpath"/>
|
|
<pathelement path="${plugin.getDependencyPath('junit')}"/>
|
|
<j:if test="${!context.getVariable('maven.junit.fork').toString().trim().equalsIgnoreCase('no') and !context.getVariable('maven.test.excludeXmlApis').toString().trim().equalsIgnoreCase('yes') }">
|
|
<pathelement path="${plugin.getDependencyPath('xerces:xmlParserAPIs')}"/>
|
|
<pathelement path="${plugin.getDependencyPath('xerces:xercesImpl')}"/>
|
|
</j:if>
|
|
</classpath>
|
|
<arg value="-noloading"/>
|
|
</java>
|
|
|
|
</goal>
|
|
|
|
|
|
<goal name="test:single"
|
|
description="Execute a single test defined using the 'testcase' variable"
|
|
prereqs="test:compile">
|
|
|
|
<j:if test="${unitTestSourcesPresent == 'true'}">
|
|
|
|
<j:choose>
|
|
<j:when test="${empty(testcase)}">
|
|
<echo>
|
|
You must define the test case to run via -Dtestcase=classname
|
|
Example: maven -Dtestcase=MyTest test:single
|
|
</echo>
|
|
</j:when>
|
|
|
|
<j:otherwise>
|
|
|
|
<taskdef
|
|
name="junit"
|
|
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"
|
|
/>
|
|
|
|
<junit printSummary="${maven.junit.printSummary}"
|
|
failureProperty="maven.test.failure"
|
|
fork="${maven.junit.fork}"
|
|
dir="${maven.junit.dir}"
|
|
forkmode="${maven.junit.forkmode}">
|
|
|
|
<j:if test="${context.getVariable('maven.junit.jvm') != null}">
|
|
<setProperty name="jvm" value="${maven.junit.jvm}" />
|
|
</j:if>
|
|
<sysproperty key="basedir" value="${basedir}"/>
|
|
<u:tokenize var="listOfProperties" delim=" ">${maven.junit.sysproperties}</u:tokenize>
|
|
<j:forEach var="someProperty" items="${listOfProperties}">
|
|
<sysproperty key="${someProperty}" value="${context.getVariable(someProperty)}"/>
|
|
</j:forEach>
|
|
<u:tokenize var="listOfEnv" delim=" ">${maven.junit.envvars}</u:tokenize>
|
|
<j:forEach var="someEnv" items="${listOfEnv}">
|
|
<env key="${someEnv}" value="${context.getVariable(someEnv)}"/>
|
|
</j:forEach>
|
|
<u:tokenize var="listOfJvmArgs" delim=" ">${maven.junit.jvmargs}</u:tokenize>
|
|
<j:forEach var="somejvmarg" items="${listOfJvmArgs}">
|
|
<jvmarg value="${somejvmarg}"/>
|
|
</j:forEach>
|
|
<formatter type="xml"/>
|
|
<formatter type="${maven.junit.format}" usefile="${maven.junit.usefile}"/>
|
|
|
|
<classpath>
|
|
<pathelement location="${maven.test.dest}"/>
|
|
<pathelement location="${maven.build.dest}"/>
|
|
<path refid="maven.dependency.classpath"/>
|
|
<pathelement path="${plugin.getDependencyPath('junit')}"/>
|
|
<j:if test="${!context.getVariable('maven.junit.fork').toString().trim().equalsIgnoreCase('no') and !context.getVariable('maven.test.excludeXmlApis').toString().trim().equalsIgnoreCase('yes') }">
|
|
<pathelement path="${plugin.getDependencyPath('xerces:xmlParserAPIs')}"/>
|
|
<pathelement path="${plugin.getDependencyPath('xerces:xercesImpl')}"/>
|
|
</j:if>
|
|
</classpath>
|
|
|
|
<test name="${testcase}" todir="${maven.test.reportsDirectory}"/>
|
|
|
|
</junit>
|
|
|
|
<j:if test="${maven.test.failure}">
|
|
<j:if test="${context.getVariable('maven.test.failure.ignore') != 'true'}">
|
|
<fail message="There were test failures."/>
|
|
</j:if>
|
|
</j:if>
|
|
|
|
</j:otherwise>
|
|
</j:choose>
|
|
</j:if>
|
|
|
|
<j:if test="${!unitTestSourcesPresent}">
|
|
<echo>No tests to run.</echo>
|
|
</j:if>
|
|
|
|
</goal>
|
|
|
|
|
|
<goal name="test:match"
|
|
description="Execute all the tests matching the given 'testmatch' variable"
|
|
prereqs="test:compile">
|
|
|
|
<j:if test="${unitTestSourcesPresent == 'true'}">
|
|
|
|
<j:if test="${context.getVariable('testmatch') != null}">
|
|
<echo>[deprecated] testmatch property is deprecated, please use testmatchpattern instead</echo>
|
|
<j:set var="testmatchpattern" value="**/${testmatch}.*"/>
|
|
</j:if>
|
|
|
|
<j:choose>
|
|
<j:when test="${empty(testmatchpattern)}">
|
|
<echo>
|
|
You must define the test case to run via -Dtestmatchpattern=pattern
|
|
Example: maven -Dtestmatchpattern=*Foo* test:match
|
|
</echo>
|
|
</j:when>
|
|
|
|
<j:otherwise>
|
|
|
|
<taskdef
|
|
name="junit"
|
|
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"
|
|
/>
|
|
|
|
<echo>Searching directory ${maven.test.searchdir}</echo>
|
|
|
|
<junit printSummary="${maven.junit.printSummary}"
|
|
failureProperty="maven.test.failure"
|
|
fork="${maven.junit.fork}"
|
|
dir="${maven.junit.dir}"
|
|
forkmode="${maven.junit.forkmode}">
|
|
|
|
<j:if test="${context.getVariable('maven.junit.jvm') != null}">
|
|
<setProperty name="jvm" value="${maven.junit.jvm}" />
|
|
</j:if>
|
|
<sysproperty key="basedir" value="${basedir}"/>
|
|
<u:tokenize var="listOfProperties" delim=" ">${maven.junit.sysproperties}</u:tokenize>
|
|
<j:forEach var="someProperty" items="${listOfProperties}">
|
|
<sysproperty key="${someProperty}" value="${context.getVariable(someProperty)}"/>
|
|
</j:forEach>
|
|
<u:tokenize var="listOfEnv" delim=" ">${maven.junit.envvars}</u:tokenize>
|
|
<j:forEach var="someEnv" items="${listOfEnv}">
|
|
<env key="${someEnv}" value="${context.getVariable(someEnv)}"/>
|
|
</j:forEach>
|
|
<u:tokenize var="listOfJvmArgs" delim=" ">${maven.junit.jvmargs}</u:tokenize>
|
|
<j:forEach var="somejvmarg" items="${listOfJvmArgs}">
|
|
<jvmarg value="${somejvmarg}"/>
|
|
</j:forEach>
|
|
<formatter type="xml"/>
|
|
<formatter type="${maven.junit.format}" usefile="${maven.junit.usefile}"/>
|
|
|
|
<classpath>
|
|
<pathelement location="${maven.test.dest}"/>
|
|
<pathelement location="${maven.build.dest}"/>
|
|
<path refid="maven.dependency.classpath"/>
|
|
<pathelement path="${plugin.getDependencyPath('junit')}"/>
|
|
<j:if test="${!context.getVariable('maven.junit.fork').toString().trim().equalsIgnoreCase('no') and !context.getVariable('maven.test.excludeXmlApis').toString().trim().equalsIgnoreCase('yes') }">
|
|
<pathelement path="${plugin.getDependencyPath('xerces:xmlParserAPIs')}"/>
|
|
<pathelement path="${plugin.getDependencyPath('xerces:xercesImpl')}"/>
|
|
</j:if>
|
|
</classpath>
|
|
|
|
<batchtest todir="${maven.test.reportsDirectory}">
|
|
<fileset dir="${maven.test.searchdir}">
|
|
|
|
<!-- includes -->
|
|
<u:tokenize var="includeItems" delim=",">${testmatchpattern}</u:tokenize>
|
|
<j:forEach var="include" items="${includeItems}">
|
|
<include name="${include}"/>
|
|
</j:forEach>
|
|
|
|
<!-- excludes -->
|
|
<j:if test="${context.getVariable('testnotmatchpattern') != null}">
|
|
<u:tokenize var="excludeItems" delim=",">${testnotmatchpattern}</u:tokenize>
|
|
<j:forEach var="exclude" items="${excludeItems}">
|
|
<exclude name="${exclude}"/>
|
|
</j:forEach>
|
|
</j:if>
|
|
|
|
</fileset>
|
|
</batchtest>
|
|
|
|
</junit>
|
|
|
|
<j:if test="${maven.test.failure}">
|
|
<j:if test="${context.getVariable('maven.test.failure.ignore') != 'true'}">
|
|
<fail message="There were test failures."/>
|
|
</j:if>
|
|
</j:if>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
</j:if>
|
|
|
|
<j:if test="${!unitTestSourcesPresent}">
|
|
<echo>No tests to run.</echo>
|
|
</j:if>
|
|
|
|
</goal>
|
|
|
|
<goal name="test:single-test"
|
|
description="[deprecated] please use the test:single goal instead">
|
|
|
|
<echo>[deprecated] please use the test:single goal instead</echo>
|
|
|
|
<attainGoal name="test:single"/>
|
|
</goal>
|
|
|
|
<goal name="test:match-test"
|
|
description="[deprecated] please use the test:match goal instead">
|
|
|
|
<echo>[deprecated] please use the test:match goal instead</echo>
|
|
|
|
<attainGoal name="test:match"/>
|
|
</goal>
|
|
|
|
<!-- ================================================================== -->
|
|
<!-- T E S T R E S O U R C E S -->
|
|
<!-- ================================================================== -->
|
|
|
|
<goal name="test:test-resources"
|
|
description="Copy any resources that must be present for run tests"
|
|
prereqs="test:prepare-filesystem">
|
|
|
|
<j:if test="${unitTestSourcesPresent == 'true' and context.getVariable('maven.test.skip') != 'true'}">
|
|
<j:if test="${pom.build.unitTest != null}">
|
|
<j:if test="${!pom.build.unitTest.resources.isEmpty()}">
|
|
<maven:copy-resources
|
|
resources="${pom.build.unitTest.resources}"
|
|
todir="${maven.test.dest}"
|
|
/>
|
|
</j:if>
|
|
</j:if>
|
|
</j:if>
|
|
</goal>
|
|
|
|
<define:taglib uri="test">
|
|
<define:tag name="dependency-handle">
|
|
<!-- XXX Use this tag to allow this plugin to be loaded into another -->
|
|
<echo>DEPRECATED: the use of dependency-handle is deprecated. Please use maven:get/set to modify properties of the test plugin</echo>
|
|
</define:tag>
|
|
</define:taglib>
|
|
</project>
|