1 # Copyright 1999-2018 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 # repoman gives LIVEVCS.unmasked even with EGIT_COMMIT, so create snapshot
7 inherit eutils java-pkg-2 # git-r3
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/"
15 EGIT_REPO_URI="https://github.com/sbt/sbt.git"
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
24 https://dev.gentoo.org/~gienah/files/dist/${P}-gentoo-binary.tar.xz
42 JAVA_GENTOO_CLASSPATH="scala-${SV}"
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}
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 )
56 # 3. Comment the sbt publishLocal line in src_compile.
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:
66 # export WORKDIR='/var/tmp/portage/dev-java/${P}/work'
69 # export PATH="/usr/share/scala-${SV}/bin:${WORKDIR}/${L_P}:${PATH}"
72 # find .ivy2 .sbt -uid 0 -exec chown portage:portage {} \;
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:
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
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.
98 # if ! use binary; then
101 # Unpack tar files only.
103 [[ ${f} == *".tar."* ]] && unpack ${f}
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"
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" "\$@"
117 cat <<- EOF > "${S}/${P}"
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" "\$@"
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
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
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)")
152 export PATH="${EROOT}usr/share/scala-${SV}/bin:${S}:${PATH}"
153 "${S}/${P}" -Dsbt.log.noformat=true test || die
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}"