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

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
View categories

Categories

  • Heroku Architecture
    • Dynos (app containers)
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Command Line
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery
    • Continuous Integration
  • Language Support
    • Node.js
    • Ruby
      • Working with Bundler
      • Rails Support
    • Python
      • Background Jobs in Python
      • Working with Django
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with Spring Boot
      • Java Advanced Topics
    • PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
    • Heroku Data For Redis
    • Apache Kafka on Heroku
    • Other Data Stores
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
    • Compliance
  • Heroku Enterprise
    • Private Spaces
      • Infrastructure Networking
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Single Sign-on (SSO)
  • 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 Deploying Java Applications with the Heroku Maven Plugin

Information & Support

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

Language Reference

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

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing

Subscribe to our monthly newsletter

Your email address:

  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Heroku Podcasts
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Facebook
  • Instagram
  • Github
  • LinkedIn
  • YouTube
Heroku is acompany

 © Salesforce.com

  • heroku.com
  • Terms of Service
  • Privacy
  • Cookies
  • Cookie Preferences