Update scala and sbt (launcher)

Julien LepillerSun Jun 20 23:22:36+0200 2021

1f8c034

Update scala and sbt (launcher)

more/packages/java.scm

82268226
      (synopsis "")
82278227
      (description "")
82288228
      (license license:asl2.0))))
8229+
8230+
(define-public java-jline3-terminal
8231+
  (package
8232+
    (name "java-jline3-terminal")
8233+
    (version "3.19.0")
8234+
    (source (origin
8235+
              (method git-fetch)
8236+
              (uri (git-reference
8237+
                     (url "https://github.com/jline/jline3")
8238+
                     (commit (string-append "jline-parent-" version))))
8239+
              (file-name (git-file-name name version))
8240+
              (sha256
8241+
               (base32
8242+
                "16cfbkbj925c92xnwq5sbg7v57yh840g0mh95iyzkkajxirz9qn9"))
8243+
              (snippet
8244+
               ;; calls maven, and conflicts with ant
8245+
               `(delete-file "build"))))
8246+
    (build-system ant-build-system)
8247+
    (arguments
8248+
     `(#:jar-name "jline3-terminal.jar"
8249+
       #:source-dir "terminal/src/main/java"
8250+
       #:test-dir "terminal/src/test"
8251+
       #:phases
8252+
       (modify-phases %standard-phases
8253+
         (add-before 'build 'copy-resources
8254+
           (lambda _
8255+
             (copy-recursively "terminal/src/main/resources/" "build/classes")
8256+
             #t)))))
8257+
    (native-inputs
8258+
     `(("java-easymock" ,java-easymock)
8259+
       ("java-junit" ,java-junit)))
8260+
    (home-page "")
8261+
    (synopsis "")
8262+
    (description "")
8263+
    (license #f)))
8264+
8265+
(define-public java-jline3-reader
8266+
  (package
8267+
    (inherit java-jline3-terminal)
8268+
    (name "java-jline3-reader")
8269+
    (arguments
8270+
     `(#:jar-name "jline3-reader.jar"
8271+
       #:source-dir "reader/src/main/java"
8272+
       #:test-dir "reader/src/test"))
8273+
    (inputs
8274+
     `(("java-jline3-terminal" ,java-jline3-terminal)))))
8275+
8276+
(define-public java-concurrent-reference-hash-map
8277+
  (package
8278+
    (name "java-concurrent-reference-hash-map")
8279+
    (version "1.0.0")
8280+
    (source (origin
8281+
              (method git-fetch)
8282+
              (uri (git-reference
8283+
                     (url "https://github.com/alexarchambault/concurrent-reference-hash-map")
8284+
                     (commit (string-append "v" version))))
8285+
              (file-name (git-file-name name version))
8286+
              (sha256
8287+
               (base32
8288+
                "1x2pybyld2b6pp5f93l2ixxljk18vkw11s6pysfck7a30l9f7bzb"))))
8289+
    (build-system ant-build-system)
8290+
    (arguments
8291+
     `(#:jar-name "concurrent-reference-hash-map.jar"
8292+
       #:tests? #f)); no tests
8293+
    (home-page "")
8294+
    (synopsis "")
8295+
    (description "")
8296+
    (license license:lgpl2.1)))

more/packages/scala.scm

2424
  #:use-module (guix git-download)
2525
  #:use-module (guix utils)
2626
  #:use-module (guix build-system ant)
27+
  #:use-module (guix build-system copy)
2728
  #:use-module (guix build-system gnu)
28-
  #:use-module (guix build-system trivial)
2929
  #:use-module (gnu packages base)
3030
  #:use-module (gnu packages bash)
3131
  #:use-module (gnu packages compression)
3232
  #:use-module (gnu packages java)
3333
  #:use-module (gnu packages protobuf)
34+
  #:use-module (gnu packages web)
3435
  #:use-module (more packages java))
3536
3637
;; This package downloads the so-called official version of scala, a pre-built

3839
;; This binary should never be made part of Guix itself, because we have
3940
;; ways to bootstrap it properly. The bootstrap project of scala takes time,
4041
;; so in the meantime... here you are :(
41-
(define-public scala-official
42-
  (package
43-
    (name "scala-official")
44-
    (version "2.12.8")
45-
    (source
46-
      (origin
47-
        (method url-fetch)
48-
        (uri (string-append "https://downloads.lightbend.com/scala/"
49-
                            version "/scala-" version ".tgz"))
50-
        (sha256
51-
         (base32
52-
          "18w0vdbsp0q5rxglgalwlgkggld926bqi1fxc598rn4gh46a03j4"))))
53-
    (build-system trivial-build-system)
54-
    (arguments
55-
     `(#:modules ((guix build utils))
56-
       #:builder (begin
57-
                   (use-modules (guix build utils))
58-
                   (let* ((source (assoc-ref %build-inputs "source"))
59-
                          (java (assoc-ref %build-inputs "icedtea-8"))
60-
                          (bash (assoc-ref %build-inputs "bash"))
61-
                          (tar (string-append
62-
                                 (assoc-ref %build-inputs "tar")
63-
                                 "/bin/tar"))
64-
                          (gzip (assoc-ref %build-inputs "gzip"))
65-
                          (output (assoc-ref %outputs "out"))
66-
                          (bindir (string-append output "/bin")))
67-
                     (mkdir-p output)
68-
                     (setenv "PATH" (string-append (getenv "PATH") ":" gzip "/bin"))
69-
                     (invoke tar "xf" source)
70-
                     (copy-recursively "scala-2.12.8" output)
71-
                     (chdir output)
72-
                     (for-each delete-file (find-files "bin" "bat$"))
73-
                     (substitute* (find-files "bin" ".*")
74-
                       (("^#!.*")
75-
                        (string-append "#!" bash "/bin/bash\n" "JAVA_HOME=" java)))))))
76-
    (inputs
77-
     `(("bash" ,bash)
78-
       ("gzip" ,gzip)
79-
       ("icedtea-8" ,icedtea-8)
80-
       ("tar" ,tar)))
81-
    (home-page "https://scala-lang.org/")
82-
    (synopsis "")
83-
    (description "")
84-
    (license license:bsd-3)))
8542
86-
;; TODO: put it in guix/build/java-utils.scm
87-
;; TODO: remove contraband-* directories and regenerate them from contraband/
88-
(define* (sbt-building-phase subprojects #:optional (kind-projector? #f))
89-
  `(lambda* (#:key inputs #:allow-other-keys)
90-
     (define (build-subproject prefix name)
91-
       (let ((build-directory (string-append "build/" name))
92-
             (kind-projector (assoc-ref inputs "scala-kind-projector"))
93-
             (jar-name (string-append
94-
                         (if (> (string-length prefix) 0)
95-
                           (string-replace prefix "-" (- (string-length prefix) 1))
96-
                           "")
97-
                         name ".jar"))
98-
             (java-files
99-
                (append
100-
                  (find-files (string-append prefix name "/src/main/contraband-java")
101-
                              ".*.java$")
102-
                  (find-files (string-append prefix name "/src/main/java")
103-
                              ".*.java$")))
104-
             (scala-files
105-
                (append
106-
                  (find-files (string-append prefix name "/src/main/contraband-scala")
107-
                              ".*.scala$")
108-
                  (find-files (string-append prefix name "/src/main/scala")
109-
                              ".*.scala$"))))
110-
         (mkdir-p build-directory)
111-
         (format #t "Building project ~a...~%" jar-name)
112-
         (unless (eq? scala-files '())
113-
           (apply invoke "scalac" "-classpath"
114-
                  (string-append
115-
                    (getenv "CLASSPATH") ":"
116-
                    ;; Add any top-level directory in build that may contain
117-
                    ;; .class files, but don't actually add build/ iteself or
118-
                    ;; any individual class file.
119-
                    (string-join
120-
                      (filter (lambda (s) (eq? (string-count s #\/) 1))
121-
                              (find-files "build" "." #:directories? #t))
122-
                      ":"))
123-
                  "-d" build-directory "-language:experimental.macros"
124-
                  (if ,kind-projector?
125-
                    (string-append "-Xplugin:" kind-projector
126-
                                   "/share/java/kind-projector.jar")
127-
                    "")
128-
                  (append scala-files java-files)))
129-
         (unless (eq? java-files '())
130-
           (apply invoke "javac" "-classpath"
131-
                  (string-append
132-
                    (getenv "CLASSPATH") ":"
133-
                    (string-join
134-
                      (filter (lambda (s) (eq? (string-count s #\/) 1))
135-
                              (find-files "build" "." #:directories? #t))
136-
                      ":"))
137-
                  "-d" build-directory java-files))
138-
         (invoke "jar" "cf" (string-append "build/jar/" jar-name)
139-
                 "-C" build-directory ".")))
140-
     (mkdir-p "build/jar")
141-
     (for-each (lambda (project)
142-
                   (build-subproject (car project) (cadr project)))
143-
       '(,@subprojects))
144-
     #t))
145-
146-
(define-public sbt-boilerplate-standalone
43+
(define %binary-scala
14744
  (package
148-
    (name "sbt-boilerplate-standalone")
149-
    (version "0.6.1")
45+
    (name "scala")
46+
    (version "2.13.6")
15047
    (source (origin
15148
              (method url-fetch)
152-
              (uri (string-append "https://github.com/sbt/sbt-boilerplate/archive/v"
153-
                                  version ".tar.gz"))
154-
              (file-name (string-append name "-" version ".tar.gz"))
49+
              (uri (string-append "https://downloads.lightbend.com/scala/"
50+
                                  version  "/scala-" version ".tgz"))
15551
              (sha256
15652
               (base32
157-
                "1xzh7qrsl2nmnbyzlmrshzfsf8b4qgf6yaqm1hn3qnzk6761p2jy"))))
158-
    (build-system ant-build-system)
159-
    (arguments
160-
     `(#:tests? #f
161-
       #:phases
162-
       (modify-phases %standard-phases
163-
         (add-before 'build 'add-standalone
164-
           (lambda _
165-
             (substitute* "src/main/scala/spray/boilerplate/Generator.scala"
166-
               (("object Generator \\{")
167-
                "object Generator {
168-
def main(args: Array[String]): Unit = {
169-
    val num = args(2).toInt
170-
    val file = scala.io.Source.fromFile(args(0))
171-
    val content = file.mkString
172-
    val result = new java.io.PrintWriter(new java.io.File(args(1)))
173-
174-
    file.close
175-
    result.write(generateFromTemplate(content, num))
176-
    result.close()
177-
}"))
178-
             #t))
179-
         (replace 'build
180-
           (lambda _
181-
             (mkdir-p "build/classes")
182-
             (mkdir-p "build/jar")
183-
             (invoke "scalac" "-classpath" (getenv "CLASSPATH")
184-
                     "-d" "build/classes"
185-
                     "src/main/scala/spray/boilerplate/Generator.scala"
186-
                     "src/main/scala/spray/boilerplate/TemplateParser.scala")
187-
             (invoke "jar" "-cf" "build/jar/boilerplate.jar"
188-
                     "-C" "build/classes" ".")
189-
             #t))
190-
         (replace 'install
191-
           (install-jars "build")))))
192-
    (native-inputs
193-
     `(("scala" ,scala-official)))
194-
    (home-page "https://github.com/sbt/sbt-boilerplate")
195-
    (synopsis "")
196-
    (description "")
197-
    (license license:bsd-2)))
198-
199-
(define-public scala-sjsonnew
200-
  (package
201-
    (name "scala-sjsonnew")
202-
    (version "0.8.2")
203-
    (source
204-
      (origin
205-
        (method url-fetch)
206-
        (uri (string-append "https://github.com/eed3si9n/sjson-new/archive/v"
207-
                            version ".tar.gz"))
208-
        (file-name (string-append name "-" version ".tar.gz"))
209-
        (sha256
210-
         (base32
211-
          "1rv0c50af5kn27x51g650wl2ig94z52fhs0rn8ykahpz4jhg1p7p"))))
53+
                "0hzd6pljc8z5fwins5a05rwpx2w7wmlb6gb8973c676i7i895ps9"))))
54+
    (build-system copy-build-system)
21255
    (arguments
213-
     `(#:tests? #f
56+
     `(#:install-plan
57+
       '(("." ""))
21458
       #:phases
21559
       (modify-phases %standard-phases
216-
         (add-before 'build 'generate-boilerplate
217-
           (lambda _
218-
             ; CaseClassFormats.scala.template  FlatUnionFormats.scala.template  TupleFormats.scala.template  UnionFormats.scala.template
219-
             (invoke "java" "-cp" (getenv "CLASSPATH") "spray.boilerplate.Generator"
220-
                     "core/src/main/boilerplate/sjsonnew/CaseClassFormats.scala.template"
221-
                     "core/src/main/scala/sjsonnew/CaseClassFormats.scala" "22")
222-
             (invoke "java" "-cp" (getenv "CLASSPATH") "spray.boilerplate.Generator"
223-
                     "core/src/main/boilerplate/sjsonnew/FlatUnionFormats.scala.template"
224-
                     "core/src/main/scala/sjsonnew/FlatUnionFormats.scala" "22")
225-
             (invoke "java" "-cp" (getenv "CLASSPATH") "spray.boilerplate.Generator"
226-
                     "core/src/main/boilerplate/sjsonnew/TupleFormats.scala.template"
227-
                     "core/src/main/scala/sjsonnew/TupleFormats.scala" "22")
228-
             (invoke "java" "-cp" (getenv "CLASSPATH") "spray.boilerplate.Generator"
229-
                     "core/src/main/boilerplate/sjsonnew/UnionFormats.scala.template"
230-
                     "core/src/main/scala/sjsonnew/UnionFormats.scala" "22")
231-
             #t))
232-
         (replace 'build
60+
         (add-before 'install 'set-java-home
61+
           (lambda* (#:key inputs #:allow-other-keys)
62+
             (substitute* (find-files "bin" ".")
63+
               (("^#!.*" shebang)
64+
                (string-append shebang "\nJAVA_HOME="
65+
                               (assoc-ref inputs "openjdk"))))))
66+
         (add-before 'set-java-home 'remove-unneeded
23367
           (lambda _
234-
             (mkdir-p "build/classes")
235-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
236-
                    "-d" "build/classes"
237-
                    (find-files "core/src/main/scala" ".*.scala$"))
238-
             (mkdir-p "build/jar")
239-
             (invoke "jar" "-cf" "build/jar/sjsonnew.jar"
240-
                     "-C" "build/classes" ".")
241-
             #t))
242-
         (replace 'install
243-
           (install-jars "build")))))
244-
    (build-system ant-build-system)
245-
    (native-inputs
246-
     `(("scala" ,scala-official)
247-
       ("sbt-boilerplate-standalone" ,sbt-boilerplate-standalone)))
248-
    (home-page "")
249-
    (synopsis "")
250-
    (description "")
251-
    (license license:asl2.0)))
68+
             (for-each delete-file (find-files "bin" "bat$")))))))
69+
    (inputs
70+
     `(("openjdk" ,openjdk14)))
71+
    (home-page "https://scala-lang.org/")
72+
    (synopsis "Scala programming language")
73+
    (description "Scala combines object-oriented and functional programming in
74+
one concise, high-level language.  Scala's static types help avoid bugs in
75+
complex applications, and its JVM and JavaScript runtimes let you build
76+
high-performance systems with easy access to huge ecosystems of libraries.")
77+
    (license license:bsd-3)))
25278
253-
(define-public scala-scalajson
79+
(define scala-asm
25480
  (package
255-
    (name "scala-scalajson")
256-
    (version "1.0.0-M4")
81+
    (inherit java-asm)
82+
    (version "9.1.0")
25783
    (source (origin
258-
              (method url-fetch)
259-
              (uri (string-append "https://github.com/mdedetrich/scalajson/archive/v" version ".tar.gz"))
260-
              (file-name (string-append name "-" version ".tar.gz"))
84+
              (method git-fetch)
85+
              (uri (git-reference
86+
                     (url "https://github.com/scala/scala-asm")
87+
                     (commit "s-9.1")))
88+
              (file-name (git-file-name "scala-asm" version))
26189
              (sha256
26290
               (base32
263-
                "0k4dj2zm7zilhshdnvqi9n17qr4szc5s9ymsm9imgqpr8r5hm2vj"))))
264-
    (build-system ant-build-system)
91+
                "1wsrlb6kb0fwxjdqanxqgmq4qcyq9gqn129w3l4bj7gvlspll33l"))))
26592
    (arguments
266-
     `(#:tests? #f
267-
       #:phases
268-
       (modify-phases %standard-phases
269-
         (replace 'build
270-
           (lambda _
271-
             (mkdir-p "build/classes")
272-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
273-
                    "-d" "build/classes"
274-
                    (find-files "shared/src/main/scala" ".*.scala$"))
275-
             (mkdir-p "build/jar")
276-
             (invoke "jar" "-cf" "build/jar/scalajson-shared.jar"
277-
                     "-C" "build/classes" ".")
278-
             (delete-file-recursively "build/classes")
279-
             (setenv "CLASSPATH" (string-append (getenv "CLASSPATH") ":build/jar/scalajson-shared.jar"))
280-
             (mkdir-p "build/classes")
281-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
282-
                    "-d" "build/classes"
283-
                    (find-files "jvm/src/main/scala" ".*.scala$"))
284-
             (mkdir-p "build/jar")
285-
             (invoke "jar" "-cf" "build/jar/scalajson-jvm.jar"
286-
                     "-C" "build/classes" ".")
287-
             #t))
288-
         (replace 'install
289-
           (install-jars "build")))))
290-
    (native-inputs
291-
     `(("scala" ,scala-official)))
292-
    (home-page "")
293-
    (synopsis "")
294-
    (description "")
295-
    (license license:bsd-3)))
93+
     `(#:jar-name "java-asm.jar"
94+
       #:source-dir "src/main/java"
95+
       ;; no tests
96+
       #:tests? #f))))
29697
297-
;; Latest is 0.13.0, but this version is required for scala-jsonnew
298-
(define-public scala-jawn
98+
(define-public scala
29999
  (package
300-
    (name "scala-jawn")
301-
    (version "0.10.4")
100+
    (inherit %binary-scala)
302101
    (source (origin
303-
              (method url-fetch)
304-
              (uri (string-append "https://github.com/non/jawn/archive/v"
305-
                                  version ".tar.gz"))
306-
              (file-name (string-append name "-" version ".tar.gz"))
102+
              (method git-fetch)
103+
              (uri (git-reference
104+
                     (url "https://github.com/scala/scala")
105+
                     (commit (string-append "v" (package-version %binary-scala)))))
106+
              (file-name (git-file-name "scala" (package-version %binary-scala)))
307107
              (sha256
308108
               (base32
309-
                "1iic1rp7w7vsy0xhi40rcp339vcq5b4b46f51qrkfpv433f7hafi"))))
109+
                "1gl156n6nd4xnq3cb6f1bbfbb9s4cp6bd9xczl99plpx6jwnpmhl"))))
310110
    (build-system ant-build-system)
311111
    (arguments
312112
     `(#:tests? #f
313113
       #:phases
314114
       (modify-phases %standard-phases
315115
         (replace 'build
316-
           (lambda _
317-
             (mkdir-p "build/classes")
318-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
319-
                    "-d" "build/classes"
320-
                    (find-files "util/src/main/scala" ".*.scala$"))
321-
             (mkdir-p "build/jar")
322-
             (invoke "jar" "-cf" "build/jar/jawn-util.jar"
323-
                     "-C" "build/classes" ".")
324-
             (delete-file-recursively "build/classes")
325-
             (setenv "CLASSPATH" (string-append (getenv "CLASSPATH") ":build/jar/scalajson-shared.jar"))
326-
             (mkdir-p "build/classes")
327-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
328-
                    "-d" "build/classes"
329-
                    (find-files "parser/src/main/scala" ".*.scala$"))
330-
             (mkdir-p "build/jar")
331-
             (invoke "jar" "-cf" "build/jar/jawn-parser.jar"
332-
                     "-C" "build/classes" ".")
333-
             #t))
334-
         (replace 'install
335-
           (install-jars "build")))))
336-
    (native-inputs
337-
     `(("scala" ,scala-official)))
338-
    (home-page "")
339-
    (synopsis "")
340-
    (description "")
341-
    (license license:bsd-3)))
116+
           (lambda* (#:key inputs #:allow-other-keys)
117+
             (define* (build-project directory jar-name name #:optional (jar? #t))
118+
               (let* ((build-dir (string-append "build/class/" name))
119+
                      (java-files (find-files directory ".*.java$"))
120+
                      (scala-files (find-files directory ".*.scala$")))
121+
                 (mkdir-p build-dir)
122+
                 (format #t "Building project ~a...~%" name)
123+
                 (with-output-to-file (string-append build-dir "/" name ".properties")
124+
                   (lambda _
125+
                     (format #t "version.number=~a~%" ,(package-version this-package))
126+
                     (format #t "maven.version.number=~a~%" ,(package-version this-package))))
127+
                 (unless (eq? scala-files '())
128+
                   (apply invoke "scalac" "-classpath"
129+
                          (string-append
130+
                            ;; Add any top-level directory in build that may contain
131+
                            ;; .class files, but don't actually add build/ iteself or
132+
                            ;; any individual class file.
133+
                            (string-join
134+
                              (filter (lambda (s) (eq? (string-count s #\/) 2))
135+
                                      (find-files "build/class" "." #:directories? #t))
136+
                              ":"))
137+
                          "-d" build-dir "-nobootcp"
138+
                          (append scala-files java-files)))
139+
                 (unless (eq? java-files '())
140+
                   (apply invoke "javac" "-classpath"
141+
                          (string-append
142+
                            (getenv "CLASSPATH") ":"
143+
                            (string-join
144+
                              (filter (lambda (s) (eq? (string-count s #\/) 2))
145+
                                      (find-files "build/class" "." #:directories? #t))
146+
                              ":"))
147+
                          "-g" "-source" "1.8" "-target" "1.8"
148+
                          "-d" build-dir java-files))
149+
                 (mkdir-p "build/jar")
150+
                 (when jar?
151+
                   (invoke "jar" "cf" (string-append "build/jar/" jar-name)
152+
                           "-C" build-dir "."))))
342153
343-
(define-public scala-sjsonnew-support-scalajson
344-
  (package
345-
    (inherit scala-sjsonnew)
346-
    (name "scala-sjsonnew-support-scalajson")
347-
    (arguments
348-
     `(#:tests? #f
349-
       #:phases
350-
       (modify-phases %standard-phases
351-
         (replace 'build
352-
           (lambda _
353-
             (substitute* (find-files "." ".*.scala")
354-
               (("shaded.scalajson") "scalajson"))
355-
             (mkdir-p "build/classes")
356-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
357-
                    "-d" "build/classes"
358-
                    (find-files "support/scalajson/src/main/scala" ".*.scala$"))
359-
             (mkdir-p "build/jar")
360-
             (invoke "jar" "-cf" "build/jar/sjsonnew-support-scalajson.jar"
361-
                     "-C" "build/classes" ".")
362-
             #t))
363-
         (replace 'install
364-
           (install-jars "build")))))
365-
    (inputs
366-
     `(("scala-sjsonnew" ,scala-sjsonnew)
367-
       ("scala-scalajson" ,scala-scalajson)
368-
       ("scala-jawn" ,scala-jawn)))))
154+
             (let ((scala-asm (assoc-ref inputs "scala-asm")))
155+
               (setenv "CLASSPATH" (string-join (find-files scala-asm ".*.jar$") ":")))
156+
             (setenv "JAVA_OPTS" "-Xmx1G")
157+
             (build-project "src/library" "scala-library.jar" "library")
158+
             (build-project "src/reflect" "scala-reflect.jar" "reflect")
159+
             (build-project "src/compiler" "scala-compiler.jar" "compiler" #f)
160+
             (build-project "src/interactive" "scala-compiler-interactive.jar" "interactive" #f)
161+
             (build-project "src/scaladoc" "scala-compiler-doc.jar" "scaladoc" #f)
162+
             (build-project "src/repl" "scala-repl.jar" "repl" #f)
163+
             (build-project "src/repl-frontend" "scala-repl-frontend.jar" "replFrontend" #f)
164+
             (build-project "src/scalap" "scalap.jar" "scalap")
369165
370-
(define-public scala-sjsonnew-support-murmurhash
371-
  (package
372-
    (inherit scala-sjsonnew)
373-
    (name "scala-sjsonnew-support-murmurhash")
374-
    (arguments
375-
     `(#:tests? #f
376-
       #:phases
377-
       (modify-phases %standard-phases
378-
         (replace 'build
379-
           (lambda _
380-
             (mkdir-p "build/classes")
381-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
382-
                    "-d" "build/classes"
383-
                    (find-files "support/murmurhash/src/main/scala" ".*.scala$"))
384-
             (mkdir-p "build/jar")
385-
             (invoke "jar" "-cf" "build/jar/sjsonnew-support-murmurhash.jar"
386-
                     "-C" "build/classes" ".")
387-
             #t))
166+
             ;; create scala-compiler.jar as a union of some of those above
167+
             (mkdir-p "build/class/scala-compiler")
168+
             (with-directory-excursion "build/class/scala-compiler"
169+
               (let ((scala-asm (assoc-ref inputs "scala-asm")))
170+
                 (invoke "jar" "xf" (car (find-files scala-asm ".*.jar$"))))
171+
               (copy-recursively "../compiler" ".")
172+
               (copy-recursively "../interactive" ".")
173+
               (copy-recursively "../scaladoc" ".")
174+
               (copy-recursively "../repl" ".")
175+
               (copy-recursively "../replFrontend" "."))
176+
             (invoke "jar" "cf" "build/jar/scala-compiler.jar"
177+
                     "-C" "build/class/scala-compiler" ".")))
388178
         (replace 'install
389-
           (install-jars "build")))))
179+
           (lambda* (#:key inputs outputs #:allow-other-keys)
180+
             (let* ((out (assoc-ref outputs "out"))
181+
                    (lib (string-append out "/lib"))
182+
                    (jna (assoc-ref inputs "java-native-access"))
183+
                    (jline-terminal (assoc-ref inputs "java-jline3-terminal"))
184+
                    (jline-reader (assoc-ref inputs "java-jline3-reader")))
185+
               (mkdir-p lib)
186+
               (for-each
187+
                 (lambda (jar)
188+
                   (copy-file jar (string-append lib "/" (basename jar))))
189+
                 (find-files "build/jar" ".*.jar$"))
190+
               (symlink (car (find-files jna "linux-.*.jar$"))
191+
                        (string-append lib "/jna-lib.jar"))
192+
               (symlink (car (find-files jna "jna.jar$"))
193+
                        (string-append lib "/jna.jar"))
194+
               (symlink (car (find-files jline-reader ".*.jar$"))
195+
                        (string-append lib "/jline-reader.jar"))
196+
               (symlink (car (find-files jline-terminal ".*.jar$"))
197+
                        (string-append lib "/jline-terminal.jar")))))
198+
         (add-after 'install 'install-bin
199+
           (lambda* (#:key outputs #:allow-other-keys)
200+
             (let* ((out (assoc-ref outputs "out"))
201+
                    (bin (string-append out "/bin")))
202+
               (define (install-script script class)
203+
                 (let ((script (string-append bin "/" script)))
204+
                   (copy-file "src/compiler/templates/tool-unix.tmpl" script)
205+
                   ;; See project/ScalaTool and build.sbt
206+
                   (substitute* script
207+
                     (("@@") "@")
208+
                     (("@class@") class)
209+
                     (("@properties@") "-Dscala.home=\"$SCALA_HOME\"")
210+
                     (("@javaflags@") "-Xmx256M -Xms32M")
211+
                     (("@toolflags@") "")
212+
                     (("@classpath@") ""))
213+
                   (chmod script #o755)))
214+
               (mkdir-p bin)
215+
               (install-script "scala" "scala.tools.nsc.MainGenericRunner")
216+
               (install-script "scalac" "scala.tools.nsc.Main")
217+
               (install-script "fsc" "scala.tools.nsc.fsc.CompileClient")
218+
               (install-script "scaladoc" "scala.tools.nsc.ScalaDoc")
219+
               (install-script "scalap" "scala.tools.scalap.Main")))))))
390220
    (inputs
391-
     `(("scala-sjsonnew" ,scala-sjsonnew)))))
221+
     `(("scala" ,%binary-scala)
222+
       ("scala-asm" ,scala-asm)
223+
       ("java-jline3-terminal" ,java-jline3-terminal)
224+
       ("java-jline3-reader" ,java-jline3-reader)
225+
       ("java-native-access" ,java-native-access)))))
392226
393-
(define-public scala-kind-projector
227+
(define-public sbt-ivy
394228
  (package
395-
    (name "scala-kind-projector")
396-
    (version "0.9.9")
229+
    (inherit java-apache-ivy)
230+
    (name "sbt-ivy")
231+
    (version "2.4.0-rc1")
397232
    (source (origin
398-
              (method url-fetch)
399-
              (uri (string-append "https://github.com/non/kind-projector/archive/v"
400-
                                  version ".tar.gz"))
401-
              (file-name (string-append name "-" version ".tar.gz"))
233+
              (method git-fetch)
234+
              (uri (git-reference
235+
                     (url "https://github.com/sbt/ivy")
236+
                     (commit version)))
237+
              (file-name (git-file-name name version))
402238
              (sha256
403239
               (base32
404-
                "125amrhy7ri0z4bk2jzghg7341fm88a0p6gw3qg5diminlpaida3"))))
405-
    (build-system ant-build-system)
240+
                "1i13iqq8r4lqkxhg9gc192874hs3wyxykyg64m98vydf5zddb5zd"))
241+
              (modules '((guix build utils)))
242+
              (snippet
243+
               ; these jars are not build products, but they interfere with the
244+
               ; ant-build-system, and we don't run the tests anyway.
245+
               `(delete-file-recursively "test"))
246+
              (patches
247+
                (search-patches "sbt-ivy-fix-bouncycastle-api.patch"))))
406248
    (arguments
407-
     `(#:phases
408-
       (modify-phases %standard-phases
409-
         (replace 'build
410-
           (lambda _
411-
             (mkdir-p "build/classes")
412-
             (mkdir-p "build/jar")
413-
             (copy-recursively "src/main/resources" "build/classes")
414-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
415-
                    "-d" "build/classes"
416-
                    (find-files "src/main/scala" ".*.scala$"))
417-
             (invoke "jar" "-cf" "build/jar/kind-projector.jar"
418-
                     "-C" "build/classes" ".")
419-
             #t))
420-
         (replace 'check
421-
           (lambda _
422-
             (mkdir-p "build/test-classes")
423-
             (copy-recursively "src/test/resources" "build/test-classes")
424-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
425-
                    "-Xplugin:build/jar/kind-projector.jar"
426-
                    "-d" "build/test-classes"
427-
                    (find-files "src/test/scala" ".*.scala$"))
428-
             ;; TODO: actually run the tests... :D
429-
             #t))
430-
         (replace 'install
431-
           (install-jars "build")))))
432-
    (native-inputs
433-
     `(("scala-official" ,scala-official)
434-
       ("java-junit" ,java-junit)))
435-
    (home-page "https://github.com/non/kind-projector")
436-
    (synopsis "Scala compiler plugin for type lambda")
437-
    (description "Kind projector is a Scala compiler plugin for making type
438-
lambdas (type projections) easier to write.")
439-
    (license license:expat)))
249+
     (substitute-keyword-arguments (package-arguments java-apache-ivy)
250+
       ((#:phases phases)
251+
        `(modify-phases ,phases
252+
           (add-after 'unpack 'make-writable
253+
             (lambda _
254+
               (for-each make-file-writable (find-files "."))
255+
               #t))))))))
440256
441-
(define-public sbt-util
442-
  (package
443-
    (name "sbt-util")
444-
    (version "1.2.4")
445-
    (source
446-
      (origin
447-
        (method url-fetch)
448-
        (uri (string-append "https://github.com/sbt/util/archive/v"
449-
                            version ".tar.gz"))
450-
        (file-name (string-append "sbt-util-" version ".tar.gz"))
451-
        (sha256
452-
         (base32
453-
          "04ss1q4rl272ryxys05zmd4j2gm3aanaiqn6dmqbh6jii934pyxg"))))
454-
    (build-system ant-build-system)
455-
    (arguments
456-
     `(#:tests? #f
457-
       #:phases
458-
       (modify-phases %standard-phases
459-
         (add-before 'build 'fix-sjsonnew
460-
           (lambda _
461-
             (substitute* (find-files "." ".*.scala")
462-
               (("sjsonnew.shaded.") ""))
463-
             #t))
464-
         (replace 'build
465-
           ,(sbt-building-phase
466-
              '(("internal/" "util-position")
467-
                ("internal/" "util-control")
468-
                ("internal/" "util-interface")
469-
                ("internal/" "util-logging")
470-
                ("internal/" "util-relation")
471-
                ("internal/" "util-scripted")
472-
                ("" "util-cache")
473-
                ("" "util-tracking"))))
474-
         (replace 'install
475-
           (install-jars ".")))))
476-
    (inputs
477-
     `(("java-log4j-api" ,java-log4j-api-for-sbt)
478-
       ("java-log4j-core" ,java-log4j-core-for-sbt)
479-
       ("sbt-io" ,sbt-io)
480-
       ("scala-jawn" ,scala-jawn)
481-
       ("scala-scalajson" ,scala-scalajson)
482-
       ("scala-sjsonnew" ,scala-sjsonnew)
483-
       ("scala-sjsonnew-support-murmurhash" ,scala-sjsonnew-support-murmurhash)
484-
       ("scala-sjsonnew-support-scalajson" ,scala-sjsonnew-support-scalajson)))
485-
    (native-inputs
486-
     `(("scala" ,scala-official)))
487-
    (home-page "https://www.scala-sbt.org/")
488-
    (synopsis "")
489-
    (description "")
490-
    (license license:bsd-3)))
257+
(define %default-java-locations
258+
  '("shared/src/main/java" "jvm/src/main/java" "src/main/java"))
491259
492-
(define-public java-log4j-api-for-sbt
493-
  (package
494-
    (inherit java-log4j-api)
495-
    (version "2.8.1")
496-
    ;(version "2.11.1")
497-
    (arguments
498-
     (ensure-keyword-arguments (package-arguments java-log4j-api)
499-
       `(#:source-dir "src/main/java"
500-
         #:phases
501-
         (modify-phases %standard-phases
502-
           (add-after 'unpack 'chdir
503-
             (lambda _
504-
               (chdir "log4j-api")
505-
               #t))
506-
           (add-before 'build 'fix-ambiguous
507-
             (lambda _
508-
               (substitute* "src/main/java/org/apache/logging/log4j/message/MapMessage.java"
509-
                 (("append\\(data") "append((CharSequence)data"))
510-
               #t))))))
511-
    (source (origin
512-
              (method url-fetch)
513-
              (uri (string-append "mirror://apache/logging/log4j/" version
514-
                                  "/apache-log4j-" version "-src.tar.gz"))
515-
              (sha256
516-
               (base32
517-
                "0x5gksgh0jkvd7k70rqrs2hy3glms0pkj6lhl26m6f83x1b6kvdm"))))))
518-
                ;"1dhxnd0348is21w93m1rv2sbfwyx83rv63adnbd0bgjq01gzbvic"))))))
260+
(define %default-scala-locations
261+
  '("shared/src/main/scala" "jvm/src/main/scala" "src/main/scala"))
519262
520-
;; More dependencies needed
521-
(define-public java-log4j-core-for-sbt
522-
  (package
523-
    (inherit java-log4j-api-for-sbt)
524-
    (name "java-log4j-core")
525-
    (inputs
526-
     `(("java-osgi-core" ,java-osgi-core)
527-
       ("java-hamcrest-core" ,java-hamcrest-core)
528-
       ("java-log4j-api" ,java-log4j-api-for-sbt)
529-
       ("java-mail" ,java-mail)
530-
       ("java-jansi" ,java-jansi)
531-
       ("java-jboss-jms-api-spec" ,java-jboss-jms-api-spec)
532-
       ("java-jctools-core" ,java-jctools-core)
533-
       ("java-lmax-disruptor" ,java-lmax-disruptor)
534-
       ("java-kafka" ,java-kafka-clients)
535-
       ("java-datanucleus-javax-persistence" ,java-datanucleus-javax-persistence)
536-
       ("java-fasterxml-jackson-annotations" ,java-fasterxml-jackson-annotations)
537-
       ("java-fasterxml-jackson-core" ,java-fasterxml-jackson-core)
538-
       ("java-fasterxml-jackson-databind" ,java-fasterxml-jackson-databind)
539-
       ("java-fasterxml-jackson-dataformat-xml" ,java-fasterxml-jackson-dataformat-xml)
540-
       ("java-fasterxml-jackson-dataformat-yaml" ,java-fasterxml-jackson-dataformat-yaml)
541-
       ("java-commons-compress" ,java-commons-compress)
542-
       ("java-commons-csv" ,java-commons-csv)
543-
       ("java-conversantmedia-disruptor" ,java-conversantmedia-disruptor)
544-
       ("java-jcommander" ,java-jcommander)
545-
       ("java-stax2-api" ,java-stax2-api)
546-
       ("java-jeromq" ,java-jeromq)
547-
       ("java-junit" ,java-junit)))
548-
    (native-inputs
549-
     `(("hamcrest" ,java-hamcrest-all)
550-
       ("java-commons-io" ,java-commons-io)
551-
       ("java-commons-lang3" ,java-commons-lang3)
552-
       ("slf4j" ,java-slf4j-api)))
553-
    (arguments
554-
     `(#:tests? #f ; tests require more dependencies
555-
       #:test-dir "src/test"
556-
       #:source-dir "src/main/java"
557-
       #:jar-name "log4j-core.jar"
558-
       #:make-flags
559-
       (list (string-append "-Ddist.dir=" (assoc-ref %outputs "out")
560-
                            "/share/java"))
561-
       #:phases
562-
       (modify-phases %standard-phases
563-
         (add-after 'unpack 'enter-dir
564-
           (lambda _ (chdir "log4j-core") #t))
565-
         (add-before 'build 'fix-ambiguous
566-
           (lambda _
567-
             (substitute* "src/main/java/org/apache/logging/log4j/core/pattern/MapPatternConverter.java"
568-
               (("append\\(sortedMap") "append((CharSequence)sortedMap"))
569-
             #t)))))
570-
    (synopsis "Core component of the Log4j framework")
571-
    (description "This package provides the core component of the Log4j
572-
logging framework for Java.")))
263+
(define %default-resources-locations
264+
  '("shared/src/main/resources" "jvm/src/main/resources" "src/main/resources"))
573265
266+
;; TODO: put it in guix/build/java-utils.scm
267+
(define* (build-scala-phase spec
268+
                            #:key (scala-arguments '())
269+
                                  (java-locations %default-java-locations)
270+
                                  (scala-locations %default-scala-locations)
271+
                                  (resources-locations %default-resources-locations))
272+
  `(lambda* (#:key inputs #:allow-other-keys)
273+
     (define (get-files directory expr)
274+
       (if (file-exists? directory)
275+
           (find-files directory expr)
276+
           '()))
277+
278+
     (define (build-scala directory name)
279+
       (let* ((build-directory (string-append (getcwd) "/build"))
280+
              (current-build-directory (string-append build-directory "/" name))
281+
              (jar-name (string-append name ".jar"))
282+
              (manifest (string-append current-build-directory "/META-INF/MANIFEST.MF"))
283+
              (classpath
284+
                ;; Add any top-level directory in build that may contain
285+
                ;; .class files, but don't actually add build/ iteself or
286+
                ;; any individual class file.
287+
                (string-join
288+
                  (map
289+
                    (lambda (s) (string-append (getcwd) "/" s))
290+
                    (filter
291+
                      (lambda (s) (eq? (string-count s #\/) 1))
292+
                      (find-files "build" "." #:directories? #t)))
293+
                  ":")))
294+
           (mkdir-p current-build-directory)
295+
           (with-directory-excursion directory
296+
             (let ((java-files
297+
                     (apply append
298+
                            (map (lambda (loc) (get-files loc "\\.java$"))
299+
                                 ',java-locations)))
300+
                   (scala-files
301+
                     (apply append
302+
                            (map (lambda (loc) (get-files loc "\\.scala$"))
303+
                                 ',scala-locations))))
304+
               (format #t "Building project ~a...~%" jar-name)
305+
               (unless (eq? scala-files '())
306+
                 (apply invoke "scalac" "-classpath"
307+
                        (string-append
308+
                          (getenv "CLASSPATH") ":"
309+
                          classpath)
310+
                        "-d" current-build-directory ,@scala-arguments
311+
                        (append scala-files java-files)))
312+
               (unless (eq? java-files '())
313+
                 (apply invoke "javac" "-classpath"
314+
                        (string-append
315+
                          (getenv "CLASSPATH") ":"
316+
                          classpath)
317+
                        "-d" current-build-directory java-files)))
318+
             (for-each
319+
               (lambda (dir)
320+
                 (when (file-exists? dir)
321+
                   (copy-recursively dir current-build-directory)))
322+
               ',resources-locations))
323+
           (if (file-exists? manifest)
324+
             (invoke "jar" "cfm" (string-append "build/jar/" jar-name)
325+
                     manifest "-C" current-build-directory ".")
326+
             (invoke "jar" "cf" (string-append "build/jar/" jar-name)
327+
                     "-C" current-build-directory "."))))
328+
329+
     (mkdir-p "build/jar")
330+
     (for-each
331+
       (lambda (s)
332+
         (apply build-scala s))
333+
       ',spec)))
574334
575-
;; TODO: Update to 2.0.6?
576-
(define-public java-swoval-apple-file-events
335+
(define-public scala-data-class
577336
  (package
578-
    (name "java-swoval-apple-file-events")
579-
    (version "1.3.2")
337+
    (name "scala-data-class")
338+
    (version "0.2.5")
580339
    (source (origin
581-
              (method url-fetch)
582-
              (uri (string-append "https://github.com/swoval/swoval/archive/v"
583-
                                  version ".tar.gz"))
584-
              (file-name (string-append "scala-swoval-" version ".tar.gz"))
340+
              (method git-fetch)
341+
              (uri (git-reference
342+
                     (url "https://github.com/alexarchambault/data-class")
343+
                     (commit (string-append "v" version))))
344+
              (file-name (git-file-name name version))
585345
              (sha256
586346
               (base32
587-
                "0ivrc4lcali84xp8frkjb2zi1l3lw8pim9xbkfah5iyj120gw6mq"))))
588-
    (build-system ant-build-system)
589-
    (arguments
590-
     `(#:tests? #f; no tests
591-
       #:jar-name "apple-file-events.jar"
592-
       #:source-dir "apple-file-events/jvm/src/main/java"))
593-
    (home-page "")
594-
    (synopsis "")
595-
    (description "")
596-
    (license license:expat)))
597-
598-
(define-public sbt-io
599-
  (package
600-
    (name "sbt-io")
601-
    (version "1.2.2")
602-
    (source
603-
      (origin
604-
        (method url-fetch)
605-
        (uri (string-append "https://github.com/sbt/io/archive/v"
606-
                            version ".tar.gz"))
607-
        (file-name (string-append name "-" version ".tar.gz"))
608-
        (sha256
609-
         (base32
610-
          "0f9yjrrcr15kx2fn7w8f8swpx2dsx5zn95yg744l9gi2ri2qpyj5"))))
347+
                "10csh0gc0snd8xpxmx8pad1rgci1i8xjhbfcx02njiy2vh4x5lh3"))))
611348
    (build-system ant-build-system)
612349
    (arguments
613350
     `(#:tests? #f
614351
       #:phases
615352
       (modify-phases %standard-phases
616353
         (replace 'build
617-
           (lambda* (#:key inputs #:allow-other-keys)
618-
             (mkdir-p "build/classes")
619-
             (apply invoke "scalac" "-classpath"
620-
                    (string-append (getenv "CLASSPATH") ":build/util-interface")
621-
                    "-d" "build/classes"
622-
                    (append
623-
                      (find-files "io/src/main/java" ".*.java$")
624-
                      (find-files "io/src/main/scala" ".*.scala$")
625-
                      (find-files "io/src/main/contraband-scala" ".*.scala$")))
626-
             (invoke "jar" "cf" "sbt-io.jar" "-C" "build/classes" ".")
627-
             #t))
354+
           ,(build-scala-phase '(("." "data-class"))
355+
              #:scala-arguments '("-Ymacro-annotations")))
628356
         (replace 'install
629-
           (install-jars ".")))))
630-
    (inputs
631-
     `(("java-native-access" ,java-native-access)
632-
       ("java-native-access-platform" ,java-native-access-platform)
633-
       ("java-swoval-apple-file-events" ,java-swoval-apple-file-events)
634-
       ("scala" ,scala-official)))
635-
    (home-page "https://www.scala-sbt.org/")
357+
           (install-jars "build")))))
358+
    (native-inputs
359+
     `(("scala" ,scala)))
360+
    (home-page "")
636361
    (synopsis "")
637362
    (description "")
638-
    (license license:bsd-3)))
363+
    (license license:asl2.0)))
639364
640-
(define-public scala-ssl-config
365+
(define-public scala-xml
641366
  (package
642-
    (name "scala-ssl-config")
643-
    (version "0.4.0")
367+
    (name "scala-xml")
368+
    (version "2.0.0")
644369
    (source (origin
645-
              (method url-fetch)
646-
              (uri (string-append "https://github.com/lightbend/ssl-config/archive/v"
647-
                                  version ".tar.gz"))
648-
              (file-name (string-append name "-" version ".tar.gz"))
370+
              (method git-fetch)
371+
              (uri (git-reference
372+
                     (url "https://github.com/scala/scala-xml")
373+
                     (commit (string-append "v" version))))
374+
              (file-name (git-file-name name version))
649375
              (sha256
650376
               (base32
651-
                "0gqglz1a43f75giz0ibvk0jvr7dlpjyk5575sidalmhllhnpd631"))))
377+
                "16nw209dwj82mn0jc3ax77jmg0jqvvbc8wdwc7kaq3102k1wdv73"))))
652378
    (build-system ant-build-system)
653379
    (arguments
654380
     `(#:tests? #f
655381
       #:phases
656382
       (modify-phases %standard-phases
657-
         (replace 'build
658-
           (lambda* (#:key inputs #:allow-other-keys)
659-
             (mkdir-p "build/classes")
660-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
661-
                    "-d" "build/classes"
662-
                    (find-files "ssl-config-core/src/main/scala" ".*.scala$"))
663-
             (invoke "jar" "cf" "okhttp.jar" "-C" "build/classes" ".")
383+
         (add-after 'unpack 'move-version-specific
384+
           (lambda _
385+
             (copy-file "shared/src/main/scala-2.13+/scala/xml/ScalaVersionSpecific.scala"
386+
                        "shared/src/main/scala/scala/xml/ScalaVersionSpecific.scala")
664387
             #t))
388+
         (replace 'build
389+
           ,(build-scala-phase '(("." "scala-xml"))))
665390
         (replace 'install
666-
           (install-jars ".")))))
667-
    (inputs
668-
     `(("java-config" ,java-config)))
391+
           (install-jars "build")))))
669392
    (native-inputs
670-
     `(("scala" ,scala-official)))
393+
     `(("scala" ,scala)))
671394
    (home-page "")
672395
    (synopsis "")
673396
    (description "")
674397
    (license license:asl2.0)))
675398
676-
(define-public scala-okhttp
399+
(define-public scala-simulacrum
677400
  (package
678-
    (name "scala-okhttp")
679-
    (version "0.3.1")
401+
    (name "scala-simulacrum")
402+
    (version "1.0.1")
680403
    (source (origin
681-
              (method url-fetch)
682-
              (uri (string-append "https://github.com/eed3si9n/gigahorse/archive/v"
683-
                                  version ".tar.gz"))
684-
              (file-name (string-append name "-" version ".tar.gz"))
404+
              (method git-fetch)
405+
              (uri (git-reference
406+
                     (url "https://github.com/typelevel/simulacrum")
407+
                     (commit (string-append "v" version))))
408+
              (file-name (git-file-name name version))
685409
              (sha256
686410
               (base32
687-
                "06ac03vr0cyr63zw0ibdwmswa03crm6i8mb00y69zpkm2jxqq2mb"))))
411+
                "1a4yrv9x6vb989385m0rmb7y6lcd8b7lcq5ksp37k70dl3piam4z"))))
688412
    (build-system ant-build-system)
689413
    (arguments
690414
     `(#:tests? #f
691415
       #:phases
692416
       (modify-phases %standard-phases
693417
         (replace 'build
694-
           (lambda* (#:key inputs #:allow-other-keys)
695-
             (mkdir-p "build/classes")
696-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
697-
                    "-d" "build/classes"
698-
                    (append
699-
                      (find-files "core/src/main/scala" ".*.scala$")
700-
                      (find-files "okhttp/src/main/scala" ".*.scala$")
701-
                      (find-files "core/src/main/contraband-scala" ".*.scala$")))
702-
             (invoke "jar" "cf" "okhttp.jar" "-C" "build/classes" ".")
703-
             #t))
418+
           ,(build-scala-phase
419+
              '(("core" "simulacrum"))
420+
               #:scala-arguments
421+
               '("-Ymacro-annotations" "-deprecation" "-feature"
422+
                 "-language:higherKinds" "-language:implicitConversions")))
704423
         (replace 'install
705-
           (install-jars ".")))))
706-
    (inputs
707-
     `(("java-config" ,java-config)
708-
       ("java-reactive-streams" ,java-reactive-streams)
709-
       ("java-slf4j-api" ,java-slf4j-api)
710-
       ("java-okhttp" ,java-okhttp)
711-
       ("java-okio" ,java-okio)
712-
       ("scala-ssl-config" ,scala-ssl-config)))
424+
           (install-jars "build")))))
713425
    (native-inputs
714-
     `(("scala" ,scala-official)))
426+
     `(("scala" ,scala)))
715427
    (home-page "")
716428
    (synopsis "")
717429
    (description "")
718430
    (license license:asl2.0)))
719431
720-
(define-public sbt-launcher
432+
(define-public scala-geny
721433
  (package
722-
    (name "sbt-launcher")
723-
    (version "1.0.4")
434+
    (name "scala-geny")
435+
    (version "0.6.10")
724436
    (source (origin
725-
              (method url-fetch)
726-
              (uri (string-append "https://github.com/sbt/launcher/archive/v" version ".tar.gz"))
727-
              (file-name (string-append name "-" version ".tar.gz"))
437+
              (method git-fetch)
438+
              (uri (git-reference
439+
                     (url "https://github.com/com-lihaoyi/geny")
440+
                     (commit version)))
441+
              (file-name (git-file-name name version))
728442
              (sha256
729443
               (base32
730-
                "1a9dfqm47fn2nbqvjl723s0h16jf71cgnilg1i7gz6h4a7i0snak"))))
444+
                "1km1xpvyy14ipgv019axg31vd9csnsi54cp8sw9mzdjikh6i211f"))))
731445
    (build-system ant-build-system)
732446
    (arguments
733447
     `(#:tests? #f
734448
       #:phases
735449
       (modify-phases %standard-phases
736450
         (replace 'build
737-
           (lambda* (#:key inputs #:allow-other-keys)
738-
             (define (split n str)
739-
               (if (<= (string-length str) n)
740-
                 (list str)
741-
                 (cons (substring str 0 n) (split n (substring str n)))))
742-
             (substitute* "launcher-implementation/src/main/input_sources/CrossVersionUtil.scala"
743-
               (("\\$\\{\\{cross.package0\\}\\}") "xsbt")
744-
               (("\\$\\{\\{cross.package1\\}\\}") "boot"))
745-
             (mkdir-p "build/classes")
746-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
747-
                    "-d" "build/classes"
748-
                    (append
749-
                      (find-files "launcher-interface/src/main/java" ".*.java$")
750-
                      (find-files "launcher-implementation/src/main/input_sources" ".*.scala$")
751-
                      (find-files "launcher-implementation/src/main/scala" ".*.scala$")))
752-
             (apply invoke "javac" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
753-
                    "-d" "build/classes"
754-
                    (find-files "launcher-interface/src/main/java" ".*.java$"))
755-
             (mkdir-p "build/classes/META-INF")
756-
             (with-output-to-file "build/classes/META-INF/MANIFEST.MF"
757-
               (lambda _
758-
                 (format #t "Manifest-Version: 1.0\n")
759-
                 (format #t "Class-Path: ~a\n"
760-
                         (string-join
761-
                           (split
762-
                             58
763-
                             (string-join
764-
                               (map
765-
                                 (lambda (jar)
766-
                                   ;; We can't use absolute paths with java 8 :/
767-
                                   (string-append "../../../../../../../../.." jar))
768-
                                 (string-split (getenv "CLASSPATH") #\:))
769-
                               " "))
770-
                            "\n "))
771-
                 (format #t "Main-Class: xsbt.boot.Boot\n\n")))
772-
             (invoke "jar" "cfm" "sbt-launcher.jar" "build/classes/META-INF/MANIFEST.MF"
773-
                     "-C" "build/classes" ".")
774-
             #t))
451+
           ,(build-scala-phase '(("geny" "scala-geny"))
452+
              #:scala-locations '("src")
453+
              #:java-locations '("src")))
775454
         (replace 'install
776-
           (install-jars ".")))))
777-
    (inputs
778-
     `(("java-apache-ivy" ,java-apache-ivy)))
455+
           (install-jars "build")))))
779456
    (native-inputs
780-
     `(("scala" ,scala-official)))
457+
     `(("scala" ,scala)))
781458
    (home-page "")
782459
    (synopsis "")
783460
    (description "")
784-
    (license license:bsd-3)))
461+
    (license license:asl2.0)))
785462
786-
(define-public sbt-librarymanagement
463+
(define-public scala-sourcecode
787464
  (package
788-
    (name "sbt-librarymanagement")
789-
    (version "1.2.4")
465+
    (name "scala-sourcecode")
466+
    (version "0.2.7")
790467
    (source (origin
791-
              (method url-fetch)
792-
              (uri (string-append "https://github.com/sbt/librarymanagement/archive/v" version ".tar.gz"))
793-
              (file-name (string-append name "-" version ".tar.gz"))
468+
              (method git-fetch)
469+
              (uri (git-reference
470+
                     (url "https://github.com/com-lihaoyi/sourcecode")
471+
                     (commit version)))
472+
              (file-name (git-file-name name version))
794473
              (sha256
795474
               (base32
796-
                "0g37agv3xkq1fjl9a25ybcdk4d5aq1m81rz5d2a8zvny135m73gl"))
797-
              (modules '((guix build utils)))
798-
              (snippet
799-
                `(begin
800-
                   (for-each delete-file (find-files "." ".*.jar"))
801-
                   #t))))
475+
                "11xd0a0svm15hcknpsfzsyl9sy7dc692b93i39j3z8mgrnh5x4di"))))
802476
    (build-system ant-build-system)
803477
    (arguments
804478
     `(#:tests? #f
805479
       #:phases
806480
       (modify-phases %standard-phases
807-
         (add-before 'build 'fix-sjsonnew
808-
           (lambda _
809-
             (substitute* (find-files "." ".*.scala")
810-
               (("sjsonnew.shaded.") ""))
811-
             #t))
812481
         (replace 'build
813-
           ,(sbt-building-phase
814-
              `(("" "core")
815-
                ("" "ivy"))))
482+
           ,(build-scala-phase '(("sourcecode" "scala-sourcecode"))
483+
              #:scala-locations '("src" "src-2")
484+
              #:java-locations '("src")))
816485
         (replace 'install
817-
           (install-jars ".")))))
818-
    (inputs
819-
     `(("java-apache-ivy" ,java-apache-ivy)
820-
       ("java-okhttp" ,java-okhttp)
821-
       ("java-okhttp-urlconnection" ,java-okhttp-urlconnection)
822-
       ("java-okio" ,java-okio)
823-
       ("sbt-launcher" ,sbt-launcher)
824-
       ("sbt-util" ,sbt-util)
825-
       ("sbt-io" ,sbt-io)
826-
       ("scala-jawn" ,scala-jawn)
827-
       ("scala-okhttp" ,scala-okhttp)
828-
       ("scala-scalajson" ,scala-scalajson)
829-
       ("scala-sjsonnew" ,scala-sjsonnew)
830-
       ("scala-sjsonnew-support-murmurhash" ,scala-sjsonnew-support-murmurhash)
831-
       ("scala-sjsonnew-support-scalajson" ,scala-sjsonnew-support-scalajson)))
486+
           (install-jars "build")))))
832487
    (native-inputs
833-
     `(("scala" ,scala-official)))
488+
     `(("scala" ,scala)))
834489
    (home-page "")
835490
    (synopsis "")
836491
    (description "")
837-
    ;; From core/NOTICE
838-
    ;; XXX: WARNING: no license in ivy/
839-
    (license license:bsd-2)))
492+
    (license license:asl2.0)))
840493
841-
;; LICENSE?
842-
(define-public scala-protoc-bridge
494+
(define-public scala-fastparse
843495
  (package
844-
    (name "scala-protoc-bridge")
845-
    (version "0.7.3")
846-
    (source
847-
      (origin
848-
        (method url-fetch)
849-
        (uri (string-append "https://github.com/scalapb/protoc-bridge/archive/v"
850-
                            version ".tar.gz"))
851-
        (file-name (string-append name "-" version ".tar.gz"))
852-
        (sha256
853-
         (base32
854-
          "17xjsa70h0w80rhps00kj42fmghk98c789aaa19g4bii2j1ckry8"))))
496+
    (name "scala-fastparse")
497+
    (version "2.3.2")
498+
    (source (origin
499+
              (method git-fetch)
500+
              (uri (git-reference
501+
                     (url "https://github.com/com-lihaoyi/fastparse")
502+
                     (commit version)))
503+
              (file-name (git-file-name name version))
504+
              (sha256
505+
               (base32
506+
                "04wqggkywfy3q733x18mi873wh23w1ix5kypradpz0njdyfznikh"))))
855507
    (build-system ant-build-system)
856508
    (arguments
857-
     `(#:phases
509+
     `(#:tests? #f
510+
       #:phases
858511
       (modify-phases %standard-phases
859-
         (add-before 'build 'fix-script
512+
         (add-after 'unpack 'generate-source
860513
           (lambda _
861-
             (substitute* "src/main/scala/protocbridge/frontend/PosixPluginFrontend.scala"
862-
               (("/usr/bin/env sh") (which "sh")))
514+
             ;; this file would be generated by build.sc, but it requires
515+
             ;; more dependencies
516+
             (with-output-to-file "fastparse/src/fastparse/SequencerGen.scala"
517+
               (lambda _
518+
                 (display "package fastparse
519+
trait SequencerGen[Sequencer[_, _, _]] extends LowestPriSequencer[Sequencer]{
520+
  protected[this] def Sequencer0[A, B, C](f: (A, B) => C): Sequencer[A, B, C]
521+
")
522+
                 (display
523+
                   (string-join
524+
                     (map
525+
                       (lambda (i)
526+
                         (let* ((ts (map
527+
                                      (lambda (n) (string-append "T" (number->string n)))
528+
                                      (iota i 1)))
529+
                                (chunks
530+
                                  (map
531+
                                    (lambda (n) (string-append "t._" (number->string n)))
532+
                                    (iota i 1)))
533+
                                (tsD (string-join
534+
                                       (append ts (list "D"))
535+
                                       ","))
536+
                                (anys (string-join
537+
                                        (map (lambda (t) "Any")
538+
                                             ts)
539+
                                        ", ")))
540+
                           (string-append
541+
                             "val BaseSequencer" (number->string i) ": Sequencer[(" anys "), Any, (" anys ", Any)] =
542+
  Sequencer0((t, d) => (" (string-join chunks ", ") ", d))
543+
implicit def Sequencer" (number->string i) "[" tsD "]: Sequencer[(" (string-join ts ", ") "), D, (" tsD ")] =
544+
  BaseSequencer" (number->string i) ".asInstanceOf[Sequencer[(" (string-join ts ", ") "), D, (" tsD ")]]
545+
")))
546+
                       (iota 20 2))
547+
                     "\n"))
548+
                 (display "}
549+
trait LowestPriSequencer[Sequencer[_, _, _]]{
550+
  protected[this] def Sequencer0[A, B, C](f: (A, B) => C): Sequencer[A, B, C]
551+
  implicit def Sequencer1[T1, T2]: Sequencer[T1, T2, (T1, T2)] = Sequencer0{case (t1, t2) => (t1, t2)}
552+
}
553+
")))
863554
             #t))
864555
         (replace 'build
865-
           (lambda _
866-
             (mkdir-p "build/classes")
867-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
868-
                    "-d" "build/classes"
869-
                    (append
870-
                      (find-files "src/main/scala" ".*.scala$")
871-
                      (find-files "src/main/java" ".*.java$")))
872-
             (apply invoke "javac" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
873-
                    "-d" "build/classes"
874-
                    (find-files "src/main/java" ".*.java$"))
875-
             (mkdir-p "build/jar")
876-
             (invoke "jar" "-cf" "build/jar/protoc-bridge.jar"
877-
                     "-C" "build/classes" ".")
878-
             #t))
879-
         (replace 'check
880-
           (lambda _
881-
             (mkdir-p "build/test-classes")
882-
             ;(apply invoke "scalac" "-classpath" (string-append (getenv "CLASSPATH")
883-
             ;                                                   ":build/classes")
884-
             ;       "-d" "build/test-classes"
885-
             ;       (find-files "src/test/scala" ".*.scala$"))
886-
             ;; TODO: actually run the tests
887-
             #t))
556+
           ,(build-scala-phase '(("fastparse" "scala-fastparse")
557+
                                 ("scalaparse" "scala-scalaparse"))
558+
              #:scala-locations '("src" "src-jvm")
559+
              #:java-locations '("src" "src-jvm")))
888560
         (replace 'install
889561
           (install-jars "build")))))
890562
    (native-inputs
891-
     `(("scala" ,scala-official)))
563+
     `(("scala" ,scala)))
564+
    (propagated-inputs
565+
     `(("scala-geny" ,scala-geny)
566+
       ("scala-sourcecode" ,scala-sourcecode)))
892567
    (home-page "")
893568
    (synopsis "")
894569
    (description "")
895-
    (license license:bsd-3)))
570+
    (license license:asl2.0)))
896571
897-
(define-public scala-sourcecode
572+
(define-public scala-dirs-dev-directories
898573
  (package
899-
    (name "scala-sourcecode")
900-
    (version "0.1.5")
574+
    (name "scala-dirs-dev-directories")
575+
    (version "23")
901576
    (source (origin
902-
              (method url-fetch)
903-
              (uri (string-append "https://github.com/lihaoyi/sourcecode/archive/v"
904-
                                  version ".tar.gz"))
905-
              (file-name (string-append name "-" version ".tar.gz"))
577+
              (method git-fetch)
578+
              (uri (git-reference
579+
                     (url "https://github.com/dirs-dev/directories-jvm")
580+
                     ;; exact version used by coursier
581+
                     (commit "7acadf2ab9a4ce306d840d652cdb77fade11b94b")))
582+
              (file-name (git-file-name name version))
906583
              (sha256
907584
               (base32
908-
                "1cq15cxsv0j6xdrl566ywmab5il3239ja4cbgm39ihyn0yw2q1q4"))))
585+
                "09h2dxzbkhki65kkkm29w7id0m0hgswsbwrbb2ix50yj297n6nbm"))))
909586
    (build-system ant-build-system)
910587
    (arguments
911-
     `(#:tests? #f; in sourcecode/shared/src/test
588+
     `(#:tests? #f
912589
       #:phases
913590
       (modify-phases %standard-phases
914-
         (add-before 'build 'copy-compat
915-
           (lambda _
916-
             (with-directory-excursion "sourcecode/shared/src/main"
917-
               (copy-file "scala-2.11/sourcecode/Compat.scala"
918-
                          "scala/sourcecode/Compat.scala"))
919-
             #t))
920591
         (replace 'build
921-
           (lambda _
922-
             (mkdir-p "build/classes")
923-
             (mkdir-p "build/jar")
924-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
925-
                    "-d" "build/classes"
926-
                    (find-files "sourcecode/shared/src/main/scala" ".*.scala$"))
927-
             (invoke "jar" "cf" "build/jar/sourcecode.jar" "-C" "build/classes" ".")
928-
             #t))
592+
           ,(build-scala-phase '(("." "scala-directories"))))
929593
         (replace 'install
930594
           (install-jars "build")))))
931595
    (native-inputs
932-
     `(("scala" ,scala-official)))
596+
     `(("scala" ,scala)))
933597
    (home-page "")
934598
    (synopsis "")
935599
    (description "")
936-
    (license license:expat)))
600+
    (license license:asl2.0)))
937601
938-
(define-public scala-acyclic
602+
(define-public scala-windowsansi
939603
  (package
940-
    (name "scala-acyclic")
941-
    (version "0.1.8")
604+
    (name "scala-windowsansi")
605+
    (version "0.0.3")
942606
    (source (origin
943-
              (method url-fetch)
944-
              (uri (string-append "https://github.com/lihaoyi/acyclic/archive/v"
945-
                                  version ".tar.gz"))
946-
              (file-name (string-append name "-" version ".tar.gz"))
607+
              (method git-fetch)
608+
              (uri (git-reference
609+
                     (url "https://github.com/alexarchambault/windows-ansi")
610+
                     (commit (string-append "v" version))))
611+
              (file-name (git-file-name name version))
947612
              (sha256
948613
               (base32
949-
                "0c26qnjfhihn06sf17bxskacjcr51s03ygcmj8fp5vdzgcyfh7dl"))))
614+
                "0r21yhxmwi71qx7qqrpk0z7ykcd08xs7fl6yhzwlqjl0kar7wq0m"))))
950615
    (build-system ant-build-system)
951616
    (arguments
952-
     `(#:tests? #f; in sourcecode/shared/src/test
617+
     `(#:tests? #f
953618
       #:phases
954619
       (modify-phases %standard-phases
955-
         (add-before 'build 'copy-compat
956-
           (lambda _
957-
             (with-directory-excursion "src/main"
958-
               (copy-file "scala-2.10_2.12/acyclic/plugin/Compat.scala"
959-
                          "scala/acyclic/plugin/Compat.scala"))
960-
             #t))
961620
         (replace 'build
621+
           ,(build-scala-phase '(("jni" "scala-windowsansi-jni")
622+
                                 ("ps" "scala-windowsansi-ps"))))
623+
         (add-after 'unpack 'remove-proprietary-interfaces
962624
           (lambda _
963-
             (mkdir-p "build/classes")
964-
             (mkdir-p "build/jar")
965-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
966-
                    "-d" "build/classes"
967-
                    (find-files "src/main/scala" ".*.scala$"))
968-
             (copy-recursively "src/main/resources" "build/classes")
969-
             (invoke "jar" "cf" "build/jar/acyclic.jar" "-C" "build/classes" ".")
970-
             #t))
625+
             (delete-file
626+
               "jni/src/main/java/io/github/alexarchambault/windowsansi/NativeImageFeature.java")
627+
             (delete-file
628+
               "jni/src/main/java/io/github/alexarchambault/windowsansi/WindowsAnsiSubstitutions.java")))
971629
         (replace 'install
972630
           (install-jars "build")))))
973631
    (native-inputs
974-
     `(("scala" ,scala-official)))
632+
     `(("scala" ,scala)))
633+
    (propagated-inputs
634+
     `(("java-jansi" ,java-jansi)))
975635
    (home-page "")
976636
    (synopsis "")
977637
    (description "")
978-
    (license license:expat)))
638+
    (license license:asl2.0)))
979639
980-
(define-public scala-fastparse
640+
(define-public scala-argonaut
981641
  (package
982-
    (name "scala-fastparse")
983-
    (version "2.1.0")
642+
    (name "scala-argonaut")
643+
    (version "6.3.3")
984644
    (source (origin
985-
              (method url-fetch)
986-
              (uri (string-append "https://github.com/lihaoyi/fastparse/archive/"
987-
                                  version ".tar.gz"))
988-
              (file-name (string-append name "-" version ".tar.gz"))
645+
              (method git-fetch)
646+
              (uri (git-reference
647+
                     (url "https://github.com/argonaut-io/argonaut")
648+
                     (commit (string-append "v" version))))
649+
              (file-name (git-file-name name version))
989650
              (sha256
990651
               (base32
991-
                "1h8s3izykv3x2g7klihk03mbnjcp23f2613827y62kdk6x9q6yjs"))))
652+
                "1pvc5jklaqqx957brkrwywvh5gsq08xd2k4c8bm4gnkd9b5n8wnl"))))
992653
    (build-system ant-build-system)
993654
    (arguments
994-
     `(#:tests? #f; in fastpares/test/src
995-
       #:modules
996-
       ((guix build ant-build-system)
997-
        (guix build java-utils)
998-
        (guix build utils)
999-
        (srfi srfi-1))
1000-
       #:imported-modules
1001-
       ((srfi srfi-1) ; for iota
1002-
        ,@%ant-build-system-modules)
655+
     `(#:tests? #f
1003656
       #:phases
1004657
       (modify-phases %standard-phases
1005658
         (add-before 'build 'generate-sources
1006659
           (lambda _
1007-
             (define (tuple num)
1008-
               (let* ((ts (map (lambda (n) (string-append "T" (number->string n)))
1009-
                               (iota num 1)))
1010-
                      (chunks (map (lambda (n)
1011-
                                     (string-append "t._" (number->string n)))
1012-
                                   (iota num 1)))
1013-
                      (chunkss (string-join chunks ", "))
1014-
                      (tsD (string-join (reverse (cons "D" (reverse ts))) ","))
1015-
                      (anys (string-join (map (const "Any") ts) ", "))
1016-
                      (tss (string-join ts ", ")))
660+
             ;; Converted from project/Boilerplate.scala
661+
             (define header "package argonaut\n\n")
662+
             (define arities (iota 22 1))
663+
             (define aritiesExceptOne (iota 21 2))
664+
             (define (arityChars n)
665+
               (string (integer->char (+ (char->integer #\A) (- n 1)))))
666+
             (define (functionTypeParameters arity)
667+
               (string-join (map arityChars (iota arity 1)) ", "))
668+
             (define (tupleFields arity)
669+
               (string-join
670+
                 (map
671+
                   (lambda (n)
672+
                     (string-append "x._" (number->string n)))
673+
                   (iota arity 1))
674+
                 ", "))
675+
             (define (listPatternMatch arity)
676+
               (string-append
677+
                 (string-join
678+
                   (map
679+
                     (lambda (n)
680+
                       (string-append "c" (string-downcase (arityChars n))))
681+
                     (iota arity 1))
682+
                   " :: ")
683+
                 " :: Nil"))
684+
             (define (jsonStringParams arity)
685+
               (string-join
686+
                 (map
687+
                   (lambda (n)
688+
                     (format #f "~an: JsonString" (string-downcase (arityChars n))))
689+
                   (iota arity 1))
690+
                 ", "))
691+
             (define (jsonStringParamNames arity)
692+
               (string-join
693+
                 (map
694+
                   (lambda (n)
695+
                     (format #f "~an" (string-downcase (arityChars n))))
696+
                   (iota arity 1))
697+
                 ", "))
698+
699+
             (with-output-to-file "argonaut/shared/src/main/scala/argonaut/GeneratedDecodeJsons.scala"
700+
               (lambda _
701+
                 (define (decodeJsonContextArities n)
702+
                   (string-join
703+
                     (map (lambda (n) (format #f "~a: DecodeJson" (arityChars n)))
704+
                          (iota n 1))
705+
                     ","))
706+
                 (define (decodeJsonParams n)
707+
                   (string-join
708+
                     (map
709+
                       (lambda (n)
710+
                         (define char (arityChars n))
711+
                         (format #f "decode~a: DecodeJson[~a]"
712+
                                 (string-downcase char) char))
713+
                       (iota n 1))
714+
                     ", "))
715+
                 (define tupleDecodes
716+
                   (map
717+
                     (lambda (arity)
718+
                       (define forComprehensionLines
719+
                         (string-join
720+
                           (map
721+
                             (lambda (n)
722+
                               (define char (arityChars n))
723+
                               (format #f "          x~a <- decode~a(c~a)"
724+
                                       (string-downcase char) (string-downcase char)
725+
                                       (string-downcase char)))
726+
                             (iota arity 1))
727+
                           "\n"))
728+
                       (define yieldResult
729+
                         (string-join
730+
                           (map
731+
                             (lambda (n)
732+
                               (string-append "x" (string-downcase (arityChars n))))
733+
                             (iota arity 1))
734+
                           ", "))
735+
                       (format #f "
736+
  implicit def Tuple~aDecodeJson[~a](implicit ~a): DecodeJson[(~a)] =
737+
    DecodeJson(c =>
738+
      c.jdecode[List[HCursor]] flatMap {
739+
        case ~a => for {
740+
~a
741+
        } yield (~a)
742+
        case _ => DecodeResult.fail(\"[~a]Tuple~a[~a]\", c.history)
743+
      })
744+
"
745+
                               arity
746+
                               (functionTypeParameters arity)
747+
                               (decodeJsonParams arity)
748+
                               (functionTypeParameters arity)
749+
                               (listPatternMatch arity)
750+
                               forComprehensionLines
751+
                               yieldResult
752+
                               (functionTypeParameters arity)
753+
                               arity
754+
                               (functionTypeParameters arity)))
755+
                     aritiesExceptOne))
756+
                 (define jdecode1 "
757+
  def jdecode1[A, X](f: A => X)(implicit decodea: DecodeJson[A]): DecodeJson[X] =
758+
    decodea.map(f)
759+
")
760+
                 (define jdecodes
761+
                   (map
762+
                     (lambda (arity)
763+
                       (format #f "
764+
  def jdecode~a[~a, X](f: (~a) => X)(implicit dx: DecodeJson[(~a)]): DecodeJson[X] =
765+
    dx.map(x => f(~a))"
766+
                               arity
767+
                               (functionTypeParameters arity)
768+
                               (functionTypeParameters arity)
769+
                               (functionTypeParameters arity)
770+
                               (tupleFields arity)))
771+
                     aritiesExceptOne))
772+
773+
                 (define jdecode1L "
774+
  def jdecode1L[A: DecodeJson, X](f: A => X)(an: JsonString): DecodeJson[X] =
775+
    DecodeJson(x => for {
776+
      aa <- x.get[A](an)
777+
    } yield f(aa))")
778+
779+
                 (define jdecodeLs
780+
                   (map
781+
                     (lambda (arity)
782+
                       (define forComprehensionLines
783+
                         (string-join
784+
                           (map
785+
                             (lambda (n)
786+
                               (define upperChar (arityChars n))
787+
                               (define lowerChar (string-downcase upperChar))
788+
                               (format #f "       ~a~a <- x.get[~a](~an)"
789+
                                       lowerChar lowerChar upperChar lowerChar))
790+
                             (iota arity 1))
791+
                           "\n"))
792+
                       (define yieldExpression
793+
                         (string-join
794+
                           (map
795+
                             (lambda (n)
796+
                               (define lowerChar (string-downcase (arityChars n)))
797+
                               (format #f "~a~a" lowerChar lowerChar))
798+
                             (iota arity 1))
799+
                           ", "))
800+
801+
                       (format #f "
802+
  def jdecode~aL[~a, X](f: (~a) => X)(~a): DecodeJson[X] =
803+
    DecodeJson(x => for {
804+
~a
805+
    } yield f(~a))"
806+
                               arity
807+
                               (decodeJsonContextArities arity)
808+
                               (functionTypeParameters arity)
809+
                               (jsonStringParams arity)
810+
                               forComprehensionLines
811+
                               yieldExpression))
812+
                     aritiesExceptOne))
813+
                 (display header)
814+
                 (display "trait GeneratedDecodeJsons {
815+
  this: DecodeJsons =>
816+
  import Json._
817+
")
818+
                 (display
819+
                   (string-join
820+
                     (append tupleDecodes (cons jdecode1 jdecodes)
821+
                             (cons jdecode1L jdecodeLs))
822+
                     ""))
823+
                 (display "\n}\n")))
824+
825+
             (with-output-to-file "argonaut/shared/src/main/scala/argonaut/GeneratedEncodeJsons.scala"
826+
               (lambda _
827+
                 (define (encodeJsonContextArities n)
828+
                   (string-join
829+
                     (map
830+
                       (lambda (n)
831+
                         (format #f "~a: EncodeJson" (arityChars n)))
832+
                       (iota n 1))
833+
                     ", "))
834+
                 (define (encodeJsonParams n)
835+
                   (string-join
836+
                     (map
837+
                       (lambda (n)
838+
                         (define char (arityChars n))
839+
                         (format #f "encode~a: EncodeJson[~a]"
840+
                                 (string-downcase char) char))
841+
                       (iota n 1))
842+
                     ", "))
843+
                 (define (invokeEncodeJsonParams n)
844+
                   (string-join
845+
                     (map
846+
                       (lambda (n)
847+
                         (define char (string-downcase (arityChars n)))
848+
                         (format #f "encode~a(~a)" char char))
849+
                       (iota n 1))
850+
                     ", "))
851+
852+
                 (define tupleEncodes
853+
                   (map
854+
                     (lambda (arity)
855+
                       (format #f "
856+
  implicit def Tuple~aEncodeJson[~a](implicit ~a): EncodeJson[(~a)] =
857+
    EncodeJson({
858+
     case (~a) => jArray(List(~a))
859+
    })
860+
"
861+
                               arity
862+
                               (functionTypeParameters arity)
863+
                               (encodeJsonParams arity)
864+
                               (functionTypeParameters arity)
865+
                               (string-downcase (functionTypeParameters arity))
866+
                               (invokeEncodeJsonParams arity)))
867+
                     aritiesExceptOne))
868+
869+
                 (define jencode1 "
870+
  def jencode1[X, A](f: X => A)(implicit encodea: EncodeJson[A]): EncodeJson[X] =
871+
    encodea.contramap(f)
872+
")
873+
874+
                 (define jencodes
875+
                   (map
876+
                     (lambda (arity)
877+
                       (format #f "
878+
  def jencode~a[X, ~a](f: X => (~a))(implicit encodex: EncodeJson[(~a)]): EncodeJson[X] =
879+
    encodex.contramap(f)
880+
"
881+
                               arity
882+
                               (functionTypeParameters arity)
883+
                               (functionTypeParameters arity)
884+
                               (functionTypeParameters arity)))
885+
                     aritiesExceptOne))
886+
887+
                 (define jencode1L "
888+
  def jencode1L[X, A](f: X => A)(an: JsonString)(implicit encodea: EncodeJson[A]): EncodeJson[X] =
889+
    EncodeJson(x => jSingleObject(an, encodea.apply(f(x))))
890+
")
891+
                 (define jencodeLs
892+
                   (map
893+
                     (lambda (arity)
894+
                       (define encodePairs
895+
                         (string-join
896+
                           (map
897+
                             (lambda (n)
898+
                               (define upperChar (arityChars n))
899+
                               (define lowerChar (string-downcase upperChar))
900+
                               (format #f "(~an, encode~a.apply(~a))"
901+
                                       lowerChar lowerChar lowerChar))
902+
                             (iota arity 1))
903+
                           ", "))
904+
905+
                       (format #f "
906+
  def jencode~aL[X, ~a](fxn: X => (~a))(~a)(implicit ~a): EncodeJson[X] =
907+
    EncodeJson(x => jObjectAssocList({
908+
      val (~a) = fxn(x)
909+
      List(~a)
910+
    }))
911+
"
912+
                               arity
913+
                               (functionTypeParameters arity)
914+
                               (functionTypeParameters arity)
915+
                               (jsonStringParams arity)
916+
                               (encodeJsonParams arity)
917+
                               (string-downcase (functionTypeParameters arity))
918+
                               encodePairs)
919+
                       )
920+
                     aritiesExceptOne))
921+
922+
                 (define content
923+
                   (string-join
924+
                     (append
925+
                       tupleEncodes (cons jencode1 jencodes) (cons jencode1L jencodeLs))
926+
                     ""))
927+
928+
                 (display header)
1017929
                 (format #t "
1018-
val BaseSequencer~a: Sequencer[(~a), Any, (~a, Any)] =
1019-
  Sequencer0((t, d) => (~a, d))
1020-
implicit def Sequencer~a[~a]: Sequencer[(~a), D, (~a)] =
1021-
  BaseSequencer~a.asInstanceOf[Sequencer[(~a), D, (~a)]]
1022-
" num anys anys chunkss num tsD tss tsD num tss tsD)))
1023-
             (with-output-to-file "fastparse/src/fastparse/SequencerGen.scala"
930+
trait GeneratedEncodeJsons {
931+
  this: EncodeJsons =>
932+
  import Json._
933+
~a
934+
}
935+
"
936+
                         content)))
937+
938+
             (with-output-to-file "argonaut/shared/src/main/scala/argonaut/GeneratedCodecJsons.scala"
1024939
               (lambda _
1025-
                 (format #t "package fastparse
1026-
trait SequencerGen[Sequencer[_, _, _]] extends LowestPriSequencer[Sequencer]{
1027-
  protected[this] def Sequencer0[A, B, C](f: (A, B) => C): Sequencer[A, B, C]
940+
                 (define (codecJsonContextArities n)
941+
                   (string-join
942+
                     (map
943+
                       (lambda (n)
944+
                         (format #f "~a: EncodeJson: DecodeJson" (arityChars n)))
945+
                       (iota n 1))
946+
                     ", "))
947+
948+
                 (define codec1 "
949+
  def codec1[A: EncodeJson: DecodeJson, X](f: A => X, g: X => A)(an: JsonString): CodecJson[X] =
950+
    CodecJson(jencode1L(g)(an).encode, jdecode1L(f)(an).decode)
1028951
")
1029-
                 (for-each tuple (iota 20 2))
1030-
                 (format #t "}
1031-
trait LowestPriSequencer[Sequencer[_, _, _]]{
1032-
  protected[this] def Sequencer0[A, B, C](f: (A, B) => C): Sequencer[A, B, C]
1033-
  implicit def Sequencer1[T1, T2]: Sequencer[T1, T2, (T1, T2)] = Sequencer0{case (t1, t2) => (t1, t2)}
952+
                 (define codecs
953+
                   (map
954+
                     (lambda (arity)
955+
                       (format #f "
956+
  def codec~a[~a, X](f: (~a) => X, g: X => (~a))(~a): CodecJson[X] =
957+
    CodecJson(jencode~aL(g)(~a).encode, jdecode~aL(f)(~a).decode)
958+
"
959+
                               arity
960+
                               (codecJsonContextArities arity)
961+
                               (functionTypeParameters arity)
962+
                               (functionTypeParameters arity)
963+
                               (jsonStringParams arity)
964+
                               arity
965+
                               (jsonStringParamNames arity)
966+
                               arity
967+
                               (jsonStringParamNames arity)))
968+
                     aritiesExceptOne))
969+
970+
                 (define casecodec1 "
971+
  def casecodec1[A: EncodeJson: DecodeJson, X](f: A => X, g: X => Option[A])(an: JsonString): CodecJson[X] =
972+
    CodecJson(jencode1L(g)(an).encode, jdecode1L(f)(an).decode)
973+
")
974+
                 (define casecodecs
975+
                   (map
976+
                     (lambda (arity)
977+
                       (format #f "
978+
  def casecodec~a[~a, X](f: (~a) => X, g: X => Option[(~a)])(~a): CodecJson[X] =
979+
    CodecJson(jencode~aL(g andThen (_.get))(~a).encode, jdecode~aL(f)(~a).decode)
980+
"
981+
                               arity
982+
                               (codecJsonContextArities arity)
983+
                               (functionTypeParameters arity)
984+
                               (functionTypeParameters arity)
985+
                               (jsonStringParams arity)
986+
                               arity
987+
                               (jsonStringParamNames arity)
988+
                               arity
989+
                               (jsonStringParamNames arity)))
990+
                     aritiesExceptOne))
991+
                 (define content
992+
                   (string-join
993+
                     (append
994+
                       (cons codec1 codecs) (cons casecodec1 casecodecs))
995+
                   ""))
996+
997+
                 (display header)
998+
                 (format #t "
999+
trait GeneratedCodecJsons {
1000+
  import Json._
1001+
  import DecodeJson._
1002+
  import EncodeJson._
1003+
~a
10341004
}
1035-
")))
1005+
"
1006+
                         content)))
10361007
             #t))
10371008
         (replace 'build
1038-
           (lambda _
1039-
             (mkdir-p "build/classes")
1040-
             (mkdir-p "build/jar")
1041-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
1042-
                    "-d" "build/classes"
1043-
                    (find-files "fastparse/src" ".*.scala$"))
1044-
             (invoke "jar" "cf" "build/jar/fastparse.jar" "-C" "build/classes" ".")
1045-
             #t))
1009+
           ,(build-scala-phase '(("argonaut" "scala-argonaut"))
1010+
              #:scala-locations '("shared/src/main/scala"
1011+
                                  "shared/src/main/scala2")
1012+
              #:java-locations '("shared/src/main/java")))
10461013
         (replace 'install
10471014
           (install-jars "build")))))
1048-
    (inputs
1049-
     `(("scala-sourcecode" ,scala-sourcecode)))
10501015
    (native-inputs
1051-
     `(("scala" ,scala-official)))
1016+
     `(("scala" ,scala)))
10521017
    (home-page "")
10531018
    (synopsis "")
10541019
    (description "")
1055-
    (license license:expat)))
1020+
    (license license:bsd-3)))
10561021
1057-
(define scala-fastparse1
1022+
(define-public scala-shapeless
10581023
  (package
1059-
    (inherit scala-fastparse)
1060-
    (version "1.0.0")
1024+
    (name "scala-shapeless")
1025+
    (version "2.3.7")
10611026
    (source (origin
1062-
              (method url-fetch)
1063-
              (uri (string-append "https://github.com/lihaoyi/fastparse/archive/"
1064-
                                  version ".tar.gz"))
1065-
              (file-name (string-append "scala-fastparse-" version ".tar.gz"))
1027+
              (method git-fetch)
1028+
              (uri (git-reference
1029+
                     (url "https://github.com/milessabin/shapeless")
1030+
                     (commit (string-append "v" version))))
1031+
              (file-name (git-file-name name version))
10661032
              (sha256
10671033
               (base32
1068-
                "14d44f23hl6ypfwlvnzkzcvv52a0xipm5wkp2glr184aik7w5pnb"))))
1034+
                "1ajni5f5gi76bghv5ajxlnfpz7163za5zv5w02fyfc0rq9p0lxai"))))
1035+
    (build-system ant-build-system)
10691036
    (arguments
1070-
     `(#:tests? #f; in fastpares/test/src
1071-
       #:modules
1072-
       ((guix build ant-build-system)
1073-
        (guix build java-utils)
1074-
        (guix build utils)
1075-
        (srfi srfi-1))
1076-
       #:imported-modules
1077-
       ((srfi srfi-1) ; for iota
1078-
        ,@%ant-build-system-modules)
1037+
     `(#:tests? #f
10791038
       #:phases
10801039
       (modify-phases %standard-phases
1081-
         (add-before 'build 'copy-compat
1082-
           (lambda _
1083-
             (with-directory-excursion "utils/shared/src/main"
1084-
               (copy-file "scala-2.11/fastparse/utils/Compat.scala"
1085-
                          "scala/fastparse/utils/Compat.scala"))
1086-
             #t))
10871040
         (add-before 'build 'generate-sources
10881041
           (lambda _
1089-
             (define (tuple num)
1090-
               (let* ((ts (map (lambda (n) (string-append "T" (number->string n)))
1091-
                               (iota num 1)))
1092-
                      (chunks (map (lambda (n)
1093-
                                     (string-append "t._" (number->string n)))
1094-
                                   (iota num 1)))
1095-
                      (chunkss (string-join chunks ", "))
1096-
                      (tsD (string-join (reverse (cons "D" (reverse ts))) ","))
1097-
                      (anys (string-join (map (const "Any") ts) ", "))
1098-
                      (tss (string-join ts ", ")))
1099-
                 (format #t "
1100-
val BaseSequencer~a: Sequencer[(~a), Any, (~a, Any)] =
1101-
  Sequencer0((t, d) => (~a, d))
1102-
implicit def Sequencer~a[~a]: Sequencer[(~a), D, (~a)] =
1103-
  BaseSequencer~a.asInstanceOf[Sequencer[(~a), D, (~a)]]
1104-
" num anys anys chunkss num tsD tss tsD num tss tsD)))
1105-
             (with-output-to-file
1106-
               "fastparse/shared/src/main/scala/fastparse/core/SequencerGen.scala"
1107-
               (lambda _
1108-
                 (format #t "package fastparse.core
1109-
trait SequencerGen[Sequencer[_, _, _]] extends LowestPriSequencer[Sequencer]{
1110-
  protected[this] def Sequencer0[A, B, C](f: (A, B) => C): Sequencer[A, B, C]
1111-
")
1112-
                 (for-each tuple (iota 20 2))
1113-
                 (format #t "}
1114-
trait LowestPriSequencer[Sequencer[_, _, _]]{
1115-
  protected[this] def Sequencer0[A, B, C](f: (A, B) => C): Sequencer[A, B, C]
1116-
  implicit def Sequencer1[T1, T2]: Sequencer[T1, T2, (T1, T2)] = Sequencer0{case (t1, t2) => (t1, t2)}
1117-
}
1042+
             ;; Converted from project/Boilerplate.scala
1043+
             (define header "package shapeless\n\n")
1044+
             (define scalaBinaryVersion ,(version-major+minor (package-version scala)))
1045+
             (define (templateVals arity)
1046+
               (let* ((synTypes (map
1047+
                                  (lambda (n)
1048+
                                    (string (integer->char (+ (char->integer #\A) n))))
1049+
                                  (iota arity)))
1050+
                      (synVals (map
1051+
                                  (lambda (n)
1052+
                                    (string (integer->char (+ (char->integer #\a) n))))
1053+
                                  (iota arity)))
1054+
                      (synTypedVals (map
1055+
                                      (lambda (v t)
1056+
                                        (string-append v ":" t))
1057+
                                      synVals synTypes)))
1058+
                `((arity . ,(number->string arity))
1059+
                  (synTypes . ,synTypes)
1060+
                  (synVals . ,synVals)
1061+
                  (synTypedVals . ,synTypedVals)
1062+
                  (A--N . ,(string-join synTypes ", "))
1063+
                  (A--N,Res . ,(string-join (append synTypes (list "Res")) ", "))
1064+
                  (a--n . ,(string-join synVals ", "))
1065+
                  (A::N . ,(string-join (append synTypes (list "HNil")) "::"))
1066+
                  (a::n . ,(string-join (append synVals (list "HNil")) "::"))
1067+
                  (_--_ . ,(string-join (map (const "_") synVals) ", "))
1068+
                  (tupleA--N . ,(if (equal? arity 1)
1069+
                                    "Tuple1[A]"
1070+
                                    (string-append
1071+
                                      "("
1072+
                                      (string-join synTypes ", ")
1073+
                                      ")")))
1074+
                  (tuple_--_ . ,(if (equal? arity 1)
1075+
                                    "Tuple1[_]"
1076+
                                    (string-append
1077+
                                      "("
1078+
                                      (string-join (map (const "_") synTypes) ", ")
1079+
                                      ")")))
1080+
                  (tuplea--n . ,(if (equal? arity 1)
1081+
                                    "Tuple1(a)"
1082+
                                    (string-append
1083+
                                      "("
1084+
                                      (string-join synVals ", ")
1085+
                                      ")")))
1086+
                  (a:A--n:N . ,(string-join synTypedVals ", ")))))
1087+
1088+
             (define* (generate-file filename content #:key
1089+
                                     (range (iota 22 1)))
1090+
               (with-output-to-file (string-append "core/src/main/scala/shapeless/"
1091+
                                                   filename)
1092+
                 (lambda _
1093+
                   (define rawContents
1094+
                     (map
1095+
                       (lambda (n)
1096+
                         (filter
1097+
                           (lambda (s) (not (equal? s "")))
1098+
                           (string-split (content n (templateVals n)) #\newline)))
1099+
                       range))
1100+
                   (define preBody
1101+
                     (let loop ((strs (car rawContents)) (ans '()))
1102+
                       (cond
1103+
                         ((null? strs) (reverse ans))
1104+
                         ((string-prefix? "|" (car strs))
1105+
                          (loop (cdr strs) (cons (car strs) ans)))
1106+
                         (else (reverse ans)))))
1107+
                   (define instances
1108+
                     (apply append
1109+
                            (map
1110+
                              (lambda (content)
1111+
                                (filter
1112+
                                  (lambda (s)
1113+
                                    (string-prefix? "-" s))
1114+
                                  content))
1115+
                              rawContents)))
1116+
                   (define postBody
1117+
                     (let loop ((strs (reverse (car rawContents))) (ans '()))
1118+
                       (cond
1119+
                         ((null? strs) (reverse ans))
1120+
                         ((string-prefix? "|" (car strs))
1121+
                          (loop (cdr strs) (cons (car strs) ans)))
1122+
                         (else (reverse ans)))))
1123+
                   (display
1124+
                     (string-append
1125+
                       header
1126+
                       (string-join
1127+
                         (map
1128+
                           (lambda (s)
1129+
                             (substring s 1))
1130+
                           (append preBody instances postBody))
1131+
                         "\n"))))))
1132+
             (generate-file
1133+
               "tupler.scala"
1134+
               (lambda (arity template)
1135+
                 (string-append "
1136+
|package ops
1137+
|
1138+
|import hlist.Tupler
1139+
|
1140+
|trait TuplerInstances {
1141+
|  type Aux[L <: HList, T] = Tupler[L] { type Out = T }
1142+
-
1143+
-  implicit def hlistTupler" (assoc-ref template 'arity) "[
1144+
-    " (assoc-ref template 'A--N) "
1145+
-  ]: Aux[
1146+
-    " (assoc-ref template 'A::N) ",
1147+
-    " (assoc-ref template 'tupleA--N) "
1148+
-  ] = Tupler.instance { case " (assoc-ref template 'a::n) " =>
1149+
-    " (assoc-ref template 'tuplea--n) "
1150+
-  }
1151+
|}
1152+
")))
1153+
             (generate-file
1154+
               "fntoproduct.scala"
1155+
               (lambda (arity template)
1156+
                 (define fnType (string-append "(" (assoc-ref template 'A--N) ") => Res"))
1157+
                 (define hlistFnType
1158+
                   (string-append "(" (assoc-ref template 'A::N) ") => Res"))
1159+
                 (define fnBody
1160+
                   (if (equal? arity 0)
1161+
                       "_ => fn()"
1162+
                       (string-append "{ case " (assoc-ref template 'a::n)
1163+
                                      " => fn(" (assoc-ref template 'a--n) ") }")))
1164+
                 (string-append "
1165+
|package ops
1166+
|
1167+
|import function.FnToProduct
1168+
|
1169+
|trait FnToProductInstances {
1170+
|  type Aux[F, P] = FnToProduct[F] { type Out = P }
1171+
-
1172+
-  implicit def fnToProduct" (assoc-ref template 'arity) "[
1173+
-    " (assoc-ref template 'A--N,Res) "
1174+
-  ]: Aux[
1175+
-    (" fnType "),
1176+
-    "hlistFnType"
1177+
-  ] = FnToProduct.instance(fn => " fnBody ")
1178+
|}
1179+
")))
1180+
             (generate-file
1181+
               "fnfromproduct.scala"
1182+
               (lambda (arity template)
1183+
                 (define fnType (string-append "(" (assoc-ref template 'A--N) ") => Res"))
1184+
                 (define hlistFnType
1185+
                   (string-append "(" (assoc-ref template 'A::N) ") => Res"))
1186+
                 (string-append "
1187+
|package ops
1188+
|
1189+
|import function.FnFromProduct
1190+
|
1191+
|trait FnFromProductInstances {
1192+
|  type Aux[F, O] = FnFromProduct[F] { type Out = O }
1193+
-
1194+
-  implicit def fnFromProduct" (assoc-ref template 'arity) "[
1195+
-    "(assoc-ref template 'A--N,Res)"
1196+
-  ]: Aux[
1197+
-    " hlistFnType ",
1198+
-    " fnType "
1199+
-  ] = FnFromProduct.instance { hf =>
1200+
-    (" (assoc-ref template 'a:A--n:N) ") =>
1201+
-      hf(" (assoc-ref template 'a::n) ")
1202+
-  }
1203+
|}
1204+
"))
1205+
               #:range (iota 23))
1206+
             (generate-file
1207+
               "caseinst.scala"
1208+
               (lambda (arity template)
1209+
                 (string-append
1210+
                   "
1211+
|
1212+
|trait CaseInst {
1213+
|  import poly._
1214+
|
1215+
-  implicit def inst" (assoc-ref template 'arity) "
1216+
-    [Fn <: Poly, " (assoc-ref template 'A--N) ", Res]
1217+
-    (cse : Case[Fn, " (assoc-ref template 'A::N) "] { type Result = Res }) 
1218+
-  : (" (assoc-ref template 'A--N) ") => Res =
1219+
-    (" (assoc-ref template 'a:A--n:N) ")
1220+
-      => cse.value(" (assoc-ref template 'a::n) ")
1221+
-
1222+
|}
1223+
")))
1224+
             (generate-file
1225+
               "polyapply.scala"
1226+
               (lambda (arity template)
1227+
                 (string-append "
1228+
|
1229+
|trait PolyApply {
1230+
|  import poly._
1231+
-  def apply
1232+
-    [" (assoc-ref template 'A--N) "]
1233+
-    (" (assoc-ref template 'a:A--n:N) ")
1234+
-    (implicit cse : Case[this.type, " (assoc-ref template 'A::N) "])
1235+
-  : cse.Result =
1236+
-    cse(" (assoc-ref template 'a::n) ")
1237+
-
1238+
|}
1239+
")))
1240+
             (generate-file
1241+
               "polyinst.scala"
1242+
               (lambda (arity template)
1243+
                 (string-append "
1244+
|
1245+
|trait PolyInst {
1246+
|
1247+
-  implicit def inst" (assoc-ref template 'arity) "
1248+
-    [" (assoc-ref template 'A--N) "]
1249+
-    (fn : Poly)(implicit cse : fn.ProductCase[" (assoc-ref template 'A::N) "])
1250+
-  : (" (assoc-ref template 'A--N) ") => cse.Result =
1251+
-    (" (assoc-ref template 'a:A--n:N) ")
1252+
-      => cse(" (assoc-ref template 'a::n) ")
1253+
-
1254+
|}
1255+
")))
1256+
             (generate-file
1257+
               "cases.scala"
1258+
               (lambda (arity template)
1259+
                 (string-append "
1260+
|
1261+
|trait Cases {
1262+
|  import poly._
1263+
|
1264+
-  type Case" (assoc-ref template 'arity) "[Fn, " (assoc-ref template 'A--N) "] =
1265+
-    Case[Fn, " (assoc-ref template 'A::N) "]
1266+
-
1267+
-  object Case" (assoc-ref template 'arity) " {
1268+
-    type Aux[Fn, " (assoc-ref template 'A--N) ", Result0] =
1269+
-      Case[Fn, " (assoc-ref template 'A::N) "] { type Result = Result0 }
1270+
-
1271+
-    def apply[
1272+
-      Fn, " (assoc-ref template 'A--N) ", Result0
1273+
-    ](
1274+
-      fn: (" (assoc-ref template 'A--N) ") => Result0
1275+
-    ): Aux[Fn, " (assoc-ref template 'A--N) ", Result0] =
1276+
-      Case { case " (assoc-ref template 'a::n) " =>
1277+
-        fn(" (assoc-ref template 'a--n) ")
1278+
-      }
1279+
-  }
1280+
-
1281+
|}
1282+
")))
1283+
             (generate-file
1284+
               "polyntraits.scala"
1285+
               (lambda (arity template)
1286+
                 (define fnBody
1287+
                   (if (equal? arity 0)
1288+
                       "_ => fn()"
1289+
                       (string-append
1290+
                         "{ case " (assoc-ref template 'a::n) " => fn("
1291+
                         (assoc-ref template 'a--n) ") }")))
1292+
                 (string-append "
1293+
|
1294+
-
1295+
-trait Poly" (assoc-ref template 'arity) " extends Poly { outer =>
1296+
-  type Case[" (assoc-ref template 'A--N) "] =
1297+
-    poly.Case[this.type, " (assoc-ref template 'A::N) "]
1298+
-
1299+
-  object Case {
1300+
-    type Aux[" (assoc-ref template 'A--N) ", Result0] =
1301+
-      poly.Case[outer.type, " (assoc-ref template 'A::N) "] { type Result = Result0 }
1302+
-  }
1303+
-
1304+
-  class CaseBuilder[" (assoc-ref template 'A--N) "] {
1305+
-    def apply[Res](
1306+
-      fn: (" (assoc-ref template 'A--N) ") => Res
1307+
-    ): Case.Aux[" (assoc-ref template 'A--N) ", Res] =
1308+
-      poly.Case(" fnBody ")
1309+
-  }
1310+
-  
1311+
-  def at[" (assoc-ref template 'A--N) "] =
1312+
-    new CaseBuilder[" (assoc-ref template 'A--N) "]
1313+
-}
1314+
-
1315+
-object Poly" (assoc-ref template 'arity) " extends PolyNBuilders.Poly" (assoc-ref template 'arity) "Builder[HNil] {
1316+
-  val functions = HNil
1317+
-}
1318+
|
1319+
")))
1320+
             (generate-file
1321+
               "polynbuilders.scala"
1322+
               (lambda (arity template)
1323+
                 (string-append "
1324+
|
1325+
|
1326+
|/**
1327+
|  * Provides elegant syntax for creating polys from functions
1328+
|  *
1329+
|  * @author Aristotelis Dossas
1330+
|  */
1331+
|object PolyNBuilders {
1332+
-
1333+
- trait Poly" (assoc-ref template 'arity) "Builder[HL <: HList] { self =>
1334+
-
1335+
-   val functions: HL
1336+
-   class AtAux[" (assoc-ref template 'A--N) "] {
1337+
-     def apply[Out](??: (" (assoc-ref template 'A--N) ") => Out) = {
1338+
-       new Poly" (assoc-ref template 'arity) "Builder[((" (assoc-ref template 'A--N) ") => Out) :: HL] {
1339+
-         val functions = ?? :: self.functions
1340+
-       }
1341+
-     }
1342+
-   }
1343+
-   def at[" (assoc-ref template 'A--N) "] = new AtAux[" (assoc-ref template 'A--N) "]
1344+
-
1345+
-   def build = new Poly" (assoc-ref template 'arity) " {
1346+
-     val functions = self.functions
1347+
-
1348+
-     implicit def allCases[" (assoc-ref template 'A--N) ", Out](implicit tL: Function" (assoc-ref template 'arity) "TypeAt[" (assoc-ref template 'A--N) ", Out, HL]) = {
1349+
-       val func: (" (assoc-ref template 'A--N) ") => Out = tL(functions)
1350+
-       at(func)
1351+
-     }
1352+
-   }
1353+
- }
1354+
-
1355+
- /* For internal use of Poly" (assoc-ref template 'arity) "Builder */
1356+
- trait Function" (assoc-ref template 'arity) "TypeAt[" (assoc-ref template 'A--N) ", Out, HL <: HList] {
1357+
-   def apply(l: HL): (" (assoc-ref template 'A--N) ") => Out
1358+
- }
1359+
-
1360+
- object Function" (assoc-ref template 'arity) "TypeAt {
1361+
-   private def instance[" (assoc-ref template 'A--N) ", Out, HL <: HList](
1362+
-     f: HL => (" (assoc-ref template 'A--N) ") => Out
1363+
-   ): Function" (assoc-ref template 'arity) "TypeAt[" (assoc-ref template 'A--N) ", Out, HL] =
1364+
-     new Function" (assoc-ref template 'arity) "TypeAt[" (assoc-ref template 'A--N) ", Out, HL] {
1365+
-       def apply(l: HL) = f(l)
1366+
-     }
1367+
-
1368+
-   implicit def at0[
1369+
-     " (assoc-ref template 'A--N) ", Out, Tail <: HList
1370+
-   ]: Function" (assoc-ref template 'arity) "TypeAt[" (assoc-ref template 'A--N) ", Out, ((" (assoc-ref template 'A--N) ") => Out) :: Tail] =
1371+
-     instance(_.head)
1372+
-
1373+
-   implicit def atOther[
1374+
-     " (assoc-ref template 'A--N) ", Out, Tail <: HList, Head
1375+
-   ](
1376+
-     implicit tprev: Function" (assoc-ref template 'arity) "TypeAt[" (assoc-ref template 'A--N) ", Out, Tail]
1377+
-   ): Function" (assoc-ref template 'arity) "TypeAt[" (assoc-ref template 'A--N) ", Out, Head :: Tail] =
1378+
-     instance(l => tprev(l.tail))
1379+
- }
1380+
|}
1381+
")))
1382+
             (generate-file
1383+
               "nats.scala"
1384+
               (lambda (arity template)
1385+
                 (define n (number->string arity))
1386+
                 (string-append "
1387+
|
1388+
|trait Nats {
1389+
-
1390+
-  type _" n " = Succ[_" (number->string (- arity 1)) "]
1391+
-  val _" n ": _" n " = new _" n "
1392+
|}
1393+
")))
1394+
             (generate-file
1395+
               "tupletypeables.scala"
1396+
               (lambda (arity template)
1397+
                 (define implicitArgs
1398+
                   (string-join
1399+
                     (map
1400+
                       (lambda (a)
1401+
                         (string-append "cast" a ":Typeable[" a "]"))
1402+
                       (assoc-ref template 'synTypes))
1403+
                     ", "))
1404+
                 (define enumerators
1405+
                   (let ((synTypes (assoc-ref template 'synTypes)))
1406+
                     (string-join
1407+
                       (map
1408+
                         (lambda (a i)
1409+
                           (string-append "_ <- p._" (number->string i) ".cast[" a "]"))
1410+
                         synTypes
1411+
                         (iota (length synTypes) 1))
1412+
                       "; ")))
1413+
                 (define castVals
1414+
                   (string-join
1415+
                     (map
1416+
                       (lambda (a)
1417+
                         (string-append "${cast" a ".describe}"))
1418+
                       (assoc-ref template 'synTypes))
1419+
                     ", "))
1420+
                 (string-append "
1421+
|
1422+
|trait TupleTypeableInstances {
1423+
|  import syntax.typeable._
1424+
-
1425+
-  implicit def tuple" (assoc-ref template 'arity) "Typeable[
1426+
-    " (assoc-ref template 'A--N) "
1427+
-  ](
1428+
-    implicit " implicitArgs "
1429+
-  ): Typeable[" (assoc-ref template 'tupleA--N) "] =
1430+
-    Typeable.instance(s\"(" castVals ")\") {
1431+
-      case p: " (assoc-ref template 'tuple_--_) " =>
1432+
-        for (" enumerators ")
1433+
-          yield p.asInstanceOf[" (assoc-ref template 'tupleA--N) "]
1434+
-      case _ =>
1435+
-        None
1436+
-    }
1437+
|}
1438+
")))
1439+
             (generate-file
1440+
               "sizedbuilder.scala"
1441+
               (lambda (arity template)
1442+
                 (define synVals (assoc-ref template 'synVals))
1443+
                 (define a:T--n:T
1444+
                   (string-join
1445+
                     (map
1446+
                       (lambda (v) (string-append v ":T"))
1447+
                       synVals)
1448+
                     ", "))
1449+
                 (define commonImplicits
1450+
                   "factory: Factory[T, CC[T]], ev: AdditiveCollection[CC[T]]")
1451+
                 (define implicits
1452+
                   (case scalaBinaryVersion
1453+
                     (("2.11" "2.12") commonImplicits)
1454+
                     (else (string-append "dis: DefaultToIndexedSeq[CC], " commonImplicits))))
1455+
                 (string-append "
1456+
|
1457+
|class SizedBuilder[CC[_]] {
1458+
|  import scala.collection._
1459+
|  import nat._
1460+
|  import Sized.wrap
1461+
|
1462+
-  def apply[T](" a:T--n:T ")
1463+
-    (implicit " implicits ") =
1464+
-    wrap[CC[T], _" (assoc-ref template 'arity) "]((factory.newBuilder ++= Seq(" (assoc-ref template 'a--n) ")).result())
1465+
-
1466+
|}
1467+
")))
1468+
             (generate-file
1469+
               "hmapbuilder.scala"
1470+
               (lambda (arity template)
1471+
                 (define typeArgs
1472+
                   (string-join
1473+
                     (map
1474+
                       (lambda (n)
1475+
                         (let ((n (number->string n)))
1476+
                           (string-append "K" n ", V" n)))
1477+
                       (iota arity))
1478+
                     ", "))
1479+
                 (define args
1480+
                   (string-join
1481+
                     (map
1482+
                       (lambda (n)
1483+
                         (let ((n (number->string n)))
1484+
                           (string-append "e" n ": (K" n ", V" n ")")))
1485+
                       (iota arity))
1486+
                     ", "))
1487+
                 (define witnesses
1488+
                   (string-join
1489+
                     (map
1490+
                       (lambda (n)
1491+
                         (let ((n (number->string n)))
1492+
                           (string-append "ev" n ": R[K" n ", V" n "]")))
1493+
                       (iota arity))
1494+
                     ", "))
1495+
                 (define mapArgs
1496+
                   (string-join
1497+
                     (map
1498+
                       (lambda (n)
1499+
                         (let ((n (number->string n)))
1500+
                           (string-append "e" n)))
1501+
                       (iota arity))
1502+
                     ", "))
1503+
                 (string-append "
1504+
|
1505+
|class HMapBuilder[R[_, _]] {
1506+
-
1507+
-  def apply
1508+
-    [" typeArgs "]
1509+
-    (" args ")
1510+
-    (implicit " witnesses ")
1511+
-    = new HMap[R](Map(" mapArgs "))
1512+
|}
1513+
")))
1514+
             (generate-file
1515+
               "unpack.scala"
1516+
               (lambda (arity template)
1517+
                 (define typeblock
1518+
                   (string-append "FF[" (assoc-ref template 'A--N) "], FF, " 
1519+
                                  (assoc-ref template 'A--N)))
1520+
                 (define hktypeblock
1521+
                   (string-append "FF[" (assoc-ref template '_--_) "], "
1522+
                                  (assoc-ref template 'A--N)))
1523+
                 (define traitname (string-append "Unpack" (number->string arity)))
1524+
                 (string-append "
1525+
|
1526+
-
1527+
-/**
1528+
- * Type class witnessing that type `PP` is equal to `FF[" (assoc-ref template 'A--N) "]` for some higher kinded type `FF[" (assoc-ref template '_--_) "]` and type(s) `" (assoc-ref template 'A--N) "`.
1529+
- * 
1530+
- * @author Miles Sabin
1531+
- */
1532+
-trait " traitname "[-PP, " hktypeblock "]
1533+
-
1534+
-object " traitname " {
1535+
-  implicit def unpack[" hktypeblock "]: " traitname "[" typeblock "] = new " traitname "[" typeblock "] {}
1536+
-}
1537+
|
11181538
")))
11191539
             #t))
11201540
         (replace 'build
1121-
           (lambda _
1122-
             (mkdir-p "build/classes")
1123-
             (mkdir-p "build/jar")
1124-
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
1125-
                    "-d" "build/classes"
1126-
                    (find-files "utils/shared/src/main/scala" ".*.scala$"))
1127-
             (apply invoke "scalac" "-classpath"
1128-
                    (string-append (getenv "CLASSPATH") ":build/classes")
1129-
                    "-d" "build/classes"
1130-
                    (find-files "fastparse/shared/src/main/scala" ".*.scala$"))
1131-
             (invoke "jar" "cf" "build/jar/fastparse.jar" "-C" "build/classes" ".")
1132-
             #t))
1541+
           ,(build-scala-phase '(("core" "scala-shapeless"))
1542+
              #:scala-locations '("src/main/scala"
1543+
                                  "src/main/scala_2.13+")))
11331544
         (replace 'install
11341545
           (install-jars "build")))))
1135-
    (inputs
1136-
     `(("scala-acyclic" ,scala-acyclic)
1137-
       ("scala-sourcecode" ,scala-sourcecode)))))
1138-
1139-
;; LICENSE?
1140-
(define-public scala-protobuf
1141-
  (package
1142-
    (name "scala-protobuf")
1143-
    (version "0.8.3")
1144-
    (source (origin
1145-
              (method url-fetch)
1146-
              (uri (string-append "https://github.com/scalapb/ScalaPB/archive/v"
1147-
                                  version ".tar.gz"))
1148-
              (file-name (string-append name "-" version ".tar.gz"))
1149-
              (sha256
1150-
               (base32
1151-
                "0x6mfpyhzxh54dxh1pj3x952gyvp05m7vkj0c3p8ssx214r327kj"))
1152-
              (modules '((guix build utils)))
1153-
              (snippet
1154-
                `(delete-file-recursively "third_party"))))
1155-
    (build-system ant-build-system)
1156-
    (arguments
1157-
     `(#:tests? #f; TODO
1158-
       #:phases
1159-
       (modify-phases %standard-phases
1160-
         (add-before 'build 'generate-sources
1161-
           (lambda _
1162-
             (with-output-to-file "compiler-plugin/src/main/scala/scalapb/compiler/Version.scala"
1163-
               (lambda _
1164-
                 (format #t "package scalapb.compiler
1165-
object Version {
1166-
  val scalapbVersion = \"~a\"
1167-
  val protobufVersion = \"~a\"
1168-
  val grpcJavaVersion = \"~a\"
1169-
}" ,version ,(package-version protobuf) "TODO")))
1170-
             (mkdir-p "compiler-plugin/src/main/scala/scalapb/compiler/internal")
1171-
             (copy-file
1172-
               "scalapb-runtime/shared/src/main/scala/scalapb/Encoding.scala"
1173-
               "compiler-plugin/src/main/scala/scalapb/compiler/internal/Encoding.scala")
1174-
             (substitute* "compiler-plugin/src/main/scala/scalapb/compiler/internal/Encoding.scala"
1175-
               (("package scalapb") "package scalapb.internal"))
1176-
             #t))
1177-
         (add-before 'build 'merge-runtime
1178-
           (lambda _
1179-
             (copy-recursively "scalapb-runtime/shared/src" "scalapb-runtime/src")
1180-
             (copy-recursively "scalapb-runtime/jvm/src" "scalapb-runtime/src")
1181-
             #t))
1182-
         (add-before 'build 'copy-compat
1183-
           (lambda _
1184-
             (with-directory-excursion "scalapb-runtime/src/main"
1185-
               (copy-file "scala-2.11/scalapb/textformat/ParserCompat.scala"
1186-
                          "scala/scalapb/textformat/ParserCompat.scala"))
1187-
             #t))
1188-
         (replace 'build
1189-
           ,(sbt-building-phase
1190-
              '(("lenses/" "shared")
1191-
                ("" "scalapb-runtime")
1192-
                ("" "compiler-plugin")
1193-
                ("" "scalapbc"))))
1194-
         (replace 'install
1195-
           (install-jars "build"))
1196-
         (add-after 'install 'install-bin
1197-
           (lambda* (#:key inputs outputs #:allow-other-keys)
1198-
             (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
1199-
               (mkdir-p bin)
1200-
               (with-output-to-file (string-append bin "/scalapbc")
1201-
                 (lambda _
1202-
                   (format #t "#!~a
1203-
java -cp ~a scalapb.ScalaPBC $@\n" (which "bash")
1204-
                           (string-join
1205-
                             (append
1206-
                               (find-files (assoc-ref outputs "out") ".*.jar")
1207-
                               (find-files (assoc-ref inputs "java-protobuf") ".*.jar")
1208-
                               (find-files (assoc-ref inputs "java-protoc-jar") ".*.jar")
1209-
                               (find-files (assoc-ref inputs "scala-fastparse1") ".*.jar")
1210-
                               (find-files (assoc-ref inputs "scala-protoc-bridge") ".*.jar")
1211-
                               (find-files (assoc-ref inputs "scala-sourcecode") ".*.jar")
1212-
                               (find-files (assoc-ref inputs "scala") ".*.jar"))
1213-
                             ":"))))
1214-
               (chmod (string-append bin "/scalapbc") #o755))
1215-
             #t)))))
1216-
    (inputs
1217-
     `(("java-protobuf" ,java-protobuf)
1218-
       ("java-protoc-jar" ,java-protoc-jar)
1219-
       ("scala-fastparse1" ,scala-fastparse1)
1220-
       ("scala-protoc-bridge" ,scala-protoc-bridge)
1221-
       ("scala-sourcecode" ,scala-sourcecode)))
12221546
    (native-inputs
1223-
     `(("protobuf" ,protobuf)
1224-
       ("scala" ,scala-official)))
1547+
     `(("scala" ,scala)))
12251548
    (home-page "")
12261549
    (synopsis "")
12271550
    (description "")
1228-
    (license license:bsd-3)))
1551+
    (license license:asl2.0)))
12291552
1230-
(define-public sbt-sbinary
1553+
(define-public scala-argonaut-shapeless
12311554
  (package
1232-
    (name "sbt-sbinary")
1233-
    (version "0.5.0")
1234-
    (source
1235-
      (origin
1236-
        (method url-fetch)
1237-
        (uri (string-append "https://github.com/sbt/sbinary/archive/v"
1238-
                            version ".tar.gz"))
1239-
        (file-name (string-append "sbt-util-" version ".tar.gz"))
1240-
        (sha256
1241-
         (base32
1242-
          "12mcny4flfc6zbgncjwqljrsg6qw7azagkackyqcp4gmv9ssw99f"))))
1555+
    (name "scala-argonaut-shapeless")
1556+
    (version "1.3.0")
1557+
    (source (origin
1558+
              (method git-fetch)
1559+
              (uri (git-reference
1560+
                     (url "https://github.com/alexarchambault/argonaut-shapeless")
1561+
                     (commit (string-append "v" version))))
1562+
              (file-name (git-file-name name version))
1563+
              (sha256
1564+
               (base32
1565+
                "0afa81fjhrjhb97iapkhv4jax9ply6mk9chmr0kwps12drjmwn03"))))
12431566
    (build-system ant-build-system)
12441567
    (arguments
12451568
     `(#:tests? #f
12461569
       #:phases
12471570
       (modify-phases %standard-phases
1248-
         (add-before 'build 'generate-fmpp
1249-
           (lambda _
1250-
             (invoke "fmpp" "-U" "all" "-S" "core/src/main/fmpp" "-O"
1251-
                     "core/src/main/scala")
1252-
             #t))
12531571
         (replace 'build
1254-
           (lambda* (#:key inputs #:allow-other-keys)
1255-
             (mkdir-p "build/classes")
1256-
             (apply invoke "scalac" "-classpath"
1257-
                    (string-append (getenv "CLASSPATH") ":build/util-interface")
1258-
                    "-d" "build/classes"
1259-
                    (append
1260-
                      (find-files "core/src/main/scala-2.13-" ".*.scala$")
1261-
                      (find-files "core/src/main/scala" ".*.scala$")))
1262-
             (invoke "jar" "cf" "sbt-sbinary.jar" "-C" "build/classes" ".")
1263-
             #t))
1572+
           ,(build-scala-phase '(("core" "scala-argonaut-shapeless"))
1573+
              #:scala-locations '("shared/src/main/scala")))
12641574
         (replace 'install
1265-
           (install-jars ".")))))
1575+
           (install-jars "build")))))
12661576
    (native-inputs
1267-
     `(("java-fmpp" ,java-fmpp)
1268-
       ("scala" ,scala-official)))
1269-
    (home-page "https://www.scala-sbt.org/")
1577+
     `(("scala" ,scala)))
1578+
    (propagated-inputs
1579+
     `(("scala-argonaut" ,scala-argonaut)
1580+
       ("scala-shapeless" ,scala-shapeless)))
1581+
    (home-page "")
12701582
    (synopsis "")
12711583
    (description "")
1272-
    (license license:bsd-3)))
1584+
    (license license:asl2.0)))
12731585
1274-
(define-public sbt-zinc
1586+
(define-public scala-coursier
12751587
  (package
1276-
    (name "sbt-zinc")
1277-
    (version "1.2.5")
1278-
    (source
1279-
      (origin
1280-
        (method url-fetch)
1281-
        (uri (string-append "https://github.com/sbt/zinc/archive/v"
1282-
                            version ".tar.gz"))
1283-
        (file-name (string-append name "-" version ".tar.gz"))
1284-
        (sha256
1285-
         (base32
1286-
          "1b01nv3dk3g7jx59jnzp2m2va5brhmds4bpgp824fnmp2fdjzgl0"))))
1588+
    (name "scala-coursier")
1589+
    (version "2.0.16")
1590+
    (source (origin
1591+
              (method git-fetch)
1592+
              (uri (git-reference
1593+
                     (url "https://github.com/coursier/coursier")
1594+
                     (commit (string-append "v" version))))
1595+
              (file-name (git-file-name name version))
1596+
              (sha256
1597+
               (base32
1598+
                "0cvy7bnqg8s2s4xljnw0p9r970yjqzg56f5nwgg0z2g18pafa3im"))))
12871599
    (build-system ant-build-system)
12881600
    (arguments
12891601
     `(#:tests? #f
12901602
       #:phases
12911603
       (modify-phases %standard-phases
1292-
         (add-before 'build 'generate-protobuf
1604+
         (add-after 'unpack 'remove-proprietary-interfaces
12931605
           (lambda _
1294-
             (invoke "scalapbc"
1295-
                     (string-append
1296-
                       "-v"
1297-
                       (string-delete #\. ,(package-version protobuf)))
1298-
                     "--scala_out=internal/zinc-persist/src/main/scala"
1299-
                     "internal/zinc-persist/src/main/protobuf/schema.proto")
1300-
             #t))
1301-
         (add-before 'build 'use-correct-class
1302-
           (lambda _
1303-
             ;; Because of our way of compiling, some classes are present
1304-
             ;; in excess in the classpath, and sometimes are imported
1305-
             ;; instead of the correct one. e.g. is AnalysisCallback imported
1306-
             ;; as xsbti.AnalysisCallback and inc.AnalysisCallback
1307-
             (with-directory-excursion "internal/zinc-compile-core/src/main/scala"
1308-
               (substitute* "sbt/internal/inc/AnalyzingCompiler.scala"
1309-
                 ((": AnalysisCallback") ": xsbti.AnalysisCallback")))
1310-
             #t))
1606+
             (delete-file
1607+
               "modules/cache/jvm/src/main/java/coursier/cache/internal/SigWinchNativeWindows.java")))
13111608
         (replace 'build
1312-
           ,(sbt-building-phase
1313-
              '(("internal/" "compiler-interface")
1314-
                ("internal/" "zinc-classpath")
1315-
                ("internal/" "zinc-classfile")
1316-
                ("internal/" "zinc-apiinfo")
1317-
                ("internal/" "zinc-core")
1318-
                ("internal/" "zinc-persist")
1319-
                ("internal/" "zinc-compile-core")
1320-
                ("internal/" "zinc-ivy-integration")
1321-
                ("" "zinc-compile")
1322-
                ("" "zinc"))))
1323-
         (replace 'install
1324-
           (install-jars ".")))))
1325-
    (inputs
1326-
     `(("java-log4j-api" ,java-log4j-api-for-sbt)
1327-
       ("java-log4j-core" ,java-log4j-core-for-sbt)
1328-
       ("java-protobuf" ,java-protobuf)
1329-
       ("sbt-io" ,sbt-io)
1330-
       ("sbt-launcher" ,sbt-launcher)
1331-
       ("sbt-librarymanagement" ,sbt-librarymanagement)
1332-
       ("sbt-sbinary" ,sbt-sbinary)
1333-
       ("sbt-util" ,sbt-util)
1334-
       ("scala-protoc-bridge" ,scala-protoc-bridge)
1335-
       ("scala-sjsonnew" ,scala-sjsonnew)))
1336-
    (native-inputs
1337-
     `(("scala-protobuf" ,scala-protobuf)
1338-
       ("scala" ,scala-official)))
1339-
    (home-page "")
1340-
    (synopsis "")
1341-
    (description "")
1342-
    (license license:bsd-3)))
1343-
1344-
(define-public scala-cache
1345-
  (package
1346-
    (name "scala-cache")
1347-
    (version "0.27.0")
1348-
    (source
1349-
      (origin
1350-
        (method url-fetch)
1351-
        (uri (string-append "https://github.com/cb372/scalacache/archive/v"
1352-
                            version ".tar.gz"))
1353-
        (file-name (string-append name "-" version ".tar.gz"))
1354-
        (sha256
1355-
         (base32
1356-
          "0iqs1zvwr19j9k726f4zf4jzqlx5y1br87ijras668c3wd301h1k"))))
1357-
    (build-system ant-build-system)
1358-
    (arguments
1359-
     `(#:tests? #f
1360-
       #:phases
1361-
       (modify-phases %standard-phases
1362-
         (add-before 'build 'merge-core
1609+
           ,(build-scala-phase
1610+
              '(("modules/util" "scala-coursier-util")
1611+
                ("modules/core" "scala-coursier-core")
1612+
                ("modules/paths" "scala-coursier-paths")
1613+
                ("modules/cache" "scala-coursier-cache")
1614+
                ("modules/coursier" "scala-coursier"))
1615+
              #:scala-arguments '("-Ymacro-annotations")))
1616+
         (add-after 'unpack 'remove-compat
13631617
           (lambda _
1364-
             (copy-recursively "modules/core/jvm" "modules/core")
1365-
             (copy-recursively "modules/core/shared" "modules/core")
1618+
             (substitute* (find-files "." "\\.scala$")
1619+
               (("import scala.collection.compat.*") ""))
13661620
             #t))
1367-
         (replace 'build
1368-
           ,(sbt-building-phase
1369-
             `(("modules/" "core")
1370-
               ("modules/" "caffeine"))))
13711621
         (replace 'install
1372-
           (install-jars ".")))))
1373-
    (inputs
1374-
     `(("java-caffeine" ,java-caffeine)
1375-
       ("java-slf4j-api" ,java-slf4j-api)))
1622+
           (install-jars "build")))))
13761623
    (native-inputs
1377-
     `(("scala" ,scala-official)))
1378-
    (home-page "https://www.scala-sbt.org/")
1624+
     `(("scala" ,scala)))
1625+
    ;; XXX: dirs-dev is normally shaded, so should we really propagate it?
1626+
    (propagated-inputs
1627+
     `(("java-jsoup" ,java-jsoup)
1628+
       ("java-concurrent-reference-hash-map" ,java-concurrent-reference-hash-map)
1629+
       ("scala-argonaut-shapeless" ,scala-argonaut-shapeless)
1630+
       ("scala-data-class" ,scala-data-class)
1631+
       ("scala-dirs-dev-directories" ,scala-dirs-dev-directories)
1632+
       ("scala-fastparse" ,scala-fastparse)
1633+
       ("scala-simulacrum" ,scala-simulacrum)
1634+
       ("scala-windowsansi" ,scala-windowsansi)
1635+
       ("scala-xml" ,scala-xml)))
1636+
    (home-page "")
13791637
    (synopsis "")
13801638
    (description "")
1381-
    (license license:bsd-3)))
1639+
    (license license:asl2.0)))
13821640
1383-
(define-public sbt-jars
1641+
(define-public sbt-launcher
13841642
  (package
1385-
    (name "sbt-jars")
1386-
    (version "1.2.8")
1643+
    (name "sbt-launcher")
1644+
    (version "1.3.2")
13871645
    (source (origin
1388-
              (method url-fetch)
1389-
              (uri (string-append "https://github.com/sbt/sbt/archive/v"
1390-
                                  version ".tar.gz"))
1391-
              (file-name (string-append name "-" version ".tar.gz"))
1646+
              (method git-fetch)
1647+
              (uri (git-reference
1648+
                     (url "https://github.com/sbt/launcher")
1649+
                     (commit (string-append "v" version))))
1650+
              (file-name (git-file-name name version))
13921651
              (sha256
13931652
               (base32
1394-
                "0fpm9jcd84xjxlfdfh2iwz7544ksgqik6591i7nrzlamygmbfadr"))
1395-
              (modules '((guix build utils)))
1396-
              (snippet
1397-
                `(begin
1398-
                   (for-each delete-file (find-files "." ".*.jar"))
1399-
                   #t))))
1653+
                "0xff9w9arj91vgh5mbzb52r2l1ij42cby3kbbmkly1nf3j4xhrx2"))))
14001654
    (build-system ant-build-system)
14011655
    (arguments
14021656
     `(#:tests? #f
14031657
       #:phases
14041658
       (modify-phases %standard-phases
1405-
         (add-before 'build 'fix-sjsonnew
1406-
           (lambda _
1407-
             (substitute* (find-files "." ".*.scala")
1408-
               (("sjsonnew.shaded.") ""))
1409-
             #t))
1410-
         (add-before 'build 'copy-resources
1411-
           (lambda _
1412-
             (copy-recursively "sbt/src/main/resources" "build/classes")
1413-
             #t))
1414-
         (add-before 'build 'generate-scalakeywords.scala
1659+
         (add-before 'build 'generate-manifest
1660+
           (lambda* (#:key outputs #:allow-other-keys)
1661+
             (define (split n str)
1662+
               (if (<= (string-length str) n)
1663+
                 (list str)
1664+
                 (cons (substring str 0 n) (split n (substring str n)))))
1665+
             (let ((dir "launcher-implementation/src/main/resources/META-INF"))
1666+
               (mkdir-p dir)
1667+
               (with-output-to-file (string-append dir "/MANIFEST.MF")
1668+
                 (lambda _
1669+
                   (format #t "Manifest-Version: 1.0\n")
1670+
                   ;(format #t "Class-Path: ~a\n"
1671+
                   ;        (string-join
1672+
                   ;          (split
1673+
                   ;            58
1674+
                   ;            (string-join
1675+
                   ;              (map
1676+
                   ;                (lambda (jar)
1677+
                   ;                  ;; We can't use absolute paths with java 8 :/
1678+
                   ;                  (string-append "../../../../../../../../.." jar))
1679+
                   ;                (cons
1680+
                   ;                  (string-append
1681+
                   ;                    (assoc-ref outputs "out")
1682+
                   ;                    "/share/java/sbt-launcher-interface.jar")
1683+
                   ;                  (string-split (getenv "CLASSPATH") #\:)))
1684+
                   ;              " "))
1685+
                   ;           "\n "))
1686+
                   (format #t "Main-Class: xsbt.boot.Boot\n\n"))))))
1687+
         (add-after 'unpack 'fill-template
14151688
           (lambda _
1416-
             (with-output-to-file "project/WriteKeywords.scala"
1417-
               (lambda _
1418-
                 (format #t "package project
1419-
object WriteKeywords {
1420-
  def main(arg: Array[String]): Unit = {
1421-
    val g = new scala.tools.nsc.Global(new scala.tools.nsc.Settings)
1422-
    val keywords = g.nme.keywords.map(_.toString)
1423-
    val init = keywords.map(tn => '\"' + tn + '\"').mkString(\"Set(\", \", \", \")\")
1424-
    val ObjectName = \"ScalaKeywords\"
1425-
    val PackageName = \"sbt.internal.util\"
1426-
    val keywordsSrc = s\"\"\"
1427-
      |package $PackageName
1428-
      |object $ObjectName {
1429-
      |  val values = $init
1430-
      |}
1431-
    \"\"\".trim.stripMargin
1432-
    val base = \"internal/util-collection/src/main/scala\"
1433-
    val out = base + \"/\" + PackageName.replace('.', '/') + \"/\" + s\"$ObjectName.scala\"
1434-
    val result = new java.io.PrintWriter(new java.io.File(out))
1435-
    result.write(keywordsSrc)
1436-
    result.close()
1437-
  }
1438-
}")))
1439-
             (invoke "scalac" "-classpath" (getenv "CLASSPATH") "project/WriteKeywords.scala")
1440-
             (invoke "java" "-cp" (string-append (getenv "CLASSPATH") ":.")
1441-
                     "project.WriteKeywords")
1689+
             (substitute* "launcher-implementation/src/main/input_sources/CrossVersionUtil.scala"
1690+
               (("\\$\\{\\{cross.package0\\}\\}") "xsbt")
1691+
               (("\\$\\{\\{cross.package1\\}\\}") "boot"))
1692+
             (copy-file "launcher-implementation/src/main/input_sources/CrossVersionUtil.scala"
1693+
                        "launcher-implementation/src/main/scala/CrossVersionUtil.scala")
14421694
             #t))
14431695
         (replace 'build
1444-
           ,(sbt-building-phase
1445-
             `(("internal/" "util-collection")
1446-
               ("internal/" "util-complete")
1447-
               ("internal/" "util-logic")
1448-
               ("testing/" "agent")
1449-
               ("" "testing")
1450-
               ("" "core-macros")
1451-
               ("" "tasks")
1452-
               ("" "tasks-standard")
1453-
               ("" "protocol")
1454-
               ("" "run")
1455-
               ("" "main-command")
1456-
               ("" "main-settings")
1457-
               ("" "main-actions")
1458-
               ("" "main")
1459-
               ("" "sbt"))
1460-
             #t))
1461-
         (add-before 'build 'build-launch
1462-
           (lambda* (#:key inputs #:allow-other-keys)
1463-
             (mkdir-p "build/launch")
1464-
             (mkdir-p "build/jar")
1465-
             (with-directory-excursion "build/launch"
1466-
               (invoke "jar" "xf" (string-append
1467-
                                    (assoc-ref inputs "sbt-launcher")
1468-
                                    "/share/java/sbt-launcher.jar")))
1469-
             (copy-recursively "launch/src/main/input_resources" "build/launch")
1470-
             (copy-recursively "launch/src/main/resources" "build/launch")
1471-
             (substitute* "build/launch/sbt/sbt.boot.properties"
1472-
               (("\\$\\{\\{sbt.version\\}\\}") ,version)
1473-
               (("\\$\\{\\{org\\}\\}") "org.scala-sbt"))
1474-
             (invoke "jar" "cmf" "build/launch/META-INF/MANIFEST.MF"
1475-
                     "build/jar/sbt-launch.jar" "-C" "build/launch" ".")
1476-
             #t))
1696+
           ,(build-scala-phase
1697+
              '(("launcher-interface" "sbt-launcher-interface")
1698+
                ("launcher-implementation" "sbt-launcher-implementation"))))
14771699
         (replace 'install
1478-
           (install-jars ".")))))
1700+
           (install-jars "build")))))
14791701
    (inputs
1480-
     `(("java-apache-ivy" ,java-apache-ivy)
1481-
       ("java-sbt-ipcsocket" ,java-sbt-ipcsocket)
1482-
       ("java-sbt-test-interface" ,java-sbt-test-interface)
1483-
       ("java-log4j-api" ,java-log4j-api-for-sbt)
1484-
       ("java-log4j-core" ,java-log4j-core-for-sbt)
1485-
       ("java-native-access" ,java-native-access)
1486-
       ("scala" ,scala-official)
1487-
       ("scala-cache" ,scala-cache)
1488-
       ("scala-jawn" ,scala-jawn)
1489-
       ("scala-scalajson" ,scala-scalajson)
1490-
       ("scala-sjsonnew" ,scala-sjsonnew)
1491-
       ("scala-sjsonnew-support-murmurhash" ,scala-sjsonnew-support-murmurhash)
1492-
       ("scala-sjsonnew-support-scalajson" ,scala-sjsonnew-support-scalajson)
1493-
       ("sbt-io" ,sbt-io)
1494-
       ("sbt-launcher" ,sbt-launcher)
1495-
       ("sbt-librarymanagement" ,sbt-librarymanagement)
1496-
       ("sbt-util" ,sbt-util)
1497-
       ("sbt-zinc" ,sbt-zinc)))
1702+
     `(("sbt-ivy" ,sbt-ivy)
1703+
       ("scala-coursier" ,scala-coursier)))
14981704
    (native-inputs
1499-
     `(("scala-kind-projector" ,scala-kind-projector)))
1500-
    (home-page "https://www.scala-sbt.org/")
1705+
     `(("scala" ,scala)))
1706+
    (home-page "")
15011707
    (synopsis "")
15021708
    (description "")
15031709
    (license license:bsd-3)))
15041710
1505-
(define-public sbt
1711+
;; This subproject is the one that is provides the binary "sbt". Its role is
1712+
;; is to download and execute the full sbt, so it is not very usable for package
1713+
;; building right now.
1714+
(define-public sbt-launch
15061715
  (package
15071716
    (name "sbt")
1508-
    (version (package-version sbt-jars))
1717+
    (version "1.5.4")
15091718
    (source (origin
1510-
              (method url-fetch)
1511-
              (uri (string-append "https://github.com/sbt/sbt-launcher-package/"
1512-
                                  "archive/v" version ".tar.gz"))
1513-
              (file-name (string-append name "-" version ".tar.gz"))
1719+
              (method git-fetch)
1720+
              (uri (git-reference
1721+
                     (url "https://github.com/sbt/sbt")
1722+
                     (commit (string-append "v" version))))
1723+
              (file-name (git-file-name name version))
15141724
              (sha256
15151725
               (base32
1516-
                "0bcqjambyf4x89ind2hg6ngh6qn46wiwa8q4gcyw65jyl4rsxls9"))))
1517-
    (build-system gnu-build-system)
1726+
                "0k3ywjmahlhnr9rg29pac6n64x8pgaz5q7p4gn548mc3nm1fwzdj"))))
1727+
    (build-system ant-build-system)
15181728
    (arguments
1519-
     `(#:tests? #f; no tests
1729+
     `(#:tests? #f
15201730
       #:phases
15211731
       (modify-phases %standard-phases
1522-
         (delete 'configure)
1523-
         (delete 'build)
1732+
         (replace 'build
1733+
           (lambda* (#:key inputs #:allow-other-keys)
1734+
             (let ((launcher (assoc-ref inputs "sbt-launcher"))
1735+
                   (scala (assoc-ref inputs "scala")))
1736+
               (mkdir-p "build/sbt")
1737+
               (with-directory-excursion "build"
1738+
                 (copy-file "../launch/src/main/input_resources/sbt/sbt.boot.properties"
1739+
                            "sbt/sbt.boot.properties")
1740+
                 (substitute* "sbt/sbt.boot.properties"
1741+
                   (("\\$\\{\\{sbt.version\\}\\}") ,version)
1742+
                   (("\\$\\{\\{org\\}\\}") "org.scala-sbt"))
1743+
                 (copy-recursively "../launch/src/main/resources" ".")
1744+
                 ;; Create a standalon jar file, with all its dependencies
1745+
                 (for-each
1746+
                   (lambda (package)
1747+
                     (for-each
1748+
                       (lambda (jar)
1749+
                         (invoke "jar" "xf" jar))
1750+
                       (find-files (assoc-ref inputs package) ".*.jar$")))
1751+
                   '("java-concurrent-reference-hash-map" "java-jansi"
1752+
                     "sbt-ivy" "scala-coursier" "scala-dirs-dev-directories"
1753+
                     "scala-fastparse" "scala-xml"))
1754+
                 (invoke
1755+
                   "jar" "xf"
1756+
                   (string-append scala "/lib/scala-library.jar"))
1757+
                 (invoke
1758+
                   "jar" "xf"
1759+
                   (string-append launcher "/share/java/sbt-launcher-interface.jar"))
1760+
                 ;; Make it last so it can override META-INF/MANIFEST.MF
1761+
                 (invoke
1762+
                   "jar" "xf"
1763+
                   (string-append launcher "/share/java/sbt-launcher-implementation.jar"))
1764+
                 (invoke "jar" "cfm" "../sbt-launch.jar" "META-INF/MANIFEST.MF"
1765+
                         ".")
1766+
                 ;; We need to shade some of the dependencies, or they will conflict
1767+
                 ;; with what SBT downloads later, leading to errors such as
1768+
                 ;; NoSuchMethodError, etc.
1769+
                 ;; We use jarjar for that task.
1770+
                 (let ((jarjar
1771+
                        (car (find-files (assoc-ref inputs "java-jarjar") ".*.jar$")))
1772+
                       (injar "../sbt-launch.jar")
1773+
                       (outjar "../sbt-launch-shaded.jar"))
1774+
                   (with-output-to-file "rules"
1775+
                     (lambda _
1776+
                       (format #t (string-append
1777+
                                    "rule "
1778+
                                    "coursier.** "
1779+
                                    "xsbt.boot.internal.shaded."
1780+
                                    "coursier.@1~%"))
1781+
                       (format #t (string-append
1782+
                                    "rule "
1783+
                                    "fastparse.** "
1784+
                                    "coursier.core.shaded."
1785+
                                    "fastparse.@1~%"))
1786+
                       (format #t (string-append
1787+
                                    "rule "
1788+
                                    "dev.dirs.** "
1789+
                                    "coursier.chache.shaded.dirs."
1790+
                                    "dev.dirs.@1~%"))
1791+
                       (format #t (string-append
1792+
                                    "rule "
1793+
                                    "concurrentrefhashmap.** "
1794+
                                    "xsbt.boot.internal.shaded.concurrentrefhashmap."
1795+
                                    "concurrentrefhashmap.@1~%"))))
1796+
                   (invoke "java" "-jar" jarjar "process" "rules" injar outjar)
1797+
                   (delete-file injar)
1798+
                   (rename-file outjar injar))
1799+
                 ))))
15241800
         (replace 'install
15251801
           (lambda* (#:key outputs inputs #:allow-other-keys)
1526-
             (delete-file "src/universal/bin/sbt.bat")
1527-
             (let ((out (assoc-ref outputs "out"))
1528-
                   (sbt (assoc-ref inputs "sbt-jars"))
1529-
                   (scala (assoc-ref inputs "scala"))
1530-
                   (icedtea (assoc-ref inputs "icedtea")))
1531-
               (substitute* "src/universal/bin/sbt-launch-lib.bash"
1532-
                 (("java_cmd=.*") (string-append "java_cmd=\"" icedtea "/bin/java\"\n")))
1533-
               (mkdir-p (string-append out "/lib/local-preloaded"))
1534-
               (for-each
1535-
                 (lambda (package)
1536-
                   (for-each
1537-
                     (lambda (jar)
1538-
                       (symlink jar (string-append out "/lib/local-preloaded/"
1539-
                                                   (basename jar))))
1540-
                     (find-files (assoc-ref inputs package) ".*.jar$")))
1541-
                 '("scala" "sbt-jars"))
1542-
               (copy-recursively "src/universal" out)
1543-
               (copy-recursively "src/linux/usr" out)
1544-
               (copy-file (string-append sbt "/share/java/sbt-launch.jar")
1545-
                          (string-append out "/bin/sbt-launch.jar")))
1546-
             #t)))))
1802+
             (substitute* "sbt"
1803+
               (("_to_be_replaced") ,(package-version this-package)))
1804+
             (let* ((out (assoc-ref outputs "out"))
1805+
                    (bin (string-append out "/bin")))
1806+
               (chmod "sbt" #o755)
1807+
               (install-file "sbt" bin)
1808+
               (install-file "sbt-launch.jar" bin)))))))
15471809
    (inputs
1548-
     `(("icedtea" ,icedtea-8)
1549-
       ("sbt-jars" ,sbt-jars)
1550-
       ("scala" ,scala-official)))
1551-
    (home-page "https://www.scala-sbt.org/")
1810+
     `(("java-concurrent-reference-hash-map" ,java-concurrent-reference-hash-map)
1811+
       ("java-jansi" ,java-jansi)
1812+
       ("java-jarjar" ,java-jarjar)
1813+
       ("sbt-launcher" ,sbt-launcher)
1814+
       ("sbt-ivy" ,sbt-ivy)
1815+
       ("scala" ,scala)
1816+
       ("scala-coursier" ,scala-coursier)
1817+
       ("scala-dirs-dev-directories" ,scala-dirs-dev-directories)
1818+
       ("scala-fastparse" ,scala-fastparse)
1819+
       ("scala-xml" ,scala-xml)))
1820+
    (home-page "")
15521821
    (synopsis "")
15531822
    (description "")
1554-
    (license license:bsd-3)))
1823+
    (license license:asl2.0)))

sbt-ivy-fix-bouncycastle-api.patch unknown status 1

1+
From 5c27ac3ca1ac9544c3d80a7a1abf2610ebec4ea6 Mon Sep 17 00:00:00 2001
2+
From: Julien Lepiller <julien@lepiller.eu>
3+
Date: Thu, 17 Jun 2021 00:04:48 +0200
4+
Subject: [PATCH] Fix API breakage
5+
6+
---
7+
 .../OpenPGPSignatureGenerator.java            | 34 +++++++++----------
8+
 1 file changed, 16 insertions(+), 18 deletions(-)
9+
10+
diff --git a/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java b/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
11+
index af7beae..a9282ed 100644
12+
--- a/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
13+
+++ b/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
14+
@@ -42,6 +42,10 @@ import org.bouncycastle.openpgp.PGPSignature;
15+
 import org.bouncycastle.openpgp.PGPSignatureGenerator;
16+
 import org.bouncycastle.openpgp.PGPUtil;
17+
 
18+
+import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
19+
+import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
20+
+import org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
21+
+
22+
 public class OpenPGPSignatureGenerator implements SignatureGenerator {
23+
 
24+
     private static final long MASK = 0xFFFFFFFFL;
25+
@@ -101,11 +105,16 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator {
26+
                 pgpSec = readSecretKey(keyIn);
27+
             }
28+
 
29+
-            PGPPrivateKey pgpPrivKey = pgpSec.extractPrivateKey(password.toCharArray(),
30+
-                BouncyCastleProvider.PROVIDER_NAME);
31+
-            PGPSignatureGenerator sGen = new PGPSignatureGenerator(pgpSec.getPublicKey()
32+
-                    .getAlgorithm(), PGPUtil.SHA1, BouncyCastleProvider.PROVIDER_NAME);
33+
-            sGen.initSign(PGPSignature.BINARY_DOCUMENT, pgpPrivKey);
34+
+            PGPPrivateKey pgpPrivKey =
35+
+                pgpSec.extractPrivateKey(
36+
+                        new JcePBESecretKeyDecryptorBuilder().setProvider( new BouncyCastleProvider() )
37+
+                                .build( password.toCharArray() ) );
38+
+            PGPSignatureGenerator sGen = new PGPSignatureGenerator(
39+
+                new JcaPGPContentSignerBuilder( pgpSec.getPublicKey().getAlgorithm(),
40+
+                        PGPUtil.SHA1)
41+
+                            .setProvider(  new BouncyCastleProvider() ) );
42+
+
43+
+            sGen.init(PGPSignature.BINARY_DOCUMENT, pgpPrivKey);
44+
 
45+
             in = new FileInputStream(src);
46+
             out = new BCPGOutputStream(new ArmoredOutputStream(new FileOutputStream(dest)));
47+
@@ -116,22 +125,10 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator {
48+
             }
49+
 
50+
             sGen.generate().encode(out);
51+
-        } catch (SignatureException e) {
52+
-            IOException ioexc = new IOException();
53+
-            ioexc.initCause(e);
54+
-            throw ioexc;
55+
         } catch (PGPException e) {
56+
             IOException ioexc = new IOException();
57+
             ioexc.initCause(e);
58+
             throw ioexc;
59+
-        } catch (NoSuchAlgorithmException e) {
60+
-            IOException ioexc = new IOException();
61+
-            ioexc.initCause(e);
62+
-            throw ioexc;
63+
-        } catch (NoSuchProviderException e) {
64+
-            IOException ioexc = new IOException();
65+
-            ioexc.initCause(e);
66+
-            throw ioexc;
67+
         } finally {
68+
             if (out != null) {
69+
                 try {
70+
@@ -156,7 +153,8 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator {
71+
 
72+
     private PGPSecretKey readSecretKey(InputStream in) throws IOException, PGPException {
73+
         in = PGPUtil.getDecoderStream(in);
74+
-        PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(in);
75+
+        PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(
76+
+                in, new JcaKeyFingerprintCalculator() );
77+
 
78+
         PGPSecretKey key = null;
79+
         for (Iterator it = pgpSec.getKeyRings(); key == null && it.hasNext();) {
80+
-- 
81+
2.31.1
82+