I'm getting the following error messages when I try to run a simple project with maven, java modules and junit 5:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project echo: Compilation failure: Compilation failure:
[ERROR] /C:/Users/andre/eclipse-workspace/echo/src/main/java/module-info.java:[2,35] module not found: org.junit.jupiter.engine
[ERROR] /C:/Users/andre/eclipse-workspace/echo/src/main/java/module-info.java:[3,35] module not found: org.junit.jupiter.api
[ERROR] -> [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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
This is my directory structure:
echo
----src/main/java
--------com.udp.echo
------------App.java
------------EchoClient.java
------------EchoServer.java
--------module-info.java
----src/test/java/com.udp.echo
--------EchoTest.java
----pom.xml
this is my module-info.java file:
open module echo {
requires junit;
}
I actually tried to do require org.junit.jupiter.api
and require org.junit.jupiter.engine
but this won't change the outcome.
this is my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.udp</groupId>
<artifactId>echo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>echo</name>
<url>http://maven.apache.org</url>
<properties>
<java.version>12</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</build>
</project>
this is the result of running mvn -v
:
$ mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T16:00:29-03:00)
Maven home: C:\apache-maven-3.6.1
Java version: 12.0.1, vendor: Oracle Corporation, runtime: C:\java\jdk-12.0.1
Default locale: pt_BR, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Wasn't maven supposed to download it's dependencies from the maven repository? If so, why is it complaining about a module not being found? This just makes no sense to me.
What am I missing?