# maven

> Maven wrapper for Node.js

Latest version **5.0.0** (published 2020-05-20) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install maven
pnpm add maven
yarn add maven
bun add maven
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2020-05-20 |
| First published | 2015-01-27 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 0 |
| Unpacked size | 26.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Benjamin P. Jung |
| Maintainers | headcr4sh |
| Keywords | maven, mvn, m2, java |

## Links

- npm: https://www.npmjs.com/package/maven
- Repository: https://github.com/headcr4sh/node-maven
- Issues: https://github.com/headcr4sh/node-maven/issues
- npm.io page: https://npm.io/package/maven

## Recent versions

- 5.0.0 (latest) — 2020-05-20
- 4.7.0 — 2019-08-22
- 4.6.0 — 2019-07-03
- 4.5.0 — 2019-05-11
- 4.4.1 — 2018-08-31
- 4.4.0 — 2018-01-22
- 4.3.0 — 2017-12-05
- 4.2.0 — 2017-05-24
- 4.1.0 — 2017-03-07
- 4.0.3 — 2016-04-20
- 4.0.2 — 2016-03-15
- 4.0.1 — 2016-03-15
- 4.0.0 — 2016-03-15
- 3.0.6 — 2015-07-28
- 3.0.5 — 2015-07-27
- … 11 more at https://npm.io/package/maven/versions

## README

# Maven for Node.js

Node.js package that wraps [Apache Maven](https://maven.apache.org/).

## Installation
```sh
npm install maven
```

## Basic usage
```javascript
    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:
```javascript
    const mvn = require('maven').create(options);
```

The following options can be passed to the <code>create</code> method:

#### `cwd` (default: ```process.cwd()```)
This parameter can be used to define the working directory when invoking the Maven command line.

#### `cmd` (default: ```./mvnw``` if present in project root, otherwise ```mvn``` (or ```mvn.bat``` on 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.xml``` in 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,!profileDisabled``` parameter.

#### `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.xml```
in 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```.

#### `alsoMake` (default: ```false```)
If project list is specified, also build projects required by the list

#### `logFile` (default: ```undefined```)
Log file where all build output will go (disables output color).

## Executing Maven commands

Executing Maven commands is simple, too:

```javascript
mvn.execute(commands, defines);
```

You can optionally specify a list of projects to be build:

```javascript
mvn.execute(commands, defines, projects)
```

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

`defines` is an object that represents the various definitions that will be passed to Java/Maven via ```-Dkey=value``` parameters.

---
_Source: https://npm.io/package/maven · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
