Package: javatools
Version: 0.53

Tags: patch

jh_build fails when a source directory passed as an argument contains spaces. 
For example:

  $ jh_build org.eclipse.ui.workbench_3.107.0.qualifier.jar 
"bundles/org.eclipse.ui.workbench/Eclipse UI Editor Support"

produces this output:

  find bundles/org.eclipse.ui.workbench/Eclipse UI Editor Support -name *.java 
-and -type f -print0 | xargs -0 /usr/lib/jvm/default-java/bin/javac -g
-cp :debian/_jh_build.org.eclipse.ui.workbench_3.107.0.qualifier -d 
debian/_jh_build.org.eclipse.ui.workbench_3.107.0.qualifier -source 1.5 -target 
1.5
  find: `bundles/org.eclipse.ui.workbench/Eclipse': No such file or directory
  find: `UI': No such file or directory
  find: `Editor': No such file or directory
  find: `Support': No such file or directory
  javac: no source files
  Usage: javac <options> <source files>
  use -help for a list of possible options

Please consider including the attached patch which should fix this issue.

Regards,

Jakub
From cfdc0aa86f6847ca99ed51b4a2af3c112e366765 Mon Sep 17 00:00:00 2001
From: Jakub Adam <jakub.a...@ktknet.cz>
Date: Fri, 18 Sep 2015 14:36:02 +0200
Subject: [PATCH 1/2] jh_build: Fix build of sources with spaces in path

---
 jh_build | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/jh_build b/jh_build
index 6e99dee..cd5834c 100755
--- a/jh_build
+++ b/jh_build
@@ -73,13 +73,13 @@ function dobuild()
 	jarfile="$1"
 	shift
 	ext="`basename "$jarfile" .jar`"
-	srcdirs=
-	srcfiles=
+	srcdirs=()
+	srcfiles=()
 	while [ -n "$1" ]; do 
 		if [ -f "$1" ]; then
-			srcfiles="$srcfiles $1"
+			srcfiles+=("$1")
 		elif [ -d "$1" ]; then
-			srcdirs="$srcdirs $1"
+			srcdirs+=("$1")
 		else
 			echo "Ignoring $1 because it does not exist"
 		fi
@@ -110,32 +110,32 @@ function dobuild()
 	if [ -n "$srcdirs" ]; then
 
 		if [ -z "`getarg q quiet`" ]; then
-			echo find $srcdirs -name '*.java' -and -type f -print0 '|' xargs -0 $JAVAC -g -cp $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.$ext $JH_JAVAC_OPTS $srcfiles
+			echo find "${srcdirs[@]}" -name '*.java' -and -type f -print0 '|' xargs -0 $JAVAC -g -cp $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.$ext $JH_JAVAC_OPTS "${srcfiles[@]}"
 		fi
 
-		find $srcdirs -name '*.java' -and -type f -print0 | xargs -0 $JAVAC -g -cp $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.$ext $JH_JAVAC_OPTS $srcfiles
+		find "${srcdirs[@]}" -name '*.java' -and -type f -print0 | xargs -0 $JAVAC -g -cp $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.$ext $JH_JAVAC_OPTS "${srcfiles[@]}"
 
 		if [ -n "`getarg J javadoc`" ] || [ -z "`getarg N no-javadoc`" ]; then
 			if [ -z "`getarg q quiet`" ]; then
-				echo find $srcdirs -name '*.java' -and -type f -print0 '|' xargs -0 $JAVADOC $CLASSPATHDOCS -classpath $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.javadoc/api -quiet $JH_JAVADOC_OPTS $srcfiles
+				echo find "${srcdirs[@]}" -name '*.java' -and -type f -print0 '|' xargs -0 $JAVADOC $CLASSPATHDOCS -classpath $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.javadoc/api -quiet $JH_JAVADOC_OPTS "${srcfiles[@]}"
 			fi
 
-			find $srcdirs -name '*.java' -and -type f -print0 | xargs -0 $JAVADOC $CLASSPATHDOCS -classpath $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.javadoc/api -quiet $JH_JAVADOC_OPTS $srcfiles
+			find "${srcdirs[@]}" -name '*.java' -and -type f -print0 | xargs -0 $JAVADOC $CLASSPATHDOCS -classpath $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.javadoc/api -quiet $JH_JAVADOC_OPTS "${srcfiles[@]}"
 		fi
 
 	elif [ -n "$srcfiles" ]; then
 
 		if [ -z "`getarg q quiet`" ]; then
-			echo $JAVAC -g -cp $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.$ext $JH_JAVAC_OPTS $srcfiles
+			echo $JAVAC -g -cp $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.$ext $JH_JAVAC_OPTS "${srcfiles[@]}"
 		fi
 
-		$JAVAC -g -cp $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.$ext $JH_JAVAC_OPTS $srcfiles
+		$JAVAC -g -cp $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.$ext $JH_JAVAC_OPTS "${srcfiles[@]}"
 
 		if [ -n "`getarg J javadoc`" ] || [ -z "`getarg N no-javadoc`" ]; then
 			if [ -z "`getarg q quiet`" ]; then
-				echo $JAVADOC $CLASSPATHDOCS -classpath $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.javadoc/api -quiet $JH_JAVADOC_OPTS $srcfiles
+				echo $JAVADOC $CLASSPATHDOCS -classpath $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.javadoc/api -quiet $JH_JAVADOC_OPTS "${srcfiles[@]}"
 			fi
-			$JAVADOC $CLASSPATHDOCS -classpath $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.javadoc/api -quiet $JH_JAVADOC_OPTS $srcfiles
+			$JAVADOC $CLASSPATHDOCS -classpath $CLASSPATH:debian/_jh_build.$ext -d debian/_jh_build.javadoc/api -quiet $JH_JAVADOC_OPTS "${srcfiles[@]}"
 		fi
 
 	else
-- 
2.5.1

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to