Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Ecore Tools » Errors When Adding Second Xcore project(Code generation and duplicate type problems)
Errors When Adding Second Xcore project [message #1844084] Tue, 31 August 2021 19:06 Go to next message
Greg Lusk is currently offline Greg LuskFriend
Messages: 36
Registered: February 2017
Location: USA
Member
I have created a project with a structure similar to the one described here:

https://blogs.itemis.com/en/using-xtext-with-xcore-and-gradle

We are using Java 11, Xtext 2.25.0, Gradle 6.7.1, and Eclipse 4.20.0.

When there is only one Xcore project in our setup, everything works as expected; when I change something in the .xcore file, Java files are generated, and class path references are resolved (we have our build output setup to generate code at ./build/xcore/main as recommended in the blog post).

If I add a second Xcore project to the workspace, followed by a new .xcore file in that project's src directory, things still work as expected; code is generated in the ./build/xcore/main folder as directed by the @GenModel setup for the modelDirectory.

However, as soon as I add a build.gradle file for the second Xcore project and perform a Gradle refresh on that project, things go wrong. Code stops being generated when the .xcore file changes, and I begin to get errors in Eclipse stating that the types are already defined in the xcore file. My build.gradle file looks like this:

dependencies {
	compile 'org.eclipse.xtext:org.eclipse.xtext:2.25.0'
	compile "org.eclipse.xtext:org.eclipse.xtext.xbase:2.25.0"
	compile 'org.eclipse.emf:org.eclipse.emf.ecore.xcore.lib:1.6.0'

	xtextLanguages ('org.eclipse.emf:org.eclipse.emf.ecore.xcore:1.17.0') {
		exclude group: 'org.antlr', module: 'antlr-runtime'
		exclude group: 'org.eclipse.xtext', module: 'org.eclipse.xtext'
		exclude group: 'org.eclipse.xtext', module: 'org.eclipse.xtext.xbase'
	}
	xtextLanguages 'org.eclipse.emf:org.eclipse.emf.ecore.xcore.lib:1.6.0'
	xtextLanguages 'org.eclipse.emf:org.eclipse.emf.codegen.ecore:2.25.0'
	xtextLanguages 'org.eclipse.emf:org.eclipse.emf.codegen.ecore.xtext:1.6.0'
	xtextLanguages 'org.eclipse.xtext:org.eclipse.xtext.ecore:2.25.0'
}

sourceSets {
	main {
		resources {
			exclude '**/*.xcore'
		}
	}
}
// This is a workaround related to xtext issue https://github.com/eclipse/xtext/issues/1976
configurations.all {
	    resolutionStrategy { 
	        eachDependency { DependencyResolveDetails details ->
	            if (details.requested.group == 'org.eclipse.platform' && details.requested.name == 'org.eclipse.core.runtime') {
	                details.useVersion "3.19.0"
	            }
	            if (details.requested.group == 'org.eclipse.platform' && details.requested.name == 'org.eclipse.equinox.common') {
	                details.useVersion("3.13.0")
	            }
	        }
	    }
	}
xtext {
	version = "${xtextVersion}"
	languages {
		ecore {
			setup = 'org.eclipse.xtext.ecore.EcoreSupport'
		}
		codegen {
			setup = 'org.eclipse.emf.codegen.ecore.xtext.GenModelSupport'
		}
		xcore {
			setup = 'org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup'
			generator.outlet.cleanAutomatically=true
			generator.outlet.producesJava = true
		}
	}
	
}


In the first Xcore project, code generation continues to work correctly.

Does anyone know why code generation would fail like this for my second project?

Thanks,

Greg

[Updated on: Tue, 31 August 2021 20:13]

Report message to a moderator

Re: Errors When Adding Second Xcore project [message #1844258 is a reply to message #1844084] Tue, 07 September 2021 09:28 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Hi.
This forum is for the Ecore Tools graphical modeler (https://www.eclipse.org/ecoretools/).
For general questions about EMF, please use https://www.eclipse.org/forums/index.php/f/108/ instead, you'll have a better chance to get an answer.


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Errors When Adding Second Xcore project [message #1844314 is a reply to message #1844258] Wed, 08 September 2021 17:49 Go to previous message
Greg Lusk is currently offline Greg LuskFriend
Messages: 36
Registered: February 2017
Location: USA
Member
My apologies. I'll post to the TMF forum instead. Thanks!
Previous Topic:StateMachine Simulation on Sirius
Next Topic:Using EObject as Key in map structure
Goto Forum:
  


Current Time: Thu Apr 25 22:57:21 GMT 2024

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

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

Back to the top