Brightspot Gradle plugins reference
This page describes every setting, check, and plugin in the Brightspot Gradle plugins. For the recommended configuration and the most common overrides, see Brightspot Gradle plugins.
Requirements
- Gradle 8.4 or higher. Some features need a higher version:
--scanneeds Gradle 8.8 or higher.- Plugin projects need Gradle 8.11.1 or higher, for dependency analysis.
- The configuration cache needs Gradle 8.14 or higher.
- Java 11 or higher to run the build. The build can produce Java 8 classes; see
versions.java.
Plugins
Apply com.brightspot.gradle in settings.gradle.
It supplies all of the other plugins, so apply them in each subproject's build.gradle without a version.
| Plugin | Apply in | Purpose |
|---|---|---|
com.brightspot.gradle | settings.gradle | Configures every project in the build. Required. |
com.brightspot.java-core | core/build.gradle | Java code for a delivery project. |
com.brightspot.java-library | library subprojects | Java code published as a JAR. |
com.brightspot.war | web/build.gradle | Builds the WAR file. See WAR. |
com.brightspot.viewgen | frontend/build.gradle | Generates view classes from the root styleguide. See Viewgen. |
com.brightspot.bundle | each bundle's build.gradle | Builds a front-end bundle. See Bundle. |
com.brightspot.jakarta-substitution | web/build.gradle | Migrates Java EE to Jakarta EE in the WAR. See Jakarta EE substitution. |
com.brightspot.sonar | none | Configures SonarQube. com.brightspot.gradle applies it. See SonarQube. |
com.brightspot.spotless | any Java subproject | Formatting. Applied automatically by plugin = true. |
com.brightspot.error-prone | any Java subproject | Error Prone and NullAway. Applied automatically by plugin = true. |
All functionality is broken down into discrete plugins which you can use individually if the standard plugins are not appropriate for your project's needs. See the Javadoc on each plugin for details.
Gradle properties and command-line arguments
buildNumber
Written to the generated build.properties for informational purposes.
Set as a command-line argument; defaults to local.
1./gradlew -PbuildNumber=123 build
codePath
Used to generate code paths in the generated build.properties file.
Required for reloader support in local development.
Defaults to the project's root directory.
gradle.properties
1systemProp.codePath=/code
release
Marks the build as a release.
It sets the release version for the project and can change release-specific behavior,
such as the Maven repository that artifacts publish to.
Without it, the version is the versions.project value.
1./gradlew -Prelease=1.0.0 build
brightspot.test.maxHeapSize
Heap size for test workers; defaults to 1g.
Set it in the project's gradle.properties, not in a user or CI runner gradle.properties.
The value is part of the test task's cache key,
so a value that is different on one machine stops that machine from sharing test results with other machines.
gradle.properties
1brightspot.test.maxHeapSize=2g
brightspot.test.mockitoAgent
Whether test workers start with Mockito as a Java agent; defaults to true.
Set it to false to turn off the agent. See Tests.
gradle.properties
1brightspot.test.mockitoAgent=false
disableLocalCache
Turns off the local build cache for one run.
1./gradlew -DdisableLocalCache build
brightspot.color
The plugins show the advice at the end of the build in a red banner, with each command in bold. By default, Gradle decides: it shows the colors in a terminal,
and plain text when the output goes to a file or a pipe, in CI, or with --console=plain.
Set brightspot.color=true to always use colors, or false to never use them.
1./gradlew -Pbrightspot.color=false build
brightspot.upgradeCheck.cacheTime
How long Gradle keeps the lists of versions that brightspotUpgradeCheck and
brightspotGradleUpgradeCheck read. The default is 1h.
Write a number and a unit: s, m, h, or d. A number without a unit is in minutes. 0 lists the versions again on every build.
Gradle keeps no list from a file: repository.
1./gradlew -Pbrightspot.upgradeCheck.cacheTime=30m build
brightspot.columns
The width of the terminal, to which the plugins wrap the advice at the end of the build.
The plugins use the COLUMNS environment variable instead when the shell exports it. The default is 80.
Gradle runs the plugins in a background process, which cannot read the width of your terminal, so set it once in ~/.gradle/gradle.properties:
1brightspot.columns=135
BOM check properties
bomConsistencyFail, bomOverlap, bomOverlapPlatforms, and bomOverlapExclusions
can also be given as Gradle properties, for a one-off run without editing settings.gradle.
List values are comma-separated.
A value set in settings.gradle takes precedence over the Gradle property.
enforcedBomDowngradeExclusions can also be given as a comma-separated Gradle property.
brightspot.failOnDeprecatedDependencies makes relocationDependencyCheck fail the build.
bomJavaTargetAllowLower is available only as a Gradle property.
See Build checks and tasks.
1./gradlew -PbomConsistencyFail=false -PbomOverlap=true build
The brightspot block
These settings go in the brightspot block in settings.gradle.
Each one applies to every project in the build.
Required settings
projectGroup
Group used for generated artifacts.
1brightspot {2projectGroup = 'com.example'3}
versions.java
See versions.
dependencies
A dependencies block that applies to every subproject that uses a Brightspot Java plugin:
java-core, java-library, war, bundle, and viewgen.
It declares the BOMs and version constraints for the whole build in one place.
1brightspot {2dependencies {3implementation enforcedPlatform('com.psddev:brightspot-bom:5.0.8')4implementation enforcedPlatform('com.psddev:brightspot-dependencies:5.0.8')5sharedTest enforcedPlatform('com.brightspot.shared-tests:bom:1.6.1')6}7}
- Delivery projects declare platforms on
implementation. Plugin projects declare them onapi, so that their published poms include them. - Platforms on
implementationorapialso apply to thesharedTestandannotationProcessorconfigurations, so version-less annotation processors resolve, such ascom.psddev:javadoc-annotationprocessor. - Declare the shared tests BOM on
sharedTestonly. - Delivery projects use
enforcedPlatform. Plugin projects useplatform. - Set versions in the nested blocks:
constraintsfor a module that no BOM manages, or to raise one above a plainplatform;pinsto move a module that a BOM manages above or below the BOM's version;substitutionsandexclusionsto replace or remove modules.
- Each entry of these blocks can give its reason with Gradle's
because; see Reasons.
These pairs of BOMs must have the same version as each other.
The versionConsistency check fails the build if they do not.
| Product | BOMs |
|---|---|
| Brightspot | com.psddev:brightspot-bom, com.psddev:brightspot-dependencies |
| Brightspot Go | com.brightspot.go:bom, com.brightspot.go:go-dependencies |
| Component Lib | com.psddev.component-lib:bom, com.psddev.component-lib:cl-dependencies |
| Brightspot Migration | com.psddev.migration:bom, com.psddev.migration:dependencies |
If a project has neither this block nor a version catalog, the build logs a warning and version-less dependencies do not resolve.
Dependabot updates the versions in this block. See Dependabot.
constraints
Gradle's own constraints block. It sets the lowest version of a module, in one configuration,
without adding a dependency, and applies only when something else in the graph pulls the module in.
1brightspot {2dependencies {3constraints {4implementation 'com.some-group:some-artifact:1.2.3'5}6}7}
- Use it for a module that no BOM manages, or, in a plugin project, to raise a module above its BOM.
- An entry below the version that the configuration's BOMs manage does not change the version, so the build fails and
names it. To keep a lower version, use a
downgrade. An entry at the BOM's version stays: it gives the version to the configurations that the BOM does not reach. - In a delivery project, an enforced BOM wins over a constraint. To move a module that it manages, use
pins.
pins
Forces the version of a module that a BOM manages, in every configuration of every project, over the BOMs.
1brightspot {2dependencies {3pins {4upgrade 'com.squareup.retrofit2:retrofit:2.11.0'5downgrade 'org.xerial:sqlite-jdbc:3.36.0.3'6}7}8}
upgrademust be above the version the BOMs manage, anddowngradebelow it. Where the BOMs disagree on a module, anupgrademust be above the lowest of their versions, and adowngradebelow the highest.- When the build's only BOMs are those of the
dependenciesblock, a pin that the BOMs moved past fails the build and is named: anupgradethat the BOMs now meet or pass, or adowngradethat the BOMs now meet or go under, no longer does anything. Remove it, or runbrightspotDoctor, which removes it. When a build file or a project platform declares a BOM too, the BOMs reach only some configurations, so the pins apply as they are and the build does not judge them. - Where no BOM of a configuration manages the module, the pin applies as it is.
The doctor moves a pin of a module that no BOM of the build manages into
constraints. - A
downgradeallows the downgrade:versionDowngradeCheckandbomConsistencyskip the module. At the end of every build,versionDowngradeChecklists each downgrade that still resolves below its BOM; its reason says why. - A module cannot have both an
upgradeand adowngrade.
substitutions
Adds, overrides, or removes dependency substitutions.
1brightspot {2dependencies {3substitutions {4substitute 'com.some-group:some-artifact' using 'com.some-preferred-group:some-preferred-artifact'5substitute 'com.some-group:other-artifact' using 'com.some-preferred-group:other-artifact:1.0.0'6substitute 'com.some-group:local-artifact' using ':local-project'7keep 'javax.el:javax.el-api'8}9}10}
- The version of the target is optional. Without one, the target takes the version of a
pinsentry, else the version its BOMs manage, else the version of aconstraintsentry, else the version that another dependency asks for. - A module with a version,
group:name:version, substitutes only that version of it.group:name:with no version after the colon is the same asgroup:name. - A target that starts with
:substitutes a project in the build. keepremoves a default substitution, so the module stays.
These substitutions apply by default. Each one replaces a module with the module that the platform standardizes on:
| Module | Replaced by | Version |
|---|---|---|
commons-logging:commons-logging | org.slf4j:jcl-over-slf4j | 2.0.18 |
org.springframework:spring-jcl | org.slf4j:jcl-over-slf4j | 2.0.18 |
com.zaxxer:HikariCP-java7 | com.zaxxer:HikariCP | 4.0.3 |
io.swagger.core.v3:swagger-annotations-jakarta | io.swagger.core.v3:swagger-annotations | 2.2.55 |
javax.xml.bind:jaxb-api | jakarta.xml.bind:jakarta.xml.bind-api | 2.3.3 |
com.github.bbottema:jetbrains-runtime-annotations | org.jetbrains:annotations | 26.0.1 |
com.google.android.tools:dx | junit:junit | 4.13.2 |
com.sun.mail:javax.mail | com.sun.mail:jakarta.mail | 1.6.8 |
javax.activation:activation | com.sun.activation:jakarta.activation | 1.2.2 |
javax.activation:javax.activation-api | com.sun.activation:jakarta.activation | 1.2.2 |
jakarta.activation:jakarta.activation-api (1.x only) | com.sun.activation:jakarta.activation | 1.2.2 |
javax.annotation:javax.annotation-api | jakarta.annotation:jakarta.annotation-api | 1.3.5 |
javax.el:javax.el-api | org.glassfish:jakarta.el | 3.0.4 |
javax.inject:javax.inject | org.glassfish.hk2.external:javax.inject | 2.4.0 |
- The version applies only when nothing else gives the replacement module one.
When a BOM of the configuration manages it, imports included, the BOM's version applies, higher or lower.
When the build pins it in
pins, the pinned version applies. A dependency that asks for a higher version still wins. - The versions of the replacement modules keep the
javaxpackage. Their later versions use thejakartapackage. - A substitution in the other direction removes the default.
For example,
substitute 'io.swagger.core.v3:swagger-annotations' using 'io.swagger.core.v3:swagger-annotations-jakarta:2.2.22'removes the default forio.swagger.core.v3:swagger-annotations-jakarta. Do not reverse a default without a reason: the doctor keeps the substitution, since removing it would change the dependencies, and lists it under "Needs a person".
exclusions
Removes modules from every configuration, as group:name.
1brightspot {2dependencies {3exclusions {4exclude 'com.some-group:some-unwanted-artifact'5}6}7}
Reasons
Each entry of pins, substitutions, and exclusions takes an optional
reason after because, as Gradle's own dependency declarations do.
An entry of constraints takes it in Gradle's own form, a closure.
1brightspot {2dependencies {3constraints {4implementation('com.some-group:unmanaged-artifact:1.2.3') { because 'no BOM manages it' }5}6pins {7upgrade 'com.squareup.retrofit2:retrofit:2.11.0' because 'fixes the timeout in 2.9.0'8}9substitutions {10substitute 'com.some-group:some-artifact' using 'com.some-preferred-group:some-preferred-artifact' because 'renamed'11keep 'javax.el:javax.el-api' because 'the server provides it'12}13exclusions {14exclude 'com.some-group:some-unwanted-artifact' because 'it duplicates classes of another module'15}16}17}
dependencyInsightshows the reason of a pin and of a constraint.- The doctor gives a reason to each version that differs from the BOMs and has none, such as
because 'the BOMs manage 2.9.0'. It never changes a reason, and a reason goes only with its entry. It does not read comments; a comment stays where it is.
Settings properties that the blocks replace
dependencyConstraints, dependencySubstitutions, dependencyExclusions, and allowedDowngrades in the
brightspot block still work as before. brightspotDoctor moves them into the blocks above:
a pin above the BOM's version into upgrade, one below it into downgrade, one of a module that no BOM manages into
constraints, and an allowed downgrade into a downgrade at the version the build resolves.
It removes an allowed downgrade of a module that the build does not resolve below its BOMs.
When the build resolves the module at several versions, the allowed downgrade stays, and the doctor asks for a downgrade.
classEnhancers
The class enhancers to run;
defaults to ['com.psddev.dari.db.LazyLoadEnhancer', 'com.psddev.dari.db.QueryCommentEnhancer'].
com.psddev.dari.util.JavadocEnhancer runs in addition to these whenever it is on the classpath,
so do not list it; see Javadoc annotations.
Changing this list causes the classes to be enhanced again.
1brightspot {2classEnhancers = [3'com.psddev.dari.db.LazyLoadEnhancer',4]5}
A subproject can set its own classEnhancers in its build.gradle.
Javadoc annotations
Every java-core, java-library, war, and viewgen subproject gets these without any configuration:
- The
com.psddev:javadoc-annotationprocessorannotation processor, which writes a*.javadoc.jsonresource for each class. It resolves in thebrightspotJavadocconfiguration and takes its version from the Brightspot BOM. If the BOM does not manage it, the subproject builds without it. Any other resolution or download failure of the processor or its dependencies fails the build. com.psddev.dari.util.JavadocEnhancer, whenever the class is on the classpath of the class enhancement task.
A subproject that still declares the processor, or lists JavadocEnhancer in classEnhancers, builds
without an error, and each runs once. Remove those declarations.
enhanceClasses and modifyClasses
Whether to apply the class enhancement and class modification plugins; both default to true.
1brightspot {2enhanceClasses = false3modifyClasses = false4}
enforcedBomDowngradeExclusions
Modules that the enforcedBomDowngrade check does not report, as group:name.
Use it when an enforced BOM holds a module back on purpose.
1brightspot {2enforcedBomDowngradeExclusions = [3'com.some-group:some-artifact',4]5}
BOM check settings
See Build checks and tasks for what each check does.
bomConsistencyFail
Whether bomConsistency and bomOverlap violations fail the build; defaults to true.
Set it to false to report violations as warnings.
1brightspot {2bomConsistencyFail = false3}
bomConsistencyExclusions
BOMs that bomConsistency ignores, as group:name.
1brightspot {2bomConsistencyExclusions = [3'io.grpc:grpc-bom',4]5}
bomOverlap
Whether bomOverlap runs; defaults to false for delivery projects and true for plugin projects.
1brightspot {2bomOverlap = true3}
bomOverlapPlatforms
The platforms whose managed coordinates a project must not set a version for, as group:name.
Defaults to the shared dependencies BOM and its JDK overlays:
com.brightspot.dependencies:bom, bom-java8, bom-java11, and bom-java21.
Platforms that are not in the dependency graph are ignored.
1brightspot {2bomOverlapPlatforms = [3'com.brightspot.dependencies:bom',4]5}
bomOverlapExclusions
Coordinates that bomOverlap ignores, as group:name.
Use it only when a local version must be different from its manager on purpose,
such as a plugin that ships a different major version of a library that an upstream plugin also carries.
1brightspot {2bomOverlapExclusions = [3'org.apache.solr:solr-solrj',4]5}
buildProperties
Which values the generated build.properties includes; both default to true.
1brightspot {2buildProperties {3buildNumber = false4gitCommits = false5}6}
versions
java
The Java version to compile classes for; required. Plugin projects compile with a Java 21 toolchain for any value; this value sets the bytecode target.
1brightspot {2versions {3java = 214}5}
project
The version of the project's artifacts; defaults to '1.0.0-SNAPSHOT'.
Plugin projects default to '9999-SNAPSHOT'.
1brightspot {2versions {3project = '2.0.0-SNAPSHOT'4}5}
basePrefix
The prefix for the versions of subprojects that are not BOMs; not set by default. Set it only in library projects that publish a BOM.
1brightspot {2versions {3basePrefix = '2.0'4}5}
enforcePlatform
Applies only to BOMs from a version catalog. See that section.
Version catalog
Existing projects can declare their Brightspot BOMs in a version catalog named brightspotLibs
in dependencyResolutionManagement.
New projects use the dependencies block instead.
1dependencyResolutionManagement {2versionCatalogs {3brightspotLibs {4library('brightspot', 'com.psddev:brightspot-bom:5.0.8')5library('brightspotDependencies', 'com.psddev:brightspot-dependencies:5.0.8')6library('brightspotSharedTests', 'com.brightspot.shared-tests:bom:1.6.1')7}8}9}
The plugins read these aliases:
| Alias | BOM |
|---|---|
brightspot | com.psddev:brightspot-bom |
brightspotDependencies | com.psddev:brightspot-dependencies |
brightspotSharedTests | com.brightspot.shared-tests:bom |
brightspotGo | com.brightspot.go:bom |
brightspotGoDependencies | com.brightspot.go:go-dependencies |
componentLib | com.psddev.component-lib:bom |
componentLibDependencies | com.psddev.component-lib:cl-dependencies |
brightspotMigration | com.psddev.migration:bom |
brightspotMigrationDependencies | com.psddev.migration:dependencies |
versions.enforcePlatform controls whether these BOMs apply as enforcedPlatform or platform.
It defaults to true (enforcedPlatform) for delivery projects and false for plugin projects.
1brightspot {2versions {3enforcePlatform = false4}5}
Build checks and tasks
Most checks run before compilation, so a failure stops the build early.
When a build fails on its dependencies, Gradle shows this line under "Try":
1Run ./gradlew brightspotDoctor: it explains many of these failures, and fixes some of them.
Before Gradle 8.14, and on a build that reuses a configuration cache entry,
the line shows above the failure, after This build failed on its dependencies.
The line does not show on a build that runs brightspotDoctor, brightspotGradleUpgrade, or brightspotGradleRewrite.
Properties file encoding
validateEncoding runs as part of check and fails the build
if a .properties file does not have UTF-8 encoding.
The advice at the end of the build names the command.
To convert the files, run the following command, then commit the changes:
1./gradlew convertEncoding
versionConsistency
Fails the build if the two BOMs of a product pair have different versions.
See the table in dependencies.
Delivery projects only.
versionDowngradeCheck
Fails the build if a dependency substitution downgrades a version that a BOM manages.
Declare a downgrade to allow a module's downgrade.
At the end of every build, it lists the allowed modules that resolve at another version than their BOM manages.
Delivery projects only.
enforcedBomDowngrade
Reports when an enforced BOM holds a module below the version that a dependency asks for.
An enforced platform wins over conflict resolution, so that dependency runs against the older, pinned version.
It names the module, the pinned version, the requested version, the dependency that asked for it,
and the BOM that declares the pin, in build/reports/enforced-bom-downgrade.txt.
It runs as part of check, and before war in WAR projects.
In WAR projects it gives the findings in the advice at the end of the build; in the others it logs them at info level. It never fails the build.
Modules the build already sets with a constraint or a substitution are not reported.
To silence a deliberate hold, add the module to enforcedBomDowngradeExclusions.
Delivery projects only.
relocationDependencyCheck and relocateApply
relocationDependencyCheck lists the declared dependencies that have moved to new coordinates in the advice at the end of the build.
To fail the build instead, pass -Pbrightspot.failOnDeprecatedDependencies=true.
Delivery projects only.
To rewrite them in your build scripts, run the following command,
then review and commit the changes:
1./gradlew relocateApply
relocateApply replaces each relocated dependency with its new coordinate, without a version.
bomConsistency
Checks each BOM in the dependency graph whose name ends in -bom, such as jackson-bom.
It reports modules of a BOM that resolve to a different major.minor version than that BOM declares,
including Jackson modules that do not match the Jackson BOM.
The usual causes are a substitution, a forced version, or a transitive dependency.
It skips the modules of downgrade pins and the BOMs of bomConsistencyExclusions.
Violations fail the build unless bomConsistencyFail is false.
bomOverlap
Reports coordinates that have a manager but that the project also sets a version for, with a constraint or with a versioned dependency. A coordinate has a manager when one of these supplies it:
- A platform in
bomOverlapPlatforms. - Another Brightspot plugin on the compile classpath:
a
com.brightspot.*module outside the build's own group.
It runs only in plugin projects, unless you set bomOverlap to true.
A published POM contains its resolved versions,
so a local version on a managed coordinate goes to every project that consumes the plugin.
bomJavaTarget
Compares the dependencies BOM tiers that the project imports, such as bom-java21,
with versions.java.
An unsuffixed com.brightspot.dependencies:bom counts as the Java 8 tier.
- In every project, it fails the build when a tier is higher than the Java target. This failure cannot be changed to a warning.
- In plugin projects, it also fails the build when the highest tier is lower than the tier for the Java target,
which is the highest
bom-javaNat or below it. A Java 21 plugin onbom-java11misses the Java 21 versions. To accept a lower tier, pass-PbomJavaTargetAllowLower=true.
brightspotGradleUpgrade
Moves the build to the latest release of these plugins, and applies the conventions of that release.
1./gradlew brightspotGradleUpgrade
It sets the latest release in settings.gradle, or in gradle.properties when a property holds the version.
Then it runs brightspotGradleRewrite of that release in a second build,
since the build that runs it uses the rules of the release it started with.
If the build is on the latest release, it does nothing.
Usually, run brightspotUpgrade, which moves the plugins the same way, commits the move,
and then runs the doctor and the upgrade of the new release.
- It upgrades only to releases, never to a pre-release such as
3.14.0-rc.1. To try a pre-release, set its version insettings.gradleby hand. - It does not run when the git working tree has changes. To run it anyway, add
--allow-dirty.
| Option | Effect |
|---|---|
--check | Changes nothing, unless -Pbrightspot.doctor.version is set: then it shows the edit as a diff and fails. |
--allow-dirty | Runs when the git working tree has changes. |
-Pbrightspot.doctor.version=<version> | Moves to this release of the plugins instead of the latest one. |
brightspotGradleUpgradeCheck
Notes a newer release of these plugins at the end of the build. It never changes a file and never fails the build.
It runs before every Java compilation, from the root project, like brightspotUpgradeCheck:
it finds the releases through the repositories of the build, so Gradle keeps the list for
brightspot.upgradeCheck.cacheTime, and the check is
up to date or comes from the build cache until then.
1The Brightspot plugins 3.15.0 are available; this build uses 3.14.2.23Apply: ./gradlew brightspotUpgrade
It notes the same release that brightspotGradleUpgrade moves to.
brightspotGradleRewrite
Brings the Gradle files of a build to the current conventions of these plugins.
1./gradlew brightspotGradleRewrite
Usually, run brightspotDoctor, which runs this task and commits its changes.
It does these steps:
- It edits
settings.gradle, thebuild.gradlefiles,gradle.properties, and the Gradle wrapper. It removes settings that the plugins apply by default, moves the version catalog and the rootbuild.gradleto thebrightspotblock, and moves versions from thebuild.gradlefiles to the BOMs or toconstraints. It does not change a resolved version. A version below a BOM stays, as adowngradewhose reason names the BOM's version and the forced one. OnlybrightspotUpgraderemoves the overrides at or above the versions that an upgraded BOM managed before the upgrade. It removes thepinsthat no longer apply, and moves the settings properties that the blocks replace intopins,constraints,substitutions, andexclusions. Where the enforced BOMs disagree on a module, it pins the version that the build resolves. It sets the maximum heap of the Gradle daemon (-Xmxinorg.gradle.jvmargs) to2gwhen it is smaller or not set. A larger value stays. - It compares the resolved dependencies before and after its edits, and shows each version that changed.
- It decides the configuration cache, when
gradle.propertiesdoes not set it. - It does not commit.
brightspotDoctorcommits its edits. - It writes a report to the console and to
build/reports/brightspotGradleRewrite/report.json.
- The doctor runs only when the build evaluates on its release of the plugins. Before the first run, do the manual steps in Automated upgrade.
- The doctor does not run when the git working tree has changes, so that
git checkout .undoes its edits. To run it anyway, add--allow-dirty. - Review the edits with
git diffbefore you commit them. - A reason from the doctor marks a version that is different from the BOMs'. Replace it with your own reason, or remove the entry.
- The report lists what the doctor cannot change. Change those items yourself.
| Option | Effect |
|---|---|
--check | Shows the edits as a diff and fails when there are edits, but changes no file. Use it in CI. |
--allow-dirty | Runs when the git working tree has changes. |
To decide the configuration cache, the doctor runs a child build of build --rerun-tasks --configuration-cache --continue,
so that every task runs. Each test task runs its own actions, such as a doFirst, but selects no tests.
Then it stores the cache of the whole build with --dry-run.
It runs this build only when gradle.properties sets neither org.gradle.configuration-cache
nor org.gradle.unsafe.configuration-cache, and not with --check.
- If the build succeeds, the doctor adds
org.gradle.configuration-cache=truetogradle.properties. A build that fails only on compilation or on a verification task, such asbuildHealth,spotlessCheck, or Checkstyle, with no cache problems, counts as a success. - If Gradle finds problems as it stores the cache, or a task fails on the configuration cache as it runs,
the doctor adds
org.gradle.configuration-cache=false, after a comment that lists each problem. A task that failed gives the line of the build script that its stack trace names:Fix the problems, then set the value to1# The configuration cache is off, since it does not support these yet. Fix them, then set this to true.2# core/build.gradle:12: Execution failed for task ':core:test'. > Cannot reference a Gradle script object from a Groovy closure as these are not supported with the configuration cache.3org.gradle.configuration-cache=falsetrue. - If the build fails for another reason, the doctor changes nothing and shows the failure. The setting stays undecided, so the next run of the doctor checks again.
The build leaves out the checks that note upgrades, which the build that runs the doctor already ran.
It also leaves out brightspotRewriteCheck, which fails when upgrade recipes are pending.
The build selects no tests, so a problem that shows only while a test itself runs can still fail a later build with the cache.
To repeat the probe, run ./gradlew build --rerun-tasks --configuration-cache --continue -Pbrightspot.doctor.configurationCacheProbe=true.
Starting in plugin version 3.14.1, the probe runs the test task actions.
In earlier versions, the probe runs build -x test, so it runs no test task actions,
and the comment that the doctor writes does not give the line of the build script.
In a plugin project, the doctor keeps the published POM the same:
- It does not edit the files that come from the plugin template:
bom/and.github/. - It keeps forced versions (
resolutionStrategy.force), because a constraint does not force a version. - It moves versions of test dependencies to
testImplementationconstraints in thebrightspotblock, not toapiconstraints, so that they stay out of the POM. - It removes a BOM that a
build.gradlefile declares again only when thebrightspotblock declares the same BOM at the same version. - It adds a product BOM to the
brightspotblock only when the BOM changes no resolved version.
brightspotGradleRewriteCheck
Notes, at the end of the build, that brightspotGradleRewrite would change the Gradle files.
To see which of its rules would change them, run ./gradlew brightspotGradleRewriteCheck --rerun --info:
the check is cacheable, and it lists the rules only when it runs.
It never changes a file and never fails the build.
1The Gradle files do not follow the Brightspot Gradle Plugin conventions.23Apply: ./gradlew brightspotDoctor
It runs before every Java compilation, from the root project, and runs only the rules that read the Gradle files:
settings.gradle, the build.gradle files, gradle.properties, and the Gradle wrapper properties.
It is up to date, or comes from the build cache, until one of these files changes.
The rules that read resolved dependencies, such as those that remove versions a BOM manages, need a full run of the doctor.
brightspotUpgradeCheck notes the most common of those: the versions that a BOM makes redundant.
brightspotRewriteCheck
Fails the build when the classpath brings upgrade recipes that the build has not run. Libraries publish upgrade recipes that change the code of the projects that use them, across a breaking change such as a renamed class or method.
The check runs before every Java compilation in each java-core, java-library, and war subproject.
It compares the recipes on the testCompileClasspath with the ledger.
If there is no ledger, every recipe is pending.
When recipes are pending, the build fails with a message such as this one:
1These upgrade recipes have not run on this project: [com.example.MigrateOldType]. Run ./gradlew brightspotDoctor to run them, ./gradlew brightspotDoctor --recipe=com.example.MigrateOldType to run one, or ./gradlew brightspotDoctor --recipe=com.example.MigrateOldType --acknowledge="<reason>" if it was applied by hand.
To upgrade a dependency:
- Change its version, or the version of its BOM, by any means: by hand, or with Dependabot or Renovate.
- If the build fails at
brightspotRewriteCheck, run./gradlew brightspotDoctor. - Review the commits that the doctor made.
The check reads the jars only when the resolved dependencies or the ledger change.
brightspotDoctor
Runs the pending upgrade recipes, brings the Gradle files to the current conventions of the plugins, and commits each change.
Run it after a version change, or when brightspotRewriteCheck fails.
1./gradlew brightspotDoctor
brightspotDoctor runs two other tasks and makes the git commits. Only it commits.
| Task | What it does | Commits |
|---|---|---|
brightspotDoctor | Runs the two tasks below, and commits their changes. | Yes |
brightspotGradleRewrite | Edits the Gradle files, and decides the configuration cache. | No |
brightspotRewrite | Runs the pending upgrade recipes, and writes the files, the ledger, and a record of the changes. | No |
It does these steps:
- It fails if the git working tree has changes, even when no recipe is pending, so that each commit holds the changes of one step only.
- It runs
brightspotGradleRewrite, with the same--checkand--allow-dirtyoptions. It does not change the release of the plugins;brightspotUpgradedoes. It commits the other edits asbuild: apply the brightspotGradleRewrite fixes. The commit lists each fix by file; for each override it removes, it says why, such asthe BOMs manage this version. - It commits
gradle.propertiesasbuild: enable the configuration cacheorbuild: disable the configuration cache, whenbrightspotGradleRewritedecided the configuration cache. - If modules do not resolve, it stops.
brightspotGradleRewritelists them under "Does not resolve" in its report, with what to do. - It runs
brightspotRewritewith the same--recipe,--acknowledge, and--checkoptions, on the edited build. If the Gradle files changed, the doctor starts a child build for this step. - It commits the changes of each recipe, with the ledger, as
refactor: apply <recipe>, in the order that the recipes ran. When you acknowledge recipes, it makes one commit of the ledger, namedchore: acknowledge <recipes>. - In a delivery build, it runs
bomConsistencyandversionDowngradeCheck, and adds each module that they report as adowngrade. It commits this asfix(deps): allow the BOM modules that bomConsistency rejects. It changes no version. - When a project of the build applies Error Prone, it compiles the code. For each Error Prone check that fails,
it writes the fix that Error Prone suggests to the sources, and commits them as
fix: apply the Error Prone fixes. Errors without a suggested fix, such as those of NullAway, stay. - In a plugin build, it applies the advice of the dependency analysis (
buildHealth) to thebuild.gradlefile of each project, and commits it asfix(deps): apply the buildHealth advice. It adds a module that a BOM manages without a version. Each change can change the advice, so it runs the analysis again until there is none, at most three times. Advice it cannot apply, such as for a dependency that the settings or the plugins declare, shows under "Needs a person". - When a project of the build enforces Spotless, it runs
spotlessApplyand commits the files that it changed asstyle: apply spotlessApply.
The commit messages follow Conventional Commits, with lines of at most 100 characters, so that a repository with commitlint accepts them.
If no recipe is pending, it shows Up to date: every recipe on the classpath has run.
With --allow-dirty, the doctor does not commit the files that had changes before it started.
If a recipe changes one of these files, the doctor puts back the files that the recipes changed and the ledger,
as they were before the recipes ran, with your changes, and fails. The recipes stay pending.
Commit or stash your changes and run the doctor again, or add --no-commit.
Outside a git repository, the doctor changes the files but commits nothing.
| Option | Effect |
|---|---|
--recipe=<name> | Runs only this pending recipe. Repeat the option to name more recipes. They run in their usual order. |
--recipe=<name> --acknowledge="<reason>" | Records the recipe in the ledger as applied by hand, for this reason, and does not run it. It does not run brightspotGradleRewrite. --acknowledge needs --recipe. |
--check | Shows the pending changes as a diff and fails when there are changes, but changes no file. |
--no-commit | Changes the files and the ledger, but commits nothing. |
--allow-dirty | Runs when the git working tree has changes. |
--skip-build | Repairs only the Gradle files, the dependencies, and the upgrade recipes. It skips the steps that compile or format the code: the configuration cache probe, Error Prone, the buildHealth advice, the properties file encodings, and Spotless. |
-Pbrightspot.doctor.gradle=false | Does not run brightspotGradleRewrite, and does not decide the configuration cache. |
A --recipe name that is not pending fails with These recipes are not pending, followed by the pending recipes.
A recipe runs only on Java sources.
If no subproject has Java sources, the recipe stays pending, and the doctor shows a warning.
To record it, use --acknowledge.
Upgrade recipe ledger
gradle/brightspot.rewrite.properties records the upgrade recipes that the build has run, by name. Commit it.
1# Recipes this project has run, kept by the Brightspot rewrite tasks. Commit this file.2recipe.com.example.MigrateOldType=run3recipe.com.example.RenameMethod=acknowledged\: Changed by hand
- The value is
runfor a recipe that a task ran, andacknowledged: <reason>for a recipe that--acknowledgerecorded. The:has a\before it, as in all.propertiesfiles. - The ledger is at the root of the build, and applies to all subprojects. A recipe runs once per build, identified by its name, whichever version of a library brings it.
brightspotRewritecreates the ledger when it runs or acknowledges the first recipe.- Without a ledger, every recipe on the classpath is pending. A recipe changes only code that uses the old API, so code that does not use it stays the same.
- The lines are sorted by name, so that merges seldom conflict.
brightspotRewrite
Runs the pending upgrade recipes on the Java sources of the main and test source sets of every Java subproject.
1./gradlew brightspotRewrite
Usually, run brightspotDoctor, which runs this task and commits its changes.
It does these steps:
- It finds the recipes on the classpath that the ledger does not have, or only the recipes that you name. The recipes of a library run in the order that the library declares them.
- It runs them on the code as it is, and writes the changed files. It does not change files that git ignores, or files in a build directory.
- It sorts the imports of each file that a recipe changes, in the import layout that the project already uses. If it finds no layout, it does not change the imports. It never replaces imports with a wildcard import.
- It records the recipes in the ledger.
- It writes a record of what each recipe changed to
build/brightspotRewrite/record/record.json.brightspotDoctorreads the record to make its commits.
- It does not commit, does not examine the git working tree, and does not run
brightspotGradleRewrite. - It works with the configuration cache.
| Option | Effect |
|---|---|
--recipe=<name> | Runs only this pending recipe. Repeat the option to name more recipes. They run in their usual order. |
--recipe=<name> --acknowledge="<reason>" | Records the recipe in the ledger as applied by hand, for this reason, and does not run it. --acknowledge needs --recipe. |
--check | Shows the pending changes as a diff and fails when a recipe is pending, but changes no file. |
Advice
At the end of the build, after the output of every task, the plugins show one block of advice:
1======================== Advice from Brightspot ========================2Brightspot upgrades are available:3com.psddev:brightspot-bom 5.0.8 -> 5.0.9 patch4with com.psddev:brightspot-dependencies56Apply: ./gradlew brightspotUpgrade78See build/reports/brightspotUpgrade/report.txt9------------------------------------------------------------------------10The Gradle files do not follow the Brightspot Gradle Plugin conventions.1112Apply: ./gradlew brightspotDoctor13------------------------------------------------------------------------14Relocated dependencies in :core:15These dependencies moved to new coordinates.16A future release removes the old coordinates.17Declare the new coordinates, and each dependency listed as missing.1819com.psddev:dari-util20moved to com.brightspot.util:web-util:1.1.12122Apply: ./gradlew :core:relocateApply23------------------------------------------------------------------------24Enforced BOMs hold back requested dependency versions (1):2526com.zaxxer:HikariCP: 7.0.2 -> 3.4.527com.brightspot.db:db:3.1.1 wants 7.0.2, but28com.psddev:brightspot-dependencies:5.0.9 enforces 3.4.52930To use a requested version, pin it in settings.gradle:31brightspot {32dependencies {33pins {34upgrade 'com.zaxxer:HikariCP:7.0.2'35}36}37}38To raise the version in the BOM, contact the maintainers of:39com.psddev:brightspot-dependencies:5.0.940To stop reporting a module, add it to enforcedBomDowngradeExclusions.41========================================================================
- In the
enforcedBomDowngradesection,7.0.2 -> 3.4.5means the requested version, then the version that the enforced BOM holds the module at. The section ends with what to do instead of anApply:line, andbuild/reports/enforced-bom-downgrade.txthas the details. - A line of
-separates the sections, one for each kind of advice. A task that runs in several projects, such asenforcedBomDowngradein each WAR project, gives one section for all of them. - Each instruction is on a line of its own:
Apply: ./gradlew <task>for a task that changes the build,Run: ./gradlew <task>for one that changes nothing. - The banner is red, and each command is bold; see
brightspot.color. - The text wraps at spaces to the width of the terminal, and the banner is as wide as the longest line. A command never breaks.
The width is the
COLUMNSenvironment variable when the shell exports it, elsebrightspot.columns, else 80. - The advice comes from the tasks that ran:
brightspotUpgradeCheck,brightspotGradleUpgradeCheck,brightspotGradleRewriteCheck,relocationDependencyCheck,enforcedBomDowngrade, andvalidateEncoding. A task that was up to date or came from the build cache gives its advice too. - When a task fails, the block shows only the advice of the failed tasks, before the failure. When nothing has advice, the build shows no block.
brightspotUpgradeCheck
Lists the newer versions of the BOMs and other versions that settings.gradle declares. It never changes a file and never fails the build.
It runs before every Java compilation, from the root project.
It reads the root settings.gradle. It does not read a settings.gradle.kts file or the version catalog.
It checks these versions:
- The
platform(...)andenforcedPlatform(...)BOMs of thedependenciesblock. The BOMs that the main list of the upgrade policy names are in the main list. The other BOMs are in the second list. - The versions of
pinsandconstraints, and the target versions ofsubstitutions, in the second list.
A version can be a property of gradle.properties, such as "com.psddev:brightspot-bom:$brightspotVersion".
The check finds the versions through the repositories of the build, with their credentials.
Gradle keeps the list of versions for one hour, or for brightspot.upgradeCheck.cacheTime,
so a new release can take that long to show. Until then the check makes no network request.
--refresh-dependencies gets a new list, and brightspotUpgrade always gets a new list before it upgrades.
With --offline, the check uses the list that Gradle has kept.
A module that it cannot check, for example offline with no kept list, is counted as "could not be checked", and the build continues.
Parent BOMs
The check reads the POM of each declared BOM, with the BOMs it imports, at its current version and at each version it can be upgraded to.
A declared BOM that manages another declared module or BOM is a parent. For example, com.psddev:brightspot-dependencies imports the BOMs of
com.brightspot.ai, com.brightspot.db, and com.brightspot.ui, so it is the parent of the constraints and BOMs of those groups.
The check compares each other declaration with the version that its parent manages after the upgrade:
-
If the declaration is at that version or below it,
brightspotUpgradedoes not upgrade it.- When
brightspotUpgrademoves the parent, it removes the declaration if the declaration was at or above the version that the parent managed before, so that the parent manages the version. See step 7 ofbrightspotUpgrade. A declaration below that old version is a downgrade, and stays. - Without an upgrade, the doctor removes a declaration at the parent's version,
and keeps one below it as a
downgrade.
The doctor keeps a version that chooses between BOMs that manage different versions, a
downgrade, a constraint on the target of a substitution, and every substitution. - When
-
If the declaration is above that version, or the doctor keeps it, its newer versions show under "Other upgrades (not recommended)".
brightspotUpgradechanges it only when you name it with--module.
Thus the BOMs manage as many versions as they can, and the overrides go away over time.
brightspotUpgrade changes a declaration that no parent manages, such as a library that the BOMs do not include, only when you name it with --module.
The check also reads the versions in the build.gradle file of each project (Groovy only).
It does not upgrade them. It counts the versions that a parent BOM manages after the upgrade.
Without an upgrade, the doctor removes a version at the parent's version, keeps one below it as a downgrade,
and asks why one above it differs. After an upgrade, brightspotUpgrade removes the versions at or above those that the BOM managed before the upgrade:
13 versions in build files are managed by com.psddev:brightspot-dependencies:5.0.8; brightspotUpgrade removes those at or above the versions in com.psddev:brightspot-dependencies:5.0.4, and brightspotDoctor allows those below them or asks why they differ.
Output
At the end of a build that runs the check, after the output of the other tasks, the build shows the upgrades:
1Brightspot upgrades are available:2com.psddev:brightspot-bom 5.0.4 -> 5.0.8 patch3with com.psddev:brightspot-dependencies4com.brightspot.shared-tests:bom 1.5.8 -> 1.6.1 minor56Apply: ./gradlew brightspotUpgrade78Upgrades you can choose:9com.psddev.migration:bom + com.psddev.migration:dependencies 2.3.410minor 2.4.0 ./gradlew brightspotUpgrade --module com.psddev.migration:bom --minor111220 versions are managed by com.psddev:brightspot-dependencies:5.0.8; brightspotUpgrade removes those at or above the versions in com.psddev:brightspot-dependencies:5.0.4, and brightspotDoctor allows those below them.133 versions in build files are managed by com.psddev:brightspot-dependencies:5.0.8; brightspotUpgrade removes those at or above the versions in com.psddev:brightspot-dependencies:5.0.4, and brightspotDoctor allows those below them or asks why they differ.14154 other upgrades are available.161 module could not be checked.17See build/reports/brightspotUpgrade/report.txt1819The Brightspot plugins 3.15.0 are available; this build uses 3.14.2.2021Apply: ./gradlew brightspotUpgrade2223The Gradle files do not follow the Brightspot Gradle Plugin conventions.2425Apply: ./gradlew brightspotDoctor
"Upgrades you can choose" lists the modules of the main list whose level allows no upgrade, with the commands for the higher levels.
The last two lines come from brightspotGradleUpgradeCheck and brightspotGradleRewriteCheck.
This text is part of the advice at the end of the build.
build/reports/brightspotUpgrade/report.txt has the full list:
1Overrides with newer versions:2bom com.example.cms:bom 1.2.0 patch 1.2.3 minor 1.4.13constraint com.fasterxml.jackson.core:jackson-databind 2.15.3 patch 2.15.4 minor 2.18.245Other upgrades (not recommended):6constraint org.yaml:snakeyaml 1.29 (com.psddev:brightspot-dependencies:5.0.8 manages 2.5) minor 1.33 major 2.778Versions that brightspotUpgrade removes:9constraint com.brightspot.ai:ai 3.1.0 (com.psddev:brightspot-dependencies:5.0.4 managed 3.0.0)1011Versions that brightspotUpgrade moves to the BOM's version:12constraint com.brightspot.go:go 2.3.1 (com.psddev:brightspot-dependencies:5.0.4 managed 2.3.0)1314Versions that brightspotUpgrade keeps:15site/build.gradle:14 com.brightspot.db:db 2.6.0 (com.psddev:brightspot-dependencies:5.0.4 managed 2.6.3)1617Could not check: com.example:private-bom (No repository lists this module)
"Overrides with newer versions" also lists the BOMs outside the main list, such as com.example.cms:bom.
"Versions that brightspotUpgrade removes", "moves to the BOM's version", and "keeps" list the versions that the upgraded BOMs manage, each with the version that the BOM managed before the upgrade
(step 7 of brightspotUpgrade).
A constraint is a pins entry, a legacy dependencyConstraints entry, or a constraints entry. A constraints entry is never under "removes".
To also list the release candidates of a newer version, run the check with --rc:
1./gradlew brightspotUpgradeCheck --rc
It does not list a version that is not a version number, such as the range [1.0,2.0).
It writes these files:
build/reports/brightspotUpgrade/report.json, for CI. For each module,upgradeshas the newestpatch,minor, andmajorversions, andautomaticis the version thatbrightspotUpgradesets with no options, which only a BOM of the main list has. A module that a parent manages hasmanagedBy,managedVersion, andredundant, which istruewhen the declaration can go: it is at the parent's version or, after an upgrade of the parent, at or below it. Of these,brightspotUpgraderemoves only the declarations that were also at or above the version that the parent managed before (step 7 ofbrightspotUpgrade); a declaration below it is a downgrade, and stays.availableis the number of modules with upgrades.buildFilePinslists the versions inbuild.gradlefiles that a parent manages, each with itsfile,line,managedBy, andmanagedVersion.build/reports/brightspotUpgrade/report.txt, the full list.
The check works with the configuration cache.
To keep the three checks that note upgrades out of compilation, set brightspot.upgradeCheck=false:
1./gradlew -Pbrightspot.upgradeCheck=false build
Which version is an upgrade
- A level is the highest change, and includes the lower levels:
patchis the newest version with the same major and minor numbers,minorthe newest with the same major number, andmajorthe newest version. - All numbers after the minor number are part of the patch:
4.1.112.1.Finalis a patch upgrade of4.1.112.Final. - An upgrade keeps the text after the numbers, such as
.Finalor-jre:32.1.3-jrenever moves to33.0.0-android. - A release never moves to a pre-release, such as
5.0.9-rc.1, unless you add--rctobrightspotUpgrade. - A pre-release moves to its release, such as
5.0.9-rc.1to5.0.9. If there is no release yet, it moves to a newer pre-release of the same version, such as5.0.9-rc.2. A suffix that starts withrc,cr,beta,alpha,pre, orMand a number marks a pre-release. - A suffix that no other published version shares, such as
-hotfix.1in5.0.4-hotfix.1, is a branch tag, not a text such as-jre. The version counts as a pre-release of5.0.4, so it moves to the main line like one. - Pull request, snapshot, and local builds, such as
5.0.9-pr.12.3,5.0.9-SNAPSHOT, or5.0.9-local.1, are never upgrades.
brightspotUpgrade
Sets the versions that brightspotUpgradeCheck lists, commits each upgrade,
and then runs brightspotDoctor, which repairs the build for the new versions.
1./gradlew brightspotUpgrade
It does these steps:
- It fails if the git working tree has changes, or if the Gradle files do not follow the conventions
that
brightspotGradleRewriteCheckchecks: then runbrightspotDoctorfirst. - It moves the build to the latest release of the plugins, as
brightspotGradleUpgradedoes, and commits it asbuild(deps): upgrade com.brightspot.gradle from <old> to <new>. Then it runsbrightspotDoctorandbrightspotUpgradeof the new release in second builds, and stops: the new release does the next steps. To keep the current release, add--no-plugin.-Pbrightspot.doctor.version=<version>moves to that release instead of the latest one. - It chooses the versions. With no options, it moves only the BOMs of the main list of the upgrade policy,
in the order of the list, each to its
automaticversion: the newest version within the level that the policy gives it. It moves no other declaration: the others are overrides or other libraries, which only--moduleupgrades. It does not change a module that a parent BOM manages. - It changes the version in
settings.gradle, or ingradle.propertieswhen a property holds it. - It commits each upgrade, such as
feat(deps): upgrade com.brightspot.db:bom from 3.2.0 to 3.3.0. Modules that share a property ofgradle.propertiesare in one commit. - It keeps the versions that the upgraded BOMs no longer manage, where a module would not resolve without them,
and commits this as
feat(deps): keep the versions the upgraded BOMs no longer manage. A version is kept for a module that the build declares without a version when no other module pulls it in, or when the upgrade moves every module that pulls it in, since their new versions may not. The upgrade adds aconstraintsentry at the version the old BOM managed, with a reason:A module that1implementation('com.example:some-library:1.4.0') { because 'com.example:bom:2.0.0 managed 1.4.0; the upgraded BOMs no longer manage it' }pinsalready holds keeps its pin. When the doctor wrote the pin's reason, the reason changes to this one. Every other module that the BOMs no longer manage takes the version that Gradle resolves from the modules that ask for it. - It removes the overrides that the upgraded BOMs moved over, and commits this as
feat(deps): remove the overrides the upgraded BOMs moved over. An override goes when it was at or above the version that its parent BOM managed before, and the parent now manages its module at or above it:- An
upgradeentry ofpins, and a legacydependencyConstraintsentry, go. - A
constraintsentry moves to the BOM's version, for the configurations that the BOMs do not reach. - In the
build.gradlefile of a project that gets the BOMs, a version goes, and the dependency stays without one. - A BOM of a
build.gradlefile goes when the parents manage every module of it that the build resolves. Otherwise, anenforcedPlatformBOM whose modules the parents managed before becomes aplatform. - A
substitutionsentry stays: its target version is only a lower bound, so the BOM's higher version wins.
- An
- It runs
brightspotDoctorin a second build, which reads the new versions. The doctor runs the upgrade recipes and makes its own commits.
If a module does not resolve after the upgrade, the doctor stops and lists it under "Does not resolve", with the BOM that manages it and this hint:
1brightspotUpgrade changed the versions before this check, so the upgrade can be the cause; if the module resolved before the upgrade, pin the version it had then.
brightspotUpgrade then fails with brightspotDoctor failed on the upgraded build. The upgrade commits stay.
Run ./gradlew dependencyInsight --configuration <configuration> --dependency <module> to see why the module does not resolve.
If it resolved before the upgrade, add a pin at the version it had then, with a reason, commit it,
and run brightspotDoctor again.
If there is nothing to upgrade, it shows Nothing to upgrade. and does not run the doctor.
When a BOM of the main list is not on a release and no release within its level is newer, it stays, with a warning:
1com.psddev:brightspot-bom, com.psddev:brightspot-dependencies stays at 5.0.9-rc.1, which is not a release: no release within the policy's level is newer.
| Option | Effect |
|---|---|
--module=<group:name> | Upgrades only this module, to the level of the upgrade policy unless a level option follows. Repeat the option to name more modules. Any module that the check lists is allowed. |
--patch, --minor, --major | Upgrades the modules named with --module to this level, not to their automatic version. Use one of them only, with --module. |
--rc | Also upgrades to the release candidates of a newer version, within the level. A release that is newer than the release candidate wins. |
--no-commit | Changes the files but commits nothing. The doctor runs with --no-commit --allow-dirty. |
--allow-dirty | Runs when the git working tree has changes. Files that had changes before the run are not committed. |
--no-plugin | Keeps the current release of the plugins: does not do step 2. |
--skip-build | Runs brightspotDoctor with --skip-build, which skips the steps that compile or format the code. |
1./gradlew brightspotUpgrade --module=com.example.cms:bom --minor2./gradlew brightspotUpgrade --module=com.psddev:brightspot-bom --patch --rc
A --module that the check does not list fails with <module> is not a monitored dependency, followed by the modules that the check lists.
A --module that a parent BOM manages at its version or above, after this upgrade, is not changed: a warning says that the doctor removes it.
Upgrade policy
The plugins hold the policy that tells brightspotUpgrade which BOMs are in the main list, and how far to upgrade each module.
The two settings are separate: the list a module is in does not change its level.
A new release of the plugins can change the policy. A project cannot change it.
The main list, in the order that brightspotUpgrade moves them:
com.psddev:brightspot-bomandcom.psddev:brightspot-dependenciescom.brightspot.go:bomandcom.brightspot.go:go-dependenciescom.psddev.component-lib:bomandcom.psddev.component-lib:cl-dependenciescom.brightspot.shared-tests:bomcom.psddev.migration:bomandcom.psddev.migration:dependencies- The
com.brightspot.dependenciesBOMs whose name starts withbom-, such asbom-java21
The levels:
- The Brightspot BOMs
com.psddev:brightspot-bomandcom.psddev:brightspot-dependenciesof 4.8 and 5.0 get patch upgrades. Any other line, such as 4.7 or 5.1, also gets patch upgrades, and stays in the main list. com.brightspot.go:bomandcom.brightspot.go:go-dependenciesget patch upgrades.com.psddev.component-lib:bomandcom.psddev.component-lib:cl-dependenciesget patch upgrades.com.psddev.migration:bomandcom.psddev.migration:dependenciesget patch upgrades.- Other modules whose group starts with
com.brightspotget minor upgrades, andcom.brightspot.cms-search-boostmodules get major upgrades. - A module that the policy does not configure gets patch upgrades from
brightspotUpgrade --module. The check shows its other levels: under "Upgrades you can choose" for a BOM of the main list, and inreport.txtfor the others.
Some BOMs always move together, to one version, in one commit:
com.psddev:brightspot-bomwithcom.psddev:brightspot-dependenciescom.brightspot.go:bomwithcom.brightspot.go:go-dependenciescom.psddev.component-lib:bomwithcom.psddev.component-lib:cl-dependenciescom.psddev.migration:bomwithcom.psddev.migration:dependencies
--module with one of them upgrades both. The version is the newest that both have.
Plugin projects
This section applies only to projects that publish libraries or plugins as JAR files to Artifactory.
Do not set plugin = true in a delivery project, meaning a project that builds a WAR file to run on Tomcat.
plugin
Marks the build as a plugin project; defaults to false. Plugin projects require Gradle 8.11.1 or higher.
1brightspot {2plugin = true3}
It applies the following:
- Error Prone and NullAway, which inspect code marked with
@NullMarked. WAR subprojects are skipped. - Spotless, which enforces formatting.
- A Java 21 toolchain for compilation, and a Javadoc JAR.
- The JUnit Platform for all test tasks.
- Dependency analysis, as
buildHealthincheck. Any reported issue fails the build, and the advice at the end of the build says to runbrightspotDoctor, which applies the analysis' advice. - The bundled Checkstyle configuration, in place of the project's
etc/checkstyle/checkstyle.xml. - SonarQube and JaCoCo.
- The
bomOverlapcheck.
It changes these defaults:
versions.enforcePlatformis false, so BOM versions do not become hard requirements for the projects that consume the plugin.versions.projectis9999-SNAPSHOT, so local subprojects win version conflicts against published artifacts.
It turns off these features, which are for delivery projects:
- Shared tests
- Git hash versioning
- The
versionConsistency,versionDowngradeCheck,enforcedBomDowngrade, andrelocationDependencyCheckchecks
Declare the BOMs in the dependencies block with platform, not enforcedPlatform.
A published library must not force versions onto the projects that consume it.
1brightspot {2plugin = true3projectGroup = 'com.brightspot.example'45versions {6java = 217}89dependencies {10api platform('com.brightspot.dependencies:bom:2.0.1')11api platform('com.psddev:brightspot-bom:4.8.19')12api platform('org.junit:junit-bom:5.14.4')1314constraints {15api 'org.apache.solr:solr-solrj:9.10.1'16}17}18}
testConfigFile
The config file to include in the JAR as brightspot-test-config.properties.
The WAR's tests combine these files from the JARs on the runtime classpath.
Relative paths start from <rootDir>/docker.
Defaults to <project-name>.properties. If that default file does not exist, the plugin skips it.
Applies only to com.brightspot.java-library subprojects.
1brightspot {2testConfigFile = 'example.properties'3}
sonarProjectKey
The sonar.projectKey; defaults to perfectsense:<root project name>.
1brightspot {2sonarProjectKey = 'perfectsense:example'3}
Formatting and static analysis
Spotless enforces import order, removes unused imports, applies the bundled Eclipse formatter configuration, trims trailing whitespace, and runs a set of CleanThat mutators. To apply the formatting:
1./gradlew spotlessApply
After the Eclipse formatter, Spotless makes two more changes:
- It keeps a jspecify
@Nullableor@NonNullon the same line as the type it annotates, after the modifiers, such aspublic static @Nullable String find(). It changes only the jspecify annotations: those that the file imports fromorg.jspecify.annotations, or that it writes with that package. - It adds a blank line after an opening brace that is not on the line where its declaration or statement starts,
such as the brace after a wrapped method signature or
ifcondition. The body then does not line up with the last line of the header, which has the same indent. Lambdas, anonymous classes, and array initializers keep their braces as they are.
The formatter does not join consecutive line comments.
Plugin 3.14.0 added these rules, so the first spotlessApply after an upgrade to it changes many files.
Until that runs, spotlessCheck fails the build.
brightspotDoctor runs spotlessApply and commits the result.
Error Prone runs NullAway, which reports errors, not warnings.
It inspects only code marked with @NullMarked.
To use either one in a build that does not set plugin = true, apply it in the subproject:
1plugins {2id 'com.brightspot.spotless'3id 'com.brightspot.error-prone'4}
Publishing upgrade recipes
A library can publish OpenRewrite recipes that change the code of the projects that use it,
across a breaking change such as a renamed class or method.
Those projects run the recipes with brightspotDoctor.
Put the recipes in the src/rewrite directory of a java-core, java-library, or war subproject.
The plugins then do the following:
- Add the
rewritesource set, which compiles for Java 11 againstorg.openrewrite:rewrite-java. The plugins set the OpenRewrite version. - Add the
rewriteTestsource set for recipe tests, withorg.openrewrite:rewrite-testand JUnit 5. TherewriteTesttask runs the tests as part ofcheck. - Publish the recipes in a jar with the
rewriteclassifier, and add thebrightspot.rewriteproperty to the POM. - Add the list of recipes to the main jar, so that the
brightspotRewriteCheckof a project finds them without running them.
The recipes run in a JVM that holds only the JDK, OpenRewrite, and the recipe jars. A recipe cannot use other libraries.
brightspotRewrite
Lists each entry recipe of the subproject, in the order that the recipes run; required.
An entry recipe is a recipe in src/rewrite that no other recipe in src/rewrite lists.
1brightspotRewrite {2recipe 'com.example.MigrateOldType', parseAgainst: ['com.example:example-lib:1.0.0']3recipe 'com.example.RenameMethod'4}
Give parseAgainst to a recipe that changes types that the new version of a library removed.
Its values are the group:name:version of the artifacts that still have those types.
The recipe then finds the old types in the code of a project that already uses the new version.
Do not give parseAgainst to other recipes.
The build fails when this block and src/rewrite do not agree.
If the block lists a recipe that src/rewrite does not define, correct or remove it.
If src/rewrite defines an entry recipe that the block does not list, the build shows the block to use,
with a placeholder for parseAgainst:
1:example defines recipes that its brightspotRewrite block does not list: [com.example.RenameMethod].23List every recipe in the order they must run. Give each one that rewrites types a newer version removed the artifact that still has them, as parseAgainst, and leave parseAgainst out for the others. Then the build script of :example has:45brightspotRewrite {6recipe 'com.example.MigrateOldType', parseAgainst: ['com.example:example-lib:1.0.0']7recipe 'com.example.RenameMethod', parseAgainst: ['group:name:old-version']8}
Writing a migration recipe
- Change only the files that use the old API.
Do not include a recipe that changes every file, such as
OrderImportsor a formatter.brightspotRewritesorts the imports of each file that a recipe changes. - Make sure that the recipe does not change code that is already migrated. A project without a ledger runs every recipe on its classpath.
- Do not rename a published recipe. The ledger identifies a recipe by its name, so a recipe with a new name runs again in every project.
- Test each recipe in
src/rewriteTest.
requiredPluginVersion
The minimum version of these plugins that the projects that use the artifact need, as major.minor.patch.
Set it in the build.gradle of the BOM subproject, so that every project that imports the BOM gets the requirement.
For example, set it when the library publishes upgrade recipes.
1plugins {2id 'java-platform'3}45javaPlatform {6allowDependencies()7}89brightspot {10requiredPluginVersion = '3.14.0'11}
A build with an older version of the plugins, or without the plugins, fails to resolve the BOM, with this reason:
1com.example:bom:1.2.0 needs brightspot-gradle 3.14.0 or newer. In settings.gradle, set the version of the com.brightspot.gradle plugin to 3.14.0 or newer.
The requirement is a dependency on com.brightspot.gradle.requires:brightspot-gradle, which is never published.
The plugins remove it from the BOM when their version is the same or newer.
A pre-release, such as 3.14.0-rc.1, counts as the release it leads to.
Do not resolve the BOM in the build that publishes it, for example with platform(project(':bom')),
because there the build fails in the same way.
Bundle
These settings go in each bundle's build.gradle file (typically under frontend/bundles/),
in the bundle block.
yarnBuildCommand
The Yarn script that builds the bundle, from "scripts" in package.json; required.
Typically 'build'.
styleguideOutputDir
The styleguide output directory, relative to the subproject's build directory; required.
Typically 'styleguide'. The value usually comes from the build script in package.json.
zipOutputPath
The bundle .zip file, relative to the subproject's build directory; required.
Typically 'theme.zip'. The value usually comes from the build script in package.json.
1bundle {2yarnBuildCommand = 'build'3styleguideOutputDir = 'styleguide'4zipOutputPath = 'theme.zip'5}
cdnCssFiles
CSS files for CdnCssTest to test, relative to the root of the generated .zip file.
1bundle {2cdnCssFiles = [3'styles/default/All.min.css'4]5}
testMode
The mode for ThemeCompatibilityTest:
'disable', 'error', or 'warn'; defaults to 'error'.
1bundle {2testMode = 'warn'3}
compatibilityTestExcludedPaths
JSON files that ThemeCompatibilityTest skips, relative to the root of the generated .zip file. ThemeCompatibilityTest also skips all files that are not in the styleguide navigation.
1bundle {2compatibilityTestExcludedPaths = [3'path/to/some/ignored/file.json'4]5}
Root styleguide dependency
The root styleguide that ThemeCompatibilityTest uses.
Defaults to the single subproject that applies com.brightspot.viewgen.
If the default does not work, examine your Gradle setup for an error.
1dependencies {2rootStyleguide project(path: ':frontend', configuration: 'rootStyleguideDir')3}
Viewgen
These settings go in frontend/build.gradle, in the viewgen block.
styleguideDir
The root styleguide directory, relative to the subproject directory; defaults to 'styleguide'.
1viewgen {2styleguideDir = '../styleguide'3}
WAR
These settings go in web/build.gradle (or site/build.gradle), in the brightspotWar block.
Put a war { } block after the brightspotWar { } block.
applyDefaultExclusions
Whether to exclude the default set of JAR files that Tomcat provides; defaults to true.
If false, you must exclude everything that Tomcat provides.
Projects on Brightspot Cloud can use the default.
Projects not on Brightspot Cloud must not exclude slf4j-api.
1brightspotWar {2applyDefaultExclusions = false3}
The default exclusions are:
1war {2rootSpec.exclude '**/javax.el-api'3rootSpec.exclude '**/javax.servlet-api-*.jar'4rootSpec.exclude '**/javax.servlet.jsp-api-*.jar'5rootSpec.exclude '**/mysql-connector-java-*.jar'6rootSpec.exclude '**/slf4j-api-*.jar'7rootSpec.exclude '**/slf4j-jdk14-*.jar'8}
cmsWarDestinationDirectory
The directory in the WAR file for the contents of the cms-tool-ui WAR file,
which contains the Brightspot CMS interface; defaults to 'cms'.
It must match the dari/routingFilter/applicationPath/cms setting in context.xml, if that setting exists.
1brightspotWar {2cmsWarDestinationDirectory = 'customCmsLocation'3}
WAR file name
For regular builds, the WAR file name does not include the version, which keeps the local Docker Compose configuration simple. For release builds, the WAR file name includes the release version.
Jakarta EE substitution
Tomcat 10.1 and higher require Jakarta EE in place of Java EE.
The com.brightspot.jakarta-substitution plugin rewrites the javax namespace to jakarta
in everything the WAR file contains, as a temporary measure until the code is migrated.
Apply it in the same build.gradle file as com.brightspot.war, without a version:
1plugins {2id 'com.brightspot.war'3id 'com.brightspot.jakarta-substitution'4}
The migration runs as the WAR file is packaged. Each dependency JAR is migrated once and cached by its content.
Tests
In a plugin project, every Test task runs on the JUnit Platform; in other projects, the test task does. Every Test task has a heap of brightspot.test.maxHeapSize.
When the test runtime classpath has a JUnit Platform engine but no junit-platform-launcher,
the plugins add the launcher at the version of the engine.
Gradle 9 no longer supplies the launcher itself.
When the test runtime classpath has mockito-core, each test worker starts with that JAR as a Java agent,
so Mockito does not attach itself at run time. Newer JDKs warn about, and will block, an agent that attaches at run time.
Nothing is added when the JAR is not an agent, as in old Mockito versions,
or when the task already names a Mockito agent in its JVM arguments.
To turn off the agent, set brightspot.test.mockitoAgent=false.
Shared tests
These settings go in any build.gradle that applies com.brightspot.shared-tests,
in the sharedTests block.
scope
Which classes the shared tests examine; defaults to 'current'.
With 'current', each subproject's shared tests examine only that subproject's classes.
With 'project', the shared tests examine every class the subproject depends on in the build.
Use 'project' on a subproject that aggregates others, such as a pack,
to run one test task in place of one per subproject.
1sharedTests {2scope = 'project'3}
classesDirs
The compiled classes to run shared tests against;
defaults to the main source set output, or the enhanced-classes directory when class enhancement applies.
Paths must be relative to the subproject directory, for cacheability.
1sharedTests {2classesDirs = [3project.getProjectDir().toPath().relativize(project.getBuildDir().resolve('classes').resolve('java').resolve('main'))4]5}
allClassesDirs
The compiled classes for the whole build, from the runtimeClasspath configuration,
filtered to the JARs of subprojects in the build.
Publishing
These settings go in the gitHashVersion block of a subproject that uses BOM versioning.
commitCountOffset
A number to add to the commit count. Use it when a subproject moves to a different location in its Git repository, which resets its commit count.
commitCountPrefix
Text immediately before the commit count.
A prefix of 14 and a commit count of 123 give a version such as 1.2.14123-xabcdef.
Use it to keep a version line sorting above versions from an earlier numbering scheme.
additionalPaths
Directories whose commits count toward the subproject's version, for a subproject whose published artifact changes when another directory changes.
1gitHashVersion {2commitCountOffset = 13commitCountPrefix = '14'4additionalPaths.from(rootProject.file('shared'))5}
SonarQube
com.brightspot.gradle configures SonarQube for every project. Do not declare anything.
For a delivery project, it applies com.brightspot.sonar, which configures:
- The root project, with the
sonartask and asonar.projectKeyofperfectsense:<root project name>. - Each
java-coresubproject, whose tests run with JaCoCo. Each test run writes the coverage report tobuild/reports/jacoco/test/jacocoTestReport.xml, which the analysis reads. - Each bundle subproject, whose sources are the subproject directory.
For a plugin project, see Plugin projects.
The build task does not run the analysis. Run it as a separate step, after the tests:
1./gradlew build2./gradlew sonar
A settings.gradle that still declares com.brightspot.sonar builds without an error. Remove the declaration.
Do not declare the org.sonarqube plugin with a version in a build.gradle.
The plugins already supply it, and Gradle rejects a version for a plugin that is already on the classpath.
Build scans
The plugins apply Develocity and accept its terms of use for every project.
A build publishes a scan only when you pass --scan.
Scans go to the public gradle.com endpoint.
--scan requires Gradle 8.8 or higher.
For --scan, lower versions of Gradle apply the older Gradle Enterprise plugin,
which cannot run alongside the Develocity plugin.
On those versions, a build with --scan stops with a message that states the requirement.
Builds without --scan are not affected.
Do not declare the com.gradle.develocity or com.gradle.enterprise plugin.
If the build declares com.gradle.enterprise, the plugins keep it, and brightspotGradleRewriteCheck
advises brightspotDoctor, which removes it.
Configuration cache
To use Gradle's configuration cache,
use Gradle 8.14 or higher.
On lower versions, the Checkstyle task's configuration cannot be read from the cache
when org.gradle.parallel or org.gradle.priority is set. The build fails with
Could not load the value of field 'aliasSet' of 'sun.nio.cs.UTF_8'.
The brightspotGradleRewrite task turns the configuration cache on or off in gradle.properties,
from a test build of the project. brightspotDoctor commits that change before the recipe commits.
These tasks work with the configuration cache on: brightspotDoctor, brightspotGradleUpgrade, brightspotGradleRewrite,
brightspotRewrite, brightspotUpgrade, and the checks brightspotUpgradeCheck, brightspotGradleUpgradeCheck,
brightspotGradleRewriteCheck, and brightspotRewriteCheck.