diff mbox series

[bug#48766,05/14] guix: maven: Support fixing modules.

Message ID 20210531224427.13300-5-julien@lepiller.eu
State Accepted
Headers show
Series [bug#48766,01/14] guix: java-utils: Factorize pom.xml generation. | expand

Commit Message

Julien Lepiller May 31, 2021, 10:44 p.m. UTC
* 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 mbox series

Patch

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
       ('() '())