I am trying to deploy a Gradle Java app to Heroku using GitHub. The repo name is "v-m-test". This is the Procfile I'm currently using: web: java -jar target/v-m-test.jar. Is this the wrong Procfile?
make sure the jar is the right path, so in your github you have a jar in this path:
target/v-m-test.jar
Related
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).
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.
I am using maven and jboss plugin. When I run this command
mvn clean install jboss-as:deploy
I will deploy in currently running jboss but I want to know which jar file it deploy..jar file generated in target folder or jar file in local repository?
By default it gets the bits from target folder. Look at targetDir property of the plugin.
You can find the details in the plugin documentation.
I am trying to deploy a dropwizard app on heroku which fails to launch.
Its works fine locally using "gradle run server config.yml"
I am using gradle for build and when I push to heroku the build is successful.
My gradle stage task dependsOn clean and jar(fat jar creation)
My Procfile has:
web: java $JAVA_OPTS -jar dropwizard-app/build/libs/dropwizard-app.jar server dropwizard-app/config.yml
The above fails with "Unable to access jarfile dropwizard-app/build/libs/dropwizard-app.jar"
I have tried unsuccessfully with
web: java $JAVA_OPTS -jar build/libs/dropwizard-app.jar server config.yml
I have also tried to execute using gradle command
web: gradle run server config.yml
This gives an error
bash: gradle command not found
My gradle tasks are as follows:
task stage(dependsOn: ['clean', 'jar'])
run {
args 'server', 'config.yml'
}
jar {
manifest {
attributes 'Title': 'dropwizard-app', 'Version': version,'Main-Class': mainClassName
}
archiveName 'dropwizard-app'
dependsOn configurations.runtime
from {
configurations.compile.collect {it.isDirectory()? it: zipTree(it)}
}
}
Am I missing out something here?
How do I launch my dropwizard application?
Got it working.
As mentioned above I was trying to execute dropwizard-app.jar
but the jar created on heroku was not of mentioned name, it took the default archive name
starting with build-'some autogenerated value'.jar
So I added a settings.gradle to my project:
rootProject.name = 'dropwizard-app'
Now the jar created was dropwizard-app-1.0.jar
as I have set the version attribute to 1.0 in build.gradle
I used heroku run bash
to check the files on heroku
I wrote a Maven-based deployment guide describing how to deploy a Dropwizard to Heroku which may offer some help. While it doesn't cover gradle, it does point out some common gotchas with the Heroku environment.
For example, your Procfile should look like this:
web java $JAVA_OPTS -Ddw.http.port=$PORT -Ddw.http.adminPort=$PORT -jar path/to/dw/module/target/example-develop-SNAPSHOT.jar server path/to/dw/module/config-heroku.yml
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.