Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to upload a kotlin multiplatform project li...

AAkira
March 27, 2019

How to upload a kotlin multiplatform project library.

I talked about how to upload a kotlin multiplatform library at どこでもKotlin #7 〜Kotlin MPP特集〜.

https://m3-engineer.connpass.com/event/123055/

AAkira

March 27, 2019
Tweet

More Decks by AAkira

Other Decks in Technology

Transcript

  1. Agenda • Kotlin/Nativeチュートリアル Android, iOS編
 http://aakira.app/blog/2018/10/kotlin-native • Kotlin Multiplatform構想 ~今やる理由編~


    https://aakira.app/blog/2018/12/kotlin-mpp-reason • Kotlin Multiplatform構想 ~設計編~
 https://aakira.app/blog/2018/12/kotlin-mpp-architecture • Kotlin Multiplatform環境でKotlin Serializationと
 Android ExtensionsのParcelize Annotationを使う
 http://aakira.app/blog/2018/12/kotlin-mpp-android-parcelable • NapierというKotlin Multiplatform用のログライブラリを作った
 https://aakira.app/blog/2019/02/napier
  2. Agenda • Kotlin/Nativeチュートリアル Android, iOS編
 http://aakira.app/blog/2018/10/kotlin-native • Kotlin Multiplatform構想 ~今やる理由編~


    https://aakira.app/blog/2018/12/kotlin-mpp-reason • Kotlin Multiplatform構想 ~設計編~
 https://aakira.app/blog/2018/12/kotlin-mpp-architecture • Kotlin Multiplatform環境でKotlin Serializationと
 Android ExtensionsのParcelize Annotationを使う
 http://aakira.app/blog/2018/12/kotlin-mpp-android-parcelable • NapierというKotlin Multiplatform用のログライブラリを作った
 https://aakira.app/blog/2019/02/napier
  3. パッケージ構成 (~Kotlin1.3) . ├── android │ ├── src │ └──

    build.gradle (apply plugin: 'kotlin-platform-android') ├── common │ ├── src │ │ └── main │ └── build.gradle (apply plugin: 'kotlin-platform-common') ├── ios │ ├── src │ │ └── main │ └── build.gradle (apply plugin: 'org.jetbrains.kotlin.platform.native') └─── js ├── src │ └── main └── build.gradle (apply plugin: 'kotlin-platform-js')
  4. パッケージ構成 (~Kotlin1.3) 各ディレクトリ毎にbuild.gradleがある . ├── android │ ├── src │

    └── build.gradle (apply plugin: 'kotlin-platform-android') ├── common │ ├── src │ │ └── main │ └── build.gradle (apply plugin: 'kotlin-platform-common') ├── ios │ ├── src │ │ └── main │ └── build.gradle (apply plugin: 'org.jetbrains.kotlin.platform.native') └─── js ├── src │ └── main └── build.gradle (apply plugin: 'kotlin-platform-js')
  5. パッケージ構成 (Kotlin1.3~) . └── library ├── build.gradle (apply plugin: 'kotlin-multiplatform')

    └── src ├── androidMain ├── androidTest ├── commonMain ├── commonTest ├── iosMain ├── iosTest ├── jsMain ├── jsTest ├── jvmMain └── jvmTest
  6. パッケージ構成 (Kotlin1.3~) . └── library ├── build.gradle (apply plugin: 'kotlin-multiplatform')

    └── src ├── androidMain ├── androidTest ├── commonMain ├── commonTest ├── iosMain ├── iosTest ├── jsMain ├── jsTest ├── jvmMain └── jvmTest build.gradleは1つのみ
  7. パッケージ構成 (Kotlin1.3~) . └── library ├── build.gradle (apply plugin: 'kotlin-multiplatform')

    └── src ├── androidMain ├── androidTest ├── commonMain ├── commonTest ├── iosMain ├── iosTest ├── jsMain ├── jsTest ├── jvmMain └── jvmTest build.gradleは1つのみが正しい
  8. Gradle設定 • Common • Android • iOS • JVM •

    JS 今回配布するライブラリ . ├── library │ ├── android.gradle │ ├── build.gradle │ └── src │ ├── androidMain │ ├── androidTest │ ├── commonMain │ ├── commonTest │ ├── iosMain │ ├── iosTest │ ├── jsMain │ ├── jsTest │ ├── jvmMain │ └── jvmTest └─── build.gradle
  9. Gradle設定 • Common • Android • iOS • JVM •

    JS 今回配布するライブラリ . ├── library │ ├── android.gradle │ ├── build.gradle │ └── src │ ├── androidMain │ ├── androidTest │ ├── commonMain │ ├── commonTest │ ├── iosMain │ ├── iosTest │ ├── jsMain │ ├── jsTest │ ├── jvmMain │ └── jvmTest └─── build.gradle androidは
 「apply plugin: 'com.android.library'」を読み込む &
 android用のSDK version等の記述をする
 必要があるので分ける
  10. Gradle設定 apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle')

    kotlin { android() iosX64('ios') iosArm32('iosArm32') iosArm64('iosArm64') js() jvm() sourceSets { commonMain.dependencies { } commonTest.dependencies { } androidMain.dependencies { } androidTest.dependencies { } iosMain.dependencies { } iosTest.dependencies { } iosArm32Main.dependsOn iosMain iosArm32Test.dependsOn iosTest iosArm64Main.dependsOn iosMain iosArm64Test.dependsOn iosTest jsMain.dependencies { } jsTest.dependencies { } jvmMain.dependencies { } jvmTest.dependencies { } } } library/build.gradle
  11. apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle') kotlin

    { android() iosX64('ios') iosArm32('iosArm32') iosArm64('iosArm64') js() jvm() sourceSets { commonMain.dependencies { } commonTest.dependencies { } Gradle設定 library/build.gradle
  12. apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle') kotlin

    { android() iosX64('ios') iosArm32('iosArm32') iosArm64('iosArm64') js() jvm() sourceSets { commonMain.dependencies { } commonTest.dependencies { } Gradle設定 library/build.gradle
  13. apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle') kotlin

    { android() iosX64('ios') iosArm32('iosArm32') iosArm64('iosArm64') js() jvm() sourceSets { commonMain.dependencies { } commonTest.dependencies { } Gradle設定 android用のgradleは別で定義
 (略) 詳しくはサンプルを見てください library/build.gradle
  14. apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle') kotlin

    { android() iosX64('ios') iosArm32('iosArm32') iosArm64('iosArm64') js() jvm() sourceSets { commonMain.dependencies { } commonTest.dependencies { } Gradle設定 publish用のgradleは別定義(後述) library/build.gradle
  15. apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle') kotlin

    { android() iosX64('ios') iosArm32('iosArm32') iosArm64('iosArm64') js() jvm() sourceSets { commonMain.dependencies { } commonTest.dependencies { } Gradle設定 library/build.gradle
  16. apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle') kotlin

    { android() iosX64('ios') iosArm32('iosArm32') iosArm64('iosArm64') js() jvm() sourceSets { commonMain.dependencies { } commonTest.dependencies { } Gradle設定 Kotlin1.3から書き方が変わった library/build.gradle
  17. apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle') kotlin

    { targets { fromPreset(presets.android, 'android') fromPreset(presets.iosArm64, 'ios') fromPreset(presets.js, 'js') fromPreset(presets.jvm, 'jvm') } sourceSets { commonMain.dependencies { } commonTest.dependencies { } androidMain.dependencies { } Gradle設定 ~Kotlin1.3 library/build.gradle
  18. apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle') kotlin

    { android() iosX64('ios') iosArm32('iosArm32') iosArm64('iosArm64') js() jvm() sourceSets { commonMain.dependencies { } commonTest.dependencies { } Gradle設定 library/build.gradle
  19. iosArm64('iosArm64') js() jvm() sourceSets { commonMain.dependencies { } commonTest.dependencies {

    } androidMain.dependencies { } androidTest.dependencies { } iosMain.dependencies { } iosTest.dependencies { } iosArm32Main.dependsOn iosMain iosArm32Test.dependsOn iosTest iosArm64Main.dependsOn iosMain iosArm64Test.dependsOn iosTest jsMain.dependencies { } jsTest.dependencies { } jvmMain.dependencies { } jvmTest.dependencies { } } } Gradle設定 それぞれの依存を定義 library/build.gradle
  20. apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle') kotlin

    { android() iosX64('ios') iosArm32('iosArm32') iosArm64('iosArm64') js() jvm() sourceSets { commonMain.dependencies { } commonTest.dependencies { } Gradle設定 library/build.gradle
  21. apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle') kotlin

    { android() iosX64('ios') iosArm32('iosArm32') iosArm64('iosArm64') js() jvm() sourceSets { commonMain.dependencies { } commonTest.dependencies { } Gradle設定 library/build.gradle
  22. apply plugin: 'kotlin-multiplatform' apply from: 'android.gradle' apply from: rootProject.file('gradle/publish.gradle') kotlin

    { android { publishLibraryVariants("release") } iosX64('ios') iosArm32('iosArm32') iosArm64('iosArm64') js() jvm() sourceSets { Gradle設定 library/build.gradle android libraryは
 release buildを指定する必要がある
  23. apply plugin: 'maven-publish' def pomConfig = { licenses { license

    { name POM_LICENSE_NAME url POM_LICENSE_URL distribution POM_LICENSE_DIST } } developers { developer { id POM_DEVELOPER_ID name POM_DEVELOPER_NAME organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL } } afterEvaluate { project.publishing.publications.all { pom.withXml { def root = asNode() root.appendNode('name', project.name) root.appendNode('description', POM_DESCRIPTION) root.appendNode('url', SITE_URL) root.children().last() + pomConfig } groupId = BINTRAY_PACKAGE if (it.name.contains('metadata')) { artifactId = "${project.name}" } else { artifactId = "${project.name}-$name" } } } Gradle設定 - Maven Publish - gradle/publish.gradle
  24. apply plugin: 'maven-publish' def pomConfig = { licenses { license

    { name POM_LICENSE_NAME url POM_LICENSE_URL distribution POM_LICENSE_DIST } } developers { developer { id POM_DEVELOPER_ID name POM_DEVELOPER_NAME organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL } } Gradle設定 - Maven Publish - gradle/publish.gradle
  25. apply plugin: 'maven-publish' def pomConfig = { licenses { license

    { name POM_LICENSE_NAME url POM_LICENSE_URL distribution POM_LICENSE_DIST } } developers { developer { id POM_DEVELOPER_ID name POM_DEVELOPER_NAME organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL } } Gradle設定 - Maven Publish - gradle/publish.gradle maven publish pluginをapply
  26. apply plugin: 'maven-publish' def pomConfig = { licenses { license

    { name POM_LICENSE_NAME url POM_LICENSE_URL distribution POM_LICENSE_DIST } } developers { developer { id POM_DEVELOPER_ID name POM_DEVELOPER_NAME organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL } } Gradle設定 - Maven Publish - gradle/publish.gradle pomに書き込む用の変数を定義
  27. apply plugin: 'maven-publish' def pomConfig = { licenses { license

    { name "The Apache Software License, Version 2.0" url "http://www.apache.org/licenses/LICENSE-2.0.txt" distribution "repo" } } developers { developer { id "aakira" name "aakira" organization "aakira" organizationUrl "https://github.com/aakira" } } scm { url "https://github.com/aakira/Napier" } } Gradle設定 - Maven Publish - gradle/publish.gradle 実際の中身
  28. apply plugin: 'maven-publish' def pomConfig = { licenses { license

    { name POM_LICENSE_NAME url POM_LICENSE_URL distribution POM_LICENSE_DIST } } developers { developer { id POM_DEVELOPER_ID name POM_DEVELOPER_NAME organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL } } Gradle設定 - Maven Publish - gradle/publish.gradle
  29. organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL

    } } afterEvaluate { project.publishing.publications.all { pom.withXml { def root = asNode() root.appendNode('name', project.name) root.appendNode('description', POM_DESCRIPTION) root.appendNode('url', SITE_URL) root.children().last() + pomConfig } groupId = BINTRAY_PACKAGE if (it.name.contains('metadata')) { artifactId = "${project.name}" } else { artifactId = "${project.name}-$name" } } } Gradle設定 - Maven Publish - gradle/publish.gradle publishで作られる成果物に全てに対して
  30. organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL

    } } afterEvaluate { project.publishing.publications.all { pom.withXml { def root = asNode() root.appendNode('name', project.name) root.appendNode('description', POM_DESCRIPTION) root.appendNode('url', SITE_URL) root.children().last() + pomConfig } groupId = BINTRAY_PACKAGE if (it.name.contains('metadata')) { artifactId = "${project.name}" } else { artifactId = "${project.name}-$name" } } } Gradle設定 - Maven Publish - gradle/publish.gradle xmlを作成
  31. organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL

    } } afterEvaluate { project.publishing.publications.all { pom.withXml { def root = asNode() root.appendNode('name', project.name) root.appendNode('description', POM_DESCRIPTION) root.appendNode('url', SITE_URL) root.children().last() + pomConfig } groupId = BINTRAY_PACKAGE if (it.name.contains('metadata')) { artifactId = "${project.name}" } else { artifactId = "${project.name}-$name" } } } Gradle設定 - Maven Publish - gradle/publish.gradle 先程指定した変数を追加
  32. organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL

    } } afterEvaluate { project.publishing.publications.all { pom.withXml { def root = asNode() root.appendNode('name', project.name) root.appendNode('description', POM_DESCRIPTION) root.appendNode('url', SITE_URL) root.children().last() + pomConfig } groupId = BINTRAY_PACKAGE if (it.name.contains('metadata')) { artifactId = "${project.name}" } else { artifactId = "${project.name}-$name" } } } Gradle設定 - Maven Publish - gradle/publish.gradle
  33. organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL

    } } afterEvaluate { project.publishing.publications.all { pom.withXml { def root = asNode() root.appendNode('name', project.name) root.appendNode('description', POM_DESCRIPTION) root.appendNode('url', SITE_URL) root.children().last() + pomConfig } groupId = BINTRAY_PACKAGE if (it.name.contains('metadata')) { artifactId = "${project.name}" } else { artifactId = "${project.name}-$name" } } } Gradle設定 - Maven Publish - gradle/publish.gradle metadataをrename
  34. organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL

    } } afterEvaluate { project.publishing.publications.all { pom.withXml { def root = asNode() root.appendNode('name', project.name) root.appendNode('description', POM_DESCRIPTION) root.appendNode('url', SITE_URL) root.children().last() + pomConfig } groupId = BINTRAY_PACKAGE if (it.name.contains('metadata')) { artifactId = "${project.name}" } else { artifactId = "${project.name}-$name" } } } Gradle設定 - Maven Publish - gradle/publish.gradle metadata=commonMainの部分のこと
  35. organization POM_ORGANIZATION_NAME organizationUrl POM_ORGANIZATION_URL } } scm { url SITE_URL

    } } afterEvaluate { project.publishing.publications.all { pom.withXml { def root = asNode() root.appendNode('name', project.name) root.appendNode('description', POM_DESCRIPTION) root.appendNode('url', SITE_URL) root.children().last() + pomConfig } groupId = BINTRAY_PACKAGE if (it.name.contains('metadata')) { artifactId = "${project.name}" } else { artifactId = "${project.name}-$name" } } } Gradle設定 - Maven Publish - gradle/publish.gradle commonMainはsuffixなし
 他はsuffixに環境名をつける e.g. napier-android, napier-js
  36. Gradle設定 - Maven Publish - pom-default.xml <licenses> <license> <name>The Apache

    Software License, Version 2.0</name> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> <distribution>repo</distribution> </license> </licenses> <developers> <developer> <id>aakira</id> <name>aakira</name> <organization>aakira</organization> <organizationUrl>https://github.com/aakira</organizationUrl> </developer> </developers> <scm> <url>https://github.com/aakira/Napier</url> </scm>
  37. Gradle設定 - Maven Publish - • publish • publishAndroidReleasePublicationToMavenLocal •

    publishIosArm32PublicationToMavenLocal • publishIosArm64PublicationToMavenLocal • publishIosPublicationToMavenLocal • publishJsPublicationToMavenLocal • publishJvmPublicationToMavenLocal • publishKotlinMultiplatformPublicationToMavenLocal • publishMetadataPublicationToMavenLocal • publishToMavenLocal targetの数だけmaven publishに関するtaskが作られる
  38. Gradle設定 - Maven Publish - $ ./gradlew publishToMavenLocal build └──

    publications ├── androidRelease │ ├── module.json │ └── pom-default.xml ├── ios │ ├── module.json │ └── pom-default.xml ├── iosArm32 │ ├── module.json │ └── pom-default.xml ├── iosArm64 │ ├── module.json │ └── pom-default.xml ├── js │ ├── module.json │ └── pom-default.xml ├── jvm │ ├── module.json │ └── pom-default.xml ├── kotlinMultiplatform │ ├── module.json │ └── pom-default.xml └── metadata ├── module.json └── pom-default.xml
  39. build └── publications ├── androidRelease │ ├── module.json │ └──

    pom-default.xml ├── ios │ ├── module.json │ └── pom-default.xml ├── iosArm32 │ ├── module.json │ └── pom-default.xml ├── iosArm64 │ ├── module.json │ └── pom-default.xml ├── js Gradle設定 - Maven Publish - oMavenLocal
  40. ├── iosArm32 │ ├── module.json │ └── pom-default.xml ├── iosArm64

    │ ├── module.json │ └── pom-default.xml ├── js │ ├── module.json │ └── pom-default.xml ├── jvm │ ├── module.json │ └── pom-default.xml ├── kotlinMultiplatform │ ├── module.json │ └── pom-default.xml └── metadata ├── module.json └── pom-default.xml Gradle設定 - Maven Publish - oMavenLocal
  41. Gradle設定 - Gradle Publish - /build.gradle buildscript { repositories {

    ... } dependencies { ... classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4" ... } } https://github.com/bintray/gradle-bintray-plugin
  42. apply plugin: 'com.jfrog.bintray' def getBintrayUserProperty() { return hasProperty('bintrayUser') ? project.property('bintrayUser')

    : System.getenv('BINTRAY_USER') } def getBintrayApiKeyProperty() { return hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') } bintray { user = getBintrayUserProperty() key = getBintrayApiKeyProperty() publish = false pkg { repo = BINTRAY_REPOSITORY name = BINTRAY_NAME userOrg = GROUP licenses = ['Apache-2.0'] vcsUrl = VCS_URL websiteUrl = SITE_URL issueTrackerUrl = ISSUE_URL version { name = rootProject.ext.LIBRARY_VERSION_NAME vcsTag = rootProject.ext.LIBRARY_VERSION_NAME released = new Date() } } } bintrayUpload.doFirst { publications = publishing.publications.collect { it.name }.findAll { it != "kotlinMultiplatform" } } bintrayUpload.dependsOn publishToMavenLocal Gradle設定 - Gradle Publish - gradle/publish.gradle
  43. apply plugin: 'com.jfrog.bintray' def getBintrayUserProperty() { return hasProperty('bintrayUser') ? project.property('bintrayUser')

    : System.getenv('BINTRAY_USER') } def getBintrayApiKeyProperty() { return hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') } bintray { user = getBintrayUserProperty() key = getBintrayApiKeyProperty() publish = false pkg { repo = BINTRAY_REPOSITORY name = BINTRAY_NAME userOrg = GROUP licenses = ['Apache-2.0'] vcsUrl = VCS_URL websiteUrl = SITE_URL issueTrackerUrl = ISSUE_URL Gradle設定 - Gradle Publish - gradle/publish.gradle
  44. apply plugin: 'com.jfrog.bintray' def getBintrayUserProperty() { return hasProperty('bintrayUser') ? project.property('bintrayUser')

    : System.getenv('BINTRAY_USER') } def getBintrayApiKeyProperty() { return hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') } bintray { user = getBintrayUserProperty() key = getBintrayApiKeyProperty() publish = false pkg { repo = BINTRAY_REPOSITORY name = BINTRAY_NAME userOrg = GROUP licenses = ['Apache-2.0'] vcsUrl = VCS_URL websiteUrl = SITE_URL issueTrackerUrl = ISSUE_URL Gradle設定 - Gradle Publish - gradle/publish.gradle bintrayのpluginをapply
  45. apply plugin: 'com.jfrog.bintray' def getBintrayUserProperty() { return hasProperty('bintrayUser') ? project.property('bintrayUser')

    : System.getenv('BINTRAY_USER') } def getBintrayApiKeyProperty() { return hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') } bintray { user = getBintrayUserProperty() key = getBintrayApiKeyProperty() publish = false pkg { repo = BINTRAY_REPOSITORY name = BINTRAY_NAME userOrg = GROUP licenses = ['Apache-2.0'] vcsUrl = VCS_URL websiteUrl = SITE_URL issueTrackerUrl = ISSUE_URL Gradle設定 - Gradle Publish - gradle/publish.gradle bintrayのuser名, API Keyを読み込む gitに追加されないlocalの
 ~/.gradle/gradle.properties に書いておくと良い
  46. def getBintrayApiKeyProperty() { return hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') }

    bintray { user = getBintrayUserProperty() key = getBintrayApiKeyProperty() publish = false pkg { repo = BINTRAY_REPOSITORY name = BINTRAY_NAME userOrg = GROUP licenses = ['Apache-2.0'] vcsUrl = VCS_URL websiteUrl = SITE_URL issueTrackerUrl = ISSUE_URL version { name = rootProject.ext.LIBRARY_VERSION_NAME vcsTag = rootProject.ext.LIBRARY_VERSION_NAME released = new Date() } } } Gradle設定 - Gradle Publish - gradle/publish.gradle
  47. def getBintrayApiKeyProperty() { return hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') }

    bintray { user = getBintrayUserProperty() key = getBintrayApiKeyProperty() publish = false pkg { repo = BINTRAY_REPOSITORY name = BINTRAY_NAME userOrg = GROUP licenses = ['Apache-2.0'] vcsUrl = VCS_URL websiteUrl = SITE_URL issueTrackerUrl = ISSUE_URL version { name = rootProject.ext.LIBRARY_VERSION_NAME vcsTag = rootProject.ext.LIBRARY_VERSION_NAME released = new Date() } } } Gradle設定 - Gradle Publish - gradle/publish.gradle keyをセット
  48. def getBintrayApiKeyProperty() { return hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') }

    bintray { user = getBintrayUserProperty() key = getBintrayApiKeyProperty() publish = false pkg { repo = BINTRAY_REPOSITORY name = BINTRAY_NAME userOrg = GROUP licenses = ['Apache-2.0'] vcsUrl = VCS_URL websiteUrl = SITE_URL issueTrackerUrl = ISSUE_URL version { name = rootProject.ext.LIBRARY_VERSION_NAME vcsTag = rootProject.ext.LIBRARY_VERSION_NAME released = new Date() } } } Gradle設定 - Gradle Publish - gradle/publish.gradle upload後すぐに公開しない
  49. def getBintrayApiKeyProperty() { return hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') }

    bintray { user = getBintrayUserProperty() key = getBintrayApiKeyProperty() publish = false pkg { repo = BINTRAY_REPOSITORY name = BINTRAY_NAME userOrg = GROUP licenses = ['Apache-2.0'] vcsUrl = VCS_URL websiteUrl = SITE_URL issueTrackerUrl = ISSUE_URL version { name = rootProject.ext.LIBRARY_VERSION_NAME vcsTag = rootProject.ext.LIBRARY_VERSION_NAME released = new Date() } } } Gradle設定 - Gradle Publish - gradle/publish.gradle
  50. def getBintrayApiKeyProperty() { return hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') }

    bintray { user = getBintrayUserProperty() key = getBintrayApiKeyProperty() publish = false pkg { repo = 'maven' name = 'napier' userOrg = 'aakira' licenses = ['Apache-2.0'] vcsUrl = 'https://github.com/aakira/Napier.git' websiteUrl = 'https://github.com/aakira/Napier' issueTrackerUrl = 'https://github.com/aakira/Napier/issues' version { name = '0.0.1' vcsTag = '0.0.1' released = new Date() } } } Gradle設定 - Gradle Publish - gradle/publish.gradle
  51. def getBintrayApiKeyProperty() { return hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') }

    bintray { user = getBintrayUserProperty() key = getBintrayApiKeyProperty() publish = false pkg { repo = BINTRAY_REPOSITORY name = BINTRAY_NAME userOrg = GROUP licenses = ['Apache-2.0'] vcsUrl = VCS_URL websiteUrl = SITE_URL issueTrackerUrl = ISSUE_URL version { name = rootProject.ext.LIBRARY_VERSION_NAME vcsTag = rootProject.ext.LIBRARY_VERSION_NAME released = new Date() } } } Gradle設定 - Gradle Publish - gradle/publish.gradle
  52. version { name = rootProject.ext.LIBRARY_VERSION_NAME vcsTag = rootProject.ext.LIBRARY_VERSION_NAME released =

    new Date() } } } bintrayUpload.doFirst { publications = publishing.publications.collect { it.name }.findAll { it != "kotlinMultiplatform" } } bintrayUpload.dependsOn publishToMavenLocal Gradle設定 - Gradle Publish - gradle/publish.gradle bintrayにuploadするpublicationsを指定
  53. version { name = rootProject.ext.LIBRARY_VERSION_NAME vcsTag = rootProject.ext.LIBRARY_VERSION_NAME released =

    new Date() } } } bintrayUpload.doFirst { publications = publishing.publications.collect { it.name }.findAll { it != "kotlinMultiplatform" } } bintrayUpload.dependsOn publishToMavenLocal Gradle設定 - Gradle Publish - gradle/publish.gradle [project name]-kotlinMultiplatform
 というディレクトリがアップロードされてしまうので除外
  54. version { name = rootProject.ext.LIBRARY_VERSION_NAME vcsTag = rootProject.ext.LIBRARY_VERSION_NAME released =

    new Date() } } } bintrayUpload.doFirst { publications = publishing.publications.collect { it.name }.findAll { it != "kotlinMultiplatform" } } bintrayUpload.dependsOn publishToMavenLocal Gradle設定 - Gradle Publish - gradle/publish.gradle bintrayUpload taskにpublishToMavenLocalを依存させる
  55. BintrayへのUpload /build.gradle buildscript { repositories { ... maven { url

    "http://dl.bintray.com/[bintray repository]/[bintray name]" } ... } }
  56. BintrayへのUpload /build.gradle buildscript { repositories { ... maven { url

    "http://dl.bintray.com/[bintray repository]/[bintray name]" } ... } } ライブラリ毎にmavenのrepositoryを書かないといけない