Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » generator output relative to dsl file(generator output relative to dsl file)
generator output relative to dsl file [message #1857216] Wed, 25 January 2023 09:27 Go to next message
Dennis Untiet is currently offline Dennis UntietFriend
Messages: 14
Registered: March 2022
Junior Member
Hello everyone,

I want to generate the src-gen folder next to my dsl file. The problem is that I have mutliple dsl files in my project. Is there a way that I can define the OutputConfiguration to do this?

I have seen that there exsists a IContextualOutputConfigurationProvider but I can't get this to work. If I understood that correctly, I would then overwrite the default output configuration for each resource every time I want to generate the code. That might not be perfect but might work.

When I generate the files "manually" in the generator ( generate file at location: resource.URI / generatedFile ) I get problems with deleting old files. In this scenario I have an OutputConfiguration with output folder: "." (the project root)

Thank you for helping!
Re: generator output relative to dsl file [message #1857217 is a reply to message #1857216] Wed, 25 January 2023 09:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14652
Registered: July 2009
Senior Member
hi, can you please be more percise on your exact requirements

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: generator output relative to dsl file [message #1857218 is a reply to message #1857216] Wed, 25 January 2023 10:36 Go to previous messageGo to next message
Dennis Untiet is currently offline Dennis UntietFriend
Messages: 14
Registered: March 2022
Junior Member
Hello Christian,
For example I have this project structure:

https://tree.nathanfriend.io/?s=(%27options!(%27fancy8~fullPath!false~trailingSlash8~rootDot8)~A(%27A%27Root0514052B1G*othCEsB2G7*9*60534%27)~vCsion!%271%27)*%20%200%5Cn*407965foldC6**genCatedE7*mydsl.dslG8!true9src-gen0Asource!BGsub5CerEFileG0*%01GECBA9876540*

And I only want to have for each mydsl.dsl file the src-gen folder next to it.
Re: generator output relative to dsl file [message #1857224 is a reply to message #1857218] Wed, 25 January 2023 15:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14652
Registered: July 2009
Senior Member
i dont know an easy solution for that.
is there a specific reason for that requirement?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 25 January 2023 15:28]

Report message to a moderator

Re: generator output relative to dsl file [message #1857312 is a reply to message #1857224] Mon, 30 January 2023 08:02 Go to previous messageGo to next message
Dennis Untiet is currently offline Dennis UntietFriend
Messages: 14
Registered: March 2022
Junior Member
Hey,

sorry for the late response.
There are reasons that are kind of stupid but it is what it is. That's unfortunately nothing that I can change. But back to the topic.
I found kind of an solution:
@Override
	public Set<OutputConfiguration> getOutputConfigurations(ResourceSet context) {
		Set<OutputConfiguration> set = new HashSet<>();
		set.add(OutputConfigurationProvider.DEFAULT());
		for (Resource res : context.getResources()) {
			OutputConfiguration outputConfiguration = new OutputConfiguration(res.toString());
			String path = res.getURI().toPlatformString(true);
			path = path + "folder";
			outputConfiguration.setOutputDirectory(path);
			outputConfiguration.setCleanUpDerivedResources(true);
			outputConfiguration.setCanClearOutputDirectory(true);
			outputConfiguration.setOverrideExistingResources(true);
			outputConfiguration.setCreateOutputDirectory(true);
			set.add(outputConfiguration);
		}
		return set;
	}

this is the output configuration and this is how I generate my files:

fsa.generateFile("pom.xml", resource.toString, generatePom(""))


So I generate my files for a resource with the right OutputConfiguration.
The problem I have now is that the old files are not deleted. I thought that is what setOverrideExistingResources does.
Does anyone knows a solution? Thanks!
Re: generator output relative to dsl file [message #1857314 is a reply to message #1857312] Mon, 30 January 2023 09:51 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14652
Registered: July 2009
Senior Member
i still dont understand: why not generating to a top level src-gen. which usecase do you solve by generating next to the file
for the incremental deletion you need to debug
the code in BuilderParticipant.getDerivedResources


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Content assist is not showing available dsl files for import
Next Topic:Xtext 2.30.0.M2 is out
Goto Forum:
  


Current Time: Sun Feb 25 09:01:40 GMT 2024

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

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

Back to the top