diff options
author | zongyu <zzy2529420793@gmail.com> | 2020-08-05 12:04:34 +0800 |
---|---|---|
committer | zongyu <zzy2529420793@gmail.com> | 2020-08-05 12:05:29 +0800 |
commit | 6630c8b0d4c1beb5dee68d4481487e8acd0340e4 (patch) | |
tree | 5f721493c5227603b2bf62806bd91244941b778b | |
parent | sort KEYWORDS (diff) | |
download | java-ebuilder-6630c8b0d4c1beb5dee68d4481487e8acd0340e4.tar.gz java-ebuilder-6630c8b0d4c1beb5dee68d4481487e8acd0340e4.tar.bz2 java-ebuilder-6630c8b0d4c1beb5dee68d4481487e8acd0340e4.zip |
update java-pkg-maven: recogize files by suffixes
Signed-off-by: zongyu <zzy2529420793@gmail.com>
-rw-r--r-- | maven/eclass/java-pkg-maven.eclass | 45 |
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 } |