【问题标题】:Deploy on heroku without keeping gradlew file在不保留 gradlew 文件的情况下部署在 heroku 上
【发布时间】:2019-02-07 21:44:43
【问题描述】:

我正在使用 Gradle 构建一个演示 Spring Boot 应用程序,并使用 Heroku 来托管该应用程序。我已经预装了 Gradle 4.8,所以我没有在项目目录中保留 gradlew 文件,并且应用程序在本地运行良好,但是当我使用 git push heroku master 在 heroku 上部署它时。显示以下警告的日志:

remote: -----> Installing Gradle Wrapper...
remote:        WARNING: Your application does not have it's own gradlew file.
remote:        We'll install one for you, but this is a deprecated feature and
remote:        in the future may not be supported.
remote: -----> Building Gradle app...
remote: -----> executing ./gradlew build -x test

显示 Gradle 版本错误后构建失败:

remote:        * What went wrong:
remote:        A problem occurred evaluating root project 'xxx'.
remote:        > Spring Boot plugin requires Gradle 4.0 or later. The current version is Gradle 2.0

表示它使用默认的gradle 文件并安装2.0 来部署应用程序。

现在我的问题是,如何强制 Heroku 部署过程使用预安装的 Gradle 版本,而不在项目目录中保留 gradlew 并且不安装默认弃用的 gradlew

【问题讨论】:

    标签: java spring-boot gradle heroku


    【解决方案1】:

    Heroku Gradle buildpack 不支持在没有 gradlew 文件的情况下使用 Gradle 版本 > 2.x。这与official Gradle recommendation 内联。

    但是,您可以分叉 Heroku Gradle buildpack 并编辑 default wrapper, which installs Gradle。然后,您可以在 Heroku 应用上将您的 fork 设置为自定义构建包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-31
      • 2019-08-13
      • 1970-01-01
      • 2022-11-21
      • 1970-01-01
      • 2012-01-25
      • 1970-01-01
      相关资源
      最近更新 更多