Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Error in building shadowJar from project with multiple xtext files (Cross-reference)(XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'org.xtext.projection.CustomTerminals'.)
Error in building shadowJar from project with multiple xtext files (Cross-reference) [message #1800368] Wed, 26 December 2018 00:30 Go to next message
Eclipse UserFriend
Hi,

I have a Xtext project with two xtext files having cross reference. When I tested the project as an Eclipse plugin, it worked well. Now I'm trying to create a shadowJar using gradle in order to implement my DSL in Eclipse-Che. The project generates artifacts without errors in the Eclipse editor. However, when I tried to build the shadowJar in the command prompt, I get an error saying 'XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'org.xtext.projection.CustomTerminals'.'

I will post my 2 grammar files, mwe2 file and the full error message below: -

Projection.xtext: -

grammar org.xtext.projection.Projection with org.xtext.projection.CustomTerminals

generate projection "http://www.xtext.org/projection/Projection"

Model:
	elements+=Element*;
	
Element:
	MyText | MyInt | MyDecimal | MyId | MyTime
;

MyText:
	'Hi' name=STRING
;

MyInt:
	'Integer:' int=INT
;

MyDecimal:
	'Decimal:' dec=DECIMAL
;

MyId:
	'ID:' id=ID
;

MyTime:
	'Time:' time=TIME
;





CustomTerminals.xtext: -

grammar org.xtext.projection.CustomTerminals with org.eclipse.xtext.common.Terminals hidden (LINE_COMMENT, LINE_COMMENT2, /*BLOCK_COMMENT,*/ ALERT_LINE_COMMENT, 
	QUESTION_LINE_COMMENT, GOOD_LINE_COMMENT, REGION_COMMENT, ML_COMMENT, SL_COMMENT, WS)

generate customTerminals "http://www.xtext.org/projection/CustomTerminals"

Rule:
	(rules+=Terminal)*
;

Terminal:
	TIME | CAMELCASE_IDENTIFIER | DECIMAL
;

@Override 
terminal ML_COMMENT : '/*' -> '*/';

@Override 
terminal SL_COMMENT : '//' !('\n'|'\r')* ('\r'? '\n')?;

@Override 
terminal WS         : (' '|'\t'|'\r'|'\n')+;

terminal LINE_COMMENT
   : ( '--' !('\r'|'\n')* )  
 
   ;

terminal LINE_COMMENT2
   : ( '//' !('!'|'?'|'='|'\r'|'\n')? !('\r'|'\n')* )  
 
   ;

//BLOCK_COMMENT is not required since ML_COMMENT is already defined
//terminal BLOCK_COMMENT
//   : '/*' .* '*/'  
//   ;

terminal ALERT_LINE_COMMENT
   : ( '//!' !('\r'|'\n')* )  
 
   ;

terminal QUESTION_LINE_COMMENT
   : ( '//?' ('\r'|'\n')* )  
 
   ;

terminal GOOD_LINE_COMMENT
   : ( '//=' !('\r'|'\n')* )  
 
   ;

terminal REGION_COMMENT
   : ( '---' ('-')+ (' ') (('A'..'Z'|'0'..'9')+ (' '))+ ('-')+ )
   ;

terminal TIME
   : ( ('0'..'9')+ ':' ('0'..'9')+ )
   ;

terminal CAMELCASE_IDENTIFIER
   : ('a'..'z') ('A'..'Z'|'a'..'z'|'0'..'9'|'_'|'$'|'#')*
   ;

terminal DECIMAL
   : ( ('0'..'9')+ '.' ('0'..'9')+ )
   ;

terminal CHARACTER
   : ('\'') !('\'') ('\'')
 
   ;
   
fragment
QUOT
   : '"'
   ;



mwe2: -

module org.xtext.projection.GenerateProjection

import org.eclipse.xtext.xtext.generator.*
import org.eclipse.xtext.xtext.generator.model.project.*

var rootPath = ".."

Workflow {
	
	component = XtextGenerator {
		configuration = {
			project = StandardProjectConfig {
				baseName = "org.xtext.projection"
				rootPath = rootPath
				runtimeTest = {
					enabled = true
				}
				genericIde = {
					enabled = true
				}
				mavenLayout = true
			}
			code = {
				encoding = "windows-1252"
				lineDelimiter = "\r\n"
				fileHeader = "/*\n * generated by Xtext \${version}\n */"
			}
			
		}
		language = StandardLanguage {
			name = "org.xtext.projection.CustomTerminals"
			fileExtensions = "projection"
			referencedResource = "platform:/resource/org.xtext.projection/src/main/java/org/xtext/projection/Projection.xtext"
			serializer = {
				generateStub = false
			}
			validator = {
			// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			// Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage
				generateDeprecationValidation = true
			}
			junitSupport = {
				junitVersion = "5"
			}
			parserGenerator = {
				debugGrammar = true
				options = {
					backtrack = true
				}
			}
		}
		language = StandardLanguage {
			name = "org.xtext.projection.Projection"
			fileExtensions = "projection"

			serializer = {
				generateStub = false
			}
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
				// Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage
				generateDeprecationValidation = true
			}
			junitSupport = {
				junitVersion = "5"
			}
		}
	}
}






Error: -

> Task :org.xtext.projection:generateXtextLanguage
0    [main] INFO  text.xtext.generator.XtextGenerator  - Initializing Xtext generator
5    [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.xtext.common.types.TypesPackage'
82   [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.projection at 'file:/D:/XtextConversion_DONOTDELETE/Completed/TEST_JAR_ProjectionForChe/org.xtext.projection.parent/org.xtext.projection/'
82   [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.projection at 'file:/D:/XtextConversion_DONOTDELETE/Completed/TEST_JAR_ProjectionForChe/org.xtext.projection.parent/org.xtext.projection/'
82   [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project org.xtext.projection.ide at 'file:/D:/XtextConversion_DONOTDELETE/Completed/TEST_JAR_ProjectionForChe/org.xtext.projection.parent/org.xtext.projection.ide/'
89   [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
366  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/Xtext/Xbase/XAnnotations' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
371  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xtype' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
388  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xbase' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
388  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/common/JavaVMTypes' from 'platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel'
415  [main] ERROR xt.generator.XtextGeneratorLanguage  - Error loading 'platform:/resource/org.xtext.projection/src/main/java/org/xtext/projection/Projection.xtext':
XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'org.xtext.projection.CustomTerminals'.
XtextLinkingDiagnostic: null:13 STRING cannot be resolved to a rule
XtextLinkingDiagnostic: null:17 INT cannot be resolved to a rule
XtextLinkingDiagnostic: null:21 DECIMAL cannot be resolved to a rule
XtextLinkingDiagnostic: null:25 ID cannot be resolved to a rule
XtextLinkingDiagnostic: null:29 TIME cannot be resolved to a rule
743  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
812  [main] ERROR xt.generator.XtextGeneratorLanguage  - [XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'org.xtext.projection.CustomTerminals'., XtextLinkingDiagnostic: null:13 STRING cannot be resolved to a rule, XtextLinkingDiagnostic: null:17 INT cannot be resolved to a rule, XtextLinkingDiagnostic: null:21 DECIMAL cannot be resolved to a rule, XtextLinkingDiagnostic: null:25 ID cannot be resolved to a rule, XtextLinkingDiagnostic: null:29 TIME cannot be resolved to a rule]
813  [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow org.xtext.projection.GenerateProjection: Problem parsing 'file:/D:/XtextConversion_DONOTDELETE/Completed/TEST_JAR_ProjectionForChe/org.xtext.projection.parent/org.xtext.projection/../org.xtext.projection/src/main/java/org/xtext/projection/Projection.xtext':
XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'org.xtext.projection.CustomTerminals'.
XtextLinkingDiagnostic: null:13 STRING cannot be resolved to a rule
XtextLinkingDiagnostic: null:17 INT cannot be resolved to a rule
XtextLinkingDiagnostic: null:21 DECIMAL cannot be resolved to a rule
XtextLinkingDiagnostic: null:25 ID cannot be resolved to a rule
XtextLinkingDiagnostic: null:29 TIME cannot be resolved to a rule
java.lang.RuntimeException: Problems running workflow org.xtext.projection.GenerateProjection: Problem parsing 'file:/D:/XtextConversion_DONOTDELETE/Completed/TEST_JAR_ProjectionForChe/org.xtext.projection.parent/org.xtext.projection/../org.xtext.projection/src/main/java/org/xtext/projection/Projection.xtext':
XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'org.xtext.projection.CustomTerminals'.
XtextLinkingDiagnostic: null:13 STRING cannot be resolved to a rule
XtextLinkingDiagnostic: null:17 INT cannot be resolved to a rule
XtextLinkingDiagnostic: null:21 DECIMAL cannot be resolved to a rule
XtextLinkingDiagnostic: null:25 ID cannot be resolved to a rule
XtextLinkingDiagnostic: null:29 TIME 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:/D:/XtextConversion_DONOTDELETE/Completed/TEST_JAR_ProjectionForChe/org.xtext.projection.parent/org.xtext.projection/../org.xtext.projection/src/main/java/org/xtext/projection/Projection.xtext':
XtextLinkingDiagnostic: null:1 Couldn't resolve reference to Grammar 'org.xtext.projection.CustomTerminals'.
XtextLinkingDiagnostic: null:13 STRING cannot be resolved to a rule
XtextLinkingDiagnostic: null:17 INT cannot be resolved to a rule
XtextLinkingDiagnostic: null:21 DECIMAL cannot be resolved to a rule
XtextLinkingDiagnostic: null:25 ID cannot be resolved to a rule
XtextLinkingDiagnostic: null:29 TIME cannot be resolved to a rule
        at org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage.initialize(XtextGeneratorLanguage.java:278)
        at org.eclipse.xtext.xtext.generator.StandardLanguage.initialize(StandardLanguage.java:189)
        at org.eclipse.xtext.xtext.generator.XtextGenerator.initialize(XtextGenerator.java:185)
        at org.eclipse.xtext.xtext.generator.XtextGenerator.checkConfigurationInternal(XtextGenerator.java:139)
        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

> Task :org.xtext.projection:generateXtextLanguage FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':org.xtext.projection:generateXtextLanguage'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_181\bin\java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 5s
1 actionable task: 1 executed



For ease, I have uploaded the project to github: https://github.com/SharkJ/ProjectionForChe.git


Could anyone please help me resolve this error?

Regards!

[Updated on: Wed, 26 December 2018 00:34] by Moderator

Re: Error in building shadowJar from project with multiple xtext files (Cross-reference) [message #1800377 is a reply to message #1800368] Wed, 26 December 2018 03:19 Go to previous messageGo to next message
Eclipse UserFriend
The referenced resource thing in the workflow makes no sense at the place it is
Re: Error in building shadowJar from project with multiple xtext files (Cross-reference) [message #1800378 is a reply to message #1800377] Wed, 26 December 2018 03:27 Go to previous messageGo to next message
Eclipse UserFriend
And you should solve the warnings and errors
Re: Error in building shadowJar from project with multiple xtext files (Cross-reference) [message #1800381 is a reply to message #1800377] Wed, 26 December 2018 03:59 Go to previous messageGo to next message
Eclipse UserFriend
Christian Dietrich wrote on Wed, 26 December 2018 13:49
The referenced resource thing in the workflow makes no sense at the place it is


Hi Christian,

Thank you for the reply!

Could you please point out how to correct this? When I built it in Eclipse, it worked fine. How should I correct the referenced resource?

Regards!
Re: Error in building shadowJar from project with multiple xtext files (Cross-reference) [message #1800382 is a reply to message #1800381] Wed, 26 December 2018 04:16 Go to previous messageGo to next message
Eclipse UserFriend
If the second grammar references the first one (commonrerminals)
Then the referenced resource entry should be at the second language section
And point to the first grammar and not the other way round
Re: Error in building shadowJar from project with multiple xtext files (Cross-reference) [message #1800504 is a reply to message #1800382] Mon, 31 December 2018 01:00 Go to previous message
Eclipse UserFriend
Hi,
It worked like a charm! Thank you! I have messed up the two grammars in the workflow.

Regards!
Previous Topic:Unit test MyDslProposalProvider
Next Topic:Error in Rules
Goto Forum:
  


Current Time: Tue Jun 17 08:03:22 EDT 2025

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

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

Back to the top