summaryrefslogtreecommitdiff
blob: b8644d7ea7e879309ed060dd370600cce212252a (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# Groovy's build system is Ant based, but they use Maven for fetching the dependencies.
# We just have to remove the fetch dependencies target, and then we can use Ant for this ebuild.

# We currently do not build the embeddable jar (which is created using JarJar).
# We could provide that via an USE flag.
# We also don't use automatic build rewriting as there seems to be already some level of support
# in the upstream build system

# TODO: Install all 3 documentation packages. Currently only the Groovy GDK documentation is installed
# as our java-pkg_dojavadoc function does not support multiple Javadoc installations.

EAPI="4"

WANT_ANT_TASKS="ant-antlr"
JAVA_PKG_IUSE="doc source"

inherit base versionator java-pkg-2 java-ant-2

MY_PV=${PV/_rc/-RC-}
MY_P="${PN}-${MY_PV}"

DESCRIPTION="Groovy is a high-level dynamic language for the JVM"
HOMEPAGE="http://groovy.codehaus.org/"

SRC_URI="http://dist.groovy.codehaus.org/distributions/${PN}-src-${PV}.zip"
LICENSE="codehaus-groovy"
SLOT="0"
KEYWORDS="~amd64"
IUSE="test"
RESTRICT="test"

CDEPEND=">=dev-java/asm-3.2
	>=dev-java/ant-core-1.8.0
	>=dev-java/junit-4.6
	dev-java/antlr:0
	dev-java/ant-ivy:2.2
	dev-java/xstream:0
	dev-java/jline:0
	dev-java/commons-cli:1
	dev-java/jansi:0
	java-virtuals/servlet-api:3.0
	>=dev-java/bsf-2.4
	java-virtuals/jmx:0"

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

DEPEND=">=virtual/jdk-1.5
	dev-java/ant-ivy:2
	test? (
		dev-java/jmock:1.0
		dev-java/xmlunit:1
		dev-db/hsqldb:0
		dev-java/commons-logging:0
		dev-java/ant-junit:0
		dev-java/ant-trax:0
	)
	doc? (
		dev-java/ant-antlr:0
		dev-java/qdox:1.12
		dev-java/commons-logging:0
	)
	${CDEPEND}"

S="${WORKDIR}/${MY_P}"

PATCHES=( "${FILESDIR}/${PN}-1.8-build-pref-locking-fix.patch" )

JAVA_PKG_BSFIX_NAME+=" build-setup.xml"
JAVA_ANT_REWRITE_CLASSPATH="yes"
JAVA_ANT_CLASSPATH_TAGS+=" java groovyc taskdef"
EANT_BUILD_TARGET="createJars"
EANT_GENTOO_CLASSPATH="asm-3,ant-core,ant-ivy-2.2,junit-4,antlr,xstream,commons-cli-1,jansi,servlet-api-3.0,bsf-2.3,jmx,jline"
EANT_GENTOO_CLASSPATH_EXTRA="target/tools:target/classes"
EANT_EXTRA_ARGS="-DskipFetch=true -DskipEmbeddable=true -Dgentoo.user.home='${T}'"
EANT_DOC_TARGET="doc"

src_prepare() {
	find "${S}" -name '*.jar' -delete
	find "${S}" -name '*.class' -delete
	base_src_prepare
	sed -i -e 's/fullQualifiedName/fullyQualifiedName/g' \
		src/tools/org/codehaus/groovy/tools/DocGenerator.groovy

	rm -rf bootstrap
	# security directory is needed for tests, but they currently don't pass
	#rm -rf security
	mkdir -p target/lib/{compile,runtime,tools}
}

src_compile() {
	use doc && EANT_ANT_TASKS+=" ant-antlr"
	use doc && EANT_GENTOO_CLASSPATH_EXTRA+=":$(java-pkg_getjars --build-only qdox-1.12,commons-logging,ant-antlr)"
	EANT_EXTRA_ARGS+=" -DskipTests=true"
	java-pkg-2_src_compile
}

#the tests currently don't pass. The problem, seems in instantiating org.objectweb.asm.ClassWriter: 
#the asm-3 package is the dependency of the groovy, while asm-1.5 is dependency of jmock-1.0 
src_test() {
	mkdir -p target/lib/{test,extras}
	EANT_TEST_GENTOO_CLASSPATH="jmock-1.0,ant-junit,xmlunit-1,hsqldb,commons-logging"
	java-pkg-2_src_test
}

src_install() {
	java-pkg_newjar "target/dist/${PN}.jar"
	use doc && java-pkg_dojavadoc "target/html/groovy-jdk/"

	# FIXME: install those two later
	#
	#use doc && java-pkg_dojavadoc "target/html/api/"
	#use doc && java-pkg_dojavadoc "target/html/gapi/"

	use source && java-pkg_dosrc "src/main/groovy" "src/main/org"
	java-pkg_dolauncher "groovyc" --main org.codehaus.groovy.tools.FileSystemCompiler
	java-pkg_dolauncher "groovy" --main groovy.ui.GroovyMain
	java-pkg_dolauncher "groovysh" --main groovy.ui.InteractiveShell
	java-pkg_dolauncher "groovyConsole" --main groovy.ui.Console
	java-pkg_dolauncher "grape" --main org.codehaus.groovy.tools.GrapeMain
}