improve josm, wip

LEPILLER JulienFri Jun 30 09:25:57+0200 2017

b5e14ae

improve josm, wip

more/packages/java.scm

3232
  #:use-module (gnu packages zip)
3333
  #:use-module (gnu packages java))
3434
35-
(define-public josm
35+
(define-public java-jmapviewer
3636
  (package
37-
    (name "josm")
38-
    (version "12039")
37+
    (name "java-jmapviewer")
38+
    (version "2.2")
3939
    (source (origin
40-
              (method svn-fetch)
41-
              ;;(uri (git-reference
42-
              ;;      (url "https://github.com/openstreetmap/josm.git")
43-
              ;;      (commit version)))
44-
              (uri (svn-reference
45-
                    (url "https://svn.openstreetmap.org/applications/editors/josm")
46-
                    (revision 12039)))
40+
              (method url-fetch)
41+
              (uri (string-append "https://svn.openstreetmap.org/applications/viewer/jmapviewer/releases/"
42+
                                  version "/JMapViewer-" version "-Source.zip"))
4743
              (sha256
4844
               (base32
49-
                ;;"17ih97kf6g6ly8gz6dbc3jzh22gamra4anbwcsxivhq7dw5z3a6n"))
50-
                "1sq35askhvg85ghj7q34adxny7dwacz7xx6sbc1l5g0khcck7vql"))
45+
                "00jxqc4fzy7hpdi0007f0a84aa630brvam7vxqirdk9j4za4p0d8"))))
46+
    (build-system ant-build-system)
47+
    (native-inputs
48+
     `(("unzip" ,unzip)))
49+
    (arguments
50+
     `(#:build-target "pack"
51+
       #:jdk ,icedtea-8
52+
       #:tests? #f; No tests
53+
       #:phases
54+
       (modify-phases %standard-phases
55+
         (add-before 'build 'clean
56+
           (lambda* _
57+
             (zero? (system* "ant" "clean"))))
58+
         (replace 'install
59+
           (lambda* (#:key outputs #:allow-other-keys)
60+
             (let ((dir (string-append (assoc-ref outputs "out") "/share/java/")))
61+
               (mkdir-p dir)
62+
               (copy-file "JMapViewer.jar" (string-append dir "JMapViewer.jar"))))))))
63+
    (home-page "https://wiki.openstreetmap.org/wiki/JMapViewer")
64+
    (synopsis "")
65+
    (description "")
66+
    (license license:gpl2)))
67+
68+
(define-public java-josm
69+
  (package
70+
    (name "java-josm")
71+
    (version "12275")
72+
    (source (origin
73+
              (method git-fetch)
74+
              (uri (git-reference
75+
                    (url "https://github.com/openstreetmap/josm.git")
76+
                    (commit "f190ffc3ec16835c39150476e21d08d5557ed466")))
77+
              ;;(uri (svn-reference
78+
              ;;      (url "https://svn.openstreetmap.org/applications/editors/josm")
79+
              ;;      (revision 12039)))
80+
              (sha256
81+
               (base32
82+
                "191isyn9v396s3c6888brq1yl2chzs7myl3qbk5c7d8msxi4wv49"))
5183
              (file-name (string-append name "-" version))))
5284
    (build-system ant-build-system)
85+
    (native-inputs
86+
     `(("java-javacc" ,java-javacc)))
87+
    (propagated-inputs
88+
     `(("java-jmapviewer" ,java-jmapviewer)
89+
       ("java-commons-compress" ,java-commons-compress)))
5390
    (arguments
54-
     `(#:build-target "dist"
91+
     `(;#:build-target "dist"
5592
       #:tests? #f
5693
       #:jdk ,icedtea-8
94+
       #:jar-name "josm.jar"
5795
       #:phases
5896
       (modify-phases %standard-phases
59-
         (add-before 'build 'fix-compiler
97+
         (add-after 'unpack 'rm-build.xml
98+
           (lambda* _
99+
             (delete-file "build.xml")))
100+
         (add-before 'build 'fix-revision
60101
           (lambda* _
61102
             (with-output-to-file "REVISION.XML"
62103
               (lambda _
63104
                 (display
64105
                   (string-append "<info><entry><commit revision=\"" ,version "\">"
65106
                                  "<date>1970-01-01 00:00:00 +0000</date>"
66-
                                  "</commit></entry></info>"))))
67-
             (substitute* "build.xml"
68-
               (("UNKNOWN") ,version)
69-
               (("<touch.*epsg.output.*") "<mkdir dir=\"${epsg.output}/..\" /><touch file=\"${epsg.output}\"/>\n")
70-
               ((".*com.google.errorprone.ErrorProneAntCompilerAdapter.*") "")
71-
               (("compiler=\"[^\"]*\" ") ""))))
107+
                                  "</commit></entry></info>"))))))
108+
         (add-before 'build 'generate-parser
109+
           (lambda* _
110+
             (let* ((dir "src/org/openstreetmap/josm/gui/mappaint/mapcss")
111+
                    (out (string-append dir "/parsergen"))
112+
                    (file (string-append dir "/MapCSSParser.jj")))
113+
               (mkdir-p "src/org/openstreetmap/josm/gui/mappaint/mapcss/parsergen")
114+
               (zero? (system* "javacc" "-DEBUG_PARSER=false"
115+
                               "-DEBUG_TOKEN_MANAGER=false" "-JDK_VERSION=1.8"
116+
                               "-GRAMMAR_ENCODING=UTF-8" (string-append "-OUTPUT_DIRECTORY=" out)
117+
                               file)))))
118+
)))
119+
         ;(add-before 'build 'fix-compiler
120+
         ;  (lambda* _
121+
         ;    (substitute* "build.xml"
122+
         ;      (("UNKNOWN") ,version)
123+
         ;      (("<touch.*epsg.output.*") "<mkdir dir=\"${epsg.output}/..\" /><touch file=\"${epsg.output}\"/>\n")
124+
         ;      ((".*com.google.errorprone.ErrorProneAntCompilerAdapter.*") "")
125+
         ;      (("compiler=\"[^\"]*\" ") ""))))
126+
         ;(replace 'install
127+
         ;  (lambda* (#:key outputs inputs #:allow-other-keys)
128+
         ;    (let* ((out (assoc-ref outputs "out"))
129+
         ;           (bin (string-append out "/bin"))
130+
         ;           (lib (string-append out "/lib/josm")))
131+
         ;      (mkdir-p bin)
132+
         ;      (mkdir-p lib)
133+
         ;      (copy-file "dist/josm-custom.jar"
134+
         ;                 (string-append lib "/josm.jar"))
135+
         ;      (with-output-to-file (string-append bin "/josm")
136+
         ;        (lambda _
137+
         ;          (display
138+
         ;            (string-append "#!/bin/sh\n"
139+
         ;                           (assoc-ref inputs "jdk") "/bin/java"
140+
         ;                           " -jar " lib "/josm.jar"))))
141+
         ;      (chmod (string-append bin "/josm") #o755)))))))
142+
    (home-page "https://josm.openstreetmap.de")
143+
    (synopsis "OSM editor")
144+
    (description "OSM editor.")
145+
    (license license:gpl2+)))
146+
147+
(define-public java-commons-collections
148+
  (package
149+
    (inherit java-commons-collections4)
150+
    (name "java-commons-collections")
151+
    (version "3.2.2")
152+
    (source (origin
153+
              (method url-fetch)
154+
              (uri (string-append "mirror://apache/commons/collections/source/"
155+
                                  "commons-collections-" version "-src.tar.gz"))
156+
              (sha256
157+
               (base32
158+
                "055r51a5lfc3z7rkxnxmnn1npvkvda7636hjpm4qk7cnfzz98387"))))))
159+
160+
(define-public java-velocity
161+
  (package
162+
    (name "java-velocity")
163+
    (version "1.7")
164+
    (source (origin
165+
              (method url-fetch)
166+
              (uri (string-append "mirror://apache/velocity/engine/"
167+
                                  version "/velocity-" version ".tar.gz"))
168+
              (sha256
169+
               (base32
170+
                "0rk7s04hkrr2k3glccx0yrglzqzj4qbipcrxhglk46yhx92vravc"))))
171+
    (build-system ant-build-system)
172+
    (arguments
173+
     `(#:phases
174+
       (modify-phases %standard-phases
175+
         (add-before 'build 'prepare
176+
           (lambda* (#:key inputs #:allow-other-keys)
177+
             (delete-file-recursively "lib")
178+
             (mkdir-p "bin/lib")
179+
             ;; Don't download anything
180+
             (substitute* "build/build.xml"
181+
               ((".*download.xml.*") ""))
182+
             (chdir "build"))))))
183+
    (native-inputs
184+
     `(("javacc" ,java-javacc)
185+
       ("antlr" ,antlr2)))
186+
    (propagated-inputs
187+
     `(("java-commons-collections" ,java-commons-collections)))
188+
    (home-page "https://velocity.apache.org/")
189+
    (synopsis "")
190+
    (description "")
191+
    (license license:asl2.0)))
192+
193+
(define-public java-commons-jcs
194+
  (package
195+
    (name "java-commons-jcs")
196+
    (version "2.1")
197+
    (source (origin
198+
              (method url-fetch)
199+
              (uri (string-append "mirror://apache/commons/jcs/source/"
200+
                                  "commons-jcs-dist-" version "-src.tar.gz"))
201+
              (sha256
202+
               (base32
203+
                "17l78mpxx1qkgp213b91sl69wawv6xzgllr479mygbg76ygwpffv"))))
204+
    (build-system ant-build-system)
205+
    (arguments
206+
     `(#:jar-name "commons-jcs.jar"
207+
       #:source-dir "commons-jcs-core/src/main/java"))
208+
    (propagated-inputs
209+
     `(("java-commons-logging-minimal" ,java-commons-logging-minimal)
210+
       ("java-velocity" ,java-velocity)))
211+
    (home-page "https://commons.apache.org/proper/commons-jcs/")
212+
    (synopsis "")
213+
    (description "")
214+
    (license license:asl2.0)))
215+
216+
(define-public java-javacc
217+
  (package
218+
    (name "java-javacc")
219+
    (version "7.0.2")
220+
    (source (origin
221+
              (method url-fetch)
222+
              (uri (string-append "https://github.com/javacc/javacc/archive/release_"
223+
                                  (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version)
224+
                                  ".tar.gz"))
225+
              (sha256
226+
               (base32
227+
                "0yf93993nlsk5kijazddi5621x4y2bwq3vl46j8h8f7di2z9jv2h"))))
228+
    (build-system ant-build-system)
229+
    (arguments
230+
     `(#:test-target "unittest"
231+
       #:phases
232+
       (modify-phases %standard-phases
233+
         (add-after 'unpack 'remove-binaries
234+
           (lambda* _
235+
             ;; Note: we cannot remove bootstrap/javacc.jar because no version of javacc comes with no bootstrap
236+
             (delete-file-recursively "lib")))
237+
         ;    (let* ((out (assoc-ref outputs "out"))
238+
         ;           (bin (string-append out "/bin"))
239+
         ;           (lib (string-append out "/lib/josm")))
240+
         ;      (mkdir-p bin)
241+
         ;      (mkdir-p lib)
242+
         ;      (copy-file "dist/josm-custom.jar"
243+
         ;                 (string-append lib "/josm.jar"))
72244
         (replace 'install
73245
           (lambda* (#:key outputs inputs #:allow-other-keys)
74246
             (let* ((out (assoc-ref outputs "out"))
75-
                    (bin (string-append out "/bin"))
76-
                    (lib (string-append out "/lib/josm")))
247+
                    (dir (string-append out "/share/java"))
248+
                    (bin (string-append out "/bin")))
249+
               (mkdir-p dir)
77250
               (mkdir-p bin)
78-
               (mkdir-p lib)
79-
               (copy-file "dist/josm-custom.jar"
80-
                          (string-append lib "/josm.jar"))
81-
               (with-output-to-file (string-append bin "/josm")
251+
               (copy-file "target/javacc.jar" (string-append dir "/javacc.jar"))
252+
               (with-output-to-file (string-append bin "/javacc")
82253
                 (lambda _
83254
                   (display
84255
                     (string-append "#!/bin/sh\n"
85256
                                    (assoc-ref inputs "jdk") "/bin/java"
86-
                                    " -jar " lib "/josm.jar"))))
87-
               (chmod (string-append bin "/josm") #o755)))))))
88-
    (home-page "https://josm.openstreetmap.de")
89-
    (synopsis "OSM editor")
90-
    (description "OSM editor.")
91-
    (license license:gpl2+)))
257+
                                    " -cp " dir "/javacc.jar" " javacc" " $*"))))
258+
               (chmod (string-append bin "/javacc") #o755)))))))
259+
    (native-inputs
260+
     `(("junit" ,java-junit)))
261+
    (home-page "https://javacc.org")
262+
    (synopsis "")
263+
    (description "")
264+
    (license license:bsd-3)))
265+
    
92266
93267
(define-public java-icu4j
94268
  (package