////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.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.
////

Dependencies for your project are defined in the `dependencies` block. In general, you can follow the https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html[Gradle documentation on dependency management] to understand how to configure additional dependencies.

The default dependencies for the Grails Web application can be seen below:

[source,groovy]
----
dependencies {
    profile "org.apache.grails.profiles:web"
    testAndDevelopmentOnly "org.webjars.npm:bootstrap"
    testAndDevelopmentOnly "org.webjars.npm:bootstrap-icons"
    testAndDevelopmentOnly "org.webjars.npm:jquery"
    implementation platform("org.apache.grails:grails-bom:$grailsVersion")
    implementation "org.apache.grails:grails-core"
    implementation "org.apache.grails:grails-logging"
    implementation "org.apache.grails:grails-databinding"
    implementation "org.apache.grails:grails-interceptors"
    implementation "org.apache.grails:grails-rest-transforms"
    implementation "org.apache.grails:grails-services"
    implementation "org.apache.grails:grails-url-mappings"
    implementation "org.apache.grails:grails-web-boot"
    implementation "org.apache.grails:grails-gsp"
    implementation "org.apache.grails:grails-data-hibernate5"
    implementation "org.apache.grails:grails-scaffolding"
    implementation "org.springframework.boot:spring-boot-autoconfigure"
    implementation "org.springframework.boot:spring-boot-starter"
    implementation "org.springframework.boot:spring-boot-starter-actuator"
    implementation "org.springframework.boot:spring-boot-starter-logging"
    implementation "org.springframework.boot:spring-boot-starter-tomcat"
    implementation "org.springframework.boot:spring-boot-starter-validation"
    console "org.apache.grails:grails-console"
    runtimeOnly "cloud.wondrify:asset-pipeline-grails"
    runtimeOnly "com.h2database:h2"
    runtimeOnly "com.zaxxer:HikariCP"
    runtimeOnly "org.fusesource.jansi:jansi"
    integrationTestImplementation testFixtures("org.apache.grails:grails-geb")
    testImplementation "org.apache.grails:grails-testing-support-datamapping"
    testImplementation "org.apache.grails:grails-testing-support-web"
    testImplementation "org.spockframework:spock-core"
}
----

Note that version numbers are not present in the majority of the dependencies. This is thanks to the Grails Gradle Plugin, which adds `grails-bom` as a managed dependency platform. The BOM defines the default versions for most commonly used Grails dependencies and plugins.

==== Overriding Managed Versions

To override a managed version, set the corresponding property in `build.gradle`:

[source,groovy]
----
ext['slf4j.version'] = '1.7.36'
----

The same override can be set in `gradle.properties` (note: `gradle.properties` only supports the `name=value` form, not the `ext[...]` syntax):

[source,properties]
----
slf4j.version=1.7.36
----

The property override mechanism is a feature of the **Grails BOM Property Overrides Gradle plugin** (`org.apache.grails.gradle.bom-property-overrides`); standalone Gradle does not natively read `<properties>` from BOM POMs (see https://github.com/gradle/gradle/issues/9160[Gradle issue #9160]). The plugin parses the BOM POM (following `<scope>import</scope>` BOMs), determines which managed versions change when your overrides are applied, and applies each change as a strict dependency constraint.

[NOTE]
====
Each property override is applied as a *strict* dependency constraint, so it wins over the `require` constraints contributed by `platform(grails-bom)` - in both directions. Setting `slf4j.version` to a value *lower* than the BOM default therefore actually downgrades `slf4j-api`, matching the legacy Spring Dependency Management plugin (a plain resolution rule would lose to Gradle's highest-version-wins conflict resolution).

This strict behaviour applies to *explicit overrides only*. The BOM's default (non-overridden) managed versions are contributed by a regular `platform()` and still participate in Gradle's standard highest-version-wins conflict resolution, so a transitive dependency can pull a non-overridden managed version higher than the BOM default. To make the BOM's default versions win unconditionally as well, declare `enforcedPlatform(grails-bom)` on the relevant configuration.

Overriding a property that selects an imported BOM's version (for example `spring-boot.version`, which selects the `spring-boot-dependencies` BOM that `grails-bom` imports) re-imports that BOM at the overridden version and applies its updated managed set.
====

==== Applying the BOM in Different Project Types

For a Grails App, applying `org.apache.grails.gradle.grails-web` will automatically configure the `grails-bom` _and_ apply the `bom-property-overrides` plugin. No other steps required.

For Plugins and Projects which do not use `org.apache.grails.gradle.grails-web`, you can apply the `grails-bom` using Gradle Platforms:

[source,groovy]
----
dependencies {
    implementation platform("org.apache.grails:grails-bom:{GrailsVersion}")
    //...
}
----

==== Using `bom-property-overrides` Outside a Grails App

The property-override mechanism is BOM-agnostic and can be applied to any project that consumes a BOM with `<properties>` references. Apply the plugin directly when you want the same `gradle.properties` / `ext['…']` override workflow without applying the full Grails web plugin:

[source,groovy]
----
plugins {
    id 'java-library'
    id 'org.apache.grails.gradle.bom-property-overrides' version '{GrailsVersion}'
}

dependencies {
    implementation platform('com.example:my-bom:1.0.0')
}

// In build.gradle
ext['slf4j.version'] = '2.0.13'
----

The same override can also be set in `gradle.properties` (note: `gradle.properties` only supports the `name=value` form, not the `ext[...]` syntax):

[source,properties]
----
slf4j.version=2.0.13
----

By default, the plugin auto-detects every `platform()` and `enforcedPlatform()` dependency declared on the project's configurations and registers each one for property-override processing. You can disable auto-detection or register additional BOMs explicitly via the `bomPropertyOverrides` extension:

[source,groovy]
----
bomPropertyOverrides {
    // Disable scanning declared platforms (default: true)
    autoDetect = false

    // Register specific BOMs (e.g. ones referenced indirectly)
    bom 'com.example:my-bom:1.0.0'
    bom 'com.example:other-bom:2.0.0'
}
----
