gnu: java-junit: Install from pom file.

* gnu/packages/java.scm (java-junit)[arguments]: Replace install phase.
(java-hamcrest-core)[arguments]: Replace install phase.
(java-hamcrest-library)[arguments]: Replace install phase.
(java-cisd-jhdf5, java-commons-math3, java-commons-collections4)
(java-commons-io, java-commons-exec-1.1, java-commons-exec)
(java-commons-lang3, java-commons-codec, java-native-access)
(java-native-access-platform, java-hamcrest-all): Change junit and hamcrest
jar location accordingly.
(java-hamcrest-all): Use old install phase of java-hamcrest-core.
* gnu/packages/maths.scm (java-hdf): Change junit and hamcrest jar
location accordingly.
This commit is contained in:
Julien Lepiller 2020-05-16 17:04:35 +02:00
parent e0ee843f77
commit fff4fcc4e2
No known key found for this signature in database
GPG key ID: 53D457B2D636EE82
2 changed files with 105 additions and 57 deletions

View file

@ -3202,11 +3202,10 @@ (define-public java-cisd-jhdf5
(string-append (assoc-ref inputs "java-testng") (string-append (assoc-ref inputs "java-testng")
"/share/java/java-testng.jar")) "/share/java/java-testng.jar"))
(("\\$\\{lib\\}/junit4/junit.jar") (("\\$\\{lib\\}/junit4/junit.jar")
(string-append (assoc-ref inputs "java-junit") (car (find-files (assoc-ref inputs "java-junit") "jar$")))
"/share/java/junit.jar"))
(("\\$\\{lib\\}/jmock/hamcrest/hamcrest-core.jar") (("\\$\\{lib\\}/jmock/hamcrest/hamcrest-core.jar")
(string-append (assoc-ref inputs "java-hamcrest-core") (car (find-files (assoc-ref inputs "java-hamcrest-core")
"/share/java/hamcrest-core.jar"))) "jar$"))))
;; Remove dependency on ch.rinn.restrictions ;; Remove dependency on ch.rinn.restrictions
(with-directory-excursion "source/java/ch/systemsx/cisd/hdf5/" (with-directory-excursion "source/java/ch/systemsx/cisd/hdf5/"
(substitute* '("BitSetConversionUtils.java" (substitute* '("BitSetConversionUtils.java"
@ -3625,6 +3624,7 @@ (define-public java-hamcrest-core
(arguments (arguments
`(#:tests? #f ; Tests require junit `(#:tests? #f ; Tests require junit
#:modules ((guix build ant-build-system) #:modules ((guix build ant-build-system)
(guix build java-utils)
(guix build utils) (guix build utils)
(srfi srfi-1)) (srfi srfi-1))
#:make-flags (list (string-append "-Dversion=" ,version)) #:make-flags (list (string-append "-Dversion=" ,version))
@ -3678,28 +3678,18 @@ (define-public java-hamcrest-core
(lambda _ (lambda _
(mkdir-p "lib/integration") (mkdir-p "lib/integration")
#t)) #t))
(add-before 'build 'create-pom
(lambda _
(substitute* "pom/hamcrest-core.pom"
(("@VERSION@") ,version))
#t))
(replace 'install (replace 'install
(lambda* (#:key outputs #:allow-other-keys) (install-from-pom "pom/hamcrest-core.pom")))))
(let* ((target (string-append (assoc-ref outputs "out")
"/share/java/"))
(version-suffix ,(string-append "-" version ".jar"))
(install-without-version-suffix
(lambda (jar)
(copy-file jar
(string-append target
(basename jar version-suffix)
".jar")))))
(mkdir-p target)
(for-each
install-without-version-suffix
(find-files "build"
(lambda (name _)
(and (string-suffix? ".jar" name)
(not (string-suffix? "-sources.jar" name)))))))
#t)))))
(native-inputs (native-inputs
`(("java-qdox-1.12" ,java-qdox-1.12) `(("java-qdox-1.12" ,java-qdox-1.12)
("java-jarjar" ,java-jarjar))) ("java-jarjar" ,java-jarjar)))
(propagated-inputs
`(("java-hamcrest-parent-pom" ,java-hamcrest-parent-pom)))
(home-page "http://hamcrest.org/") (home-page "http://hamcrest.org/")
(synopsis "Library of matchers for building test expressions") (synopsis "Library of matchers for building test expressions")
(description (description
@ -3709,15 +3699,44 @@ (define-public java-hamcrest-core
testing frameworks, mocking libraries and UI validation rules.") testing frameworks, mocking libraries and UI validation rules.")
(license license:bsd-2))) (license license:bsd-2)))
(define java-hamcrest-parent-pom
(package
(inherit java-hamcrest-core)
(name "java-hamcrest-parent-pom")
(propagated-inputs '())
(native-inputs '())
(arguments
`(#:tests? #f
#:phases
(modify-phases %standard-phases
(delete 'configure)
(replace 'build
(lambda _
(substitute* "pom/hamcrest-parent.pom"
(("@VERSION@") ,(package-version java-hamcrest-core)))
#t))
(replace 'install
(install-pom-file "pom/hamcrest-parent.pom")))))))
(define-public java-hamcrest-library (define-public java-hamcrest-library
(package (package
(inherit java-hamcrest-core) (inherit java-hamcrest-core)
(name "java-hamcrest-library") (name "java-hamcrest-library")
(arguments (arguments
(substitute-keyword-arguments (package-arguments java-hamcrest-core) (substitute-keyword-arguments (package-arguments java-hamcrest-core)
((#:build-target _) "library"))) ((#:build-target _) "library")
((#:phases phases)
`(modify-phases ,phases
(replace 'create-pom
(lambda _
(substitute* "pom/hamcrest-library.pom"
(("@VERSION@") ,(package-version java-hamcrest-core)))
#t))
(replace 'install
(install-from-pom "pom/hamcrest-library.pom"))))))
(propagated-inputs (propagated-inputs
`(("java-hamcrest-core" ,java-hamcrest-core))))) `(("java-hamcrest-core" ,java-hamcrest-core)
("java-hamcrest-parent-pom" ,java-hamcrest-parent-pom)))))
(define-public java-junit (define-public java-junit
(package (package
@ -3750,7 +3769,9 @@ (define-public java-junit
(add-before 'check 'copy-test-resources (add-before 'check 'copy-test-resources
(lambda _ (lambda _
(copy-recursively "src/test/resources" "build/test-classes") (copy-recursively "src/test/resources" "build/test-classes")
#t))))) #t))
(replace 'install
(install-from-pom "pom.xml")))))
(propagated-inputs (propagated-inputs
`(("java-hamcrest-core" ,java-hamcrest-core))) `(("java-hamcrest-core" ,java-hamcrest-core)))
(native-inputs (native-inputs
@ -4874,8 +4895,29 @@ (define-public java-hamcrest-all
(find-files (assoc-ref inputs "java-easymock") "\\.jar$"))) (find-files (assoc-ref inputs "java-easymock") "\\.jar$")))
";")) ";"))
(("build/hamcrest-core-\\$\\{version\\}\\.jar") (("build/hamcrest-core-\\$\\{version\\}\\.jar")
(string-append (assoc-ref inputs "java-hamcrest-core") (car (find-files (assoc-ref inputs "java-hamcrest-core")
"/share/java/hamcrest-core.jar"))) "jar$"))))
#t))
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(let* ((target (string-append (assoc-ref outputs "out")
"/share/java/"))
(version-suffix
,(string-append
"-" (package-version java-hamcrest-core) ".jar"))
(install-without-version-suffix
(lambda (jar)
(copy-file jar
(string-append target
(basename jar version-suffix)
".jar")))))
(mkdir-p target)
(for-each
install-without-version-suffix
(find-files "build"
(lambda (name _)
(and (string-suffix? ".jar" name)
(not (string-suffix? "-sources.jar" name)))))))
#t))))))) #t)))))))
(inputs (inputs
`(("java-junit" ,java-junit) `(("java-junit" ,java-junit)
@ -4935,9 +4977,10 @@ (define-public java-commons-math3
#:make-flags #:make-flags
(let ((hamcrest (assoc-ref %build-inputs "java-hamcrest-core")) (let ((hamcrest (assoc-ref %build-inputs "java-hamcrest-core"))
(junit (assoc-ref %build-inputs "java-junit"))) (junit (assoc-ref %build-inputs "java-junit")))
(list (string-append "-Djunit.jar=" junit "/share/java/junit.jar") (list (string-append "-Djunit.jar="
(string-append "-Dhamcrest.jar=" hamcrest (car (find-files junit "jar$")))
"/share/java/hamcrest-core.jar"))) (string-append "-Dhamcrest.jar="
(car (find-files hamcrest ".*.jar$")))))
#:phases #:phases
(modify-phases %standard-phases (modify-phases %standard-phases
;; We want to build the jar in the build phase and run the tests ;; We want to build the jar in the build phase and run the tests
@ -5024,9 +5067,10 @@ (define-public java-commons-collections4
(let ((hamcrest (assoc-ref %build-inputs "java-hamcrest-core")) (let ((hamcrest (assoc-ref %build-inputs "java-hamcrest-core"))
(junit (assoc-ref %build-inputs "java-junit")) (junit (assoc-ref %build-inputs "java-junit"))
(easymock (assoc-ref %build-inputs "java-easymock"))) (easymock (assoc-ref %build-inputs "java-easymock")))
(list (string-append "-Djunit.jar=" junit "/share/java/junit.jar") (list (string-append "-Djunit.jar="
(string-append "-Dhamcrest.jar=" hamcrest (car (find-files junit "jar$")))
"/share/java/hamcrest-core.jar") (string-append "-Dhamcrest.jar="
(car (find-files hamcrest "jar$")))
(string-append "-Deasymock.jar=" easymock (string-append "-Deasymock.jar=" easymock
"/share/java/easymock.jar"))) "/share/java/easymock.jar")))
#:phases #:phases
@ -5161,8 +5205,8 @@ (define-public java-commons-io
`(#:test-target "test" `(#:test-target "test"
#:make-flags #:make-flags
(list (string-append "-Djunit.jar=" (list (string-append "-Djunit.jar="
(assoc-ref %build-inputs "java-junit") (car (find-files (assoc-ref %build-inputs "java-junit")
"/share/java/junit.jar")) "jar$"))))
#:phases #:phases
(modify-phases %standard-phases (modify-phases %standard-phases
(add-after 'build 'build-javadoc ant-build-javadoc) (add-after 'build 'build-javadoc ant-build-javadoc)
@ -5194,8 +5238,8 @@ (define-public java-commons-exec-1.1
`(#:test-target "test" `(#:test-target "test"
#:make-flags #:make-flags
(list (string-append "-Dmaven.junit.jar=" (list (string-append "-Dmaven.junit.jar="
(assoc-ref %build-inputs "java-junit") (car (find-files (assoc-ref %build-inputs "java-junit")
"/share/java/junit.jar")) "jar$"))))
#:phases #:phases
(modify-phases %standard-phases (modify-phases %standard-phases
(add-before 'build 'delete-network-tests (add-before 'build 'delete-network-tests
@ -5230,8 +5274,8 @@ (define-public java-commons-exec
`(#:test-target "test" `(#:test-target "test"
#:make-flags #:make-flags
(list (string-append "-Dmaven.junit.jar=" (list (string-append "-Dmaven.junit.jar="
(assoc-ref %build-inputs "java-junit") (car (find-files (assoc-ref %build-inputs "java-junit")
"/share/java/junit.jar") "jar$")))
"-Dmaven.compiler.source=1.7" "-Dmaven.compiler.source=1.7"
"-Dmaven.compiler.target=1.7") "-Dmaven.compiler.target=1.7")
#:phases #:phases
@ -5332,9 +5376,10 @@ (define-public java-commons-lang3
(junit (assoc-ref %build-inputs "java-junit")) (junit (assoc-ref %build-inputs "java-junit"))
(easymock (assoc-ref %build-inputs "java-easymock")) (easymock (assoc-ref %build-inputs "java-easymock"))
(io (assoc-ref %build-inputs "java-commons-io"))) (io (assoc-ref %build-inputs "java-commons-io")))
(list (string-append "-Djunit.jar=" junit "/share/java/junit.jar") (list (string-append "-Djunit.jar="
(string-append "-Dhamcrest.jar=" hamcrest (car (find-files junit "jar$")))
"/share/java/hamcrest-all.jar") (string-append "-Dhamcrest.jar="
(car (find-files hamcrest ".*.jar$")))
(string-append "-Dcommons-io.jar=" io (string-append "-Dcommons-io.jar=" io
"/share/java/commons-io-" "/share/java/commons-io-"
,(package-version java-commons-io) ,(package-version java-commons-io)
@ -6901,9 +6946,8 @@ (define-public java-commons-codec
#:make-flags #:make-flags
(let ((hamcrest (assoc-ref %build-inputs "java-hamcrest-core")) (let ((hamcrest (assoc-ref %build-inputs "java-hamcrest-core"))
(junit (assoc-ref %build-inputs "java-junit"))) (junit (assoc-ref %build-inputs "java-junit")))
(list (string-append "-Djunit.jar=" junit "/share/java/junit.jar") (list (string-append "-Djunit.jar=" (car (find-files junit "jar$")))
(string-append "-Dhamcrest.jar=" hamcrest (string-append "-Dhamcrest.jar=" (car (find-files hamcrest "jar$")))
"/share/java/hamcrest-core.jar")
;; Do not append version to jar. ;; Do not append version to jar.
"-Dfinal.name=commons-codec")) "-Dfinal.name=commons-codec"))
#:phases #:phases
@ -11090,11 +11134,10 @@ (define-public java-native-access
;; so don't fail if we can't find a native library for another architecture. ;; so don't fail if we can't find a native library for another architecture.
(("zipfileset") "zipfileset erroronmissingarchive=\"false\"")) (("zipfileset") "zipfileset erroronmissingarchive=\"false\""))
;; Copy test dependencies ;; Copy test dependencies
(copy-file (string-append (assoc-ref inputs "java-junit") (copy-file (car (find-files (assoc-ref inputs "java-junit") "jar$"))
"/share/java/junit.jar")
"lib/junit.jar") "lib/junit.jar")
(copy-file (string-append (assoc-ref inputs "java-hamcrest-core") (copy-file (car (find-files (assoc-ref inputs "java-hamcrest-core")
"/share/java/hamcrest-core.jar") "jar$"))
"lib/hamcrest-core.jar") "lib/hamcrest-core.jar")
;; FIXME: once reflections.jar is built, copy it to lib/test. ;; FIXME: once reflections.jar is built, copy it to lib/test.
#t)) #t))
@ -11143,11 +11186,11 @@ (define-public java-native-access-platform
(string-append (assoc-ref inputs "java-native-access") (string-append (assoc-ref inputs "java-native-access")
"/share/java/jna.jar")) "/share/java/jna.jar"))
(("../../lib/hamcrest-core-.*.jar") (("../../lib/hamcrest-core-.*.jar")
(string-append (assoc-ref inputs "java-hamcrest-core") (car (find-files (assoc-ref inputs "java-hamcrest-core")
"/share/java/hamcrest-core.jar")) "jar$")))
(("../../lib/junit.jar") (("../../lib/junit.jar")
(string-append (assoc-ref inputs "java-junit") (car (find-files (assoc-ref inputs "java-junit")
"/share/java/junit.jar"))) "jar$"))))
#t)) #t))
(replace 'install (replace 'install
(install-jars "dist"))))) (install-jars "dist")))))

View file

@ -1187,10 +1187,15 @@ (define-public hdf-java
(jhdf (string-append lib "/jhdf.jar")) (jhdf (string-append lib "/jhdf.jar"))
(jhdf5 (string-append lib "/jhdf5.jar")) (jhdf5 (string-append lib "/jhdf5.jar"))
(testjars (testjars
(append
(map (lambda (i) (map (lambda (i)
(string-append (assoc-ref inputs i) (string-append (assoc-ref inputs i)
"/share/java/" i ".jar")) "/share/java/" i ".jar"))
'("junit" "hamcrest-core" "slf4j-api" "slf4j-simple"))) '("slf4j-api" "slf4j-simple"))
(list
(car (find-files (assoc-ref inputs "junit") "jar$"))
(car (find-files (assoc-ref inputs "hamcrest-core")
"jar$")))))
(class-path (class-path
(string-join `("." ,build-dir ,jhdf ,jhdf5 ,@testjars) ":"))) (string-join `("." ,build-dir ,jhdf ,jhdf5 ,@testjars) ":")))