unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Julien Lepiller <julien@lepiller.eu>
To: 48766@debbugs.gnu.org
Subject: [bug#48766] [PATCH 02/14] guix: maven: Simplify finding version and group information.
Date: Tue,  1 Jun 2021 00:44:15 +0200	[thread overview]
Message-ID: <20210531224427.13300-2-julien@lepiller.eu> (raw)
In-Reply-To: <20210531224427.13300-1-julien@lepiller.eu>

* 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





  reply	other threads:[~2021-05-31 22:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Julien Lepiller [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210531224427.13300-2-julien@lepiller.eu \
    --to=julien@lepiller.eu \
    --cc=48766@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).