Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Absolute paths in ._trace files when building with maven and xtext-maven-plugin #2957

Closed
LorenzoBettini opened this issue Mar 12, 2024 · 3 comments · Fixed by #3044
Closed
Milestone

Comments

@LorenzoBettini
Copy link
Contributor

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=503309

@szarnekow
Copy link
Contributor

Here we install a project config on the resource set
https://github.com/eclipse/xtext/blob/main/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/batch/XtendBatchCompiler.java#L412

That project config has enough information to provide source folders and the like - which allows to create a project relative path to the source file.

In the maven plugin, we should probably configure a proper project configuration provider that exposes the source folders etc to the languages, too.

https://github.com/eclipse/xtext/blob/main/org.eclipse.xtext.maven.plugin/src/main/java/org/eclipse/xtext/maven/AbstractXtextGeneratorMojo.java#L187

@LorenzoBettini
Copy link
Contributor Author

further hint: see what the org.eclipse.xtext.xbase.testing.CompilationTestHelper.resourceSet(Pair<String, ? extends CharSequence>...) does:

	public ResourceSet resourceSet(@SuppressWarnings("unchecked") Pair<String,? extends CharSequence> ...resources ) throws IOException {
		XtextResourceSet result = newResourceSetWithUTF8Encoding();
		FileProjectConfig projectConfig = new FileProjectConfig(new File(workspaceRoot,PROJECT_NAME), PROJECT_NAME);
		projectConfig.addSourceFolder("src");
		ProjectConfigAdapter.install(result, projectConfig);
		for (Pair<String, ? extends CharSequence> entry : resources) {
			URI uri = copyToWorkspace(getSourceFolderPath()+"/"+entry.getKey(), entry.getValue());
			Resource resource = result.createResource(uri);
			if (resource == null)
				throw new IllegalStateException("Couldn't create resource for URI "+uri+". Resource.Factory not registered?");
			resource.load(result.getLoadOptions());
		}
		return result;
	}

@LorenzoBettini
Copy link
Contributor Author

@szarnekow Do you think this could be done/addressed directly in the StandaloneBuilder when we pass the sources?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants