Subject: [bug#63145] [PATCH 2/3] gnu: maven-*-*: DRY add-missing-shebangs.

From: Rostislav Svoboda <[email-masked]>
Date: Fri, 28 Apr 2023 15:13:11 +0200

* 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-shebangs`.
---
 gnu/packages/maven.scm | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/gnu/packages/maven.scm b/gnu/packages/maven.scm
index a3122bfa32..6990d091cf 100644
--- a/gnu/packages/maven.scm
+++ b/gnu/packages/maven.scm
@@ -1354,6 +1354,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 _
+     ;; -i, --in-place   edit files in place
+     (invoke "sed" "-i" "1s;^;#!/bin/sh\\n\\n;" "./sisu.sh")))
+
 (define-public maven-settings-builder
   (package
     (inherit maven-artifact)
@@ -1366,8 +1371,7 @@ (define-public maven-settings-builder
        #:phases
        (modify-phases %standard-phases
          (add-before 'patch-source-shebangs 'add-missing-shebang
-           (lambda _
-             (invoke "sed" "-i" "1s;^;#!/bin/sh\\n\\n;" "./sisu.sh")))
+           ,add-missing-shebang)
          (add-before 'build 'generate-sisu-named
            (lambda _
              (mkdir-p "build/classes/META-INF/sisu")
@@ -1400,8 +1404,7 @@ (define-public maven-model-builder
        #:phases
        (modify-phases %standard-phases
          (add-before 'patch-source-shebangs 'add-missing-shebang
-           (lambda _
-             (invoke "sed" "-i" "1s;^;#!/bin/sh\\n\\n;" "./sisu.sh")))
+           ,add-missing-shebang)
          (add-before 'configure 'chdir
            (lambda _
              ;; Required for tests that rely on the package's default
@@ -1508,8 +1511,7 @@ (define-public maven-resolver-provider
        #:phases
        (modify-phases %standard-phases
          (add-before 'patch-source-shebangs 'add-missing-shebang
-           (lambda _
-             (invoke "sed" "-i" "1s;^;#!/bin/sh\\n\\n;" "./sisu.sh")))
+           ,add-missing-shebang)
          (add-before 'build 'generate-sisu-named
            (lambda _
              (mkdir-p "build/classes/META-INF/sisu")
@@ -1601,8 +1603,7 @@ (define-public maven-core-bootstrap
          #:phases
          (modify-phases %standard-phases
            (add-before 'patch-source-shebangs 'add-missing-shebang
-             (lambda _
-               (invoke "sed" "-i" "1s;^;#!/bin/sh\\n\\n;" "./sisu.sh")))
+             ,add-missing-shebang)
            (add-before 'configure 'chdir
              (lambda _
                ;; Required for generating components.xml in maven-core
@@ -1835,8 +1836,7 @@ (define-public maven-embedder
        #:phases
        (modify-phases %standard-phases
          (add-before 'patch-source-shebangs 'add-missing-shebang
-           (lambda _
-             (invoke "sed" "-i" "1s;^;#!/bin/sh\\n\\n;" "./sisu.sh")))
+           ,add-missing-shebang)
          (add-before 'build 'generate-sisu-named
            (lambda _
              (mkdir-p "build/classes/META-INF/sisu")
-- 
2.39.2