unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#48766] [PATCH] gnu: java-jmh: Switch to maven-build-system.
@ 2021-05-31 22:41 Julien Lepiller
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
  2021-06-22 11:13 ` bug#48766: [PATCH] " Julien Lepiller
  0 siblings, 2 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:41 UTC (permalink / raw)
  To: 48766

Hi Guix!

I'm excited to submit this patch series, as it adds the first package
to guix that uses the maven-build-system.

The series first improves the maven build system, so it actually works
with jmh :)

The series then changes a few dependencies to install to the maven
repository structure (lib/m2), so they can be detected by maven during
the build.

Since the series updates files that are used by the ant-build-system,
it unfortunately needs to update all java packages. Grepping for
"build-system ant-build-system", it shows 302 packages, which is
two packages above the limit for master. However, since most java
packages are fast to build, I'd like to ask for an exception to this
rule and push to master directly.

Patches will follow :)




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation.
  2021-05-31 22:41 [bug#48766] [PATCH] gnu: java-jmh: Switch to maven-build-system Julien Lepiller
@ 2021-05-31 22:44 ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 02/14] guix: maven: Simplify finding version and group information Julien Lepiller
                     ` (12 more replies)
  2021-06-22 11:13 ` bug#48766: [PATCH] " Julien Lepiller
  1 sibling, 13 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* guix/build/java-utils.scm (generate-pom.xml): New procedure.
* gnu/packages/maven.scm (java-surefire-junit4): Use it.
* gnu/packages/java.scm (java-qdox, java-jsr250, java-jsr305)
(java-aopalliance, java-jboss-el-api-spec)
(java-jboss-interceptors-api-spec): Use it.
(java-qdox-M9): Ensure the generated pom file has the correct version.
---
 gnu/packages/java.scm     | 117 ++++++--------------------------------
 gnu/packages/maven.scm    |  28 ++++-----
 guix/build/java-utils.scm |  29 ++++++++++
 3 files changed, 58 insertions(+), 116 deletions(-)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index a167aafc38..d7118b4ce6 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -3781,25 +3781,11 @@ documentation tools.")
     (arguments
      `(#:jar-name "qdox.jar"
        #:tests? #f; no tests
-       #:modules
-       ((guix build ant-build-system)
-        (guix build java-utils)
-        (guix build utils)
-        (sxml simple))
        #:phases
        (modify-phases %standard-phases
          (add-before 'install 'create-pom
-           (lambda _
-             (with-output-to-file "pom.xml"
-               (lambda _
-                 (sxml->xml
-                   `((project
-                       (modelVersion "4.0.0")
-                       (name "QDox")
-                       (groupId "com.thoughtworks.qdox")
-                       (artifactId "qdox")
-                       (version ,,version))))))
-             #t))
+           (generate-pom.xml "pom.xml" "com.thoughtworks.qdox" "qdox" ,version
+                             #:name "QDox"))
          (replace 'install
            (install-from-pom "pom.xml")))))
     (home-page "https://github.com/codehaus/qdox")
@@ -3825,7 +3811,14 @@ documentation tools.")
                                   "/qdox-" version "-sources.jar"))
               (sha256
                (base32
-                "1s2jnmx2dkwnaha12lcj26aynywgwa8sslc47z82wx8xai13y4fg"))))))
+                "1s2jnmx2dkwnaha12lcj26aynywgwa8sslc47z82wx8xai13y4fg"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments java-qdox)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (replace 'create-pom
+             (generate-pom.xml "pom.xml" "com.thoughtworks.qdox" "qdox" ,version
+                               #:name "QDox"))))))))
 
 (define-public java-jarjar
   (package
@@ -6397,25 +6390,11 @@ bottlenecks move away from the database in an effectively cached system.")
      `(#:tests? #f ; no tests included
        #:jdk ,icedtea-8
        #:jar-name "jsr250.jar"
-       #:modules ((guix build ant-build-system)
-                  (guix build utils)
-                  (guix build maven pom)
-                  (guix build java-utils)
-                  (sxml simple))
        #:phases
        (modify-phases %standard-phases
          (add-before 'install 'create-pom
-           (lambda _
-             (with-output-to-file "pom.xml"
-               (lambda _
-                 (sxml->xml
-                   `((project
-                       (modelVersion "4.0.0")
-                       (name "jsr250")
-                       (groupId "javax.annotation")
-                       (artifactId "jsr250-api")
-                       (version ,,version))))))
-             #t))
+           (generate-pom.xml "pom.xml" "javax.annotation" "jsr250-api" ,version
+                             #:name "jsr250"))
          (replace 'install
            (install-from-pom "pom.xml")))))
     (home-page "https://jcp.org/en/jsr/detail?id=250")
@@ -6444,25 +6423,10 @@ namespaces.")
     (arguments
      `(#:tests? #f ; no tests included
        #:jar-name "jsr305.jar"
-       #:modules ((guix build ant-build-system)
-                  (guix build java-utils)
-                  (guix build maven pom)
-                  (guix build utils)
-                  (sxml simple))
        #:phases
        (modify-phases %standard-phases
          (add-before 'install 'create-pom
-           (lambda _
-             (with-output-to-file "pom.xml"
-               (lambda _
-                 (sxml->xml
-                   `((project
-                       (modelVersion "4.0.0")
-                       (name "jsr305")
-                       (groupId "com.google.code.findbugs")
-                       (artifactId "jsr305")
-                       (version ,,version))))))
-             #t))
+           (generate-pom.xml "pom.xml" "com.google.code.findbugs" "jsr305" ,version))
          (replace 'install
            (install-from-pom "pom.xml")))))
     (home-page "http://findbugs.sourceforge.net/")
@@ -10493,25 +10457,10 @@ this is not a static analysis tool.)")
        #:jdk ,icedtea-8
        #:tests? #f; no tests
        #:source-dir "aopalliance/src/main"
-       #:modules ((guix build ant-build-system)
-                  (guix build utils)
-                  (guix build maven pom)
-                  (guix build java-utils)
-                  (sxml simple))
        #:phases
        (modify-phases %standard-phases
          (add-before 'install 'create-pom
-           (lambda _
-             (with-output-to-file "pom.xml"
-               (lambda _
-                 (sxml->xml
-                   `((project
-                       (modelVersion "4.0.0")
-                       (name "aopalliance")
-                       (groupId "aopalliance")
-                       (artifactId "aopalliance")
-                       (version "1.0"))))))
-             #t))
+           (generate-pom.xml "pom.xml" "aopalliance" "aopalliance" ,version))
          (replace 'install
            (install-from-pom "pom.xml")))))
     (home-page "http://aopalliance.sourceforge.net")
@@ -12110,29 +12059,14 @@ sequences to format your console output which works on every platform.")
     (build-system ant-build-system)
     (arguments
      `(#:jar-name "java-jboss-el-api_spec.jar"
-       #:modules ((guix build ant-build-system)
-                  (guix build utils)
-                  (guix build maven pom)
-                  (guix build java-utils)
-                  (sxml simple))
        #:phases
        (modify-phases %standard-phases
          ;; the origin of javax.el:javax.el-api is unknown, so we use this package
          ;; instead, which implements the same thing.  We override the pom file
          ;; to "rename" the package so it can be found by maven.
          (add-before 'install 'override-pom
-           (lambda _
-             (delete-file "pom.xml")
-             (with-output-to-file "pom.xml"
-               (lambda _
-                 (sxml->xml
-                   `(project
-                      (modelVersion "4.0.0")
-                      (name "el-api")
-                      (groupId "javax.el")
-                      (artifactId "javax.el-api")
-                      (version "3.0")))))
-             #t))
+           (generate-pom.xml "pom.xml" "javax.el" "javax.el-api" "3.0"
+                             #:name "el-api"))
          (replace 'install
            (install-from-pom "pom.xml")))))
     (inputs
@@ -12164,11 +12098,6 @@ JavaServer Pages (JSP).")
        #:jdk ,icedtea-8
        #:source-dir "."
        #:tests? #f; no tests
-       #:modules ((guix build ant-build-system)
-                  (guix build utils)
-                  (guix build maven pom)
-                  (guix build java-utils)
-                  (sxml simple))
        #:phases
        (modify-phases %standard-phases
          ;; the origin of javax.interceptor:javax.interceptor-api is unknown,
@@ -12176,18 +12105,8 @@ JavaServer Pages (JSP).")
          ;; We override the pom file to "rename" the package so it can be found
          ;; by maven.
          (add-before 'install 'override-pom
-           (lambda _
-             (delete-file "pom.xml")
-             (with-output-to-file "pom.xml"
-               (lambda _
-                 (sxml->xml
-                   `(project
-                      (modelVersion "4.0.0")
-                      (name "interceptor-api")
-                      (groupId "javax.interceptor")
-                      (artifactId "javax.interceptor-api")
-                      (version "3.0")))))
-             #t))
+           (generate-pom.xml "pom.xml" "javax.interceptor" "javax.interceptor-api"
+                             "3.0" #:name "interceptor-api"))
          (replace 'install
            (install-from-pom "pom.xml")))))
     (home-page "https://github.com/jboss/jboss-interceptors-api_spec")
diff --git a/gnu/packages/maven.scm b/gnu/packages/maven.scm
index c637e5c7ae..8f63ee9be2 100644
--- a/gnu/packages/maven.scm
+++ b/gnu/packages/maven.scm
@@ -3424,23 +3424,17 @@ starting from JUnit 4.")))
        #:phases
        (modify-phases %standard-phases
          (add-before 'install 'regenerate-own-pom
-           (lambda _
-             ;; Surefire struggles resolving artifacts because of this pom
-             ;; file, resulting in a NullPointerException when collecting
-             ;; Artifacts (and a "Failure detected." message from
-             ;; DefaultArtifactResolver).  Replace the pom file with a much
-             ;; simpler one.  Everything is shaded anyway (as used to be the
-             ;; case in 2.22), so there will not be missing dependencies.
-             (with-output-to-file "surefire-providers/surefire-junit4/pom.xml"
-               (lambda _
-                 (sxml->xml
-                   `((project
-                       (modelVersion "4.0.0")
-                       (name "Surefire JUnit4")
-                       (groupId "org.apache.maven.surefire")
-                       (artifactId "surefire-junit4")
-                       (version ,,(package-version java-surefire-common-java5)))))))
-             #t))
+           ;; Surefire struggles resolving artifacts because of this pom
+           ;; file, resulting in a NullPointerException when collecting
+           ;; Artifacts (and a "Failure detected." message from
+           ;; DefaultArtifactResolver).  Replace the pom file with a much
+           ;; simpler one.  Everything is shaded anyway (as used to be the
+           ;; case in 2.22), so there will not be missing dependencies.
+           (generate-pom.xml
+             "surefire-providers/surefire-junit4/pom.xml"
+             "org.apache.maven.surefire" "surefire-junit4"
+             ,(package-version java-surefire-common-java5)
+             #:name "Surefire JUnit4"))
          (add-before 'build 'copy-resources
            (lambda _
              (mkdir-p "build/classes")
diff --git a/guix/build/java-utils.scm b/guix/build/java-utils.scm
index a868e4d52c..6abd97e118 100644
--- a/guix/build/java-utils.scm
+++ b/guix/build/java-utils.scm
@@ -28,6 +28,7 @@
   #:use-module (sxml simple)
   #:export (ant-build-javadoc
             generate-plugin.xml
+            generate-pom.xml
             install-jars
             install-javadoc
             install-pom-file
@@ -206,3 +207,31 @@ recognize the package as a plugin, and find the entry points in the plugin."
                  ,mojos
                  (dependencies
                   ,@dependencies)))))))))
+
+(define* (generate-pom.xml pom-file groupid artifactid version
+                           #:key (dependencies '())
+                                 (name artifactid))
+  "Generates the @file{pom.xml} for a project. It is required by Maven to find
+a package, and by the java build system to know where to install a package, when
+a pom.xml doesn't already exist and installing to the maven repository."
+  (lambda _
+    (mkdir-p (dirname pom-file))
+    (with-output-to-file pom-file
+      (lambda _
+        (sxml->xml
+          (sxml-indent
+            `(project
+               (modelVersion "4.0.0")
+               (name ,name)
+               (groupId ,groupid)
+               (artifactId ,artifactid)
+               (version ,version)
+               (dependencies
+                ,@(map
+                    (match-lambda
+                      ((groupid artifactid version)
+                      `(dependency
+                         (groupId ,groupid)
+                         (artifactId ,artifactid)
+                         (version ,version))))
+                    dependencies)))))))))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 02/14] guix: maven: Simplify finding version and group information.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 03/14] guix: maven: Simplify finding local packages and modules Julien Lepiller
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* guix/build/maven/pom.scm (pom-version, pom-groupid): Do not use inputs
and local packages information anymore. Adapt file to new arguments.
* guix/build/maven-build-system.scm: Adapt to new arguments.
* guix/build/java-utils.scm: Adapt to new arguments.
---
 guix/build/java-utils.scm         | 18 +++++++++---------
 guix/build/maven-build-system.scm |  6 +++---
 guix/build/maven/pom.scm          | 26 ++++++++++++--------------
 3 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/guix/build/java-utils.scm b/guix/build/java-utils.scm
index 6abd97e118..5a54a14c1b 100644
--- a/guix/build/java-utils.scm
+++ b/guix/build/java-utils.scm
@@ -2,7 +2,7 @@
 ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
-;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
+;;; Copyright © 2020, 2021 Julien Lepiller <julien@lepiller.eu>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -69,9 +69,9 @@ fetched."
     (let* ((out (assoc-ref outputs "out"))
            (java-inputs (append (map cdr inputs) (map cdr outputs)))
            (pom-content (get-pom pom-file))
-           (version (pom-version pom-content java-inputs))
+           (version (pom-version pom-content))
            (artifact (pom-artifactid pom-content))
-           (group (group->dir (pom-groupid pom-content java-inputs)))
+           (group (group->dir (pom-groupid pom-content)))
            (repository (string-append out "/lib/m2/" group "/" artifact "/"
                                       version "/"))
            (pom-name (string-append repository artifact "-" version ".pom")))
@@ -87,8 +87,8 @@ to ensure that maven can find dependencies."
          (manifest (string-append dir "/META-INF/MANIFEST.MF"))
          (pom (get-pom pom-file))
          (artifact (pom-artifactid pom))
-         (group (pom-groupid pom inputs))
-         (version (pom-version pom inputs))
+         (group (pom-groupid pom))
+         (version (pom-version pom))
          (pom-dir (string-append "META-INF/maven/" group "/" artifact)))
     (mkdir-p (string-append dir "/" pom-dir))
     (copy-file pom-file (string-append dir "/" pom-dir "/pom.xml"))
@@ -113,9 +113,9 @@ the phase fails."
     (let* ((out (assoc-ref outputs "out"))
            (java-inputs (append (map cdr inputs) (map cdr outputs)))
            (pom-content (get-pom pom-file))
-           (version (pom-version pom-content java-inputs))
+           (version (pom-version pom-content))
            (artifact (pom-artifactid pom-content))
-           (group (group->dir (pom-groupid pom-content java-inputs)))
+           (group (group->dir (pom-groupid pom-content)))
            (repository (string-append out "/lib/m2/" group "/" artifact "/"
                                       version "/"))
            ;; We try to find the file that was built.  If it was built from our
@@ -180,9 +180,9 @@ recognize the package as a plugin, and find the entry points in the plugin."
            (name (pom-name pom-content))
            (description (pom-description pom-content))
            (dependencies (pom-dependencies pom-content))
-           (version (pom-version pom-content java-inputs))
+           (version (pom-version pom-content))
            (artifact (pom-artifactid pom-content))
-           (groupid (pom-groupid pom-content java-inputs))
+           (groupid (pom-groupid pom-content))
            (mojos
             `(mojos
                ,@(with-directory-excursion directory
diff --git a/guix/build/maven-build-system.scm b/guix/build/maven-build-system.scm
index 534b4ebcee..0456bfdf61 100644
--- a/guix/build/maven-build-system.scm
+++ b/guix/build/maven-build-system.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
+;;; Copyright © 2020, 2021 Julien Lepiller <julien@lepiller.eu>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -82,8 +82,8 @@
   (let* ((pom (get-pom pom-file))
          (java-inputs (map cdr inputs))
          (artifact (pom-artifactid pom))
-         (group (pom-groupid pom java-inputs local-packages))
-         (version (pom-version pom java-inputs local-packages)))
+         (group (pom-groupid pom))
+         (version (pom-version pom)))
     (let loop ((modules (pom-ref pom "modules"))
                (local-packages
                  (add-local-package local-packages group artifact version)))
diff --git a/guix/build/maven/pom.scm b/guix/build/maven/pom.scm
index c92d409d2b..327d5f75e8 100644
--- a/guix/build/maven/pom.scm
+++ b/guix/build/maven/pom.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2019, 2020 Julien Lepiller <julien@lepiller.eu>
+;;; Copyright © 2019-2021 Julien Lepiller <julien@lepiller.eu>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -93,13 +93,12 @@ If no result is found, the result is @code{#f}."
               (get-pom (car java-inputs))))
         #f)))
 
-(define* (pom-groupid content inputs #:optional local-packages)
+(define* (pom-groupid content)
   "Find the groupID of a pom file, potentially looking at its parent pom file.
 See @code{find-parent} for the meaning of the arguments."
   (if content
     (let ((res (or (pom-ref content "groupId")
-                   (pom-groupid (find-parent content inputs local-packages)
-                                inputs))))
+                   (pom-ref (pom-ref content "parent") "groupId"))))
       (cond
         ((string? res) res)
         ((null? res) #f)
@@ -114,13 +113,12 @@ See @code{find-parent} for the meaning of the arguments."
       (car res)
       #f)))
 
-(define* (pom-version content inputs #:optional local-packages)
+(define* (pom-version content)
   "Find the version of a pom file, potentially looking at its parent pom file.
 See @code{find-parent} for the meaning of the arguments."
   (if content
     (let ((res (or (pom-ref content "version")
-                   (pom-version (find-parent content inputs local-packages)
-                                inputs))))
+                   (pom-ref (pom-ref content "parent") "version"))))
       (cond
         ((string? res) res)
         ((null? res) #f)
@@ -344,7 +342,7 @@ Returns nothing, but overrides the @var{pom-file} as a side-effect."
       ((tag rest ...)
        (match tag
          (('http://maven.apache.org/POM/4.0.0:plugin plugin ...)
-          (let ((group (or (pom-groupid plugin inputs) "org.apache.maven.plugins"))
+          (let ((group (or (pom-groupid plugin) "org.apache.maven.plugins"))
                 (artifact (pom-artifactid plugin)))
             (if (member artifact (or (assoc-ref excludes group) '()))
               (fix-plugins rest optional?)
@@ -355,11 +353,11 @@ Returns nothing, but overrides the @var{pom-file} as a side-effect."
 
   (define* (fix-plugin plugin #:optional optional?)
     (let* ((artifact (pom-artifactid plugin))
-           (group (or (pom-groupid plugin inputs) "org.apache.maven.plugins"))
+           (group (or (pom-groupid plugin) "org.apache.maven.plugins"))
            (version (or (assoc-ref (assoc-ref local-packages group) artifact)
                         (find-version inputs group artifact optional?)
-                        (pom-version plugin inputs))))
-      (if (pom-version plugin inputs)
+                        (pom-version plugin))))
+      (if (pom-version plugin)
         (map
           (lambda (tag)
             (match tag
@@ -373,7 +371,7 @@ Returns nothing, but overrides the @var{pom-file} as a side-effect."
 
   (define* (fix-dep dep #:optional optional?)
     (let* ((artifact (pom-artifactid dep))
-           (group (or (pom-groupid dep inputs) (pom-groupid pom inputs)))
+           (group (or (pom-groupid dep) (pom-groupid pom)))
            (scope (pom-ref dep "scope"))
            (is-optional? (equal? (pom-ref dep "optional") '("true"))))
       (format (current-error-port) "maven: ~a:~a :: ~a (optional: ~a)~%"
@@ -382,8 +380,8 @@ Returns nothing, but overrides the @var{pom-file} as a side-effect."
               with-build-dependencies?)
           (let ((version (or (assoc-ref (assoc-ref local-packages group) artifact)
                              (find-version inputs group artifact optional?)
-                             (pom-version dep inputs))))
-            (if (pom-version dep inputs)
+                             (pom-version dep))))
+            (if (pom-version dep)
               (map
                 (lambda (tag)
                   (match tag
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 03/14] guix: maven: Simplify finding local packages and modules.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 02/14] guix: maven: Simplify finding version and group information Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 04/14] guix: maven: Support fixing extensions Julien Lepiller
                     ` (10 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* guix/build/maven-build-system (fix-pom): Fix a single pom file without
recursing
(fix-pom-files): Find local packages and all submodules, and fix them
all at once.
(add-local-package): Move to...
* guix/build/maven/pom.scm (add-local-package): ...here.
(pom-and-submodules, pom-local-packages): New procedures.
---
 guix/build/maven-build-system.scm | 41 +++++-------------------
 guix/build/maven/pom.scm          | 53 ++++++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 34 deletions(-)

diff --git a/guix/build/maven-build-system.scm b/guix/build/maven-build-system.scm
index 0456bfdf61..374fa2fdb8 100644
--- a/guix/build/maven-build-system.scm
+++ b/guix/build/maven-build-system.scm
@@ -60,47 +60,22 @@
   (invoke "mvn" "-v")
   #t)
 
-(define (add-local-package local-packages group artifact version)
-  (define (alist-set lst key val)
-    (match lst
-      ('() (list (cons key val)))
-      (((k . v) lst ...)
-       (if (equal? k key)
-         (cons (cons key val) lst)
-         (cons (cons k v) (alist-set lst key val))))))
-  (alist-set local-packages group
-    (alist-set (or (assoc-ref local-packages group) '()) artifact
-      version)))
-
 (define (fix-pom pom-file inputs local-packages excludes)
   (chmod pom-file #o644)
   (format #t "fixing ~a~%" pom-file)
   (fix-pom-dependencies pom-file (map cdr inputs)
                         #:with-plugins? #t #:with-build-dependencies? #t
                         #:local-packages local-packages
-                        #:excludes excludes)
-  (let* ((pom (get-pom pom-file))
-         (java-inputs (map cdr inputs))
-         (artifact (pom-artifactid pom))
-         (group (pom-groupid pom))
-         (version (pom-version pom)))
-    (let loop ((modules (pom-ref pom "modules"))
-               (local-packages
-                 (add-local-package local-packages group artifact version)))
-      (pk 'local-packages local-packages)
-      (match modules
-        (#f local-packages)
-        ('() local-packages)
-        (((? string? _) modules ...)
-         (loop modules local-packages))
-        (((_ module) modules ...)
-         (loop
-           modules
-           (fix-pom (string-append (dirname pom-file) "/" module "/pom.xml")
-                    inputs local-packages excludes)))))))
+                        #:excludes excludes))
 
 (define* (fix-pom-files #:key inputs local-packages exclude #:allow-other-keys)
-  (fix-pom "pom.xml" inputs local-packages exclude)
+  (let ((local-packages (pom-local-packages "pom.xml" #:local-packages local-packages)))
+    (format (current-error-port) "Fix pom files with local packages: ~a~%" local-packages)
+    (for-each
+      (lambda (pom)
+        (when (file-exists? pom)
+          (fix-pom pom inputs local-packages exclude)))
+      (pom-and-submodules "pom.xml")))
   #t)
 
 (define* (build #:key outputs #:allow-other-keys)
diff --git a/guix/build/maven/pom.scm b/guix/build/maven/pom.scm
index 327d5f75e8..8f16cf4d26 100644
--- a/guix/build/maven/pom.scm
+++ b/guix/build/maven/pom.scm
@@ -21,7 +21,8 @@
   #:use-module (system foreign)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
-  #:export (get-pom
+  #:export (add-local-package
+            get-pom
             pom-ref
             pom-description
             pom-name
@@ -30,8 +31,24 @@
             pom-groupid
             pom-dependencies
             group->dir
+            pom-and-submodules
+            pom-local-packages
             fix-pom-dependencies))
 
+(define (add-local-package local-packages group artifact version)
+  "Takes @var{local-packages}, a list of local packages, and adds a new one
+for @var{group}:@var{artifact} at @var{version}."
+  (define (alist-set lst key val)
+    (match lst
+      ('() (list (cons key val)))
+      (((k . v) lst ...)
+       (if (equal? k key)
+         (cons (cons key val) lst)
+         (cons (cons k v) (alist-set lst key val))))))
+  (alist-set local-packages group
+    (alist-set (or (assoc-ref local-packages group) '()) artifact
+      version)))
+
 (define (get-pom file)
   "Return the content of a @file{.pom} file."
   (let ((pom-content (call-with-input-file file xml->sxml)))
@@ -234,6 +251,40 @@ to re-declare the namespaces in the top-level element."
                    http://maven.apache.org/xsd/maven-4.0.0.xsd"))
        ,(map fix-xml sxml)))))
 
+(define (pom-and-submodules pom-file)
+  "Given @var{pom-file}, the file name of a pom, return the list of pom file
+names that correspond to itself and its submodules, recursively."
+  (define (get-modules modules)
+    (match modules
+      (#f '())
+      ('() '())
+      (((? string? _) rest ...) (get-modules rest))
+      ((('http://maven.apache.org/POM/4.0.0:module mod) rest ...)
+       (let ((pom (string-append (dirname pom-file) "/" mod "/pom.xml")))
+         (if (file-exists? pom)
+             (cons pom (get-modules rest))
+             (get-modules rest))))))
+
+  (let* ((pom (get-pom pom-file))
+         (modules (get-modules (pom-ref pom "modules"))))
+    (cons pom-file
+          (apply append (map pom-and-submodules modules)))))
+
+(define* (pom-local-packages pom-file #:key (local-packages '()))
+  "Given @var{pom-file}, a pom file name, return a list of local packages that
+this repository contains."
+  (let loop ((modules (pom-and-submodules pom-file))
+             (local-packages local-packages))
+    (match modules
+      (() local-packages)
+      ((module modules ...)
+       (let* ((pom (get-pom module))
+              (version (pom-version pom))
+              (artifactid (pom-artifactid pom))
+              (groupid (pom-groupid pom)))
+         (loop modules
+               (add-local-package local-packages groupid artifactid version)))))))
+
 (define (group->dir group)
   "Convert a group ID to a directory path."
   (string-join (string-split group #\.) "/"))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 04/14] guix: maven: Support fixing extensions.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 02/14] guix: maven: Simplify finding version and group information Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 03/14] guix: maven: Simplify finding local packages and modules Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 05/14] guix: maven: Support fixing modules Julien Lepiller
                     ` (9 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* guix/build/maven/pom.scm (fix-pom-dependencies): Add support for fixing
extension versions.
---
 guix/build/maven/pom.scm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/guix/build/maven/pom.scm b/guix/build/maven/pom.scm
index 8f16cf4d26..3a4ad7a216 100644
--- a/guix/build/maven/pom.scm
+++ b/guix/build/maven/pom.scm
@@ -374,8 +374,27 @@ Returns nothing, but overrides the @var{pom-file} as a side-effect."
           `((http://maven.apache.org/POM/4.0.0:plugins
               ,(fix-plugins plugins))
             ,@(fix-build rest)))
+         (('http://maven.apache.org/POM/4.0.0:extensions extensions ...)
+          `((http://maven.apache.org/POM/4.0.0:extensions
+              ,(fix-extensions extensions))
+            ,@(fix-build rest)))
          (tag (cons tag (fix-build rest)))))))
 
+  (define* (fix-extensions extensions #:optional optional?)
+    (match extensions
+      ('() '())
+      ((tag rest ...)
+       (match tag
+         (('http://maven.apache.org/POM/4.0.0:extension extension ...)
+          (let ((group (or (pom-groupid extension) "org.apache.maven.plugins"))
+                (artifact (pom-artifactid extension)))
+            (if (member artifact (or (assoc-ref excludes group) '()))
+              (fix-extensions rest optional?)
+              `((http://maven.apache.org/POM/4.0.0:extension
+                  ,(fix-plugin extension optional?)); extensions are similar to plugins
+                ,@(fix-extensions rest optional?)))))
+         (tag (cons tag (fix-extensions rest optional?)))))))
+
   (define fix-management
     (match-lambda
       ('() '())
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 05/14] guix: maven: Support fixing modules.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
                     ` (2 preceding siblings ...)
  2021-05-31 22:44   ` [bug#48766] [PATCH 04/14] guix: maven: Support fixing extensions Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 06/14] guix: maven: Look in local packages when searching for package version Julien Lepiller
                     ` (8 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* guix/build/maven/pom.scm (fix-pom-dependencies): Support fixing
modules that do not exist.
* guix/build/maven-build-system.scm (fix-pom): Fix modules.
---
 guix/build/maven-build-system.scm |  1 +
 guix/build/maven/pom.scm          | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/guix/build/maven-build-system.scm b/guix/build/maven-build-system.scm
index 374fa2fdb8..b3d97c81ea 100644
--- a/guix/build/maven-build-system.scm
+++ b/guix/build/maven-build-system.scm
@@ -65,6 +65,7 @@
   (format #t "fixing ~a~%" pom-file)
   (fix-pom-dependencies pom-file (map cdr inputs)
                         #:with-plugins? #t #:with-build-dependencies? #t
+                        #:with-modules? #t
                         #:local-packages local-packages
                         #:excludes excludes))
 
diff --git a/guix/build/maven/pom.scm b/guix/build/maven/pom.scm
index 3a4ad7a216..ffb4515179 100644
--- a/guix/build/maven/pom.scm
+++ b/guix/build/maven/pom.scm
@@ -291,7 +291,8 @@ this repository contains."
 
 (define* (fix-pom-dependencies pom-file inputs
                                #:key with-plugins? with-build-dependencies?
-                                     (excludes '()) (local-packages '()))
+                                     with-modules? (excludes '())
+                                     (local-packages '()))
   "Open @var{pom-file}, and override its content, rewritting its dependencies
 to set their version to the latest version available in the @var{inputs}.
 
@@ -339,8 +340,24 @@ Returns nothing, but overrides the @var{pom-file} as a side-effect."
               `((http://maven.apache.org/POM/4.0.0:build ,(fix-build build))
                 ,@(fix-pom rest))
               (cons tag (fix-pom rest))))
+         (('http://maven.apache.org/POM/4.0.0:modules modules ...)
+          (if with-modules?
+              `((http://maven.apache.org/POM/4.0.0:modules ,(fix-modules modules))
+                ,@(fix-pom rest))
+              (cons tag (fix-pom rest))))
          (tag (cons tag (fix-pom rest)))))))
 
+  (define fix-modules
+    (match-lambda
+      ('() '())
+      ((tag rest ...)
+       (match tag
+        (('http://maven.apache.org/POM/4.0.0:module module)
+         (if (file-exists? (string-append (dirname pom-file) "/" module "/pom.xml"))
+             `((http://maven.apache.org/POM/4.0.0:module ,module) ,@(fix-modules rest))
+             (fix-modules rest)))
+        (tag (cons tag (fix-modules rest)))))))
+
   (define fix-dep-management
     (match-lambda
       ('() '())
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 06/14] guix: maven: Look in local packages when searching for package version.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
                     ` (3 preceding siblings ...)
  2021-05-31 22:44   ` [bug#48766] [PATCH 05/14] guix: maven: Support fixing modules Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 07/14] guix: maven: Use a temporary file to fix pom files Julien Lepiller
                     ` (7 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* guix/build/maven/pom.scm (fix-pom-dependencies): Also look at local
packages when looking for a package version.
---
 guix/build/maven/pom.scm | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/guix/build/maven/pom.scm b/guix/build/maven/pom.scm
index ffb4515179..9c0669c7cd 100644
--- a/guix/build/maven/pom.scm
+++ b/guix/build/maven/pom.scm
@@ -481,7 +481,7 @@ Returns nothing, but overrides the @var{pom-file} as a side-effect."
               (cons `(http://maven.apache.org/POM/4.0.0:version ,version) dep)))
           dep)))
 
-  (define* (find-version inputs group artifact #:optional optional?)
+  (define (find-packaged-version inputs group artifact)
     (let* ((directory (string-append "lib/m2/" (group->dir group)
                                      "/" artifact))
            (java-inputs (filter
@@ -493,13 +493,19 @@ Returns nothing, but overrides the @var{pom-file} as a side-effect."
            (versions (append-map ls java-inputs))
            (versions (sort versions version>?)))
       (if (null? versions)
-        (if optional?
           #f
-          (begin
-            (format (current-error-port) "maven: ~a:~a is missing from inputs~%"
-                    group artifact)
-            (throw 'no-such-input group artifact)))
-        (car versions))))
+          (car versions))))
+
+  (define* (find-version inputs group artifact #:optional optional?)
+    (let ((packaged-version (find-packaged-version inputs group artifact))
+          (local-version (assoc-ref (assoc-ref local-packages group) artifact)))
+      (or local-version packaged-version
+          (if optional?
+            #f
+            (begin
+              (format (current-error-port) "maven: ~a:~a is missing from inputs~%"
+                      group artifact)
+              (throw 'no-such-input group artifact))))))
 
   (let ((tmpfile (string-append pom-file ".tmp")))
     (with-output-to-file pom-file
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 07/14] guix: maven: Use a temporary file to fix pom files.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
                     ` (4 preceding siblings ...)
  2021-05-31 22:44   ` [bug#48766] [PATCH 06/14] guix: maven: Look in local packages when searching for package version Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 08/14] guix: java-utils: Look for actual jar files Julien Lepiller
                     ` (6 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* guix/build/maven/pom.scm (fix-pom-dependencies): Actually use the
temporary file that was created.
---
 guix/build/maven/pom.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/guix/build/maven/pom.scm b/guix/build/maven/pom.scm
index 9c0669c7cd..9e35e47a7f 100644
--- a/guix/build/maven/pom.scm
+++ b/guix/build/maven/pom.scm
@@ -508,6 +508,7 @@ Returns nothing, but overrides the @var{pom-file} as a side-effect."
               (throw 'no-such-input group artifact))))))
 
   (let ((tmpfile (string-append pom-file ".tmp")))
-    (with-output-to-file pom-file
+    (with-output-to-file tmpfile
       (lambda _
-        (sxml->xml (fix-maven-xml (fix-pom pom)))))))
+        (sxml->xml (fix-maven-xml (fix-pom pom)))))
+    (rename-file tmpfile pom-file)))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 08/14] guix: java-utils: Look for actual jar files.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
                     ` (5 preceding siblings ...)
  2021-05-31 22:44   ` [bug#48766] [PATCH 07/14] guix: maven: Use a temporary file to fix pom files Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 09/14] gnu: Add java-jopt-simple-4 Julien Lepiller
                     ` (5 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* guix/build/java-utils.scm (install-from-pom): Fix `find-files` to look
only for jar files.
---
 guix/build/java-utils.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/build/java-utils.scm b/guix/build/java-utils.scm
index 5a54a14c1b..87c3ac43c9 100644
--- a/guix/build/java-utils.scm
+++ b/guix/build/java-utils.scm
@@ -125,7 +125,7 @@ the phase fails."
                                                              version ".jar"))))
            ;; Otherwise, we try to find any jar file.
            (jars (if (null? jars)
-                     (find-files "." ".*.jar")
+                     (find-files "." "\\.jar$")
                      jars))
            (jar-name (string-append repository artifact "-" version ".jar"))
            (pom-name (string-append repository artifact "-" version ".pom")))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 09/14] gnu: Add java-jopt-simple-4.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
                     ` (6 preceding siblings ...)
  2021-05-31 22:44   ` [bug#48766] [PATCH 08/14] guix: java-utils: Look for actual jar files Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 10/14] gnu: java-commons-math3: Install to maven repository Julien Lepiller
                     ` (4 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* gnu/packges/java.scm (java-jopt-simple-4): New variable.
(java-jopt-simple): Install to maven repository structure.
---
 gnu/packages/java.scm | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index d7118b4ce6..14d02af512 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -3,7 +3,7 @@
 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
 ;;; Copyright © 2016, 2017 Roel Janssen <roel@gnu.org>
 ;;; Copyright © 2017, 2019, 2021 Carlo Zancanaro <carlo@zancanaro.id.au>
-;;; Copyright © 2017-2020 Julien Lepiller <julien@lepiller.eu>
+;;; Copyright © 2017-2021 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2017 Thomas Danckaert <post@thomasdanckaert.be>
 ;;; Copyright © 2016, 2017, 2018 Alex Vong <alexvong1995@gmail.com>
 ;;; Copyright © 2017, 2019, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
@@ -5715,7 +5715,13 @@ The jMock library
     (build-system ant-build-system)
     (arguments
      `(#:tests? #f ; there are no tests
-       #:jar-name "jopt-simple.jar"))
+       #:jar-name "jopt-simple.jar"
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'install 'create-pom
+           (generate-pom.xml "pom.xml" "net.sf.jopt-simple" "jopt-simple" ,version))
+         (replace 'install
+           (install-from-pom "pom.xml")))))
     (home-page "https://pholser.github.io/jopt-simple/")
     (synopsis "Java library for parsing command line options")
     (description "JOpt Simple is a Java library for parsing command line
@@ -5727,6 +5733,28 @@ retrieval of options and their arguments simple and expressive, without being
 overly clever.")
     (license license:expat)))
 
+;; Required by jmh
+(define-public java-jopt-simple-4
+  (package
+    (inherit java-jopt-simple)
+    (version "4.6")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://repo1.maven.org/maven2/"
+                                  "net/sf/jopt-simple/jopt-simple/"
+                                  version "/jopt-simple-"
+                                  version "-sources.jar"))
+              (sha256
+               (base32
+                "0ny82zczxkn201ld0b7rps0ifzjhfs8m1ncdmy1f50145ciszkpd"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments java-jopt-simple)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (replace 'create-pom
+             (generate-pom.xml "pom.xml" "net.sf.jopt-simple" "jopt-simple"
+                               ,version))))))))
+
 (define-public java-commons-math3
   (package
     (name "java-commons-math3")
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 10/14] gnu: java-commons-math3: Install to maven repository.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
                     ` (7 preceding siblings ...)
  2021-05-31 22:44   ` [bug#48766] [PATCH 09/14] gnu: Add java-jopt-simple-4 Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 11/14] gnu: maven-core: Hardcode versions we have in Guix Julien Lepiller
                     ` (3 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* gnu/packages/java.scm (java-commons-math3)[phases]: Use
install-from-pom.
---
 gnu/packages/java.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 14d02af512..dd9827a351 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -5789,7 +5789,7 @@ overly clever.")
              #t))
          ;; There is no install target.
          (replace 'install
-           (install-jars "target")))))
+           (install-from-pom "pom.xml")))))
     (native-inputs
      `(("java-junit" ,java-junit)
        ("java-hamcrest-core" ,java-hamcrest-core)))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 11/14] gnu: maven-core: Hardcode versions we have in Guix.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
                     ` (8 preceding siblings ...)
  2021-05-31 22:44   ` [bug#48766] [PATCH 10/14] gnu: java-commons-math3: Install to maven repository Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 12/14] gnu: maven-enforcer-parent-pom: Fix pom Julien Lepiller
                     ` (2 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* gnu/packages/maven.scm (maven-core)[phases]: Replace default hardcoded
versions by versions of packages we have in Guix.
---
 gnu/packages/maven.scm | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/maven.scm b/gnu/packages/maven.scm
index 8f63ee9be2..9d65e9b56d 100644
--- a/gnu/packages/maven.scm
+++ b/gnu/packages/maven.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
+;;; Copyright © 2018-2021 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
@@ -1541,7 +1541,9 @@ process."))))
             (add-before 'build 'modify-metainf
               (lambda _
                 (substitute* "build.xml"
-                  (("message=\"\"") "message=\"Implementation-Version: 3.5.4\n\""))
+                  (("message=\"\"")
+                   (string-append "message=\"Implementation-Version: "
+                                  (package-version maven) "\n\"")))
                 #t))
             (add-before 'build 'add-maven-files
               (lambda _
@@ -1590,7 +1592,28 @@ artifactId=maven-core" ,(package-version maven-core-bootstrap))))
                                        default-bindings-xml
                                        artifact-handlers-xml)))))))
                 #t))
-            (add-after 'generate-metadata 'rebuild
+            (add-after 'generate-metadata 'fix-plugin-versions
+              (lambda _
+                ;; This file controls the default plugins used by Maven.  Ensure
+                ;; we use the versions we have packaged by default
+                (substitute* '("build/classes/META-INF/plexus/default-bindings.xml"
+                               "build/classes/META-INF/plexus/components.xml")
+                  (("maven-install-plugin:[0-9.]+")
+                   (string-append "maven-install-plugin:"
+                                  ,(package-version maven-install-plugin)))
+                  (("maven-resources-plugin:[0-9.]+")
+                   (string-append "maven-resources-plugin:"
+                                  ,(package-version maven-resources-plugin)))
+                  (("maven-compiler-plugin:[0-9.]+")
+                   (string-append "maven-compiler-plugin:"
+                                  ,(package-version maven-compiler-plugin)))
+                  (("maven-surefire-plugin:[0-9.]+")
+                   (string-append "maven-surefire-plugin:"
+                                  ,(package-version maven-surefire-plugin)))
+                  (("maven-jar-plugin:[0-9.]+")
+                   (string-append "maven-jar-plugin:"
+                                  ,(package-version maven-jar-plugin))))))
+            (add-after 'fix-plugin-versions 'rebuild
               (lambda _
                 (invoke "ant" "jar")
                 #t))))))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 12/14] gnu: maven-enforcer-parent-pom: Fix pom.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
                     ` (9 preceding siblings ...)
  2021-05-31 22:44   ` [bug#48766] [PATCH 11/14] gnu: maven-core: Hardcode versions we have in Guix Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 13/14] gnu: java-jmh: Update to 1.32 Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 14/14] gnu: java-jmh: Switch to maven-build-system Julien Lepiller
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* gnu/packages/maven.scm (maven-enforcer-parent-pom): Fix dependency
versions in pom file.
---
 gnu/packages/maven.scm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gnu/packages/maven.scm b/gnu/packages/maven.scm
index 9d65e9b56d..f7cb168f47 100644
--- a/gnu/packages/maven.scm
+++ b/gnu/packages/maven.scm
@@ -2713,6 +2713,15 @@ Maven project dependencies.")
        (modify-phases %standard-phases
          (delete 'configure)
          (delete 'build)
+         (add-before 'install 'fix-pom-versions
+           (lambda _
+             (substitute* "pom.xml"
+               (("3.8.1") ,(package-version java-commons-lang3))
+               (("1.4.1") ,(package-version maven-resolver-util))
+               (("1.12") ,(package-version java-commons-codec))
+               (("<version>2.2</version>")
+                ,(string-append "<version>" (package-version maven-dependency-tree)
+                                "</version>")))))
          (replace 'install
            (install-pom-file "pom.xml")))))
     (propagated-inputs
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 13/14] gnu: java-jmh: Update to 1.32.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
                     ` (10 preceding siblings ...)
  2021-05-31 22:44   ` [bug#48766] [PATCH 12/14] gnu: maven-enforcer-parent-pom: Fix pom Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  2021-05-31 22:44   ` [bug#48766] [PATCH 14/14] gnu: java-jmh: Switch to maven-build-system Julien Lepiller
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* gnu/packages/java.scm (java-jmh): Update to 1.32.
[source]: Switch to the git repository.
---
 gnu/packages/java.scm | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index dd9827a351..c7ae002736 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -5803,16 +5803,16 @@ available in the Java programming language or Commons Lang.")
 (define-public java-jmh
   (package
     (name "java-jmh")
-    (version "1.17.5")
+    (version "1.32")
     (source (origin
-              (method hg-fetch)
-              (uri (hg-reference
-                    (url "http://hg.openjdk.java.net/code-tools/jmh/")
-                    (changeset version)))
-              (file-name (string-append name "-" version "-checkout"))
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/openjdk/jmh")
+                    (commit version)))
+              (file-name (git-file-name name version))
               (sha256
                (base32
-                "1fxyxhg9famwcg1prc4cgwb5wzyxqavn3cjm5vz8605xz7x5k084"))))
+                "0i7fa7l3gdqkkgz5ddayp6m46dgbj9rqlz35xffrcbyiz3gpljy0"))))
     (build-system ant-build-system)
     (arguments
      `(#:jar-name "jmh-core.jar"
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [bug#48766] [PATCH 14/14] gnu: java-jmh: Switch to maven-build-system.
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
                     ` (11 preceding siblings ...)
  2021-05-31 22:44   ` [bug#48766] [PATCH 13/14] gnu: java-jmh: Update to 1.32 Julien Lepiller
@ 2021-05-31 22:44   ` Julien Lepiller
  12 siblings, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-05-31 22:44 UTC (permalink / raw)
  To: 48766

* gnu/packages/java.scm (java-jmh): Switch to maven-build-system.
---
 gnu/packages/java.scm | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index c7ae002736..f597c64811 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -43,6 +43,7 @@
   #:use-module (guix utils)
   #:use-module (guix build-system ant)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system maven)
   #:use-module (guix build-system trivial)
   #:use-module (gnu packages)
   #:use-module (gnu packages attr)
@@ -5813,26 +5814,27 @@ available in the Java programming language or Commons Lang.")
               (sha256
                (base32
                 "0i7fa7l3gdqkkgz5ddayp6m46dgbj9rqlz35xffrcbyiz3gpljy0"))))
-    (build-system ant-build-system)
+    (build-system maven-build-system)
     (arguments
-     `(#:jar-name "jmh-core.jar"
-       #:source-dir "jmh-core/src/main"
-       #:test-dir "jmh-core/src/test"
+     `(#:exclude
+       (("org.apache.maven.plugins" .
+         ("maven-source-plugin" "maven-archetype-plugin" "maven-shade-plugin"
+          "maven-site-plugin" "maven-javadoc-plugin" "maven-eclipse-plugin"))
+        ("com.mycila.maven-license-plugin" . ("maven-license-plugin"))
+        ("org.apache.maven.wagon" . ("wagon-ssh")))
+       #:maven-plugins
+       (("maven-enforcer-plugin" ,maven-enforcer-plugin)
+        ,@(default-maven-plugins))
        #:phases
        (modify-phases %standard-phases
-         ;; This seems to be a bug in the JDK.  It may not be necessary in
-         ;; future versions of the JDK.
-         (add-after 'unpack 'fix-bug
+         (add-after 'unpack 'remove-unnecessary
            (lambda _
-             (with-directory-excursion
-                 "jmh-core/src/main/java/org/openjdk/jmh/runner/options"
-               (substitute* '("IntegerValueConverter.java"
-                              "ThreadsValueConverter.java")
-                 (("public Class<Integer> valueType")
-                  "public Class<? extends Integer> valueType")))
-             #t)))))
-    (inputs
-     `(("java-jopt-simple" ,java-jopt-simple)
+             ;; requires org.apache.maven.archetype:archetype-packaging.
+             ;; Its subprojects also require groovy, kotlin and scala,
+             ;; respectively.
+             (delete-file-recursively "jmh-archetypes"))))))
+    (propagated-inputs
+     `(("java-jopt-simple" ,java-jopt-simple-4)
        ("java-commons-math3" ,java-commons-math3)))
     (native-inputs
      `(("java-junit" ,java-junit)
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* bug#48766: [PATCH] gnu: java-jmh: Switch to maven-build-system.
  2021-05-31 22:41 [bug#48766] [PATCH] gnu: java-jmh: Switch to maven-build-system Julien Lepiller
  2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
@ 2021-06-22 11:13 ` Julien Lepiller
  1 sibling, 0 replies; 16+ messages in thread
From: Julien Lepiller @ 2021-06-22 11:13 UTC (permalink / raw)
  To: 48766-done

After almost a month of silence, pushed to master as
4c98db94b0271aa5371ff00cf98c0ebc70ab1a8d to
1b1eeb3b123162c4d73c939e9ca7bbbb4f79aef1. Thanks!




^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-06-22 11:14 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-31 22:41 [bug#48766] [PATCH] gnu: java-jmh: Switch to maven-build-system Julien Lepiller
2021-05-31 22:44 ` [bug#48766] [PATCH 01/14] guix: java-utils: Factorize pom.xml generation Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 02/14] guix: maven: Simplify finding version and group information Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 03/14] guix: maven: Simplify finding local packages and modules Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 04/14] guix: maven: Support fixing extensions Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 05/14] guix: maven: Support fixing modules Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 06/14] guix: maven: Look in local packages when searching for package version Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 07/14] guix: maven: Use a temporary file to fix pom files Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 08/14] guix: java-utils: Look for actual jar files Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 09/14] gnu: Add java-jopt-simple-4 Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 10/14] gnu: java-commons-math3: Install to maven repository Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 11/14] gnu: maven-core: Hardcode versions we have in Guix Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 12/14] gnu: maven-enforcer-parent-pom: Fix pom Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 13/14] gnu: java-jmh: Update to 1.32 Julien Lepiller
2021-05-31 22:44   ` [bug#48766] [PATCH 14/14] gnu: java-jmh: Switch to maven-build-system Julien Lepiller
2021-06-22 11:13 ` bug#48766: [PATCH] " Julien Lepiller

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).