MWE2 Running as Standalone [message #727602] |
Wed, 21 September 2011 11:52  |
Eclipse User |
|
|
|
Hi.
I just wanted to deploy my compiler as a standalone package. I created a CLI class which triggers the MWE2 Runner using the file specified using the arguments:
/**
* Runs the specified MWE file using the {@link Mwe2Runner} class created by
* a new {@link Mwe2StandaloneSetup} instance.
*
* @param mweFile the MWE file to execute
*/
public static void runAsStandalone(File mweFile) {
if (mweFile == null) {
throw new IllegalArgumentException("MWE file (mwe) must be set!"); //$NON-NLS-1$
}
if (!mweFile.exists() || !mweFile.isFile()) {
throw new IllegalArgumentException("The specified MWE file \"" + mweFile.getAbsolutePath() + "\" does not exist oder is no file"); //$NON-NLS-1$ //$NON-NLS-2$
}
Injector injector = new Mwe2StandaloneSetup().createInjectorAndDoEMFRegistration();
Mwe2Runner mweRunner = injector.getInstance(Mwe2Runner.class);
Map<String, String> empty = Collections.emptyMap();
mweRunner.run(URI.createFileURI(mweFile.getAbsolutePath()), empty);
}
Afterwards I exported the main dsl project using the Export as Runnable Jar to include all dependencies.
But I only get this error if I invoke the compiler:
> java -cp .;build -jar MyDslRuntime.jar build/CompileToC.mwe2
0 [main] FATAL at.mydsl.CLI - MyDsl Build Failed
java.lang.IllegalStateException: Couldn't find module CompileToC
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:79)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:64)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:55)
at at.mydsl.MyDslCompiler.runAsStandalone(MyDslCompiler.java:216)
at at.mydsl.CLI.main(CLI.java:33)
The I took a look at the Mwe2Runner.java and found this wierd code:
Mwe2Runner:62-66
EObject eObject = resource.getContents().get(0);
if (eObject instanceof Module) {
run(((Module) eObject).getCanonicalName(), params);
return;
}
Mwe2Runner:76-80
ppublic void run(String moduleName, Map<String, String> params, IWorkflowContext ctx) {
Module module = findModule(moduleName);
if (module == null) {
throw new IllegalStateException("Couldn't find module "+moduleName);
}
The Module instance is available on line 64 but only the name gets bypassed ot the other run method. There it tries to resolve the module by name. It seems the loaded module doesn't get registered correctly to find it via findModule.
Any Ideas?
Greetings
Daniel
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06853 seconds