Closed3
Gradle docs Reading

Learning the Basics
Setting File Basics
Add subprojects
サブプロジェクトを追加するにはsettings.gradle.kts
に以下のように記述する。
include("sub-project-a")
include("sub-project-b")
include("sub-project-c")
Dependencies Basics
Declaring Your Dependencies
依存関係の種類は複数ある。
testImplementation
, runtimeOnly
, compileOnly
, api
, and more.
これはAnthonyの考えと同じ。
Incremental Builds and Build Caching Basic
Incremental builds
Gradleでは増分ビルドが常に有効になっている。変更のあるなしはverbose
モードでコマンドを実行することでわかる。
./gradlew compileJava --console=verbose
このモードを永続的に有効にするには、gradle.properties
にorg.gradle.console=verbose
を追加する。
Build caching
増分ビルドが使えたとしても、先週で更新が止まっているブランチにチェックアウトした場合はキャッシュが効かなくなる。そこで便利なのがこれ。
./gradlew compileJava --build-cache
Define Version Catalog
gradle/libs.versions.toml
にバージョンカタログを記載できる。
[versions]
guava = "33.3.1-jre"
junit-jupiter = "5.11.3"
[libraries]
guava = { module = "com.google.guava:guava", version.ref = "guava" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
こう書ける。
app/build.gradle.kts
dependencies {
// Use JUnit Jupiter for testing.
testImplementation(libs.junit.jupiter)
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// This dependency is used by the application.
implementation(libs.guava)
}

Multi-Project Build Basics

Gradle Build Lyfecycle
このスクラップは4ヶ月前にクローズされました