Groovy & Gradle: JVM Automation and Build Engineering · บทเรียน

การสร้างหลายโครงการและไฟล์การตั้งค่า

จัดระเบียบฐานโค้ดขนาดใหญ่ด้วยการสร้างหลายโครงการของ Gradle ไฟล์ settings.gradle และการกำหนดค่าร่วมระหว่างโครงการย่อย

บทเรียน 4 จาก 413 ขั้นตอน

การสร้างหลายโครงการและไฟล์การตั้งค่า เป็นบทเรียน Groovy & Gradle: JVM Automation and Build Engineering ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Groovy & Gradle: JVM Automation and Build Engineering และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Groovy & Gradle: JVM Automation and Build Engineering มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why Multi-Project Builds?

Real applications often split into modules — an API, a core library, a CLI. Gradle multi-project builds let one build coordinate many subprojects, sharing configuration and dependencies.

The settings.gradle File

The root settings.gradle defines the build: its name and which subprojects belong to it. Without an include entry, Gradle ignores a directory.

rootProject.name = 'my-app'
include 'core', 'api', 'cli'

Directory Layout

Each included project lives in its own folder with its own build.gradle. The root build can configure them all from one place.

The Root build.gradle

Use allprojects and subprojects blocks in the root build to apply shared settings, avoiding repetition.

subprojects {
    apply plugin: 'java'
    repositories { mavenCentral() }
}

Project Dependencies

One subproject can depend on another using the project() notation, so Gradle builds them in the right order.

dependencies {
    implementation project(':core')
}

The Build Order

Gradle builds a directed graph of project dependencies and compiles each module before the ones that need it. You never order things by hand.

Running Tasks Across Projects

From the root, gradle build builds every subproject. Target one with the project path prefix.

gradle :api:test

Configuration on Demand

For large builds, enabling configuration on demand tells Gradle to configure only the projects relevant to the requested task, speeding up startup.

org.gradle.configureondemand=true

Sharing with buildSrc

The special buildSrc directory holds shared build logic (custom tasks, plugins) compiled once and available to every subproject automatically.

Composite Builds

For independent repositories, a composite build with includeBuild lets you wire separate Gradle builds together without publishing artifacts.

includeBuild '../shared-lib'

Parallel Execution

Independent subprojects can build at the same time. Enable parallel execution to use all CPU cores, cutting build time on large multi-project setups.

org.gradle.parallel=true

Quick Check

Test your multi-project knowledge.

Recap

You learned to structure larger builds:

  • Multi-project builds coordinate many modules
  • settings.gradle includes subprojects
  • subprojects/allprojects share config from the root
  • project(:name) declares inter-module dependencies
  • buildSrc and composite builds promote reuse
เริ่มต้นได้ฟรี

เรียนรู้ Groovy ด้วย AI tutor — ฟรี

เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป

คอร์ส
12
บทเรียน
48

คำถามที่พบบ่อย

บทเรียน “การสร้างหลายโครงการและไฟล์การตั้งค่า” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การสร้างหลายโครงการและไฟล์การตั้งค่า” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Groovy & Gradle: JVM Automation and Build Engineering ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Groovy & Gradle: JVM Automation and Build Engineering มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การสร้างหลายโครงการและไฟล์การตั้งค่า”

จัดระเบียบฐานโค้ดขนาดใหญ่ด้วยการสร้างหลายโครงการของ Gradle ไฟล์ settings.gradle และการกำหนดค่าร่วมระหว่างโครงการย่อย คุณปฏิบัติ Groovy & Gradle: JVM Automation and Build Engineering ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Groovy & Gradle: JVM Automation and Build Engineering หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Groovy & Gradle: JVM Automation and Build Engineering บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “การสร้างหลายโครงการและไฟล์การตั้งค่า” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Groovy & Gradle: JVM Automation and Build Engineering นี้ได้ไหม

ได้ บทเรียน Groovy & Gradle: JVM Automation and Build Engineering ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การติดตั้ง Gradle และ CLI
  2. โครงสร้างโครงการ Gradle
  3. งานและวงจรชีวิตการสร้าง
  4. การสร้างหลายโครงการและไฟล์การตั้งค่า
← กลับไปที่ Groovy & Gradle: JVM Automation and Build Engineering