dev-java/sbt-bin: version bump.
[gentoo.git] / dev-java / sbt / sbt-0.13.13.ebuild
1 # Copyright 1999-2018 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 # repoman gives LIVEVCS.unmasked even with EGIT_COMMIT, so create snapshot
7 inherit eutils java-pkg-2 # git-r3
8
9 L_PN="sbt-launch"
10 L_P="${L_PN}-${PV}"
11
12 DESCRIPTION="sbt is a build tool for Scala and Java projects that aims to do the basics well"
13 HOMEPAGE="https://www.scala-sbt.org/"
14 EGIT_COMMIT="v${PV}"
15 EGIT_REPO_URI="https://github.com/sbt/sbt.git"
16 SRC_URI="
17         !binary? (
18                 https://dev.gentoo.org/~gienah/snapshots/${P}-src.tar.xz
19                 https://dev.gentoo.org/~gienah/snapshots/${P}-ivy2-deps.tar.xz
20                 https://dev.gentoo.org/~gienah/snapshots/${P}-sbt-deps.tar.xz
21                 http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/${L_PN}/${PV}/${L_PN}.jar -> ${L_P}.jar
22         )
23         binary? (
24                 https://dev.gentoo.org/~gienah/files/dist/${P}-gentoo-binary.tar.xz
25         )"
26 LICENSE="BSD"
27 SLOT="0"
28 KEYWORDS="amd64 x86"
29 IUSE="binary"
30
31 DEPEND="
32         >=virtual/jdk-1.8
33         dev-lang/scala"
34
35 RDEPEND="
36         >=virtual/jre-1.8
37         dev-lang/scala"
38
39 # test hangs or fails
40 RESTRICT="test"
41
42 JAVA_GENTOO_CLASSPATH="scala-${SV}"
43
44 # Note: to bump sbt, some things to try are:
45 # 1. Create the sbt src snapshot:
46 # git clone https://github.com/sbt/sbt.git ${P}
47 # cd ${P}
48 # git checkout v${PV}
49 # cd ..
50 # XZ_OPT=-9 tar --owner=portage --group=portage \
51 # -cJf /usr/portage/distfiles/${P}-src.tar.xz ${P}
52 # 2. remove the https://dev.gentoo.org/~gienah/snapshots/${P}-ivy2-deps.tar.xz
53 # https://dev.gentoo.org/~gienah/snapshots/${P}-sbt-deps.tar.xz and
54 # binary? ( https://dev.gentoo.org/~gienah/files/dist/${P}-gentoo-binary.tar.xz )
55 # from SRC_URI
56 # 3. Comment the sbt publishLocal line in src_compile.
57 # 4. try:
58 # FEATURES='noclean -test' emerge -v -1 dev-java/sbt
59 # It should fail in src_install since the sbt publishLocal is not done.
60 # Check if it downloads more stuff in
61 # src_compile to ${WORKDIR}/.ivy2 and ${WORKDIR}/.sbt.
62 # 5. If some of the downloads fail, it might be necessary to run the sbt compile
63 # again manually to obtain all the dependencies, if so:
64 # cd to ${S}
65 # export EROOT=/
66 # export WORKDIR='/var/tmp/portage/dev-java/${P}/work'
67 # export SV="2.11"
68 # export L_P=${P}
69 # export PATH="/usr/share/scala-${SV}/bin:${WORKDIR}/${L_P}:${PATH}"
70 # sbt compile
71 # cd ${WORKDIR}
72 # find .ivy2 .sbt -uid 0 -exec chown portage:portage {} \;
73 # 6. cd ${WORKDIR}
74 # XZ_OPT=-9 tar --owner=portage --group=portage \
75 # -cJf /usr/portage/distfiles/${P}-ivy2-deps.tar.xz .ivy2/cache
76 # XZ_OPT=-9 tar --owner=portage --group=portage \
77 # -cJf /usr/portage/distfiles/${P}-sbt-deps.tar.xz .sbt
78 # Uncomment the sbt publishLocal line in src_compile.
79 # 7. It *might* download more dependencies for src_test, however the presence
80 # of some of these may cause the src_compile to fail.  So download them
81 # seperately as root so we can identify the
82 # additional files.  As root:
83 # cd ${S}
84 # ${S}/${P} test
85 # cd ${WORKDIR}
86 # XZ_OPT=-9 tar --owner=portage --group=portage \
87 # -cJf /usr/portage/distfiles/${P}-test-deps.tar.xz \
88 # $(find .ivy2/cache .sbt -uid 0 -type f -print)
89 # Note: It might not download anything in src_test, in which case
90 # ${P}-test-deps.tar.xz is not required.
91 # 8. Create the binary
92 # cd $WORDKIR
93 # XZ_OPT=-9 tar --owner=portage --group=portage \
94 # -cJf /usr/portage/distfiles/${P}-gentoo-binary.tar.xz ${P} .ivy2/local
95 # 9. Undo the earlier temporary edits to the ebuild.
96
97 src_unpack() {
98         # if ! use binary; then
99         #       git-r3_src_unpack
100         # fi
101         # Unpack tar files only.
102         for f in ${A} ; do
103                 [[ ${f} == *".tar."* ]] && unpack ${f}
104         done
105 }
106
107 src_prepare() {
108         default
109         if ! use binary; then
110                 mkdir "${WORKDIR}/${L_P}" || die
111                 cp -p "${DISTDIR}/${L_P}.jar" "${WORKDIR}/${L_P}/${L_PN}.jar" || die
112                 cat <<- EOF > "${WORKDIR}/${L_P}/sbt"
113                         #!/bin/sh
114                         SBT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled"
115                         java -Djavac.args="-encoding UTF-8" -Duser.home="${WORKDIR}" \${SBT_OPTS} -jar "${WORKDIR}/${L_P}/sbt-launch.jar" "\$@"
116                 EOF
117                 cat <<- EOF > "${S}/${P}"
118                         #!/bin/sh
119                         SBT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled"
120                         java -Djavac.args="-encoding UTF-8" -Duser.home="${WORKDIR}" \${SBT_OPTS} -jar "${S}/launch/target/sbt-launch.jar" "\$@"
121                 EOF
122                 chmod u+x "${WORKDIR}/${L_P}/sbt" "${S}/${P}" || die
123                 sed -e "s@scalaVersion := scala210,@scalaVersion := scala${SV/./},\n  scalaHome := Some(file(\"${EROOT}usr/share/scala-${SV}\")),@" \
124                         -i "${S}/build.sbt" || die
125
126                 # suppress this warning in build.log:
127                 # [warn] Credentials file /var/tmp/portage/dev-java/${P}/work/.bintray/.credentials does not exist
128                 mkdir -p "${WORKDIR}/.bintray" || die
129                 cat <<- EOF > "${WORKDIR}/.bintray/.credentials"
130                         realm = Bintray API Realm
131                         host = api.bintray.com
132                         user =
133                         password =
134                 EOF
135         fi
136 }
137
138 src_compile() {
139         if ! use binary; then
140                 export PATH="${EROOT}usr/share/scala-${SV}/bin:${WORKDIR}/${L_P}:${PATH}"
141                 einfo "=== sbt compile ..."
142                 "${WORKDIR}/${L_P}/sbt" -Dsbt.log.noformat=true compile || die
143                 einfo "=== sbt publishLocal with jdk $(java-pkg_get-vm-version) ..."
144                 cat <<- EOF | "${WORKDIR}/${L_P}/sbt" -Dsbt.log.noformat=true || die
145                         set every javaVersionPrefix in javaVersionCheck := Some("$(java-pkg_get-vm-version)")
146                         publishLocal
147                 EOF
148         fi
149 }
150
151 src_test() {
152         export PATH="${EROOT}usr/share/scala-${SV}/bin:${S}:${PATH}"
153         "${S}/${P}" -Dsbt.log.noformat=true test || die
154 }
155
156 src_install() {
157         # Place sbt-launch.jar at the end of the CLASSPATH
158         java-pkg_dojar $(find "${WORKDIR}"/.ivy2/local -name \*.jar -print | grep -v sbt-launch.jar) \
159                 $(find "${WORKDIR}"/.ivy2/local -name sbt-launch.jar -print)
160         local ja="-Dsbt.version=${PV} -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled"
161         java-pkg_dolauncher sbt --jar sbt-launch.jar --java_args "${ja}"
162 }