[osmosis-dev] call osmosis from groovy

Gubler, Ruediger rgubler at init-ka.de
Mon Sep 19 15:20:04 BST 2011


Hi,

classworlds calls fix the main method of the configured class. 
I added 
	" Thread.currentThread().setContextClassLoader(classLoader); "
and now i can call 
	" org.openstreetmap.osmosis.core.Osmosis.run(args) "


Yours Rüdiger 


-----Ursprüngliche Nachricht-----
Von: Igor Podolskiy [mailto:igor.podolskiy at vwi-stuttgart.de] 
Gesendet: Montag, 19. September 2011 14:44
An: Gubler, Ruediger
Cc: osmosis-dev
Betreff: Re: [osmosis-dev] call osmosis from groovy

Hi Rüdiger,

> I found there is a run method in
> "org.openstreetmap.osmosis.core.Osmosis" but it doesn't work with the
> following code:
are you sure your code works with the main() method? Since main() is 
basically a wrapper around run() which just does System.exit(0) or 
System.exit(1) depending on whether there were exceptions or not, both 
run() and main() are equivalent in terms of classpath requirements, 
plugin initialization, etc.

AFAIK you don't need to add everything in lib/default to the classpath, 
classworlds will do it for you. Instead, your initial classpath should 
contain the classworlds jar, and then you need to set some magic system 
properties to point to the classworlds configuration (in the 
$OSMOSIS_HOME/config directory). Just look in the Osmosis startup script 
($OSMOSIS_HOME/bin/osmosis) and try to set up the environment (with 
System.setProperty() or the like) the same way in your Groovy script 
before calling run() - after all, you are "emulating" that startup shell 
script if you use Osmosis.run() or Osmosis.main().

Hope that helps
Igor


More information about the osmosis-dev mailing list