IntelliJ does not suggest import statements from Kotlin dependency not residing in the same project


#1

Hi.

Since we moved some of our Kotlin framework code out of the application project, then Intellij was suddenly unable to “see” and suggest imports to dependencies in the framework code (now residing in a separate project).

This problem is a huge time consumer as we have to add the imports manually.

Note: However if I copy the class name from some other Kotlin-file where it has been used and try to paste it into another, then it will add the import.

Our project(s) are built using Maven 3 and compilation target is Javascript.

I would be very happy if anyone knew something about this, that could help us.

BTW: Just upgraded to Kotlin 1.0.3 (IntelliJ Kotlin plugin also), but it did not help on the problem.

Jørund


#2

How exactly is the dependency between the two modules configured?


#3

Hi and thanks for following up!

The module depending on the “external” framework does it like this:

...
    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-js-library</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>com.mycompany</groupId>
            <artifactId>myframework-kotlin</artifactId>
            <version>${myframework.version}</version>
        </dependency>
        ...
    </dependencies>

    <build>
        <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>kotlin-maven-plugin</artifactId>
                <groupId>org.jetbrains.kotlin</groupId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>js</goal>
                        </goals>
                        <configuration>
                            <outputFile>${project.build.outputDirectory}/${project.artifactId}.js</outputFile>
                            <metaInfo>true</metaInfo>
                            <sourceMap>true</sourceMap>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            ...
        </plugins>
    </build>