cds:watch
Full name:
com.sap.cds:cds-maven-plugin:5.1.1: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.
Fast mode
By default, this goal launches the application with the full Maven lifecycle. For a much faster inner-loop, set the property
-Dfast (or -Dfast=true) on the command line. In fast mode, the goal resolves the runtime classpath directly from the Maven project model and spawns the application as a plain java -cp ... <mainClass> process.
Note: This goal can only be executed from the command line.
Attributes:
- Requires a Maven project to be executed.
- 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,**/genUser Property: cds.watch.excludes |
<fast> |
boolean |
5.1.0 |
Enables a fast inner-loop mode that skips the Spring Boot Maven plugin and the surrounding Maven lifecycle. The application is started as a plain java -cp ... <mainClass> process using the runtime classpath of the service module.
Requires the project to have been built at least once (so Default: falseUser Property: fast |
<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,**/*.csvUser Property: cds.watch.includes |
<incrementalGoals> |
List<String> |
5.1.0 |
A comma separated list of goals to execute when a watched file is changed. Only these goals are re-run on every file change. Default: cds,generateUser Property: cds.watch.incrementalGoals |
<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: falseUser Property: testRun |
Optional Parameters
| Name | Type | Since | Description |
|---|---|---|---|
<goals> |
List<String> |
3.8.0 |
The list of goals to execute in the specified order. Default: install-node,npm,resolve,cds,generateUser Property: goals |
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.
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
<fast>
Enables a fast inner-loop mode that skips the Spring Boot Maven plugin and the surrounding Maven lifecycle. The application is started as a plain
java -cp ... <mainClass> process using the runtime classpath of the service module.
Requires the project to have been built at least once (so target/classes and the local Maven repository are populated).
- Type:
boolean - Since:
5.1.0 - Required:
Yes - User Property:
fast - Default:
false
<goals>
The list of goals to execute in the specified order.
- Type:
java.util.List<java.lang.String> - Since:
3.8.0 - Required:
No - User Property:
goals - Default:
install-node,npm,resolve,cds,generate
<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.
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
<incrementalGoals>
A comma separated list of goals to execute when a watched file is changed. Only these goals are re-run on every file change.
- Type:
java.util.List<java.lang.String> - Since:
5.1.0 - Required:
Yes - User Property:
cds.watch.incrementalGoals - Default:
cds,generate
<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