summaryrefslogtreecommitdiff
blob: ca6ed62c4af73b826c85bc79de171cd585fe0ee2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-util/checkstyle/checkstyle-4.2.ebuild,v 1.7 2007/06/10 16:00:49 philantrop Exp $

JAVA_PKG_IUSE="doc source"
inherit java-pkg-2 java-ant-2

MY_P="${PN}-src-${PV}"
DESCRIPTION="A development tool to help programmers write Java code that adheres to a coding standard."
HOMEPAGE="http://checkstyle.sourceforge.net"
SRC_URI="mirror://sourceforge/checkstyle/${MY_P}.tar.gz"

LICENSE="LGPL-2.1"
SLOT="0"
KEYWORDS="amd64 ppc x86"
IUSE="test"

COMMON_DEP="dev-java/antlr
	=dev-java/commons-beanutils-1.7*
	=dev-java/commons-cli-1*
	dev-java/commons-logging"

RDEPEND="!test? ( >=virtual/jre-1.4 )
	test? ( >=virtual/jre-1.5 )
	${COMMON_DEP}"

# Uses antlr and as such needs ant-tasks
# Tests only pass with 1.5 but I think that
# is a problem with the test classes so running
# with 1.6 should be fine
DEPEND="!test? ( >=virtual/jdk-1.4 )
	test? ( =virtual/jdk-1.5* )
	${COMMON_DEP}
	dev-java/ant-core
	dev-java/ant-tasks
	test? (
		dev-java/junit
		dev-java/emma
	)"
S="${WORKDIR}/${MY_P}"

src_unpack() {
	unpack ${A}
	cd ${S}/lib
	rm *.jar
	java-pkg_jar-from antlr
	java-pkg_jar-from commons-beanutils-1.7
	java-pkg_jar-from commons-cli-1
	java-pkg_jar-from commons-logging
}

src_compile() {
	eant compile.checkstyle $(use_doc)
	jar cfm ${PN}.jar config/manifest.mf -C target/checkstyle . || die "jar failed"
}

src_test() {
	cd "${S}/lib"
	java-pkg_jar-from --build-only junit
	# for some weird classpath interactions both seem to be needed
	java-pkg_jar-from --build-only emma
	cd "${S}"
	local cp=$(java-pkg_getjar --build-only emma emma.jar)
	eant run.tests -lib "${cp}"
}

src_install() {
	java-pkg_dojar ${PN}.jar

	dodoc README RIGHTS.antlr || die
	use doc && java-pkg_dojavadoc target/docs/api
	use source && java-pkg_dosrc src/${PN}/com

	# Install check files
	insinto /usr/share/checkstyle/checks
	for file in *.xml; do
		[[ "${file}" != build.xml ]] && doins ${file}
	done

	# Install extra files
	insinto  /usr/share/checkstyle/contrib
	doins -r contrib/*

	java-pkg_dolauncher ${PN} \
		--main com.puppycrawl.tools.checkstyle.Main

	# Make the ant tasks available to ant
	dodir /usr/share/ant-core/lib
	dosym /usr/share/${PN}/lib/${PN}.jar /usr/share/ant-core/lib/
}

pkg_postinst() {
	elog "Checkstyle is located at /usr/bin/checkstyle"
	elog "Check files are located in /usr/share/checkstyle/checks/"
}