Deploy a Java application on Heroku, which depends on my own Maven artifacts

Heroku Supports Maven-Based Java Application Deployment

They also provide tips for deploying applications if you need a library that is not available in the maven public repository.

But: I have two Maven projects where each depends on the other. When I locally mvn install a dependent artifact, I can mvn build another, and everything works fine. However, I cannot push him to the hero, because the hero cannot access my local mvn repository.

What can I do? Will it be necessary to set up a private maven repository available for the herook on the Internet (for example, artifactory), or are there other ways to deploy such an application with user dependency on heroku?

Thanks.

+4
source share
3 answers

There is an alternative deployment path for Heroku called Anvil , which can help here. Using this path, you would create everything locally with any private libraries that you need and copy all the dependencies to your target directory , then use Anvil to build and release it all into your Heroku application. By default, Anvil will detect your application as Java and try to create it again, but you can override this by specifying a null buildpack that tells it to take your files in the same way as if you already built it locally. This is probably better illustrated with an example:

  • Install Anvil:

    heroku plugins:install https://github.com/ddollar/heroku-anvil

  • Clone is an example application that already has copy-dependencies configured in pom.xml . You will need to configure this in your own application:

    git clone git://github.com/heroku/template-java-jaxrs.git

  • Enter the directory and create an application that will work copy-dependencies . This is important because you need all your dependencies in the target dir application, not in ~/.m2/repository , so Heroku can find them:

    mvn package

  • Build the Heroku app:

    heroku create

  • Use Anvil to build with null buildpack and release the application:

    heroku build -b https://github.com/ryandotsmith/null-buildpack.git -r

+2
source

See how we do it with an open source open source web application: pom.xml . The application is deployed to Heroku using Maven and Ant. We automatically do git clone , then copy the new files to the folder, and then do git commit && git push . The important thing is that we use the maven-invoker-plugin to load artifacts inside the Heroku cork.

+1
source

You need a Maven repository. If your projects are on GitHub, you can use JitPack . He will build your code and publish the jar.

The website has instructions and documents. Basically add JitPack as a repository, and then add your project to the dependency.

0
source

All Articles