Package com.sap.cds.maven.plugin.build
Class InstallCdsdkMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
com.sap.cds.maven.plugin.AbstractCdsMojo
com.sap.cds.maven.plugin.build.InstallCdsdkMojo
- All Implemented Interfaces:
CdsMojoLogger
,org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="install-cdsdk",
defaultPhase=INITIALIZE,
aggregator=true)
public class InstallCdsdkMojo
extends AbstractCdsMojo
Install the @sap/cds-dk into a 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 and the existing @sap/cds-dk could be outdated. Add property
Note: This goal ignores any dependency (including version) to @sap/cds-dk, @sap/cds or @sap/cds-compiler in the package.json of the CAP Java project.
Alternative way to install the @sap/cds-dk:
If you need to install additional Node.js modules in your CAP Java project, we recommend to use a different approach for the installation. In that case, maintain all dependencies, including the @sap/cds-dk, as a devDependency in the package.json:
Also remove the execution of goal cds:install-cdsdk from your pom.xml and replace it with goal cds:npm:
The
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 and the existing @sap/cds-dk could be outdated. Add property
-Dcds.install-cdsdk.force=true
to the Maven
command line to force the installation of the @sap/cds-dk in the configured version.Note: This goal ignores any dependency (including version) to @sap/cds-dk, @sap/cds or @sap/cds-compiler in the package.json of the CAP Java project.
Alternative way to install the @sap/cds-dk:
If you need to install additional Node.js modules in your CAP Java project, we recommend to use a different approach for the installation. In that case, maintain all dependencies, including the @sap/cds-dk, as a devDependency in the package.json:
"devDependencies": {
"@sap/cds-dk": "version"
}
Also remove the execution of goal cds:install-cdsdk from your pom.xml and replace it with goal cds:npm:
<execution>
<id>cds.install-dependencies</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
This execution configuration runs the npm install
command during each Maven build for your project and
installs @sap/cds-dk and other dependencies. The
npm cliwill install the dependencies, if they are not
installed or not available in the requested versions.The
cds.install-cdsdk.global
property needs to be removed from the pom.xml as the version is
already maintained in package.json.- Since:
- 1.7.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected org.eclipse.aether.RepositorySystemSession
Defines settings and components that control the repository system.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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
protected void
execute
(File workDir, File execFile, OutputStream outputStream, Map<String, String> additionalEnv, int[] exitValues, String... args) Executes a program as child process.protected String
executeNpm
(File workDir, int[] exitValues, String... args) protected void
executeNpm
(File workDir, File outputFile, String... args) protected String
executeNpm
(File workDir, String... args) protected File
Finds the cds working directory by going upwards and looking for a .cdsrc.json file.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
-
Field Details
-
PROP_NODE_DIR
- See Also:
-
PROP_NODE_EXECUTABLE
- See Also:
-
PROP_NPM_EXECUTABLE
- See Also:
-
PROP_NPX_EXECUTABLE
- See Also:
-
PARAM_NODE_DIR
- See Also:
-
PARAM_NPX_EXECUTABLE
- See Also:
-
PARAM_NPM_EXECUTABLE
- See Also:
-
repositorySystemSession
@Parameter(defaultValue="${repositorySystemSession}", required=true, readonly=true) protected org.eclipse.aether.RepositorySystemSession repositorySystemSessionDefines settings and components that control the repository system.
-
-
Constructor Details
-
InstallCdsdkMojo
public InstallCdsdkMojo()
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
executeNpm
- Throws:
IOException
-
executeNpm
- Throws:
IOException
-
executeNpm
- Throws:
IOException
-
execute
protected void execute(File workDir, File execFile, OutputStream outputStream, Map<String, String> additionalEnv, int[] exitValues, String... args) throws IOExceptionExecutes a program as child process.- Parameters:
workDir
- the working directory of child processexecFile
- the executable to useoutputStream
- an optional standard output streamadditionalEnv
- additional environment variables, can benull
exitValues
- an optional list with exit values of the process to be considered successful, can benull
args
- an optional command line arguments passed to the process- Throws:
IOException
- if an I/O exception occurredorg.apache.commons.exec.ExecuteException
- if process execution failed
-
findCdsWorkingDir
Finds the cds working directory by going upwards and looking for a .cdsrc.json file. It stops at the top-most project directory.- Returns:
- the cds working directory or
null
if not found.
-