javakotlinmavenintellij-ideascalatest

How to force IntelliJ to use pom.xml settings


I'm using IntelliJ IDEA 2023.2 with Apache Maven 3.9.4. Working on a Java project with some Scala and Kotlin in it. The project is old. Hence the Kotlin version is 1.3.

When running mvn -f integration-test/pom.xml test-compile scalatest:test in the terminal everything works fine. But when I try to run the test within IntelliJ like: Run scala test

It will show up an error complaining that Kotlin 1.2 is no more supported.

Kotlin: API version 1.2 is no longer supported; please, use version 1.3 or greater.

I get that, I would like to upgrade Kotlin but it is out of my scope. It's far down in the backlog. But I need a solution in the meantime.

The Kotlin dependency I use:

        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-osgi-bundle</artifactId>
            <version>1.3</version>
            <exclusions>
                <exclusion>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
            <version>1.3</version>
        </dependency>

What I try to achieve in the end? I want to be able to run a single test so I can debug the code and figure out whats wrong with the test.

Concludes to: How can I force IntelliJ to just run the mvn project settings


Solution

  • In addition to what @Sam said, you might also want to check this page in the documentation, in particular:

    By default, IntelliJ IDEA uses the native IntelliJ IDEA builder to build a Maven project

    So I think it's just the built-in compiler that complains about the old version of Kotlin. I think you have 2 options to overcome this issue:

    1. Let IntelliJ delegate the build to Maven (as described in the link above)
    2. Configure the built-in Kotlin compiler to use an older version of the language. This can be done by changing the settings as described here (under Settings -> Build, Execution, Deployment -> Compiler -> Kotlin Compiler). Depending on the version of IntelliJ + the Kotlin plugin, you might or might not be able to solve the issue this way.