[java-sig-commits] [javapackages] Add support for resolving Maven artifacts
Mikolaj Izdebski
mizdebsk at fedoraproject.org
Mon Sep 16 08:55:05 UTC 2013
commit e10ab679ebf441a6429c2f1ef47cedaf51418482
Author: Mikolaj Izdebski <mizdebsk at redhat.com>
Date: Mon Sep 16 09:45:57 2013 +0200
Add support for resolving Maven artifacts
Now find_jar() function, which is used by find-jar, build-classpath,
build-jar-repository and %jpackage_script, will be able to resolve
artifacts in form:
groupId:artifactId[:extension[:classifier]][:version]
For successfull resolution of Maven artifacts XMvn has to be
installed, but XMvn is not a hard recurement. XMvn is not required as
long as traditional JAR names are used instead of Maven coordinates.
TODO | 6 -----
java-utils/java-functions | 46 ++++++++++++++++++++++++++++++--------------
2 files changed, 31 insertions(+), 21 deletions(-)
---
diff --git a/TODO b/TODO
index fe6e670..79bf21d 100644
--- a/TODO
+++ b/TODO
@@ -66,9 +66,3 @@
generated quto-requires should include SCL-specific metapackage
instead of jpackage-utils. The SCL package is assumed to own all
the directories like /opt/rh/scl/usr/share/maven-fragments etc.
-
-** support for maven artifacts in build-classpath et al.
-
- build-classpath xpp3 org.apache.maven:maven-artifact:2.0.7
-
- /usr/share/java/xpp3.jar:/usr/share/java/maven/maven-artifact-2.0.7.jar
diff --git a/java-utils/java-functions b/java-utils/java-functions
index 5bda299..eeed64a 100644
--- a/java-utils/java-functions
+++ b/java-utils/java-functions
@@ -1,5 +1,8 @@
# Functions library for Java applications. -*- sh -*-
#
+# Fedora Project <http://www.fedoraproject.org/>
+# Mikolaj Izdebski <mizdebsk at redhat.com>
+#
# JPackage Project <http://www.jpackage.org/>
# Guillaume Rousse <guillomovitch at sourceforge.net>
# Ville Skyttä <scop at jpackage.org>
@@ -276,26 +279,39 @@ link_jar_repository() {
# Requires a correct $JAVA_LIBDIR, $JAVAVER_LIBDIR and $JVM_LIBDIR
find_jar() {
- # Remove jar extension if present
- extension=$(echo "$1" | sed 's+\.jar$++g')
-
- found_extension=$(do_find_jar $extension)
- found=$?
+ # If extension contains semicolon then assume it specifies Maven
+ # artifact coordinates.
+ if echo "$1" | grep -q ':'; then
+ if ! [ -x "${M2_HOME:-/usr/share/xmvn}/bin/xmvn-resolve" ]; then
+ echo "$0: Unable to execute xmvn-resolve." >&2
+ echo "$0: Make sure that XMvn is installed and M2_HOME is set correctly." >&2
+ return 1
+ fi
- # Version-less fallback
- if [ $found != 0 ] && $(echo $extension | grep -q -e "-[\.[:digit:]]*$")
- then
- # 's+++g' breaks here for some reason (GNU sed 4.1.5), 's///g' works
- extension=$(echo $extension | sed 's/-[\.[:digit:]]\+$//g')
- found_extension=$(do_find_jar $extension)
+ found_extension=$("${M2_HOME:-/usr/share/xmvn}/bin/xmvn-resolve" -c "$1")
found=$?
- fi
+ else
+ # Remove jar extension if present
+ extension=$(echo "$1" | sed 's+\.jar$++g')
- # Root directory fallback
- if [ $found != 0 ] && $(echo $extension | grep -q "/") ; then
- extension=$(dirname $extension)
found_extension=$(do_find_jar $extension)
found=$?
+
+ # Version-less fallback
+ if [ $found != 0 ] && $(echo $extension | grep -q -e "-[\.[:digit:]]*$")
+ then
+ # 's+++g' breaks here for some reason (GNU sed 4.1.5), 's///g' works
+ extension=$(echo $extension | sed 's/-[\.[:digit:]]\+$//g')
+ found_extension=$(do_find_jar $extension)
+ found=$?
+ fi
+
+ # Root directory fallback
+ if [ $found != 0 ] && $(echo $extension | grep -q "/") ; then
+ extension=$(dirname $extension)
+ found_extension=$(do_find_jar $extension)
+ found=$?
+ fi
fi
if [ $found = 0 ] ; then
More information about the java-sig-commits
mailing list