How to use my custom Kotlin(Javascript) library in Idea


#1

Hi, I have created a Kotlin/Javascript library: https://github.com/jean79/yested It packages into a jar containing Kotlin source and META-INF/services/org.jetbrains.kotlin.js.librarySource file with list of classes.

Then I import this library into Idea (13,14) into another Kotlin JS project:
Project Structure - Libraries - Add New Project Library - Java - Select Jar - add as Classes and Sources.

Content assist works fine, I see no compilation issue when writing Kotlin code.
Also if I setup a maven project with this dependency then the compilation works fine.

But when I do build in Idea: Build - Make Project, compiler cannot find classes from my library: Unresolved reference: …

Do I need to import library differently?

Many Thanks,
Jan


#2

Hi, Jan!

Try to use plugin/compiler version 0.9.1306 or higher or wait M10(ETA today).

Since 0.9.1306 You no more needs META-INF/services/org.jetbrains.kotlin.js.librarySource, but You should declare next fields in META-INF/MANIFEST.MF:
Specification-Title: Kotlin JavaScript Lib
Kotlin-JS-Module-Name: <your-modeule-name>


#3

Hi, I have added lines to manifest:

Manifest-Version: 1.0
Built-By: kovarja3
Build-Jdk: 1.7.0_03
Created-By: Apache Maven 3.1.1
Archiver-Version: Plexus Archiver
Specification-Title: Kotlin JavaScript Lib
Kotlin-JS-Module-Name: Yested

Idea editor still works fine, but compilation keeps crashing:
Error:(4, 8) Kotlin: Unresolved reference: net
(net is a package in my library).

I use kotlin: 0.9.223

I think I am doing something wrong when adding library to my second project. There is no error in Idea log files.
I Project view I see:
External Libraries:
1.7 (JDK)
Yested-1.0-snapshot

Many thanks,
Jan


#4

You need plugin/compiler version 0.9.1306 or higher.


#5

Sorry, didn't spotted that it is 4 digit minor number. How can I update compiler in Idea? I have the latest plugin (0.9.233) installed. Many thanks, Jan


#6

Please see https://github.com/JetBrains/kotlin/blob/master/ReadMe.md#using-a-pre-built-kotlin-intellij-idea-plugin


#7

You can try the following slightly modified version of pom.xml for your library: http://pastebin.com/RSL0pPG1

It creates valid Kotlin Javascript library, which should work in idea (kotlin version is set to 0.10.4).

Hope this helps,
Michael


#8

Thanks, I have used the shared pom file. Just had to include an ant script that copies Kotlin source and generated JS file from target/classes and it works. https://github.com/jean79/yested/blob/master/pom.xml J.