Adding Kotlin Support to an Existing Maven project in Intellij (Eclipse ->IntelliJ)


#1

Hi All, We have a java project (Maven /Eclipse) which is straight forward to build either by command line or Eclipse. Now we want add some Kotlin support for the project and to leverage IDE support - for Kotlin  - planning to switch to IntelliJ (We are very new to IntelliJ). We have imported eclipse project into IntelliJ and configured maven (which is straight forward) . Java : 1.7 Intellij : 14.1.5 (trial) Maven : 3.2.5 Kotlin Plugin : 0.14.449.Idea141.12

But, when we open our *.kt files in IntelliJ, this is giving some unresolved references error.

/uploads/kotlinlang/original/1X/22edc809fafb60baf72570371d43030fb479fb8b.png

It seems, the error is due to missing Kotlin in the build path.
Can you please provide the steps to configure this (we will also give a try :))

Thanks

Thanks


#2

You need to add a dependency to the Kotlin standard library to your pom.xml. See here for instructions: https://kotlinlang.org/docs/reference/using-maven.html


#3

Hi,

We have this dependency in place  already, and the current code is perfectly compilable using maven commandline
Kotlin Version - 0.12.412

<plugin>   <artifactId>kotlin-maven-plugin</artifactId>   <groupId>org.jetbrains.kotlin</groupId>   <version>${kotlin.version}</version>

  <executions>
  <execution>
           <id>compile</id>
           <phase>process-sources</phase>
           <goals> <goal>compile</goal> </goals>
  </execution>
<

execution>
           <id>test-compile</id>
           <phase>process-test-sources</phase>
           <goals> <goal>test-compile</goal> </goals>
  </execution>
  </executions>
</plugin>



<dependency>

    <groupId>org.jetbrains.kotlin</groupId>
  <artifactId>kotlin-stdlib</artifactId>
</dependency>


We followed the article mentioned  to set-up/configure the POM.
We got this issue once we imported the project into IntelliJ (basically we are looking for seemless IDE integration).

NB: Now the code is imported into IntelliJ-14.1.5 with Kotiln Plugin - 0.14.449.Idea141.12

Thanks,

Message was edited by: kallada


#4

kotlin-stdlib 0.12.412 isn't compatible with Kotlin Plugin 0.14.449: you should use the same version of Kotlin Plugin in IDE and in Maven.