heroku / heroku-gradle-plugin Goto Github PK
View Code? Open in Web Editor NEWA Gradle plugin for deploying JAR and WAR files to Heroku.
License: MIT License
A Gradle plugin for deploying JAR and WAR files to Heroku.
License: MIT License
Hello
How can I inform the app name and credentials when using heroku-gradle? I intend to use it on GitHub Actions and I'm not sure if configuring it just by reading the read me file is enough
How to deploy an application with Postgres process and according Heroku addon?
The CLI expects a task named stage, and most people would have set up one (or inherited if using Spring). It'd be helpful to have the plugin depend on task stage
, if it's present. That'll also eliminate the need for declaring a dependency on whatever task that creates the fat jar (stage
depends on it already).
See heroku-maven-plugin as an example of better documentation for a build tool plugin. Most of the information there also applies to the Gradle plugin and can be ported over.
App isn't deployed with Gitlab CI, but I can run ./gradlew deployHeroku locally, and it works. HEROKU_API_KEY is available.
$ ./gradlew --build-cache deployHeroku
Downloading https://services.gradle.org/distributions/gradle-6.3-bin.zip
.........10%..........20%..........30%.........40%..........50%..........60%.........70%..........80%..........90%..........100%
Welcome to Gradle 6.3!
Here are the highlights of this release:
- Java 14 support
- Improved error messages for unexpected failures
For more details see https://docs.gradle.org/6.3/release-notes.html
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/6.3/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing
> Task :compileKotlin
w: /builds/CMDR_Tvis/mcs-server-java/src/main/kotlin/io/github/commandertvis/mcs/ConfigurationRoute.kt: (8, 9): Variable 'log' is never used
> Task :compileJava NO-SOURCE
> Task :processResources
> Task :classes
> Task :shadowJar
> Task :deployHeroku FAILED
-----> Packaging application...
- app: mcs-server-java
- including: build/libs/mcs-server-1.0.0-all.jar
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':deployHeroku'.
> java.io.IOException: There was an error packaging the application for deployment.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2m 30s
4 actionable tasks: 4 executed
I now get a warning upon deploy with the following message:
remote:
remote: ! Warning: You are running on a deprecated stack.
remote: ! Please upgrade to the latest stack by following the instructions on:
remote: ! https://devcenter.heroku.com/articles/upgrading-to-the-latest-stack
remote:
-----> Done
I'm using version 1.0.4 of the plugin.
Configuration
heroku {
if (project.hasProperty('production')) {
appName = "myapp"
} else {
appName = "myapp-test"
}
includes = [new File(project('backend').getBuildDir(), "libs/myapp-0.0.1.jar").absolutePath]
includeBuildDir = false
processTypes (
web: "java -jar -Dspring.profiles.active=\$profile -Dserver.port=\$PORT backend/build/libs/myapp-0.0.1.jar"
)
}
I'm using Heroku Gradle plugin (version 1.0.4
) to deploy a roughly 13 MB sized executable application JAR.
And struggling with correctly packing only this artifact (and not all the other stuff from Gradle's build
folder);
and getting the instruction to launch this app right.
Excerpt from build.gradle
:
heroku {
appName = '[APPLICATION]'
processTypes(
web: "java \$JAVA_OPTS -jar ./build/libs/[APPLICATION].jar" as String
)
}
This works, BUT the artifact uploaded to Heroku platform contains many useless content, e.g. compiled class files etc.:
$ ./gradlew deployHeroku
> Task :deployHeroku
-----> Packaging application...
- app: [APPLICATION]
- including: build/
-----> Creating build...
- file: build/heroku/build.tgz
- size: 66MB
66 MB, but application's JAR is only 13 MB in size!
Adding includeBuildDir = false
to heroku task in build.gradle
:
heroku {
appName = '[APPLICATION]'
includeBuildDir = false
processTypes(
web: "java \$JAVA_OPTS -jar ./build/libs/[APPLICATION].jar" as String
)
}
This FAILS, the artifact uploaded to Heroku platform does NOT contain the executable JAR file!
Size of the uploaded build.tgz
is simply too small:
$ ./gradlew deployHeroku
> Task :deployHeroku
-----> Packaging application...
- app: [APPLICATION]
- including: build/
-----> Creating build...
- file: build/heroku/build.tgz
- size: 1MB
Let's exactly define the artifact file to upload using includes = ["build/libs/[APPLICATION].jar"]
in heroku task:
heroku {
appName = '[APPLICATION]'
includeBuildDir = false
includes = ["build/libs/[APPLICATION].jar"]
processTypes(
web: "java \$JAVA_OPTS -jar ./build/libs/[APPLICATION].jar" as String
)
}
This FAILS, Heroku's console tells us the reason:
Error: Unable to access jarfile ./build/libs/[APPLICATION].jar
Size of the uploaded build.tgz
is OK now (13 MB), BUT what means the over-long including
path:
$ ./gradlew deployHeroku
> Task :deployHeroku
-----> Packaging application...
- app: [APPLICATION]
- including: /home/[USER]/.gradle/daemon/6.5.1/build/libs/[APPLICATION].jar
-----> Creating build...
- file: build/heroku/build.tgz
- size: 13MB
Connecting to the Heroku platform and searching for our application JAR file shows:
$ heroku run -a [APPLICATION] -- pwd\; find . -name [APPLICATION]\*.jar
Running pwd; find . -name *.jar on ⬢ [APPLICATION]... up, run.2939 (Free)
/app
./home/[USER]/.gradle/daemon/6.5.1/build/libs/[APPLICATION].jar
Oh, my JAR file has been uploaded with its absolute filesystem path of Gradle's daemon!
So changing processTypes
instruction to contain ./home/[USER]/.gradle/daemon/6.5.1/build/libs/[APPLICATION].jar
would work, but that is not the expected solution!
My expectation is that this operates the same way as with the other two szenarios: Application JAR file is available on Heroku platform under project-relative path build/libs/[APPLICATION].jar
.
Seems to be an error reading the credentials
It would be great to be able to pass the app name by command line
./gradlew deployHeroku -Dheroku.appName=myapp
like with the maven plugin
Version 3.0.3 of heroku-deploy
has a bug that causes failure of deployHeroku
task.
I'm getting this error when using the plugin to deploy to heroku.
Could not get unknown property 'FileUtils' for object of type com.heroku.sdk.gradle.HerokuPluginExtension.
jHispter 4.1.1
Gradle 3.4.1
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_66 (Oracle Corporation 25.66-b17)
OS: Mac OS X 10.12
On local machine I have file in mode
> stat -c "%a %n" app.jar
< 764 app.jar
But on heroku after running task deployHeroku
> stat -c "%a %n" app.jar
< 700 app.jar
Could someone please release this plugin?
We really need the feature you merged 2 weeks ago to migrate to Gradle.
I love the Heroku pipelines feature. Here's why:
My app builds fine on CI, but I can't get it to build on Heroku. The deployHeroku
task works great, and makes a nice tiny slug.
Is there a way I can make this plugin integrate with my Heroku pipeline? Review apps and all? Thanks.
> Task :deployHeroku FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':deployHeroku'.
> Could not resolve app name!
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':deployHeroku'.
There's an app.json
present in the project root directory but the plugin still requires the app name to be configured in the build file.
Where's heroku login
? In order to run and deploy from CI, a login is necessary.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.