jitpack / jitpack.io

Documentation and issues of https://jitpack.io
MIT License
2.52k stars 183 forks source link

Add ability to build and publish Kotlin Multiplatform Libraries #3853

Open arkivanov opened 5 years ago

arkivanov commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

Hi,

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

yslvlln commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

Will look into this. Thanks a lot @arkivanov!

jillesvangurp commented 4 years ago

@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 commented 4 years ago

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 commented 3 years ago

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 commented 3 years ago

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

ligi commented 3 years ago

Would really love to see this @jitpack-io

arkivanov commented 3 years ago

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

ArcticLampyrid commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

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

ArcticLampyrid commented 3 years ago

@DetachHead publishToLocalMaven works fine for me with Kotlin multiplatform libraries

DetachHead commented 3 years ago

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 commented 3 years ago

lcurl missing error when building KMP with linuxX64 target https://github.com/jitpack/jitpack.io/issues/4523

alexwhb commented 3 years ago

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 commented 2 years ago

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 commented 2 years ago

@jitpack-io Any updates? 😇 🤞

kierans commented 2 years ago

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

github-actions[bot] commented 2 years ago

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

ArcticLampyrid commented 2 years ago

Not stale.

github-actions[bot] commented 1 year ago

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

mariuszmarzec commented 1 year ago

dismissing the objection ☝️

stefanhaustein commented 1 year ago

What is blocking this? Is this a resource problem? Would it be feasible to donate to this effort somehow if that helps?

ltttttttttttt commented 1 year ago

Does KMP support now? I've been doing this for a long time, But I never did it well

https://github.com/ltttttttttttt/ComposeViews

Prompt when importing:

:common:desktopMain: Could not resolve com.github.ltttttttttttt.ComposeViews:compose_views-android:1.3.2.7.test_kmp.
Required by:
    project :common > com.github.ltttttttttttt:ComposeViews:1.3.2.7.test_kmp

:common:commonMain: Could not resolve com.github.ltttttttttttt.ComposeViews:compose_views-android:1.3.2.7.test_kmp.
Required by:
    project :common > com.github.ltttttttttttt:ComposeViews:1.3.2.7.test_kmp

Prompt at runtime:

Execution failed for task ':common:compileKotlinDesktop'.
> Error while evaluating property 'filteredArgumentsMap' of task ':common:compileKotlinDesktop'
   > Could not resolve all files for configuration ':common:desktopCompileClasspath'.
      > Could not resolve com.github.ltttttttttttt.ComposeViews:compose_views-android:1.3.2.7.test_kmp.
        Required by:
            project :common > com.github.ltttttttttttt:ComposeViews:1.3.2.7.test_kmp
         > No matching variant of com.github.ltttttttttttt.ComposeViews:compose_views-android:1.3.2.7.test_kmp was found. The consumer was configured to find an API of a library, preferably optimized for standard JVMs, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
             - Variant 'releaseApiElements-published' capability com.github.ltttttttttttt.ComposeViews:compose_views-android:1.3.2.7.test_kmp declares an API of a library:
                 - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
                 - Other compatible attribute:
                     - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
             - Variant 'releaseRuntimeElements-published' capability com.github.ltttttttttttt.ComposeViews:compose_views-android:1.3.2.7.test_kmp declares a runtime of a library:
                 - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
                 - Other compatible attribute:
                     - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
arkivanov commented 1 year ago

@ltttttttttttt On the first glance, it appears that you compile common against jvm target. And common depends on com.github.ltttttttttttt.ComposeViews:compose_views-android, which is only for android. jvm targets can't have android dependencies.

ltttttttttttt commented 1 year ago

@ltttttttttttt On the first glance, it appears that you compile common against jvm target. And common depends on com.github.ltttttttttttt.ComposeViews:compose_views-android, which is only for android. jvm targets can't have android dependencies.

What should I do?

arkivanov commented 1 year ago

@ltttttttttttt you should structure your dependencies property. JVM modules can't use Android libraries.

ltttttttttttt commented 1 year ago

@arkivanov Thanks, I'll try

ltttttttttttt commented 1 year ago

@ltttttttttttt you should structure your dependencies property. JVM modules can't use Android libraries.

Wow, It's finally ok, Thank you

github-actions[bot] commented 1 year ago

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

arkivanov commented 1 year ago

Definitely not stale ☝️

jillesvangurp commented 1 year ago

It worked for a bit last year and now it's broken again.

This one worked: https://jitpack.io/com/github/jillesvangurp/geogeometry/3.2.24/build.log This one broke again: https://jitpack.io/com/github/jillesvangurp/geogeometry/3.2.25/build.log

Same with several other projects. Basically the error is that the relevant urls that gradle expects produce 404s. The build is fine, the artifacts are just not getting copied over or end up in the wrong place somehow. Even though the log claims to have found them.

So, I'm going back to deploying releases to a google bucket straight from gradle. I can't depend on Jitpack like this.

github-actions[bot] commented 1 year ago

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

arkivanov commented 1 year ago

Not stale

github-actions[bot] commented 1 year ago

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

GuilhE commented 1 year ago

Not stale

nathanmeade commented 1 year ago

Does this same issue exist with Maven central or just jitpack?

GuilhE commented 1 year ago

Just jitpack

Kashif-E commented 1 year ago

do it jitpack

dev-lcc commented 1 year ago

any updates?

github-actions[bot] commented 1 year ago

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

nathanmeade commented 1 year ago

Not stale

DenisBronx commented 1 year ago

any progress with this? the issue was opened more than 4 years ago!

nathanmeade commented 1 year ago

At this rate Jitpack is doomed just like jcenter and bintray were lol

github-actions[bot] commented 1 year ago

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