summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Lepiller <julien@lepiller.eu>2026-03-28 18:04:11 +0100
committerJulien Lepiller <julien@lepiller.eu>2026-04-20 08:31:13 +0200
commitd3a01084151655b59470286453ef29998edd6ab2 (patch)
treed13de4e5dd6a83f7fc8e58b3777fcf56fe4952d7
parent1a7e8d47e3e1abc35514dc4b1a6ea3497481ee80 (diff)
gnu: ant/java8: Enable tests.
As a side-effect, this also builds ant-junit. * gnu/packages/java.scm (ant/java8)[build-system]: Use ant-build-system. [arguments]: Enable tests and build of ant-junit. [native-inputs]: Remove. [inputs]: Add junit and hamcrest. Change-Id: Ia6fe325b11f4a50a2466c88befcdc1f56cef7c31
-rw-r--r--gnu/packages/java.scm78
1 files changed, 31 insertions, 47 deletions
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index d0e7363d28c..3058431e297 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -1980,15 +1980,12 @@ OpenJDK.")
1980 (snippet 1980 (snippet
1981 '(begin 1981 '(begin
1982 (for-each delete-file 1982 (for-each delete-file
1983 (find-files "lib/optional" "\\.jar$")) 1983 (find-files "lib/optional" "\\.jar$"))))))
1984 #t)))) 1984 (build-system ant-build-system)
1985 (build-system gnu-build-system)
1986 (arguments 1985 (arguments
1987 (list 1986 (list
1988 #:modules '((srfi srfi-1) 1987 #:ant ant
1989 (guix build gnu-build-system) 1988 #:test-target "test"
1990 (guix build utils))
1991 #:tests? #f ;no "check" target
1992 #:phases 1989 #:phases
1993 #~(modify-phases %standard-phases 1990 #~(modify-phases %standard-phases
1994 (add-after 'unpack 'remove-scripts 1991 (add-after 'unpack 'remove-scripts
@@ -1998,54 +1995,41 @@ OpenJDK.")
1998 (for-each delete-file 1995 (for-each delete-file
1999 (find-files "src/script" 1996 (find-files "src/script"
2000 "(.*\\.(bat|cmd)|runant.*|antRun.*)")))) 1997 "(.*\\.(bat|cmd)|runant.*|antRun.*)"))))
1998 (add-after 'unpack 'link-test-dependencies
1999 (lambda* (#:key inputs #:allow-other-keys)
2000 (for-each (lambda (file)
2001 (symlink file
2002 (string-append "lib/optional/"
2003 (basename file))))
2004 (append
2005 (find-files (assoc-ref inputs "java-hamcrest-core")
2006 "\\.jar$")
2007 (find-files (assoc-ref inputs "java-hamcrest-library")
2008 "\\.jar$")
2009 (find-files (assoc-ref inputs "java-junit")
2010 "\\.jar$")))))
2011 (add-before 'build 'fix-test-failures
2012 (lambda _
2013 ;; Failure because the directory does not exist
2014 (substitute* "src/etc/testcases/taskdefs/exec/exec-with-redirector.xml"
2015 (("/usr/bin") (getcwd)))
2016 ;; Failure because it cannot read root's name in the build
2017 ;; container
2018 (delete-file "src/tests/junit/org/apache/tools/ant/types/selectors/OwnedBySelectorTest.java")
2019 ;; Cause timestamp issue when trying to rollback time by a few
2020 ;; seconds.
2021 (for-each (lambda (file) (utime file 5000))
2022 (find-files "src/etc/testcases/taskdefs" "" #:directories? #t))))
2001 (delete 'bootstrap) 2023 (delete 'bootstrap)
2002 (delete 'configure) 2024 (delete 'configure)
2003 (replace 'build 2025 (replace 'build
2004 (lambda* (#:key inputs #:allow-other-keys) 2026 (lambda* (#:key inputs #:allow-other-keys)
2005 (setenv "JAVA_HOME" (assoc-ref inputs "jdk")) 2027 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
2006
2007 ;; Disable tests to avoid dependency on hamcrest-core, which needs
2008 ;; Ant to build. This is necessary in addition to disabling the
2009 ;; "check" phase, because the dependency on "test-jar" would always
2010 ;; result in the tests to be run.
2011 (substitute* "build.xml"
2012 (("depends=\"jars,test-jar") "depends=\"jars"))
2013 (invoke "bash" "bootstrap.sh" 2028 (invoke "bash" "bootstrap.sh"
2014 (string-append "-Ddist.dir=" #$output)))) 2029 (string-append "-Ddist.dir=" #$output))))
2015 (add-after 'build 'strip-jar-timestamps ;based on ant-build-system
2016 (lambda _
2017 (define (repack-archive jar)
2018 (let* ((dir (mkdtemp "jar-contents.XXXXXX"))
2019 (manifest (string-append dir "/META-INF/MANIFESTS.MF")))
2020 (with-directory-excursion dir
2021 (invoke "unzip" jar))
2022 (delete-file jar)
2023 ;; XXX: copied from (gnu build install)
2024 (for-each (lambda (file)
2025 (let ((s (lstat file)))
2026 (unless (eq? (stat:type s) 'symlink)
2027 (utime file 0 0 0 0))))
2028 (find-files dir #:directories? #t))
2029 ;; It is important that the manifest appears first.
2030 (with-directory-excursion dir
2031 (let* ((files (find-files "." ".*" #:directories? #t))
2032 ;; To ensure that the reference scanner can
2033 ;; detect all store references in the jars
2034 ;; we disable compression with the "-0" option.
2035 (command (if (file-exists? manifest)
2036 `("zip" "-0" "-X" ,jar ,manifest
2037 ,@files)
2038 `("zip" "-0" "-X" ,jar ,@files))))
2039 (apply invoke command)))))
2040 (for-each repack-archive
2041 (find-files
2042 (string-append #$output "/lib")
2043 "\\.jar$"))))
2044 (delete 'install)))) 2030 (delete 'install))))
2045 (native-inputs 2031 (inputs
2046 `(("jdk" ,icedtea-8 "jdk") 2032 (list java-junit java-hamcrest-core java-hamcrest-library))
2047 ("zip" ,zip)
2048 ("unzip" ,unzip)))
2049 (home-page "https://ant.apache.org") 2033 (home-page "https://ant.apache.org")
2050 (synopsis "Build tool for Java") 2034 (synopsis "Build tool for Java")
2051 (description 2035 (description