You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by gs...@apache.org on 2008/02/11 03:49:48 UTC

svn commit: r620384 - /lucene/mahout/trunk/build.xml

Author: gsingers
Date: Sun Feb 10 18:49:47 2008
New Revision: 620384

URL: http://svn.apache.org/viewvc?rev=620384&view=rev
Log:
build.xml changes for testing, compilation, etc.

Modified:
    lucene/mahout/trunk/build.xml

Modified: lucene/mahout/trunk/build.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/build.xml?rev=620384&r1=620383&r2=620384&view=diff
==============================================================================
--- lucene/mahout/trunk/build.xml (original)
+++ lucene/mahout/trunk/build.xml Sun Feb 10 18:49:47 2008
@@ -46,7 +46,7 @@
   <property name="lib" value="lib" />
 
   <!-- mahout source files -->
-  <property name="src" value="src/main" />
+  <property name="src" value="src" />
 
   <!-- Destination for compiled classes and binaries -->
   <property name="dest" value="build" />
@@ -90,6 +90,37 @@
   <property name="junit.output.dir" location="${dest}/test-results"/>
   <property name="junit.reports" location="${dest}/test-results/reports"/>
   <property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
+  <property name="tests.verbose" value="false"/>
+
+  <property name="junit.excludes" value=""/>
+  <property name="junit.jar" value="junit-3.8.2.jar"/>
+  <property name="junit-location.jar" value="${lib}/${junit.jar}"/>
+  <path id="junit-path">
+    <pathelement location="${junit-location.jar}"/>
+  </path>
+
+  <!-- The compilation classpath -->
+  <path id="compile.classpath">
+    <fileset dir="${lib}">
+      <include name="*.jar" />
+      <exclude name="junit*.jar"/>
+    </fileset>
+  </path>
+  <path id="test.classpath">
+    <path refid="junit-path"/>
+    <path refid="compile.classpath"/>
+    <pathelement location="${dest}/test-classes"/>
+    <pathelement location="${dest}/classes"/>
+  </path>
+
+
+  <path id="junit.classpath">
+    <path refid="junit-path"/>
+    <pathelement location="${dest}/test-classes"/>
+    <pathelement location="${dest}/classes"/>
+    <path refid="compile.classpath"/>
+    <pathelement path="${java.class.path}"/>
+  </path>
 
   <!-- Macro for compilation -->
   <macrodef name="mahout-javac">
@@ -182,22 +213,13 @@
   <!-- ===================== COMPILATION-RELATED TASKS ========================= -->
   <!-- ========================================================================= -->
 
-
-  <!-- The compilation classpath -->
-  <path id="compile.classpath">
-    <fileset dir="${lib}">
-      <include name="*.jar" />
-    </fileset>
-  </path>
-
   <!-- Compile the project. -->
   <target name="compile"
           description="Compile the source code."
           >
-
-    <mahout-javac destdir="${dest}/core"
+    <mahout-javac destdir="${dest}/classes"
                 classpathref="compile.classpath">
-      <src path="${src}/java" />
+      <src path="${src}/main/java" />
     </mahout-javac>
   </target>
 
@@ -222,15 +244,63 @@
       doctitle="${Name} ${version} API (${specversion})"
       bottom="Copyright &amp;copy; ${javadoc.years} The Apache Software Foundation"
       >
-        <packageset dir="${src}/java"/>
-        <packageset dir="${src}/webapp/src"/>
+        <packageset dir="${src}/main/java"/>
         <link href="${javadoc.link.java}"/>
         <link href="${javadoc.link.junit}"/>
-        <link href="${javadoc.link.lucene}"/>
         <classpath refid="javadoc.classpath"/>
     </javadoc>
   </target>
 
+  <target name="compile-test" depends="compile">
+    <mahout-javac
+
+      destdir="${dest}/test-classes/" classpathref="test.classpath">
+      <src path="${src}/test/java"/>
+      </mahout-javac>
+
+    <!-- Copy any data files present to the classpath -->
+    <copy todir="${dest}/test-classes">
+      <fileset dir="src/test/java" excludes="**/*.java"/>
+    </copy>
+  </target>
+
+
+
+  <target name="test" depends="compile-test" description="Runs unit tests">
+    <mkdir dir="${junit.output.dir}"/>
+    <junit printsummary="off" haltonfailure="no"
+      errorProperty="tests.failed" failureProperty="tests.failed">
+      <classpath refid="junit.classpath"/>
+      <assertions>
+        <enable package="org.apache.mahout"/>
+      </assertions>
+
+      <!-- allow tests to control debug prints -->
+      <sysproperty key="tests.verbose" value="${tests.verbose}"/>
+
+      <!-- TODO: create propertyset for test properties, so each project can have its own set -->
+      <sysproperty key="dataDir" file="src/test"/>
+      <sysproperty key="tempDir" file="${dest}/test"/>
+      <sysproperty key="java.io.tmpdir" file="${dest}/test"/>
+
+
+      <formatter type="xml"/>
+      <formatter type="brief" usefile="false"/>
+      <batchtest fork="yes" todir="${junit.output.dir}" unless="testcase">
+        <fileset dir="${src}/test/java" includes="${junit.includes}" excludes="${junit.excludes}"/>
+      </batchtest>
+      <batchtest fork="yes" todir="${junit.output.dir}" if="testcase">
+        <fileset dir="${src}/test/java" includes="**/${testcase}.java"/>
+      </batchtest>
+    </junit>
+    <!-- create this file, then if we don't fail, delete it -->
+    <!-- this meme makes it easy to tell if contribs have failed later -->
+    <echo file="${dest}/junitfailed.flag">MAYBE</echo>
+    <fail if="tests.failed">Tests failed!</fail>
+    <!-- life would be easier if echo had an 'if' attribute like fail -->
+    <delete file="${dest}/test/junitfailed.flag" />
+
+  </target>
 
   <target name="dist-jar"
           description="Creates the Mahout JAR Distribution file."
@@ -238,7 +308,7 @@
     <mkdir dir="${dist}" />
     <mahout-jar
          destfile="${dist}/${fullnamever}.jar"
-         basedir="${dest}/core" />
+         basedir="${dest}/classes" />
 
   </target>