Maven wrapper for Node.js

Maven for Node.js

Node.js package that wraps Apache Maven.


npm install maven

Basic usage

const mvn = require('maven').create({
      cwd: '/path/to/your/maven-project'
    mvn.execute(['clean', 'install'], { 'skipTests': true }).then(() => {
      // As mvn.execute(..) returns a promise, you can use this block to continue
      // your stuff, once the execution of the command has been finished successfully.

Creating the Maven wrapper instance

Creating a Maven wrapper instance is pretty much straight forward:

const mvn = require('maven').create(options);

The following options can be passed to the createmethod:

cwd(default: process.cwd())

This parameter can be used to define the working directory when invoking the Maven command line.

cmd(default: ./mvnwif present in project root, otherwise mvn(or mvn.baton Windows))

Maven executable relative to cwd. For example, cwd: '/usr/local/bin/mvn

file(default: undefined)

Can be used to pass a specific POM file to the Maven command line. If nothing is specified, the Maven process itself will look for a file called pom.xmlin the base directory.

profiles(default: [])

An array that can be used to enable or disable profiles. You can either explicitly enable a profile by adding it's name or disable a profile by pre-pending !to it's name. Will be passed to Java/Maven as -PprofileEnabled,!profileDisabledparameter.

settings(default: undefined)

Can be used to override the default settings file when invoking Maven. If nothing is specified, the Maven process itself will load .m2/settings.xmlin the user's home directory.

quiet(default: false)

Quiet output - only show errors if set to true.

debug(default: false)

Produce execution debug output if set to true.

updateSnapshots(default: false)

Forces a check for missing releases and updated snapshots on remote repositories if set to true.

offline(default: false)

Produce execution offline if set to true.

nonRecursive(default: false)

Prevents Maven from building submodules if set to true.

threads(default: undefined)

Thread count, for instance 2.0C where C is core multiplied

noTransferProgress(default: false)

Suppress the transfer progress when downloading/uploading in interactive mode if set to true(requires Maven 3.6.1+).

batchMode(default: false)

Run in non-interactive (batch) mode (disables output color) if set to true.

logFile(default: undefined)

Log file where all build output will go (disables output color).

Executing Maven commands

Executing Maven commands is simple, too:

mvn.execute(commands, defines);

commandsis just a list of lifecycle phases and/or goals, e.g. 'compile', [ 'clean', 'install' ]or [ 'release:prepare', 'release:perform' ].

definesis an object that represents the various definitions that will be passed to Java/Maven via -Dkey=valueparameters.





  • maven多模块的项目搭建

    springmvc spring mybatis springboot maven多模块的项目搭建 参考:

    1 年前
  • maven-deploy

    A simple Node.js module to create a war/jarpackage and install/deploy to a local/remote Maven reposi...

    13 天前
  • gulp-maven-deploy

    Simple gulp plugin for the mavendeploy module gulpmavendeploy ================= A Gulp(//

    13 天前
  • Maven插件的版本和压缩JavaScript

    Tauren(提出了一个问题:Maven plugin for versioning and minifyi...

    2 年前
  • Jenkins+Maven+Svn实现代码自动打包与发布

    前言 可能很多小伙伴们都知道,在一般互联企业初期大多数都是采用手工打包上传与发布的方式进行代码发布,常见就是利用打包工具手工打包,上传到WEB服务器,备份原代码文件,发布新的代码,重启服务和检测是...

    9 个月前
  • JQuery Availability on Maven Repositories

    JQuery Availability on Maven Repositories...

    2 年前
  • 10.基于Spring的Maven项目实现发送邮件功能

    问题分析 现在我们有这样一个需求,就是当我们系统出现问题或bug的时候,让系统通过邮件发送日志信息给相关人员,那么此时,我们就需要实现一个让系统发送邮件的功能 解决步骤 1.pom jar包导入 ...

    4 个月前


扫码加入 JavaScript 社区