Can I bundle grammar and genmodel into a jar? [message #1833134] |
Sat, 03 October 2020 07:46  |
Jan Hermes Messages: 27 Registered: September 2020 |
Junior Member |
|
|
Hello community,
I'm trying to divide my project into packages with different responsibilities.
- The core-project should just bundle the generated emf-model and its java-classes and the language grammar. (the mwe2 workflow only has the ecore.EMFGeneratorFragment2 activated)
- Another project should use the genmodel from core and the grammar and build the feature fragments for it (all the other fragments without the EMFGeneratorFragment2).
Actually everything would work as expected, but I cannot figure out how I can reference resources from jars in the mwe2 workflow.
Does anybody have some experience with that kind of workflow?
Regards,
Jan Hermes
[Updated on: Sat, 03 October 2020 08:02] Report message to a moderator
|
|
|
|
Re: Can I bundle grammar and genmodel into a jar? [message #1834014 is a reply to message #1833152] |
Fri, 30 October 2020 08:14  |
Jan Hermes Messages: 27 Registered: September 2020 |
Junior Member |
|
|
Hi,
yes sorry I was lacking an example. But I figured the way out I wanted it to be:
I now have a core-project for generating the model and maintaining the grammar and some-other-dependent projects that may use the core
core-project:
Workflow {
bean = org.eclipse.emf.mwe.utils.StandaloneSetup {
platformUri = rootPath
}
component = XtextGenerator {
configuration {
// ... the usual
}
language = XtextGeneratorLanguage {
name = "org.example.MyDsl"
fragment = ecore.EMFGeneratorFragment2 {
}
// the usual desired fragments etc...
}
}
}
Now in the standard gradle-workflow (e.g. via creating a new xtext-gradle project with the eclipse-wizard) there is already the setup, that the grammar and model are included in the generated jar artifact in <rootProject>/gradle/source-layout.gradle:
// ...
jar {
from('model') {
into('model')
}
from(sourceSets.main.allSource) {
include '**/*.xtext'
}
manifest {
attributes 'Bundle-SymbolicName': project.name
}
}
// ...
So after publishing the artifact, e.g. to org.example.mydsl:mydsl-core the xtext and model can be used in dependent projects, e.g. if I would have another gradle project with a dependency to the above core I can do this in the Workflow:
Some other dependent project
Workflow {
bean = StandaloneSetup {
platformUri = "${rootPath}"
scanClassPath = true
registerGeneratedEPackage = "org.example.mydsl.MyDslPackage"
registerGenModelFile = "platform:/resource/mydsl-core/model/generated/MyDsl.genmodel"
}
// ...
language = XtextGeneratorLanguage {
name = "de.fraunhofer.iosb.pslp.Pslp"
grammarUri = "platform:/resource/mydsl-core/org/example/mydsl/MyDsl.xtext"
fileExtensions = "mydsl"
// ...
In the above workflow I can reference any dependent artifact by its Bundle-SymbolicName as specified in the above source-layout.gradle via platform:/resource/<bundle-symbolic-name>. I just didn't know how to use this uri-specifications for accessing dependent jars on the classpath.
[Updated on: Fri, 30 October 2020 08:42] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01434 seconds