diff mbox series

[bug#35545,17/17] gnu: Add josm.

Message ID 20190503130134.24788-17-julien@lepiller.eu
State Accepted
Headers show
Series [bug#35545,01/17] gnu: Add java-signpost-core. | expand

Checks

Context Check Description
cbaines/applying patch success Successfully applied

Commit Message

Julien Lepiller May 3, 2019, 1:01 p.m. UTC
* gnu/packages/geo.scm (josm): New variable.
---
 gnu/packages/geo.scm | 134 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 134 insertions(+)

Comments

Björn Höfling May 5, 2019, 10:22 p.m. UTC | #1
On Fri,  3 May 2019 15:01:34 +0200
Julien Lepiller <julien@lepiller.eu> wrote:

> * gnu/packages/geo.scm (josm): New variable.
> ---
>  gnu/packages/geo.scm | 134

> +(define-public josm
> +  (package
> +    (name "josm")
> +    (version "15031")
> +    (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                     (url
> "https://github.com/openstreetmap/josm.git")
> +                     (commit
> "04d4c64b1b5698c0f9af40938f32194bc25bf75f")))

Checking out josm from git took at least 15 minutes, with the following
message:


building /gnu/store/4k4p9gm7jcrga0y1bk5rnq7025691kij-josm-15031-checkout.drv...
environment variable `PATH' set to `/gnu/store/q09sy224qnxrp982z4xfaxi19721mjx8-gzip-1.9/bin:/gnu/store/ipx79bfj2mrc8npj7s3qi3zri11jfhaw-tar-1.30/bi>
Initialized empty Git repository in /gnu/store/irx9c08wfp9g48ilrlj8z2xndl3z45l4-josm-15031-checkout/.git/
error: Server does not allow request for unadvertised object 04d4c64b1b5698c0f9af40938f32194bc25bf75f
Failed to do a shallow fetch; retrying a full fetch...
From https://github.com/openstreetmap/josm
 * [new branch]      master     -> origin/master
 * [new branch]      mirror     -> origin/mirror
Note: checking out '04d4c64b1b5698c0f9af40938f32194bc25bf75f'.


Have you tried out the original svn-checkout? Would that be faster? At
least it would better reflect the version, as this is the SVN commit id.

[..]

> +         (add-after 'install 'install-bin
> +           (lambda* (#:key outputs inputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out"))
> +                    (bin (string-append out "/bin")))
> +               (mkdir-p bin)
> +               (with-output-to-file (string-append bin "/josm")
> +                 (lambda _
> +                   (display
> +                     (string-append "#!/bin/sh\n"
> +                                    (assoc-ref inputs "jdk")
> "/bin/java"

I wonder where "jdk" comes in. I suppose it is some implicit (native?)
input from the ant-build-system. When I do a "guix gc --reference" I
see that it is referenced. Thus, it wouldn't be garbage-collected away
at least.

But wouldn't it be better to have the java-runtime (java:out) as an
explicit input and use that? Then it is first explicit and second would
use less space for people who do not need the full JDK. Though
sometimes programs NEED parts of the JDK, not only from the runtime. I
wonder if josm needs a JDK (usually these programs are more
server-oriented).


> +    (license license:gpl2+)))

I found some files under LGPL (though not mentioned in the
REAMDE/LICENSE file :-)), like:

 ./src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java

Looks like they are from Swing, I wonder if they are in any way
modified from the original ones.

While running the application:

I see a lot of NPEs on the console complaining about icons, though when
I run it, it looks good. I don't miss anything compared to my
downloaded josm-latest.jar.

When looking into the installed josm.jar, I find these:
24452 Tue Jan 01 00:00:00 CET 1980 images/presets/shop/kiosk.svg

But still having this error on the console:

2019-05-05 21:34:04.152 WARNING: Could not load SVG jar:file:/gnu/store/msbv0zpiwdjax2dwa3s9ml3idpc86bxp-josm-15031/share/java/josm.jar!/images/presets/shop/kiosk.svg
java.lang.NullPointerException
	at com.kitfox.svg.Tspan.appendToShape(Tspan.java:281)
	at com.kitfox.svg.Text.buildText(Text.java:362)
	at com.kitfox.svg.Text.build(Text.java:266)
	at com.kitfox.svg.Text.updateTime(Text.java:610)
	at com.kitfox.svg.Group.updateTime(Group.java:313)
	at com.kitfox.svg.Group.updateTime(Group.java:313)
	at com.kitfox.svg.SVGRoot.updateTime(SVGRoot.java:403)
	at com.kitfox.svg.SVGDiagram.updateTime(SVGDiagram.java:243)
	at com.kitfox.svg.SVGUniverse.loadSVG(SVGUniverse.java:616)
	at com.kitfox.svg.SVGUniverse.loadSVG(SVGUniverse.java:468)
	at com.kitfox.svg.SVGUniverse.loadSVG(SVGUniverse.java:445)
	at org.openstreetmap.josm.tools.ImageProvider.getIfAvailableLocalURL(Unknown Source)
	at org.openstreetmap.josm.tools.ImageProvider.getIfAvailableImpl(Unknown Source)
	at org.openstreetmap.josm.tools.ImageProvider.getResource(Unknown Source)
	at org.openstreetmap.josm.tools.ImageProvider.getResourceAsync(Unknown Source)
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPreset.setIcon(Unknown Source)
	at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.openstreetmap.josm.tools.XmlObjectParser$Parser.setValue(Unknown Source)
	at org.openstreetmap.josm.tools.XmlObjectParser$Parser.startElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:374)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
	at org.openstreetmap.josm.tools.XmlObjectParser.start(Unknown Source)
	at org.openstreetmap.josm.tools.XmlObjectParser.start(Unknown Source)
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader.readAll(Unknown Source)
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader.readAll(Unknown Source)
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader.readAll(Unknown Source)
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader.readFromPreferences(Unknown Source)
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPresets.readFromPreferences(Unknown Source)
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPresets.initialize(Unknown Source)
	at org.openstreetmap.josm.spi.lifecycle.InitializationTask.call(Unknown Source)
	at org.openstreetmap.josm.spi.lifecycle.InitializationTask.call(Unknown Source)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)


Plugins: I will continue the discussions where I started.

Thanks again for getting that into Guix!

Björn
diff mbox series

Patch

diff --git a/gnu/packages/geo.scm b/gnu/packages/geo.scm
index de9e228a25..06fd6c2822 100644
--- a/gnu/packages/geo.scm
+++ b/gnu/packages/geo.scm
@@ -49,6 +49,7 @@ 
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages image)
   #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages java)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages perl)
@@ -887,3 +888,136 @@  dropping features at lower levels.")
 integrate an OSM map view into your Java application.  It is maintained as
 an independent project by the JOSM team.")
     (license license:gpl2)))
+
+(define-public josm
+  (package
+    (name "josm")
+    (version "15031")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                     (url "https://github.com/openstreetmap/josm.git")
+                     (commit "04d4c64b1b5698c0f9af40938f32194bc25bf75f")))
+              (sha256
+               (base32
+                "0dgxa0yqh2sxl6nvpzw9507y5rdfxvmy54bhk2gfk1hxh3hvgmxh"))
+              (file-name (git-file-name name version))
+              (modules '((guix build utils)))
+              (snippet
+                `(begin
+                   (for-each delete-file (find-files "." ".*.jar"))
+                   (for-each delete-file-recursively
+                     '("src/org/apache"
+                       "src/org/glassfish"
+                       "src/org/tukaani"
+                       "src/javax"
+                       "src/oauth"
+                       "src/com"))
+                   #t))))
+    (build-system ant-build-system)
+    (native-inputs
+     `(("javacc" ,javacc)))
+    (inputs
+     `(("java-commons-jcs" ,java-commons-jcs)
+       ("java-commons-compress" ,java-commons-compress)
+       ("java-jmapviewer" ,java-jmapviewer)
+       ("java-jsonp-api" ,java-jsonp-api)
+       ("java-jsonp-impl" ,java-jsonp-impl); runtime dependency
+       ("java-metadata-extractor" ,java-metadata-extractor)
+       ("java-openjfx-media" ,java-openjfx-media)
+       ("java-signpost-core" ,java-signpost-core)
+       ("java-svg-salamander" ,java-svg-salamander)))
+    (arguments
+     `(#:tests? #f
+       #:jar-name "josm.jar"
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'rm-build.xml
+           (lambda* _
+             (delete-file "build.xml")
+             #t))
+         (add-before 'build 'fix-revision
+           (lambda* _
+             (with-output-to-file "REVISION.XML"
+               (lambda _
+                 (display
+                   (string-append "<info><entry><commit revision=\"" ,version "\">"
+                                  "<date>1970-01-01 00:00:00 +0000</date>"
+                                  "</commit></entry></info>"))))
+             #t))
+         (add-before 'build 'generate-parser
+           (lambda* _
+             (let* ((dir "src/org/openstreetmap/josm/gui/mappaint/mapcss")
+                    (out (string-append dir "/parsergen"))
+                    (file (string-append dir "/MapCSSParser.jj")))
+               (mkdir-p "src/org/openstreetmap/josm/gui/mappaint/mapcss/parsergen")
+               (invoke "javacc" "-DEBUG_PARSER=false"
+                       "-DEBUG_TOKEN_MANAGER=false" "-JDK_VERSION=1.8"
+                       "-GRAMMAR_ENCODING=UTF-8"
+                       (string-append "-OUTPUT_DIRECTORY=" out)
+                       file))
+             #t))
+         (add-after 'build 'generate-epsg
+           (lambda _
+             (system* "javac" "scripts/BuildProjectionDefinitions.java"
+                      "-cp" "build/classes")
+             (mkdir-p "data/projection")
+             (with-output-to-file "data/projection/custom-epsg"
+               (lambda _ (display "")))
+             (invoke "java" "-cp" "build/classes:scripts:."
+                     "BuildProjectionDefinitions" ".")
+             #t))
+         (add-after 'generate-epsg 'copy-data
+           (lambda _
+             (mkdir-p "build/classes")
+             (rename-file "data" "build/classes/data")
+             #t))
+         (add-before 'install 'regenerate-jar
+           (lambda _
+             ;; We need to regenerate the jar file to add data.
+             (delete-file "build/jar/josm.jar")
+             (invoke "jar" "-cf" "build/jar/josm.jar" "-C"
+                     "build/classes" ".")
+             #t))
+         (add-before 'build 'copy-styles
+           (lambda _
+             (mkdir-p "build/classes")
+             (rename-file "styles" "build/classes/styles")
+             #t))
+         (add-before 'build 'copy-images
+           (lambda _
+             (mkdir-p "build/classes")
+             (rename-file "images" "build/classes/images")
+             #t))
+         (add-before 'build 'copy-revision
+           (lambda _
+             (mkdir-p "build/classes")
+             (with-output-to-file "build/classes/REVISION"
+               (lambda _
+                 (display
+                   (string-append "Revision: " ,version "\n"
+                                  "Is-Local-Build: true\n"
+                                  "Build-Date: 1970-01-01 00:00:00 +0000\n"))))
+             #t))
+         (add-after 'install 'install-bin
+           (lambda* (#:key outputs inputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (bin (string-append out "/bin")))
+               (mkdir-p bin)
+               (with-output-to-file (string-append bin "/josm")
+                 (lambda _
+                   (display
+                     (string-append "#!/bin/sh\n"
+                                    (assoc-ref inputs "jdk") "/bin/java"
+                                    " -cp " out "/share/java/josm.jar:"
+                                    (getenv "CLASSPATH")
+                                    " org.openstreetmap.josm.gui.MainApplication"))))
+               (chmod (string-append bin "/josm") #o755))
+             #t)))))
+    (home-page "https://josm.openstreetmap.de")
+    (synopsis "OSM editor")
+    (description "JOSM is an extensible editor for OpenStreetMap (OSM).  It
+supports loading GPX tracks, background imagery and OSM data from local
+sources as well as from online sources and allows to edit the OSM data (nodes,
+ways, and relations) and their metadata tags.")
+    (license license:gpl2+)))