summaryrefslogtreecommitdiff
path: root/gnu/packages/java.scm
diff options
context:
space:
mode:
authorJulien Lepiller <julien@lepiller.eu>2026-03-28 13:05:25 +0100
committerJulien Lepiller <julien@lepiller.eu>2026-04-20 08:30:27 +0200
commitc781426226d934f197e4807f91a491042277a5b9 (patch)
tree5237726ab6f89c6aa388423884fe4726be996339 /gnu/packages/java.scm
parent3699c4a4fe85c4ac1884d9458c3c0b15fca11da7 (diff)
gnu: ant: Simplify definition.
* gnu/packages/java.scm (ant)[arguments]: Clean up phases. Change-Id: I9aac740918e1ac54a9c9333a8dace9a3075fb4d0
Diffstat (limited to 'gnu/packages/java.scm')
-rw-r--r--gnu/packages/java.scm161
1 files changed, 59 insertions, 102 deletions
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 0ef3849c672..fecc6bff9ba 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -2067,108 +2067,65 @@ build process and its dependencies, whereas Make uses Makefile format.")
2067 (sha256 2067 (sha256
2068 (base32 2068 (base32
2069 "1xy30f1w5gaqk6g3f0vw7ygix4rb6032qkcw42y4z8wd9jihgygd")))) 2069 "1xy30f1w5gaqk6g3f0vw7ygix4rb6032qkcw42y4z8wd9jihgygd"))))
2070 ;; XXX: we do this to avoid a rebuild. This mess will be cleaned up 2070 (arguments
2071 ;; later. 2071 `(#:modules ((srfi srfi-1)
2072 (arguments 2072 (guix build gnu-build-system)
2073 (substitute-keyword-arguments 2073 (guix build utils))
2074 `(#:modules ((srfi srfi-1) 2074 #:tests? #f ; no "check" target
2075 (guix build gnu-build-system) 2075 #:phases
2076 (guix build utils)) 2076 (modify-phases %standard-phases
2077 #:tests? #f ; no "check" target 2077 (delete 'bootstrap)
2078 #:phases 2078 (delete 'configure)
2079 (modify-phases %standard-phases 2079 (add-after 'unpack 'remove-scripts
2080 (delete 'bootstrap) 2080 ;; Remove bat / cmd scripts for DOS as well as the antRun and runant
2081 (delete 'configure) 2081 ;; wrappers.
2082 (add-before 'build 'define-java-environment-variables 2082 (lambda _
2083 (lambda* (#:key inputs #:allow-other-keys) 2083 (for-each delete-file
2084 ;; First, set environment variables (eases debugging on -K). 2084 (find-files "src/script"
2085 (setenv "JAVA_HOME" (assoc-ref inputs "jamvm")) 2085 "(.*\\.(bat|cmd)|runant.*|antRun.*)"))))
2086 (setenv "JAVACMD" (search-input-file inputs "/bin/jamvm")) 2086 (replace 'build
2087 (setenv "JAVAC" (search-input-file inputs "/bin/jikes")) 2087 (lambda* (#:key inputs outputs #:allow-other-keys)
2088 (setenv "CLASSPATH" (search-input-file inputs "/lib/rt.jar")))) 2088 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
2089 (replace 'build 2089
2090 (lambda* (#:key inputs outputs #:allow-other-keys) 2090 ;; Disable tests to avoid dependency on hamcrest-core, which needs
2091 ;; Ant complains if this file doesn't exist. 2091 ;; Ant to build. This is necessary in addition to disabling the
2092 (setenv "HOME" "/tmp") 2092 ;; "check" phase, because the dependency on "test-jar" would always
2093 (with-output-to-file "/tmp/.ant.properties" 2093 ;; result in the tests to be run.
2094 (lambda _ (display ""))) 2094 (substitute* "build.xml"
2095 2095 (("depends=\"jars,test-jar") "depends=\"jars"))
2096 ;; Use jikes instead of javac for <javac ...> tags in build.xml 2096 (invoke "bash" "bootstrap.sh"
2097 (setenv "ANT_OPTS" "-Dbuild.compiler=jikes") 2097 (string-append "-Ddist.dir="
2098 2098 (assoc-ref outputs "out")))))
2099 ;; jikes produces lots of warnings, but they are not very 2099 (add-after 'build 'strip-jar-timestamps ;based on ant-build-system
2100 ;; interesting, so we silence them. 2100 (lambda* (#:key outputs #:allow-other-keys)
2101 (setenv "$BOOTJAVAC_OPTS" "-nowarn") 2101 (define (repack-archive jar)
2102 2102 (let* ((dir (mkdtemp "jar-contents.XXXXXX"))
2103 ;; Without these JamVM options the build may freeze. 2103 (manifest (string-append dir "/META-INF/MANIFESTS.MF")))
2104 (substitute* "bootstrap.sh" 2104 (with-directory-excursion dir
2105 (("^\"\\$\\{JAVACMD\\}\" " m) 2105 (invoke "unzip" jar))
2106 ,@(if (string-prefix? "armhf" (or (%current-system) 2106 (delete-file jar)
2107 (%current-target-system))) 2107 ;; XXX: copied from (gnu build install)
2108 `((string-append m "-Xnocompact ")) 2108 (for-each (lambda (file)
2109 `((string-append m "-Xnocompact -Xnoinlining "))))) 2109 (let ((s (lstat file)))
2110 2110 (unless (eq? (stat:type s) 'symlink)
2111 ;; Disable tests because we are bootstrapping and thus don't have 2111 (utime file 0 0 0 0))))
2112 ;; any of the dependencies required to build and run the tests. 2112 (find-files dir #:directories? #t))
2113 (substitute* "build.xml" 2113 ;; It is important that the manifest appears first.
2114 (("depends=\"jars,test-jar\"") "depends=\"jars\"")) 2114 (with-directory-excursion dir
2115 (invoke "bash" "bootstrap.sh" 2115 (let* ((files (find-files "." ".*" #:directories? #t))
2116 (string-append "-Ddist.dir=" 2116 ;; To ensure that the reference scanner can
2117 (assoc-ref outputs "out"))))) 2117 ;; detect all store references in the jars
2118 (add-after 'build 'strip-jar-timestamps ;based on ant-build-system 2118 ;; we disable compression with the "-0" option.
2119 (lambda* (#:key outputs #:allow-other-keys) 2119 (command (if (file-exists? manifest)
2120 (define (repack-archive jar) 2120 `("zip" "-0" "-X" ,jar ,manifest
2121 (let* ((dir (mkdtemp "jar-contents.XXXXXX")) 2121 ,@files)
2122 (manifest (string-append dir "/META-INF/MANIFESTS.MF"))) 2122 `("zip" "-0" "-X" ,jar ,@files))))
2123 (with-directory-excursion dir 2123 (apply invoke command)))))
2124 (invoke "unzip" jar)) 2124 (for-each repack-archive
2125 (delete-file jar) 2125 (find-files
2126 ;; XXX: copied from (gnu build install) 2126 (string-append (assoc-ref %outputs "out") "/lib")
2127 (for-each (lambda (file) 2127 "\\.jar$"))))
2128 (let ((s (lstat file))) 2128 (delete 'install))))
2129 (unless (eq? (stat:type s) 'symlink)
2130 (utime file 0 0 0 0))))
2131 (find-files dir #:directories? #t))
2132 ;; It is important that the manifest appears first.
2133 (with-directory-excursion dir
2134 (let* ((files (find-files "." ".*" #:directories? #t))
2135 ;; To ensure that the reference scanner can
2136 ;; detect all store references in the jars
2137 ;; we disable compression with the "-0" option.
2138 (command (if (file-exists? manifest)
2139 `("zip" "-0" "-X" ,jar ,manifest
2140 ,@files)
2141 `("zip" "-0" "-X" ,jar ,@files))))
2142 (apply invoke command)))))
2143 (for-each repack-archive
2144 (find-files
2145 (string-append (assoc-ref %outputs "out") "/lib")
2146 "\\.jar$"))))
2147 (delete 'install)))
2148 ((#:phases phases)
2149 `(modify-phases ,phases
2150 (delete 'define-java-environment-variables)
2151 (add-after 'unpack 'remove-scripts
2152 ;; Remove bat / cmd scripts for DOS as well as the antRun and runant
2153 ;; wrappers.
2154 (lambda _
2155 (for-each delete-file
2156 (find-files "src/script"
2157 "(.*\\.(bat|cmd)|runant.*|antRun.*)"))
2158 #t))
2159 (replace 'build
2160 (lambda* (#:key inputs outputs #:allow-other-keys)
2161 (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
2162
2163 ;; Disable tests to avoid dependency on hamcrest-core, which needs
2164 ;; Ant to build. This is necessary in addition to disabling the
2165 ;; "check" phase, because the dependency on "test-jar" would always
2166 ;; result in the tests to be run.
2167 (substitute* "build.xml"
2168 (("depends=\"jars,test-jar") "depends=\"jars"))
2169 (invoke "bash" "bootstrap.sh"
2170 (string-append "-Ddist.dir="
2171 (assoc-ref outputs "out")))))))))
2172 (native-inputs 2129 (native-inputs
2173 `(("jdk" ,icedtea-7 "jdk") 2130 `(("jdk" ,icedtea-7 "jdk")
2174 ("zip" ,zip) 2131 ("zip" ,zip)