Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindException: Module org.apiguardian.api not found, required by org.junit.platform.launcher #2730

Closed
Marcono1234 opened this issue Sep 27, 2021 · 5 comments

Comments

@Marcono1234
Copy link
Contributor

Description

When using a module-info.java as part of the test sources, Gradle fails executing the tests:

> Task :test FAILED
Error occurred during initialization of boot layer
java.lang.module.FindException: Module org.apiguardian.api not found, required by org.junit.platform.launcher

It appears #2695 tried to solve that issue for 5.8.0, but I am seeing this behavior for 5.8.0 and 5.8.1.
Manually adding testImplementation("org.apiguardian:apiguardian-api:1.1.2") as dependency solves this issue.

Steps to reproduce

  1. Clone https://github.com/Marcono1234/junit5-module-issue-demo
  2. Run ./gradlew build
    ❌ It fails with a FindException

Context

  • Used versions (Jupiter/Vintage/Platform): org.junit.jupiter:junit-jupiter:5.8.1
  • Build Tool/IDE: Gradle 7.2
@sormuras
Copy link
Member

sormuras commented Sep 29, 2021

@Marcono1234
Copy link
Contributor Author

I have only checked https://github.com/junit-team/junit5-samples/tree/main/junit5-jupiter-starter-gradle now but I don't think that makes a difference. The main difference is usage of the module system. When I edit junit5-jupiter-starter-gradle by:

  • Adding src/main/java/module-info.java
     module example {
        exports com.example.project;
    }
  • Adding src/test/java/module-info.java
    open module test {
        requires example;
    
        requires org.junit.jupiter.api;
        requires org.junit.jupiter.params;
    }
  • Changing package name of CalculatorTests (because two modules cannot contain the same package) and adding the import

I get the same exception as above.

@arjenzhou
Copy link

After upgrading from 5.7.2 to 5.8.1, I have the same issue.

@marcphilipp
Copy link
Member

The problem seems to be that Gradle is bundling a pre-5.8 version of junit-platform-launcher. Adding an explicit testRuntimeOnly("org.junit.platform:junit-platform-launcher") dependency to the build script "solves" the issue.

@Marcono1234 Could you please raise an issue with Gradle to get this upgraded?

@Marcono1234
Copy link
Contributor Author

Have created gradle/gradle#18627; hopefully that includes all necessary information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants