// Copyright (C) 2024 Gradle, Inc.
//
// Licensed under the Creative Commons Attribution-Noncommercial-ShareAlike 4.0 International License.;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

[[rule_source]]
= Implementing model rules in a plugin

[CAUTION]
====
Rule based configuration link:https://blog.gradle.org/state-and-future-of-the-gradle-software-model[will be deprecated].
New plugins should not use this concept.
Instead, use the standard approach described in the <<plugins.adoc#custom_plugins, Writing Custom Plugins>> chapter.
====

A plugin can define rules by extending link:{javadocPath}/org/gradle/model/RuleSource.html[RuleSource] and adding methods that define the rules. The plugin class can either extend link:{javadocPath}/org/gradle/model/RuleSource.html[RuleSource] directly or can implement link:{javadocPath}/org/gradle/api/Plugin.html[Plugin] and include a nested link:{javadocPath}/org/gradle/model/RuleSource.html[RuleSource] subclass.

Refer to the API docs for link:{javadocPath}/org/gradle/model/RuleSource.html[RuleSource] for more details.


[[sec:applying_additional_rules]]
== Applying additional rules

A rule method annotated with link:{javadocPath}/org/gradle/model/Rules.html[Rules] can apply a link:{javadocPath}/org/gradle/model/RuleSource.html[RuleSource] to a target model element.
