question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to resolve the new junit-jupiter aggregator dependency via Gradle

See original GitHub issue

I tried updating my project from junit 5.3.2 to 5.4.0 but I have been running into this error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileTestJava'.
> Could not resolve all files for configuration ':testCompileClasspath'.
   > Could not resolve org.junit.jupiter:junit-jupiter:5.4.0.
     Required by:
         project :
      > Could not resolve org.junit.jupiter:junit-jupiter:5.4.0.
         > Could not parse POM https://repo.maven.apache.org/maven2/org/junit/jupiter/junit-jupiter/5.4.0/junit-jupiter-5.4.0.pom
            > Content is not allowed in prolog.
      > Could not resolve org.junit.jupiter:junit-jupiter:5.4.0.
         > Could not parse POM https://jcenter.bintray.com/org/junit/jupiter/junit-jupiter/5.4.0/junit-jupiter-5.4.0.pom
            > Content is not allowed in prolog.

I also downloaded the samples and tried those with same result.

MINGW64 ~/Downloads/junit5-samples-master/junit5-jupiter-starter-gradle
$ ./gradlew clean test
> Task :clean
> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes

> Task :compileTestJava
[Fatal Error] junit-jupiter-5.4.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] junit-jupiter-5.4.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] junit-jupiter-5.4.0.pom:2:1: Content is not allowed in prolog.

> Task :compileTestJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileTestJava'.
> Could not resolve all files for configuration ':testCompileClasspath'.
   > Could not resolve org.junit.jupiter:junit-jupiter:5.4.0.
     Required by:
         project :
      > Could not resolve org.junit.jupiter:junit-jupiter:5.4.0.
         > Could not parse POM https://repo.maven.apache.org/maven2/org/junit/jupiter/junit-jupiter/5.4.0/junit-jupiter-5.4.0.pom
            > Content is not allowed in prolog.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
3 actionable tasks: 3 executed

 MINGW64 ~/Downloads/junit5-samples-master/junit5-jupiter-starter-gradle-kotlin
$ ./gradlew clean test
> Task :clean
> Task :compileKotlin
> Task :compileJava NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE

> Task :compileTestKotlin
[Fatal Error] junit-jupiter-5.4.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] junit-jupiter-5.4.0.pom:2:1: Content is not allowed in prolog.
[Fatal Error] junit-jupiter-5.4.0.pom:2:1: Content is not allowed in prolog.

> Task :compileTestKotlin FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileTestKotlin'.
> Could not resolve all files for configuration ':testCompileClasspath'.
   > Could not resolve org.junit.jupiter:junit-jupiter:5.4.0.
     Required by:
         project :
      > Could not resolve org.junit.jupiter:junit-jupiter:5.4.0.
         > Could not parse POM https://repo.maven.apache.org/maven2/org/junit/jupiter/junit-jupiter/5.4.0/junit-jupiter-5.4.0.pom
            > Content is not allowed in prolog.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
3 actionable tasks: 3 executed

The junit5-jupiter-starter-maven sample works as expected.

Since I cannot find anything on google about this error, there must be something on my machine or something that I am doing wrong.

Does anyone have an idea what the problem might be? Can anyone else reproduce this issue with the Gradle samples?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
fanngrimcommented, Mar 17, 2019

Thanks for the replies so far.

@jbduncan what you mentioned about a MCVE were exactly my thoughts as well. That’s why I ran the junit5-samples in the first place since it does not get more minimal than that. 😉 Sorry if that wasn’t too clear in my original comment.

I also didn’t really expect there to be a general problem since I couldn’t find anything on Google even remotely resembling this but since I couldn’t figure it out on my own I thought I would ask you guys for some input.

@marcphilipp Thanks for your tip! Apparently the cached pom was actually corrupted! I deleted it and now I can execute the samples without problems.

I’m kind of embarrassed to not think of this myself but from the Gradle error I figured that the actual download from Maven central had failed and nothing has been cached.

Well, at least I learned not to blindly trust the error messages Gradle gives me 😃 Thanks for nudging me in the right direction guys!

Closing the issue.

1reaction
jbduncancommented, Mar 17, 2019

@fanngrim That being said, from what I’ve read of your opening comment, it does look like you have a strange environment problem. So you could try clearing your Gradle cache first; I find that works sometimes.

I don’t have the time personally to verify that the JUnit 5 Gradle samples work on my machine, sadly. Perhaps someone else could verify them instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does TestEngine with ID 'junit-jupiter' fail to discover tests ...
Any suggestion how to resolve it? Even in Gradle you should follow the default layout for directories src/test/java and src/test/resources etc. ...
Read more >
JUnit 5 Tutorial: Running Unit Tests With Gradle
This blog post describes how we can create a Gradle project that can compile and run unit tests which use JUnit 5.
Read more >
JUnit 5 User Guide
The junit5-samples repository hosts a collection of sample projects based on JUnit Jupiter, JUnit Vintage, and other testing frameworks. You'll ...
Read more >
Testing in Java & JVM projects - Gradle User Manual
dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1' } test ... You can also enable this behavior by using the --fail-fast command line ...
Read more >
Prepare for testing | IntelliJ IDEA Documentation - JetBrains
Open your build.gradle and add a dependency to the necessary testing library. For example, if you want to use JUnit 5, add the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found