heroku/heroku-gradle-plugin

Read the app name from app.json

Closed this issue · 4 comments

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

Malax commented

How do you configure your app name in app.json?

{
  "name": "asarkar-duel",
  "description": "Application that simulates a duel and streams live updates.",
  "image": "heroku/java"
}

In order to refer to a single source of truth, I do the following in the build file:

configure<com.heroku.sdk.HerokuExtension> {
    appName = ObjectMapper()
        .readTree(project.rootDir.resolve("app.json"))
        .path("name")
        .asText()
    includes = tasks.shadowJar.get().outputs.files.map { "build/libs/${it.name}" }
    isIncludeBuildDir = false
}
Malax commented

@asarkar that name field does not refer to your Heroku app, but is a generic name you can give your application. Similar to the description. This plugin cannot use this name to detect your Heroku app name for you. Documentation for this field in app.json can be found here: https://devcenter.heroku.com/articles/app-json-schema#name

I'll close this since it's not possible to implement this as requested.

@Malax Can you not make up a name using the groupId and artifactId, unless the user specifies a name of their choice? That'd be more consistent with the Maven/Gradle model. For instance, jar task doesn't require you to set a specific name for that JAR.