Groovy & Gradle: JVM Automation and Build Engineering · レッスン

コンポジットビルドとビルドの合成

コンポジットビルド(includeBuild)を使って独立したGradleビルドを1つにまとめ、成果物を公開せずに相互依存するプロジェクトを一緒に開発・テストします。

レッスン 4/413 ステップ

「コンポジットビルドとビルドの合成」はCoddyKit上の無料Groovy & Gradle: JVM Automation and Build Engineeringレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはGroovy & Gradle: JVM Automation and Build Engineering学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Groovy & Gradle: JVM Automation and Build Engineeringコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

What is a Composite Build?

A composite build stitches multiple otherwise-independent Gradle builds together. Unlike subprojects, each included build keeps its own settings.gradle and lifecycle.

  • Subprojects: one build, many modules
  • Composite: many builds, joined on demand

Why Use Composites?

Composite builds shine when you work across repository boundaries:

  • Develop a library and its consumer side by side
  • Avoid publishing SNAPSHOTs just to test a change
  • Debug a plugin in the context of a real project

includeBuild Basics

You join another build with includeBuild in settings.gradle. The path points at a directory containing its own settings file.

includeBuild("../shared-library")

Dependency Substitution

The magic is automatic dependency substitution. When your project declares a dependency on a module that an included build produces, Gradle wires the in-source build in place of the published artifact.

dependencies {
    implementation("com.acme:shared-library:1.0")
}

Explicit Substitution

If group/name do not match, declare the mapping manually so Gradle knows which project replaces the coordinate.

includeBuild("../shared-library") {
    dependencySubstitution {
        substitute(module("com.acme:shared")).using(project(":"))
    }
}

Running Tasks Across Builds

You can invoke tasks from an included build using the :buildName:task syntax from the root.

gradle :shared-library:build

Composite vs Multi-Project

Use a multi-project build when modules always ship together. Use a composite when builds are independently versioned and released but you occasionally need them linked.

Plugin Development Workflow

Composite builds are the recommended way to test a custom plugin. Include the plugin build, and consuming projects pick up your local changes instantly.

includeBuild("../my-gradle-plugin")

IDE Behavior

IntelliJ IDEA and Android Studio import composite builds as a single workspace, so navigation, refactoring, and debugging span all included builds seamlessly.

Limitations to Know

A few constraints apply:

  • Included builds cannot themselves define the same root build
  • A build cannot include itself (no cycles)
  • Publishing tasks are not substituted, only consumable artifacts

Best Practices

Keep composites ergonomic:

  • Use relative paths so teammates can clone side by side
  • Keep coordinates consistent to rely on automatic substitution
  • Document which builds are expected to be included

Quick Check

Test your understanding of composite builds.

Recap

You learned composite builds:

  • includeBuild joins independent builds
  • Dependency substitution swaps artifacts for live source
  • Ideal for cross-repo and plugin development
  • Differs from multi-project: builds stay independently versioned
無料で開始

AI チューターと学ぶ Groovy — 無料

ブラウザでリアルコードを書いて実行し、24/7 の AI チューターから瞬時にサポートを受け、ウェブまたはアプリで続きから学習できます。

コース
12
レッスン
48

よくある質問

「コンポジットビルドとビルドの合成」レッスンは無料ですか?

はい。「コンポジットビルドとビルドの合成」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Groovy & Gradle: JVM Automation and Build Engineeringコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Groovy & Gradle: JVM Automation and Build Engineeringコースには全4レッスンが含まれています。

「コンポジットビルドとビルドの合成」で何を学びますか?

コンポジットビルド(includeBuild)を使って独立したGradleビルドを1つにまとめ、成果物を公開せずに相互依存するプロジェクトを一緒に開発・テストします。 ブラウザで直接実行するハンズオンコードでGroovy & Gradle: JVM Automation and Build Engineeringを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Groovy & Gradle: JVM Automation and Build Engineeringを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのGroovy & Gradle: JVM Automation and Build Engineeringは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「コンポジットビルドとビルドの合成」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このGroovy & Gradle: JVM Automation and Build Engineeringレッスンでコードを書いて実行できますか?

はい。すべてのGroovy & Gradle: JVM Automation and Build Engineeringレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. モノレポのプロジェクト構成
  2. サブプロジェクトと設定
  3. プロジェクト間の依存関係
  4. コンポジットビルドとビルドの合成
← Groovy & Gradle: JVM Automation and Build Engineeringに戻る