Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Can I bundle grammar and genmodel into a jar?(make an mwe2 workflow reference genmodel and grammar from a jar)
Can I bundle grammar and genmodel into a jar? [message #1833134] Sat, 03 October 2020 07:46 Go to next message
Jan Hermes is currently offline Jan HermesFriend
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 #1833152 is a reply to message #1833134] Sun, 04 October 2020 12:15 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7178
Registered: July 2009
Senior Member
Hi

Yes. Without an example of your problems one can only guess.

You can find examples of all sorts of modularization and cross-project accesses in the org.eclipse.ocl.examples.build plugin and its references.

Regards

Ed Willink
Re: Can I bundle grammar and genmodel into a jar? [message #1834014 is a reply to message #1833152] Fri, 30 October 2020 08:14 Go to previous message
Jan Hermes is currently offline Jan HermesFriend
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

Previous Topic:JVM Model Infer Append String to XBlockExpression
Next Topic:mwe2 workflow: seperation of ide and non-ide fragments
Goto Forum:
  


Current Time: Thu Jun 24 01:37:20 GMT 2021

Powered by FUDForum. Page generated in 0.02007 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top