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

EAPI=5
JAVA_PKG_IUSE="doc source"

inherit java-pkg-2 java-ant-2

DESCRIPTION="Google Web Toolkit library"
HOMEPAGE="http://www.gwtproject.org/"
SRC_URI="https://github.com/gwtproject/${PN}/archive/${PV}.zip -> ${P}.zip"
RESTRICT="mirror"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

CDEPEND="
        dev-java/json:0
        dev-java/guava:18
        dev-java/rhino:1.7
        >=dev-java/asm-5.0.3:4
        dev-java/eclipse-ecj:4.4"

RDEPEND="
        ${CDEPEND}
        >=virtual/jre-1.6"
DEPEND="
        ${CDEPEND}
        >=virtual/jdk-1.6"

JAVA_ANT_REWRITE_CLASSPATH="yes"
EANT_BUILD_XML="build.xml"
EANT_BUILD_TARGET="build"

EANT_GENTOO_CLASSPATH="
        json
        asm-4
        guava-18
        rhino-1.7
        eclipse-ecj-4.4
"

java_prepare() {
        # Nuts.
        ebegin "Fixing various imports"
        find "${S}" \
                -type f \
                -name \*.java \
                -exec sed -i -e 's#com.google.gwt.thirdparty.javascript.rhino#org.mozilla.javascript#g;' {} \; \
                -exec sed -i -e 's#com.google.gwt.thirdparty.guava#com.google#g;' {} \; \
                -exec sed -i -e 's#com.google.gwt.thirdparty.json#org.json#g;' {} \; \
                || die
        eend $?
}

src_compile() {
        GWT_TOOLS="${S}/tools" \
                java-pkg-2_src_compile
}