Inspired by Stefan Frankes post about using the Eclipse Formatter on command line (e.g. for pre-commit formatting) I've tried to use the libs from Eclipse Mars. Using these libs the formatter is running but it does not shutdown.
I've used the following config.ini:
osgi.instance.area.default=./workspace
osgi.bundles.defaultStartLevel=4
eclipse.application=org.eclipse.jdt.core.JavaCodeFormatter
osgi.bundles= \
org.eclipse.core.runtime_3.11.1.v20150903-1804.jar@start ,\
org.eclipse.core.jobs_3.7.0.v20150330-2103.jar ,\
org.eclipse.core.contenttype_3.5.0.v20150421-2214.jar ,\
org.eclipse.equinox.registry_3.6.0.v20150318-1503.jar ,\
org.eclipse.equinox.preferences_3.5.300.v20150408-1437.jar ,\
org.eclipse.equinox.common_3.7.0.v20150402-1709.jar ,\
org.eclipse.equinox.app_1.3.300.v20150423-1356.jar ,\
org.eclipse.jdt.core_3.11.2.v20160128-0629.jar ,\
org.eclipse.core.resources_3.10.1.v20150725-1910.jar ,\
org.eclipse.core.filesystem_1.5.0.v20150725-1910.jar ,\
org.eclipse.core.commands_3.7.0.v20150422-0725.jar ,\
org.eclipse.core.expressions_3.5.0.v20150421-2214.jar ,\
org.eclipse.text_3.5.400.v20150505-1044.jar ,\
com.ibm.icu_54.1.1.v201501272100.jar ,\
org.eclipse.core.filesystem.win32.x86_1.4.0.v20140124-1940.jar ,\
org.eclipse.core.resources.win32.x86_3.5.100.v20140124-1940.jar ,\
Started using
java -jar plugins\org.eclipse.osgi_3.10.102.v20160118-1700.jar -config fmt.ini %*
Remote debugging showed that the app is idle. Calling the eclipse binary is because of the desired environment not an option for me.
Any ideas how to make it stop after the job is done?
I found a solution by myself that is working but I don't know if it's the best one ;-)
I created a new bundle containing only an Activator and an Application that extends CodeFormatterApplication by adding just a call to
Activator.getContext().getBundle( 0 ).stop();
to the original code:
public Object start( IApplicationContext context )
throws Exception
{
Object result = super.start( context );
Activator.getContext().getBundle( 0 ).stop();
return result;
}
This shuts down the system bundle causing the application (and the process) to shut down.
The idea was taken from this post.