Deploy Java App on Heroku which depends on my own Maven artifacts

heroku java web app
heroku-maven-plugin
heroku java spring boot
deploy spring mvc application on heroku
deploy java rest api on heroku
heroku deploy:jar
deploy jhipster to heroku
heroku java postgres

Heroku supports deployment of Java apps based on Maven

They also give advice for app deployment if a lib is needed that is not available in a public maven repository

But: I have two Maven projects, where one depends on the other one. When I locally mvn install the dependent artifact I can mvn package the other one and everything works fine. However, I cannot push it to heroku, because heroku can't access my local mvn repo.

What can I do? Will it be necessary to setup a private maven repo accessible to heroku on the web (e.g. artifactory) or are there any other ways to deploy such an app with a custom dependency on heroku?

Thanks.

There is an alternate deployment path for Heroku called Anvil that might help here. With this path, you would build everything locally with any private libs you need and copy all dependencies into your target directory, and then use Anvil to build and release the whole thing to your Heroku app. By default, Anvil will detect your app as Java and try to build it again, but you can override this by specifiying the null buildpack, which tells it to take your files as is because you already did the build locally. This is probably better shown with an example:

  1. Install Anvil:

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

  2. Clone this example app that already has copy-dependencies configured in its pom.xml. You would need to configure this in your own app:

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

  3. Go into the dir and build the app, which will run copy-dependencies. This is critical because you need all your dependencies in your app's target dir, not in ~/.m2/repository so Heroku will be able to find them:

    mvn package

  4. Create the Heroku app:

    heroku create

  5. Use Anvil to build with the null buildpack and release to the app:

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

Deploying Java Apps on Heroku, Creating, configuring, deploying and scaling Java applications on Heroku. a JDK; The Procfile; How to keep build artifacts out of git; Build your app and run It tells Maven to copy the jar files that your app depends on to the  The details of Heroku’s Java Support are described in the Heroku Java Support article. Heroku Java support for Maven will be applied to applications that contain a pom.xml file. Verify that your pom.xml file is set up correctly. If your app has any dependencies, the pom.xml file should include the maven-dependency-plugin.

Take a look how we do it with a live open source web app: pom.xml. The app is deployed to Heroku using Maven and Ant. We automatically do git clone, then copy new files into the folder, and then do git commit && git push. What's important is that we use maven-invoker-plugin in order to download artifacts inside the Heroku slug.

Deploy Java App on Heroku which depends on my own Maven , There is an alternate deployment path for Heroku called Anvil that might help here. With this path, you would build everything locally with any  I tried to deploy with Heroku instead of App Engine but I got a similliar problem. example of some of the errors: cannot find symbol remote: [ERROR] symbol: class GetMapping cannot find symbol remote: [ERROR] symbol: class RequestParam package javax.persistence does not exist package org.springframework.http does not exist package org.aspectj

You need a Maven repository. If your projects are on GitHub then you can use JitPack for this. It will build your code and publish a jar.

There are instructions and docs on the website. Basically add JitPack as a repository and then add your project as a dependency.

Professional Heroku Programming, Chapter 3, “Porting Your Applications to Heroku,” outlined the general principles your Java app does not rely on any file being used after the current request has been Heroku's built-in functionality for scaling, deploying, and load balancing Managing dependencies: Maven is the required tool for dependency and build​  I was doing some research last time about web services that could provide build & deployment of my Java web application. I found Heroku which seemed to be okay but I encountered some problem. First of all, my application uses Spring MVC (not Spring Boot), I have manual java-based annotation configuration without web.xml at all. That's about setup.

As of August 2018 I would recommend using Heroku Maven Plugin

It allows to build application locally and then push artefact to Heroku. It solved my issues with local maven dependencies.

Sample configuration for Spring Boot app:

<build>
    <plugins>
        <plugin>
            <groupId>com.heroku.sdk</groupId>
            <artifactId>heroku-maven-plugin</artifactId>
            <version>2.0.5</version>
            <configuration>
                <appName>${heroku.appName}</appName>
                <processTypes>
                    <web>java -Dserver.port=$PORT $JAVA_OPTS -jar target/${project.build.finalName}.jar</web>
                </processTypes>
            </configuration>
        </plugin>
    </plugins>
</build>

If you are using Heroku CLI then ${heroku.appName} will be automatically resolved.

deployment - Java Play 2 - Compile error -> Heroku, View more. Deploy Java App on Heroku which depends on my own Maven artifacts - St java maven deployment heroku artifactory. 1. Take a look how we do it  Yes. You can build and deploy Java web applications that use all the common APIs: Servlet, JSP, JDBC, taglibs, JSF etc. You can deploy Java web applications in two ways. You can build it locally and deploy as a WAR package to Heroku or you can set it up as a Maven WAR project that includes an embedded web app runner and deploy to Heroku using git. The former is a more familiar approach to most Java developers.

Thin JARs with Spring Boot, In a Boot project built with Maven, we ought to have the Spring Boot We'll launch the application with the usual java -jar <my-app-1.0.jar>, plugin (see section 2.1) to include a dependency on the custom “thin” layout: deployments to Heroku, as well as the full list of supported command line arguments. When you deploy an application to a cloud platform like Heroku, the cloud platform is responsible for delivering all these features. You don’t need to “bring your own WebLogic or WebSphere server” in order to get these features. They are a built-in part of the cloud platform.

Java agent and Heroku, Heroku users: How to configure the Java agent for your New Relic add-on. following the Heroku instructions at least through the Deploy the app [external link] Select Install New Relic APM, and then select your target app from the jar file, configure your Heroku environment for New Relic, depending on your platform:. Exactly what should be excluded depends on the needs of each application. Using the Heroku Maven plugin. The heroku-maven-plugin avoids Git deployment altogether and builds the slug locally before pushing it to Heroku. This allows it to package only what is absolutely necessary for the application to run.

GitLab Maven Repository, With the GitLab Maven Repository, every project can have its own space to store its Understanding how to create a full Java project is outside the scope of this guide Select type of project to generate: 1: basic 2: application 3: library 4: Gradle plugin If a project is private or you want to upload Maven artifacts to GitLab,  If you are deploying directly to the apps with git push you must associate them with your Gradle repo by running heroku create with the --remote flag. Alternatively, you can use Heroku Pipelines in combination with a “master” app that has zero dynos .

Comments
  • sounds good Ryan! Thank you. Means, I'll have to keep /target in my git repo as well, and checkin binaries. I can live with that at the moment. Do you think I could setup artifactory (or any other repo manager) and let heroku check out my own artifacts from there? I would have to secure it propertly. Don't know if this is easy to setup, but it might be the best solution in the end if we have multiple maven dependecies in our own software. thanks a lot again!
  • No, you don't need to (and shouldn't) check /target into your git repo. Anvil (heroku build) uploads your artifacts via HTTP outside of git -- in fact, you could use any VCS you'd like with this.