Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Workaround for ECJ issue 542090; FilerException: Source file already created #231

famod started this conversation in Ideas
Discussion options

Hi!

Please see https://bugs.eclipse.org/bugs/show_bug.cgi?id=542090#c43 for the general problem.

Given the age of that bug and the lack of activity, I was thinking about possible workarounds via plexus-compiler-eclipse.

What if EclipseJavaCompiler would delete target/generated-sources/annotations (or .../generated-test-sources/...) before calling ECJ?
Maybe controlled by a flag?

I would really like to use ECJ in my Maven projects because it's so much faster than javac and it also minimizes the risk of differences between IDE (Eclipse) and command line, but not being able to compile without clean (when e.g. mapstruct is involved) is a showstopper.

WDYT?

Cheers,
Falko

You must be logged in to vote

Replies: 1 comment · 1 reply

Comment options

After digging deeper, I think the issue actually lies within this module (plexus-compiler) and not within ECJ!

When I patch EclipseJavaCompiler to use AbstractCompiler.getSourceFiles(CompilerConfiguration) (instead of it's own logic) to gather allSources then the problem vanishes! This is due to the fact that then the explicit CompilerConfiguration.sourceFiles are preferred over CompilerConfiguration.sourceLocations.
The crucial thing at this point is that target/generated-sources/annotations is a sourceLocation, but none of its files are part of the sourceFiles (which I suppose are coming from maven-compiler-plugin).
Now, what's very interesting and revealing: When I patch AbstractCompiler.getSourceFiles(CompilerConfiguration) to ignore sourceFiles and use sourceLocations instead, then javac fails the same way ECJ is failing!
For me this is enough proof that the problem is in how this module is passing sources to ECJ (and potentially also Javac).

cc @olamy

You must be logged in to vote
1 reply
@famod
Comment options

I'll create a PR changing EclipseJavaCompiler to use AbstractCompiler.getSourceFiles(CompilerConfiguration).

But as I outlined above, if (for whatever reason) CompilerConfiguration.sourceFiles is empty, then the problem will kick in again, for both compilers!
Ignoring files in target/generated-sources/annotations and only setting it via -sourcepath would solve this, but what if some "standalone" annotation processor is writing to this directory? Are there even such processors/plugins in 2022? Processors are usually run via the compiler these days...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.