guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

06/110: gnu: java-junit: Install from pom file.


From: guix-commits
Subject: 06/110: gnu: java-junit: Install from pom file.
Date: Thu, 16 Jul 2020 22:23:11 -0400 (EDT)

roptat pushed a commit to branch master
in repository guix.

commit fff4fcc4e22f11788dfaf103141ff6cffbf788dc
Author: Julien Lepiller <julien@lepiller.eu>
AuthorDate: Sat May 16 17:04:35 2020 +0200

    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.
---
 gnu/packages/java.scm  | 149 +++++++++++++++++++++++++++++++------------------
 gnu/packages/maths.scm |  13 +++--
 2 files changed, 105 insertions(+), 57 deletions(-)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 70d8b61..9d32a51 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -3202,11 +3202,10 @@ libraries from the SIS division at ETH Zurich like 
jHDF5.")
                   (string-append (assoc-ref inputs "java-testng")
                                  "/share/java/java-testng.jar"))
                  (("\\$\\{lib\\}/junit4/junit.jar")
-                  (string-append (assoc-ref inputs "java-junit")
-                                 "/share/java/junit.jar"))
+                  (car (find-files (assoc-ref inputs "java-junit") "jar$")))
                  (("\\$\\{lib\\}/jmock/hamcrest/hamcrest-core.jar")
-                  (string-append (assoc-ref inputs "java-hamcrest-core")
-                                 "/share/java/hamcrest-core.jar")))
+                  (car (find-files (assoc-ref inputs "java-hamcrest-core")
+                                   "jar$"))))
                ;; Remove dependency on ch.rinn.restrictions
                (with-directory-excursion "source/java/ch/systemsx/cisd/hdf5/"
                  (substitute* '("BitSetConversionUtils.java"
@@ -3625,6 +3624,7 @@ an Ant task that extends the built-in @code{jar} task.")
     (arguments
      `(#:tests? #f ; Tests require junit
        #:modules ((guix build ant-build-system)
+                  (guix build java-utils)
                   (guix build utils)
                   (srfi srfi-1))
        #:make-flags (list (string-append "-Dversion=" ,version))
@@ -3678,28 +3678,18 @@ private Method[] allMethods = getSortedMethods();")))
            (lambda _
              (mkdir-p "lib/integration")
              #t))
+         (add-before 'build 'create-pom
+           (lambda _
+             (substitute* "pom/hamcrest-core.pom"
+               (("@VERSION@") ,version))
+             #t))
          (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (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)))))
+           (install-from-pom "pom/hamcrest-core.pom")))))
     (native-inputs
      `(("java-qdox-1.12" ,java-qdox-1.12)
        ("java-jarjar" ,java-jarjar)))
+    (propagated-inputs
+     `(("java-hamcrest-parent-pom" ,java-hamcrest-parent-pom)))
     (home-page "http://hamcrest.org/";)
     (synopsis "Library of matchers for building test expressions")
     (description
@@ -3709,15 +3699,44 @@ declaratively, to be used in other frameworks.  Typical 
scenarios include
 testing frameworks, mocking libraries and UI validation rules.")
     (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
   (package
     (inherit java-hamcrest-core)
     (name "java-hamcrest-library")
     (arguments
      (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
-     `(("java-hamcrest-core" ,java-hamcrest-core)))))
+     `(("java-hamcrest-core" ,java-hamcrest-core)
+       ("java-hamcrest-parent-pom" ,java-hamcrest-parent-pom)))))
 
 (define-public java-junit
   (package
@@ -3750,7 +3769,9 @@ testing frameworks, mocking libraries and UI validation 
rules.")
          (add-before 'check 'copy-test-resources
            (lambda _
              (copy-recursively "src/test/resources" "build/test-classes")
-             #t)))))
+             #t))
+         (replace 'install
+           (install-from-pom "pom.xml")))))
     (propagated-inputs
      `(("java-hamcrest-core" ,java-hamcrest-core)))
     (native-inputs
@@ -4874,8 +4895,29 @@ The jMock library
                               (find-files (assoc-ref inputs "java-easymock") 
"\\.jar$")))
                        ";"))
                      (("build/hamcrest-core-\\$\\{version\\}\\.jar")
-                      (string-append (assoc-ref inputs "java-hamcrest-core")
-                                     "/share/java/hamcrest-core.jar")))
+                      (car (find-files (assoc-ref inputs "java-hamcrest-core")
+                                       "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)))))))
     (inputs
      `(("java-junit" ,java-junit)
@@ -4935,9 +4977,10 @@ overly clever.")
        #:make-flags
        (let ((hamcrest (assoc-ref %build-inputs "java-hamcrest-core"))
              (junit    (assoc-ref %build-inputs "java-junit")))
-         (list (string-append "-Djunit.jar=" junit "/share/java/junit.jar")
-               (string-append "-Dhamcrest.jar=" hamcrest
-                              "/share/java/hamcrest-core.jar")))
+         (list (string-append "-Djunit.jar="
+                              (car (find-files junit "jar$")))
+               (string-append "-Dhamcrest.jar="
+                              (car (find-files hamcrest ".*.jar$")))))
        #:phases
        (modify-phases %standard-phases
          ;; We want to build the jar in the build phase and run the tests
@@ -5024,9 +5067,10 @@ targeting the JVM.")
        (let ((hamcrest (assoc-ref %build-inputs "java-hamcrest-core"))
              (junit    (assoc-ref %build-inputs "java-junit"))
              (easymock (assoc-ref %build-inputs "java-easymock")))
-         (list (string-append "-Djunit.jar=" junit "/share/java/junit.jar")
-               (string-append "-Dhamcrest.jar=" hamcrest
-                              "/share/java/hamcrest-core.jar")
+         (list (string-append "-Djunit.jar="
+                              (car (find-files junit "jar$")))
+               (string-append "-Dhamcrest.jar="
+                              (car (find-files hamcrest "jar$")))
                (string-append "-Deasymock.jar=" easymock
                               "/share/java/easymock.jar")))
        #:phases
@@ -5161,8 +5205,8 @@ setter and getter method.")
      `(#:test-target "test"
        #:make-flags
        (list (string-append "-Djunit.jar="
-                            (assoc-ref %build-inputs "java-junit")
-                            "/share/java/junit.jar"))
+                            (car (find-files (assoc-ref %build-inputs 
"java-junit")
+                                             "jar$"))))
        #:phases
        (modify-phases %standard-phases
          (add-after 'build 'build-javadoc ant-build-javadoc)
@@ -5194,8 +5238,8 @@ file filters and endian classes.")
      `(#:test-target "test"
        #:make-flags
        (list (string-append "-Dmaven.junit.jar="
-                            (assoc-ref %build-inputs "java-junit")
-                            "/share/java/junit.jar"))
+                            (car (find-files (assoc-ref %build-inputs 
"java-junit")
+                                             "jar$"))))
        #:phases
        (modify-phases %standard-phases
          (add-before 'build 'delete-network-tests
@@ -5230,8 +5274,8 @@ file filters and endian classes.")
      `(#:test-target "test"
        #:make-flags
        (list (string-append "-Dmaven.junit.jar="
-                            (assoc-ref %build-inputs "java-junit")
-                            "/share/java/junit.jar")
+                            (car (find-files (assoc-ref %build-inputs 
"java-junit")
+                                             "jar$")))
              "-Dmaven.compiler.source=1.7"
              "-Dmaven.compiler.target=1.7")
        #:phases
@@ -5332,9 +5376,10 @@ included:
              (junit    (assoc-ref %build-inputs "java-junit"))
              (easymock (assoc-ref %build-inputs "java-easymock"))
              (io       (assoc-ref %build-inputs "java-commons-io")))
-         (list (string-append "-Djunit.jar=" junit "/share/java/junit.jar")
-               (string-append "-Dhamcrest.jar=" hamcrest
-                              "/share/java/hamcrest-all.jar")
+         (list (string-append "-Djunit.jar="
+                              (car (find-files junit "jar$")))
+               (string-append "-Dhamcrest.jar="
+                              (car (find-files hamcrest ".*.jar$")))
                (string-append "-Dcommons-io.jar=" io
                               "/share/java/commons-io-"
                               ,(package-version java-commons-io)
@@ -6901,9 +6946,8 @@ This is a part of the Apache Commons Project.")
        #:make-flags
        (let ((hamcrest (assoc-ref %build-inputs "java-hamcrest-core"))
              (junit    (assoc-ref %build-inputs "java-junit")))
-         (list (string-append "-Djunit.jar=" junit "/share/java/junit.jar")
-               (string-append "-Dhamcrest.jar=" hamcrest
-                              "/share/java/hamcrest-core.jar")
+         (list (string-append "-Djunit.jar=" (car (find-files junit "jar$")))
+               (string-append "-Dhamcrest.jar=" (car (find-files hamcrest 
"jar$")))
                ;; Do not append version to jar.
                "-Dfinal.name=commons-codec"))
        #:phases
@@ -11090,11 +11134,10 @@ from ORO, Inc.")
                ;; so don't fail if we can't find a native library for another 
architecture.
                (("zipfileset") "zipfileset erroronmissingarchive=\"false\""))
              ;; Copy test dependencies
-             (copy-file (string-append (assoc-ref inputs "java-junit")
-                                       "/share/java/junit.jar")
+             (copy-file (car (find-files (assoc-ref inputs "java-junit") 
"jar$"))
                         "lib/junit.jar")
-             (copy-file (string-append (assoc-ref inputs "java-hamcrest-core")
-                                       "/share/java/hamcrest-core.jar")
+             (copy-file (car (find-files (assoc-ref inputs 
"java-hamcrest-core")
+                                         "jar$"))
                         "lib/hamcrest-core.jar")
              ;; FIXME: once reflections.jar is built, copy it to lib/test.
              #t))
@@ -11143,11 +11186,11 @@ Java method invocation.")
                 (string-append (assoc-ref inputs "java-native-access")
                                "/share/java/jna.jar"))
                (("../../lib/hamcrest-core-.*.jar")
-                (string-append (assoc-ref inputs "java-hamcrest-core")
-                               "/share/java/hamcrest-core.jar"))
+                (car (find-files (assoc-ref inputs "java-hamcrest-core")
+                                 "jar$")))
                (("../../lib/junit.jar")
-                (string-append (assoc-ref inputs "java-junit")
-                               "/share/java/junit.jar")))
+                (car (find-files (assoc-ref inputs "java-junit")
+                                 "jar$"))))
              #t))
          (replace 'install
            (install-jars "dist")))))
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index b75fd25..ee4d30c 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -1187,10 +1187,15 @@ extremely large and complex data collections.")
                     (jhdf (string-append lib "/jhdf.jar"))
                     (jhdf5 (string-append lib "/jhdf5.jar"))
                     (testjars
-                     (map (lambda (i)
-                            (string-append (assoc-ref inputs i)
-                                           "/share/java/" i ".jar"))
-                          '("junit" "hamcrest-core" "slf4j-api" 
"slf4j-simple")))
+                     (append
+                       (map (lambda (i)
+                              (string-append (assoc-ref inputs i)
+                                             "/share/java/" i ".jar"))
+                            '("slf4j-api" "slf4j-simple"))
+                       (list
+                         (car (find-files (assoc-ref inputs "junit") "jar$"))
+                         (car (find-files (assoc-ref inputs "hamcrest-core")
+                                          "jar$")))))
                     (class-path
                      (string-join `("." ,build-dir ,jhdf ,jhdf5 ,@testjars) 
":")))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]