Hi everyone,
I added some targets to the maven generated build.xml
(javadoc and tests). This need came up (at least for the tests) when
someone had a bad day and wasn't able to get maven installed in a normal
timespan..
I also added the following tags to the project.xml :
<unitTest>
<resources>
<excludes/>
<includes/>
</resources>
</unitTest>
These tags are needed to have a simple way to copy over resources that
are needed by testcase (eg .betwixt, .properties files)..
Have fun ;)
Mvgr,
Martin
Index: src/java/org/apache/maven/project/UnitTest.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/project/UnitTest.java,v
retrieving revision 1.1
diff -u -r1.1 UnitTest.java
--- src/java/org/apache/maven/project/UnitTest.java 28 Jun 2002 01:59:35 -0000 1.1
+++ src/java/org/apache/maven/project/UnitTest.java 22 Jul 2002 21:27:19 -0000
@@ -62,7 +62,35 @@
/** Collects unit-test include and exclude patterns.
*
* @author <a href="mailto:[EMAIL PROTECTED]">bob mcwhirter</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Martin van den Bemt</a>
*/
public class UnitTest extends Resources
{
+ private Resources resources;
+ private List includes;
+ private List excludes;
+
+ public UnitTest()
+ {
+ this.includes = new ArrayList();
+ this.excludes = new ArrayList();
+ }
+
+ /**
+ * Sets the test resources
+ * @param resources
+ */
+ public void setResources(Resources resources)
+ {
+ this.resources = resources;
+ }
+
+ /**
+ * Gets the resources
+ * @return
+ */
+ public Resources getResources()
+ {
+ return this.resources;
+ }
}
Index: src/plugins-build/ant/plugin.jelly
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/ant/plugin.jelly,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 plugin.jelly
--- src/plugins-build/ant/plugin.jelly 14 Jul 2002 19:09:02 -0000 1.1.1.1
+++ src/plugins-build/ant/plugin.jelly 22 Jul 2002 21:27:20 -0000
@@ -23,18 +23,26 @@
<j:file name="build.xml">
<j:whitespace>
<project name="${pom.id}" default="jar" basedir=".">
-
+
+ <property name="defaulttargetdir" value="target"/>
+ <property name="classesdir" value="target/classes"/>
+ <property name="testclassesdir" value="target/test-classes"/>
+ <property name="testreportdir" value="target/test-reports"/>
+ <property name="distdir" value="dist"/>
+ <property name="javadocdir" value="target/docs/apidocs"/>
+
<target
name="jar"
- depends="get-deps">
+ depends="get-deps"
+ description="o Create the jar">
- <mkdir dir="target/classes"/>
+ <mkdir dir="$${classesdir}"/>
<javac
- destdir="target/classes"
+ destdir="$${classesdir}"
excludes="**/package.html"
- debug="false"
- deprecation="false"
+ debug="true"
+ deprecation="true"
optimize="false">
<src>
<pathelement location="${pom.build.sourceDirectory}"/>
@@ -46,27 +54,168 @@
</classpath>
</javac>
+ <j:if test="${maven.has.jar.resource.patterns}">
+
+ <!-- Copy any resources that must be present in the deployed
+ JAR file.
+ -->
+
+ <copy todir="$${classesdir}">
+ <fileset dir="${maven.jarResources.basedir}">
+ <j:forEach var="res" items="${pom.build.resources.includes}">
+ <include name="${res}"/>
+ </j:forEach>
+ <j:forEach var="res" items="${pom.build.resources.excludes}">
+ <exclude name="${res}"/>
+ </j:forEach>
+ </fileset>
+ </copy>
+
+ </j:if>
<jar
jarfile="target/${maven.final.name}.jar"
- basedir="target/classes"
+ basedir="$${classesdir}"
excludes="**/package.html"
/>
</target>
<target
- name="clean">
- <delete dir="target"/>
- <delete dir="dist"/>
+ name="clean"
+ description="o Clean up the generated directories">
+ <delete dir="$${defaulttargetdir}"/>
+ <delete dir="$${distdir}"/>
</target>
<target
name="dist"
- depends="jar">
+ depends="jar, javadoc"
+ description="o Create a distribution">
<mkdir dir="dist"/>
<copy todir="dist">
- <fileset dir="target"/>
+ <fileset dir="$${defaulttargetdir}"/>
</copy>
+ </target>
+
+ <target
+ name="test"
+ depends="compile-tests"
+ description="o Run the test cases">
+ <mkdir dir="$${testreportdir}"/>
+ <junit printSummary="yes"
+ haltonerror="true"
+ fork="true"
+ dir="./">
+ <sysproperty key="basedir" value="${pom.build.unitTestSourceDirectory}"/>
+ <formatter type="xml"/>
+ <formatter type="plain" usefile="true"/>
+ <classpath>
+ <fileset dir="lib">
+ <include name="*.jar"/>
+ </fileset>
+ <pathelement location="target/${maven.final.name}.jar"/>
+ <pathelement path="$${testclassesdir}"/>
+ </classpath>
+ <batchtest todir="$${testreportdir}">
+ <fileset dir="${pom.build.unitTestSourceDirectory}">
+ <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>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target
+ name="compile-tests"
+ depends="jar">
+ <mkdir dir="$${testclassesdir}"/>
+ <javac
+ destdir="$${testclassesdir}"
+ excludes="**/package.html"
+ debug="true"
+ deprecation="true"
+ optimize="false">
+ <src>
+ <pathelement location="${pom.build.unitTestSourceDirectory}"/>
+ </src>
+ <classpath>
+ <fileset dir="lib">
+ <include name="*.jar"/>
+ </fileset>
+ <pathelement location="target/${maven.final.name}.jar"/>
+ </classpath>
+ </javac>
+
+ <j:choose trim="true">
+ <j:when test="${!pom.build.unitTest.resources.includes.isEmpty()}">
+ <j:set var="maven.has.test.resource.patterns" value="true"/>
+ </j:when>
+ <j:when test="${!pom.build.unitTest.resources.excludes.isEmpty()}">
+ <j:set var="maven.has.test.resource.patterns" value="true"/>
+ </j:when>
+ </j:choose>
+
+ <j:if test="${maven.has.test.resource.patterns}">
+
+ <copy todir="$${testclassesdir}">
+ <fileset dir="${pom.build.unitTestSourceDirectory}">
+ <j:forEach var="res" items="${pom.build.unitTest.resources.includes}">
+ <include name="${res}"/>
+ </j:forEach>
+ <j:forEach var="res" items="${pom.build.unitTest.resources.excludes}">
+ <exclude name="${res}"/>
+ </j:forEach>
+ </fileset>
+ </copy>
+ </j:if>
+ </target>
+
+ <target
+ name="javadoc"
+ depends="jar"
+ description="o Generate javadoc">
+
+
+ <mkdir dir="$${javadocdir}"/>
+
+ <!-- Get the year to display in the Javadocs -->
+ <tstamp>
+ <format property="year" pattern="${pom.inceptionYear}-yyyy"/>
+ </tstamp>
+
+ <property
+ name="copyright"
+ value="Copyright &copy; ${year} ${pom.organization.name}. All Rights Reserved."
+ />
+
+ <property
+ name="title"
+ value="${pom.name} ${pom.currentVersion} API"
+ />
+
+ <javadoc
+ sourcepath="${pom.build.sourceDirectory}"
+ packagenames="${pom.package}.*"
+ destdir="$${javadocdir}"
+ author="true"
+ private="true"
+ version="true"
+ use="true"
+ windowtitle="${title}"
+ doctitle="${title}"
+ bottom="${copyright}">
+ <classpath>
+ <fileset dir="lib">
+ <include name="*.jar"/>
+ </fileset>
+ <pathelement location="target/${maven.final.name}.jar"/>
+ </classpath>
+ </javadoc>
+
</target>
<target
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>