Author: fourmond Date: 2011-04-02 23:48:44 +0000 (Sat, 02 Apr 2011) New Revision: 13489
Added: trunk/java-wrappers/get-classpath Modified: trunk/java-wrappers/debian/changelog trunk/java-wrappers/debian/java-wrappers.install trunk/java-wrappers/java-wrappers.sh Log: [java-wrappers] Experimental support for automatic classpath loading Modified: trunk/java-wrappers/debian/changelog =================================================================== --- trunk/java-wrappers/debian/changelog 2011-04-02 23:37:49 UTC (rev 13488) +++ trunk/java-wrappers/debian/changelog 2011-04-02 23:48:44 UTC (rev 13489) @@ -1,3 +1,9 @@ +java-wrappers (0.1.19) experimental; urgency=low + + * First draft of a recursive classpath resolution function. + + -- Vincent Fourmond <[email protected]> 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 Modified: trunk/java-wrappers/debian/java-wrappers.install =================================================================== --- trunk/java-wrappers/debian/java-wrappers.install 2011-04-02 23:37:49 UTC (rev 13488) +++ trunk/java-wrappers/debian/java-wrappers.install 2011-04-02 23:48:44 UTC (rev 13489) @@ -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 Added: trunk/java-wrappers/get-classpath =================================================================== --- trunk/java-wrappers/get-classpath (rev 0) +++ trunk/java-wrappers/get-classpath 2011-04-02 23:48:44 UTC (rev 13489) @@ -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"; + Property changes on: trunk/java-wrappers/get-classpath ___________________________________________________________________ Added: svn:executable + * Modified: trunk/java-wrappers/java-wrappers.sh =================================================================== --- trunk/java-wrappers/java-wrappers.sh 2011-04-02 23:37:49 UTC (rev 13488) +++ trunk/java-wrappers/java-wrappers.sh 2011-04-02 23:48:44 UTC (rev 13489) @@ -194,12 +194,8 @@ 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 @@ 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 @@ java_warning "Could fine none of $@ in $JAVA_JARPATH" return 1 } - + # Runs the program ! run_java() { if [ -z "$JAVA_CMD" ]; then _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/pkg-java-commits

