Heroku deployment of Gradle application: pom.xml missing - gradle

I have an existing Maven based application on Heroku that I want to replace with a JHipster generated, Gradle based one. The steps I took were:
Develop the new Gradle based application using JHipster
run jhipster heroku
git merge heroku --strategy ours
git push heroku
Most of the deployment succeeds (Node.js app detected, webpack logging), but then I get an error:
Could not find a pom.xml file! Please check that it exists and is committed to Git.
It is correct that there is no pom.xml, because now it is a Gradle application. But apparently, Heroku still expects a Maven based one. Where is this knowledge stored and how can I reset it?

Already found out. You have to run this command, to remove the Maven build pack:
heroku buildpacks:clear
Additionally, in my case I also had to set:
heroku buildpacks:set heroku/nodejs
Or Heroku didn't know whether to run as Gradle or NodeJS. The latter is needed for JHipster based applications.

Related

How do you deploy Maven project from Github to Heroku automatically?

So I have a Maven project and I'd like to deploy it on Heroku via Github. To be more precise I want to use automatic deployments where when I push to my master branch only then is it deployed. The only thing I found for Maven is that I add a dependency and it would deploy to Heroku from my machine (which I essentially don't want).
I really don't know what else to say as I had 0 progress. For now I am just pushing my target as well and then just running the target jar file. But I'd like to just send over my source code and for Heroku to build the project.
Alright, so I found my solution.
I saw an example (I can't find it now, no luck) for Heroku that build the project with a thing called mvnw script which is a Maven wrapper when it's not installed on the system. I added it and the .mvn directory but it didn't start by itself like how it is written on Heroku (it should run it when it's detected), no problem really.
I then edited my Procfile and instead of:
web: java -jar target/my-file.jar
I am using:
web: ./mvnw clean package; java -jar target/my-file.jar
And everything works well!
You only need to integrate your GitHub repository on Heroku, and define the automated deployment of the master branch (each push will trigger a deployment).
Heroku will build the JAR and take care of the deployment, you need though to define the Java version in a system.properties and create an Uber-Jar (ie including all dependencies).

CircleCI and Heroku automatic deployment

I'm trying to configure automatic deploy on Heroku integrated with CircleCI.
On Heroku Dashboard, at the Deploy tab, I have the option to configure an automatic deploy for a specific branch and there is an option "Wait for CI to pass before deploy". What happens when I have both this and the circle.yml configured for an automated deploy on Heroku? Will the app be deployed twice?
Yes it will.
CircleCi and Heroku will trigger building and deploying process at the same time

Jenkins and AWS Elasctic Beanstalk deployment

What i'm looking for is this kind of stack:
CI: Jenkins
Plugins: M2 Release, AWSEB Deployment Plugin
pom.xml version is 1.0-SNAPSHOT.
When i push to github, Jenkins creates a project-1.0-SNAPSHOT package and deploys it automatically on test server with AWSEB Deployment Plugin.
Once all devs are good on test server, I manually deploy on production the current snapshot with M2 Release and AWSEB Deployment Plugin.
pom.xml version on github is now set to 1.1-SNAPSHOT.
Does anyone has a similar stack, or has some usefull resources to do the entire chain ?
The AWSEB Deployment Plugin is just a focused version of beanstalker.
Actually, you can use something combining the maven-release-plugin (although I'd suggest using only versions instead) with beanstalker, like this:
http://www.nagaseyasuhito.net/2012/03/26/211/

How to clean Heroku dependency cache (unmanaged maven dependencies)

I have to use an unmanaged SNAPSHOT dependency in my java/maven heroku app.
I do this using a project-local maven repository as desribed in this article.
Heroku caches the dependencies between builds. Unfortunatly Heroku does not notice if the SNAPSHOT Version changes and keeps on using the cached dependency. This leads to compilation errors as I depend on changes in the SNAPSHOT version.
Is there a way to manually or automatically clean this dependency cache?
I found this maven plugin (it does a local build and pushes the resulting artefacts to heroku) but its not really the way I want to do it.
One could argue its a bad practice to use this snapshot dependency in the first place but I think there are other more or less valid reasons for cleaning the cash e.g. leaking storage as the unmanaged dependencies are not even removed if they are deleted from the project local repository.
I appreciate your answer
There's a branch of the java buildpack that clears maven cache. To use it, configure your app to use the cache_clear branch:
heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-java.git#cache_clear
===Update===
There's a plugin that clears cache on any app. Install it and run the purge-cache command.
$ heroku plugins:install https://github.com/heroku/heroku-repo.git
$ heroku repo:purge_cache -a appname
Login to heroko by console, go to the git repository directory of your app, run the following commands and try to push to the heroku git repository again
$ heroku config:set MAVEN_CUSTOM_GOALS="clean package"
$ heroku config:set MAVEN_CUSTOM_OPTS="--update-snapshots -DskipTests=true"
Now, it will download the latest SNAPSHOT from the repository before build.
Refer this heroku build pack for java for more details.
You can also configure a custom settings.xml for your maven, refer this heroku documentation.
I've written plugin with an alternate take: bundling the container + the war image into a git repository base image (for now, its either winstone and/or jetty) which is pushed to Heroku, thus maving easier to deploy (I think) :]
http://cedarhero.ingenieux.com.br/heroku-maven-plugin/
This doesn't answer the question directly, but if you're having the same issue with Clojure project (using Leiningen), there's a better way to handle this than purging cache with each build: use :update :always property for the repository you're working with. (https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L91)
:repositories [["releases" {:url "http://blueant.com/archiva/internal"
;; How often should this repository be checked for
;; snapshot updates? (:daily, :always, or :never)
:update :always}]]

Is it possible to deploy a heroku war app with Java 1.7?

I tried updating system.properties to say 1.7, but it seems to stay at 1.6.
When I deploy via maven, system.properties works.
When I deploy via:
heroku deploy:war --war
it reverts back to 1.6 ignoring my system.properties. any ideas?
I'm wondering whether perhaps deploying with "heroku deploy:war" doesn't pick up the system.properties file. Try deploying by pushing your Git repo instead.

Resources