I have a single-module maven project which uses a number of Kotlin libraries, and I'm trying to specify the kotlin-bom to ensure they all use the same version. I've got the following in my pom.xml
:
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.6.20</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
...
However, when I do mvn compile
, I get this error:
[ERROR] 'dependencies.dependency.version' for org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar is missing.
How can I use kotlin-bom in a single-module project?
CodePudding user response:
Move your bom declaration to dependencyManagment section
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.6.20</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
</dependencies>