Skip to content

Useful build commands

Andy Wilkinson edited this page Sep 19, 2024 · 9 revisions

This page gathers some commands that are useful when working on the project.

Detect build wrapper

When working in a sub-module, the wrapper script defined at the root of the repository is not available. The following explains how to workaround that issue.

Gradle wrapper

Copy the following script in your environment, i.e. ~/bin/run-gradle.sh.

Then alias the script to make it easier to use. For instance to g:

alias g=~/bin/run-gradle.sh

You can now invoke Gradle anywhere using g, e.g. g build.

Maven Wrapper

Copy the following script in your environment, i.e. ~/bin/run-mvn.sh.

Then alias the script to make it easier to use. For instance to m:

alias m=~/bin/run-mvn.sh

You can now invoke Maven anywhere using m, e.g. m package.

Useful commands

This is a list of commands that we use often when working on the project. For convenience, both the Maven and Gradle commands are provided, when possible.

Run a specific test

The following command runs all the tests in the current module that start with Cassandra:

Gradle Maven

g test --tests 'Cassandra*'

m test -Dtest='Cassandra*'

Run bomr

To run Bomr, you need to have a ~/.bomr.properties file containing GitHub details:

bomr.github.username=myusername
bomr.github.password=github_pat_…

bomr.github.password should be a fine-grained personal access token. The token should have spring-projects as the resource owner, grant access to spring-projects/spring-boot with read and write permissions for issues and nothing more.

Upgrading to New Releases

To upgrade to new releases, use the bomrUpgrade task. A milestone must be provided using the --milestone option, for example:

For example:

$ ./gradlew --no-scan spring-boot-project:spring-boot-dependencies:bomrUpgrade --milestone=2.7.7

When working on a maintenance branch, you would typically merge forward using --strategy=ours:

$ git merge --no-ff 2.7.x --strategy=ours

Then you can run the command directly again on the later branch.

Moving to Snapshots

Note
Moving to snapshots is only intended for use on maintenance branches at this time. There is no support for mapping a snapshot (such as 6.1.0-SNAPSHOT) to a forthcoming release (such as 6.1.0-M2). Issue titles and commit messages will incorrectly state that the move to snapshots is for an upgrade to the final release version (such as 6.1.0).

To move to snapshots, use the moveToSnapshots task. A milestone must be provided using the --milestone option, for example:

$ ./gradlew spring-boot-project:spring-boot-dependencies:moveToSnapshots --no-scan --milestone 2.7.7

New snapshots in line with the configured upgrade policy will be suggested. https://calendar.spring.io is used to determine which snapshots will be released before the next Spring Boot release, filtering from the suggestions those that will not be released in time.

Generate a Configuration Properties Changelog

The tool for generating the changelog is part of Spring Boot’s build and can be run using Gradle:

$ ./gradlew spring-boot-project:spring-boot-tools:spring-boot-configuration-metadata-changelog-generator:generate -PoldVersion=<<oldVersion>> -PnewVersion=<<newVersion>>

For example, to generate a changelog for 3.1.0 using a diff with 3.0.7, run the following command:

./gradlew spring-boot-project:spring-boot-tools:spring-boot-configuration-metadata-changelog-generator:generate -PoldVersion=3.0.7 -PnewVersion=3.1.0

The changelog is written to spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata-changelog-generator/build/configuration-metadata-changelog.adoc.

Clone this wiki locally