|
|
|
|
|
|
|
|
|
|
Re: Invoke .emf from Ant programatically ? [message #1751889 is a reply to message #1751804] |
Mon, 16 January 2017 14:34 |
Lina Ochoa Messages: 8 Registered: January 2017 |
Junior Member |
|
|
Than you for your help. I have finally followed your standalone example, available in the Epsilon git repository:
https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/tree/examples/org.eclipse.epsilon.examples.workflow.standalone
Everything works fine now except for one thing. I am using Xtext and one of the models involved in the transformation has a ".coco2afm" extension. When I manually execute the transformation, these type of models are identified as Ecore models. However, when executing the workflow with Ant I obtain the following error:
Caused by: org.xml.sax.SAXParseExceptionpublicId: file:/C:/Path/runtime-EclipseApplication/CoCoPreviewV2.0/models/pruebasEscalabilidad/M0.coco2afm; systemId: file:/C:/Path/runtime-EclipseApplication/CoCoPreviewV2.0/models/pruebasEscalabilidad/M0.coco2afm; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException[ErrorHandlerWrapper.java:203]
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError[ErrorHandlerWrapper.java:177]
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError[XMLErrorReporter.java:441]
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError[XMLErrorReporter.java:368]
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError[XMLScanner.java:1437]
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next[XMLDocumentScannerImpl.java:999]
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next[XMLDocumentScannerImpl.java:606]
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument[XMLDocumentFragmentScannerImpl.java:510]
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse[XML11Configuration.java:848]
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse[XML11Configuration.java:777]
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse[XMLParser.java:141]
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse[AbstractSAXParser.java:1213]
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse[SAXParserImpl.java:649]
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse[SAXParserImpl.java:333]
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load[XMLLoadImpl.java:175]
... 23 more
I suppose it is trying to find and XML file which is in fact an instance of my DSL (plain text). I think it is an issue of third party dependencies. However, I would like to know if you have in mind which are those needed dependencies both of Epsilon and Xtext.
I have also followed with no success the guidelines defined in:
https://www.eclipse.org/forums/index.php/t/369157/
And I have added the following Xtex dependencies:
org.eclipse.xtext.satandalone.jar
org.eclipse.xtext.jar
org.eclipse.xtext.builder.jar
org.eclipse.xtext.builder.standalone.jar
org.eclipse.xtext.ecore.jar
org.eclipse.xtext.java.jar
org.eclipse.xtext.m2e.jar
Thank you again for your help.
[Updated on: Mon, 16 January 2017 14:52] Report message to a moderator
|
|
|
|
Re: Invoke .emf from Ant programatically ? [message #1752115 is a reply to message #1751913] |
Thu, 19 January 2017 01:35 |
Lina Ochoa Messages: 8 Registered: January 2017 |
Junior Member |
|
|
Hi Dimitris,
Thank you for all your help, it was very useful and accurate. Finally the ANT file was correctly executed. Just in case someone else needs the complete solution, these are the steps to follow:
When you want to programatically execute an ANT file with epsilon transformations, (and maybe you have Xtext files):
- Develop your Xtext grammar, execute the mwe2 file, and generate "Model", "Edit", and "Editor" code from the genmodel file.
- Generate a runnable JAR from the Xtext project based on the steps provided in https://www.eclipse.org/forums/index.php/t/369157/
- Create your Epsilon standalone project based on the following example https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/tree/examples/org.eclipse.epsilon.examples.workflow.standalone
- Include the required dependencies (see Note 1 below)
- Implement the Ant Executor (see Note 2 below)
- Implement the Xtext model reader (see Note 3 below)
Note 1 (Required dependencies):
- ant.jar
- ant-launcher.jar
- mydsl.jar (obtained from step 2)
- epsilon-1.X-workflow-emf-src.jar
- epsilon-1.X-workflow-src.jar
- org.eclipse.emf.jar
- org.eclipse.emf.common.jar
- org.eclipse.emf.ecore.jar
- org.eclipse.emf.ecore.xmi.jar
- org.eclipse.emf.jar
- org.eclipse.xsd.jar
- org.eclipse.epsilon.*.jar (depending on your project needs)
Note 2 (ANT executor):
File file = new File(pathAnt);
Project project = new Project();
project.init();
DefaultLogger logger = new DefaultLogger();
logger.setErrorPrintStream(System.err);
logger.setOutputPrintStream(System.err);
logger.setMessageOutputLevel(Project.MSG_INFO);
project.setProperty("ant.file", file.getAbsolutePath());
project.addBuildListener(logger);
project.fireBuildStarted();
ProjectHelper helper = ProjectHelper.getProjectHelper();
project.addReference("ant.projectHelper", helper);
helper.parse(project, file);
project.executeTarget(project.getDefaultTarget());
Note 3 (Xtext model reader):
This code is based on https://wiki.eclipse.org/Xtext/FAQ#How_do_I_load_my_model_in_a_standalone_Java_application.C2.A0.3F and https://www.eclipse.org/epsilon/doc/articles/in-memory-emf-model/.
StandaloneSetup setup = new StandaloneSetup();
setup.setPlatformUri("../");
Injector injector = new CoCo2AfmStandaloneSetupGenerated().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
URI uri = URI.createURI("ModelURI");
Resource resource = resourceSet.getResource(uri, true);
InMemoryEmfModel emfModel = new InMemoryEmfModel(resource);
emfModel.loadModel();
emfModel.setModelFile("ModelPath");
emfModel.setName("ModelName");
Additional Note:
If you have problems to modify a model (although you have set store=true), use the storeModel task after executing the transformation (it happens to me).
<epsilon.storeModel model="ModelName"/>
[Updated on: Thu, 19 January 2017 18:31] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04344 seconds