760815923eed3d2eb360596fab5c36b73a81989b
[ub0rlay.git] / dev-java / proguard / proguard-4.2-r1.ebuild
1 # Copyright 1999-2008 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/dev-java/proguard/proguard-4.2-r1.ebuild,v 1.1 2008/10/22 01:27:23 fordfrog Exp $
4
5 JAVA_PKG_IUSE="doc source"
6 inherit java-pkg-2 java-ant-2
7
8 DESCRIPTION="Free Java class file shrinker, optimizer, and obfuscator."
9 HOMEPAGE="http://proguard.sourceforge.net/"
10 MY_P=${P/-/}
11 MY_P=${MY_P/_/}
12 SRC_URI="mirror://sourceforge/proguard/${MY_P}.tar.gz"
13
14 LICENSE="GPL-2-with-linking-exception"
15 SLOT="0"
16 KEYWORDS="~amd64 ~x86"
17 IUSE="examples j2me"
18
19 DEPEND=">=virtual/jdk-1.4
20                 j2me? ( dev-java/sun-wtk-bin )"
21 RDEPEND=">=virtual/jre-1.4
22                 j2me? ( dev-java/sun-wtk-bin )"
23
24 S=${WORKDIR}/${MY_P}
25
26 src_unpack() {
27         unpack ${A}
28         find "${S}" -name "*.jar" | xargs rm -v
29 }
30
31 src_compile() {
32         # create jars
33         mkdir dist
34
35         einfo "Compiling ${PN}.jar"
36         mkdir -p build/proguard/classes
37         ejavac -sourcepath src -d build/proguard/classes src/proguard/ProGuard.java || die "Cannot compile 'proguard'"
38         jar -cf "${S}"/dist/${PN}.jar -C build/proguard/classes proguard || die "Cannot create ${PN}.jar"
39
40         einfo "Compiling ${PN}gui.jar"
41         mkdir -p build/proguardgui/classes
42         ejavac -sourcepath src -d build/proguardgui/classes src/proguard/gui/ProGuardGUI.java || die "Cannot compile 'proguardgui'"
43         cp src/proguard/gui/*.gif build/proguardgui/classes/proguard/gui/
44         cp src/proguard/gui/*.pro build/proguardgui/classes/proguard/gui/
45         cp src/proguard/gui/*.properties build/proguardgui/classes/proguard/gui/
46         jar -cf "${S}"/dist/${PN}gui.jar -C build/proguardgui/classes proguard || die "Cannot create ${PN}gui.jar"
47
48         einfo "Compiling retrace.jar"
49         mkdir -p build/retrace/classes
50         ejavac -sourcepath src -d build/retrace/classes src/proguard/retrace/ReTrace.java || die "Cannot compile 'retrace'"
51         jar -cf "${S}"/dist/retrace.jar -C build/retrace/classes proguard || die "Cannot create retrace.jar"
52
53         einfo "Compiling ${PN}-ant.jar"
54         mkdir -p build/ant/classes
55         ejavac -sourcepath src -classpath $(java-pkg_getjars --build-only ant-core) \
56                 -d build/ant/classes src/proguard/ant/ProGuardTask.java || die "Cannot compile 'proguard-ant'"
57         jar -cf "${S}"/dist/${PN}-ant.jar -C build/ant/classes proguard || die "Cannot create ${PN}-ant.jar"
58
59         if use j2me ; then
60                 einfo "Compiling ${PN}-wtk.jar"
61                 mkdir -p build/wtk/classes
62                 ejavac -sourcepath src -classpath $(java-pkg_getjars sun-wtk-bin) \
63                         -d build/wtk/classes src/proguard/wtk/ProGuardObfuscator.java || die "Cannot compile 'proguard-wtk'"
64                 jar -cf "${S}"/dist/${PN}-wtk.jar -C build/wtk/classes proguard || die "Cannot create ${PN}-wtk.jar"
65         fi
66
67         # generate javadoc
68         if use doc ; then
69                 mkdir javadoc
70                 local cp=$(java-pkg_getjars --build-only ant-core)
71                 use j2me && cp="${cp}:$(java-pkg_getjars sun-wtk-bin)"
72                 javadoc -d javadoc -sourcepath src -classpath $${cp} -subpackages proguard || die "Cannot compile javadoc"
73         fi
74 }
75
76 src_install() {
77         java-pkg_dojar dist/*
78         java-pkg_dolauncher ${PN} --main proguard.ProGuard
79         java-pkg_dolauncher ${PN}gui --main proguard.gui.ProGuardGUI
80         java-pkg_dolauncher ${PN}_retrace --main proguard.retrace.ReTrace
81
82         if use doc; then
83                 dohtml -r docs/*
84                 java-pkg_dojavadoc javadoc
85         fi
86
87         if use examples; then
88                 dohtml -r examples
89         fi
90 }
91
92 pkg_postinst() {
93         elog "Please see http://proguard.sourceforge.net/GPL_exception.html"
94         elog "for linking exception information about ${PN}"
95 }