Plugin Documentation

Goals available for this plugin:

Goal Description
cds:addIntegrationTest Add an integration test module to the current CAP Java project.
Call mvn com.sap.cds:cds-maven-plugin:addIntegrationTest to add an integration test module.
It automatically detects the OData version of the CAP Java project and adds the corresponding integration test class.

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

cds:addSample Add sample Java handler class, unit test, and CDS sample files to the current CAP Java project.
Call mvn com.sap.cds:cds-maven-plugin:addSample to add sample classes and CDS files.

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

cds:addTargetPlatform Add a target platform cds-starter-${targetPlatform} to the dependencies of the current CAP Java project if missing.
Call mvn com.sap.cds:cds-maven-plugin:addTargetPlatform -DtargetPlatform=cloudfoundry to add Cloud Foundry target platform.

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

cds:auto-build Performs an initial CDS build (same as mvn cds:build) and then watches for changes in the CDS model. If changes are detected, the CDS model is re-built automatically. In contrast to mvn cds:watch this goal does not start a CAP Java NG application.
Note: This goal can only be executed from the command line.

cds:build Performs a cds build with Java class generation by invoking the goals install-node, install-cdsdk, cds and generate of the cds-maven-plugin on current project. Any Java property that is provided on command line with option -D will be forwarded to the invoked goals.
Call mvn cds:build or mvn com.sap.cds:cds-maven-plugin:build to perform the cds build.

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

cds:cds Execute CDS commands on the current CAP Java project.
Call mvn cds:cds or mvn com.sap.cds:cds-maven-plugin:cds on the command line to execute all configured CDS commands of the project in current directory.

Several CDS commands can be configured in one execution block and they're executed in the specified order. If a command execution fails, the overall goal execution is stopped and the Maven build fails.

Note:This goal requires an installation of the @sap/cds-dk, either locally or globally. The goal install-cdsdk of this plugin can be used for this.

cds:clean Clean generated files and directories of the previous build from the current CAP Java project.
Call mvn com.sap.cds:cds-maven-plugin:clean to execute cleaning from command line.

This goal deletes the following files and directories from the resource directory of the current CAP Java project:
  • file: src/main/resources/**/csn.json
  • file: src/main/resources/**/schema.sql
  • directory: src/main/resources/**/edmx/
  • directory: ${codeOutputDirectory}

cds:generate Generate Java Pojos for type-safe access to the CDS model.

This goal scans the resource directory for a csn.json file and uses it for Java source code generation. It also adds the code output directory to the project's source code directories configuration. This allows you to use the generated Java classes in your custom code without any additional configuration in the project.

cds:help Display help information on cds-maven-plugin.
Call mvn cds:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.
cds:install-cdsdk Install @sap/cds-dk in the current CAP Java project.
By default, this goal looks for an already installed @sap/cds-dk and skips installation if it was found. It doesn't validate the found version against the requested version to install and the installed @sap/cds-dk could be outdated. Add property -Dcds.install-cdsdk.force=true to the Maven command line to force the installation of a @sap/cds-dk in the configured version.

cds:install-node Download and install a Node.js distribution on the local file system.
If the requested version is already installed, the download and installation is skipped.

This goal also recognizes proxy configurations in your ~/.m2/settings.xml. If there's an active proxy for the host in the downloadUrl configured, it will be used.

The goal also supports basic authentication at the downloadUrl. The optional parameter serverId can be used to reference a server configuration from settings.xml, which provides username and password. See also Settings Reference for further details about server configuration in settings.xml.

This goal also exposes the following locations as project properties:
  • ${cds.node.executable}: Location of the node executable
  • ${cds.npm.executable}: Location of the npm executable
  • ${cds.npx.executable}: Location of the npx executable
  • ${cds.node.directory}: Directory containing the Node.js executables (node/npm/npx), can be used to enhance the $PATH environment variable

cds:npm Execute an npm command on the current CAP Java project.
Call mvn com.sap.cds:cds-maven-plugin:npm -Darguments="..." to execute npm command with given arguments.

cds:npx Execute an npx command on the current CAP Java NG project.
cds:version Prints detailed version information about current CAP Java project on the console.
Call mvn cds:version or mvn com.sap.cds:cds-maven-plugin:version to print detailed version information.

This goal prints the following version information about current CAP Java project and build environment:
  • version of CAP Java SDK including CDS4J
  • console output of command line cds version
  • version and location of Apache Maven
  • version and location of Java runtime
  • OS information

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

In order to get even faster development cycles locally, add an optional dependency to the Spring Boot Developer tools in the pom.xml. In this case the watch goal leaves the restart of the application to the developer tools, which is faster.

<dependencies>
  ...
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
    <scope>runtime</scope>
  </dependency>
  ...
</dependencies>

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

System Requirements

The following specifies the minimum requirements to run this Maven plugin:

Maven 3.3.1
JDK 1.8
Memory No minimum requirement.
Disk Space No minimum requirement.

Usage

You should specify the version in your project's plugin configuration:

<project>
  ...
  <build>
    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.sap.cds</groupId>
          <artifactId>cds-maven-plugin</artifactId>
          <version>1.29.0</version>
        </plugin>
        ...
      </plugins>
    </pluginManagement>
    <!-- To use the plugin goals in your POM or parent POM -->
    <plugins>
      <plugin>
        <groupId>com.sap.cds</groupId>
        <artifactId>cds-maven-plugin</artifactId>
        <version>1.29.0</version>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

For more information, see "Guide to Configuring Plug-ins"