Migrating to Cloud Endpoints Frameworks 2.0 for Ap

2019-02-14 16:05发布

I'm currently trying to migrate from Cloud Endpoints 1.0 to Cloud Endpoints Frameworks 2.0.

I've followed the steps outlined here: https://cloud.google.com/appengine/docs/java/endpoints/migrating?authuser=0

In my build.gradle I've replaced:

compile 'com.google.appengine:appengine-endpoints:1.9.42'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.42'

with:

compile 'com.google.endpoints:endpoints-framework:2.0.0-beta.5'
compile 'javax.inject:javax.inject:1'

And in web.xml I've replaced SystemServiceServlet with EndpointsServlet and /_ah/spi/* with /_ah/api/*.

However on compile, I get the following error:

Error:Execution failed for task ':myapp_backend:appengineEndpointsGetClientLibs'.
> There was an error running endpoints command get-client-lib: web.xml must have 1 (found:0) SystemServiceServlet servlet

Am I missing something?

Edit, as requested by @saiyr, here's my build.gradle file:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42'
    }
}

repositories {
    jcenter();
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
    // AppEngine
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'
    compile 'javax.servlet:servlet-api:2.5'

    //  Cloud Endpoints
    compile 'com.google.appengine:appengine-endpoints:1.9.42'
    compile 'com.google.appengine:appengine-endpoints-deps:1.9.42'

    // Cloud Endpoints Frameworks
    // compile 'com.google.endpoints:endpoints-framework:2.0.0-beta.7'
    // compile 'javax.inject:javax.inject:1'

    // Project
    compile files('src/main/webapp/WEB-INF/lib/gson-2.3.1.jar')
    compile 'com.googlecode.objectify:objectify:5.1.9'
    compile 'com.ganyo:gcm-server:1.0.2'
    compile 'com.google.appengine.tools:appengine-gcs-client:0.5'
}

appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
    }
    endpoints {
        getClientLibsOnBuild = true
        getDiscoveryDocsOnBuild = true
    }
}

UPDATE:

There is now a guide detailing the transition process here: https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin/blob/master/ANDROID_README.md

And here: https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating-android

3条回答
smile是对你的礼貌
2楼-- · 2019-02-14 16:19

Hi don't know if you fixed it already but this solved my problem

compile 'com.google.endpoints:endpoints-framework:2.0.0-beta.9'

查看更多
仙女界的扛把子
3楼-- · 2019-02-14 16:30

Since the Gradle plugin is in the progress of being updated, for now you need to comment out/delete the endpoints fragment so that client libraries aren't generated on build. Then, if you need to generate client libraries, do it manually for now.

查看更多
登录 后发表回答