generator output relative to dsl file [message #1857216] |
Wed, 25 January 2023 09:27  |
Eclipse User |
|
|
|
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 #1857312 is a reply to message #1857224] |
Mon, 30 January 2023 08:02   |
Eclipse User |
|
|
|
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!
|
|
|
|
Powered by
FUDForum. Page generated in 0.02915 seconds