title: Gradle 5 JUnit BOM and Spring Boot Incorrect Versions
body: <p>I am using Gradle 5's BOM (Bill of Materials) <a href="https://docs.gradle.org/5.0/userguide/managing_transitive_dependencies.html#sec:bom_import" rel="noreferrer">feature</a>. This is how I describe it for my JUnit 5 dependencies:</p>
  
  <pre><code>testImplementation(enforcedPlatform("org.junit:junit-bom:5.4.0")) // JUnit 5 BOM
  testImplementation("org.junit.jupiter:junit-jupiter-api")
  testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
  testImplementation("org.junit.jupiter:junit-jupiter-params")
  </code></pre>
  
  <p>My assumption is that providing the BOM will resolve the versions of the dependencies to <code>5.4.0</code>. However, they get resolved to <code>5.1.1</code>. I am not sure why. (I also request <code>enforcedPlatform()</code> to lock the specified version)</p>
  
  <p><a href="https://i.stack.imgur.com/TWIlW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TWIlW.png" alt="enter image description here"></a></p>
  
  <p>Inspecting <a href="http://central.maven.org/maven2/org/junit/junit-bom/5.4.0/junit-bom-5.4.0.pom" rel="noreferrer">JUnit 5's BOM</a> we see that all <code>org.junit.jupiter</code> dependencies are listed with version <code>5.4.0</code> (resolving to 5.1.1 in the project) and all <code>org.junit.platform</code> dependencies are listed with version <code>1.4.0</code> which resolve correctly in the project.</p>
  
  <p>I am not sure what I am missing and was hoping to get some help here. Thanks!</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>I used Sormuras response and moved all BOMs at the top of the <code>dependencies {}</code> block but was still not getting version <code>5.4.0</code>. Then I suspected it might be coming from the <a href="https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/#managing-dependencies" rel="noreferrer">Gradle Spring Dependency Management</a> plugin that I use, so when I commented it out, I got version JUnit 5.4.0. How do I disable JUnit coming from the Gradle Spring Dependency Management plugin?</p>
  
  <p><a href="https://i.stack.imgur.com/lHWMT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lHWMT.png" alt="Gradle Spring Dependency Management plugin"></a></p>
  
  <p><strong>FINALLY:</strong></p>
  
  <p>I decided to use the <a href="https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies" rel="noreferrer">Spring Boot Dependencies BOM</a> directly and remove the Gradle plugin:</p>
  
  <p><code>implementation(platform("org.springframework.boot:spring-boot-dependencies:2.0.5.RELEASE"))</code></p>
  
  <p>I imagine the plugin was created for those version of Gradle before Gradle 5 where you couldn't use a BOM file. Now with the BOM support I can directly include it. This way my version of JUnit is as I have specified it in the <code>enforcedPlatform()</code> block.</p>
  
  <p>I accepted Sam Brannen's answer below because he explains well how the issue occurs and what solves it and I think it's relevant for those who use older versions of Gradle.</p>