플러그인 확장과 구성 가능한 DSL
확장 객체, 속성, 규약을 사용해 Gradle 플러그인에 깔끔한 구성 DSL을 제공하고 세련된 사용자 경험을 만드는 방법을 배웁니다.
플러그인 확장과 구성 가능한 DSL은(는) CoddyKit의 무료 Groovy & Gradle: JVM Automation and Build Engineering 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Groovy & Gradle: JVM Automation and Build Engineering 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Groovy & Gradle: JVM Automation and Build Engineering 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Configuring a Plugin
A good plugin lets users customize its behaviour through a readable block in their build script. Gradle calls this an extension — it is how plugins like the Java plugin expose settings.
What Is an Extension?
An extension is a plain object your plugin registers under a name. Users set its properties in a matching DSL block, and your tasks read those values.
Defining an Extension Class
Create a class holding the configurable properties.
class GreetingExtension {
String message = "Hello"
String recipient = "World"
}Registering the Extension
In the plugin apply method, register the extension under a DSL name.
void apply(Project project) {
project.extensions.create('greeting', GreetingExtension)
}Configuring in build.gradle
Users now configure the plugin with a clean block matching the extension name.
greeting {
message = 'Hi'
recipient = 'Gradle'
}Reading Extension Values in a Task
Wire the extension values into a task so configuration drives behaviour at execution time.
def ext = project.extensions.greeting
project.tasks.register('greet') {
doLast { println "${ext.message}, ${ext.recipient}!" }
}Lazy Properties
Modern plugins use the Provider API (Property<String>) so values are evaluated lazily, after the user has finished configuring.
abstract class Ext {
abstract Property<String> getMessage()
}Setting Conventions
Give sensible defaults with convention so the plugin works out of the box but stays overridable.
message.convention('Hello')Nested Extensions
Complex plugins nest extensions, e.g. a publishing block containing a repositories sub-block, by registering child objects.
Configuring Tasks from the Extension
The robust pattern is to register tasks and wire their lazy properties from the extension inside project.afterEvaluate or via providers, so user configuration is fully applied before values are read.
project.afterEvaluate {
project.tasks.greet.configure { message = project.extensions.greeting.message }
}Why Extensions Matter
Extensions separate what the user wants from how the plugin works. They make plugins discoverable, type-safe, and pleasant to configure — the hallmark of a reusable plugin.
Quick Check
Test your plugin extension knowledge.
Recap
You learned to make plugins configurable:
- Extensions expose a named DSL block to users
- Register with
project.extensions.create - Tasks read extension values at execution time
- Use the Provider API and
conventionfor lazy defaults - Extensions separate user intent from plugin mechanics
자주 묻는 질문
“플러그인 확장과 구성 가능한 DSL” 강의는 무료인가요?
네 — “플러그인 확장과 구성 가능한 DSL” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Groovy & Gradle: JVM Automation and Build Engineering 강의 전체를 잠금 해제할 수 있습니다. Groovy & Gradle: JVM Automation and Build Engineering 강의에는 총 4개의 강의가 포함되어 있습니다.
“플러그인 확장과 구성 가능한 DSL”에서 뭘 배우나요?
확장 객체, 속성, 규약을 사용해 Gradle 플러그인에 깔끔한 구성 DSL을 제공하고 세련된 사용자 경험을 만드는 방법을 배웁니다. 브라우저에서 직접 실행하는 실습 코드로 Groovy & Gradle: JVM Automation and Build Engineering을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Groovy & Gradle: JVM Automation and Build Engineering을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Groovy & Gradle: JVM Automation and Build Engineering은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“플러그인 확장과 구성 가능한 DSL” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Groovy & Gradle: JVM Automation and Build Engineering 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Groovy & Gradle: JVM Automation and Build Engineering 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- Gradle 플러그인 이해하기
- 바이너리 플러그인 구축
- 플러그인 적용과 게시
- 플러그인 확장과 구성 가능한 DSL