The call-onsave ANT target, which takes care of generating necessary code from tmpl, sdf3, nab and ts files, currently only works when invoked from inside Eclipse. To improve command line support, it should also work from outside of Eclipse. Otherwise, you’ll end up putting all the generated files under version control if you want to do continuous integration.

I tried to get this working, but ran into the following error:

call-onsave2:
     [java] java.lang.IllegalStateException: Workbench has not been created yet.
     ....
     [java] Caused by: java.lang.IllegalStateException: Workbench has not been created yet.
     [java] 	at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:93)
     [java] 	at org.eclipse.imp.language.LanguageRegistry.preInitEditorRegistry(LanguageRegistry.java:94)
     [java] 	at org.eclipse.imp.language.LanguageRegistry.initializeRegistryAsNeeded(LanguageRegistry.java:274)
     [java] 	at org.eclipse.imp.language.LanguageRegistry.findLanguage(LanguageRegistry.java:165)
     [java] 	at org.strategoxt.imp.runtime.FileState.getFile(FileState.java:65)
     [java] 	at org.strategoxt.imp.metatooling.building.AntForceOnSave.main(AntForceOnSave.java:17)
     [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     [java] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     [java] 	at java.lang.reflect.Method.invoke(Method.java:606)
     [java] 	at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
     [java] 	at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
     [java] 	... 21 more
     [java] Java Result: -1

It seems like we can fix this by not having AntForceOnSave.java depend on IMP code. Is there possibly a solution in Spoofax Sunshine already?

Submitted by Oskar van Rest on 8 January 2014 at 08:20

On 8 January 2014 at 08:20 Oskar van Rest tagged major

On 8 January 2014 at 09:49 Gabriël Konat commented:

This requires language registration and loading so this will not work outside of Eclipse without huge changes in the architecture. You could build something similar in sunshine.


On 9 January 2014 at 09:57 Vlad Vergu commented:

This is exactly what Sunshine was made for. If you just remove the IMP dependency of AntForceOnSave you’ll probably still have dependencies on IMP in the rest of the Spoofax code.


On 9 January 2014 at 11:52 Oskar van Rest commented:

Yeah it seems like any dependency on UI components causes problems. Currently having similar troubles with GMF: hundreds of generated files but no headless support. I found a way to invoke the generator from ANT, but run into the same error as above :/


On 9 January 2014 at 11:59 Gabriël Konat commented:

Like I said, it requires language registration and loading from Spoofax, which depends on all kinds of Eclipse stuff so it will not run outside of Eclipse. You have to commit your generated files to the repository for now.

To properly do this in Sunshine you need to load all meta-languages like SDF3, NaBL, etc into Sunshine, and adapt the external build script to work with Sunshine instead of Spoofax.


On 9 January 2014 at 12:22 Oskar van Rest commented:

I actually meant that I’m having a similar problem with GMF; same error, different stack trace. Would still need to find a way to get it to work for GMF even if it works for Spoofax. But that’s different problem (will stop discussing it here :P).


On 29 April 2014 at 01:15 Oskar van Rest commented:

I was thinking, can’t we start shipping Sunshine with Spoofax Eclipse already to get this to work? It would only require a few changes to Sunshine and build.generated.xml. All the metalanguages that Sunshine needs can already be found in the Eclipse home directory. It works for GMF now, so would be nice if it actually works for Spoofax too :-)


On 29 April 2014 at 09:14 Vlad Vergu commented:

Actually Sunshine can already call the on-save handlers. To use this just call java -jar sunshine.jar -i ... --builder "OnSave" --build-on ...

Log in to post comments