When I create a new IntelliJ 2018.1 project from the Maven archetype maven-archetype-quickstart
version 1.3 using Oracle 10.0.1 on macOS Sierra, I get this error when doing a Maven install
.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test (default-test) on project h2e2: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test failed.: NullPointerException -> [Help 1]
I am running this directly after creating the new project. I am writing no code. I can run the default line:
public static void main( String[] args ) { System.out.println( "Hello World!" ); }
…by choosing Run 'App.main()'
from the context menu clicked in the code editor. That works, but the Maven install
fails.
Executing clean
and install
in the Maven pane of IntelliJ does not solve the problem.
If I switch IntelliJ File
> Project Structure
> Project
> Project SDK
> from 10.0.1 to 1.8.0_171 (and set Project language level
to 8 - Lambdas, type annotations etc.
), then the Maven install
succeeds.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
If I return that setting to Java 10, the Maven install
fails again, with same error.
I am running external Maven 3.5.3 rather than IntelliJ’s bundled older version, for no particular reason.
My older existing projects based on Java 8 have no problem. My only problem is trying to create new Maven-based quickstart
projects using Java 10.
maven-surefire-plugin
It seems the archetype is not yet updated for Java 10.
According to this blog post: http://joshlong.com/jl/blogPost/java-10.html, you can do the following to get it up and running...
.... I want to use Java 10, though, so I opened the pom.xml file and changed the java.version property value to be 10. The Maven surefire plugin broke the build next; it was complaining about not being able to parse the version of the JDK. I overrode the version by redefining the property for the plugin's version: 2.21.0.
The important part here is I think updating to the higher version of surefire, as mentioned in the comments. As of 2018-10, the current version is 2.22.1
.
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With