all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#56054] [PATCH] gnu: Add maven-shared-invoker
@ 2022-06-18 14:58 Artyom V. Poptsov
  2022-06-18 19:56 ` Julien Lepiller
  0 siblings, 1 reply; 3+ messages in thread
From: Artyom V. Poptsov @ 2022-06-18 14:58 UTC (permalink / raw)
  To: 56054


[-- Attachment #1.1: Type: text/plain, Size: 88 bytes --]

Hello,

this patch adds Apache Maven Invoker[1] under the name
'maven-shared-invoker'.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-Add-maven-shared-invoker.patch --]
[-- Type: text/x-diff, Size: 12523 bytes --]

From bc84964c765656cd53bc85345b30d780157818dc Mon Sep 17 00:00:00 2001
From: "Artyom V. Poptsov" <poptsov.artyom@gmail.com>
Date: Sat, 18 Jun 2022 17:05:36 +0300
Subject: [PATCH] gnu: Add maven-shared-invoker

* gnu/packages/maven.scm (maven-shared-invoker): New variable.
* gnu/packages/patches/maven-shared-invoker-exception-handler-fix.patch,
  gnu/packages/patches/maven-shared-invoker-rename-test-classes.patch: Add to
  the repository.
* gnu/local.mk (dist_patch_DATA): Add new Maven shared invoker patches.
---
 gnu/local.mk                                  |   2 +
 gnu/packages/maven.scm                        |  37 +++++
 ...shared-invoker-exception-handler-fix.patch |  28 ++++
 ...n-shared-invoker-rename-test-classes.patch | 126 ++++++++++++++++++
 4 files changed, 193 insertions(+)
 create mode 100644 gnu/packages/patches/maven-shared-invoker-exception-handler-fix.patch
 create mode 100644 gnu/packages/patches/maven-shared-invoker-rename-test-classes.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 0176585485..6d7aafb848 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1479,6 +1479,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/maxima-defsystem-mkdir.patch		\
   %D%/packages/patches/maven-generate-component-xml.patch		\
   %D%/packages/patches/maven-generate-javax-inject-named.patch		\
+  %D%/packages/patches/maven-shared-invoker-exception-handler-fix.patch	\
+  %D%/packages/patches/maven-shared-invoker-rename-test-classes.patch	\
   %D%/packages/patches/mcrypt-CVE-2012-4409.patch			\
   %D%/packages/patches/mcrypt-CVE-2012-4426.patch			\
   %D%/packages/patches/mcrypt-CVE-2012-4527.patch			\
diff --git a/gnu/packages/maven.scm b/gnu/packages/maven.scm
index 817fee1c71..57f469ed5d 100644
--- a/gnu/packages/maven.scm
+++ b/gnu/packages/maven.scm
@@ -765,6 +765,43 @@ plexus-utils in Maven.  It is not a 100% API compatible replacement but a
 replacement with improvements.")
     (license license:asl2.0)))
 
+(define-public maven-shared-invoker
+  (package
+    (name "maven-shared-invoker")
+    (version "3.2.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://apache/maven/shared/"
+                                  "maven-invoker-" version "-source-release.zip"))
+              (sha256
+               (base32
+                "0yhgxvwpmyfhqaksdfmj9c4ml4pj60gnin8bq1a92ximf1dyyjyc"))
+              (patches
+               (search-patches
+                "maven-shared-invoker-exception-handler-fix.patch"
+                "maven-shared-invoker-rename-test-classes.patch"))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "maven-shared-invoker.jar"
+       #:source-dir "src/main/java"
+       #:tests? #f))                      ; Tests require Maven itself
+    (propagated-inputs
+     (list maven-parent-pom-35))
+    (native-inputs
+     (list unzip
+           maven-surefire-plugin
+           java-javax-inject
+           java-junit))
+    (home-page "https://maven.apache.org/shared/maven-invoker/index.html")
+    (synopsis "Invoke Maven programmatically")
+    (description "The API of this module is concerned with firing a Maven
+build in a new JVM.  It accomplishes its task by building up a conventional
+Maven command line from options given in the current request, along with those
+global options specified in the invoker itself.  Once it has the command line,
+the invoker will execute it, and capture the resulting exit code or any
+exception thrown to signal a failure to execute.")
+    (license license:asl2.0)))
+
 (define-public maven-plugin-annotations
   (package
     (name "maven-plugin-annotations")
diff --git a/gnu/packages/patches/maven-shared-invoker-exception-handler-fix.patch b/gnu/packages/patches/maven-shared-invoker-exception-handler-fix.patch
new file mode 100644
index 0000000000..eb572f7c26
--- /dev/null
+++ b/gnu/packages/patches/maven-shared-invoker-exception-handler-fix.patch
@@ -0,0 +1,28 @@
+From 30e9cde32c1e2513ca1f656fa5043c05935f2645 Mon Sep 17 00:00:00 2001
+From: "Artyom V. Poptsov" <poptsov.artyom@gmail.com>
+Date: Tue, 14 Jun 2022 23:53:13 +0300
+Subject: [PATCH 1/2] MavenCommandLineBuilder: Fix exception handling
+
+* src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
+  (setGoals): Catch 'Exception' instead of 'CommandLineException' as
+  'CommandLineException' is never thrown in the "try" block.
+---
+ .../apache/maven/shared/invoker/MavenCommandLineBuilder.java    | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java b/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
+index 7c7e985..eaf8333 100644
+--- a/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
++++ b/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
+@@ -257,7 +257,7 @@ public class MavenCommandLineBuilder
+             {
+                 cli.createArg().setLine( StringUtils.join( goals.iterator(), " " ) );
+             }
+-            catch ( CommandLineException e )
++            catch ( Exception e )
+             {
+                 throw new CommandLineConfigurationException( "Problem to set goals: " + e.getMessage(), e );
+             }
+-- 
+2.25.1
+
diff --git a/gnu/packages/patches/maven-shared-invoker-rename-test-classes.patch b/gnu/packages/patches/maven-shared-invoker-rename-test-classes.patch
new file mode 100644
index 0000000000..7ffb6fed9b
--- /dev/null
+++ b/gnu/packages/patches/maven-shared-invoker-rename-test-classes.patch
@@ -0,0 +1,126 @@
+From 4bce3183b25c44ab406c2f4d8541a0a520b15a3d Mon Sep 17 00:00:00 2001
+From: "Artyom V. Poptsov" <poptsov.artyom@gmail.com>
+Date: Wed, 15 Jun 2022 07:09:29 +0300
+Subject: [PATCH 2/2] test: Rename some classes to avoid name conflicts
+
+* src/test/resources/test-build-should-timeout/src/main/java/org/apache/maven/shared/invoker/App.java:
+  Rename to
+  "src/test/resources/test-build-should-timeout/src/main/java/org/apache/maven/shared/invoker/AppTimeout.java"
+* src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java
+  Rename to
+  "src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTimeoutTest.java"
+* src/test/resources/test-build-should-succeed/src/test/java/org/apache/maven/shared/invoker/AppTest.java:
+  Rename to
+  "src/test/resources/test-build-should-succeed/src/test/java/org/apache/maven/shared/invoker/AppShouldSucceedTest.java"
+* src/test/resources/test-build-should-succeed/src/main/java/org/apache/maven/shared/invoker/App.java:
+  Rename to
+  "src/test/resources/test-build-should-timeout/src/main/java/org/apache/maven/shared/invoker/AppTimeout.java".
+---
+ ...AppTest.java => AppShouldSucceedTest.java} |  4 +--
+ .../org/apache/maven/shared/invoker/App.java  | 32 -------------------
+ .../maven/shared/invoker/AppTimeout.java}     |  2 +-
+ .../{AppTest.java => AppTimeoutTest.java}     |  2 +-
+ 4 files changed, 4 insertions(+), 36 deletions(-)
+ rename src/test/resources/test-build-should-succeed/src/test/java/org/apache/maven/shared/invoker/{AppTest.java => AppShouldSucceedTest.java} (94%)
+ delete mode 100644 src/test/resources/test-build-should-timeout/src/main/java/org/apache/maven/shared/invoker/App.java
+ rename src/test/resources/{test-build-should-succeed/src/main/java/org/apache/maven/shared/invoker/App.java => test-build-should-timeout/src/main/java/org/apache/maven/shared/invoker/AppTimeout.java} (97%)
+ rename src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/{AppTest.java => AppTimeoutTest.java} (97%)
+
+diff --git a/src/test/resources/test-build-should-succeed/src/test/java/org/apache/maven/shared/invoker/AppTest.java b/src/test/resources/test-build-should-succeed/src/test/java/org/apache/maven/shared/invoker/AppShouldSucceedTest.java
+similarity index 94%
+rename from src/test/resources/test-build-should-succeed/src/test/java/org/apache/maven/shared/invoker/AppTest.java
+rename to src/test/resources/test-build-should-succeed/src/test/java/org/apache/maven/shared/invoker/AppShouldSucceedTest.java
+index 785d70c..9b5bb0a 100644
+--- a/src/test/resources/test-build-should-succeed/src/test/java/org/apache/maven/shared/invoker/AppTest.java
++++ b/src/test/resources/test-build-should-succeed/src/test/java/org/apache/maven/shared/invoker/AppShouldSucceedTest.java
+@@ -26,7 +26,7 @@ import junit.framework.TestSuite;
+ /**
+  * Unit test for simple App.
+  */
+-public class AppTest 
++public class AppShouldSucceedTest
+     extends TestCase
+ {
+     /**
+@@ -34,7 +34,7 @@ public class AppTest
+      *
+      * @param testName name of the test case
+      */
+-    public AppTest( String testName )
++    public AppShouldSucceedTest( String testName )
+     {
+         super( testName );
+     }
+diff --git a/src/test/resources/test-build-should-timeout/src/main/java/org/apache/maven/shared/invoker/App.java b/src/test/resources/test-build-should-timeout/src/main/java/org/apache/maven/shared/invoker/App.java
+deleted file mode 100644
+index 753a51c..0000000
+--- a/src/test/resources/test-build-should-timeout/src/main/java/org/apache/maven/shared/invoker/App.java
++++ /dev/null
+@@ -1,32 +0,0 @@
+-package org.apache.maven.shared.invoker;
+-
+-/*
+- * Licensed to the Apache Software Foundation (ASF) under one
+- * or more contributor license agreements.  See the NOTICE file
+- * distributed with this work for additional information
+- * regarding copyright ownership.  The ASF licenses this file
+- * to you under the Apache License, Version 2.0 (the
+- * "License"); you may not use this file except in compliance
+- * with the License.  You may obtain a copy of the License at
+- *
+- *   http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing,
+- * software distributed under the License is distributed on an
+- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+- * KIND, either express or implied.  See the License for the
+- * specific language governing permissions and limitations
+- * under the License.
+- */
+-
+-/**
+- * Hello world!
+- *
+- */
+-public class App 
+-{
+-    public static void main( String[] args )
+-    {
+-        System.out.println( "Hello World!" );
+-    }
+-}
+diff --git a/src/test/resources/test-build-should-succeed/src/main/java/org/apache/maven/shared/invoker/App.java b/src/test/resources/test-build-should-timeout/src/main/java/org/apache/maven/shared/invoker/AppTimeout.java
+similarity index 97%
+rename from src/test/resources/test-build-should-succeed/src/main/java/org/apache/maven/shared/invoker/App.java
+rename to src/test/resources/test-build-should-timeout/src/main/java/org/apache/maven/shared/invoker/AppTimeout.java
+index 753a51c..d94b104 100644
+--- a/src/test/resources/test-build-should-succeed/src/main/java/org/apache/maven/shared/invoker/App.java
++++ b/src/test/resources/test-build-should-timeout/src/main/java/org/apache/maven/shared/invoker/AppTimeout.java
+@@ -23,7 +23,7 @@ package org.apache.maven.shared.invoker;
+  * Hello world!
+  *
+  */
+-public class App 
++public class AppTimeout
+ {
+     public static void main( String[] args )
+     {
+diff --git a/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java b/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTimeoutTest.java
+similarity index 97%
+rename from src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java
+rename to src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTimeoutTest.java
+index 27808ea..2bdeda4 100644
+--- a/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTest.java
++++ b/src/test/resources/test-build-should-timeout/src/test/java/org/apache/maven/shared/invoker/AppTimeoutTest.java
+@@ -24,7 +24,7 @@ import org.junit.Test;
+ /**
+  * Unit test for simple App.
+  */
+-public class AppTest
++public class AppTimeoutTest
+ {
+ 
+     /**
+-- 
+2.25.1
+
-- 
2.25.1


[-- Attachment #1.3: Type: text/plain, Size: 295 bytes --]


- Artyom

References:
1. https://maven.apache.org/shared/maven-invoker/index.html

-- 
Artyom "avp" Poptsov <poptsov.artyom@gmail.com>
Home page: https://memory-heap.org/~avp/
CADR Hackerspace co-founder: https://cadrspace.ru/
GPG: D0C2 EAC1 3310 822D 98DE  B57C E9C5 A2D9 0898 A02F

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#56054] [PATCH] gnu: Add maven-shared-invoker
  2022-06-18 14:58 [bug#56054] [PATCH] gnu: Add maven-shared-invoker Artyom V. Poptsov
@ 2022-06-18 19:56 ` Julien Lepiller
  2022-08-04  9:11   ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Lepiller @ 2022-06-18 19:56 UTC (permalink / raw)
  To: Artyom V. Poptsov; +Cc: 56054

Thanks for the patch! It's mostly good, but I have some comments below
:)

Le Sat, 18 Jun 2022 17:58:12 +0300,
"Artyom V. Poptsov" <poptsov.artyom@gmail.com> a écrit :

> +(define-public maven-shared-invoker
> +  (package
> +    (name "maven-shared-invoker")
> +    (version "3.2.0")
> +    (source (origin
> +              (method url-fetch)
> +              (uri (string-append "mirror://apache/maven/shared/"
> +                                  "maven-invoker-" version
> "-source-release.zip"))
> +              (sha256
> +               (base32
> +
> "0yhgxvwpmyfhqaksdfmj9c4ml4pj60gnin8bq1a92ximf1dyyjyc"))
> +              (patches
> +               (search-patches
> +                "maven-shared-invoker-exception-handler-fix.patch"
> +                "maven-shared-invoker-rename-test-classes.patch"))))
> +    (build-system ant-build-system)
> +    (arguments
> +     `(#:jar-name "maven-shared-invoker.jar"
> +       #:source-dir "src/main/java"
> +       #:tests? #f))                      ; Tests require Maven
> itself

How so? Tests are usually just junit tests and it's easy to run them.
How are they so different from the usual tests?

If it really requires maven, have you tried building it with the
maven-build-system? There's a way to remove plugins from the pom file,
so maven doesn't complain. The pom file doesn't look too complex, so I
think it could work.

> +    (propagated-inputs
> +     (list maven-parent-pom-35))

Yes you should propagate the parent, but that's only because maven
needs it when it reads this package's pom file. So, please keep it and
install this package from its pom file, like the others :)

> +    (native-inputs
> +     (list unzip
> +           maven-surefire-plugin
> +           java-javax-inject
> +           java-junit))

I'm surprised here you need maven-surefire-plugin. What is it used for
exactly? From my understanding it can't be called outside of maven, and
we don't use maven to install this package.

The pom file lists java-javax-inject as a normal dependency, so it
should be propagated instead. The pom file also lists
maven-shared-utils. Is it needed? If so please add it to the propagated
inputs, otherwise fix the pom file (with a patch to upstream I guess).

> +    (home-page
> "https://maven.apache.org/shared/maven-invoker/index.html")
> +    (synopsis "Invoke Maven programmatically")

> Sep 17 00:00:00 2001 +From: "Artyom V. Poptsov"
> <poptsov.artyom@gmail.com> +Date: Tue, 14 Jun 2022 23:53:13 +0300
> +Subject: [PATCH 1/2] MavenCommandLineBuilder: Fix exception handling
> +
> +*
> src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
> +  (setGoals): Catch 'Exception' instead of 'CommandLineException' as
> +  'CommandLineException' is never thrown in the "try" block.
> +---
> + .../apache/maven/shared/invoker/MavenCommandLineBuilder.java    | 2
> +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git

This looks like a simple patch, but I don't understand why it's needed.
Is this a fix from upstream? Did you create it? For what reason?

> @@ -0,0 +1,126 @@ +From 4bce3183b25c44ab406c2f4d8541a0a520b15a3d Mon
> Sep 17 00:00:00 2001 +From: "Artyom V. Poptsov"
> <poptsov.artyom@gmail.com> +Date: Wed, 15 Jun 2022 07:09:29 +0300
> +Subject: [PATCH 2/2] test: Rename some classes to avoid name
> conflicts +
> +*

I'm lost. What's happening in this patch? Why do you need it
(especially since you couldn't run the tests anyway)? Is this a problem
with upstream, or some issue you encountered because of what Guix is
doing?




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [bug#56054] [PATCH] gnu: Add maven-shared-invoker
  2022-06-18 19:56 ` Julien Lepiller
@ 2022-08-04  9:11   ` Ludovic Courtès
  0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2022-08-04  9:11 UTC (permalink / raw)
  To: Julien Lepiller; +Cc: Artyom V. Poptsov, 56054

Hey Artyom,

Did you have a chance to look at Julien’s comments below?

Thanks,
Ludo’.

Julien Lepiller <julien@lepiller.eu> skribis:

> Thanks for the patch! It's mostly good, but I have some comments below
> :)
>
> Le Sat, 18 Jun 2022 17:58:12 +0300,
> "Artyom V. Poptsov" <poptsov.artyom@gmail.com> a écrit :
>
>> +(define-public maven-shared-invoker
>> +  (package
>> +    (name "maven-shared-invoker")
>> +    (version "3.2.0")
>> +    (source (origin
>> +              (method url-fetch)
>> +              (uri (string-append "mirror://apache/maven/shared/"
>> +                                  "maven-invoker-" version
>> "-source-release.zip"))
>> +              (sha256
>> +               (base32
>> +
>> "0yhgxvwpmyfhqaksdfmj9c4ml4pj60gnin8bq1a92ximf1dyyjyc"))
>> +              (patches
>> +               (search-patches
>> +                "maven-shared-invoker-exception-handler-fix.patch"
>> +                "maven-shared-invoker-rename-test-classes.patch"))))
>> +    (build-system ant-build-system)
>> +    (arguments
>> +     `(#:jar-name "maven-shared-invoker.jar"
>> +       #:source-dir "src/main/java"
>> +       #:tests? #f))                      ; Tests require Maven
>> itself
>
> How so? Tests are usually just junit tests and it's easy to run them.
> How are they so different from the usual tests?
>
> If it really requires maven, have you tried building it with the
> maven-build-system? There's a way to remove plugins from the pom file,
> so maven doesn't complain. The pom file doesn't look too complex, so I
> think it could work.
>
>> +    (propagated-inputs
>> +     (list maven-parent-pom-35))
>
> Yes you should propagate the parent, but that's only because maven
> needs it when it reads this package's pom file. So, please keep it and
> install this package from its pom file, like the others :)
>
>> +    (native-inputs
>> +     (list unzip
>> +           maven-surefire-plugin
>> +           java-javax-inject
>> +           java-junit))
>
> I'm surprised here you need maven-surefire-plugin. What is it used for
> exactly? From my understanding it can't be called outside of maven, and
> we don't use maven to install this package.
>
> The pom file lists java-javax-inject as a normal dependency, so it
> should be propagated instead. The pom file also lists
> maven-shared-utils. Is it needed? If so please add it to the propagated
> inputs, otherwise fix the pom file (with a patch to upstream I guess).
>
>> +    (home-page
>> "https://maven.apache.org/shared/maven-invoker/index.html")
>> +    (synopsis "Invoke Maven programmatically")
>
>> Sep 17 00:00:00 2001 +From: "Artyom V. Poptsov"
>> <poptsov.artyom@gmail.com> +Date: Tue, 14 Jun 2022 23:53:13 +0300
>> +Subject: [PATCH 1/2] MavenCommandLineBuilder: Fix exception handling
>> +
>> +*
>> src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java
>> +  (setGoals): Catch 'Exception' instead of 'CommandLineException' as
>> +  'CommandLineException' is never thrown in the "try" block.
>> +---
>> + .../apache/maven/shared/invoker/MavenCommandLineBuilder.java    | 2
>> +-
>> + 1 file changed, 1 insertion(+), 1 deletion(-)
>> +
>> +diff --git
>
> This looks like a simple patch, but I don't understand why it's needed.
> Is this a fix from upstream? Did you create it? For what reason?
>
>> @@ -0,0 +1,126 @@ +From 4bce3183b25c44ab406c2f4d8541a0a520b15a3d Mon
>> Sep 17 00:00:00 2001 +From: "Artyom V. Poptsov"
>> <poptsov.artyom@gmail.com> +Date: Wed, 15 Jun 2022 07:09:29 +0300
>> +Subject: [PATCH 2/2] test: Rename some classes to avoid name
>> conflicts +
>> +*
>
> I'm lost. What's happening in this patch? Why do you need it
> (especially since you couldn't run the tests anyway)? Is this a problem
> with upstream, or some issue you encountered because of what Guix is
> doing?




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-04  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-18 14:58 [bug#56054] [PATCH] gnu: Add maven-shared-invoker Artyom V. Poptsov
2022-06-18 19:56 ` Julien Lepiller
2022-08-04  9:11   ` Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.