Skip to content
UnknownJoe796 edited this page Sep 6, 2022 · 3 revisions

This is all written for .gradle.kts.

Root Script

In your root buildscript, insert this to start using the plugin:

buildscript { 
    // ...
    val khrysalisVersion: String by extra
    classpath("com.lightningkite.khrysalis:plugin:$khrysalisVersion")
}

This will make the Khrysalis plugin available for usage elsewhere in your project.

Subproject Script

To make a given subproject translate, we'll do the following:

Add the Plugin

plugins {
    // ...
    id("com.lightningkite.khrysalis")
}

Add dependencies

val khrysalisVersion: String by extra
dependencies {
    // ...

    // These add the compiler plugins for Khrysalis - without these, the plugin's tasks will not work.
    kcp("com.lightningkite.khrysalis:kotlin-compiler-plugin-swift:$khrysalisVersion")
    kcp("com.lightningkite.khrysalis:kotlin-compiler-plugin-typescript:$khrysalisVersion")

    // This is a very-light runtime that essentially adds a few minor functions and annotations
    api("com.lightningkite.khrysalis:jvm-runtime:$khrysalisVersion")

    // This loads the base set of 'equivalents' - AKA, information about how to translate specific calls to libraries.
    equivalents("com.lightningkite.khrysalis:jvm-runtime:$khrysalisVersion:equivalents")

    // You can load your own equivalents as well.
    // If you depend on another local Khrysalis subproject, you can do this:
    api(project(":other"))
    equivalents(project(":other", "equivalents"))
}

Configure the Khrysalis destination

khrysalis {
    // If this module is a library, turn this on.  It will generate information to export so other projects can translate too.
    libraryMode = true

    // iOS configuration
    iosProjectName = "IosProjectName"  // The name of the iOS module
    iosProjectFolder = rootDir.resolve("IosProjectName")  // The project's base folder.
    iosSourceFolder = rootDir.resolve("IosProjectName/Classes")  // The location to place the translated files.

    // Web configuration
    webProjectName = "web-project-name"  // The name of the NPM module
    webProjectFolder = rootDir.resolve("web")  // The NPM project's base folder.
    webSourceFolder = rootDir.resolve("web/src")  // The location to place the translated files.
}
Clone this wiki locally