diff options
author | zongyu <zzy2529420793@gmail.com> | 2020-07-29 14:13:04 +0800 |
---|---|---|
committer | zongyu <zzy2529420793@gmail.com> | 2020-07-29 14:19:25 +0800 |
commit | 970308e5d845b5da6818131c75f84c38691691c6 (patch) | |
tree | 9287ed6d0ce5acd01861f91429e1c3343cf82603 /maven | |
parent | replace "\t" with spaces, enable test if --binjar-uri is set (diff) | |
download | java-ebuilder-970308e5d845b5da6818131c75f84c38691691c6.tar.gz java-ebuilder-970308e5d845b5da6818131c75f84c38691691c6.tar.bz2 java-ebuilder-970308e5d845b5da6818131c75f84c38691691c6.zip |
write src_unpack everytime is not elegant, use java-pkg-maven to handle it
Signed-off-by: zongyu <zzy2529420793@gmail.com>
Diffstat (limited to 'maven')
-rw-r--r-- | maven/eclass/java-pkg-maven.eclass | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/maven/eclass/java-pkg-maven.eclass b/maven/eclass/java-pkg-maven.eclass new file mode 100644 index 0000000..d926cc3 --- /dev/null +++ b/maven/eclass/java-pkg-maven.eclass @@ -0,0 +1,60 @@ +# Copyright 2004-2020 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +# @ECLASS: java-pkg-binjar.eclass +# @MAINTAINER: +# zzy2529420793@gmail.com +# @AUTHOR: +# Zhang Zongyu +# @BLURB: Eclass for unpacking Maven aritfacts +# @DESCRIPTION: +# This class is an attempt to unpack Maven artifacts properly. + +EXPORT_FUNCTIONS src_unpack + +# @ECLASS-VARIABLE: JAVA_SOURCE_FILENAME +# @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} + +# @ECLASS-VARIABLE: JAVA_RESOURCE_DIRS +# @DEFAULT_UNSET +# @DESCRIPTION: +# A directory relative to ${S} which contain the resources of the +# application. Give it a default value to handle src_unpack. +: ${JAVA_RESOURCE_DIRS:=src/main/resources} + +# @FUNCTION: java-pkg-binjar_src_unpack +# @DESCRIPTION: +# Copy the binary jar into the expected place of java-pkg-simple. Do +# not extract files from archive. +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}) + 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" ;; + esac + done + + # the resources (maven resources are bundled inside source file) + 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 +} + |