Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

maven-deploy

finn-no66.7kMIT1.5.0

A simple Node.js module to create a war-/jar-package and install/deploy to a local/remote Maven repository

maven, deploy

readme

maven-deploy

Build Status Coverage Status Dependencies status

A simple Node.js module to create a war-/jar-package and install/deploy to a local/remote Maven repository. It uses mvn to do the actual deployment, so you need maven installed locally.

Project name and version is extracted from package.json and used as artifactId and maven version. Supply an object litteral with other Maven related config. Values from package.json can be used by adding curly-braces around the key. Example {finalName: "{name}-{version}"}.

The package is created from the {buildDir}/ folder. So you need to make sure that the files you want in the package is put there before packaging. The default is dist/. The package file will be output in the same folder.

var config = {
    "groupId"      : "com.example",    // required - the Maven group id.
    "artifactId"   : "{name}",         // the Maven artifact id.
    "buildDir"     : "dist",           // project build directory.
    "finalName"    : "{name}",         // the final name of the file created when the built project is packaged.
    "type"         : "war",            // type of package. "war" or "jar" supported.
    "fileEncoding" : "utf-8"           // file encoding when traversing the file system, default is UTF-8
    "repositories" : [                 // array of repositories, each with id and url to a Maven repository.
      {
        "id": "example-internal-snapshot",
        "url": "http://mavenproxy.example.com/example-internal-snapshot/"
      },
      {
        "id": "example-internal-release",
        "url": "http://mavenproxy.example.com/example-internal-release/"
      }
    ]
};

It might be useful to store the config as a separate json-file, so you can re-use it in multiple files.

var config = require('./maven-config.json');

Package war/jar

It expects output from the project to be in dist/ directory. It zips the content and outputs it to dist/{finalName}.{type} Usage: maven.package( [callback] )

Example:

var maven = require('maven-deploy');
maven.config(config);
maven.package();

Install to local repository

Runs package first, then installs the package to your local Maven repository. Usage: maven.install( [callback] )

Example:

var maven = require('maven-deploy');
maven.config(config);
maven.install();

Deploy

Runs package first, then deploys the package to the specified Maven repository. Usage: maven.deploy( repositoryId, [snapshot = false], [callback])

Example: deploy to snapshot repo

var maven = require('maven-deploy');
maven.config(config);
maven.deploy('example-internal-snapshot', true);

Example: deploy to release repo

var maven = require('maven-deploy');
maven.config(config);
maven.deploy('example-internal-release');

Example: deploy existing archive file

var maven = require('maven-deploy');
maven.config(config);
maven.deploy('example-internal-release', 'file.jar');

Contributing

We would love your contribution, please consult the contributing page for how to make your contributions land into the project as easily as possible.

changelog

Changelog

Next major release

  • BREAKING CHANGE: Do not exit if mvn command fails. Pass error, stdout and stderr to callback instead.
  • Switch to async API

1.5.0

  • No change since 1.5.0-beta

1.5.0-beta

  • Add generatePom config-option
  • Update some dev-dependencies and remove coveralls as runtime dependency
  • Fix some lint errors

1.4.1

  • Fix bug for deploy (Issue #31)

1.4.0

  • Add optional file argument to pass an archive instead of generating one
  • Update dependencies

1.3.2

  • Fix undocumented breaking change in isbinaryfile (Issue #28)

1.3.1

  • Add folders/directories to archive
  • Update dependencies

1.3.0

  • Revert breaking change accidentally shipped in 1.2.1
  • {version} in finalName for a snapshot should use the new snapshot-version

1.2.1

  • Strip undefined mvn arguments

1.2.0

  • Fix wrong path-separator for the archive on Windows (Anton Savchenko)
  • Add Classifier maven parameter (jmorille and Gregers Rygg)
  • Updated dependencies and removed Chai (Gregers Rygg)

1.1.0

  • Fix package.json might change between calls to maven.config and maven.deploy (Gregers Rygg)
  • Add coverage for tests (Gregers Rygg)
  • Refactored tests (Gregers Rygg)
  • Create tests for maven.install (Gregers Rygg)
  • Other small improvements (Gregers Rygg)

1.0.0

  • Fix zipping shouldn't corrupt binary files (Kalle Wuoti)
  • Define artifact id in maven config and run maven in batch mode (-B) (Kalle Wuoti)
  • Ignore only package file, when creating ZIP archive (tmair)
  • Add fileEncoding as an option (Espen Dalløkken)
  • JSHint and other small improvements (Gregers Rygg)

0.0.2

  • Improved readme and package.json

0.0.1

  • Initial work (Gregers Rygg)