Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to build and publish Kotlin Multiplatform Libraries #3853

Open
arkivanov opened this issue May 26, 2019 · 105 comments
Open

Add ability to build and publish Kotlin Multiplatform Libraries #3853

arkivanov opened this issue May 26, 2019 · 105 comments

Comments

@arkivanov
Copy link

Is your feature request related to a problem? Please describe.
We are playing with Kotlin Multiplatform projects at the moment and publishing our artifacts via JitPack. But JitPack builds only on Linux so we can't build some Native targets (e.g. iOS), as it requires macos host. Taking into account that Github Package Registry is coming, I think it would be nice to add macos host to JitPack.

Describe the solution you'd like
Add ability to publish Kotlin Multiplatform libraries with Native targets

Describe alternatives you've considered
Manual publishing to JCenter, signed up for Github Package Registry beta

Additional context
Travis can be configured to build on multiple hosts, perhaps same technique could be used

@jitpack-io
Copy link
Member

Hi,

That's an interesting suggestion, thank you!
Would it be enough to build your whole project on macos or do you require some parts built on Linux?

@arkivanov
Copy link
Author

At the moment we are targeting JVM, iOS and Linux so Macos would work for us as it can build all our targets. But other people might be interested in Windows and it requires Windows host.
So first iteration might be to just allow selection between Linux and Macos (we would just select Macos).
Second iteration might be to allow partial selection.

@mtrewartha
Copy link

I'll second this. We're investing heavily in Kotlin multi-platform libraries that are published for use on Android and the JVM, but we'll be publishing them for iOS soon, too.

@jitpack-io
Copy link
Member

Hi,

We've added preliminary support for Kotlin MPP libraries. In particular we now handle Gradle metadata (.module) in our Linux builds.

@yslvlln
Copy link

yslvlln commented May 18, 2020

Hi @jitpack-io,

Do you have a sample build.gradle for this Kotlin MPP support? I couldn't find any in your existing repositories.

Thanks!

@arkivanov
Copy link
Author

@yslvlln Here are some KMP projects:
https://github.com/badoo/Reaktive - this one uses regular Groovy Gradle scripts
https://github.com/arkivanov/MVIKotlin - this one uses Kotlin Gradle scripts

Hope this helps

@yslvlln
Copy link

yslvlln commented May 18, 2020

Will look into this. Thanks a lot @arkivanov!

@jillesvangurp
Copy link

@yslvlln Recently KMP evolved a bit so might be worth another look. Setting this up got a lot easier. Basically the multiplatform plugin has out of the box support for publish. There have been a few changes to the meta data part and how gradle handles this. E.g. It is able to figure out for a js project to depend on the -js variant.

I have a simple project that I'm trying to publish via jitpack currently. Currently it half works in the sense that I can publish but not depend on the dependencies.

The project is: https://github.com/jillesvangurp/geogeometry & https://jitpack.io/#jillesvangurp/geogeometry

Release 3.1.4 for this was a kotlin multi platform build. See logs + build file in this gist: https://gist.github.com/jillesvangurp/8b1d8bcfa930a0f1a419a11f33462c74

This initially looks like it works. But when I try to depend on the -jvm jar in a different project, I get a 401 from jitpack:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileKotlin'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve com.github.jillesvangurp:geogeometry-jvm:v3.1.4.
     Required by:
         project :
      > Could not resolve com.github.jillesvangurp:geogeometry-jvm:v3.1.4.
         > Could not get resource 'https://jitpack.io/com/github/jillesvangurp/geogeometry-jvm/v3.1.4/geogeometry-jvm-v3.1.4.pom'.
            > Could not GET 'https://jitpack.io/com/github/jillesvangurp/geogeometry-jvm/v3.1.4/geogeometry-jvm-v3.1.4.pom'. Received status code 401 from server: Unauthorized

I've also tried depending both:

    implementation("com.github.jillesvangurp:geogeometry-jvm:v3.1.4")

or

    implementation("com.github.jillesvangurp:geogeometry:v3.1.4")

For a different project I use a google storage bucket as a poor man's gradle repository and there it works as it should. So, I know my build file is OK. To me it looks like either files are missing/not uploaded or access to those files is somehow not allowed. Since it seems to be close to working; it might be worth getting this over the finishing line.

KMP is about to be more important now that Kotlin 1.4 is out so fixing this would be really nice. I have several libraries that are probably going to be multi-platform soon.

@jillesvangurp
Copy link

Note, for the project above I have now switched to rsyncing a local file repository to my website. This seems to work fine. So the issue is definitely with how jitpack handles the generated artifacts as the exact same artifacts when uploaded unmodified to a website seem to work fine.

@Zhuinden
Copy link

Hello, is there any news on this? It would be super nice to be able to use Jitpack with KMM projects reliably, especially now that they've officially reached alpha (and hopefully won't make significant changes over time).

@petersamokhin
Copy link

Hey @jitpack-io, any updates 1.5 years after the creation of this issue? 🙂

@ligi
Copy link

ligi commented Jan 14, 2021

Would really love to see this @jitpack-io

@arkivanov
Copy link
Author

Since Jcenter and Bintray are shutting down, it would be really cool to have Jitpack working with Kotlin Multiplatform!

@ArcticLampyrid
Copy link

@arkivanov
It's almost available for Kotlin Multiplatform.
For a multi-module project, the artifacts are published under com.github.USER.REPO:MODULE:VERSION now.
And version id is provided through project property.

Let's take https://github.com/ArcticLampyrid/KtJsonRpcPeer as an example
You can find the following in log

Running: ./gradlew clean -Pgroup=com.github.ArcticLampyrid -Pversion=master-9459df002c-1 build publishToMavenLocal

We can see that group is wrong (it's in a format for single-module project, but KPP is always a multi module project) but version is correct.
Then let's overwrite group in build script but keep version as it is.

group = "com.github.ArcticLampyrid.KtJsonRpcPeer"
if (version.toString() == "unspecified") {
    version = "0.7.0" // set if version is not provided (impossible for JitPack)
}

Finally kotlin should generate the correct metadata.

@DetachHead
Copy link

the issue seems to be that for some reason the publishToLocalMaven task doesn't output the multiplatform files:

image

but the publish task does:

image

my solution was to just make the publish task output to local maven:

configure<PublishingExtension> {
    publications {
        // ...
    }
    repositories {
        maven("file://${System.getenv("HOME")}/.m2/repository")
    }
}

but that doesn't help because jitpack runs publishToLocalMaven, not publish. so let's fix that in the jitpack.yml:

install:
  - ./gradlew publish

jitpack should now publish all of the necessary files. if anyone is curious here's the projct where i got it (mostly) working

@arkivanov
Copy link
Author

publishToLocalMaven usually works just fine, used it quite a lot with the maven-publish plugin.

@ArcticLampyrid
Copy link

@DetachHead publishToLocalMaven works fine for me with Kotlin multiplatform libraries

@DetachHead
Copy link

care to share your config? been tearing my hair out at this for the last few days.

here's mine, it's full of dirty hacks because none of it worked out of the box for me.no idea what i'm doing wrong

@Shabinder
Copy link

lcurl missing error when building KMP with linuxX64 target
#4523

@alexwhb
Copy link

alexwhb commented Sep 20, 2021

Any progress on this? I'd absolutely love to be able to publish KMM libraries on Github without the headache of a typical maven publish.

Also for anyone who stumbles across this... I found this great way to self host maven repos. I was super discouraged by the difficulty of hosting on maven central and others... so I came across this, and it's by far the easiest solution I've seen for hosting KMM libraries. Also, you can run it very easily from Docker on something like Digital Ocean. Took me about 5 minutes to configure.

@alexvanyo
Copy link

As of Kotlin 1.6.0, Windows targets can be compiled on any host: https://kotlinlang.org/docs/whatsnew16.html#compilation-of-windows-targets-on-any-host

In particular, that means that if JitPack could be configured to run builds on a macOS host, then that single host should be able to compile all necessary native targets for multiplatform projects with Kotlin 1.6.0 and beyond.

@theapache64
Copy link

@jitpack-io Any updates? 😇 🤞

@kierans
Copy link

kierans commented Apr 13, 2022

I'm a little bit surprised this hasn't gotten more attention.

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Apr 26, 2024
@Skaldebane
Copy link

Skaldebane commented Apr 26, 2024

not stale ;)

it's my turn!

@Kashif-E
Copy link

not stale

@github-actions github-actions bot removed the stale label Apr 27, 2024
@muhammadzkralla
Copy link

Does jitpack now support publishing KMP libraries, or is the issue still open?

@GuilhE
Copy link

GuilhE commented May 17, 2024

Does jitpack now support publishing KMP libraries, or is the issue still open?

Not yet, but I hope to live to see that day

@hellomr3
Copy link

not stale

@tamimattafi
Copy link

Is there a way to link GitHub actions to jitpack.io? Actions seem to be able to build all KMP targets since they can use a macOS environment, therefore, you don't need to explicitly support them on your servers.

@kaidotarma
Copy link

kaidotarma commented Jun 4, 2024

Still waiting for a way to use Jitpack to build for iOS native targets (like iosArm64, iosSimulatorArm64, iosX64), which requires a macOS build environment.
This would be beneficial for not only our own libraries, but also for forked libraries where we want to do some changes.
Hope to see some progress soon. :)

@aeckar
Copy link

aeckar commented Jun 9, 2024

Not stale!

@yosephws
Copy link

yosephws commented Jul 5, 2024

can we expedite this changes? really need it for kmp atm.

@arkivanov
Copy link
Author

My hunch is that the bottleneck here is hardware changes, not software.

@Zhuinden
Copy link

Zhuinden commented Jul 7, 2024

The bottleneck is that nobody is looking at this Github issue repository, and the fact the jitpack repositories exist at all is a miracle.

@yosephws
Copy link

yosephws commented Jul 8, 2024

i see, in that case nothing we can do but invest on alternatives, i like jitpack tho, sadly have to let it go for now.

@nort3x
Copy link

nort3x commented Jul 11, 2024

speaking of hosts,
i'm struggling with Kotlin/JS build here

/lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27' not found (required by /home/jitpack/.gradle/nodejs/node-v18.0.0-linux-x64/bin/node)

it seems like node requires a version of libc which is not present in the host
can't i change os and it's version of the builder?

@amarcolini
Copy link

@nort3x I had this issue myself and commented my solution earlier (I don't blame you for not seeing it). Try changing your node version using this.

@nort3x
Copy link

nort3x commented Jul 13, 2024

thank you @amarcolini ,
github new UI collapsed around 100 comments in the middle of the issue and it was there,
I've also tried to fix node version but kotlin multiplatform 2.0.0 when using js target requires some libraries that require node version of at least 18.x.x and i can confirm jitpack can't handle that nodejs - and kotlin 2.0.0 is an important migration that can't be avoided in favor of jitpack!

plugins {
    kotlin("multiplatform") version "2.0.0"
}

rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
    val node = rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>()
    node.version = "16.0.0"
    node.download = true
}
Task :kotlinNpmInstall FAILED
error karma-webpack@5.0.1: The engine "node" is incompatible with this module. Expected version ">= 18". Got "16.0.0"
error Found incompatible module.

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Aug 13, 2024
@arkivanov
Copy link
Author

Not stale.

@github-actions github-actions bot removed the stale label Aug 14, 2024
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Sep 13, 2024
@arkivanov
Copy link
Author

Never been stale.

@github-actions github-actions bot removed the stale label Sep 14, 2024
@furkanakcakaya
Copy link

not stale

@Zhuinden
Copy link

I have a feeling at this point, nobody even knows where and who makes Jitpack run.

I have doubts they even have an actual maintainer.

@crysxd
Copy link

crysxd commented Oct 23, 2024

Sad to see this still being unresolved in 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests