GNU bug report logs - #47789
[PATCH 0/6] Add TLA+ Tools (tla2tools)

Previous Next

Package: guix-patches;

Reported by: Mike Gerwitz <mtg <at> gnu.org>

Date: Thu, 15 Apr 2021 04:24:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47789 in the body.
You can then email your comments to 47789 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Thu, 15 Apr 2021 04:24:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mike Gerwitz <mtg <at> gnu.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 15 Apr 2021 04:24:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: guix-patches <at> gnu.org
Subject: [PATCH 0/6] Add TLA+ Tools (tla2tools)
Date: Thu, 15 Apr 2021 00:22:03 -0400
[Message part 1 (text/plain, inline)]
This introduces tla2tools.jar, which contains the TLA+ model checker
and simulator (TLC); a TLA+ REPL; a semantic analyzer (SANY); the TLATeX
typesetting system; PlusCal translator; and more.  I have added five
wrapper scripts for convenience, rather than invoking `java' manually.
The wrapper scripts are not comprehensive; users who are familiar with
tla2tools.jar, or have read the book Specifying Systems, may still
invoke the commands in the traditional way.

This was significnatly more involved than I had anticipated, and I was
forced to make some compromises on how I handled dependencies.  Most
notably, rather than packaging the entirety of LSP4J and JLine 3, I packaged
only what tla2tools used, since going all the way would have been a
significant undertaking that I would not have been able to see through.

I have not packaged Java libraries for Guix before (and it's been years
since I packaged anything else), so please be critical and let me know what
I can do better.

I hope to explore packaging TLAPS next.  I don't anticipate packaging the
Toolbox for Guix, which is TLA+'s GUI; there are a huge number of
dependencies.

Enjoy!

Mike Gerwitz (6):
  gnu: Add java-gson-2.8.6.
  gnu: Add java-eclipse-xtext-xbase-lib.
  gnu: Add java-eclipse-lsp4j packages.
  gnu: Add java-jline-terminal.
  gnu: Add java-jline-reader.
  gnu: Add tla2tools.

 gnu/packages/java.scm                         | 410 ++++++++++++++++++
 .../patches/tla2tools-build-xml.patch         | 109 +++++
 2 files changed, 519 insertions(+)
 create mode 100644 gnu/packages/patches/tla2tools-build-xml.patch

-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Thu, 15 Apr 2021 04:29:02 GMT) Full text and rfc822 format available.

Message #8 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 1/6] gnu: Add java-gson-2.8.6.
Date: Thu, 15 Apr 2021 00:25:10 -0400
[Message part 1 (text/plain, inline)]
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 <at> disroot.org>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2021 Vincent Legoll <vincent.legoll <at> gmail.com>
+;;; Copyright © 2021 Mike Gerwitz <mtg <at> 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")
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Thu, 15 Apr 2021 04:29:02 GMT) Full text and rfc822 format available.

Message #11 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 2/6] gnu: Add java-eclipse-xtext-xbase-lib.
Date: Thu, 15 Apr 2021 00:26:28 -0400
[Message part 1 (text/plain, inline)]
This package is a component of xtext-lib.  The rest of xtext-lib was not
added.

* gnu/packages/java.scm (java-eclipse-xtext-xbase-lib): New variable.
---
 gnu/packages/java.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index fe75404e9c..b0e67b2f6e 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -7547,6 +7547,36 @@ means for generating files and compiling new Java classes based on annotations
 found in your source code.")
     (license license:epl2.0)))
 
+(define-public java-eclipse-xtext-xbase-lib
+  (package
+    (name "java-eclipse-xtext-xbase-lib")
+    (version "2.25.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/eclipse/xtext-lib")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "13b9lf6lnsprkik665m1qcyyc8cs16k33xm7as4rjcfcpn4pln71"))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "eclipse-xtext-xbase-lib.jar"
+       #:jdk ,openjdk11
+       #:tests? #f; TODO
+       #:source-dir "org.eclipse.xtext.xbase.lib/src"
+       #:test-dir "org.eclipse.xtext.xbase.lib.tests/src"))
+    (native-inputs
+     `(("java-junit" ,java-junit)))
+    (inputs
+     `(("java-guava" ,java-guava)))
+    (home-page "https://www.eclipse.org/Xtext/")
+    (synopsis "Eclipse Xbase Runtime Library")
+    (description "This package contains runtime libraries for Xbase languages
+such as Xtend.")
+    (license license:epl2.0)))
+
 (define-public java-javax-mail
   (package
     (name "java-javax-mail")
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Thu, 15 Apr 2021 04:29:03 GMT) Full text and rfc822 format available.

Message #14 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 3/6] gnu: Add java-eclipse-lsp4j packages.
Date: Thu, 15 Apr 2021 00:26:41 -0400
[Message part 1 (text/plain, inline)]
All of these packages are components of java-eclipse-lsp4j, packaged
independently.  This contains only what was needed for tla2tools, and so
there are parts of java-eclipse-lsp4j that are not packaged.

Note that this does not package the latest version (0.12.0 at the time
of writing)---it depends on the Xtend language, which is a huge
packaging effort.  0.10.0 is the version expected by tla2tools, for
which this dependency was introduced.

* gnu/packages/java.scm (java-eclipse-lsp4j-common): New variable.
(java-eclipse-lsp4j-jsonrpc): New variable.
(java-eclipse-lsp4j-jsonrpc-debug): New variable.
(java-eclipse-lsp4j-generator): New variable.
(java-eclipse-lsp4j-debug): New variable.
---
 gnu/packages/java.scm | 104 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index b0e67b2f6e..e82e828df0 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -7547,6 +7547,110 @@ means for generating files and compiling new Java classes based on annotations
 found in your source code.")
     (license license:epl2.0)))
 
+(define java-eclipse-lsp4j-common
+  (package
+    (name "java-eclipse-lsp4j-common")
+    (version "0.10.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/eclipse/lsp4j")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "17srrac0pkpybwwc21rzdvn762zzl9m80rlqihc9b4l55hkqpk98"))))
+    (build-system ant-build-system)
+    (home-page "https://eclipse.org/lsp4j/")
+    (synopsis "LSP4J common package")
+    (description "Eclipse LSP4J provides Java bindings for the Language
+Server Protocol and the Debug Adapter Protocol.  This package is a common
+definition intended to be inherited by other packages.")
+    (license license:epl2.0)))
+
+(define-public java-eclipse-lsp4j-debug
+  (package
+    (inherit java-eclipse-lsp4j-common)
+    (name "java-eclipse-lsp4j-debug")
+    (arguments
+     `(#:jar-name "eclipse-lsp4j-debug.jar"
+       #:jdk ,openjdk11
+       #:tests? #f; tests fail obscurely
+       #:source-dir "org.eclipse.lsp4j.debug/src/main/java"
+       #:test-dir "org.eclipse.lsp4j.debug/src/test"
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'copy-xtend
+           (lambda _
+             (copy-recursively "org.eclipse.lsp4j.debug/src/main/xtend-gen"
+                               "org.eclipse.lsp4j.debug/src/main/java")
+             #t)))))
+    (native-inputs
+     `(("java-junit" ,java-junit)))
+    (inputs
+     `(("java-gson" ,java-gson-2.8.6)
+       ("java-eclipse-lsp4j-generaor" ,java-eclipse-lsp4j-generator)
+       ("java-eclipse-lsp4j-jsonrpc" ,java-eclipse-lsp4j-jsonrpc)
+       ("java-eclipse-lsp4j-jsonrpc-debug" ,java-eclipse-lsp4j-jsonrpc-debug)
+       ("java-eclipse-xtext-xbase-lib" ,java-eclipse-xtext-xbase-lib)))
+    (synopsis "Eclipse LSP4J Java bindings for the Debug Server Protocol")
+    (description "Eclipse LSP4J provides Java bindings for the Language
+Server Protocol and the Debug Adapter Protocol.  This package contains its
+LSP4J Java bindings for the Debug Server Protocol.")))
+
+(define-public java-eclipse-lsp4j-generator
+  (package
+    (inherit java-eclipse-lsp4j-common)
+    (name "java-eclipse-lsp4j-generator")
+    (arguments
+     `(#:jar-name "eclipse-lsp4j-generator.jar"
+       #:jdk ,openjdk11
+       #:tests? #f; no tests
+       #:source-dir "org.eclipse.lsp4j.generator/src/main/java"))
+    (inputs
+     `(("java-eclipse-lsp4j-jsonrpc" ,java-eclipse-lsp4j-jsonrpc)))
+    (synopsis "Eclipse LSP4J Generator")
+    (description "Eclipse LSP4J provides Java bindings for the Language
+Server Protocol and the Debug Adapter Protocol.  This package contains its
+LSP4J code generator for Language Server Protocol classes.")))
+
+(define-public java-eclipse-lsp4j-jsonrpc
+  (package
+    (inherit java-eclipse-lsp4j-common)
+    (name "java-eclipse-lsp4j-jsonrpc")
+    (arguments
+     `(#:jar-name "eclipse-lsp4j-jsonrpc.jar"
+       #:jdk ,openjdk11
+       #:source-dir "org.eclipse.lsp4j.jsonrpc/src/main/java"
+       #:test-dir "org.eclipse.lsp4j.jsonrpc/src/test"))
+    (native-inputs
+     `(("java-junit" ,java-junit)))
+    (inputs
+     `(("java-gson" ,java-gson-2.8.6)))
+    (synopsis "Java JSON-RPC implementation")
+    (description "Eclipse LSP4J provides Java bindings for the Language
+Server Protocol and the Debug Adapter Protocol.  This package contains its
+JSON-RPC implementation.")))
+
+(define-public java-eclipse-lsp4j-jsonrpc-debug
+  (package
+    (inherit java-eclipse-lsp4j-common)
+    (name "java-eclipse-lsp4j-jsonrpc-debug")
+    (arguments
+     `(#:jar-name "eclipse-lsp4j-jsonrpc-debug.jar"
+       #:jdk ,openjdk11
+       #:source-dir "org.eclipse.lsp4j.jsonrpc.debug/src/main/java"
+       #:test-dir "org.eclipse.lsp4j.jsonrpc.debug/src/test"))
+    (native-inputs
+     `(("java-junit" ,java-junit)))
+    (inputs
+     `(("java-eclipse-lsp4j-jsonrpc" ,java-eclipse-lsp4j-jsonrpc)
+       ("java-gson" ,java-gson-2.8.6)))
+    (synopsis "Java JSON-RPC implementation (debug protocol)")
+    (description "Eclipse LSP4J provides Java bindings for the Language
+Server Protocol and the Debug Adapter Protocol.  This package contains its
+JSON-RPC implementation's debug protocol.")))
+
 (define-public java-eclipse-xtext-xbase-lib
   (package
     (name "java-eclipse-xtext-xbase-lib")
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Thu, 15 Apr 2021 04:29:03 GMT) Full text and rfc822 format available.

Message #17 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 4/6] gnu: Add java-jline-terminal.
Date: Thu, 15 Apr 2021 00:26:55 -0400
[Message part 1 (text/plain, inline)]
This is part of JLine 3.

I was able to get this working properly under Guix by providing ncurses'
infocmp, as well as ensuring the *.caps files were present in the JAR,
but similar methods didn't work for the tests; if you have Java
knowledge, I'd appreciate the help getting those tests enabled.

* gnu/packages/java.scm (java-jline-terminal): New variable.
---
 gnu/packages/java.scm | 57 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index e82e828df0..aef857661d 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -71,6 +71,7 @@
   #:use-module (gnu packages maths)
   #:use-module (gnu packages maven)
   #:use-module (gnu packages maven-parent-pom)
+  #:use-module (gnu packages ncurses)
   #:use-module (gnu packages nss)
   #:use-module (gnu packages onc-rpc)
   #:use-module (gnu packages web)
@@ -12477,6 +12478,62 @@ features that bring it on par with the Z shell line editor.")
        ("java-junit" ,java-junit)
        ("java-hawtjni" ,java-hawtjni)))))
 
+(define-public java-jline-terminal
+  (package
+    (name "java-jline-terminal")
+    (version "3.14.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/jline/jline3")
+                    (commit (string-append "jline-parent-" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0ilhk9ljp0pivl1rn0bb06syshc67p6imcjhrg6vr7kv15p3w4lr"))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "jline-terminal.jar"
+       #:jdk ,openjdk11
+       #:tests? #f; TODO: tests fail on *.caps resource lookups
+       #:source-dir "terminal/src/main/java"
+       #:test-dir "terminal/src/test"
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'remove-build-file
+           (lambda _
+             ;; Conflicts with build directory generated by ant-build-system.
+             (delete-file "build")
+             #t))
+         (add-after 'unpack 'patch-paths
+           (lambda _
+             (substitute* "terminal/src/main/java/org/jline/utils/OSUtils.java"
+               (("= \"(s?tty|infocmp)\"" _ cmd)
+                (string-append "= \"" (which cmd) "\"")))
+             #t))
+         ;; Resources are not added to the JAR by ant-build-system.
+         (add-after 'build 'add-resources
+           (lambda* (#:key jar-name source-dir #:allow-other-keys)
+             (let ((build (string-append (getcwd) "/build")))
+               (with-directory-excursion
+                   (string-append source-dir "/../resources")
+                 (apply invoke "jar" "-uvf"
+                        (string-append build "/jar/" jar-name)
+                        (find-files "."))))
+             #t)))))
+    (inputs
+     `(("ncurses" ,ncurses))); infocmp
+    (home-page "https://github.com/jline/jline3")
+    (synopsis "Java JLine Terminal API and implementations")
+    (description "JLine is a Java library for handling console input.  It is
+similar in functionality to BSD editline and GNU readline but with additional
+features that bring it in par with ZSH line editor.  People familiar with the
+readline/editline capabilities for modern shells (such as bash and tcsh) will
+find most of the command editing features of JLine to be familiar.
+
+This package includes the @var{Terminal} API and implementations.")
+    (license license:bsd-3)))
+
 (define-public java-xmlunit
   (package
     (name "java-xmlunit")
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Thu, 15 Apr 2021 04:29:03 GMT) Full text and rfc822 format available.

Message #20 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 5/6] gnu: Add java-jline-reader.
Date: Thu, 15 Apr 2021 00:27:11 -0400
[Message part 1 (text/plain, inline)]
This package is part of JLine 3.

* gnu/packages/java.scm (java-jline-reader): New variable.
---
 gnu/packages/java.scm | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index aef857661d..4d6befe511 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -12534,6 +12534,48 @@ find most of the command editing features of JLine to be familiar.
 This package includes the @var{Terminal} API and implementations.")
     (license license:bsd-3)))
 
+(define-public java-jline-reader
+  (package
+    (name "java-jline-reader")
+    (version "3.14.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/jline/jline3")
+                    (commit (string-append "jline-parent-" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0ilhk9ljp0pivl1rn0bb06syshc67p6imcjhrg6vr7kv15p3w4lr"))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "jline-reader.jar"
+       #:jdk ,openjdk11
+       #:source-dir "reader/src/main/java"
+       #:test-dir "reader/src/test"
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'remove-build-file
+           (lambda _
+             ;; conflicts with build directory generated by ant-build-system
+             (delete-file "build")
+             #t)))))
+    (native-inputs
+     `(("java-junit" ,java-junit)
+       ("java-easymock" ,java-easymock)))
+    (inputs
+     `(("java-jline-terminal" ,java-jline-terminal)))
+    (home-page "https://github.com/jline/jline3")
+    (synopsis "Java JLine line reader")
+    (description "JLine is a Java library for handling console input.  It is
+similar in functionality to BSD editline and GNU readline but with additional
+features that bring it in par with ZSH line editor.  People familiar with the
+readline/editline capabilities for modern shells (such as bash and tcsh) will
+find most of the command editing features of JLine to be familiar.
+
+This package includes the line reader.")
+    (license license:bsd-3)))
+
 (define-public java-xmlunit
   (package
     (name "java-xmlunit")
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Thu, 15 Apr 2021 04:29:04 GMT) Full text and rfc822 format available.

Message #23 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 6/6] gnu: Add tla2tools.
Date: Thu, 15 Apr 2021 00:27:27 -0400
[Message part 1 (text/plain, inline)]
This introduces tla2tools.jar, which contains the TLA+ model checker
and simulator (TLC); a TLA+ REPL; a semantic analyzer (SANY); the TLATeX
typesetting system; PlusCal translator; and more.  I have added five
wrapper scripts for convenience, rather than invoking `java' manually.
The wrapper scripts are not comprehensive; users who are familiar with
tla2tools.jar, or have read the book Specifying Systems, may still
invoke the commands in the traditional way.

The minimum JDK version is 11.  I chose to stick with that rather than
bumping it to 14 (which is the largest version currently in Guix)
because each OpenJDK version in Guix depends on the version before it,
and so it needlessly results in many 100s of MiB of unnecessary
dependencies.

Note that this is _not_ the TLA+ Toolbox, which is the GUI commonly used
with TLA+.

* gnu/packages/java.scm (tla2tools): New variable.
* gnu/packages/patches/tla2tools-build-xml.patch: New patch.
---
 gnu/packages/java.scm                         | 134 ++++++++++++++++++
 .../patches/tla2tools-build-xml.patch         | 109 ++++++++++++++
 2 files changed, 243 insertions(+)
 create mode 100644 gnu/packages/patches/tla2tools-build-xml.patch

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 4d6befe511..087f411258 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -14040,3 +14040,137 @@ can be interpreted by IDEs and static analysis tools to improve code analysis.")
                ;; either lgpl or asl
                license:lgpl3+
                license:asl2.0))))
+
+(define-public tla2tools
+  (let* ((version "1.8.0")
+         (tag (string-append "v" version)))
+    (package
+      (name "tla2tools")
+      (version version)
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/tlaplus/tlaplus")
+                      (commit tag)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1503ljw32mbgw1mzkyk31sxdyggli9jf5sa31chfy5g5ccaphz9b"))
+                (patches
+                 (search-patches "tla2tools-build-xml.patch"))
+                (modules '((guix build utils)))
+                (snippet
+                 '(begin
+                    ;; Remove packaged libraries (see 'replace-libs below)
+                    (for-each delete-file (find-files "." ".*.jar$"))
+                    #t))))
+      (build-system ant-build-system)
+      (arguments
+       (let* ((tlatools "tlatools/org.lamport.tlatools/")
+              (build-xml (string-append tlatools "customBuild.xml")))
+         `(#:jdk ,openjdk11
+           #:modules ((guix build ant-build-system)
+                      (guix build utils)
+                      (ice-9 match)
+                      (srfi srfi-26))
+           #:make-flags '("-f" ,build-xml)
+           #:phases
+           (modify-phases %standard-phases
+            ;; Replace packed libs with references to jars in store
+             (add-after 'unpack 'replace-libs
+               (lambda* (#:key inputs #:allow-other-keys)
+                 (define (input-jar input)
+                   (car (find-files (assoc-ref inputs input) "\\.jar$")))
+                 (for-each
+                  (match-lambda
+                    ((file . input)
+                     (symlink (input-jar input)
+                              (string-append ,tlatools "/lib/" file))))
+                  '(("gson/gson-2.8.6.jar" . "java-gson")
+                    ("javax.mail/mailapi-1.6.3.jar" . "java-javax-mail")
+                    ("jline/jline-terminal-3.14.1.jar" . "java-jline-terminal")
+                    ("jline/jline-reader-3.14.1.jar" . "java-jline-reader")
+                    ("lsp/org.eclipse.lsp4j.debug-0.10.0.jar" .
+                     "java-eclipse-lsp4j-debug")
+                    ("lsp/org.eclipse.lsp4j.jsonrpc-0.10.0.jar" .
+                     "java-eclipse-lsp4j-jsonrpc")
+                    ("lsp/org.eclipse.lsp4j.jsonrpc.debug-0.10.0.jar" .
+                     "java-eclipse-lsp4j-jsonrpc-debug")
+                    ("junit-4.12.jar" . "java-junit")
+                    ("easymock-3.3.1.jar" . "java-easymock")))
+                 ;; Retain a tiny subset of the original X-Git-*
+                 ;; manifest values just to aid in debugging
+                 (substitute* ,build-xml
+                   (("\\$\\{git.tag\\}") ,tag))
+                 #t))
+             (add-before 'check 'prepare-tests
+               (lambda _
+                 ;; pcal tests write to cfg files
+                 (for-each (cut chmod <> #o644)
+                           (find-files (string-append ,tlatools
+                                                      "/test-model/pcal")
+                                       "\\.cfg$"))
+                 #t))
+             (replace 'install
+               (lambda _
+                 (let* ((share (string-append %output "/share/java"))
+                        (jar-name "tla2tools.jar"); set in project.properties
+                        (jar (string-append ,tlatools
+                                            "/dist/" jar-name))
+                        (java-cp (string-append share "/" jar-name))
+                        (bin (string-append %output "/bin")))
+                   (install-file jar share)
+                   (mkdir-p bin)
+                   ;; Generate wrapper scripts for bin/, which invoke common
+                   ;; commands within tla2tools.jar.  Users can still invoke
+                   ;; tla2tools.jar for the rest.
+                   (for-each
+                    (match-lambda
+                      ((wrapper . class)
+                       (let ((file (string-append bin "/" wrapper)))
+                         (begin
+                           (with-output-to-file file
+                             (lambda _
+                               (display
+                                (string-append
+                                 "#!" (which "sh") "\n"
+                                 "java -cp " java-cp " " class " \"$@\""))))
+                           (chmod file #o755)))))
+                    ;; bin/wrapper . java-class
+                    '(("pcal" . "pcal.trans")
+                      ("tlatex" . "tla2tex.TLA")
+                      ("tla2sany" . "tla2sany.SANY")
+                      ("tlc2" . "tlc2.TLC")
+                      ("tlc2-repl" . "tlc2.REPL"))))
+                 #t))))))
+      (native-inputs
+       `(("java-junit" ,java-junit)
+         ("java-easymock" ,java-easymock)))
+      (inputs
+       `(("java-javax-mail" ,java-javax-mail)
+         ("java-gson" ,java-gson-2.8.6)
+         ("java-jline-terminal" ,java-jline-terminal)
+         ("java-jline-reader" ,java-jline-reader)
+         ("java-eclipse-lsp4j-jsonrpc" ,java-eclipse-lsp4j-jsonrpc)
+         ("java-eclipse-lsp4j-jsonrpc-debug" ,java-eclipse-lsp4j-jsonrpc-debug)
+         ("java-eclipse-lsp4j-debug" ,java-eclipse-lsp4j-debug)))
+      (home-page "https://lamport.azurewebsites.net/tla/tools.html")
+      (synopsis "TLA+ tools (analyzer, TLC, TLATeX, PlusCal translator)")
+      (description "TLA+ is a high-level language for modeling programs and
+systems---especially concurrent and distributed ones.  It's based on the idea
+that the best way to describe things precisely is with simple
+mathematics.  TLA+ and its tools are useful for eliminating fundamental design
+errors, which are hard to find and expensive to correct in code.
+
+The following TLA+ tools are available in this distribution:
+
+@itemize
+@item The Syntactic Analyzer: A parser and syntax checker for
+  TLA+ specifications;
+@item TLC: A model checker and simulator for a subclass of \"executable\" TLA+
+  specifications;
+@item TLATeX: A program for typesetting TLA+ specifications;
+@item Beta test versions of 1-3 for the TLA+2 language; and
+@item The PlusCal translator.
+@end itemize")
+      (license license:expat))))
diff --git a/gnu/packages/patches/tla2tools-build-xml.patch b/gnu/packages/patches/tla2tools-build-xml.patch
new file mode 100644
index 0000000000..0bba82072a
--- /dev/null
+++ b/gnu/packages/patches/tla2tools-build-xml.patch
@@ -0,0 +1,109 @@
+tla2tools comes packaged with three separate javax.mail JARs, which it
+expects to be available to include in the JAR produced by the `dist' target.
+However, the `java-javax-mail' packaged with Guix contains all of these
+dependencies in a single JAR, so the other two are unneeded.  This patch
+removes references to them.
+
+The JAR also was expected to contain classes that are built as part of the
+test suite.  That does not seem useful, nor is it available during the
+`compile' phase, so that portion is removed.
+
+There are a number of Git attributes that are set in the final manifest.
+The branch name is kept, but the others are removed.  The build user is set
+statically to "guix".
+
+Finally, since we already have a patch, two targets `jar' and `check' are
+added to satisfy `ant-build-system' and keep the package definition more
+lean.
+
+diff --git a/tlatools/org.lamport.tlatools/customBuild.xml b/tlatools/org.lamport.tlatools/customBuild.xml
+index f0ba77cb7..748e60d95 100644
+--- a/tlatools/org.lamport.tlatools/customBuild.xml
++++ b/tlatools/org.lamport.tlatools/customBuild.xml
+@@ -36,6 +36,17 @@
+ 		<istrue value="${maven.test.halt}"/>
+ 	</condition>
+ 
++  <!-- `jar' and `check' added for Guix -->
++  <target name="jar">
++		<antcall target="compile" inheritall="true" inheritrefs="true" />
++		<antcall target="compile-aj" inheritall="true" inheritrefs="true" />
++		<antcall target="dist" inheritall="true" inheritrefs="true" />
++  </target>
++  <target name="check">
++		<antcall target="compile-test" inheritall="true" inheritrefs="true" />
++		<antcall target="test" inheritall="true" inheritrefs="true" />
++  </target>
++
+ 	<!-- https://github.com/alx3apps/jgit-buildnumber -->
+ 	<target name="git-revision">
+ 	    <taskdef name="jgit-buildnumber" classname="ru.concerteza.util.buildnumber.JGitBuildNumberAntTask">
+@@ -217,17 +228,7 @@
+ 				<exclude name="javax/mail/search/**"/>
+ 			</patternset>
+ 		</unzip>
+-		<unzip src="lib/javax.mail/smtp-1.6.3.jar" dest="${class.dir}">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-			</patternset>
+-		</unzip>
+-		<unzip src="lib/javax.mail/javax.activation_1.1.0.v201211130549.jar" dest="${class.dir}">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-				<exclude name="org/**"/>
+-			</patternset>
+-		</unzip>
++		<mkdir dir="${class.dir}/META-INF" />
+ 		<touch file="${class.dir}/META-INF/javamail.default.address.map"/>
+ 		<unzip src="lib/jline/jline-terminal-3.14.1.jar" dest="${class.dir}">
+ 			<patternset>
+@@ -259,17 +260,7 @@
+ 				<exclude name="javax/mail/search/**"/>
+ 			</patternset>
+ 		</unzip>
+-		<unzip src="lib/javax.mail/smtp-1.6.3.jar" dest="target/classes">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-			</patternset>
+-		</unzip>
+-		<unzip src="lib/javax.mail/javax.activation_1.1.0.v201211130549.jar" dest="target/classes">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-				<exclude name="org/**"/>
+-			</patternset>
+-		</unzip>
++		<mkdir dir="target/classes/META-INF" />
+ 		<touch file="target/classes/META-INF/javamail.default.address.map"/>
+ 
+ 		<unzip src="lib/jline/jline-terminal-3.14.1.jar" dest="target/classes">
+@@ -373,14 +364,8 @@
+ 					src/tla2sany/parser/Token.09-09-07,
+ 					src/tla2sany/parser/TokenMgrError.09-09-07"/>
+ 			<fileset dir="${doc.dir}" includes="License.txt"/>
+-			<fileset dir="${test.class.dir}">
+-				<include name="**/tlc2/tool/CommonTestCase*.class" />
+-				<include name="**/tlc2/tool/liveness/ModelCheckerTestCase*.class" />
+-				<include name="**/tlc2/TestMPRecorder*.class" />
+-				<include name="**/util/IsolatedTestCaseRunner*.class" />
+-			</fileset>
+ 			<manifest>
+-				<attribute name="Built-By" value="${user.name}" />
++				<attribute name="Built-By" value="guix" />
+ 				<attribute name="Build-Tag" value="${env.BUILD_TAG}" />
+ 				<attribute name="Build-Rev" value="${Build-Rev}" />
+ 				<attribute name="Implementation-Title" value="TLA+ Tools" />
+@@ -389,14 +374,8 @@
+ 				<!-- The jar files contains many main classes (SANY, TEX, pcal, ...) --> 
+                 <!-- but lets consider TLC the one users primarily use. --> 
+ 				<attribute name="Main-class" value="tlc2.TLC" />
+-				<attribute name="Class-Path" value="CommunityModules-deps.jar CommunityModules.jar" />
+ 				<!-- Git revision -->
+-				<attribute name="X-Git-Branch" value="${git.branch}" />
+ 				<attribute name="X-Git-Tag" value="${git.tag}" />
+-				<attribute name="X-Git-Revision" value="${git.revision}" />
+-				<attribute name="X-Git-ShortRevision" value="${git.shortRevision}" />
+-				<attribute name="X-Git-BuildNumber" value="${git.branch}_${git.tag}_${git.shortRevision}" />
+-				<attribute name="X-Git-Commits-Count" value="${git.commitsCount}" />
+ 				<!-- App-Name and Permissions is required by Java Webstart used by distributed TLC -->
+ 				<!-- Depending on security level, the user will see a warning otherwise. -->
+ 				<!-- http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/security/manifest.html -->
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Thu, 15 Apr 2021 08:07:01 GMT) Full text and rfc822 format available.

Message #26 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Mike Gerwitz <mtg <at> gnu.org>, 47789 <at> debbugs.gnu.org
Subject: Re: [bug#47789] [PATCH 1/6] gnu: Add java-gson-2.8.6.
Date: Thu, 15 Apr 2021 10:06:03 +0200
[Message part 1 (text/plain, inline)]
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.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Thu, 15 Apr 2021 08:14:02 GMT) Full text and rfc822 format available.

Message #29 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Mike Gerwitz <mtg <at> gnu.org>, 47789 <at> debbugs.gnu.org
Subject: Re: [bug#47789] [PATCH 4/6] gnu: Add java-jline-terminal.
Date: Thu, 15 Apr 2021 10:13:03 +0200
[Message part 1 (text/plain, inline)]
On Thu, 2021-04-15 at 00:26 -0400, Mike Gerwitz wrote:
> +         (add-after 'unpack 'patch-paths
> +           (lambda _
> +             (substitute* "terminal/src/main/java/org/jline/utils/OSUtils.java"
> +               (("= \"(s?tty|infocmp)\"" _ cmd)
> +                (string-append "= \"" (which cmd) "\"")))

(which cmd) is most likely incorrect when cross-compiling,
as when cross-compiling, only the inputs in "native-inputs" contribute
towards PATH, and "inputs" does not contribute towards PATH (IIUC).

You will need something like
(lambda* (#:key inputs #:allow-other-keys)
  ...
  ... (string-append "= \"" (assoc-ref "ncurses" inputs) "/bin/ncurses")
  ... (string-append "= \"" (assoc-ref "ncurses" inputs) "/bin/stty")
  ... (string-append "= \"" (assoc-ref "ncurses" inputs) "/bin/tty")
  ...)

(TODO to self: define a variant which/target which looks at the build inputs
instead of native-inputs when cross-compiling.) 

Greetings,
Maxime.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Thu, 15 Apr 2021 08:18:01 GMT) Full text and rfc822 format available.

Message #32 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Mike Gerwitz <mtg <at> gnu.org>, 47789 <at> debbugs.gnu.org
Subject: Re: [bug#47789] [PATCH 6/6] gnu: Add tla2tools.
Date: Thu, 15 Apr 2021 10:17:09 +0200
[Message part 1 (text/plain, inline)]
On Thu, 2021-04-15 at 00:27 -0400, Mike Gerwitz wrote:
> +                                 "#!" (which "sh") "\n"
Most likely incorrect when cross-compiling, as noted in a previous
patch.

+                                 "java -cp " java-cp " " class " \"$@\""))))

Shouldn't this be "OPENJDK-11-FILENAME/bin/java ..."?

Greetings,
Maxime.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Thu, 15 Apr 2021 10:47:02 GMT) Full text and rfc822 format available.

Message #35 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: Mike Gerwitz <mtg <at> gnu.org>,47789 <at> debbugs.gnu.org
Subject: Re: [bug#47789] [PATCH 1/6] gnu: Add java-gson-2.8.6.
Date: Thu, 15 Apr 2021 06:46:21 -0400
Le 15 avril 2021 00:25:10 GMT-04:00, Mike Gerwitz <mtg <at> 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 <at> disroot.org>
> ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
> ;;; Copyright © 2021 Vincent Legoll <vincent.legoll <at> gmail.com>
>+;;; Copyright © 2021 Mike Gerwitz <mtg <at> 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?




Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:26:01 GMT) Full text and rfc822 format available.

Message #38 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: Julien Lepiller <julien <at> lepiller.eu>
Cc: 47789 <at> debbugs.gnu.org
Subject: Re: [bug#47789] [PATCH 1/6] gnu: Add java-gson-2.8.6.
Date: Thu, 15 Apr 2021 20:27:38 -0400
[Message part 1 (text/plain, inline)]
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
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:26:02 GMT) Full text and rfc822 format available.

Message #41 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: Maxime Devos <maximedevos <at> telenet.be>
Cc: 47789 <at> debbugs.gnu.org
Subject: Re: [bug#47789] [PATCH 4/6] gnu: Add java-jline-terminal.
Date: Thu, 15 Apr 2021 20:55:54 -0400
[Message part 1 (text/plain, inline)]
On Thu, Apr 15, 2021 at 10:13:03 +0200, Maxime Devos wrote:
> On Thu, 2021-04-15 at 00:26 -0400, Mike Gerwitz wrote:
>> +         (add-after 'unpack 'patch-paths
>> +           (lambda _
>> +             (substitute* "terminal/src/main/java/org/jline/utils/OSUtils.java"
>> +               (("= \"(s?tty|infocmp)\"" _ cmd)
>> +                (string-append "= \"" (which cmd) "\"")))
>
> (which cmd) is most likely incorrect when cross-compiling,
> as when cross-compiling, only the inputs in "native-inputs" contribute
> towards PATH, and "inputs" does not contribute towards PATH (IIUC).
>
> You will need something like
> (lambda* (#:key inputs #:allow-other-keys)
>   ...
>   ... (string-append "= \"" (assoc-ref "ncurses" inputs) "/bin/ncurses")

Thanks.  There are some other Java packages that do this as well.  I'll
include these changes in the new series.

> (TODO to self: define a variant which/target which looks at the build inputs
> instead of native-inputs when cross-compiling.) 

+1

-- 
Mike Gerwitz
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:27:01 GMT) Full text and rfc822 format available.

Message #44 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: Maxime Devos <maximedevos <at> telenet.be>
Cc: 47789 <at> debbugs.gnu.org
Subject: Re: [bug#47789] [PATCH 6/6] gnu: Add tla2tools.
Date: Thu, 15 Apr 2021 20:57:06 -0400
[Message part 1 (text/plain, inline)]
On Thu, Apr 15, 2021 at 10:17:09 +0200, Maxime Devos wrote:
> On Thu, 2021-04-15 at 00:27 -0400, Mike Gerwitz wrote:
>> +                                 "#!" (which "sh") "\n"
> Most likely incorrect when cross-compiling, as noted in a previous
> patch.
>
> +                                 "java -cp " java-cp " " class " \"$@\""))))
>
> Shouldn't this be "OPENJDK-11-FILENAME/bin/java ..."?

Indeed it should!  Thanks.  Fixed in the new series.

-- 
Mike Gerwitz
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:27:02 GMT) Full text and rfc822 format available.

Message #47 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: Maxime Devos <maximedevos <at> telenet.be>
Cc: 47789 <at> debbugs.gnu.org
Subject: Re: [bug#47789] [PATCH 6/6] gnu: Add tla2tools.
Date: Thu, 15 Apr 2021 21:12:15 -0400
[Message part 1 (text/plain, inline)]
On Thu, Apr 15, 2021 at 10:17:09 +0200, Maxime Devos wrote:
> On Thu, 2021-04-15 at 00:27 -0400, Mike Gerwitz wrote:
>> +                                 "#!" (which "sh") "\n"
> Most likely incorrect when cross-compiling, as noted in a previous
> patch.

I ended up using "/bin/sh" in the new series because the
'patch-source-shebangs phase that runs as part of the build system
automatically fixes it for me.  Please lmk if that's not okay.

Using `(assoc-ref inputs "bash-minimal")' feels wrong to me since that
makes assumptions about the underlying dependencies, but I'll leave that
decision to you.  (It didn't seem to work when I tried it, but I could
try again.)

-- 
Mike Gerwitz
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:27:02 GMT) Full text and rfc822 format available.

Message #50 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: Maxime Devos <maximedevos <at> telenet.be>
Cc: 47789 <at> debbugs.gnu.org
Subject: Re: [bug#47789] [PATCH 1/6] gnu: Add java-gson-2.8.6.
Date: Thu, 15 Apr 2021 21:13:08 -0400
[Message part 1 (text/plain, inline)]
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!

-- 
Mike Gerwitz
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:27:03 GMT) Full text and rfc822 format available.

Message #53 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 1/6] gnu: Add java-gson-2.8.6.
Date: Thu, 15 Apr 2021 21:23:42 -0400
[Message part 1 (text/plain, inline)]
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 | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 207f136513..62f684a74c 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -15,6 +15,7 @@
 ;;; Copyright © 2020 Raghav Gururajan <raghavgururajan <at> disroot.org>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2021 Vincent Legoll <vincent.legoll <at> gmail.com>
+;;; Copyright © 2021 Mike Gerwitz <mtg <at> gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -11724,6 +11725,37 @@ 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
+    (inherit java-gson)
+    (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"))))
+    (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))))))))))
+
 (define-public java-hawtjni
   (package
     (name "java-hawtjni")
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:27:03 GMT) Full text and rfc822 format available.

Message #56 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 2/6] gnu: Add java-eclipse-xtext-xbase-lib.
Date: Thu, 15 Apr 2021 21:23:53 -0400
[Message part 1 (text/plain, inline)]
This package is a component of xtext-lib.  The rest of xtext-lib was not
added.

* gnu/packages/java.scm (java-eclipse-xtext-xbase-lib): New variable.
---
 gnu/packages/java.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 62f684a74c..4a80fef04f 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -7547,6 +7547,36 @@ means for generating files and compiling new Java classes based on annotations
 found in your source code.")
     (license license:epl2.0)))
 
+(define-public java-eclipse-xtext-xbase-lib
+  (package
+    (name "java-eclipse-xtext-xbase-lib")
+    (version "2.25.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/eclipse/xtext-lib")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "13b9lf6lnsprkik665m1qcyyc8cs16k33xm7as4rjcfcpn4pln71"))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "eclipse-xtext-xbase-lib.jar"
+       #:jdk ,openjdk11
+       #:tests? #f; TODO (maybe needs newer guava version?)
+       #:source-dir "org.eclipse.xtext.xbase.lib/src"
+       #:test-dir "org.eclipse.xtext.xbase.lib.tests/src"))
+    (native-inputs
+     `(("java-junit" ,java-junit)))
+    (inputs
+     `(("java-guava" ,java-guava)))
+    (home-page "https://www.eclipse.org/Xtext/")
+    (synopsis "Eclipse Xbase Runtime Library")
+    (description "This package contains runtime libraries for Xbase languages
+such as Xtend.")
+    (license license:epl2.0)))
+
 (define-public java-javax-mail
   (package
     (name "java-javax-mail")
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:27:03 GMT) Full text and rfc822 format available.

Message #59 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 3/6] gnu: Add java-eclipse-lsp4j packages.
Date: Thu, 15 Apr 2021 21:24:04 -0400
[Message part 1 (text/plain, inline)]
All of these packages are components of java-eclipse-lsp4j, packaged
independently.  This contains only what was needed for tla2tools, and so
there are parts of java-eclipse-lsp4j that are not packaged.

Note that this does not package the latest version (0.12.0 at the time
of writing)---it depends on the Xtend language, which is a huge
packaging effort.  0.10.0 is the version expected by tla2tools, for
which this dependency was introduced.

* gnu/packages/java.scm (java-eclipse-lsp4j-common): New variable.
(java-eclipse-lsp4j-jsonrpc): New variable.
(java-eclipse-lsp4j-jsonrpc-debug): New variable.
(java-eclipse-lsp4j-generator): New variable.
(java-eclipse-lsp4j-debug): New variable.
---
 gnu/packages/java.scm | 103 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 4a80fef04f..b4e4cafddb 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -7547,6 +7547,109 @@ means for generating files and compiling new Java classes based on annotations
 found in your source code.")
     (license license:epl2.0)))
 
+(define java-eclipse-lsp4j-common
+  (package
+    (name "java-eclipse-lsp4j-common")
+    (version "0.10.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/eclipse/lsp4j")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "17srrac0pkpybwwc21rzdvn762zzl9m80rlqihc9b4l55hkqpk98"))))
+    (build-system ant-build-system)
+    (home-page "https://eclipse.org/lsp4j/")
+    (synopsis "LSP4J common package")
+    (description "Eclipse LSP4J provides Java bindings for the Language
+Server Protocol and the Debug Adapter Protocol.  This package is a common
+definition intended to be inherited by other packages.")
+    (license license:epl2.0)))
+
+(define-public java-eclipse-lsp4j-debug
+  (package
+    (inherit java-eclipse-lsp4j-common)
+    (name "java-eclipse-lsp4j-debug")
+    (arguments
+     `(#:jar-name "eclipse-lsp4j-debug.jar"
+       #:jdk ,openjdk11
+       #:tests? #f; tests fail with reflection errors
+       #:source-dir "org.eclipse.lsp4j.debug/src/main/java"
+       #:test-dir "org.eclipse.lsp4j.debug/src/test"
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'copy-xtend
+           (lambda _
+             (copy-recursively "org.eclipse.lsp4j.debug/src/main/xtend-gen"
+                               "org.eclipse.lsp4j.debug/src/main/java"))))))
+    (native-inputs
+     `(("java-junit" ,java-junit)))
+    (inputs
+     `(("java-gson" ,java-gson-2.8.6)
+       ("java-eclipse-lsp4j-generaor" ,java-eclipse-lsp4j-generator)
+       ("java-eclipse-lsp4j-jsonrpc" ,java-eclipse-lsp4j-jsonrpc)
+       ("java-eclipse-lsp4j-jsonrpc-debug" ,java-eclipse-lsp4j-jsonrpc-debug)
+       ("java-eclipse-xtext-xbase-lib" ,java-eclipse-xtext-xbase-lib)))
+    (synopsis "Eclipse LSP4J Java bindings for the Debug Server Protocol")
+    (description "Eclipse LSP4J provides Java bindings for the Language
+Server Protocol and the Debug Adapter Protocol.  This package contains its
+LSP4J Java bindings for the Debug Server Protocol.")))
+
+(define-public java-eclipse-lsp4j-generator
+  (package
+    (inherit java-eclipse-lsp4j-common)
+    (name "java-eclipse-lsp4j-generator")
+    (arguments
+     `(#:jar-name "eclipse-lsp4j-generator.jar"
+       #:jdk ,openjdk11
+       #:tests? #f; no tests
+       #:source-dir "org.eclipse.lsp4j.generator/src/main/java"))
+    (inputs
+     `(("java-eclipse-lsp4j-jsonrpc" ,java-eclipse-lsp4j-jsonrpc)))
+    (synopsis "Eclipse LSP4J Generator")
+    (description "Eclipse LSP4J provides Java bindings for the Language
+Server Protocol and the Debug Adapter Protocol.  This package contains its
+LSP4J code generator for Language Server Protocol classes.")))
+
+(define-public java-eclipse-lsp4j-jsonrpc
+  (package
+    (inherit java-eclipse-lsp4j-common)
+    (name "java-eclipse-lsp4j-jsonrpc")
+    (arguments
+     `(#:jar-name "eclipse-lsp4j-jsonrpc.jar"
+       #:jdk ,openjdk11
+       #:source-dir "org.eclipse.lsp4j.jsonrpc/src/main/java"
+       #:test-dir "org.eclipse.lsp4j.jsonrpc/src/test"))
+    (native-inputs
+     `(("java-junit" ,java-junit)))
+    (inputs
+     `(("java-gson" ,java-gson-2.8.6)))
+    (synopsis "Java JSON-RPC implementation")
+    (description "Eclipse LSP4J provides Java bindings for the Language
+Server Protocol and the Debug Adapter Protocol.  This package contains its
+JSON-RPC implementation.")))
+
+(define-public java-eclipse-lsp4j-jsonrpc-debug
+  (package
+    (inherit java-eclipse-lsp4j-common)
+    (name "java-eclipse-lsp4j-jsonrpc-debug")
+    (arguments
+     `(#:jar-name "eclipse-lsp4j-jsonrpc-debug.jar"
+       #:jdk ,openjdk11
+       #:source-dir "org.eclipse.lsp4j.jsonrpc.debug/src/main/java"
+       #:test-dir "org.eclipse.lsp4j.jsonrpc.debug/src/test"))
+    (native-inputs
+     `(("java-junit" ,java-junit)))
+    (inputs
+     `(("java-eclipse-lsp4j-jsonrpc" ,java-eclipse-lsp4j-jsonrpc)
+       ("java-gson" ,java-gson-2.8.6)))
+    (synopsis "Java JSON-RPC implementation (debug protocol)")
+    (description "Eclipse LSP4J provides Java bindings for the Language
+Server Protocol and the Debug Adapter Protocol.  This package contains its
+JSON-RPC implementation's debug protocol.")))
+
 (define-public java-eclipse-xtext-xbase-lib
   (package
     (name "java-eclipse-xtext-xbase-lib")
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:27:04 GMT) Full text and rfc822 format available.

Message #62 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 4/6] gnu: Add java-jline-terminal.
Date: Thu, 15 Apr 2021 21:24:15 -0400
[Message part 1 (text/plain, inline)]
This is part of JLine 3.

I was able to get this working properly under Guix by providing ncurses'
infocmp, as well as ensuring the *.caps files were present in the JAR,
but similar methods didn't work for the tests; if you have Java
knowledge, I'd appreciate the help getting those tests enabled.

* gnu/packages/java.scm (java-jline-terminal): New variable.
---
 gnu/packages/java.scm | 58 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index b4e4cafddb..9bf26b1dc7 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -71,6 +71,7 @@
   #:use-module (gnu packages maths)
   #:use-module (gnu packages maven)
   #:use-module (gnu packages maven-parent-pom)
+  #:use-module (gnu packages ncurses)
   #:use-module (gnu packages nss)
   #:use-module (gnu packages onc-rpc)
   #:use-module (gnu packages web)
@@ -12465,6 +12466,63 @@ features that bring it on par with the Z shell line editor.")
        ("java-junit" ,java-junit)
        ("java-hawtjni" ,java-hawtjni)))))
 
+(define-public java-jline-terminal
+  (package
+    (name "java-jline-terminal")
+    (version "3.14.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/jline/jline3")
+                    (commit (string-append "jline-parent-" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0ilhk9ljp0pivl1rn0bb06syshc67p6imcjhrg6vr7kv15p3w4lr"))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "jline-terminal.jar"
+       #:jdk ,openjdk11
+       #:tests? #f; TODO: tests fail on *.caps resource lookups
+       #:source-dir "terminal/src/main/java"
+       #:test-dir "terminal/src/test"
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'remove-build-file
+           (lambda _
+             ;; Conflicts with build directory generated by ant-build-system.
+             (delete-file "build")))
+         (add-after 'unpack 'patch-paths
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "terminal/src/main/java/org/jline/utils/OSUtils.java"
+               (("= \"infocmp\"")
+                (string-append "= \"" (assoc-ref inputs "ncurses")
+                               "/bin/infocmp\""))
+               (("= \"(s?tty)\"" _ cmd)
+                (string-append "= \"" (assoc-ref inputs "coreutils")
+                               "/bin/" cmd "\"")))))
+         ;; Resources are not added to the JAR by ant-build-system.
+         (add-after 'build 'add-resources
+           (lambda* (#:key jar-name source-dir #:allow-other-keys)
+             (let ((build (string-append (getcwd) "/build")))
+               (with-directory-excursion
+                   (string-append source-dir "/../resources")
+                 (apply invoke "jar" "-uvf"
+                        (string-append build "/jar/" jar-name)
+                        (find-files ".")))))))))
+    (inputs
+     `(("ncurses" ,ncurses))); infocmp
+    (home-page "https://github.com/jline/jline3")
+    (synopsis "Java JLine Terminal API and implementations")
+    (description "JLine is a Java library for handling console input.  It is
+similar in functionality to BSD editline and GNU readline but with additional
+features that bring it in par with ZSH line editor.  People familiar with the
+readline/editline capabilities for modern shells (such as bash and tcsh) will
+find most of the command editing features of JLine to be familiar.
+
+This package includes the @var{Terminal} API and implementations.")
+    (license license:bsd-3)))
+
 (define-public java-xmlunit
   (package
     (name "java-xmlunit")
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:28:01 GMT) Full text and rfc822 format available.

Message #65 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 5/6] gnu: Add java-jline-reader.
Date: Thu, 15 Apr 2021 21:24:26 -0400
[Message part 1 (text/plain, inline)]
This package is part of JLine 3.

* gnu/packages/java.scm (java-jline-reader): New variable.
---
 gnu/packages/java.scm | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 9bf26b1dc7..a474c40ebb 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -12523,6 +12523,47 @@ find most of the command editing features of JLine to be familiar.
 This package includes the @var{Terminal} API and implementations.")
     (license license:bsd-3)))
 
+(define-public java-jline-reader
+  (package
+    (name "java-jline-reader")
+    (version "3.14.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/jline/jline3")
+                    (commit (string-append "jline-parent-" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0ilhk9ljp0pivl1rn0bb06syshc67p6imcjhrg6vr7kv15p3w4lr"))))
+    (build-system ant-build-system)
+    (arguments
+     `(#:jar-name "jline-reader.jar"
+       #:jdk ,openjdk11
+       #:source-dir "reader/src/main/java"
+       #:test-dir "reader/src/test"
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'remove-build-file
+           (lambda _
+             ;; conflicts with build directory generated by ant-build-system
+             (delete-file "build"))))))
+    (native-inputs
+     `(("java-junit" ,java-junit)
+       ("java-easymock" ,java-easymock)))
+    (inputs
+     `(("java-jline-terminal" ,java-jline-terminal)))
+    (home-page "https://github.com/jline/jline3")
+    (synopsis "Java JLine line reader")
+    (description "JLine is a Java library for handling console input.  It is
+similar in functionality to BSD editline and GNU readline but with additional
+features that bring it in par with ZSH line editor.  People familiar with the
+readline/editline capabilities for modern shells (such as bash and tcsh) will
+find most of the command editing features of JLine to be familiar.
+
+This package includes the line reader.")
+    (license license:bsd-3)))
+
 (define-public java-xmlunit
   (package
     (name "java-xmlunit")
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:28:02 GMT) Full text and rfc822 format available.

Message #68 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: [PATCH 6/6] gnu: Add tla2tools.
Date: Thu, 15 Apr 2021 21:24:39 -0400
[Message part 1 (text/plain, inline)]
This introduces tla2tools.jar, which contains the TLA+ model checker
and simulator (TLC); a TLA+ REPL; a semantic analyzer (SANY); the TLATeX
typesetting system; PlusCal translator; and more.  I have added five
wrapper scripts for convenience, rather than invoking `java' manually.
The wrapper scripts are not comprehensive; users who are familiar with
tla2tools.jar, or have read the book Specifying Systems, may still
invoke the commands in the traditional way.

The minimum JDK version is 11.  I chose to stick with that rather than
bumping it to 14 (which is the largest version currently in Guix)
because each OpenJDK version in Guix depends on the version before it,
and so it needlessly results in many 100s of MiB of unnecessary
dependencies.

Note that this is _not_ the TLA+ Toolbox, which is the GUI commonly used
with TLA+.

* gnu/packages/java.scm (tla2tools): New variable.
* gnu/packages/patches/tla2tools-build-xml.patch: New patch.
---
 gnu/packages/java.scm                         | 132 ++++++++++++++++++
 .../patches/tla2tools-build-xml.patch         | 109 +++++++++++++++
 2 files changed, 241 insertions(+)
 create mode 100644 gnu/packages/patches/tla2tools-build-xml.patch

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index a474c40ebb..12e3577ca4 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -14028,3 +14028,135 @@ can be interpreted by IDEs and static analysis tools to improve code analysis.")
                ;; either lgpl or asl
                license:lgpl3+
                license:asl2.0))))
+
+(define-public tla2tools
+  (let* ((version "1.8.0")
+         (tag (string-append "v" version)))
+    (package
+      (name "tla2tools")
+      (version version)
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/tlaplus/tlaplus")
+                      (commit tag)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1503ljw32mbgw1mzkyk31sxdyggli9jf5sa31chfy5g5ccaphz9b"))
+                (patches
+                 (search-patches "tla2tools-build-xml.patch"))
+                (modules '((guix build utils)))
+                (snippet
+                 '(begin
+                    ;; Remove packaged libraries (see 'replace-libs below)
+                    (for-each delete-file (find-files "." ".*.jar$"))))))
+      (build-system ant-build-system)
+      (arguments
+       (let* ((tlatools "tlatools/org.lamport.tlatools/")
+              (build-xml (string-append tlatools "customBuild.xml")))
+         `(#:jdk ,openjdk11
+           #:modules ((guix build ant-build-system)
+                      (guix build utils)
+                      (ice-9 match)
+                      (srfi srfi-26))
+           #:make-flags '("-f" ,build-xml)
+           #:phases
+           (modify-phases %standard-phases
+            ;; Replace packed libs with references to jars in store
+             (add-after 'unpack 'replace-libs
+               (lambda* (#:key inputs #:allow-other-keys)
+                 (define (input-jar input)
+                   (car (find-files (assoc-ref inputs input) "\\.jar$")))
+                 (for-each
+                  (match-lambda
+                    ((file . input)
+                     (symlink (input-jar input)
+                              (string-append ,tlatools "/lib/" file))))
+                  '(("gson/gson-2.8.6.jar" . "java-gson")
+                    ("javax.mail/mailapi-1.6.3.jar" . "java-javax-mail")
+                    ("jline/jline-terminal-3.14.1.jar" . "java-jline-terminal")
+                    ("jline/jline-reader-3.14.1.jar" . "java-jline-reader")
+                    ("lsp/org.eclipse.lsp4j.debug-0.10.0.jar" .
+                     "java-eclipse-lsp4j-debug")
+                    ("lsp/org.eclipse.lsp4j.jsonrpc-0.10.0.jar" .
+                     "java-eclipse-lsp4j-jsonrpc")
+                    ("lsp/org.eclipse.lsp4j.jsonrpc.debug-0.10.0.jar" .
+                     "java-eclipse-lsp4j-jsonrpc-debug")
+                    ("junit-4.12.jar" . "java-junit")
+                    ("easymock-3.3.1.jar" . "java-easymock")))
+                 ;; Retain a tiny subset of the original X-Git-*
+                 ;; manifest values just to aid in debugging
+                 (substitute* ,build-xml
+                   (("\\$\\{git.tag\\}") ,tag))))
+             (add-before 'check 'prepare-tests
+               (lambda _
+                 ;; pcal tests write to cfg files
+                 (for-each (cut chmod <> #o644)
+                           (find-files (string-append ,tlatools
+                                                      "/test-model/pcal")
+                                       "\\.cfg$"))))
+             (replace 'install
+               (lambda* (#:key inputs #:allow-other-keys)
+                 (let* ((share (string-append %output "/share/java"))
+                        (jar-name "tla2tools.jar"); set in project.properties
+                        (jar (string-append ,tlatools
+                                            "/dist/" jar-name))
+                        (java-cp (string-append share "/" jar-name))
+                        (bin (string-append %output "/bin"))
+                        (java (string-append (assoc-ref inputs "jdk")
+                                             "/bin/java")))
+                   (install-file jar share)
+                   (mkdir-p bin)
+                   ;; Generate wrapper scripts for bin/, which invoke common
+                   ;; commands within tla2tools.jar.  Users can still invoke
+                   ;; tla2tools.jar for the rest.
+                   (for-each
+                    (match-lambda
+                      ((wrapper . class)
+                       (let ((file (string-append bin "/" wrapper)))
+                         (begin
+                           (with-output-to-file file
+                             (lambda _
+                               (display
+                                (string-append
+                                 "#!/bin/sh\n"
+                                 java " -cp " java-cp " " class " \"$@\""))))
+                           (chmod file #o755)))))
+                    ;; bin/wrapper . java-class
+                    '(("pcal" . "pcal.trans")
+                      ("tlatex" . "tla2tex.TLA")
+                      ("tla2sany" . "tla2sany.SANY")
+                      ("tlc2" . "tlc2.TLC")
+                      ("tlc2-repl" . "tlc2.REPL"))))))))))
+      (native-inputs
+       `(("java-junit" ,java-junit)
+         ("java-easymock" ,java-easymock)))
+      (inputs
+       `(("java-javax-mail" ,java-javax-mail)
+         ("java-gson" ,java-gson-2.8.6)
+         ("java-jline-terminal" ,java-jline-terminal)
+         ("java-jline-reader" ,java-jline-reader)
+         ("java-eclipse-lsp4j-jsonrpc" ,java-eclipse-lsp4j-jsonrpc)
+         ("java-eclipse-lsp4j-jsonrpc-debug" ,java-eclipse-lsp4j-jsonrpc-debug)
+         ("java-eclipse-lsp4j-debug" ,java-eclipse-lsp4j-debug)))
+      (home-page "https://lamport.azurewebsites.net/tla/tools.html")
+      (synopsis "TLA+ tools (analyzer, TLC, TLATeX, PlusCal translator)")
+      (description "TLA+ is a high-level language for modeling programs and
+systems---especially concurrent and distributed ones.  It's based on the idea
+that the best way to describe things precisely is with simple
+mathematics.  TLA+ and its tools are useful for eliminating fundamental design
+errors, which are hard to find and expensive to correct in code.
+
+The following TLA+ tools are available in this distribution:
+
+@itemize
+@item The Syntactic Analyzer: A parser and syntax checker for
+  TLA+ specifications;
+@item TLC: A model checker and simulator for a subclass of \"executable\" TLA+
+  specifications;
+@item TLATeX: A program for typesetting TLA+ specifications;
+@item Beta test versions of 1-3 for the TLA+2 language; and
+@item The PlusCal translator.
+@end itemize")
+      (license license:expat))))
diff --git a/gnu/packages/patches/tla2tools-build-xml.patch b/gnu/packages/patches/tla2tools-build-xml.patch
new file mode 100644
index 0000000000..0bba82072a
--- /dev/null
+++ b/gnu/packages/patches/tla2tools-build-xml.patch
@@ -0,0 +1,109 @@
+tla2tools comes packaged with three separate javax.mail JARs, which it
+expects to be available to include in the JAR produced by the `dist' target.
+However, the `java-javax-mail' packaged with Guix contains all of these
+dependencies in a single JAR, so the other two are unneeded.  This patch
+removes references to them.
+
+The JAR also was expected to contain classes that are built as part of the
+test suite.  That does not seem useful, nor is it available during the
+`compile' phase, so that portion is removed.
+
+There are a number of Git attributes that are set in the final manifest.
+The branch name is kept, but the others are removed.  The build user is set
+statically to "guix".
+
+Finally, since we already have a patch, two targets `jar' and `check' are
+added to satisfy `ant-build-system' and keep the package definition more
+lean.
+
+diff --git a/tlatools/org.lamport.tlatools/customBuild.xml b/tlatools/org.lamport.tlatools/customBuild.xml
+index f0ba77cb7..748e60d95 100644
+--- a/tlatools/org.lamport.tlatools/customBuild.xml
++++ b/tlatools/org.lamport.tlatools/customBuild.xml
+@@ -36,6 +36,17 @@
+ 		<istrue value="${maven.test.halt}"/>
+ 	</condition>
+ 
++  <!-- `jar' and `check' added for Guix -->
++  <target name="jar">
++		<antcall target="compile" inheritall="true" inheritrefs="true" />
++		<antcall target="compile-aj" inheritall="true" inheritrefs="true" />
++		<antcall target="dist" inheritall="true" inheritrefs="true" />
++  </target>
++  <target name="check">
++		<antcall target="compile-test" inheritall="true" inheritrefs="true" />
++		<antcall target="test" inheritall="true" inheritrefs="true" />
++  </target>
++
+ 	<!-- https://github.com/alx3apps/jgit-buildnumber -->
+ 	<target name="git-revision">
+ 	    <taskdef name="jgit-buildnumber" classname="ru.concerteza.util.buildnumber.JGitBuildNumberAntTask">
+@@ -217,17 +228,7 @@
+ 				<exclude name="javax/mail/search/**"/>
+ 			</patternset>
+ 		</unzip>
+-		<unzip src="lib/javax.mail/smtp-1.6.3.jar" dest="${class.dir}">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-			</patternset>
+-		</unzip>
+-		<unzip src="lib/javax.mail/javax.activation_1.1.0.v201211130549.jar" dest="${class.dir}">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-				<exclude name="org/**"/>
+-			</patternset>
+-		</unzip>
++		<mkdir dir="${class.dir}/META-INF" />
+ 		<touch file="${class.dir}/META-INF/javamail.default.address.map"/>
+ 		<unzip src="lib/jline/jline-terminal-3.14.1.jar" dest="${class.dir}">
+ 			<patternset>
+@@ -259,17 +260,7 @@
+ 				<exclude name="javax/mail/search/**"/>
+ 			</patternset>
+ 		</unzip>
+-		<unzip src="lib/javax.mail/smtp-1.6.3.jar" dest="target/classes">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-			</patternset>
+-		</unzip>
+-		<unzip src="lib/javax.mail/javax.activation_1.1.0.v201211130549.jar" dest="target/classes">
+-			<patternset>
+-		        <include name="**/*.class"/>
+-				<exclude name="org/**"/>
+-			</patternset>
+-		</unzip>
++		<mkdir dir="target/classes/META-INF" />
+ 		<touch file="target/classes/META-INF/javamail.default.address.map"/>
+ 
+ 		<unzip src="lib/jline/jline-terminal-3.14.1.jar" dest="target/classes">
+@@ -373,14 +364,8 @@
+ 					src/tla2sany/parser/Token.09-09-07,
+ 					src/tla2sany/parser/TokenMgrError.09-09-07"/>
+ 			<fileset dir="${doc.dir}" includes="License.txt"/>
+-			<fileset dir="${test.class.dir}">
+-				<include name="**/tlc2/tool/CommonTestCase*.class" />
+-				<include name="**/tlc2/tool/liveness/ModelCheckerTestCase*.class" />
+-				<include name="**/tlc2/TestMPRecorder*.class" />
+-				<include name="**/util/IsolatedTestCaseRunner*.class" />
+-			</fileset>
+ 			<manifest>
+-				<attribute name="Built-By" value="${user.name}" />
++				<attribute name="Built-By" value="guix" />
+ 				<attribute name="Build-Tag" value="${env.BUILD_TAG}" />
+ 				<attribute name="Build-Rev" value="${Build-Rev}" />
+ 				<attribute name="Implementation-Title" value="TLA+ Tools" />
+@@ -389,14 +374,8 @@
+ 				<!-- The jar files contains many main classes (SANY, TEX, pcal, ...) --> 
+                 <!-- but lets consider TLC the one users primarily use. --> 
+ 				<attribute name="Main-class" value="tlc2.TLC" />
+-				<attribute name="Class-Path" value="CommunityModules-deps.jar CommunityModules.jar" />
+ 				<!-- Git revision -->
+-				<attribute name="X-Git-Branch" value="${git.branch}" />
+ 				<attribute name="X-Git-Tag" value="${git.tag}" />
+-				<attribute name="X-Git-Revision" value="${git.revision}" />
+-				<attribute name="X-Git-ShortRevision" value="${git.shortRevision}" />
+-				<attribute name="X-Git-BuildNumber" value="${git.branch}_${git.tag}_${git.shortRevision}" />
+-				<attribute name="X-Git-Commits-Count" value="${git.commitsCount}" />
+ 				<!-- App-Name and Permissions is required by Java Webstart used by distributed TLC -->
+ 				<!-- Depending on security level, the user will see a warning otherwise. -->
+ 				<!-- http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/security/manifest.html -->
-- 
Mike Gerwitz
Activist For User Freedom | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#47789; Package guix-patches. (Fri, 16 Apr 2021 01:31:01 GMT) Full text and rfc822 format available.

Message #71 received at 47789 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: 47789 <at> debbugs.gnu.org
Subject: Re: [bug#47789] [PATCH 0/6] Add TLA+ Tools (tla2tools)
Date: Thu, 15 Apr 2021 21:29:42 -0400
[Message part 1 (text/plain, inline)]
Sorry, I sent the new series in reply to the original cover. :(

-- 
Mike Gerwitz
[signature.asc (application/pgp-signature, inline)]

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Wed, 05 May 2021 15:04:02 GMT) Full text and rfc822 format available.

Notification sent to Mike Gerwitz <mtg <at> gnu.org>:
bug acknowledged by developer. (Wed, 05 May 2021 15:04:02 GMT) Full text and rfc822 format available.

Message #76 received at 47789-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Mike Gerwitz <mtg <at> gnu.org>
Cc: 47789-done <at> debbugs.gnu.org
Subject: Re: bug#47789: [PATCH 0/6] Add TLA+ Tools (tla2tools)
Date: Wed, 05 May 2021 17:02:30 +0200
Hi Mike,

I pushed the whole patch series as
f30e8f29096e3ae2a4de689690daf5fa27a8c91b!  \o/

For the tla2tools patch, I added the patch to gnu/local.mk.  I also had
to change the hash of the checkout, because I wouldn’t get the same one.
There are two possibilities: either upstream changed the tag upstream,
or you were looking at a same-named store item actually coming from a
different commit.  Please take a look and let us know if anything’s
amiss.

Thanks for this heroic effort, and apologies for the delay!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 03 Jun 2021 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 320 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.