# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

# TODO Look to actually splitting this into 2 packages.
# Maybe not.  j3d-core-utils requires j3d-core's build.xml files to build.
# they are more or less the same package.  Maybe just add a use flag to install
# utils jar/javadoc

EAPI=6

WANT_ANT_TASKS="ant-nodeps"
JAVA_PKG_IUSE="doc source"
inherit eutils java-pkg-2 java-ant-2

DESCRIPTION="Java3D Core API and Utils package"
HOMEPAGE="https://github.com/hharrison/java3d-core"
MY_PV=$(replace_version_separator 3 '-')
SRC_URI="https://github.com/hharrison/java3d-utils/archive/${MY_PV}.tar.gz -> java3d-utils-${PV}.tar.gz
		https://github.com/hharrison/java3d-core/archive/${MY_PV}.tar.gz -> java3d-core-${PV}.tar.gz"

LICENSE="GPL-2-with-exceptions BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

COMMON_DEP="~dev-java/vecmath-${PV}:0
		dev-java/jogl:2.3
		dev-java/gluegen:2.3"

RDEPEND=">=virtual/jre-1.6
		${COMMON_DEP}"
DEPEND=">=virtual/jdk-1.6
		app-arch/unzip
		dev-java/eclipse-ecj:4.5[ant]
		${COMMON_DEP}"

ANT_OPTS="-Xmx1g"
JAVA_PKG_FORCE_COMPILER="ecj-4.5"

S="${WORKDIR}"/java3d-core-${MY_PV}

src_prepare() {
	default

	mv ${WORKDIR}/java3d-utils-${MY_PV} ${WORKDIR}/j3d-utils

	# prepare references to external libs
	for d in "${WORKDIR}"/vecmath/build/jars "${WORKDIR}"/jogl-v2.3.2
	do
		mkdir -p "${d}"
	done

	java-pkg_jarfrom --into "${WORKDIR}"/vecmath/build/jars vecmath
	java-pkg_jarfrom --into "${WORKDIR}"/jogl-v2.3.2 jogl-2.3
	java-pkg_jarfrom --into "${WORKDIR}"/jogl-v2.3.2 gluegen-2.3
}

src_install() {
	java-pkg_dojar build/jars/*.jar
	use source && java-pkg_dosrc src/classes/share/javax 
}