LoginSignup
23
21

More than 5 years have passed since last update.

Kotlinのライブラリをbintray-releaseを使ってアップロードするときにハマったこと

Last updated at Posted at 2015-11-14

bintray-releaseとは

bintray-releaseは、bintrayにAndroidなどのライブラリをリリースするのが超カンタンになるライブラリです。リリースに関する設定の部分は5,6行ですぐに記述できます。

GitHubリポジトリ

説明:Super duper easy way to release your Android and other artifacts to bintray.
GitHub

bintray-releaseの使い方

bintray-releaseの使い方は、すごく簡単です。

まずは、プロジェクト直下の build.gradle のdependenciesに新たにパスを追加します。

build.gradle
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.0-beta-2422'
        classpath 'com.novoda:bintray-release:0.3.4' // 新たに追加
    }
}

次に、ライブラリフォルダ内の build.gradle の任意の場所に以下のような文を追加します。

library/build.gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.novoda.bintray-release' // 新たに追加

android {
    // 省略
}

// publicブロックを新たに追加します。ここがbintrayにリリースする際の情報になります
public {
    userOrg = 'novoda'
    groupId = 'com.novoda'
    artifactId = 'bintray-release'
    publishVersion = '0.3.4'
    desc = 'Oh hi, this is a nice description for a project, right?'
    website = 'https://github.com/novoda/bintray-release'
}

他に設定できるパラメーター

最後に、gradleコマンドを書きます。

bintrayのユーザー名とAPIキーの取得の仕方については、割愛します。
こちらについては、bintrayに登録し、APIキーを書きます。

$ ./gradlew clean build bintrayUpload -PbintrayUser=BINTRAY_USERNAME -PbintrayKey=BINTRAY_KEY -PdryRun=false

ハマったこと

kotlinのフォルダにおいて、javadoc生成タスクで失敗する

回避策

gradleの中からjavadocの生成タスクを消します。
gradleからの特定のタスクの消しかたは、StachOverflowの記事を参考にしました。StackOverflow

tasksに関する処理は、そのライブラリ内のbuild.gradle内に新たにafterEvaluateタグを追加して、その中に記述します。
もし、プロジェクト直下に記述したい場合はtasksの前にproject(":{モデュール名}").task~~と追加します。

library/build.gradle
afterEvaluate {
    tasks.findByPath(":{タスク名}").enabled = false
}

これで、見事にうまくいきました。
かなり簡単に記述できるので、みなさんもbintray-release使ってみてください!

最後に

RxAnimationというライブラリをJavaとKotlin両方でリリースしました。
今回のgradleの部分もかかれているので、見ていただけたらと思います。
https://github.com/Reyurnible/RxAnimation

23
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
21