Skip to content

About

An Apache Maven example reactor project with multiple modules

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

IntelliJ IDEA Maven Multi-Module Build Error Reproduction

This repository is created to reproduce a specific build error encountered in IntelliJ IDEA when working with a multi-module Maven project.

Problem Description

When configuring -Xlint options from a parent Maven project in a multi-module setup, Maven itself builds the project correctly and honors the suppression of certain warnings as configured.

However, IntelliJ IDEA does not behave as expected in this scenario:

  • IntelliJ provoke build errors on all warnings, including those that are explicitly suppressed via the -Xlint options.
  • IntelliJ fails to suppress warnings like -deprecation and -processing which are configured to be ignored.
  • This discrepancy causes confusion and false-positive error reporting inside the IDE, although Maven builds succeed.

Example Configuration

The problematic configuration is typically defined in the parent pom.xml like this:

<properties>
    <!-- treat warnings as errors as default -->
    <fail.on.warnings.args>-Werror</fail.on.warnings.args>
    <!-- deprecations and annotation processing are suppressed -->
    <xlint.args>-Xlint:all,-deprecation,-processing</xlint.args>

    <!-- specify the encoding once per entire project -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
</properties>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <showWarnings>true</showWarnings>
        <compilerArgs>
            <args>${fail.on.warnings.args}</args>
            <args>${xlint.args}</args>
        </compilerArgs>
    </configuration>
</plugin>

Compile error

This class used a deprecated feature. This warning provokes build error in IDEA.

public class Module1 implements Supplier<String> {

	protected static final String MODULE_NAME = "module1";

	@Override
	public String get() {
		return MODULE_NAME;
	}

	/**
	 * Build in intellij IDEA will fail on this warning.
	 * However, this is a warning that should be suppressed given the options set in the ReactorCore module.
	 */
	public void triggerCompileError() {
		new Date(0, Calendar.NOVEMBER, 10);
	}
}

About

An Apache Maven example reactor project with multiple modules

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages