Subject: Re: bug#63145: [PATCH 1/3] gnu: maven-*-*: Fix - add missing shebang to the sisu.sh.

From: Rostislav Svoboda <[email-masked]>
Date: Sat, 29 Apr 2023 12:24:45 +0200

Hi Ludo,

> We could definitely factorize along the lines of what you propose.
> Would you like to update these two patches?

Here are the updated patches.

Cheers Bost
From 54c70d1ea7130bedd5fda4317a76ad5546e89348 Mon Sep 17 00:00:00 2001
From: Rostislav Svoboda <[email-masked]>
Date: Sat, 29 Apr 2023 12:01:01 +0200
Subject: [PATCH 2/2] gnu: maven-*-*: DRY generate-sisu-named.

* gnu/packages/maven.scm
  - maven-settings-builder
  - maven-model-builder
  - maven-resolver-provider
  - maven-core-bootstrap
  - maven-embedder
  Implement common functionality just once in the `generate-sisu-named`.
---
 gnu/packages/maven.scm | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/gnu/packages/maven.scm b/gnu/packages/maven.scm
index 8c44e68d31..51fbe5ae54 100644
--- a/gnu/packages/maven.scm
+++ b/gnu/packages/maven.scm
@@ -1361,6 +1361,14 @@ (define add-missing-shebang
      (substitute* "sisu.sh"
        (("^## T") "#!/bin/sh\n## T"))))
 
+(define* (generate-sisu-named sisu-path #:optional (src-path ""))
+  (let ((sisu-sh (string-append sisu-path "sisu.sh")))
+    `(lambda _
+       (mkdir-p "build/classes/META-INF/sisu")
+       (chmod  ,sisu-sh #o755)
+       (invoke ,sisu-sh ,(string-append src-path "src/main/java")
+               "build/classes/META-INF/sisu/javax.inject.Named"))))
+
 (define-public maven-settings-builder
   (package
     (inherit maven-artifact)
@@ -1374,11 +1382,7 @@ (define-public maven-settings-builder
        (modify-phases %standard-phases
          (add-after 'unpack 'add-sisu-shebang ,add-missing-shebang)
          (add-before 'build 'generate-sisu-named
-           (lambda _
-             (mkdir-p "build/classes/META-INF/sisu")
-             (chmod "sisu.sh" #o755)
-             (invoke "./sisu.sh" "maven-settings-builder/src/main/java"
-                     "build/classes/META-INF/sisu/javax.inject.Named")))
+           ,(generate-sisu-named "./" "maven-settings-builder/"))
          (replace 'install (install-from-pom "maven-settings-builder/pom.xml")))))
     (propagated-inputs
      (list java-plexus-utils
@@ -1416,11 +1420,7 @@ (define-public maven-model-builder
              #t))
          (add-after 'unpack 'add-sisu-shebang ,add-missing-shebang)
          (add-before 'build 'generate-sisu-named
-           (lambda _
-             (mkdir-p "build/classes/META-INF/sisu")
-             (chmod "../sisu.sh" #o755)
-             (invoke "../sisu.sh" "src/main/java"
-                     "build/classes/META-INF/sisu/javax.inject.Named")))
+           ,(generate-sisu-named "../"))
          (replace 'install
            (install-from-pom "pom.xml")))))
     (propagated-inputs
@@ -1512,12 +1512,7 @@ (define-public maven-resolver-provider
        (modify-phases %standard-phases
          (add-after 'unpack 'add-sisu-shebang ,add-missing-shebang)
          (add-before 'build 'generate-sisu-named
-           (lambda _
-             (mkdir-p "build/classes/META-INF/sisu")
-             (chmod "./sisu.sh" #o755)
-             (invoke "./sisu.sh" "maven-resolver-provider/src/main/java"
-                     "build/classes/META-INF/sisu/javax.inject.Named")
-             #t))
+           ,(generate-sisu-named "./" "maven-resolver-provider/"))
          (replace 'install
            (install-from-pom "maven-resolver-provider/pom.xml")))))
     (propagated-inputs
@@ -1835,12 +1830,7 @@ (define-public maven-embedder
        (modify-phases %standard-phases
          (add-after 'unpack 'add-sisu-shebang ,add-missing-shebang)
          (add-before 'build 'generate-sisu-named
-           (lambda _
-             (mkdir-p "build/classes/META-INF/sisu")
-             (chmod "sisu.sh" #o755)
-             (invoke "./sisu.sh" "maven-embedder/src/main/java"
-                     "build/classes/META-INF/sisu/javax.inject.Named")
-             #t))
+           ,(generate-sisu-named "./" "maven-embeder/"))
          (add-before 'build 'copy-resources
            (lambda _
              (mkdir-p "build/classes/")
-- 
2.39.2

From fb7774525924d59bf212a122301aa47766f53b0e Mon Sep 17 00:00:00 2001
From: Rostislav Svoboda <[email-masked]>
Date: Sat, 29 Apr 2023 11:56:24 +0200
Subject: [PATCH 1/2] gnu: maven-*-*: DRY add-missing-shebang.

* gnu/packages/maven.scm
  - maven-settings-builder
  - maven-model-builder
  - maven-resolver-provider
  - maven-core-bootstrap
  - maven-embedder
  Implement common functionality just once in the `add-missing-shebang`.
---
 gnu/packages/maven.scm | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/maven.scm b/gnu/packages/maven.scm
index a805bda8e5..8c44e68d31 100644
--- a/gnu/packages/maven.scm
+++ b/gnu/packages/maven.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2020 Efraim Flashner <[email-masked]>
 ;;; Copyright © 2022 Artyom V. Poptsov <[email-masked]>
 ;;; Copyright © 2023 Aleksandr Vityazev <[email-masked]>
+;;; Copyright © 2023 Rostislav Svoboda <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1355,6 +1356,11 @@ (define-public maven-settings
 tool.  This package contains strictly the model for Maven settings, that is
 simply plain java objects.")))
 
+(define add-missing-shebang
+  `(lambda _
+     (substitute* "sisu.sh"
+       (("^## T") "#!/bin/sh\n## T"))))
+
 (define-public maven-settings-builder
   (package
     (inherit maven-artifact)
@@ -1366,10 +1372,7 @@ (define-public maven-settings-builder
        #:test-dir "maven-settings-builder/src/test"
        #:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'add-sisu-shebang
-           (lambda _
-             (substitute* "sisu.sh"
-               (("^## T") "#!/bin/sh\n## T"))))
+         (add-after 'unpack 'add-sisu-shebang ,add-missing-shebang)
          (add-before 'build 'generate-sisu-named
            (lambda _
              (mkdir-p "build/classes/META-INF/sisu")
@@ -1411,10 +1414,7 @@ (define-public maven-model-builder
              (copy-recursively "src/main/resources"
                                "build/classes")
              #t))
-         (add-after 'unpack 'add-sisu-shebang
-           (lambda _
-             (substitute* "sisu.sh"
-               (("^## T") "#!/bin/sh\n## T"))))
+         (add-after 'unpack 'add-sisu-shebang ,add-missing-shebang)
          (add-before 'build 'generate-sisu-named
            (lambda _
              (mkdir-p "build/classes/META-INF/sisu")
@@ -1510,10 +1510,7 @@ (define-public maven-resolver-provider
        #:tests? #f; dependency loop on maven-core (@Component RepositorySystem)
        #:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'add-sisu-shebang
-           (lambda _
-             (substitute* "sisu.sh"
-               (("^## T") "#!/bin/sh\n## T"))))
+         (add-after 'unpack 'add-sisu-shebang ,add-missing-shebang)
          (add-before 'build 'generate-sisu-named
            (lambda _
              (mkdir-p "build/classes/META-INF/sisu")
@@ -1604,10 +1601,7 @@ (define-public maven-core-bootstrap
          #:tests? #f
          #:phases
          (modify-phases %standard-phases
-           (add-after 'unpack 'add-sisu-shebang
-             (lambda _
-               (substitute* "sisu.sh"
-                 (("^## T") "#!/bin/sh\n## T"))))
+           (add-after 'unpack 'add-sisu-shebang ,add-missing-shebang)
            (add-before 'configure 'chdir
              (lambda _
                ;; Required for generating components.xml in maven-core
@@ -1839,10 +1833,7 @@ (define-public maven-embedder
        #:jdk ,icedtea-8
        #:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'add-sisu-shebang
-           (lambda _
-             (substitute* "sisu.sh"
-               (("^## T") "#!/bin/sh\n## T"))))
+         (add-after 'unpack 'add-sisu-shebang ,add-missing-shebang)
          (add-before 'build 'generate-sisu-named
            (lambda _
              (mkdir-p "build/classes/META-INF/sisu")
-- 
2.39.2