Use https by default
[gentoo.git] / dev-lang / scala / scala-2.11.7.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 JAVA_PKG_IUSE="doc source"
8 JAVA_ANT_DISABLE_ANT_CORE_DEP="yes"
9 EANT_TEST_TARGET="test.suite"
10
11 inherit eutils check-reqs java-pkg-2 java-ant-2 versionator
12
13 MY_P="${PN}-sources-${PV}"
14 SV="$(get_version_component_range 1-2)"
15
16 # creating the binary:
17 # JAVA_PKG_FORCE_VM="$available-1.7" USE="doc source" ebuild scala-*.ebuild compile
18 # cd $WORDKIR
19 # tar -cjf scala-2.11.7-gentoo-binary.tar.bz2 scala-2.11.7/build/pack/bin \
20 # scala-2.11.7/build/pack/lib/ scala-2.11.7/build/pack/man \
21 # scala-2.11.7/src/actors/ scala-2.11.7/src/forkjoin/ \
22 # scala-2.11.7/src/library scala-2.11.7/src/library-aux/ \
23 # scala-2.11.7/src/reflect/ scala-2.11.7/docs/TODO \
24 # scala-2.11.7/doc/README scala-2.11.7/build/scaladoc/compiler
25
26 # In the pullJarFiles function in tools/binary-repo-lib.sh it executes find commands
27 # to search for .desired.sha1 files, which contain sha1 hashes that are appended
28 # to ${BURI} along with the subdirectory and filename to form the list of jar files
29 # listed in SRC_URI.  The output of this find command can be hacked into the desired format:
30 # find . -name \*.desired.sha1 -exec sed -e 's@\([0-9a-f]*\).*@\1@' {} \; -print
31 # After editing it into the desired format: sort -t / -k 3 file
32
33 BURI="http://repo.typesafe.com/typesafe/scala-sha-bootstrap/org/scala-lang/bootstrap"
34
35 declare -a JURI=(
36         "${BURI}/943cd5c8802b2a3a64a010efb86ec19bac142e40/lib/ant/ant-contrib.jar -> ${P}-ant-contrib.jar"
37         "${BURI}/3fc1e35ca8c991fc3488548f7a276bd9053c179d/lib/ant/ant-dotnet-1.0.jar -> ${P}-ant-dotnet-1.0.jar"
38         "${BURI}/7b456ca6b93900f96e58cc8371f03d90a9c1c8d1/lib/ant/ant.jar -> ${P}-ant.jar"
39         "${BURI}/7e50e3e227d834695f1e0bf018a7326e06ee4c86/lib/ant/maven-ant-tasks-2.1.1.jar -> ${P}-maven-ant-tasks-2.1.1.jar"
40         "${BURI}/2c61d6e9a912b3253194d5d6d3e1db7e2545ac4b/lib/ant/vizant.jar -> ${P}-vizant.jar"
41         "${BURI}/ddd7d5398733c4fbbb8355c049e258d47af636cf/lib/forkjoin.jar -> ${P}-forkjoin.jar"
42         "${BURI}/0392ecdeb306263c471ce51fa368223388b82b61/test/benchmarks/lib/jsr166_and_extra.jar -> ${P}-jsr166_and_extra.jar"
43         "${BURI}/e737b123d31eede5594ceda07caafed1673ec472/test/files/codelib/code.jar -> ${P}-code.jar"
44         "${BURI}/02fe2ed93766323a13f22c7a7e2ecdcd84259b6c/test/files/lib/annotations.jar -> ${P}-annotations.jar"
45         "${BURI}/981392dbd1f727b152cd1c908c5fce60ad9d07f7/test/files/lib/enums.jar -> ${P}-enums.jar"
46         "${BURI}/b1ec8a095cec4902b3609d74d274c04365c59c04/test/files/lib/genericNest.jar -> ${P}-genericNest.jar"
47         "${BURI}/346d3dff4088839d6b4d163efa2892124039d216/test/files/lib/jsoup-1.3.1.jar -> ${P}-jsoup-1.3.1.jar"
48         "${BURI}/3794ec22d9b27f2b179bd34e9b46db771b934ec3/test/files/lib/macro210.jar -> ${P}-macro210.jar"
49         "${BURI}/be8454d5e7751b063ade201c225dcedefd252775/test/files/lib/methvsfield.jar -> ${P}-methvsfield.jar"
50         "${BURI}/cd33e0a0ea249eb42363a2f8ba531186345ff68c/test/files/lib/nest.jar -> ${P}-nest.jar"
51         "${BURI}/1b11ac773055c1e942c6b5eb4aabdf02292a7194/test/files/speclib/instrumented.jar -> ${P}-instrumented.jar"
52         "${BURI}/a1883f4304d5aa65e1f6ee6aad5900c62dd81079/tools/push.jar -> ${P}-push.jar"
53 )
54
55 DESCRIPTION="The Scala Programming Language"
56 HOMEPAGE="http://www.scala-lang.org/"
57 SRC_URI="!binary?
58 (       https://github.com/scala/scala/archive/v${PV}.tar.gz -> ${P}.tar.gz
59         ${JURI[@]}
60         https://dev.gentoo.org/~gienah/snapshots/${P}-maven-deps.tar.gz
61 )
62 binary? ( https://dev.gentoo.org/~gienah/files/dist/${P}-gentoo-binary.tar.bz2 )"
63
64 LICENSE="BSD"
65 SLOT="${SV}/${PV}"
66 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x86-macos"
67
68 IUSE="binary emacs"
69
70 COMMON_DEP="dev-java/ant-core:0
71         dev-java/hawtjni-runtime:0"
72
73 DEPEND="${COMMON_DEP}
74         java-virtuals/jdk-with-com-sun:0
75         !binary? (
76                 >=virtual/jdk-1.6.0
77                 <virtual/jdk-1.9.0
78                 dev-java/ant-core:0
79                 dev-java/ant-contrib:0
80                 dev-java/ant-nodeps:0
81                 media-gfx/graphviz
82         )
83         binary? (
84                 >=virtual/jdk-1.7.0
85                 <virtual/jdk-1.9.0
86         )
87         app-arch/xz-utils:0"
88
89 RDEPEND="${COMMON_DEP}
90         >=virtual/jre-1.6
91         app-eselect/eselect-scala
92         !dev-lang/scala-bin:0"
93
94 PDEPEND="emacs? ( app-emacs/scala-mode:0 )"
95
96 S="${WORKDIR}/${P}"
97
98 CHECKREQS_MEMORY="1536M"
99
100 pkg_setup() {
101         java-pkg-2_pkg_setup
102
103         if ! use binary; then
104                 debug-print "Checking for sufficient physical RAM"
105
106                 ewarn "This package can fail to build with memory allocation errors in some cases."
107                 ewarn "If you are unable to build from sources, please try USE=binary"
108                 ewarn "for this package. See bug #181390 for more information."
109
110                 check-reqs_pkg_setup
111         fi
112 }
113
114 src_unpack() {
115         # Unpack tar files only.
116         for f in ${A} ; do
117                 [[ ${f} == *".tar."* ]] && unpack ${f}
118         done
119 }
120
121 java_prepare() {
122         java-pkg_getjars ant-core,hawtjni-runtime
123
124         if ! use binary; then
125                 local a
126                 for a in "${JURI[@]}"
127                 do
128                         echo "${a}"
129                         local g="${a/* -> /}"
130                         echo "${g}"
131                         local j="${a/ -> */}"
132                         echo "${j}"
133                         cp -p "${DISTDIR}/${g}" "${S}/${j#${BURI}/*/}" || die
134                 done
135                 # gentoo patch (by gienah) to stop it calling git log in the build
136                 epatch "${FILESDIR}/${P}-no-git.patch"
137                 # Note: to bump scala, some things to try are:
138                 # 1. update all the sha1s in JURI
139                 # 2. remove the https://dev.gentoo.org/~gienah/snapshots/${P}-maven-deps.tar.gz from SRC_URI
140                 # 3. try emerge scala.  Check if it downloads more stuff in src_compile to ${WORKDIR}/.m2
141                 # or /var/tmp/portage/.m2 or /root/.m2
142                 # 4. tar up all the .m2 junk into ${P}-maven-deps.tar.gz and add it to SRC_URI.
143                 sed -e "s@\(<mkdir dir=\"\)\${user.home}\(/.m2/repository\"/>\)@\1${WORKDIR}\2\n      <artifact:localRepository id=\"localrepo\" path=\"${WORKDIR}/.m2/repository\" />@" \
144                         -e "s@\${user.home}/.m2@${WORKDIR}/.m2@g" \
145                         -e 's@\(<artifact:dependencies .*>\)@\1\n        <localRepository refid="localrepo" />@g' \
146                         -i "${S}/build.xml" \
147                         || die "Could not change location of .m2 maven download directory in ${S}/build.xml"
148                 sed -e 's@-Xmx1024M@-Xmx1536M@' \
149                         -e 's@-XX:MaxPermSize=128M@-XX:MaxPermSize=256M@' \
150                         -i "${S}/test/partest" \
151                         || die "Could not change increase memory size in ${S}/test/partest"
152         fi
153 }
154
155 src_compile() {
156         if ! use binary; then
157                 #unset ANT_OPTS as this is set in the build.xml
158                 #sets -X type variables which might come back to bite me
159                 unset ANT_OPTS
160
161                 # reported in bugzilla that multiple launches use less resources
162                 # https://bugs.gentoo.org/show_bug.cgi?id=282023
163                 eant all.clean
164                 eant -Djavac.args="-encoding UTF-8" -Duser.home="${WORKDIR}" \
165                         fastdist-opt
166                 if use doc; then
167                         # The separate build for doc is to workaround this problem that occurs
168                         # with one "fastdist docscomp" build (still fails with MaxPermSize=384M)
169                         # java.lang.OutOfMemoryError: PermGen space
170                         eant -Djavac.args="-encoding UTF-8" -Duser.home="${WORKDIR}" \
171                                 docscomp
172                         eant -Djavac.args="-encoding UTF-8" -Duser.home="${WORKDIR}" \
173                                 docs
174                 fi
175         else
176                 einfo "Skipping compilation, USE=binary is set."
177         fi
178 }
179
180 src_test() {
181         java-pkg-2_src_test
182 }
183
184 src_install() {
185         pushd build/pack || die
186         local SCALADIR="/usr/share/${PN}-${SV}"
187         exeinto "${SCALADIR}/bin"
188         doexe $(find bin/ -type f ! -iname '*.bat')
189         dodir "${SCALADIR}/lib"
190         insinto "${SCALADIR}/lib"
191         pushd lib || die
192         for j in *.jar; do
193                 local i="$(echo "${j}" | sed -e "s@[_-][0-9.-]*\.jar@.jar@")"
194                 newins "${j}" "${i}"
195                 java-pkg_regjar "${ED}${SCALADIR}/lib/${i}"
196         done
197         popd
198
199         dodir /usr/bin
200         for b in $(find bin/ -type f ! -iname '*.bat'); do
201                 local _name=$(basename "${b}")
202                 dosym "${SCALADIR}/bin/${_name}" "/usr/bin/${_name}-${SV}"
203         done
204
205         pushd man/man1 || die
206         for i in *.1; do
207                 newman "${i}" "${i/./-${SV}.}"
208         done
209         popd
210         popd
211
212         #sources are .scala so no use for java-pkg_dosrc
213         pushd src || die
214         if use source; then
215                 dodir "${SCALADIR}/src"
216                 insinto "${SCALADIR}/src"
217                 doins -r actors forkjoin library library-aux reflect
218         fi
219         popd
220
221         local docdir="build/scaladoc"
222         dodoc docs/TODO doc/README
223         if use doc; then
224                 dohtml -r "${docdir}"/{compiler,library}
225         fi
226 }