#!/bin/bash # Usage: make_classpath DIR # Finds jars in lib/, and class files in classes/ and build/classes # If CP is already set, include that as well. DIRROOT="$1" if [ "$DIRROOT" = "" ] then echo "No directory given" 1>&2 exit 1 fi # remove any trailing / DIRROOT=${DIRROOT%/} LIBDIR="$DIRROOT/lib" # List CPDIR1="$DIRROOT/classes" CPDIR2="$DIRROOT/target/classes" #CPDIR3="$DIRROOT/build/classes" ETCDIR="$DIRROOT/etc" # Cygwin - on Windows, the Java separator is ; # Alternative: Form in UNIX style, turn into windows form at the end. CYGWIN=0 SEP=':' if [ "$OSTYPE" = "cygwin" ] then CYGWIN=1 SEP=';' fi # CP is the variable collecting the path/ # It may already have a value. CP="${CP:-}" # Append any jars in the lib/ directory for jar in "$LIBDIR"/*.jar do # Check for no expansion [ -e "$jar" ] || break # Check not sources and no javadoc. [ "${jar/sources}" = "${jar}" ] || continue [ "${jar/javadoc}" = "${jar}" ] || continue #echo "Path: $jar" [ "$CP" != "" ] && CP="${CP}${SEP}" CP="${CP}$jar" ## # Suggested: ## if [ "$CYGWIN" = 1 ] ## then ## CP="${CP}$(cygpath -wp "$jar")" ## else ## CP="${CP}$jar" ## fi ## done # Prepend any classes/ directory # As it's "prepend", we need to do it in reverse. for dir in "$CPDIR2" "$CPDIR1" do if [ -e "$dir" ] then [ "$CP" != "" ] && CP="${SEP}${CP}" CP="${dir}$CP" fi done # Add DIRROOT #CP="${CP}${SEP}${DIRROOT}" ## if [ "$CYGWIN" = 1 ] ## then ## CP="$(cygpath -w "$CP")" ## fi echo "$CP"