guix-more/more/packages/scala.scm

scala.scm

1
;;; GNU Guix --- Functional package management for GNU
2
;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
3
;;;
4
;;; This file is part of GNU Guix.
5
;;;
6
;;; GNU Guix is free software; you can redistribute it and/or modify it
7
;;; under the terms of the GNU General Public License as published by
8
;;; the Free Software Foundation; either version 3 of the License, or (at
9
;;; your option) any later version.
10
;;;
11
;;; GNU Guix is distributed in the hope that it will be useful, but
12
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
;;; GNU General Public License for more details.
15
;;;
16
;;; You should have received a copy of the GNU General Public License
17
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
18
19
(define-module (more packages scala)
20
  #:use-module ((guix licenses) #:prefix license:)
21
  #:use-module (gnu packages)
22
  #:use-module (guix packages)
23
  #:use-module (guix download)
24
  #:use-module (guix git-download)
25
  #:use-module (guix utils)
26
  #:use-module (guix build-system ant)
27
  #:use-module (guix build-system trivial)
28
  #:use-module (gnu packages base)
29
  #:use-module (gnu packages bash)
30
  #:use-module (gnu packages compression)
31
  #:use-module (gnu packages java))
32
33
;; This package downloads the so-called official version of scala, a pre-built
34
;; binary by the scala developers.
35
;; This binary should never be made part of Guix itself, because we have
36
;; ways to bootstrap it properly. The bootstrap project of scala takes time,
37
;; so in the meantime... here you are :(
38
(define-public scala-official
39
  (package
40
    (name "scala-official")
41
    (version "2.12.6")
42
    (source
43
      (origin
44
        (method url-fetch)
45
        (uri (string-append "https://downloads.lightbend.com/scala/"
46
                            version "/scala-" version ".tgz"))
47
        (sha256
48
         (base32
49
          "05ili2959yrshqi44wpmwy0dyfm4kvp6i8mlbnj1xvc5b9649iqs"))))
50
    (build-system trivial-build-system)
51
    (arguments
52
     `(#:modules ((guix build utils))
53
       #:builder (begin
54
                   (use-modules (guix build utils))
55
                   (let* ((source (assoc-ref %build-inputs "source"))
56
                          (java (assoc-ref %build-inputs "icedtea-8"))
57
                          (bash (assoc-ref %build-inputs "bash"))
58
                          (tar (string-append
59
                                 (assoc-ref %build-inputs "tar")
60
                                 "/bin/tar"))
61
                          (gzip (assoc-ref %build-inputs "gzip"))
62
                          (output (assoc-ref %outputs "out"))
63
                          (bindir (string-append output "/bin")))
64
                     (mkdir-p output)
65
                     (setenv "PATH" (string-append (getenv "PATH") ":" gzip "/bin"))
66
                     (invoke tar "xf" source)
67
                     (copy-recursively "scala-2.12.6" output)
68
                     (chdir output)
69
                     (for-each delete-file (find-files "bin" "bat$"))
70
                     (substitute* (find-files "bin" ".*")
71
                       (("^#!.*")
72
                        (string-append "#!" bash "/bin/bash\n" "JAVA_HOME=" java)))))))
73
    (inputs
74
     `(("bash" ,bash)
75
       ("gzip" ,gzip)
76
       ("icedtea-8" ,icedtea-8)
77
       ("tar" ,tar)))
78
    (home-page "https://scala-lang.org/")
79
    (synopsis "")
80
    (description "")
81
    (license license:bsd-3)))
82
83
(define-public sjsonnew
84
  (package
85
    (name "sjsonnew")
86
    (version "0.8.2")
87
    (source
88
      (origin
89
        (method url-fetch)
90
        (uri (string-append "https://github.com/eed3si9n/sjson-new/archive/v"
91
                            version ".tar.gz"))
92
        (file-name (string-append name "-" version ".tar.gz"))
93
        (sha256
94
         (base32
95
          "1rv0c50af5kn27x51g650wl2ig94z52fhs0rn8ykahpz4jhg1p7p"))))
96
    (arguments
97
     `(#:tests? #f
98
       #:jdk ,icedtea-8
99
       #:phases
100
       (modify-phases %standard-phases
101
         (replace 'build
102
           (lambda _
103
             (mkdir-p "build/classes")
104
             (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
105
                    "-d" "build/classes"
106
                    (find-files "core/src/main/scala" ".*.scala$"))
107
             #t)))))
108
    (build-system ant-build-system)
109
    (inputs
110
     `(("scala" ,scala-official)))
111
    (home-page "")
112
    (synopsis "")
113
    (description "")
114
    (license license:asl2.0)))
115
116
(define-public sbt
117
  (package
118
    (name "sbt")
119
    (version "1.2.1")
120
    (source
121
      (origin
122
        (method url-fetch)
123
        (uri (string-append "https://github.com/sbt/sbt/archive/v"
124
                            version ".tar.gz"))
125
        (file-name (string-append name "-" version ".tar.gz"))
126
        (sha256
127
         (base32
128
          "15i8fd7zgairaaikscrva8d1klz0w9nh7fc0896x1n8nrs578vmy"))))
129
    (build-system ant-build-system)
130
    (arguments
131
     `(#:tests? #f
132
       #:jdk ,icedtea-8
133
       #:phases
134
       (modify-phases %standard-phases
135
         (add-before 'build 'copy-resources
136
           (lambda _
137
             (copy-recursively "sbt/src/main/resources" "build/classes")
138
             #t))
139
         (replace 'build
140
           (lambda _
141
             (define (build-subproject prefix name)
142
               (let ((build-directory (string-append "build/" name))
143
                     (jar-name (string-append name ".jar")))
144
                 (mkdir-p build-directory)
145
                 (format #t "Building project ~a...~%" name)
146
                 (apply invoke "scalac" "-classpath" (getenv "CLASSPATH")
147
                        "-d" build-directory
148
                        (find-files (string-append prefix name "/src/main/scala")
149
                                    ".*.scala$"))
150
                 (invoke "jar" "cf" jar-name "-C" build-directory)))
151
             (build-subproject "internal/" "util-collection")
152
             (build-subproject "" "main-settings")
153
             (build-subproject "" "sbt")
154
             #t))
155
         (replace 'install
156
           (install-jars "build")))))
157
    (inputs
158
     `(("scala" ,scala-official)))
159
    (home-page "https://www.scala-sbt.org/")
160
    (synopsis "")
161
    (description "")
162
    (license license:bsd-3)))
163