[java-wrappers] 33/61: [java-wrappers] Experimental support for automatic classpath loading

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Tue Oct 24 17:55:20 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to branch master
in repository java-wrappers.

commit a9dce359af6267fecd1ba2a22065c8ba54f4c6d4
Author: Vincent Fourmond <fourmond at debian.org>
Date:   Sat Apr 2 23:48:44 2011 +0000

    [java-wrappers] Experimental support for automatic classpath loading
---
 debian/changelog             |  6 ++++++
 debian/java-wrappers.install |  3 ++-
 get-classpath                | 40 ++++++++++++++++++++++++++++++++++++++++
 java-wrappers.sh             | 33 ++++++++++++++++++++++++++++-----
 4 files changed, 76 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 5bd22d8..0daa751 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+java-wrappers (0.1.19) experimental; urgency=low
+
+  * First draft of a recursive classpath resolution function.
+
+ -- Vincent Fourmond <fourmond at debian.org>  Sun, 03 Apr 2011 01:38:16 +0200
+
 java-wrappers (0.1.18) unstable; urgency=low
 
   * The "let's break Java applications in Wheezy !" upload, or, in other
diff --git a/debian/java-wrappers.install b/debian/java-wrappers.install
index 076b5e8..b0763a8 100644
--- a/debian/java-wrappers.install
+++ b/debian/java-wrappers.install
@@ -1,2 +1,3 @@
 java-wrappers.sh usr/lib/java-wrappers
-jvm-list.sh usr/lib/java-wrappers
\ No newline at end of file
+jvm-list.sh usr/lib/java-wrappers
+get-classpath usr/lib/java-wrappers
\ No newline at end of file
diff --git a/get-classpath b/get-classpath
new file mode 100755
index 0000000..a40c8f5
--- /dev/null
+++ b/get-classpath
@@ -0,0 +1,40 @@
+#! /usr/bin/perl
+
+
+# get-classpayth, copyright 2011 by Vincent Fourmond
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+$file = shift(@ARGV);
+open MANIFEST, "unzip -p \"$file\" META-INF/MANIFEST.MF | ";
+my $cp = "";
+while(my $line = <MANIFEST>) {
+    if($line =~ /Class-Path:\s*(.*)/) {
+	$cp = $1;
+    }
+    elsif($cp) {
+	
+	if($line =~ /^ (.*)/) {
+	    $cp .= $1;
+	}
+	else {
+	    last;
+	}
+    }
+}
+close MANIFEST;
+$cp =~ s/\r//g;
+print "$cp\n";
+
diff --git a/java-wrappers.sh b/java-wrappers.sh
index 4a0be8f..61ea503 100644
--- a/java-wrappers.sh
+++ b/java-wrappers.sh
@@ -194,12 +194,8 @@ locate_jar() {
     elif [ -r $JAVA_JARPATH/$jar.jar ]; then
 	found_jar=$JAVA_JARPATH/$jar.jar
     elif [ -r $jar ]; then
-	# Maybe issue a warning that jars should not be looked
-	# for absolutely ?
 	found_jar=$jar
     elif [ -r $jar.jar ]; then
-	# Maybe issue a warning that jars should not be looked
-	# for absolutely ?
 	found_jar=$jar.jar
     else
 	return 1		# Not found
@@ -219,6 +215,33 @@ find_jars() {
     done
 }
 
+# This function tries to mimick the behaviour of the -jar option of
+# the java executable, by adding the target jar and all its classpath
+# recursively.
+#
+# This function is experimental for now, and its interface is not very
+# well specified yet.
+#
+# It will return without problem if the target class already is in the
+# classpath. It aborts with an error if a JAR file can't be found.
+find_jar_classpath() {
+    if locate_jar "$1"; then
+	looked_for_jars=1
+	if echo $JAVA_CLASSPATH | grep found_jar; then
+	    return 0;
+	fi
+	JAVA_CLASSPATH=$JAVA_CLASSPATH:$found_jar
+	for jar in $(/usr/lib/java-wrappers/get-classpath $found_jar); do
+	    find_jar_classpath $jar;
+	done
+    else
+	java_warning "Unable to locate the necessary jar file $jar"
+	return 1;
+    fi
+}
+
+
+
 # Adds the first jar found to the classpath. Useful for alternative
 # dependencies.
 find_one_jar_in() {
@@ -232,7 +255,7 @@ find_one_jar_in() {
     java_warning "Could fine none of $@ in $JAVA_JARPATH"
     return 1
 }
-
+    
 # Runs the program !
 run_java() {
     if [ -z "$JAVA_CMD" ]; then

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/java-wrappers.git



More information about the pkg-java-commits mailing list