我正试图将一个gradle java应用程序部署到heroku(基于jhipster)。我可以使用"heroku-local"在本地构建和运行它,但当我尝试远程部署它时,当它尝试构建应用程序时(在执行./gradlew-stage时),我会遇到错误。错误为:
...
remote: Download https://oss.sonatype.org/content/repositories/releases/org/mapstruct/mapstruct-processor/1.0.0.CR1/mapstruct-processor-1.0.0.CR1.pom
remote: Download https://oss.sonatype.org/content/repositories/releases/org/mapstruct/mapstruct-processor/1.0.0.CR1/mapstruct-processor-1.0.0.CR1.jar
remote: :bower FAILED
remote: FAILURE: Build failed with an exception.
remote:
remote: * What went wrong:
remote: Execution failed for task ':bower'.
remote: > A problem occurred starting process 'command 'bower''
remote:
remote: * Try:
remote: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
remote:
remote: BUILD FAILED
我想如果我能看到stacktrace,它可能会澄清问题,但我不知道如何将命令行参数(--stacktrace)传递给heroku远程服务器上的gradle构建。我会用(heroku-run-bash)手动尝试,但我做不到,因为这是第一次部署,dyno上还没有代码。
此错误表示bower
命令不可用。为了将其添加到构建中,您需要通过运行以下命令将Node.js构建包添加到您的应用程序中:
$ heroku buildpacks:clear
$ heroku buildpacks:add heroku/nodejs
$ heroku buildpacks:add heroku/gradle
这将首先运行Node.js构建包(在git push
之后),它将在package.json
中安装Node和任何依赖项。然后它将运行Gradle构建包。
你可能还需要配置一些其他的东西,我有一篇关于用Maven做这件事的博客文章。但总的来说,同样的原则也适用于Gradle。
您也可以使用Heroku部署插件部署到Heroku。
./gradlew clean -Pprod bootRepackage -x test
heroku deploy:jar --jar build/libs/*.war