You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Karl Heinz Marbaise (Jira)" <ji...@apache.org> on 2020/03/07 13:04:00 UTC
[jira] [Commented] (MCOMPILER-408) CompileMojo resets project
artifacts when used in verify phase
[ https://issues.apache.org/jira/browse/MCOMPILER-408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17054039#comment-17054039 ]
Karl Heinz Marbaise commented on MCOMPILER-408:
-----------------------------------------------
[~bmarwell] Can you give more details why it does not work (cause the [documentation of errorprone|https://errorprone.info/docs/installation] look like I expect that it should work)...and I don't see the real reason why your configuration is binding the compile plugin to the verify phase ? It would be very helpful to have full example project....
> CompileMojo resets project artifacts when used in verify phase
> --------------------------------------------------------------
>
> Key: MCOMPILER-408
> URL: https://issues.apache.org/jira/browse/MCOMPILER-408
> Project: Maven Compiler Plugin
> Issue Type: Bug
> Affects Versions: 3.8.0, 3.8.1
> Environment: - Maven 3.6.2
> - Maven compiler plugin <any>
> - errorprone <any>
> Reporter: Benjamin Marwell
> Priority: Major
>
> h2. Problem Description / Setup
> I tried to execute the google error-prone plugin in the compile phase, but was unsatisfied with the outcome. However, it seemed to be a perfect fit for the {{verify}} phase. Other plugins will also use the verify phase, e.g. checkstyle. I will also compile it to a different folder (which is {{target/classes-errorprone}}).
> However, when using the CompileMojo, it will always call [projectArtifact.setFile(dir);|[https://github.com/apache/maven-compiler-plugin/blob/master/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java#L189]]. There is no possibility to override this.
> I do think this is not always the wanted behaviour.
> Now, when executing
> {code:java}
> mvn clean verify -Perrorprone {code}
> the {{ear}} project will not find the {{war}} anymore, because the war had:
> * Compile phase creating target/classes
> * package phase, which set projectArtifact.setFile() to the {{.war}} file.
> * verify phase, which set projectArtifact.setFile() back to {{target/classes}}.
> h2. Reproducible
> Always, see above.
> h2. Workarounds
> Do not execute verify+errorprone together with your main target phase and all reactor projects (e.g. including ear). But this will need two compile steps (one for packaging, anothero ne for error-prone).
> h2. Expected behaviour
> I can execute the maven-compiler-plugin with a compiler plugin like checkstyle in the verify phase without un-attaching any previous artifacts. At least as long as I compile into another directory.
> h2. Actual behaviour
> I cannot execute the compiler in the verify phase again using the {{maven-compiler-plugin}}, because it will reset my project artifacts.
>
> h2. errorprone configuration
> {code:java}
> <profile>
> <id>errorprone</id>
> <activation>
> <activeByDefault>false</activeByDefault>
> </activation>
> <build>
> <plugins>
> <plugin>
> <artifactId>maven-compiler-plugin</artifactId>
> <executions>
> <execution>
> <id>errorprone</id>
> <phase>verify</phase>
> <goals><goal>compile</goal></goals>
> <configuration>
> <showWarnings>true</showWarnings>
> <compilerArgs>
> <arg>-XDcompilePolicy=simple</arg>
> <arg>
> -Xplugin:ErrorProne
> ${plugin.errorprone.excluded.paths}
> -XepDisableWarningsInGeneratedCode
> ${plugin.errorprone.additional.checks}
> </arg>
> <arg>-d</arg>
> <arg>${project.build.directory}/classes-ep</arg>
> </compilerArgs>
> <annotationProcessorPaths>
> <path>
> <groupId>com.google.errorprone</groupId>
> <artifactId>error_prone_core</artifactId>
> <version>${dependency.errorprone.core.version}</version>
> </path>
> </annotationProcessorPaths>
> <useIncrementalCompilation>true</useIncrementalCompilation>
> </configuration>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
> </profile> {code}
> Note: I use incrementalCompilation=true which behaves like non-incremental compilation due to a bug which is open since ever.
> h2. Proposed sulutions
> Either create a new goal (compile-only) or provide a switch to not invoke [projectArtifact.setFile(outputdir)|[https://github.com/apache/maven-compiler-plugin/blob/master/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java#L189]].
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)