しおしお

IntelliJ IDEAのことなんかを書いてます

KotlinのGradleプラグイン

KotlinのGradleプラグインがあるらしいので試してみました。

Gradleのbuildスクリプトサンプルは、以下のKotlinのサイトに上がっています。
Kotlin Build Tools - Kotlin - Confluence

サンプルbuildスクリプト
buildscript {
  repositories {
    mavenCentral()
    maven {
      url 'http://repository.jetbrains.com/all'
    }
  }
  dependencies {
    classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:+'
  }
}

apply plugin: "kotlin"

repositories {
  mavenCentral()
  maven {
    url 'http://repository.jetbrains.com/all'
  }
}

// テストを実行するための設定
test.testClassesDir = project.tasks.compileTestKotlin.destinationDir

dependencies {
  compile 'org.jetbrains.kotlin:kotlin-stdlib:+'
  testCompile 'junit:junit:+'
}
注意点

チケット(Gradle test tasks do not see kotlin test classes : KT-3490)にも上がっていますが、test.testClassesDirの設定を行わないと自動テストの実行がされません。
Kotlinのドキュメントサイトに有るサンプルだとこの設定が抜けているので、サンプル流用するとテストが実行されなくて嵌ったりするので注意ですね。

他にもkdocのタスク実行すると、標準入力での入力を求められたりとイマイチなところが多々あるけど、今後に期待ですね。

おわり。