GradleのビルドスクリプトをKotlinで書く
GradleのビルドスクリプトとしてKotlinを使う
Gradle3.0移行、GradleのビルドスクリプトをKotlinで書くことが可能になりました。
2016年12月現在build.gradle.ktsというスクリプトファイルを用意することでビルドスクリプトをKotlinで記述可能です。
以下のように記述します。
import org.gradle.api.plugins.*
import org.gradle.api.tasks.wrapper.*
import org.gradle.script.lang.kotlin.*
group = "gradle-meets-kotlin"
version = "1.0.0-SNAPSHOT"
val kotlinVersion by extra.properties
apply {
plugin("application")
}
configure<ApplicationPluginConvention> {
mainClassName = "samples.HelloWorld"
applicationName = "gradle-meets-kotlin"
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
"testCompile"("junit:junit:4.12")
}
settings.gradleの設定も以下のように修正する必要があるようです。
rootProject.buildFileName = 'build.gradle.kts'
最終更新日時:2016年12月11日