From 8df1faa047870c51954275664e8e7efc94e6fc56 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Tue, 5 Sep 2017 19:04:38 +0200 Subject: guix: ant-build-system: Add main-class support. * guix/build-system/ant.scm: New #:main-class argument * guix/build/ant-build-system.scm: Generate a manifest file with additional properties. * doc/guix.texi (Build Systems): Document it. --- guix/build/ant-build-system.scm | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'guix/build/ant-build-system.scm') diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm index 4042630a10..727d3a3b25 100644 --- a/guix/build/ant-build-system.scm +++ b/guix/build/ant-build-system.scm @@ -36,7 +36,7 @@ (define-module (guix build ant-build-system) ;; Code: (define* (default-build.xml jar-name prefix #:optional - (source-dir ".") (test-dir "./test")) + (source-dir ".") (test-dir "./test") (main-class #f)) "Create a simple build.xml with standard targets for Ant." (call-with-output-file "build.xml" (lambda (port) @@ -44,6 +44,10 @@ (define* (default-build.xml jar-name prefix #:optional `(project (@ (basedir ".")) (property (@ (name "classes.dir") (value "${basedir}/build/classes"))) + (property (@ (name "manifest.dir") + (value "${basedir}/build/manifest"))) + (property (@ (name "manifest.file") + (value "${manifest.dir}/MANIFEST.MF"))) (property (@ (name "jar.dir") (value "${basedir}/build/jar"))) (property (@ (name "dist.dir") @@ -60,6 +64,17 @@ (define* (default-build.xml jar-name prefix #:optional (path (@ (id "classpath")) (pathelement (@ (location "${env.CLASSPATH}")))) + (target (@ (name "manifest")) + (mkdir (@ (dir "${manifest.dir}"))) + (echo (@ (file "${manifest.file}") + (message ,(string-append + (if main-class + (string-append + "Main-Class: " main-class + "${line.separator}") + "") + ""))))) + (target (@ (name "compile")) (mkdir (@ (dir "${classes.dir}"))) (javac (@ (includeantruntime "false") @@ -97,10 +112,11 @@ (define* (default-build.xml jar-name prefix #:optional (include (@ (name "**/*Test.java" ))))))) (target (@ (name "jar") - (depends "compile")) + (depends "compile, manifest")) (mkdir (@ (dir "${jar.dir}"))) (exec (@ (executable "jar")) - (arg (@ (line ,(string-append "-cf ${jar.dir}/" jar-name + (arg (@ (line ,(string-append "-cmf ${manifest.file} " + "${jar.dir}/" jar-name " -C ${classes.dir} .")))))) (target (@ (name "install")) @@ -133,12 +149,13 @@ (define* (unpack #:key source #:allow-other-keys) (define* (configure #:key inputs outputs (jar-name #f) (source-dir "src") - (test-dir "src/test") #:allow-other-keys) + (test-dir "src/test") + (main-class #f) #:allow-other-keys) (when jar-name (default-build.xml jar-name (string-append (assoc-ref outputs "out") "/share/java") - source-dir test-dir)) + source-dir test-dir main-class)) (setenv "JAVA_HOME" (assoc-ref inputs "jdk")) (setenv "CLASSPATH" (generate-classpath inputs))) -- cgit v1.2.3 From f403d7abdf28d2d6e4446a2989e0d37d023b6b53 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Tue, 5 Sep 2017 22:14:11 +0200 Subject: guix: ant-build-system: Add #:test-include and #:test-exclude arguments. * guix/build-system/ant.scm: Add #:test-include and #:test-exclude arguments. * guix/build/ant-build-system.scm: Generate test list from arguments. * doc/guix.texi (Build Systems): Document it. --- doc/guix.texi | 6 +++++- guix/build-system/ant.scm | 4 ++++ guix/build/ant-build-system.scm | 17 +++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) (limited to 'guix/build/ant-build-system.scm') diff --git a/doc/guix.texi b/doc/guix.texi index 312f5e7822..f0a59a6b4b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3481,7 +3481,11 @@ specify the source sub-directory, defaulting to ``src''. The @code{#:main-class} parameter can be used with the minimal ant buildfile to specify the main class of the resulting jar. This makes the -jar file executable. +jar file executable. The @code{#:test-include} parameter can be used to +specify the list of junit tests to run. It defaults to +@code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to +disable some tests. It defaults to @code{(list "**/Abstract*.java")}, +because abstract classes cannot be run as tests. The parameter @code{#:build-target} can be used to specify the Ant task that should be run during the @code{build} phase. By default the diff --git a/guix/build-system/ant.scm b/guix/build-system/ant.scm index a700230ece..b5626bd42d 100644 --- a/guix/build-system/ant.scm +++ b/guix/build-system/ant.scm @@ -100,6 +100,8 @@ (define* (ant-build store name inputs (build-target "jar") (jar-name #f) (main-class #f) + (test-include (list "**/*Test.java")) + (test-exclude (list "**/Abstract*.java")) (source-dir "src") (test-dir "src/test") (phases '(@ (guix build ant-build-system) @@ -132,6 +134,8 @@ (define builder #:build-target ,build-target #:jar-name ,jar-name #:main-class ,main-class + #:test-include (list ,@test-include) + #:test-exclude (list ,@test-exclude) #:source-dir ,source-dir #:test-dir ,test-dir #:phases ,phases diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm index 727d3a3b25..a440daf054 100644 --- a/guix/build/ant-build-system.scm +++ b/guix/build/ant-build-system.scm @@ -36,7 +36,9 @@ (define-module (guix build ant-build-system) ;; Code: (define* (default-build.xml jar-name prefix #:optional - (source-dir ".") (test-dir "./test") (main-class #f)) + (source-dir ".") (test-dir "./test") (main-class #f) + (test-include '("**/*Test.java")) + (test-exclude '("**/Abstract*Test.java"))) "Create a simple build.xml with standard targets for Ant." (call-with-output-file "build.xml" (lambda (port) @@ -109,7 +111,12 @@ (define* (default-build.xml jar-name prefix #:optional (batchtest (@ (fork "yes") (todir "${test.home}/test-reports")) (fileset (@ (dir "${test.home}/java")) - (include (@ (name "**/*Test.java" ))))))) + ,@(map (lambda (file) + `(include (@ (name ,file)))) + test-include) + ,@(map (lambda (file) + `(exclude (@ (name ,file)))) + test-exclude))))) (target (@ (name "jar") (depends "compile, manifest")) @@ -150,12 +157,14 @@ (define* (unpack #:key source #:allow-other-keys) (define* (configure #:key inputs outputs (jar-name #f) (source-dir "src") (test-dir "src/test") - (main-class #f) #:allow-other-keys) + (main-class #f) + (test-include '("**/*Test.java")) + (test-exclude '("**/Abstract*.java")) #:allow-other-keys) (when jar-name (default-build.xml jar-name (string-append (assoc-ref outputs "out") "/share/java") - source-dir test-dir main-class)) + source-dir test-dir main-class test-include test-exclude)) (setenv "JAVA_HOME" (assoc-ref inputs "jdk")) (setenv "CLASSPATH" (generate-classpath inputs))) -- cgit v1.2.3