Eclipse Jar export script
-
28-09-2019 - |
Question
I have a shared project that I'd like to split up in Eclipse. It's an android shared library which some packages should just be jar files others need to be smaller shared libraries.
What is the best way to handle this other than manually creating smaller projects?
Also is there a way to create a script to create exported jar files from eclipse if I gave it a project path?
Solution
What about doing a Ant script that generate different JARs?
References for the jar task : Intro tutorial, Jar task, More examples
OTHER TIPS
Simplistic shell script for creating JAR file from a standard Eclipse Dynamic Java project. Uses RAM file system (/dev/shm) on Linux systems.
#!/bin/sh
UTILITY=$(basename $0)
if [ -z "$1" ] ; then
echo "usage: $UTILITY [-s] <jar-directory>..."
echo " -s ..... With source"
exit 1
fi
if [ "$1" == "-s" ] ; then
WITH_SOURCE=1
shift
fi
while [ ! -z "$1" ] ; do
JAR_DIR=$1
shift
if [ ! -d $JAR_DIR ] ; then
echo "\"$JAR_DIR\" is not a directory"
continue
fi
if [ ! -d $JAR_DIR/bin ] ; then
echo "\"$JAR_DIR\" is not a Java JAR directory"
continue
fi
TMP_DIR=/dev/shm/${JAR_DIR}.$$.tmp
JAR_FILE=/dev/shm/${JAR_DIR}.jar
mkdir $TMP_DIR
pushd $JAR_DIR > /dev/null
cp -r bin/* $TMP_DIR
[ ! -z "$WITH_SOURCE" ] && cp -r src/* $TMP_DIR
cd $TMP_DIR > /dev/null
[ -e $JAR_FILE ] && rm -f $JAR_FILE
jar cf $JAR_FILE .
ls -lsF $JAR_FILE
popd > /dev/null
rm -rf $TMP_DIR
done
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow