The 0.7 changelog includes the item: “Use Gradle n...
# kotlin-native
r
The 0.7 changelog includes the item: “Use Gradle native dependency model, allowing to use .klib as Maven artifacts” Does this mean I can publish a klib to a repository like jitpack or bintray and consume it in another project? If so, how can I configure this via the gradle plugin?
m
AFAIK for now bintray gradle plugin does not support this model, pull request is still open: https://github.com/bintray/gradle-bintray-plugin/pull/230 For local repository here is sample in samples/libcurl and samples/curl
o
Yes, it is possible, but only using patched Bintray plugin build
smth like
Copy code
buildscript {
  repositories {
   mavenCentral()
   maven {
      url "<https://dl.bintray.com/jetbrains/kotlin-native-dependencies>"
   }
   dependencies {
       classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1-SNAPSHOT"
   }
}

publishing {
    repositories {
        maven {
           url = '<https://dl.bintray.com/sample/sample-url-repo>'
        }
    }
}
...

apply plugin: 'com.jfrog.bintray'

bintray {
   user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
   key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
   pkg {
       userOrg = 'sample'
       repo = 'sample-url-repo'
       name = 'repo-name'
       version {
           name = project.version
           vcsTag = project.version
           released  = new Date()
       }
   }
}

bintrayUpload.doFirst {
   publications = project.publishing.publications
}
r
What about consuming it? How do I point a kotlin-native module at a remote repo? The
useRepo
property in the
libraries
block only seems to allow local paths.
s
r
Ok yeah that helps. I didn’t realize you could add a
dependencies
block inside of an artifact in
konanArtifacts
. I think that’s missing from the documentation at https://github.com/JetBrains/kotlin-native/blob/master/GRADLE_PLUGIN.md which only mentions
expectedBy
dependencies
So looking at https://github.com/Kotlin/kotlinx.serialization/blob/json_ast/example-native/build.gradle is the syntax
artifactxxx
where
xxx
is the artifact name? or is
artifactsample
a standard syntax?
m
It's name of the program prefixed by
artifact
Copy code
konanArtifacts {
    program('Curl') {
        dependsOn ':libcurl:publish'
        dependencies {
            artifactCurl 'org.jetbrains.kotlin.native:libcurl:1.0'
        }
    }
}