Maven 2.x Compiler Plugin

Compiler swallows messages from annotation processors

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 2.0.2, 2.1
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    1

Description

When using the annotation processor API to print messages through the javax.annotation.processing.Messager object, only messagesspecified by levels javax.tools.Diagnostic.Kind.ERROR and javax.tools.Diagnostic.Kind.MANDATORY_WARNING are displayed (and cause the build to fail). All other messages are swallowed.

Note that while the attached JUnit test case is necessary to help expose the problem, passing it will not imply that the bug is fixed. The only way to confirm the fix (that I know of) is to examine console output.

Issue Links

Activity

Hide
Jesse Glick added a comment -

Possible cause in JavacCompiler.java:

else if ( buffer.length() == 0 && line.startsWith( "Note: " ) )

{ // skip this one - it is JDK 1.5 telling us that the interface is deprecated. }
Show
Jesse Glick added a comment - Possible cause in JavacCompiler.java: else if ( buffer.length() == 0 && line.startsWith( "Note: " ) ) { // skip this one - it is JDK 1.5 telling us that the interface is deprecated. }
Hide
Milos Kleint added a comment -

If the compiler plugin is configured to show warnings, all messages appear. The build still fails.

@JesseGlick: The JavaCCompiler.java's message parsing fails and a generic message including all output is printed. The code you mention is still weird and would probably swallow the output for some more complicated (read real-life) outputs.

Show
Milos Kleint added a comment - If the compiler plugin is configured to show warnings, all messages appear. The build still fails. @JesseGlick: The JavaCCompiler.java's message parsing fails and a generic message including all output is printed. The code you mention is still weird and would probably swallow the output for some more complicated (read real-life) outputs.
Hide
Jesse Glick added a comment -

Why should you need to configure the plugin to show warnings? If javac issues messages they ought to be displayed as is unless otherwise requested.

Show
Jesse Glick added a comment - Why should you need to configure the plugin to show warnings? If javac issues messages they ought to be displayed as is unless otherwise requested.
Hide
David Boden added a comment -

Adding <showWarnings>true</showWarnings> to my compiler plugin <configuration/> results in:

  • The Kind.NOTE print statements being output as [ERROR]
  • Without the showWarnings, the statements don't get printed.
  • The build fails (it succeeds when showWarnings=false), probably because the NOTE messages have been artificially raised to ERROR level and Maven is interpreting this as a build failure?

I'm using:
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>

I'm building this project:
http://immutablebean.googlecode.com/svn/ImmutableBeanExample
Hopefully you'll be able to check out this project, build it and change the <showWarnings/> to recreate this error at will.

Here's the output I get with showWarnings=true:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] \Users\Dave\workspace\ImmutableBeanExample\src\main\java\org\immutablebean\beantemplates\BeanInterfaceTemplate.java:[14,21] Note: Identified bean property: identifier

[ERROR] \Users\Dave\workspace\ImmutableBeanExample\src\main\java\org\immutablebean\beantemplates\BeanInterfaceTemplate.java:[15,18] Note: Identified bean property: version

[ERROR] \Users\Dave\workspace\ImmutableBeanExample\src\main\java\org\immutablebean\beantemplates\BeanInterfaceTemplate.java:[16,6] Note: Identified bean property: creationDate

[ERROR] \Users\Dave\workspace\ImmutableBeanExample\src\main\java\org\immutablebean\beantemplates\BeanInterfaceTemplate.java:[17,12] Note: Identified bean property: price

[ERROR] \Users\Dave\workspace\ImmutableBeanExample\src\main\java\org\immutablebean\beantemplates\BeanInterfaceTemplate.java:[18,12] Note: Identified bean property: quantity

Show
David Boden added a comment - Adding <showWarnings>true</showWarnings> to my compiler plugin <configuration/> results in:
  • The Kind.NOTE print statements being output as [ERROR]
  • Without the showWarnings, the statements don't get printed.
  • The build fails (it succeeds when showWarnings=false), probably because the NOTE messages have been artificially raised to ERROR level and Maven is interpreting this as a build failure?
I'm using: <artifactId>maven-compiler-plugin</artifactId> <version>2.3.1</version> I'm building this project: http://immutablebean.googlecode.com/svn/ImmutableBeanExample Hopefully you'll be able to check out this project, build it and change the <showWarnings/> to recreate this error at will. Here's the output I get with showWarnings=true: [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] \Users\Dave\workspace\ImmutableBeanExample\src\main\java\org\immutablebean\beantemplates\BeanInterfaceTemplate.java:[14,21] Note: Identified bean property: identifier [ERROR] \Users\Dave\workspace\ImmutableBeanExample\src\main\java\org\immutablebean\beantemplates\BeanInterfaceTemplate.java:[15,18] Note: Identified bean property: version [ERROR] \Users\Dave\workspace\ImmutableBeanExample\src\main\java\org\immutablebean\beantemplates\BeanInterfaceTemplate.java:[16,6] Note: Identified bean property: creationDate [ERROR] \Users\Dave\workspace\ImmutableBeanExample\src\main\java\org\immutablebean\beantemplates\BeanInterfaceTemplate.java:[17,12] Note: Identified bean property: price [ERROR] \Users\Dave\workspace\ImmutableBeanExample\src\main\java\org\immutablebean\beantemplates\BeanInterfaceTemplate.java:[18,12] Note: Identified bean property: quantity

People

Vote (19)
Watch (17)

Dates

  • Created:
    Updated: