Hello.
I’m trying to setup a maven project to compile some kotlin code to javascript.
I’m using kotlin 0.8.11 (the latest IDEA plugin version available, the latest kotlin version is 0.8.679, but it’s incopatible with the plugin).
kotlin-maven-plugin with ‘js’ goal works well until I’m not trying to use some native code from kotlin-js-library. I’ve added kotlin-js-library as compile dependency but I’m still can’t import something like js.dom.html.window.
IDEA suggests me to import folders from the library but not actual packages declared there (see screenshot below)
The kotlin-maven-plugin also fails to compile from cmd.
A little project to reproduce:
/pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>apomelov.samplewebapp</groupId>
<artifactId>client</artifactId>
<version>1.0-SNAPSHOT</version>
<properties><kotlin.version>0.8.11</kotlin.version></properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-js-library</artifactId>
<version>${kotlin.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>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/src/main/kotlin/Main.kt
import js.dom.html.window
fun main(args: Array<String>) {
window.location.replace(“http://google.com”)
}
When I’m not using maven, but create a kotlin-javascript-project from IDEA’s wizard, everything works well. Code completion suggests me all packages and members.
What am I doing wrong? Why does kotlin-js-library.jar contain source code but not compiled bytecode?
Thanks, Alexey