https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
n

napperley

02/22/2020, 2:24 AM
Getting stuck on trying to setup remote publishing to Bintray with a Kotlin Multiplatform project. Every time the publish Gradle task is run Gradle becomes stuck when the message
Configure build..
is outputted.
Contents of build file.
Tried with the bintray Gradle plugin however a empty package is uploaded. Looks like the plugin doesn't have Kotlin Multiplatform support.
l

louiscad

02/22/2020, 12:47 PM
Do not use bintray gradle plugin to publish libraries. Why? Because it does not publish the needed gradle metadata that Kotlin Multiplatform relies on. Instead, ensure you're using Gradle 6+ and use the built-in
maven-publish
plugin, which is also simpler to use, and is up to date with Gradle features since built-in. You can find info about publishing by searching on this page: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html
☝️ 1
n

napperley

02/22/2020, 11:43 PM
Noticed that later on when some people/organisations (including JB) were using some horrendous workarounds (ugly hacks) to get Gradle metadata generated.
How do I upload/publish to Bintray without the extension?
What would this URL (https://bintray.com/kmetrics/kmetrics-core) translate to as the URL to use for uploading a Kotlin MPP library to Bintray?
Keep on getting a 404 from Bintray with the following error:
Copy code
Execution failed for task ':publishKotlinMultiplatformPublicationToMavenRepository'.
> Failed to publish publication 'kotlinMultiplatform' to repository 'maven'
   > Could not PUT '<https://api.bintray.com/maven/kmetrics/kmetrics-core/kmetrics-core/org/kmetrics/kmetrics-core/0.1/kmetrics-core-0.1.pom>'. Received status code 404 from server: Not Found
Below is the publishing block in the build file:
Copy code
publishing {
    repositories {
        maven {
            val subject = "kmetrics"
            val name = if (projectSettings.isDevVer) "${project.name}-dev" else project.name
            val repo = project.name
            url = uri("<https://api.bintray.com/maven/$subject/$repo/$name>")
            credentials {
                username = bintraySettings.user
                password = bintraySettings.key
            }
        }
    }
}
l

louiscad

02/23/2020, 1:47 AM
If you have 404, then the built url is most likely wrong. I'd check again with what's expected there.
n

napperley

02/23/2020, 3:01 AM
Ended up going with GitLab instead of Bintray, which isn't ideal (from a security POV) but it seems to get the job done. Bintray was becoming VERY frustrating to work with to point of insanity.
Updated build file that covers remote publishing to a GitLab Maven repository.
The build file was updated based on the GitLab article for Maven repositories ( https://docs.gitlab.com/ee/user/packages/maven_repository/ ), this GitHub comment ( https://github.com/gradle/kotlin-dsl-samples/issues/1109#issuecomment-421321320 ), and this GitLab comment ( https://gitlab.com/gitlab-com/support-forum/issues/4162#note_122783149 ).
Package list on GitLab.
Linux X64 artifact info on GitLab.
Linux X64 file list on GitLab. Can someone from JetBrains please confirm if the files for the Linux X64 artifact are valid (does the list look correct?).
Can confirm the library (KMetrics Core) was successfully published to GitLab simple smile . Feel free to try out the library. To access the repository add the following block to the repositories block:
Copy code
maven {
        url = uri("<https://gitlab.com/api/v4/projects/16972287/packages/maven>")
    }
After the repository is added insert the following line into the dependencies block (only the linuxX64 target is supported):
Copy code
implementation("org.kmetrics:kmetrics-core:0.1")
The build file should look similar to the following:
Copy code
// ...
repositories {
    mavenCentral()
    jcenter()
    maven {
        url = uri("<https://gitlab.com/api/v4/projects/16972287/packages/maven>")
    }
}

kotlin {
    linuxX64 {
        compilations.getByName("main") {
            dependencies {
                val kmetricsCoreVer = "0.1"
                implementation("org.kmetrics:kmetrics-core:$kmetricsCoreVer")
            }
        }
        // ...
    }
}
17 Views