Using Kotlin in extensions.

Stuart Beesley (Mr Toolbox)'s Avatar

Stuart Beesley (Mr Toolbox)

27 Sep, 2024 02:43 PM

FYI. It’s possible to use Kotlin within moneydance extensions (mxt files). The code can be all Java, all Kotlin, or mixed Java/Kotlin.

The Kotlin target must be Java/JVM bytecode.

The moneydance_open repo on GitHub has been recently updated; so if you fork that and look at the ant build.xml file you will see how it’s enabled.

Essentially for ant:
- you must first have the Kotlin compiler installed (either manually, or by having IntelliJ installed)

  • to the build file you add:
    <typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="pathto/kotlin-ant.jar"/>
    

Then, within the <javac> task, you add:

<withKotlin/>

Don’t forget to update your includes statement to include the *.kt files too!

Your project must also have the Kotlin dependency. As soon as you add a Kotlin file, then IntelliJ should add this for you anyway.

The simple approach is probably to use the Kotlin tools to convert one class from Java to Kotlin and see how that works.

Refer: https://www.jetbrains.com/help/idea/get-started-with-kotlin.html

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

10 Oct, 2024 11:07 PM
10 Oct, 2024 11:06 PM
10 Oct, 2024 08:50 PM
10 Oct, 2024 08:41 PM
10 Oct, 2024 07:32 PM