“maven.compiler.release” as an replacement for source and target?

The “simple suggestion” in the other answer won’t work correctly because unfortunately the situation is not simple. The compiler options mean slightly different things. The maven.compiler.source and maven.compiler.target options refer to the source code format and the format of the generated class files, respectively. But they do not take into account API changes as maven.compiler.release … Read more

Maven compiler recompile all files instead modified

Summary While you can tell Maven “to recompile only modified files”, doing so will lead to wrong results. The default behavior is not a bug, but an intentional design decision. What useIncrementalCompilation really does The documentation on this topic is, to put it mildly, not optimal. Here is what really happens (based on AbstractCompilerMojo source … Read more

javax.annotation classes and Java 11 JDK

When migrating up ahead 3 releases of Java, the first thing one should consider is to update all the major dependencies. maven-compiler-plugin -> current version is 3.8.1, 2.5.1 is 7 years old. Try the following to resolve this error: java.lang.NoSuchMethodError: javax.annotation.Resource.lookup()Ljava/lang/String; Keep the dependency: <dependency> <groupId>javax.annotation</groupId> <artifactId>javax.annotation-api</artifactId> <version>1.3.1</version> </dependency> And explicitly add it as a … Read more

What does “Required filename-based automodules detected.” warning mean?

Automatic module recap An explicit module (i.e. one with a module-info.java) can only access code of modules that it requires (ignoring implied readability for a moment). That’s great if all dependencies are modularized, but what if they are not? How to refer to a JAR that isn’t modular? Automatic modules are the answer: Any JAR … Read more

Intellij maven project Fatal error compiling: invalid flag: –release

In your pom.xml file, simply remove the tag <release>8</release> from your maven-compiler-plugin configuration: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> <configuration> <source>1.8</source> <target>1.8</target> <verbose>true</verbose> </configuration> </plugin>

Maven build Compilation error : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven

The error occurred because the code is not for the default compiler used there. Paste this code in effective POM before the root element ends, after declaring dependencies, to change the compiler used. Adjust version as you need. <dependencies> … </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>