Package com.sap.cds.maven.plugin.build
Class WatchMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
com.sap.cds.maven.plugin.AbstractCdsMojo
com.sap.cds.maven.plugin.build.BuildMojo
com.sap.cds.maven.plugin.build.WatchMojo
- All Implemented Interfaces:
CdsMojoLogger
,org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AutoBuildMojo
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
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
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.
Note: This goal can only be executed from the command line.
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.
Note: This goal can only be executed from the command line.
- Since:
- 1.17.0
-
Field Summary
Fields inherited from class com.sap.cds.maven.plugin.AbstractCdsMojo
buildContext, CDS_SERVICES_GROUPID, mojoExecution, PLUGIN_KEY, project, session, settings
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.maven.shared.invoker.InvocationRequest
createRequest
(List<String> goals, String... optionalProperties) void
execute()
protected Process
executeMaven
(org.apache.maven.shared.invoker.InvocationRequest request) protected void
executeMojo
(org.apache.maven.model.Plugin plugin, String goal, org.apache.maven.model.PluginExecution pluginExec) protected org.apache.maven.plugin.descriptor.MojoDescriptor
getMojoDescriptor
(org.apache.maven.model.Plugin plugin, String goal) Methods inherited from class com.sap.cds.maven.plugin.build.BuildMojo
executeBuild, executeGoal
Methods inherited from class com.sap.cds.maven.plugin.AbstractCdsMojo
ensureCliExecuted, findGoalExecution, findSrvProject, getReactorBaseDirectory, isCliExecuted, logDebug, logDebug, logError, logError, logError, logInfo, logWarn, logWarn, logWarn, scanDirectory, setProperty, strong
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Constructor Details
-
WatchMojo
public WatchMojo() -
WatchMojo
protected WatchMojo(boolean noStart)
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException -
createRequest
-
executeMojo
protected void executeMojo(org.apache.maven.model.Plugin plugin, String goal, org.apache.maven.model.PluginExecution pluginExec) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
getMojoDescriptor
protected org.apache.maven.plugin.descriptor.MojoDescriptor getMojoDescriptor(org.apache.maven.model.Plugin plugin, String goal) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-