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