Unable to resolve the new junit-jupiter aggregator dependency via Gradle
Closed this issue ยท 6 comments
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?
Hi @fanngrim, welcome to JUnit 5. :)
I find that the best way to solve this sort of problem is to create a minimal, correct and verifiable example (or MCVE for short).
In my opinion, the great advantage of creating an MCVE is that 50% of the time you'll realise what's wrong just by creating it, and the other 50% of the time you'll have a concrete example to share with others who can help you.
StackOverflow has some information on how to create an MCVE, which I consider a good starting point: https://stackoverflow.com/help/mcve.
If you're still stuck after working through StackOverflow's advice, or if you still can't understand why things don't work even after creating an MCVE, then please feel free to ask for help again and, if you have an MCVE, to put it in a public GitHub repo and paste a link to it here.
I hope this helps. :)
@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.
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.
About an hour ago, Travis CI verified that the samples are working as expected: https://travis-ci.org/junit-team/junit5-samples/builds/507488290
@fanngrim Could you check the contents of the POM in ~/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter/5.4.0/, please?
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.