First you need to build to heroku then you could use this command line:

docker run --rm -u gradle -v gradle-cache:/home/gradle/.gradle -v "$PWD":/home/gradle/project -w /home/gradle/project -p 8081:8080 gradle-rocketship /bin/bash -c "gradle clean && gradle build -x test"

That’s going to generate a build file ignoring tests.

Now you can send that file to heroku:

heroku deploy:war build/libs/project-web.war --app app_name_in_heroku

At this case I’m using .war file.

That’s it! It’s done and probably it’s live in heroku server.

HEADS UP I: I’m using gradle into docker container if you are not used to work with that you could take a look here.

HEADS UP II I’m not showing how to set up gradle file to build .jar / .war I think you already have that.

HEADS UP III: I think you have created app in heroku dashboard, if not please make it before to use head this article up.