Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Couldn't resolve reference to Grammar(Reference grammar from jar )
Couldn't resolve reference to Grammar [message #1743887] Tue, 20 September 2016 12:22 Go to next message
Denis Krusko is currently offline Denis KruskoFriend
Messages: 3
Registered: September 2016
Junior Member
I looked for the documentation about importing existing metamodels https://www.eclipse.org/Xtext/documentation/302_configuration.html, as well as corresponding topics on this forum, but nothing helps.

I have 2 projects, created with org.xtext:xtext-gradle-plugin:1.0.2 and IntelliJ IDEA 2016.2.3. A grammar from co3.linearisationScript project refers to a grammar from eu.metatools.util.featurelogic.term project.

xtextVersion = '2.10.0'


As every project has a deep structure, lke:
co3.linearisationScript/co3.linearisationScript.parent/co3.linearisationScript
, I am trying to import the dependency project as a jar.

Jar contains Manifest:
Manifest-Version: 1.0
Bundle-SymbolicName: eu.metatools.util.featurelogic.term
Bundle-Name: eu.metatools.util.featurelogic.term
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: JavaSE-1.8

, generated model (Term.ecore and Term.genmodel), *.xtextbin and other files.

I added dependencies to build.gradle:

 compile "eu.metatools.util.featurelogic.term:eu.metatools.util.featurelogic.term:1.0.0-SNAPSHOT"

and (probably redundant)
  mwe2 "eu.metatools.util.featurelogic.term:eu.metatools.util.featurelogic.term:1.0.0-SNAPSHOT"
into co3.linearisationScript project.,

referencedResource and bean to GenerateLinearisationScript.mwe2:
 referencedResource = 'platform:/resource/eu.metatools.util.featurelogic.term/model/generated/Term.genmodel'

    bean = StandaloneSetup {
        scanClassPath = true
        registerGeneratedEPackage = "eu.metatools.util.featurelogic.term.term.TermPackage"
        registerGenModelFile = "platform:/resource/eu.metatools.util.featurelogic.term/model/generated/Term.genmodel"
    }


And still get the error " Couldn't resolve reference to Grammar".

13:23:27: Executing external task 'build'...
[DefaultExternalModuleDependency{group='eu.metatools.util.featurelogic.term', name='eu.metatools.util.featurelogic.term', version='1.0.0-SNAPSHOT', configuration='default'}, DefaultExternalModuleDependency{group='org.eclipse.xtext', name='org.eclipse.xtext', version='2.10.0', configuration='default'}, DefaultExternalModuleDependency{group='org.eclipse.xtext', name='org.eclipse.xtext.xtext.generator', version='2.10.0', configuration='default'}, DefaultExternalModuleDependency{group='org.eclipse.xtext', name='org.eclipse.xtext.generator', version='2.10.0', configuration='default'}, DefaultExternalModuleDependency{group='org.eclipse.xtext', name='org.eclipse.xtext.xtext', version='2.10.0', configuration='default'}, DefaultExternalModuleDependency{group='org.eclipse.emf', name='org.eclipse.emf.mwe2.launch', version='2.8.3', configuration='default'}, DefaultExternalModuleDependency{group='org.eclipse.xtext', name='org.eclipse.xtext.xbase.lib', version='${xtextVersion}', configuration='default'}]
:co3.linearisationScript:generateXtextLanguage
0    [main] WARN  lipse.emf.mwe.utils.StandaloneSetup  - Skipping conflicting project antlr at 'archive:file:/home/kunz/.gradle/caches/modules-2/files-2.1/org.antlr/antlr-runtime/3.2/31c746001016c6226bd7356c9f87a6a084ce3715/antlr-runtime-3.2.jar!/' and using 'archive:file:/home/kunz/.gradle/caches/modules-2/files-2.1/org.xtext/antlr-generator/3.2.1/d3fa97d931949af341889c94f6455822674e52f2/antlr-generator-3.2.1.jar!/' instead.
1    [main] WARN  lipse.emf.mwe.utils.StandaloneSetup  - Skipping conflicting project antlr at 'archive:file:/home/kunz/.gradle/caches/modules-2/files-2.1/org.xtext/antlr-generator/3.2.1/d3fa97d931949af341889c94f6455822674e52f2/antlr-generator-3.2.1.jar!/' and using 'archive:file:/home/kunz/.gradle/caches/modules-2/files-2.1/antlr/antlr/2.7.7/83cd2cd674a217ade95a4bb83a8a14f351f48bd0/antlr-2.7.7.jar!/' instead.
12   [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'eu.metatools.util.featurelogic.term.term.TermPackage'
169  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http : / / www.metatools.eu / util /featurelogic / term / Term' from 'platform:/resource/eu.metatools.util.featurelogic.term/model/generated/Term.genmodel'
809  [main] INFO  text.xtext.generator.XtextGenerator  - Initializing Xtext generator
810  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.xtext.common.types.TypesPackage'
876  [main] WARN  lipse.emf.mwe.utils.StandaloneSetup  - Skipping conflicting project antlr at 'archive:file:/home/kunz/.gradle/caches/modules-2/files-2.1/antlr/antlr/2.7.7/83cd2cd674a217ade95a4bb83a8a14f351f48bd0/antlr-2.7.7.jar!/' and using 'archive:file:/home/kunz/.gradle/caches/modules-2/files-2.1/org.antlr/antlr-runtime/3.2/31c746001016c6226bd7356c9f87a6a084ce3715/antlr-runtime-3.2.jar!/' instead.
883  [main] WARN  lipse.emf.mwe.utils.StandaloneSetup  - Skipping conflicting project antlr at 'archive:file:/home/kunz/.gradle/caches/modules-2/files-2.1/org.antlr/antlr-runtime/3.2/31c746001016c6226bd7356c9f87a6a084ce3715/antlr-runtime-3.2.jar!/' and using 'archive:file:/home/kunz/.gradle/caches/modules-2/files-2.1/org.xtext/antlr-generator/3.2.1/d3fa97d931949af341889c94f6455822674e52f2/antlr-generator-3.2.1.jar!/' instead.
884  [main] WARN  lipse.emf.mwe.utils.StandaloneSetup  - Skipping conflicting project antlr at 'archive:file:/home/kunz/.gradle/caches/modules-2/files-2.1/org.xtext/antlr-generator/3.2.1/d3fa97d931949af341889c94f6455822674e52f2/antlr-generator-3.2.1.jar!/' and using 'archive:file:/home/kunz/.gradle/caches/modules-2/files-2.1/antlr/antlr/2.7.7/83cd2cd674a217ade95a4bb83a8a14f351f48bd0/antlr-2.7.7.jar!/' instead.
887  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project co3.linearisationScript at 'file:/home/kunz/workspace/xtext-gradle-demo/co3.linearisationScript/co3.linearisationScript.parent/co3.linearisationScript/'
905  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
1066 [main] ERROR xt.generator.XtextGeneratorLanguage  - [XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'eu.metatools.util.featurelogic.term.Term'., XtextLinkingDiagnostic: null:11 INT cannot be resolved to a rule, XtextLinkingDiagnostic: null:11 Cannot resolve implicit reference to rule 'ID', XtextLinkingDiagnostic: null:14 ID cannot be resolved to a rule, XtextLinkingDiagnostic: null:42 STRING cannot be resolved to a rule, XtextLinkingDiagnostic: null:45 Cannot resolve implicit reference to rule 'ID', XtextLinkingDiagnostic: null:87 ID cannot be resolved to a rule, XtextLinkingDiagnostic: null:91 TermGeneral cannot be resolved to a rule]
1070 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow co3.lscript.GenerateLinearisationScript: Problem parsing 'file:/home/kunz/workspace/xtext-gradle-demo/co3.linearisationScript/co3.linearisationScript.parent/co3.linearisationScript/../co3.linearisationScript/src/main/java/co3/lscript/LinearisationScript.xtext':
XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'eu.metatools.util.featurelogic.term.Term'.
XtextLinkingDiagnostic: null:11 INT cannot be resolved to a rule
XtextLinkingDiagnostic: null:11 Cannot resolve implicit reference to rule 'ID'
XtextLinkingDiagnostic: null:14 ID cannot be resolved to a rule
XtextLinkingDiagnostic: null:42 STRING cannot be resolved to a rule
XtextLinkingDiagnostic: null:45 Cannot resolve implicit reference to rule 'ID'
XtextLinkingDiagnostic: null:87 ID cannot be resolved to a rule
XtextLinkingDiagnostic: null:91 TermGeneral cannot be resolved to a rule
java.lang.RuntimeException: Problems running workflow co3.lscript.GenerateLinearisationScript: Problem parsing 'file:/home/kunz/workspace/xtext-gradle-demo/co3.linearisationScript/co3.linearisationScript.parent/co3.linearisationScript/../co3.linearisationScript/src/main/java/co3/lscript/LinearisationScript.xtext':
XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'eu.metatools.util.featurelogic.term.Term'.
XtextLinkingDiagnostic: null:11 INT cannot be resolved to a rule
XtextLinkingDiagnostic: null:11 Cannot resolve implicit reference to rule 'ID'
XtextLinkingDiagnostic: null:14 ID cannot be resolved to a rule
XtextLinkingDiagnostic: null:42 STRING cannot be resolved to a rule
XtextLinkingDiagnostic: null:45 Cannot resolve implicit reference to rule 'ID'
XtextLinkingDiagnostic: null:87 ID cannot be resolved to a rule
XtextLinkingDiagnostic: null:91 TermGeneral cannot be resolved to a rule
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:104)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.lang.IllegalStateException: Problem parsing 'file:/home/kunz/workspace/xtext-gradle-demo/co3.linearisationScript/co3.linearisationScript.parent/co3.linearisationScript/../co3.linearisationScript/src/main/java/co3/lscript/LinearisationScript.xtext':
XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'eu.metatools.util.featurelogic.term.Term'.
XtextLinkingDiagnostic: null:11 INT cannot be resolved to a rule
XtextLinkingDiagnostic: null:11 Cannot resolve implicit reference to rule 'ID'
XtextLinkingDiagnostic: null:14 ID cannot be resolved to a rule
XtextLinkingDiagnostic: null:42 STRING cannot be resolved to a rule
XtextLinkingDiagnostic: null:45 Cannot resolve implicit reference to rule 'ID'
XtextLinkingDiagnostic: null:87 ID cannot be resolved to a rule
XtextLinkingDiagnostic: null:91 TermGeneral cannot be resolved to a rule
	at org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage.initialize(XtextGeneratorLanguage.java:272)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.initialize(XtextGenerator.java:176)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.checkConfigurationInternal(XtextGenerator.java:120)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2.checkConfiguration(AbstractWorkflowComponent2.java:21)
	at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.preInvoke(Mwe2Bridge.java:65)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.preInvoke(AbstractWorkflowComponent.java:197)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.preInvoke(AbstractCompositeWorkflowComponent.java:29)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:18)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
	... 4 more
:co3.linearisationScript:generateXtextLanguage FAILED

FAILURE: Build failed with an exception.


I created a corresponding demo project on github:
https://github.com/kruskod/xtext-gradle-demo

Could you tell me, what is wrong with my configuration?

[Updated on: Tue, 20 September 2016 14:59]

Report message to a moderator

Re: Couldn't resolve reference to Grammar [message #1743908 is a reply to message #1743887] Tue, 20 September 2016 14:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14677
Registered: July 2009
Senior Member
Can you please create and share a reproducing sample project

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to Grammar [message #1743913 is a reply to message #1743908] Tue, 20 September 2016 15:03 Go to previous messageGo to next message
Denis Krusko is currently offline Denis KruskoFriend
Messages: 3
Registered: September 2016
Junior Member
Please take a look at this:
https://github.com/kruskod/xtext-gradle-demo
Re: Couldn't resolve reference to Grammar [message #1743916 is a reply to message #1743913] Tue, 20 September 2016 15:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14677
Registered: July 2009
Senior Member
the jar does not contain the *.xtext file.
somewhere in your gradle file bunch must be a configuration that reprevents that.

e.g. changing to

resources.srcDirs = ['src/main/resources', 'src/main/xtext-gen','src/main/java']

should do the trick


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to Grammar [message #1743923 is a reply to message #1743916] Tue, 20 September 2016 16:41 Go to previous messageGo to next message
Denis Krusko is currently offline Denis KruskoFriend
Messages: 3
Registered: September 2016
Junior Member
Thank you for your answer!

Indeed the problem was in the lack of the *.xtext files.

This solved my problem:
sourceSets {
    main {
        resources {
            srcDirs = ['src/main/resources', 'src/main/xtext-gen','src/main/java']
            exclude '*.xtend'
        }
    }
}


Does xtext grammar need any *.xtend files in the jar?
I think they are redundant, so I filtered them out.
Re: Couldn't resolve reference to Grammar [message #1743927 is a reply to message #1743923] Tue, 20 September 2016 17:08 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14677
Registered: July 2009
Senior Member
No it does not

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Namespace Global Scoping not working properly in IntelliJ
Next Topic:use of EOF
Goto Forum:
  


Current Time: Fri May 10 15:23:12 GMT 2024

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

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

Back to the top