[pkg-java] r12034 - in trunk/maven2/debian: . bash_completion.d patches

Ludovic Claude ludovicc-guest at alioth.debian.org
Tue Apr 6 22:12:35 UTC 2010


Author: ludovicc-guest
Date: 2010-04-06 22:12:35 +0000 (Tue, 06 Apr 2010)
New Revision: 12034

Added:
   trunk/maven2/debian/patches/mvnDebug-cmd.patch
Modified:
   trunk/maven2/debian/bash_completion.d/maven2
   trunk/maven2/debian/changelog
   trunk/maven2/debian/patches/series
Log:
* Improve bash completion for maven2, -D options are better
  handled for plugins (for example, mvn install:install-file -DpomFile=...)
* Apply patch from Heikki Henriksen <heikkih at gmail.com> to
  fix mvnDebug command. Thanks Heikki! (Closes: #561596)

Modified: trunk/maven2/debian/bash_completion.d/maven2
===================================================================
--- trunk/maven2/debian/bash_completion.d/maven2	2010-04-06 21:05:59 UTC (rev 12033)
+++ trunk/maven2/debian/bash_completion.d/maven2	2010-04-06 22:12:35 UTC (rev 12034)
@@ -393,6 +393,11 @@
 	for x in `find -type f -name pom.xml -or -name *.pom` ; do echo ${x#./} ; done
 }
 
+__mvnlist_jars ()
+{
+	for x in `find -type f -name *.jar` ; do echo ${x#./} ; done
+}
+
 __mvnlist_prefix ()
 {
 	local pfx=$1 IFS=' '$'\t'$'\n'
@@ -502,7 +507,7 @@
 		__mvncomp "${__mvnpackaging}" "$(__mvnprefix_equals $cur)" "${cur#*=}"
 		;;
 	*)
-		local options="artifactId= classifier= description= file=press file=tab generatePom=false groupId= pomFile=press pomFile=tab repositoryId= 
+		local options="artifactId= classifier= description= file=press file=tab generatePom=true groupId= pomFile=press pomFile=tab repositoryId= 
 		  repositoryLayout=legacy uniqueVersion=false url= version="
 		options="$options $(__mvnlist_prefix 'packaging=' ${__mvnpackaging} )"
 		__mvncomp "$options" "-D" "${cur}"
@@ -510,6 +515,35 @@
 	esac
 }
 
+__mvninstall_install_file ()
+{
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	cur="${cur#-D}"
+	case "${cur}" in
+	file=*)
+		COMPREPLY=( $( compgen -f -P "$(__mvnprefix_equals $cur)" -- "${cur#*=}" ) )
+		;;
+	pomFile=*)
+		__mvncomp "$(__mvnlist_poms)" "$(__mvnprefix_equals $cur)" "${cur#*=}"
+		;;
+	sources=*)
+		__mvncomp "$(__mvnlist_jars)" "$(__mvnprefix_equals $cur)" "${cur#*=}"
+		;;
+	javadoc=*)
+		__mvncomp "$(__mvnlist_jars)" "$(__mvnprefix_equals $cur)" "${cur#*=}"
+		;;
+	packaging=*)
+		__mvncomp "${__mvnpackaging}" "$(__mvnprefix_equals $cur)" "${cur#*=}"
+		;;
+	*)
+		local options="artifactId= classifier= file=press file=tab generatePom=true groupId= pomFile=press pomFile=tab
+		  createChecksum=true url= version= sources=press sources=tab javadoc=press javadoc=tab"
+		options="$options $(__mvnlist_prefix 'packaging=' ${__mvnpackaging} )"
+		__mvncomp "$options" "-D" "${cur}"
+		;;
+	esac
+}
+
 __mvnarchetype_generate ()
 {
 	local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -622,10 +656,14 @@
 
 _mvn ()
 {
-	local i prev c=1 cmd option optionArg=0
+	local i prev c=1 cmd option optionArg=0 cmdcomplete=0
+	local cur="${COMP_WORDS[COMP_CWORD]}"
 	COMPREPLY=() 
 
-	while [ $c -lt $COMP_CWORD ]; do
+	#echo " cur $cur"
+
+	# discover the options and the command
+	while [ $c -le $COMP_CWORD ]; do
 		prev=$i
 		i="${COMP_WORDS[c]}"
 		c=$((++c))
@@ -635,13 +673,54 @@
 			optionArg=1
 			continue;
 		fi
+
+		#echo "c $c i '$i'"
+
+		if [[ $cmdcomplete == -3 ]]; then
+		    cmdcomplete=1 # complete command
+		    break;
+		fi
+
+		if [[ "$i" == "" ]]; then
+		  if [[ $cmd ]]; then
+		    cmdcomplete=1 # complete command
+		    break;
+		  fi
+		  continue
+		fi
+
+		if [[ "$i" == ":" ]]; then
+		  if [[ $cmd ]]; then
+		    cmdcomplete=$((cmdcomplete-1))
+		    cmd="${cmd}:"
+		  fi
+		  continue
+		fi
+
 		case "$i" in
 		--version|--help) return ;;
 		-*) option="$i" ;;
-		*)  cmd="$i"; break ;;
+		*)  if [[ ! $cmd ]]; then 
+		      # incomplete command 
+		      cmdcomplete=$((cmdcomplete-1))
+		      cmd="$i"
+		      local next=$c
+		      if [[ $next -lt $COMP_CWORD ]]; then
+			#echo "next ${COMP_WORDS[next]}"
+		        if [[ "${COMP_WORDS[next]}" != ":" ]]; then
+		          break
+		        fi
+		      fi
+		    else
+		      cmdcomplete=$((cmdcomplete-1))
+		      cmd="$cmd$i"
+		    fi
+		    ;;
 		esac
 	done
 
+	#echo "cmd $cmd cmdcomplete $cmdcomplete"
+
 	if [[ ! $cmd && $option && ($optionArg == 0) ]]; then
 		case "$option" in
 		--file)
@@ -657,7 +736,6 @@
 			return
 			;;
 		--projects)
-			local cur="${COMP_WORDS[COMP_CWORD]}"
 			case "${cur}" in
 			*,*)
 				__mvncomp "$(__mvnlist_projects)" "$(__mvnprefix_comma $cur)" "${cur#*,}"
@@ -677,21 +755,37 @@
 		esac
 	fi
 
+	if [ $cmdcomplete -lt 0 ]; then
+		#echo "incomplete cmd $cmd"
+		case "${cmd}" in
+		*:)
+			local plugin="${cmd%%:}:"
+			#echo "plugin $plugin"
+			__mvncomp "$(__mvnlist_goals $plugin)" "$(__mvnprefix_colon $cmd)" ""
+			;;
+		*:*)
+			local plugin="${cmd%%:*}:"
+			#echo "plugin $plugin"
+			__mvncomp "$(__mvnlist_goals $plugin)" "$(__mvnprefix_colon $cmd)" "${cmd#*:}"
+			;;
+		*)     __mvncomp "${__mvnphases} ${__mvnall_plugin_and_goals}" ;;
+		esac
+		return
+	fi
+
 	if [ -z "$cmd" ]; then
-		local cur="${COMP_WORDS[COMP_CWORD]}"
+		#echo "empty cmd cur $cur"
 		case "${cur}" in
 		-D*=*) COMPREPLY=() ;;
 		-*)    __mvncomp "${__mvnopts} ${__mvnparams}" ;;
 		--*)   __mvncomp "${__mvnopts}" ;;
-		*:*)
-			local plugin="${cur%%:*}:"
-			__mvncomp "$(__mvnlist_goals $plugin)" "$(__mvnprefix_colon $cur)" "${cur#*:}"
-			;;
 		*)     __mvncomp "${__mvnphases} ${__mvnall_plugin_and_goals}" ;;
 		esac
 		return
 	fi
 
+	#echo "cmd $cmd"
+
 	case "$cmd" in
 	*:help) 
 		local plugin="${cmd%%:*}:"
@@ -710,6 +804,7 @@
 	dependency:purge-local-repository) __mvndependency_purge_local_repository ;;
 	dependency:analyze)		__mvndependency_analyze ;;
 	dependency:analyze-dep-mgt)	__mvndependency_analyze_dep_mgt ;;
+	install:install-file)		__mvninstall_install_file ;;
 	release:prepare)		__mvnrelease_prepare ;;
 	scm:checkin)			__mvnscm_checkin ;;
 	*)

Modified: trunk/maven2/debian/changelog
===================================================================
--- trunk/maven2/debian/changelog	2010-04-06 21:05:59 UTC (rev 12033)
+++ trunk/maven2/debian/changelog	2010-04-06 22:12:35 UTC (rev 12034)
@@ -1,3 +1,12 @@
+maven2 (2.2.1-4) unstable; urgency=low
+
+  * Improve bash completion for maven2, -D options are better
+    handled for plugins (for example, mvn install:install-file -DpomFile=...)
+  * Apply patch from Heikki Henriksen <heikkih at gmail.com> to
+    fix mvnDebug command. Thanks Heikki! (Closes: #561596)
+
+ -- Ludovic Claude <ludovic.claude at laposte.net>  Tue, 06 Apr 2010 20:38:51 +0200
+
 maven2 (2.2.1-3) unstable; urgency=low
 
   * Team Upload.

Added: trunk/maven2/debian/patches/mvnDebug-cmd.patch
===================================================================
--- trunk/maven2/debian/patches/mvnDebug-cmd.patch	                        (rev 0)
+++ trunk/maven2/debian/patches/mvnDebug-cmd.patch	2010-04-06 22:12:35 UTC (rev 12034)
@@ -0,0 +1,103 @@
+--- old/apache-maven/src/bin/mvnDebug	2009-12-18 15:08:02.000000000 +0100
++++ new/apache-maven/src/bin/mvnDebug	2009-12-18 15:07:34.000000000 +0100
+@@ -72,9 +72,80 @@
+            ;;
+ esac
+ 
++if [ -z "$M2_HOME" ] ; then
++  M2_HOME="/usr/share/maven2"
++fi
++
++# Debian patch - search for preferred JRE
++
++# Given the "java" executable as an argument, find JAVA_HOME
++find_java() {
++  # First check if it is a JDK in the /usr/lib/jvm directory, or a symlink there.
++  # The test is somewhat complicated due to the different ways the Java implementations
++  # are set up with the alternatives system
++  # e.g.
++  #  /usr/bin/java -> /etc/alternatives/java -> /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
++  # or
++  #  /usr/bin/java -> /etc/alternatives/java -> /usr/lib/jvm/java-gcj/bin/java -> /usr/bin/gij-4.2
++
++  JAVA_HOME=$1
++  while true ; do
++    case $JAVA_HOME in
++      /usr/lib/jvm/*)
++        # Found it! Return the correct paremt directory.
++
++        JAVA_HOME=`echo $JAVA_HOME | sed 's:\(/usr/lib/jvm/[^/]*\).*:\1:'`
++	return
++	;;
++      *) ;;
++    esac
++
++    if [ -h $JAVA_HOME ] ; then
++      JAVA_HOME=`readlink $JAVA_HOME`
++    else
++      break
++    fi
++  done
++        
++  # Not found in the Debian alternatives system, so presumably
++  # it is a user-installed JDK/JRE. Might as well be helpful
++  # and try to find JAVA_HOME.
++
++  # First try for a JDK:
++  JAVA_HOME=`readlink -e $1`
++  while [ `dirname $JAVA_HOME` != /  ]; do
++    if [ -e $JAVA_HOME/lib/tools.jar ]; then
++      return
++    fi
++
++    JAVA_HOME=`dirname $JAVA_HOME`
++  done
++
++  # If we get here we did not find a JDK. Search again for a JRE:
++  JAVA_HOME=`readlink -e $1`
++  while [ `dirname $JAVA_HOME` != /  ]; do
++    if [ -e $JAVA_HOME/bin/java ]; then
++      return
++    fi
++
++    JAVA_HOME=`dirname $JAVA_HOME`
++  done
++
++  # Nothing found; leave blank
++  JAVA_HOME=
++}
++
++    
+ if [ -z "$JAVA_HOME" ] ; then
+   if [ -r /etc/gentoo-release ] ; then
+     JAVA_HOME=`java-config --jre-home`
++  else
++    # Debian patch - search for preferred JRE
++    if [ -n "$JAVACMD" ] ; then
++      find_java "$JAVACMD"
++    else
++      find_java `which java`
++    fi
+   fi
+ fi
+ 
+@@ -132,7 +203,7 @@
+       JAVACMD="$JAVA_HOME/bin/java"
+     fi
+   else
+-    JAVACMD=java
++    JAVACMD="`which java`"
+   fi
+ fi
+ 
+@@ -161,9 +232,8 @@
+ exec "$JAVACMD" \
+   $MAVEN_OPTS \
+   $MAVEN_DEBUG_OPTS \
+-  -classpath "${M2_HOME}"/boot/classworlds-*.jar \
++  -classpath "${M2_HOME}"/boot/classworlds.jar \
+   "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
+   "-Dmaven.home=${M2_HOME}"  \
+   ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS
+ 
+-

Modified: trunk/maven2/debian/patches/series
===================================================================
--- trunk/maven2/debian/patches/series	2010-04-06 21:05:59 UTC (rev 12033)
+++ trunk/maven2/debian/patches/series	2010-04-06 22:12:35 UTC (rev 12034)
@@ -1,3 +1,4 @@
 mvn-cmd.patch
+mvnDebug-cmd.patch
 build.patch
 pom.patch




More information about the pkg-java-commits mailing list