Class VersionMojo

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

@Mojo(name="version", defaultPhase=GENERATE_SOURCES, aggregator=true) public class VersionMojo extends AbstractCdsMojo
Prints detailed version information about the CAP Java project on the console.
Call cds:version or mvn com.sap.cds:cds-maven-plugin:version to get detailed version information.

This goal shows the following version information about the 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

Since:
1.19.0
  • Field Details

    • PROP_NODE_DIR

      protected static final String PROP_NODE_DIR
      See Also:
    • PROP_NODE_EXECUTABLE

      protected static final String PROP_NODE_EXECUTABLE
      See Also:
    • PROP_NPM_EXECUTABLE

      protected static final String PROP_NPM_EXECUTABLE
      See Also:
    • PROP_NPX_EXECUTABLE

      protected static final String PROP_NPX_EXECUTABLE
      See Also:
    • PARAM_NODE_DIR

      protected static final String PARAM_NODE_DIR
      See Also:
    • PARAM_NPX_EXECUTABLE

      protected static final String PARAM_NPX_EXECUTABLE
      See Also:
    • PARAM_NPM_EXECUTABLE

      protected static final String PARAM_NPM_EXECUTABLE
      See Also:
    • repositorySystemSession

      @Parameter(defaultValue="${repositorySystemSession}", required=true, readonly=true) protected org.eclipse.aether.RepositorySystemSession repositorySystemSession
      Defines settings and components that control the repository system.
  • Constructor Details

    • VersionMojo

      public VersionMojo()
  • Method Details

    • execute

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

      protected String executeCdsVersion()
      Executes command cds version and returns console output.
      Returns:
      the console output of the cds version command
    • setNpxExec

      public void setNpxExec(File npxExec)
      Gets called to inject parameter "npxExec".
      Parameters:
      npxExec - a File pointing to npx executable
    • executeCds

      protected void executeCds(File workDir, String args, OutputStream output, Map<String,String> additionalEnv) throws IOException
      Executes a cds command with given arguments in given working directory.
      Parameters:
      workDir - the working directory to use
      args - the cds command line arguments
      output - an optional OutputStream
      Throws:
      org.apache.commons.exec.ExecuteException - if CDS execution failed with an error
      IOException - if an I/O error occurred
    • getWorkingDirectory

      protected File getWorkingDirectory()
    • 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.