6 echo "Usage: $CMD /path/to/jarfile" >&2
20 [ -z $JARFILE ] && usagexit
21 [ -f $JARFILE ] || error "No file $JARFILE"
22 [ -r $JARFILE ] || error "$JARFILE not readable"
26 FILENAME=$(basename $JARFILE)
27 BASE=$(basename -s $EXT $JARFILE)
28 DIR=$(dirname $JARFILE)
30 # set absolute path to $JARFILE if not specified
31 [ x${DIR#/} = x$DIR ] && DIR=$(cd "$DIR" && pwd)
33 ABSJARFILE=$DIR/$FILENAME
35 TMPDIR=/tmp/$USER-$CMD-$BASE-$$
37 [ x$FILENAME = x$BASE ] && error "Should be $EXT file"
39 mkdir -p $TMPDIR/jar || error "Could not create tmp dir $TMPDIR/jar"
40 mkdir -p $TMPDIR/info || error "Could not create tmp dir $TMPDIR/info"
42 jar -xvf $ABSJARFILE > /dev/null
43 jdeps --module-path="$DIR" --generate-module-info $TMPDIR/info $ABSJARFILE
44 # next line assuming only one module-info.java file created, I think this is always true...? It'll just use the last one if not.
45 find $TMPDIR/info -name "module-info.java" -exec /bin/mv {} . \;
46 [ -e ./module-info.java ] || error "No module-info.java file found in $TMPDIR/info"
47 javac -d $TMPDIR/jar ./module-info.java
48 jar -cvf $DIR/${BASE}${SUFFIX}${EXT} -C $TMPDIR/jar . > /dev/null