Using Kotlin in Bndtools

157 views
Skip to first unread message

Przemysław Wesołek

unread,
Jul 19, 2016, 10:33:34 AM7/19/16
to bndtools-users
Hi,

I know that using Kotlin is Bndtools projects is problematic, mainly due to "ephemeral" form of class files generated by Kotlin plugin [1][2]. I've thought of a workaround: running a dummy program, which forces Kotlin compiler to dump the class files to the filesystem, and forcing Bndtools to rebuild the bundle, now with the dumped Kotlin class files.

This is of course very fragile, but considering little interest in the linked feature request, I assume this is the only way to use Kotlin inside Bndtools bundles.

Any idea what might go wrong, before I sink into — very pleasant in itself, I have to admit — process of writing larger portions of code in Kotlin?

BTW, in the issue text Peter mentions of using Kotlin in Bndtools. Is it in some planning phase, or do you guys have some concrete ideas in mind (e.g. some Kotlin-specific stuff in enRoute?)

Przemek

[1]: https://youtrack.jetbrains.com/issue/KT-10361
[2]: http://stackoverflow.com/questions/36248021/output-folder-of-the-kotlin-compiler-in-eclipse

Peter Kriens

unread,
Jul 20, 2016, 6:10:16 AM7/20/16
to bndtool...@googlegroups.com
Kotlin is my personal interest. I think it alleviate a lot of the problems in Java, is still based on the VM, and seems aligned with Apple’s Dart.

What program could you run that would dump the class files? You can run this from bnd automatically but it should run in Eclipse, Gradle, Maven, etc.

Kind regards,

Peter Kriens

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Neil Bartlett

unread,
Jul 20, 2016, 6:24:08 AM7/20/16
to bndtool...@googlegroups.com
On 20 Jul 2016, at 11:10, Peter Kriens <pkr...@gmail.com> wrote:

Kotlin is my personal interest. I think it alleviate a lot of the problems in Java, is still based on the VM, and seems aligned with Apple’s Dart.

Did you mean Google’s Dart? Or Apple Swift?

Peter Kriens

unread,
Jul 20, 2016, 6:25:13 AM7/20/16
to bndtool...@googlegroups.com
Testing if you were paying attention … Apple Swift of course

Kind regards,

Peter Kriens

Przemysław Wesołek

unread,
Jul 20, 2016, 6:52:58 AM7/20/16
to bndtools-users
I created a dummy Eclipse run configuration: dummy class with an empty main() method. When I run this program (from within Eclipse), it forces the compilation and writing of class files to bin/ folder. Very manual and fragile, I know...

As for my poor understanding of Eclipse plugins API, this might look like a place in the plugin to force compilation:

https://github.com/JetBrains/kotlin-eclipse/blob/master/kotlin-eclipse-core/src/org/jetbrains/kotlin/core/compiler/KotlinCompiler.java#L48

Added a fuller comment to your StackOverflow question. (http://stackoverflow.com/a/38479226/283519)

Yesterday I mentioned our problems on Kotlin's Slack and the issue got two upvotes. Little by little... :)

Przemek

Andreas Neupert

unread,
May 18, 2017, 4:40:13 AM5/18/17
to bndtools-users
Hi there,

any news on this topic?

Is there meanwhile any way to integrate kotlin compilation into Bndtools/Eclipse to get rid of the need to build it manually?

Woden Cafe

unread,
May 18, 2017, 10:31:05 AM5/18/17
to bndtools-users
I think Kotlin does now support Incremental Compilation, which I understood to be the main blocker for this integration.

So now bnd just has to pick up these class files generated by the Kotlin Compiler?

Peter Kriens

unread,
May 18, 2017, 11:01:34 AM5/18/17
to bndtool...@googlegroups.com
Just downloaded it from Marketplace but I cannot find class files in a Kotlin project.

If someone can figure out where they are then we can easily pick them up.

Kind regards,

Peter Kriens

Woden Cafe

unread,
May 18, 2017, 1:50:31 PM5/18/17
to bndtools-users
Hi Peter,

did you see the change suggested by Przemysław Wesołek here?


I wonder if they are just waiting for a PR / contribution of this change to their compiler.

Woden Cafe

unread,
May 22, 2017, 9:34:23 PM5/22/17
to bndtools-users
Hi Peter,

I downloaded Eclipse Kotlin Plugin, the .class files show up in the project's bin folder.

Is this what you need to be able to use them with bndtools?

Thank you,

Woden Cafe


On Thursday, May 18, 2017 at 10:01:34 AM UTC-5, pkriens wrote:

Peter Kriens

unread,
May 23, 2017, 3:28:11 AM5/23/17
to bndtool...@googlegroups.com
You’re sure? All I get are the kt files in ecj, not the class files. I guess they are copied by ecj?

Kind regards,

Peter Kriens

Woden Cafe

unread,
May 23, 2017, 8:28:33 AM5/23/17
to bndtools-users
Hi Peter,

It looks like this .class file only gets generated when I launch the Kotlin application.

Now that I think about it, that is probably why Przemyslaw is suggesting this change here, a preference to force the Kotlin Compiler to compile the entire project (the same thing that happens when you launch the Kotlin application):


if (isBuildingForLaunch() || preferences.alwaysFullyCompile) {
    compileKotlinFiles(javaProject)
    return null
}

I'm assuming this preference would come from the Eclipse Preferences -> Kotlin Compiler page, which currently doesn't have any options on it.

I think I will submit a PR to kotlin-eclipse with this change, and the addition of the option to the Kotlin Compiler preferences page.

Thank you,

Woden Cafe

Przemysław Wesołek

unread,
Jun 5, 2017, 4:31:32 AM6/5/17
to bndtools-users
Yes, you are right.

Sadly, from what I see, JetBrains has a clear policy to buy everyone into their tools, including IDE. So, the Eclipse plugin is effectively an "abandonware" for them. Everyone I speak to around Kotlin community uses IntelliJ IDEA.

As long as the Eclipse community doesn't put their hands into the plugin (it's on Github), I don't think we will see new features on par with those in the IntelliJ.

Przemek

Przemysław Wesołek

unread,
Jun 5, 2017, 4:34:49 AM6/5/17
to bndtools-users
Please come back with a PR link, so we can upvote it.

Thanks,

Przemek


W dniu wtorek, 23 maja 2017 14:28:33 UTC+2 użytkownik Woden Cafe napisał:

Woden Cafe

unread,
Jun 21, 2017, 11:21:54 AM6/21/17
to bndtools-users
I ran into some bizarre issues with building the plugin with maven,

basically after I built it once, every rebuild would produce that exact same jar, even after I would change code etc.

I can have a look again tonight, but I could not get maven to produce a new version of the plugin - it would just build the exact same thing, every time.

Thank you,

Woden Cafe
Reply all
Reply to author
Forward
0 new messages