Class InstallNodeMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
com.sap.cds.maven.plugin.AbstractCdsMojo
com.sap.cds.maven.plugin.build.InstallNodeMojo
All Implemented Interfaces:
CdsMojoLogger, org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="install-node", defaultPhase=INITIALIZE, aggregator=true, requiresProject=false) public class InstallNodeMojo extends AbstractCdsMojo
Download a Node.js distribution and install it on the local file system.
If the requested version is already installed, the download and installation is skipped.

This goal also considers proxy configurations in the ~/.m2/settings.xml. If there's an active proxy for the host in the downloadUrl configured, it is 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.

Once executed, this goal 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

Since:
1.7.0
  • Field Details

  • Constructor Details

    • InstallNodeMojo

      public InstallNodeMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • execute

      protected void execute(File workDir, File execFile, OutputStream outputStream, Map<String,String> additionalEnv, int[] exitValues, String... args) throws IOException
      Executes a program as child process.
      Parameters:
      workDir - the working directory of child process
      execFile - the executable to use
      outputStream - an optional standard output stream
      additionalEnv - additional environment variables, can be null
      exitValues - an optional list with exit values of the process to be considered successful, can be null
      args - an optional command line arguments passed to the process
      Throws:
      IOException - if an I/O exception occurred
      org.apache.commons.exec.ExecuteException - if process execution failed
    • findCdsWorkingDir

      protected File 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.