Skip to content

Commit

Permalink
Allow setting module path.
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaub committed May 30, 2012
1 parent d5f08da commit 129f7a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
9 changes: 7 additions & 2 deletions bin/geoscript
Expand Up @@ -49,15 +49,20 @@ else
CLASS=org.geoscript.js.GeoScriptShell CLASS=org.geoscript.js.GeoScriptShell
fi fi


ARGS=
if [ -x $MODULES ]; then
ARGS="-Dgeoscript.modules=$MODULES"
fi

if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
# resolve absolute path to main module # resolve absolute path to main module
MAIN_PATH=$( MAIN_PATH=$(
cd -P -- "$(dirname -- "$1")" \ cd -P -- "$(dirname -- "$1")" \
&& pwd -P && pwd -P
) && MAIN_PATH=$MAIN_PATH/$(basename -- "$1") ) && MAIN_PATH=$MAIN_PATH/$(basename -- "$1")


java -cp $CP $CLASS -main $MAIN_PATH java -cp $CP $ARGS $CLASS -main $MAIN_PATH
else else
java -cp $CP $CLASS java -cp $CP $ARGS $CLASS
fi fi


14 changes: 8 additions & 6 deletions src/main/java/org/geoscript/js/GeoScriptModules.java
Expand Up @@ -6,12 +6,14 @@
public class GeoScriptModules { public class GeoScriptModules {


public static String getModulePath() { public static String getModulePath() {
URL moduleUrl = GeoScriptModules.class.getResource("lib"); String modulePath = System.getProperty("geoscript.modules");
String modulePath; if (modulePath == null) {
try { URL moduleUrl = GeoScriptModules.class.getResource("lib");
modulePath = moduleUrl.toURI().toString(); try {
} catch (URISyntaxException e) { modulePath = moduleUrl.toURI().toString();
throw new RuntimeException("Trouble evaluating GeoScript module path.", e); } catch (URISyntaxException e) {
throw new RuntimeException("Trouble evaluating GeoScript module path.", e);
}
} }
return modulePath; return modulePath;
} }
Expand Down

0 comments on commit 129f7a9

Please sign in to comment.