Skip to content

Issue #68: use JSR-199 to call Eclipse compiler #69

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

Merged
merged 1 commit into from
Feb 15, 2020

Conversation

tomaswolf
Copy link
Contributor

@tomaswolf tomaswolf commented Feb 1, 2020

Instead of invoking BatchCompiler with an option to write diagnostics
to a temporary XML file and then parsing that call ECJ via the standard
JSR-199 interfaces and use a DiagnosticListener.

Besides not needing a temporary file this also ensures that all
diagnostics are reported correctly. ECJ's BatchCompiler reports
diagnostics from APT processors differently than other diagnostics
(they're "extra_problems" in the XML), and the XML parser just ignores
these extra_problems. Even if it did parse them, ECJ up to at least
3.20.0 neglects to give the source file for such extra_problems in the
XML (that's a bug in ECJ), and thus the output would be not exactly
helpful.

Using JSR-199 to call ECJ, it reports all diagnostics including these
"extra_problems" (with source file!) to the DiagnosticListener, and
thus no messages are lost.

A minor quirk is that when no source level is specified, BatchCompiler
compiles with source level 1.3, while the ECJ JSR-199 implementation
uses the latest source level it supports (Java 12 for ECJ 3.20.0). To
maintain backwards compatibility, set source level 1.3 explicitly in
that case. In normal maven usage, <source> is typically set anyway,
either explicitly in the user projects' POMs or via property
maven.compiler.source.

If no JSR-199 interface for ECJ can be found keep using the legacy
mechanism using BatchCompiler.

Instead of invoking BatchCompiler with an option to write diagnostics
to a temporary XML file and then parsing that call ECJ via the standard
JSR-199 interfaces and use a DiagnosticListener.

Besides not needing a temporary file this also ensures that all
diagnostics are reported correctly. ECJ's BatchCompiler reports
diagnostics from APT processors differently than other diagnostics
(they're "extra_problems" in the XML), and the XML parser just ignores
these extra_problems. Even if it did parse them, ECJ up to at least
3.20.0 neglects to give the source file for such extra_problems in the
XML (that's a bug in ECJ), and thus the output would be not exactly
helpful.

Using JSR-199 to call ECJ, it reports all diagnostics including these
"extra_problems" (with source file!) to the DiagnosticListener, and
thus no messages are lost.

A minor quirk is that when no source level is specified, BatchCompiler
compiles with source level 1.3, while the ECJ JSR-199 implementation
uses the latest source level it supports (Java 12 for ECJ 3.20.0). To
maintain backwards compatibility, set source level 1.3 explicitly in
that case. In normal maven usage, <source> is typically set anyway,
either explicitly in the user projects' POMs or via property
maven.compiler.source.

If no JSR-199 interface for ECJ can be found keep using the legacy
mechanism using BatchCompiler.
@olamy olamy merged commit 910ef1f into codehaus-plexus:master Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants