aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--maven/eclass/java-pkg-maven.eclass45
1 files changed, 28 insertions, 17 deletions
diff --git a/maven/eclass/java-pkg-maven.eclass b/maven/eclass/java-pkg-maven.eclass
index d926cc3..fb41bb2 100644
--- a/maven/eclass/java-pkg-maven.eclass
+++ b/maven/eclass/java-pkg-maven.eclass
@@ -13,23 +13,30 @@
EXPORT_FUNCTIONS src_unpack
-# @ECLASS-VARIABLE: JAVA_SOURCE_FILENAME
+# @ECLASS-VARIABLE: JAVA_SRC_DIR
# @DESCRIPTION:
-# The filename of the source code.
-: ${JAVA_SOURCE_FILENAME:=${P}-sources.jar}
-
-# @ECLASS-VARIABLE: JAVA_TEST_SOURCE_FILENAME
-# @DESCRIPTION:
-# The filename of the source code for launch testing.
-: ${JAVA_TEST_SOURCE_FILENAME:=${P}-test-sources.jar}
+# A directory relative to ${S} which contains the source code.
+# source code distributed by Maven Central are exactly the root of
+# the source code, we need to assign them a separate directory to
+# avoid the situation that the source code, the resources and the
+# source code for testing are mixed in ${S}.
+#
+: ${JAVA_SRC_DIR:=src/main/java}
# @ECLASS-VARIABLE: JAVA_RESOURCE_DIRS
# @DEFAULT_UNSET
# @DESCRIPTION:
-# A directory relative to ${S} which contain the resources of the
+# A directory relative to ${S} which contains the resources of the
# application. Give it a default value to handle src_unpack.
: ${JAVA_RESOURCE_DIRS:=src/main/resources}
+# @ECLASS-VARIABLE: JAVA_RESOURCE_DIRS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# A directory relative to ${S} which contains the source code for testing
+# the application. Give it a default value to handle src_unpack.
+: ${JAVA_TEST_SRC_DIR:=src/test/java}
+
# @FUNCTION: java-pkg-binjar_src_unpack
# @DESCRIPTION:
# Copy the binary jar into the expected place of java-pkg-simple. Do
@@ -37,23 +44,27 @@ EXPORT_FUNCTIONS src_unpack
java-pkg-maven_src_unpack() {
for file in ${A}; do
case ${file} in
- ${JAVA_BINJAR_FILENAME}) ;;
- ${JAVA_SOURCE_FILENAME})
- mkdir -p "${S}"/${JAVA_SRC_DIR}\
- || die "Could not create ${JAVA_SRC_DIR}"
- unzip -q -o "${DISTDIR}"/${file} -d "${S}"/${JAVA_SRC_DIR}\
- || die "Could not unzip source code" ;;
- ${JAVA_TEST_SOURCE_FILENAME})
+ *-test-sources.jar)
mkdir -p "${S}"/${JAVA_TEST_SRC_DIR}\
|| die "Could not create ${JAVA_TEST_SRC_DIR}"
unzip -q -o "${DISTDIR}"/${file} -d "${S}"/${JAVA_TEST_SRC_DIR}\
|| die "Could not unzip source code for testing" ;;
+ *-sources.jar)
+ mkdir -p "${S}"/${JAVA_SRC_DIR}\
+ || die "Could not create ${JAVA_SRC_DIR}"
+ unzip -q -o "${DISTDIR}"/${file} -d "${S}"/${JAVA_SRC_DIR}\
+ || die "Could not unzip source code"
+ if [[ -d "${S}"/${JAVA_SRC_DIR}/META-INF ]] ; then
+ rm "${S}"/${JAVA_SRC_DIR}/META-INF -r || die
+ fi ;;
+ *)
+ unpack ${file};;
esac
done
# the resources (maven resources are bundled inside source file)
+ mkdir -p $(dirname "${S}"/${JAVA_RESOURCE_DIRS}) || die
cp "${S}"/${JAVA_SRC_DIR} "${S}"/${JAVA_RESOURCE_DIRS} -r || die
- rm "${S}"/${JAVA_RESOURCE_DIRS}/META-INF -r || die
find "${S}"/${JAVA_RESOURCE_DIRS} -type f ! -name \*.properties \
-exec rm {} \; || die
}