1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 JAVA_PKG_IUSE="doc source"
8 JAVA_ANT_DISABLE_ANT_CORE_DEP="yes"
9 EANT_TEST_TARGET="test.suite"
11 inherit eutils check-reqs java-pkg-2 java-ant-2 versionator
13 MY_P="${PN}-sources-${PV}"
14 SV="$(get_version_component_range 1-2)"
16 # creating the binary:
17 # JAVA_PKG_FORCE_VM="$available-1.7" USE="doc source" ebuild scala-*.ebuild compile
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
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
33 BURI="http://repo.typesafe.com/typesafe/scala-sha-bootstrap/org/scala-lang/bootstrap"
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"
55 DESCRIPTION="The Scala Programming Language"
56 HOMEPAGE="http://www.scala-lang.org/"
58 ( https://github.com/scala/scala/archive/v${PV}.tar.gz -> ${P}.tar.gz
60 https://dev.gentoo.org/~gienah/snapshots/${P}-maven-deps.tar.gz
62 binary? ( https://dev.gentoo.org/~gienah/files/dist/${P}-gentoo-binary.tar.bz2 )"
66 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x86-macos"
70 COMMON_DEP="dev-java/ant-core:0
71 dev-java/hawtjni-runtime:0"
74 java-virtuals/jdk-with-com-sun:0
79 dev-java/ant-contrib:0
89 RDEPEND="${COMMON_DEP}
91 app-eselect/eselect-scala
92 !dev-lang/scala-bin:0"
94 PDEPEND="emacs? ( app-emacs/scala-mode:0 )"
98 CHECKREQS_MEMORY="1536M"
103 if ! use binary; then
104 debug-print "Checking for sufficient physical RAM"
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."
115 # Unpack tar files only.
117 [[ ${f} == *".tar."* ]] && unpack ${f}
122 java-pkg_getjars ant-core,hawtjni-runtime
124 if ! use binary; then
126 for a in "${JURI[@]}"
129 local g="${a/* -> /}"
131 local j="${a/ -> */}"
133 cp -p "${DISTDIR}/${g}" "${S}/${j#${BURI}/*/}" || die
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"
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
161 # reported in bugzilla that multiple launches use less resources
162 # https://bugs.gentoo.org/show_bug.cgi?id=282023
164 eant -Djavac.args="-encoding UTF-8" -Duser.home="${WORKDIR}" \
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}" \
172 eant -Djavac.args="-encoding UTF-8" -Duser.home="${WORKDIR}" \
176 einfo "Skipping compilation, USE=binary is set."
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"
193 local i="$(echo "${j}" | sed -e "s@[_-][0-9.-]*\.jar@.jar@")"
195 java-pkg_regjar "${ED}${SCALADIR}/lib/${i}"
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}"
205 pushd man/man1 || die
207 newman "${i}" "${i/./-${SV}.}"
212 #sources are .scala so no use for java-pkg_dosrc
215 dodir "${SCALADIR}/src"
216 insinto "${SCALADIR}/src"
217 doins -r actors forkjoin library library-aux reflect
221 local docdir="build/scaladoc"
222 dodoc docs/TODO doc/README
224 dohtml -r "${docdir}"/{compiler,library}