GithubHelp home page GithubHelp logo

heroku-gradle-plugin's Introduction

Heroku Gradle Plugin

CI

Important

This plugin is no longer maintained.

Heroku offers a build tool independent CLI for the purpose of deploying JAR and WAR files directly to Heroku without using the standard Git workflow. Users that require the functionality of the Heroku Gradle Plugin are encouraged to migrate to it.

Find out more: Heroku JVM Application Deployer

This plugin is used to deploy Gradle based JVM applications directly to Heroku without pushing to a Git repository. This can be useful when deploying from a CI server.

Using the Plugin

Add the plugin to your build.gradle:

plugins {
  id "com.heroku.sdk.heroku-gradle" version "3.0.0"
}

Create a Heroku app using the Heroku CLI:

$ heroku create

Build your application, and run the deployHeroku task:

$ ./gradlew build deployHeroku

Configuration

You can configure the heroku-gradle plugin by using the heroku directive in your build.gradle configuration.

You can configure your Heroku app name like this:

heroku {
  appName = "sushi"
}

You can include extra files like this:

heroku {
  includes = ["README.md"]
}

You can exclude all files except your fat-jar like this:

heroku {
  includes = ["build/libs/my-app.jar"]
  includeBuildDir = false
}

You can strip the path from the file paths (e.g. turning "foo/bar/build/foobar.tgz" into "foobar.tgz" ). This will default to project.rootDir (i.e. the root of all modules)

heroku {
  includeRootDir = project.buildDir
}

You can explicitly define the required jdk version (in system.properties)

heroku {
  jdkVersion = 17
}

You can customize the command used to run your app (in Procfile) like this:

heroku {
  processTypes(
      web: "java -jar build/libs/my-app.jar"
  )
}

Development

The heavy lifting for this plugin is done by the heroku-deploy library. The source code for that project can be found in the heroku-maven-plugin repository. If you need to update that library, do this:

$ git clone https://github.com/heroku/heroku-maven-plugin
$ cd heroku-maven-plugin/heroku-deploy
# make your changes
$ mvn clean install

Then update the heroku-deploy dependency version in the heroku-gradle build.gradle to 0.1.0 (or whatever version is specified in the heroku-deploy pom.xml). The next time you run the scripted tests it will pick up the snapshot version from your local Maven repository.

heroku-gradle-plugin's People

Contributors

breskeby avatar dependabot[bot] avatar edmorley avatar jkutner avatar kyle-cackett avatar malax avatar man-at-home avatar tekacs avatar tobias- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

heroku-gradle-plugin's Issues

Cannot deploy an app with Gitlab CI

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

Read the app name from app.json

> 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.

deployHeroku task should depend on stage task

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).

Warning: You are running on a deprecated stack.

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"
    )
}

Heroku pipelines integration

I love the Heroku pipelines feature. Here's why:

  • every PR has a link to CircleCI results
  • every PR has a link to a Heroku preview app

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.

Heroku login

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

Artifact is deployed to Heroku platform under its full filesystem path in Gradle daemon's directory

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.

First szenario:

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!

Second szenario:

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

Third szenario:

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.

heroku.appName by System property

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

Can't Find 'FileUtils' in HerokuPluginExtension

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

New release

Could someone please release this plugin?

We really need the feature you merged 2 weeks ago to migrate to Gradle.

Unable to deploy executable jar

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.