diff mbox series

[bug#47789,1/6] gnu: Add java-gson-2.8.6.

Message ID 0bb3e905602bcba367d14ad4ff20ef3caa54f72b.1618460450.git.mtg@gnu.org
State Accepted
Headers show
Series Add TLA+ Tools (tla2tools) | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Mike Gerwitz April 15, 2021, 4:25 a.m. UTC
This introduces a new package rather than upgrading the exist java-gson
package because it is built using OpenJDK11; I didn't want to have to
propagate that JDK dependency to the other packages that use it.

OpenJDK 11 was chosen becuase this dependency was introduced for
tla2tools.

* gnu/packages/java.scm (java-gson-2.8.6): New variable.
---
 gnu/packages/java.scm | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

Comments

M April 15, 2021, 8:06 a.m. UTC | #1
On Thu, 2021-04-15 at 00:25 -0400, Mike Gerwitz wrote:
> +           #t)))))

Phases do not need to return #t anymore.  The warning has been removed
on the 'core-updates' branch; we might as well stop introducing these
silly #t now.

Greetings,
Maxime.
Julien Lepiller April 15, 2021, 10:46 a.m. UTC | #2
Le 15 avril 2021 00:25:10 GMT-04:00, Mike Gerwitz <mtg@gnu.org> a écrit :
>This introduces a new package rather than upgrading the exist java-gson
>package because it is built using OpenJDK11; I didn't want to have to
>propagate that JDK dependency to the other packages that use it.
>
>OpenJDK 11 was chosen becuase this dependency was introduced for
>tla2tools.
>
>* gnu/packages/java.scm (java-gson-2.8.6): New variable.
>---
> gnu/packages/java.scm | 43 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
>diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
>index 207f136513..fe75404e9c 100644
>--- a/gnu/packages/java.scm
>+++ b/gnu/packages/java.scm
>@@ -15,6 +15,7 @@
> ;;; Copyright © 2020 Raghav Gururajan <raghavgururajan@disroot.org>
> ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
> ;;; Copyright © 2021 Vincent Legoll <vincent.legoll@gmail.com>
>+;;; Copyright © 2021 Mike Gerwitz <mtg@gnu.org>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
>@@ -11724,6 +11725,48 @@ string to an equivalent Java object.  Gson can
>work with arbitrary Java objects
> including pre-existing objects that you do not have source-code of.")
>     (license license:asl2.0)))
> 
>+;; This requires a different Java version than 2.8.2 above
>+(define-public java-gson-2.8.6
>+  (package
>+    (name "java-gson")
>+    (version "2.8.6")
>+    (source (origin
>+              (method git-fetch)
>+              (uri (git-reference
>+                    (url "https://github.com/google/gson")
>+                    (commit (string-append "gson-parent-" version))))
>+              (file-name (git-file-name name version))
>+              (sha256
>+               (base32
>+               
>"0kk5p3vichdb0ph1lzknrcpbklgnmq455mngmjpxvvj29p3rgpk3"))))
>+    (build-system ant-build-system)
>+    (arguments
>+     `(#:jar-name "gson.jar"
>+       #:jdk ,openjdk11
>+       #:source-dir "gson/src/main/java"
>+       #:test-dir "gson/src/test"
>+       #:phases
>+       (modify-phases %standard-phases
>+         ;; avoid Maven dependency
>+         (add-before 'build 'fill-template
>+           (lambda _
>+             (with-directory-excursion "gson/src/main"
>+               (copy-file
>"java-templates/com/google/gson/internal/GsonBuildConfig.java"
>+                         
>"java/com/google/gson/internal/GsonBuildConfig.java")
>+               (substitute*
>"java/com/google/gson/internal/GsonBuildConfig.java"
>+                 (("\\$\\{project.version\\}") ,version)))
>+           #t)))))
>+    (native-inputs
>+     `(("java-junit" ,java-junit)
>+       ("java-hamcrest-core" ,java-hamcrest-core)))
>+    (home-page "https://github.com/google/gson")
>+    (synopsis "Java serialization/deserialization library from/to
>JSON")
>+    (description "Gson is a Java library that can be used to convert
>Java
>+Objects into their JSON representation.  It can also be used to
>convert a JSON
>+string to an equivalent Java object.  Gson can work with arbitrary
>Java objects
>+including pre-existing objects that you do not have source-code of.")
>+    (license license:asl2.0)))
>+
> (define-public java-hawtjni
>   (package
>     (name "java-hawtjni")

Hi!

I think it would be easier to inherit from the existing package, right? Why do you need this package at all? I know that mixing JDKs can result in errors if you use a dependency that was built with a more recent JDK that what you use for a package, but the other way around should be fine, no?

What error do you get if you use the existing package?
Mike Gerwitz April 16, 2021, 12:27 a.m. UTC | #3
On Thu, Apr 15, 2021 at 06:46:21 -0400, Julien Lepiller wrote:
> I think it would be easier to inherit from the existing package,
> right?

Thanks; a missed refactoring.  I'll send an updated patch.

> do you need this package at all? I know that mixing JDKs can result in
> errors if you use a dependency that was built with a more recent JDK that
> what you use for a package, but the other way around should be fine, no?

I suspect it'd be fine, but tla2tools uses what I assume is a new method
that wasn't in the previous API.

> What error do you get if you use the existing package?

--8<---------------cut here---------------start------------->8---
  [javac] /tmp/guix-build-tla2tools-1.8.0.drv-0/tla2tools-1.8.0-checkout/tlatools/org.lamport.tlatools/src/tlc2/module/Json.java:116: error: cannot find symbol
  [javac]         JsonElement node = JsonParser.parseString(line);
  [javac]                                      ^
--8<---------------cut here---------------end--------------->8---
Mike Gerwitz April 16, 2021, 1:13 a.m. UTC | #4
On Thu, Apr 15, 2021 at 10:06:03 +0200, Maxime Devos wrote:
> On Thu, 2021-04-15 at 00:25 -0400, Mike Gerwitz wrote:
>> +           #t)))))
>
> Phases do not need to return #t anymore.  The warning has been removed
> on the 'core-updates' branch; we might as well stop introducing these
> silly #t now.

Corrected in each patch in the new series.

Thank you for your quick reviews!
diff mbox series

Patch

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 207f136513..fe75404e9c 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -15,6 +15,7 @@ 
 ;;; Copyright © 2020 Raghav Gururajan <raghavgururajan@disroot.org>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Vincent Legoll <vincent.legoll@gmail.com>
+;;; Copyright © 2021 Mike Gerwitz <mtg@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -11724,6 +11725,48 @@  string to an equivalent Java object.  Gson can work with arbitrary Java objects
 including pre-existing objects that you do not have source-code of.")
     (license license:asl2.0)))
 
+;; This requires a different Java version than 2.8.2 above
+(define-public java-gson-2.8.6
+  (package
+    (name "java-gson")
+    (version "2.8.6")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/google/gson")
+                    (commit (string-append "gson-parent-" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0kk5p3vichdb0ph1lzknrcpbklgnmq455mngmjpxvvj29p3rgpk3"))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "gson.jar"
+       #:jdk ,openjdk11
+       #:source-dir "gson/src/main/java"
+       #:test-dir "gson/src/test"
+       #:phases
+       (modify-phases %standard-phases
+         ;; avoid Maven dependency
+         (add-before 'build 'fill-template
+           (lambda _
+             (with-directory-excursion "gson/src/main"
+               (copy-file "java-templates/com/google/gson/internal/GsonBuildConfig.java"
+                          "java/com/google/gson/internal/GsonBuildConfig.java")
+               (substitute* "java/com/google/gson/internal/GsonBuildConfig.java"
+                 (("\\$\\{project.version\\}") ,version)))
+           #t)))))
+    (native-inputs
+     `(("java-junit" ,java-junit)
+       ("java-hamcrest-core" ,java-hamcrest-core)))
+    (home-page "https://github.com/google/gson")
+    (synopsis "Java serialization/deserialization library from/to JSON")
+    (description "Gson is a Java library that can be used to convert Java
+Objects into their JSON representation.  It can also be used to convert a JSON
+string to an equivalent Java object.  Gson can work with arbitrary Java objects
+including pre-existing objects that you do not have source-code of.")
+    (license license:asl2.0)))
+
 (define-public java-hawtjni
   (package
     (name "java-hawtjni")