我'm trying to deploy a Grails 3 application that I'一直在研究Heroku但我遇到了build.gradle文件的问题 .
以下命令在本地工作:
./gradlew stage
heroku local web
然后我可以在http://localhost:5000/看到我的Grails应用程序
部署的第一部分显示它执行我的阶段任务 . 但后来,它抱怨无法找到舞台任务 .
remote: -----> Gradle app detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Building Gradle app...
remote: WARNING: The Gradle buildpack is currently in Beta.
remote: -----> executing ./gradlew stage
remote: Downloading https://services.gradle.org/distributions/gradle-2.13-all.zip
部署期间收到以下错误:
remote: ! ERROR: Failed to run Gradle!
remote: It looks like your project does not contain a 'stage' task, which Heroku needs in order
remote: to build your app. Our Dev Center article on preparing a Gradle application for Heroku
remote: describes how to create this task:
remote: https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku
remote:
remote: If you're stilling having trouble, please submit a ticket so we can help:
remote: https://help.heroku.com
remote:
remote: Thanks,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Gradle app.
但是,我已经按照https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku的说明进行操作,并将阶段任务添加到我的build.gradle中,并且还填充了proc文件 .
当我在项目的根目录中运行./gradlew任务时,阶段任务确实显示在“其他任务”下的列表中 .
Other tasks
-----------
assetClean
assetPluginPackage
cleanIdeaWorkspace
console
dependencyManagement
mergeTestReports
pathingJar
pathingJarCommand
schemaExport
shell
stage
urlMappingsReport
wrapper
这是我的build.gradle:
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.8.2"
classpath "org.grails.plugins:hibernate4:5.0.10"
}
}
version "0.1"
group "paxdata"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"asset-pipeline"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
compile group: 'org.codehaus.groovy.modules.http-builder', name: 'http-builder', version: '0.6'
compile 'org.grails.plugins:spring-security-core:3.1.1'
compile 'org.grails.plugins:quartz:2.0.9'
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
compile 'com.github.jsimone:webapp-runner:8.0.30.2'
}
assets {
minifyJs = true
minifyCss = true
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
task stage() {
dependsOn clean, war
}
tasks.stage.doLast() {
delete fileTree(dir: "build/distributions")
delete fileTree(dir: "build/assetCompile")
delete fileTree(dir: "build/distributions")
delete fileTree(dir: "build/libs", exclude: "*.war")
}
war.mustRunAfter clean
task copyToLib(type: Copy) {
into "$buildDir/server"
from(configurations.compile) {
include "webapp-runner*"
}
}
stage.dependsOn(copyToLib)
这是我的Procfile的内容:
web: cd build ; java $JAVA_OPTS -Dgrails.env=prod -jar ../build/server/webapp-runner-*.jar --expand-war --port $PORT libs/*.war
对我做错了什么的想法?
1 回答
与我同样的问题,通过运行以下命令解决
heroku config:set GRADLE_TASK="build" git push heroku master
您可以查看以下链接
https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku