summaryrefslogtreecommitdiff
blob: 2abc8db056aafb00897cdcd56c881e6e223295a3 (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
96
97
98
99
100
101
102
103
104
105
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI="5"

JAVA_PKG_IUSE="doc source test"
WANT_ANT_TASKS="ant-trax"

inherit java-pkg-2 java-ant-2

MY_P="${P}-src"

DESCRIPTION="A powerful Model View Controller Framework for JSP/Servlets"
SRC_URI="mirror://apache/struts/source/${MY_P}.zip
	https://dev.gentoo.org/~tomwij/files/dist/${PN}-build.xml-${PV}.tar.xz"
HOMEPAGE="http://struts.apache.org/index.html"

LICENSE="Apache-2.0"
SLOT="2"
KEYWORDS="~amd64"

COMMON_DEPS="
	dev-java/felix-shell:0
	dev-java/osgi-core-api:0
	dev-java/struts-core:${SLOT}
	dev-java/struts-plugins:${SLOT}
	dev-java/struts-xwork:${SLOT}
	java-virtuals/servlet-api:2.3"

RDEPEND=">=virtual/jre-1.5
	${COMMON_DEPS}"

DEPEND=">=virtual/jdk-1.5
	test? ( dev-java/ant-junit:0 )
	${COMMON_DEPS}"

S="${WORKDIR}/${P}/src"

JAVA_ANT_REWRITE_CLASSPATH="true"
EANT_GENTOO_CLASSPATH="struts-core-${SLOT},struts-plugins-${SLOT},struts-xwork-${SLOT}"
EANT_TEST_GENTOO_CLASSPATH="${EANT_GENTOO_CLASSPATH}"
EANT_BUILD_TARGET="package"
EANT_TEST_TARGET="test"

# TODO: Incompatible with newer junit; we either need to patch it or slot junit.
RESTRICT="test"

src_unpack() {
	unpack ${MY_P}.zip
	cd "${S}" || die
	unpack ${PN}-build.xml-${PV}.tar.xz
}

java_prepare() {
	find . -name '*.jar' -print -delete || die

	epatch "${FILESDIR}"/${P}-build.xml-remove-core-and-plugins.patch
	epatch "${FILESDIR}"/${P}-build.xml-classpath.patch
	epatch "${FILESDIR}"/${P}-build.xml-manifest.patch
	epatch "${FILESDIR}"/${P}-build.xml-apps-package.patch
	epatch "${FILESDIR}"/${P}-build.xml-remove-apps-portlet.patch

	java-pkg_getjars felix-shell,osgi-core-api,servlet-api-2.3
}

src_install() {
	insinto /usr/share/${PN}-${SLOT}/

	# Misses apps/portlet.
	for dir in apps/{blank,mailreader,rest-showcase,showcase} bundles/{admin,demo} ; do
		if [[ ${dir} == "apps/"* ]] ; then
			doins ${dir}/target/${PN}2-${dir/apps\//}.war
		else
			java-pkg_newjar ${dir}/target/${PN}2-osgi-*-bundle-${PV}.jar ${dir/bundles\//}.jar
		fi

		if use doc ; then
			java-pkg_dojavadoc ${dir}/target/site/apidocs
			mkdir "${D}"/usr/share/doc/${P}/${dir/*\//} || die
			mv "${D}"/usr/share/doc/${P}/{html,${dir/*\//}/html} || die
		fi

		if [[ ${dir} == *"mailreader"* ]] ; then
			use source && java-pkg_dosrc ${dir}/src/main/java/mailreader2
		else
			use source && java-pkg_dosrc ${dir}/src/main/java/org
		fi
	done

	if use doc ; then
		rm "${D}"/usr/share/${PN}-${SLOT}/api || die
	fi
}

src_test() {
	EANT_TEST_EXTRA_ARGS="-Dgentoo.test.classpath=$(java-pkg_getjars ${EANT_TEST_GENTOO_CLASSPATH})"
	EANT_TEST_EXTRA_ARGS+=" -Djunit.present=true"

	java-pkg-2_src_test
}

pkg_postinst() {
	elog "The application 'portlet' is not in this release because it doesn't build."
}