GradleでIntelliJ IEDAのプロジェクトを作成する(途中まで)
Kotlin入門2日目:Macでの環境構築の続き。IntelliJはインストール済み。
前回はGradle, Kotlinの導入が終わったところで、Gradleから素のKotlinプロジェクトを作成したところだった。今回はIntelliJのプロジェクトを作成する。
Gradleを使ったプロジェクト作成
まずは前回同様、プロジェクトを作成する。
$ cd sample/ $ gradle init --dsl kotlin --type=kotlin-application \ --package=sample --project-name=sample BUILD SUCCESSFUL in 0s 2 actionable tasks: 2 executed
ここを参考に、作成されたbuild.gradle.ktsにプラグインを追加する。コメントを除いて以下のようになった。
plugins {
id("org.jetbrains.kotlin.jvm").version("1.3.10")
application
idea // <- 追加
}
repositories {
jcenter()
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}
application {
mainClassName = "sample.AppKt"
}
プラグインによってタスクが追加されている。
IDE tasks --------- cleanIdea - Cleans IDEA project files (IML, IPR) idea - Generates IDEA project files (IML, IPR, IWS) openIdea - Opens the IDEA project
ideaタスクを実行する。
$ gradle idea > Task :idea Generated IDEA project at file:///private/tmp/sample/sample.ipr Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings BUILD SUCCESSFUL in 15s 4 actionable tasks: 4 executed
IntelliJ からはfile:///private/tmp/sample/sample.iprを開くと良いっぽい。
IntelliJで開く
Gradleの方でopenIdeaというタスクがあるので、実行してみる。
$ gradle openIdea > Task :idea Generated IDEA project at file:///private/tmp/sample/sample.ipr Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings BUILD SUCCESSFUL in 1s 5 actionable tasks: 5 executed
この後IDEAが開いたがUnlinked Gradle project?と出てきた。

時間なくなったんで今日はここまで。