Scarab commit: svn commit: r10538 - trunk/build/build.xml

[email protected]
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: ronvoe122
Date: 2008-01-29 15:25:42-0800
New Revision: 10538

Modified:
   trunk/build/build.xml

Log:
Added new ant targets for: 
- executing the unit tests 
- starting and stopping the included tomcat



Modified: trunk/build/build.xml
Url: http://scarab.tigris.org/source/browse/scarab/trunk/build/build.xml?view=diff&rev=10538&p1=trunk/build/build.xml&p2=trunk/build/build.xml&r1=10537&r2=10538
==============================================================================
--- trunk/build/build.xml	(original)
+++ trunk/build/build.xml	2008-01-29 15:25:42-0800
@@ -16,7 +16,7 @@
 <!--                   scarab/src/java/org/tigris/scarab/om/...            -->
 <!-- ===================================================================== -->
 
-<project name="Scarab" default="deploy">
+<project name="Scarab" default="deploy" basedir="..">
 
     <!-- Allow the user to have multiple configuration files and
          specify them using -Dconfiguration.file=filename 
@@ -24,13 +24,14 @@
     -->         
     <property name="configuration.file" value="build.properties"/>
 
-    <property name="root.dir" value=".."/>
+    <property name="root.dir" value="."/>
     
     <property file="${root.dir}/wizzard.properties"/>
     <property file="${root.dir}/${configuration.file}"/>
     <property file="${root.dir}/project.properties" />
 
-    <property name="ant.home" value=".."/>
+    <property name="ant.home" value="${root.dir}"/>
+    <property name="tomcat.home" value="${root.dir}/tomcat"/>
 
     <property name="final.name" value="${project}-${version}"/>
     <property name="final.dir" value="${root.dir}/${final.name}/"/>
@@ -43,7 +44,9 @@
     <property name="src.webinf.dir" value="${src.webapp.dir}/WEB-INF"/>
     <property name="src.templates.dir" value="${src.webinf.dir}/templates"/>    
     <property name="src.test.dir" value="${src.dir}/test"/>
-    
+
+    <property name="build.dest.test" value="${build.dir}/test-classes"/>
+    <property name="reports.dest.test" value="${build.dir}/test-reports"/>
     <property name="torquedoc.destdir" value="${build.dir}/torquedoc"/>
     <property name="scarab.war.file.dir" value="${build.dir}"/>
     <property name="scarab.war.file.name" value="scarab.war"/>
@@ -272,11 +275,11 @@
     <target name="generate-om" depends="check-om-uptodate" 
             unless="om.uptodate">
 
-        <ant antfile="build-torque.xml" target="om" inheritAll="false">
-            <property name="lib.dir"                  value="${repository.dir}"/>
-            <property name="torque.schema.dir"        value="${src.schema.dir}"/>
-            <property name="torque.java.dir"          value="${src.java.dir.scarab}"/>
-            <property name="torque.contextProperties" value="${src.conf.dir}/torque.static.props"/>
+        <ant antfile="build/build-torque.xml" target="om" inheritAll="false">
+            <property name="lib.dir"                  value="../${repository.dir}"/>
+            <property name="torque.schema.dir"        value="../${src.schema.dir}"/>
+            <property name="torque.java.dir"          value="../${src.java.dir.scarab}"/>
+            <property name="torque.contextProperties" value="../${src.conf.dir}/torque.static.props"/>
             <property name="torque.database"          value="default"/>
         </ant>
 
@@ -290,11 +293,11 @@
     <target name="sql-specific-db" depends="check-sql-uptodate"
             unless="sql.uptodate">
         
-        <ant antfile="build-torque.xml" target="sql" inheritAll="false">
-            <property name="lib.dir"                  value="${repository.dir}"/>
-            <property name="torque.schema.dir"        value="${src.schema.dir}"/>
-            <property name="torque.sql.dir"           value="${build.project}/sql/all/${generatesql.database.type}"/>
-            <property name="torque.contextProperties" value="${src.conf.dir}/torque.static.props"/>
+        <ant antfile="build/build-torque.xml" target="sql" inheritAll="false">
+            <property name="lib.dir"                  value="../${repository.dir}"/>
+            <property name="torque.schema.dir"        value="../${src.schema.dir}"/>
+            <property name="torque.sql.dir"           value="../${build.project}/sql/all/${generatesql.database.type}"/>
+            <property name="torque.contextProperties" value="../${src.conf.dir}/torque.static.props"/>
             <property name="torque.database"          value="${generatesql.database.type}"/>
         </ant>
                     
@@ -509,18 +512,65 @@
         </copy>     
 
     </target>
- 
-<!-- ============================================================= -->
-<!-- Targets beyond this point are currently considered broken or  -->
-<!-- experimental - User Beware!                                  -->
-<!-- ============================================================= -->
 
-    <!-- Remove any torque *.generation files.  This forces torque to rebuild. -->
-    <target name="remove-generation">
+    <target name="remove-generation" description="Remove torque generation files (forces torque to rebuild)">
         <delete file="${src.sql.dir}/report.scarab.sql.generation"/>
         <delete file="${src.java.dir.scarab}/report.scarab.om.generation"/>
         <delete file="${src.java.dir.scarab}/report.scarab.om.base.generation"/>
         <delete file="${src.dir}/report.scarab.datadtd.generation"/>
     </target>
 
+   <target name="compile-test" description="compile test classes" depends="compile,generate-sql,create-custom-property-file">
+        <mkdir dir="${build.dest.test}"/>
+        <javac srcdir="${src.test.dir}"
+               destdir="${build.dest.test}">
+            <classpath refid="classpath"/>
+            <classpath path="${build.dest.scarab}"/>
+        </javac>
+    </target>
+
+   <target name="test" description="execute all tests" depends="compile-test">
+      <mkdir dir="${reports.dest.test}"/>
+      <!-- this works out of the box only with ant1.7.0 or higher
+           (http://ant.apache.org/faq.html#delegating-classloader) -->
+      <junit printsummary="true" 
+             haltonfailure="true" 
+             haltonerror="true" 
+             fork="true" 
+             forkmode="once"
+             dir=".">
+          <classpath refid="classpath"/>
+          <classpath path="${build.dest.scarab}"/>
+          <classpath path="${build.dest.test}"/>
+
+          <formatter type="plain"/>
+          <formatter type="xml"/>
+
+          <batchtest todir="${reports.dest.test}">
+             <fileset dir="${src.test.dir}">
+                <include name="**/AllScarabTests.java"/>
+             </fileset>
+          </batchtest>
+      </junit>
+   </target>
+
+   <target name="status-tomcat" description="check if the included tomcat is running">
+      <condition property="tomcat.started">
+         <socket server="localhost" port="${scarab.http.port}"/>
+      </condition>
+   </target>
+
+   <target name="stop-tomcat" depends="status-tomcat" if="tomcat.started" description="stop the included tomcat">
+      <java jar="${tomcat.home}/bin/bootstrap.jar" fork="true">
+         <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
+         <arg line="stop"/>
+      </java>
+   </target>
+
+   <target name="start-tomcat" description="start the included tomcat">
+      <java jar="${tomcat.home}/bin/bootstrap.jar" fork="true" spawn="true">
+         <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
+         <arg line="start"/>
+      </java>
+   </target>
 </project>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.