https://github.com/mvnpm/mvnpm
Use npm like any other Maven/Gradle dependency...
https://github.com/mvnpm/mvnpm
gradle java maven npm
Last synced: about 1 month ago
JSON representation
Use npm like any other Maven/Gradle dependency...
- Host: GitHub
- URL: https://github.com/mvnpm/mvnpm
- Owner: mvnpm
- License: apache-2.0
- Created: 2022-10-11T05:44:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2026-05-15T09:00:22.000Z (about 1 month ago)
- Last Synced: 2026-05-15T10:53:57.832Z (about 1 month ago)
- Topics: gradle, java, maven, npm
- Language: Java
- Homepage: https://mvnpm.org/
- Size: 2.43 MB
- Stars: 31
- Watchers: 1
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

## Use NPM packages as Maven/Gradle dependencies
**mvnpm** lets you consume [NPM Registry](https://www.npmjs.com/) packages directly from your Java build tool.
**Maven**
```xml
org.mvnpm
{package-name}
{package-version}
{runtime/provided}
```
**Gradle**
```groovy
implementation 'org.mvnpm:{package-name}:{package-version}'
// or compileOnly for bundled usage
```
For scoped packages, use `org.mvnpm.at.{namespace}` as groupId
(e.g. `@hotwired/stimulus` becomes `org.mvnpm.at.hotwired:stimulus`).
## Ways to consume
- Bundled and served with the [Quarkus Web Bundler](https://docs.quarkiverse.io/quarkus-web-bundler/dev/index.html) (scope `provided`)
- Served directly using [importmaps](https://github.com/mvnpm/importmap) (scope `runtime`)
- Bundled with [esbuild-java](https://github.com/mvnpm/esbuild-java)
- As a drop-in [WebJars](https://www.webjars.org/) replacement
## Syncing a missing package
Most popular packages are already on Maven Central. Check the "Maven Central" badge on the [Browse page](https://mvnpm.org/) to verify.
- Click the "Maven Central" badge to trigger a sync.
- Or configure the [fallback repository](#configuring-the-fallback-repository) to fetch missing packages automatically.
Once a package is synced, mvnpm automatically syncs new versions as they're published on NPM. Tools like Dependabot and Renovate can then propose updates in your pull requests.
> **Use Maven Central for production builds.** The fallback repository is for development and initial sync only.
## Fallback repository mode

1. Your build requests a package from Maven Central.
2. If it's not there yet, the request falls through to the mvnpm repository.
3. mvnpm fetches the package from NPM and converts it into a Maven artifact (JAR + POM).
4. The artifact is returned to your build immediately and synced to Maven Central in the background.
## Configuring the fallback repository
**Maven**
Add to your `~/.m2/settings.xml`:
```xml
mvnpm-repo
central
central
https://repo.maven.apache.org/maven2
false
mvnpm.org
mvnpm
https://repo.mvnpm.org/maven2
mvnpm-repo
```
**Gradle**
Add to your `build.gradle`. Since Gradle honors the repository order, declare it after `mavenCentral()` so it's only used as fallback. Content filtering avoids unnecessary lookups:
```groovy
repositories {
mavenCentral()
maven {
name = "mvnpm"
url = uri("https://repo.mvnpm.org/maven2")
content {
includeGroupByRegex "org\\.mvnpm.*"
}
}
}
```
## Locking dependencies
**Maven**
The [mvnpm locker Maven Plugin](https://github.com/mvnpm/locker) locks your `org.mvnpm` and `org.webjars` dependency versions, similar to `package-lock.json` or `yarn.lock`.
**Gradle**
Enable native dependency locking in your `build.gradle`:
```groovy
dependencyLocking {
lockAllConfigurations()
}
```
Then run `gradle dependencies --write-locks` to generate the lockfile.
## Learn more
- [Getting Started](https://mvnpm.org/doc/) - full documentation
- [About mvnpm](https://mvnpm.org/about/) - the story, ecosystem, and vision
- [Browse packages](https://mvnpm.org/) - search and explore NPM packages as Maven dependencies