2017-05-08 17 views
1

我對將舊的Google App Engine項目轉換爲Gradle感到非常困惑。無法運行Gradle應用引擎任務

我正在嘗試按照this頁面上的說明進行操作。它建議先從這個構建腳本:

buildscript { // Configuration for building 
    repositories { 
    jcenter() // Bintray's repository - a fast Maven Central mirror & more 
    mavenCentral() 
    } 
    dependencies { 
    classpath 'com.google.cloud.tools:appengine-gradle-plugin:+' // latest App Engine Gradle tasks 
    } 
} 

repositories { // repositories for Jar's you access in your code 
    maven { 
    url 'https://maven-central.storage.googleapis.com'    // Google's mirror of Maven Central 
// url 'https://oss.sonatype.org/content/repositories/snapshots' // SNAPSHOT Repository (if needed) 
    } 
    jcenter() 
    mavenCentral() 
} 

apply plugin: 'java'        // standard Java tasks 
apply plugin: 'war'        // standard Web Archive plugin 
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks 

dependencies { 
    providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5' 
    compile 'com.google.appengine:appengine:+' 
// Add your dependencies here. 

} 

appengine { // App Engine tasks configuration 
    run {  // local (dev_appserver) configuration (standard environments only) 
    port = 8080     // default 
    } 

    deploy { // deploy configuration 
    stopPreviousVersion = true // default - stop the current version 
    promote = true    // default - & make this the current version 
    } 
} 

group = 'com.example.appengine' // Generated output GroupId 
version = '1.0-SNAPSHOT'   // Version in generated output 

sourceCompatibility = 1.7 // App Engine Standard uses Java 7 
targetCompatibility = 1.7 // App Engine Standard uses Java 7 

但是它不工作:

$ gradle appengineRun 

FAILURE: Build failed with an exception. 

* Where: 
Build file '/path/to/myproject/build.gradle' line: 32 

* What went wrong: 
A problem occurred evaluating root project 'myproject'. 
> Could not find method run() for arguments [[email protected]] on root project 'myproject' of type org.gradle.api.Project. 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

不應該依賴下載使定製appengine任務配置工作?

回答

1

請看看插件的sources。當核心插件被應用時,它決定是否應用靈活的標準 appengine插件。由於可能沒有src/main/webapp/WEB-INF/appengine-web.xml靈活的插件應用,它不會創建失敗的擴展(FYI,此擴展創建爲here)。要解決該問題,請運行:

mkdir -p src/main/webapp/WEB-INF 

然後:

touch src/main/webapp/WEB-INF/appengine-web.xml 

在控制檯,build.gradle所在。這將解決問題。糟糕的文檔:/

+0

哈,我想知道'appengine-web.xml'文件 - 它在原始頁面被提及,但沒有建議它的內容。順便說一句可能'mkdir'而不是'md'?謝謝,這工作。 –

+0

@DanGravell,正如我所說的糟糕的文檔質量。更正爲'mkdir',謝謝。 – Opal

相關問題