From 9aa80713372911cec499b3adb2cd746790920916 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Tue, 29 Jun 2021 10:15:54 +0100 Subject: gentoo resync : 29.06.2021 --- eclass/java-pkg-simple.eclass | 85 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 10 deletions(-) (limited to 'eclass/java-pkg-simple.eclass') diff --git a/eclass/java-pkg-simple.eclass b/eclass/java-pkg-simple.eclass index 0c3e1af70364..174fa08ce4ea 100644 --- a/eclass/java-pkg-simple.eclass +++ b/eclass/java-pkg-simple.eclass @@ -326,7 +326,7 @@ java-pkg-simple_prepend_resources() { # If USE FLAG 'binary' exists and is set, it will just copy # ${JAVA_BINJAR_FILENAME} to ${S} and skip the rest of src_compile. java-pkg-simple_src_compile() { - local sources=sources.lst classes=target/classes apidoc=target/api + local sources=sources.lst classes=target/classes apidoc=target/api moduleinfo # auto generate classpath java-pkg_gen-cp JAVA_GENTOO_CLASSPATH @@ -344,7 +344,14 @@ java-pkg-simple_src_compile() { fi # gather sources - find "${JAVA_SRC_DIR[@]}" -name \*.java > ${sources} + # if target < 9, we need to compile module-info.java separately + # as this feature is not supported before Java 9 + if [[ java-pkg_get-target -lt 9 ]]; then + find "${JAVA_SRC_DIR[@]}" -name \*.java ! -name module-info.java > ${sources} + moduleinfo=$(find "${JAVA_SRC_DIR[@]}" -name module-info.java) + else + find "${JAVA_SRC_DIR[@]}" -name \*.java > ${sources} + fi # create the target directory mkdir -p ${classes} || die "Could not create target directory" @@ -354,9 +361,33 @@ java-pkg-simple_src_compile() { java-pkg-simple_getclasspath java-pkg-simple_prepend_resources ${classes} "${JAVA_RESOURCE_DIRS[@]}" - ejavac -d ${classes} -encoding ${JAVA_ENCODING}\ - ${classpath:+-classpath ${classpath}} ${JAVAC_ARGS}\ - @${sources} + if [[ -n ${moduleinfo} ]] || [[ java-pkg_get-target -lt 9 ]]; then + ejavac -d ${classes} -encoding ${JAVA_ENCODING}\ + ${classpath:+-classpath ${classpath}} ${JAVAC_ARGS} @${sources} + else + ejavac -d ${classes} -encoding ${JAVA_ENCODING}\ + ${classpath:+--module-path ${classpath}} --module-version ${PV}\ + ${JAVAC_ARGS} @${sources} + fi + + # handle module-info.java separately as it needs at least JDK 9 + if [[ -n ${moduleinfo} ]]; then + if java-pkg_is-vm-version-ge "9" ; then + local tmp_source=${JAVA_PKG_WANT_SOURCE} tmp_target=${JAVA_PKG_WANT_TARGET} + + JAVA_PKG_WANT_SOURCE="9" + JAVA_PKG_WANT_TARGET="9" + ejavac -d ${classes} -encoding ${JAVA_ENCODING}\ + ${classpath:+--module-path ${classpath}} --module-version ${PV}\ + ${JAVAC_ARGS} "${moduleinfo}" + + JAVA_PKG_WANT_SOURCE=${tmp_source} + JAVA_PKG_WANT_TARGET=${tmp_target} + else + ewarn "Need at least JDK 9 to compile module-info.java in src_compile," + ewarn "see https://bugs.gentoo.org/796875" + fi + fi # javadoc if has doc ${JAVA_PKG_IUSE} && use doc; then @@ -422,7 +453,7 @@ java-pkg-simple_src_install() { # It will perform test with frameworks that are defined in # ${JAVA_TESTING_FRAMEWORKS}. java-pkg-simple_src_test() { - local test_sources=test_sources.lst classes=target/test-classes + local test_sources=test_sources.lst classes=target/test-classes moduleinfo local tests_to_run classpath # do not continue if the USE FLAG 'test' is explicitly unset @@ -444,12 +475,46 @@ java-pkg-simple_src_test() { java-pkg-simple_prepend_resources ${classes} "${JAVA_TEST_RESOURCE_DIRS[@]}" # gathering sources for testing - find "${JAVA_TEST_SRC_DIR[@]}" -name \*.java > ${test_sources} + # if target < 9, we need to compile module-info.java separately + # as this feature is not supported before Java 9 + if [[ java-pkg_get-target -lt 9 ]]; then + find "${JAVA_TEST_SRC_DIR[@]}" -name \*.java ! -name module-info.java > ${test_sources} + moduleinfo=$(find "${JAVA_TEST_SRC_DIR[@]}" -name module-info.java) + else + find "${JAVA_TEST_SRC_DIR[@]}" -name \*.java > ${test_sources} + fi + # compile - [[ -s ${test_sources} ]] && ejavac -d ${classes} ${JAVAC_ARGS} \ - -encoding ${JAVA_ENCODING} ${classpath:+-classpath ${classpath}} \ - @${test_sources} + if [[ -s ${test_sources} ]]; then + if [[ -n ${moduleinfo} ]] || [[ java-pkg_get-target -lt 9 ]]; then + ejavac -d ${classes} -encoding ${JAVA_ENCODING}\ + ${classpath:+-classpath ${classpath}} ${JAVAC_ARGS} @${test_sources} + else + ejavac -d ${classes} -encoding ${JAVA_ENCODING}\ + ${classpath:+--module-path ${classpath}} --module-version ${PV}\ + ${JAVAC_ARGS} @${test_sources} + fi + fi + + # handle module-info.java separately as it needs at least JDK 9 + if [[ -n ${moduleinfo} ]]; then + if java-pkg_is-vm-version-ge "9" ; then + local tmp_source=${JAVA_PKG_WANT_SOURCE} tmp_target=${JAVA_PKG_WANT_TARGET} + + JAVA_PKG_WANT_SOURCE="9" + JAVA_PKG_WANT_TARGET="9" + ejavac -d ${classes} -encoding ${JAVA_ENCODING}\ + ${classpath:+--module-path ${classpath}} --module-version ${PV}\ + ${JAVAC_ARGS} "${moduleinfo}" + + JAVA_PKG_WANT_SOURCE=${tmp_source} + JAVA_PKG_WANT_TARGET=${tmp_target} + else + ewarn "Need at least JDK 9 to compile module-info.java in src_test," + ewarn "see https://bugs.gentoo.org/796875" + fi + fi # grab a set of tests that testing framework will run tests_to_run=$(find "${classes}" -type f\ -- cgit v1.2.3