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 01/14] guix: java-utils: Factorize pom.xml generation.
Date: Tue,  1 Jun 2021 00:44:14 +0200	[thread overview]
Message-ID: <20210531224427.13300-1-julien@lepiller.eu> (raw)
In-Reply-To: <20210601004100.69baa2d0@tachikoma.lepiller.eu>

* 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





  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 ` Julien Lepiller [this message]
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

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-1-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).