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

Parse and forward JavaC 'Note:' level messages #312

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gnodet
Copy link
Member

@gnodet gnodet commented Oct 27, 2023

Theses messages can be generated by annotation processors using
printMessage(Diagnostic.Kind.NOTE, "...").

@gnodet gnodet force-pushed the infoLogs2 branch 3 times, most recently from 3f48996 to 1b578f4 Compare October 27, 2023 15:02
@gnodet gnodet marked this pull request as draft October 27, 2023 18:25
@gnodet
Copy link
Member Author

gnodet commented Oct 27, 2023

This PR should also integrate #57
I'll remove the draft status when that's done.

@gnodet gnodet marked this pull request as ready for review October 27, 2023 21:33
mensinda and others added 2 commits October 28, 2023 10:34
Theses messages can be generated by annotation processors using
`printMessage(Diagnostic.Kind.NOTE, "...")`.
If the -log argument is used, the resulting log file is scanned for compiler output, both text and xml formatting supported. Otherwise a temporary log file is used to capture compiler output.

* Unit tests refactored
* Output emitted as "INFO" are reported as Kind.NOTE
* Column count adjusted to be 1-based index
@gnodet
Copy link
Member Author

gnodet commented Oct 28, 2023

Actually, I'm not sure about including the -log eclipse compiler option the way it is.
I think it should be rather implemented as #296 or with a global option in the CompilerConfig to give a path to a directory or file to store the compiler output for later inspection. However, passing the argument directly to the compiler and have plexus-compiler parse the file after the compilation could definitely lead to problems in case the give log is an absolute path and use concurrently. I'd rather have direct compiler output not accessible and the mentioned option to write/move/copy the output after the compilation has been done and the output has been parsed.

@spadou
Copy link

spadou commented Nov 27, 2023

For info, in Java 21, a note was added that span multiple lines (see https://inside.java/2023/07/29/quality-heads-up/). This produce the following output from javac:

Note: Annotation processing is enabled because one or more processors were found
  on the class path. A future release of javac may disable annotation processing
  unless at least one processor is specified by name (-processor), or a search
  path is specified (--processor-path, --processor-module-path), or annotation
  processing is enabled explicitly (-proc:only, -proc:full).
  Use -Xlint:-options to suppress this message.
  Use -proc:none to disable annotation processing.

This should probably be handled in this PR when note level messages are parsed.

Not sure what is the plan to merge this, but it would be really useful to have at least the note parsing, to handle this case when compiling with Java 21. Currently note messages are skipped, but this also only handle single line messages, so only the first line is skipped and the remaining lines are prepended with the next warning which is not a good output.

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.

Output information needed to suppress Xlint warnings
4 participants