3

I am currently evaluating EMF. Therefore, I created a few toy models inside Eclipse and generated the corresponding code.

Since my workflow does not contain any Eclipse related tools I would like to stick to my gradle-based workflow for non-toy projects. Is it possible and does it make sense to generate EMF models (provided via annotated Java) via Gradle without Eclipse?

miho
  • 833
  • 7
  • 11
  • Absolutely....emf core does not require any eclipse dependencies....but if you need any emf ui related features then probably you need eclipse dependencies... – saurav Mar 21 '16 at 03:09
  • I know that the generated code can theoretically run standalone without Eclipse. But can I run the code generator outside of Eclipse? Do you know how I can generate code for emf models with gradle? Thanks! – miho Mar 21 '16 at 15:21

1 Answers1

4

Xtext has the possibility to generate xtext languages using gradle. part of this option is to run mwe2 workflows. there is a mwe workflow component to run the ecore 2 java generator (EcoreGenerator)

thus you should be able to write a workflow that uses this component and do the generation via gradle. unfortunately if will be manual work to stick all together

Workflow {

bean = org.eclipse.emf.mwe.utils.StandaloneSetup {
    platformUri=".."
}

component = org.eclipse.emf.mwe.utils.DirectoryCleaner {
    directory ="src/main/java/sample"
}

component = org.eclipse.emf.mwe2.ecore.EcoreGenerator {
    generateCustomClasses = false
    genModel = "platform:/resource/org.xtext.example.mydsl3/model/sample.genmodel"
    srcPath = "platform:/resource/org.xtext.example.mydsl3/src/main/java" 
}
}

e.g. you may have to adapt the genmodel regarding the places where the generated sources should go to etc.

Christian Dietrich
  • 11,778
  • 4
  • 24
  • 32