summaryrefslogtreecommitdiff
path: root/guix/build/ant-build-system.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/build/ant-build-system.scm')
-rw-r--r--guix/build/ant-build-system.scm44
1 files changed, 40 insertions, 4 deletions
diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm
index 00a4a46d81..4042630a10 100644
--- a/guix/build/ant-build-system.scm
+++ b/guix/build/ant-build-system.scm
@@ -35,7 +35,8 @@
;;
;; Code:
-(define (default-build.xml jar-name prefix)
+(define* (default-build.xml jar-name prefix #:optional
+ (source-dir ".") (test-dir "./test"))
"Create a simple build.xml with standard targets for Ant."
(call-with-output-file "build.xml"
(lambda (port)
@@ -47,6 +48,10 @@
(value "${basedir}/build/jar")))
(property (@ (name "dist.dir")
(value ,prefix)))
+ (property (@ (name "test.home")
+ (value ,test-dir)))
+ (property (@ (name "test.classes.dir")
+ (value "${basedir}/build/test-classes")))
;; respect the CLASSPATH environment variable
(property (@ (name "build.sysclasspath")
@@ -58,10 +63,39 @@
(target (@ (name "compile"))
(mkdir (@ (dir "${classes.dir}")))
(javac (@ (includeantruntime "false")
- (srcdir "src")
+ (srcdir ,source-dir)
(destdir "${classes.dir}")
(classpath (@ (refid "classpath"))))))
+ (target (@ (name "compile-tests"))
+ (mkdir (@ (dir "${test.classes.dir}")))
+ (javac (@ (includeantruntime "false")
+ (srcdir ,test-dir)
+ (destdir "${test.classes.dir}"))
+ (classpath
+ (pathelement (@ (path "${env.CLASSPATH}")))
+ (pathelement (@ (location "${classes.dir}")))
+ (pathelement (@ (location "${test.classes.dir}"))))))
+
+ (target (@ (name "check")
+ (depends "compile-tests"))
+ (mkdir (@ (dir "${test.home}/test-reports")))
+ (junit (@ (printsummary "true")
+ (showoutput "true")
+ (fork "yes")
+ (haltonfailure "yes"))
+ (classpath
+ (pathelement (@ (path "${env.CLASSPATH}")))
+ (pathelement (@ (location "${test.home}/resources")))
+ (pathelement (@ (location "${classes.dir}")))
+ (pathelement (@ (location "${test.classes.dir}"))))
+ (formatter (@ (type "plain")
+ (usefile "true")))
+ (batchtest (@ (fork "yes")
+ (todir "${test.home}/test-reports"))
+ (fileset (@ (dir "${test.home}/java"))
+ (include (@ (name "**/*Test.java" )))))))
+
(target (@ (name "jar")
(depends "compile"))
(mkdir (@ (dir "${jar.dir}")))
@@ -98,11 +132,13 @@ to the default GNU unpack strategy."
((assq-ref gnu:%standard-phases 'unpack) #:source source)))
(define* (configure #:key inputs outputs (jar-name #f)
- #:allow-other-keys)
+ (source-dir "src")
+ (test-dir "src/test") #:allow-other-keys)
(when jar-name
(default-build.xml jar-name
(string-append (assoc-ref outputs "out")
- "/share/java")))
+ "/share/java")
+ source-dir test-dir))
(setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
(setenv "CLASSPATH" (generate-classpath inputs)))