Deep-dive on the Next Gen Platform. Join the Webinar!

Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Visit the Heroku Blog

    Find news and updates from Heroku in the blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Language Support
  • Java
  • Working with Maven
  • Adding Unmanaged Dependencies to a Maven Project

Adding Unmanaged Dependencies to a Maven Project

English — 日本語に切り替える

Last updated December 16, 2019

Table of Contents

  • Pick groupId, artifactId and version parameters
  • Create a local Maven repository directory
  • Deploy the Artifact Into the Repo
  • Update Pom file
  • Commit to Git

Some Java applications have dependencies that aren’t available in a public or private Maven repository (the latter of which can be accessed using a custom settings.xml file). This guide shows you how to add these unmanaged libraries in your application project and tell Maven how to find them.

Pick groupId, artifactId and version parameters

Let’s say your app depends on the library mylib.jar which is not in any public Maven repository. First you must define a groupId, artifactId and version for the library. These parameters may not matter to you, but Maven requires this information for all dependencies.

So let’s use:

  • groupId: com.example
  • artifactId: mylib
  • version: 1.0 (or whatever version your lib is, if you have it versioned)

Create a local Maven repository directory

Your project root should look something like this to start with:

yourproject
+- pom.xml
+- src

Add a standard Maven repository directory called repo for the group com.example and version 1.0:

yourproject
+- pom.xml
+- src
+- repo

Deploy the Artifact Into the Repo

Maven can deploy the artifact for you using the mvn deploy:deploy-file goal:

mvn deploy:deploy-file -Durl=file:///path/to/yourproject/repo/ -Dfile=mylib-1.0.jar -DgroupId=com.example -DartifactId=mylib -Dpackaging=jar -Dversion=1.0

Your project will contain some Maven metadata and your JAR file.

yourproject
+- pom.xml
+- src
+- repo
   +- com
      +- example
         +- mylib
            +- maven-metadata.xml
            +- ...
            +- 1.0
               +- mylib-1.0.jar
               +- mylib-1.0.pom
               +- ...

Update Pom file

Now edit your pom.xml and add this repository to your <repositories/> element. You may have to create the <repositories/> element if you dont have one.

<repositories>
    <!--other repositories if any-->
    <repository>
        <id>project.local</id>
        <name>project</name>
        <url>file:${project.basedir}/repo</url>
    </repository>
</repositories>

When using the repository from a sub-module, you will need to substitute the ${project.parent.baseDir} property in the <url> element.

Now you can add this jar as a dependency as normal:

<dependency>
    <groupId>com.example</groupId>
    <artifactId>mylib</artifactId>
    <version>1.0</version>
</dependency>

Commit to Git

Dont forget to add and commit your local repo folder to git.

$ git add repo
$ git commit -m 'adding project local maven repo, with mylib.jar 1.0'

The next time you push your project the dependency will resolve and your application will build without an issue. Since the local repo folder and jars are checked in with your application code they will remain private to your app.

Keep reading

  • Working with Maven

Feedback

Log in to submit feedback.

Using a Custom Maven Settings File Using a Custom Maven Settings File

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices