Coder Social home page Coder Social logo

Any plans to support Kotlin Native? about clikt HOT 13 CLOSED

ajalt avatar ajalt commented on May 14, 2024 19
Any plans to support Kotlin Native?

from clikt.

Comments (13)

ajalt avatar ajalt commented on May 14, 2024 19

I have a working prototype of a multi-platform project with native support for windows and linux targets in the multiplatform branch. There's no OSX target, because I don't have a Mac computer, and cross-compilation for OSX targets is not supported (apparently due to legal reasons, so I don't expect that support to be added.)

There are a few things holding me back from releasing it: There are some dokka bugs causing broken API doc output, and I haven't yet managed to set up publishing. I also haven't reimplemented the file editing functionality for the native targets, although I would be ok with simply documenting its absence, since I don't think it a commonly used feature.

If anyone is interested in trying it out, you should be able to checkout that branch, build the clikt klib from source and include it manually.

from clikt.

ajalt avatar ajalt commented on May 14, 2024 7

That would be great to do at some point. I think most of the work would involve rewriting TermUi and Editor. We also access java class names in a few places, and have some option extensions that are jvm only, and so would need to be moved to a new file.

from clikt.

ajalt avatar ajalt commented on May 14, 2024 7

@dkotrada @dhakehurst @jmfayard @fuzzyweapon

I just released a beta of the next version of Clikt, which has full multiplatform support. This version implements all functionality for JVM, NodeJS, and native Windows, Linux, and MacOS.

For all non-JVM MPP targets, you can use this dependency:

api("com.github.ajalt:clikt-multiplatform:2.5.0-beta1")

It would be very helpful if anyone is able to try it out and let me know if it works for you. You can comment here or DM me on the ASG or kotlinlang slack.

Thank you!

from clikt.

dhakehurst avatar dhakehurst commented on May 14, 2024 2

I checked out the multiplatform branch,
seems to build fine if I add a macosX64 (OSX) target, and simply copy the linux code into it.

you also need a JS target to be multiplatform....even if the functions are filled with TODO()

from clikt.

jmfayard avatar jmfayard commented on May 14, 2024 2

@ajalt is that a good solution for the "I don't have a mac" problem? #93

from clikt.

yousuf-haque avatar yousuf-haque commented on May 14, 2024 1

I updated to gradle 6.1.1( from 5.5.1) and that seemed to do the trick.

Thanks!

from clikt.

dhakehurst avatar dhakehurst commented on May 14, 2024

I would love the mpp version

from clikt.

fuzzyweapon avatar fuzzyweapon commented on May 14, 2024

I can confirm. The way the kotlin multiplatform plugin works for native is to generally expect it to only compile a target if the machine is that target platform. I worked on cross-platform Gradle build work for a multi-platform product in my job and while we hadn't gotten to Native support, I was recon-ing it (so this knowledge comes out of my recon from a few months ago, though things are moving fast).

Since mac is a POSIX system, all you need to do is make sure that the code for linux is POSIX compatible and it should work nearly everywhere.

If you have the need to actually release mac target packages (in general), you just need a contributor who owns a mac to trigger your publishing pipeline for that target. Pretty easy once it is all setup.

from clikt.

jmfayard avatar jmfayard commented on May 14, 2024

@ajalt
Paul Merlin from Gradle has a ready to use Gradle Action
https://github.com/marketplace/actions/gradle-command

Maybe that's all what you need to build on a system that you don't have

from clikt.

yousuf-haque avatar yousuf-haque commented on May 14, 2024

@ajalt I tried the kmpp dependency for clikt.

I was able to sync gradle with that dependencies and build the binary but the library doesn't seem to be on the IDE's classpath and I don't get autocompletion when editing a .kt file with the Clikt library. Additionally, if I type out the import statements and the Clikt classes manually and try to compile, I still get a compilation error - I don't think the issue is with the ide's classpath specifically.

Any ideas?
What would be easiest is if you could point me to a kotlin native sample app that consumes this library.

Thanks!
This is my gradle file:

plugins {
    id 'org.jetbrains.kotlin.multiplatform' version '1.3.61'
}
repositories {
    mavenCentral()
}
kotlin {
    // For ARM, should be changed to iosArm32 or iosArm64
    // For Linux, should be changed to e.g. linuxX64
    // For MacOS, should be changed to e.g. macosX64
    // For Windows, should be changed to e.g. mingwX64
    macosX64("macos") {
        binaries {
            executable {
                // Change to specify fully qualified name of your application's entry point:
               entryPoint = 'sample.main'
                // Specify command-line arguments, if necessary:
                runTask?.args('-o', 'foobar')
            }
        }
        compilations["main"].enableEndorsedLibs = true

    }
    sourceSets {
        // Note: To enable common source sets please comment out 'kotlin.import.noCommonSourceSets' property
        // in gradle.properties file and re-import your project in IDE.
        macosMain {
            dependencies {
                implementation("com.github.ajalt:clikt-multiplatform:2.5.0-beta1")
            }
        }
        macosTest {
            dependencies {
                implementation("com.github.ajalt:clikt-multiplatform:2.5.0-beta1")
            }
        }
    }

}


// Use the following Gradle tasks to run your application:
// :runReleaseExecutableMacos - without debug symbols
// :runDebugExecutableMacos - with debug symbols

from clikt.

ajalt avatar ajalt commented on May 14, 2024

@yousuf-haque thank you for trying out the beta!

Your gradle configuration looks fine; I'm able to get completion and builds working with that configuration on both Gradle 5.4 and 6.1.

Here's an example project with a similar configuration to yours, which works in both IntelliJ and gradle:
clikt-native-sample.zip

from clikt.

audkar avatar audkar commented on May 14, 2024

I am also using clikt native (linux). It work perfectly! Only difference I can see, is that I am using api instead of implementation while declaring dependency

from clikt.

ajalt avatar ajalt commented on May 14, 2024

Clikt 2.5.0 has been released. Thank you to everyone who provided feedback!

from clikt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.