cds:watch

Full name:

com.sap.cds:cds-maven-plugin:3.6.0:watch

Description:

Starts a CAP Java application and watches for changes in the CDS model. If changes are detected, a cds:build is performed and the application is automatically restarted. Call mvn cds:watch or mvn com.sap.cds:cds-maven-plugin:watch to start the CAP Java application.

With Spring Boot Developer Tools
In order to get even faster development cycles locally, add an optional dependency to the Spring Boot Developer Tools in the pom.xml:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-devtools</artifactId>
  <optional>true</optional>
</dependency>
In this case the watch goal leaves the restart of the application to the Developer Tools, which is faster. The CAP Java application is started with a trigger file configured, used to signal the restart: --spring.devtools.restart.trigger-file=.reloadtrigger. The watch goal touches this trigger file after the cds:build is finished to signal the Spring Boot Developer Tools a safe application restart.
The trigger file is also touched, if any other file in the project has changed and no cds:build is performed. This behaviour ensures that the application is restarted, if a Java source file was changed in an IDE and a restart makes sense to test the changes.

Without Spring Boot Developer Tools
Without a dependency to the Spring Boot Developer Tools, this goal recognises all changes of included files and fully rebuilds and restarts the application.

Start test application
By default, this goal uses spring-boot:run to start the application, but it also supports running an optional test-application. This behaviour can be enabled by setting the property -DtestRun or -DtestRun=true at the Maven command line.

Note: This goal can only be executed from the command line.

Attributes:

  • Requires a Maven project to be executed.
  • Executes as an aggregator goal.
  • The goal is not marked as thread-safe and thus does not support parallel builds.
  • Since version: 1.17.0.

Required Parameters

Name Type Since Description
<excludes> List<String> - A comma separated list with GLOB pattern describing directories and files to be excluded from watching for changes. Changes on these files are generally ignored. In case Spring Boot Developer tools are used, changes on all non-excluded files in the project directory trigger an update of the trigger file.
See here for further details about the supported GLOB patterns.
Default: **/node_modules,**/target,**/gen
User Property: cds.watch.excludes
<includes> List<String> - A comma separated list of GLOB patterns describing files to be included in watching for changes. Changes on these files will trigger a cds:build. In case Spring Boot Developer tools are not used, changes of these files will also trigger an explicit rebuild and restart of the application.
See here for further details about the supported GLOB patterns.
Default: **/*.cds,**/*.csv
User Property: cds.watch.includes
<testRun> boolean 2.4.0 Indicates whether spring-boot:run or spring-boot:test-run is executed to start the application. If the property value is true, spring-boot:test-run is executed. Otherwise spring-boot:run is used.
Default: false
User Property: testRun

Parameter Details

<excludes>

A comma separated list with GLOB pattern describing directories and files to be excluded from watching for changes. Changes on these files are generally ignored. In case Spring Boot Developer tools are used, changes on all non-excluded files in the project directory trigger an update of the trigger file.
See here for further details about the supported GLOB patterns.
  • Type: java.util.List<java.lang.String>
  • Required: Yes
  • User Property: cds.watch.excludes
  • Default: **/node_modules,**/target,**/gen

<includes>

A comma separated list of GLOB patterns describing files to be included in watching for changes. Changes on these files will trigger a cds:build. In case Spring Boot Developer tools are not used, changes of these files will also trigger an explicit rebuild and restart of the application.
See here for further details about the supported GLOB patterns.
  • Type: java.util.List<java.lang.String>
  • Required: Yes
  • User Property: cds.watch.includes
  • Default: **/*.cds,**/*.csv

<testRun>

Indicates whether spring-boot:run or spring-boot:test-run is executed to start the application. If the property value is true, spring-boot:test-run is executed. Otherwise spring-boot:run is used.
  • Type: boolean
  • Since: 2.4.0
  • Required: Yes
  • User Property: testRun
  • Default: false