Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.4
    • Labels:
      None
    • Number of attachments :
      4

      Description

      If I write a pom file like the following:

      ...
        		<plugin>
        			<groupId>org.apache.maven.plugins</groupId>
        			<artifactId>maven-compiler-plugin</artifactId>
        			<version>2.1</version>
        			<configuration>
        			    <compilerId>javac</compilerId>
        				<source>1.6</source>
        				<target>1.6</target>
        				
        				<compilerArguments>
        					<Werror /> 
        					<Xlint:all />
        				</compilerArguments>
        				<showDeprecation>true</showDeprecation>
        			</configuration>
        		</plugin>

      and if there are only warnings, then the build will not fail as intended by the compiler Argument. The reason is that in compileInProcess the exit code from javac is only considered if there are no messages. In the case of treating warnings as errors, there will be messages but no errors so the intention of the build failure is lost.

        Issue Links

          Activity

          Hide
          Kristian Rosenvold added a comment - - edited

          You can add plexus-compiler manually to maven-compiler-plugin

                        <plugin>
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-compiler-plugin</artifactId>
                          <dependencies>
                              <dependency>
                                  <groupId>org.codehaus.plexus</groupId>
                                  <artifactId>plexus-compiler</artifactId>
                                  <version>1.8.2</version>
                              </dependency>
                          </dependencies>
                      </plugin>
          
          Show
          Kristian Rosenvold added a comment - - edited You can add plexus-compiler manually to maven-compiler-plugin <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <dependencies> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-compiler</artifactId> <version>1.8.2</version> </dependency> </dependencies> </plugin>
          Hide
          Steven Schlansker added a comment - - edited

          Thank you, I had to do this actually:

                              <!-- Remove after we move to maven-compiler-plugin 2.4 -->
                              <dependencies>
                                <dependency>
                                  <groupId>org.codehaus.plexus</groupId>
                                  <artifactId>plexus-compiler-api</artifactId>
                                  <version>1.8.2</version>
                                  <exclusions>
                                    <exclusion>
                                      <groupId>org.codehaus.plexus</groupId>
                                      <artifactId>plexus-component-api</artifactId>
                                    </exclusion>
                                  </exclusions>
                                </dependency>
                                <dependency>
                                  <groupId>org.codehaus.plexus</groupId>
                                  <artifactId>plexus-compiler-manager</artifactId>
                                  <version>1.8.2</version>
                                  <exclusions>
                                    <exclusion>
                                      <groupId>org.codehaus.plexus</groupId>
                                      <artifactId>plexus-component-api</artifactId>
                                    </exclusion>
                                  </exclusions>
                                </dependency>
                                <dependency>
                                  <groupId>org.codehaus.plexus</groupId>
                                  <artifactId>plexus-compiler-javac</artifactId>
                                  <version>1.8.2</version>
                                  <scope>runtime</scope>
                                  <exclusions>
                                    <exclusion>
                                      <groupId>org.codehaus.plexus</groupId>
                                      <artifactId>plexus-component-api</artifactId>
                                    </exclusion>
                                  </exclusions>
                                </dependency>
                              </dependencies>
          

          but it does work now!

          Show
          Steven Schlansker added a comment - - edited Thank you, I had to do this actually: <!-- Remove after we move to maven-compiler-plugin 2.4 --> <dependencies> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-compiler-api</artifactId> <version>1.8.2</version> <exclusions> <exclusion> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-component-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-compiler-manager</artifactId> <version>1.8.2</version> <exclusions> <exclusion> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-component-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-compiler-javac</artifactId> <version>1.8.2</version> <scope>runtime</scope> <exclusions> <exclusion> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-component-api</artifactId> </exclusion> </exclusions> </dependency> </dependencies> but it does work now!
          Hide
          Benson Margulies added a comment - - edited

          I'm reopening this because the 'fix' has a pretty major problem: no message is printed explaining why the compilation fails. Adding -e and -X do not lead to the actual message arriving.

          [INFO] Changes detected - recompiling the module!
          [INFO] Compiling 179 source files to /Users/benson/x/gcoref/core/target/classes
          [INFO] ------------------------------------------------------------------------
          [INFO] BUILD FAILURE
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 4.000 s
          [INFO] Finished at: 2015-01-26T13:50:23-05:00
          [INFO] Final Memory: 30M/705M
          [INFO] ------------------------------------------------------------------------
          [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project res-core: Compilation failure -> [Help 1]
          [ERROR]
          [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
          [ERROR] Re-run Maven using the -X switch to enable full debug logging.
          

          Here's the effective pom of note:

                    <execution>
                      <id>default-compile</id>
                      <phase>compile</phase>
                      <goals>
                        <goal>compile</goal>
                      </goals>
                      <configuration>
                        <compilerArgs>
                          <arg>-Werror</arg>
                          <arg>-Xlint:all</arg>
                        </compilerArgs>
                        <showDeprecation>true</showDeprecation>
                        <showWarnings>true</showWarnings>
                        <fork>true</fork>
                        <verbose>true</verbose>
                        <encoding>utf-8</encoding>
                        <source>1.7</source>
                        <target>1.7</target>
                        <maxmem>256M</maxmem>
                        <debug>true</debug>
                        <optimize>true</optimize>
                      </configuration>
                    </execution>
          
          Show
          Benson Margulies added a comment - - edited I'm reopening this because the 'fix' has a pretty major problem: no message is printed explaining why the compilation fails. Adding -e and -X do not lead to the actual message arriving. [INFO] Changes detected - recompiling the module! [INFO] Compiling 179 source files to /Users/benson/x/gcoref/core/target/classes [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.000 s [INFO] Finished at: 2015-01-26T13:50:23-05:00 [INFO] Final Memory: 30M/705M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project res-core: Compilation failure -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. Here's the effective pom of note: <execution> <id> default -compile</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> <configuration> <compilerArgs> <arg>-Werror</arg> <arg>-Xlint:all</arg> </compilerArgs> <showDeprecation> true </showDeprecation> <showWarnings> true </showWarnings> <fork> true </fork> <verbose> true </verbose> <encoding>utf-8</encoding> <source>1.7</source> <target>1.7</target> <maxmem>256M</maxmem> <debug> true </debug> <optimize> true </optimize> </configuration> </execution>
          Hide
          Benson Margulies added a comment - - edited

          The problem here is

           <showDeprecation>true</showDeprecation>
          

          If this is present, the warnings disappear with -Werror.

          Show
          Benson Margulies added a comment - - edited The problem here is <showDeprecation> true </showDeprecation> If this is present, the warnings disappear with -Werror.
          Hide
          Benson Margulies added a comment -

          Here's the story.

          If you are compiling down with -source / -target, and not supplying -Xbootclasspath, you get a warning at the outset. That stops the process with -Werror unless you then also use -Xlint:-options to turn this off. I can't explain the apparent influence of deprecation/warning control.

          Show
          Benson Margulies added a comment - Here's the story. If you are compiling down with -source / -target, and not supplying -Xbootclasspath, you get a warning at the outset. That stops the process with -Werror unless you then also use -Xlint:-options to turn this off. I can't explain the apparent influence of deprecation/warning control.

            People

            • Assignee:
              Kristian Rosenvold
              Reporter:
              Christopher Webster
            • Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: