Enhancing endpoints in Cloud Endpoints Frameworks

2019-05-22 09:47发布

I have received an email from GCP to migrate my project 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 previous build.gradle I had this directive to enhance my endpoints and it worked fine:

appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
    }
    endpoints {
        getClientLibsOnBuild = true
        getDiscoveryDocsOnBuild = true
    }
    enhancer {
        version = "v2"
        api="jdo"  // or "jpa"
        enhanceOnBuild = true
    }
}

However, after migration and on compile, I get the following error:

Error:(60, 0) Could not find method enhancer() for arguments [build_2dn4fni12bkrsqgsi25gsx3hh$_run_closure2$_closure7@6b02ee9e] on object of type com.google.cloud.tools.gradle.appengine.core.AppEngineExtension.

And if I remove the enhancer part, I get the following error:

org.datanucleus.metadata.MetaDataManager initialiseFileMetaDataForUse: Found Meta-Data for class [...] but this class is not enhanced!! Please enhance the class before running DataNucleus.

So, what is the equivalent enhancing in the new framework? (I'm using Android Studio 2.3.3)

2条回答
Bombasti
2楼-- · 2019-05-22 10:23

The problem is that the new gradle plugin doesn't have the task appengineEnhance which is required to enhance your classes for jpa/jdo.

There's a workaround for this here https://stackoverflow.com/a/29279504/3190492

It's also worth nothing that the enhancer {...} section in the appengine block won't be required and that configuration should be done in the script in the link above.

查看更多
叛逆
3楼-- · 2019-05-22 10:29

I got this response directly from Google Cloud Support:

There are some features and tools that are excluded and currently unavailable with the latest version of Endpoints v2. If your application requires any of the below mentioned, you are not recommended to migrate.

  • JSON-RPC protocol, which is required for legacy iOS clients
  • Automatic ETags
  • Automatic Kind fields
  • IDE integration
  • fields partial responses

Meanwhile, below are the tools that are currently not supported in v2.0:

  • Android Studio support for Cloud Endpoints 1.0
  • Android Studio code validation and quick fixes for Cloud Endpoints 1.0

So, with regards to the 'enhancer' method, have you checked if this is included on the aforementioned features? If so, the only way for you to do is check for an equivalent function or downgrade again to v1.0.

This is not the answer I hoped for, but at least till they officially support these features, we should not migrate to Endpoints Framework v2.0.

查看更多
登录 后发表回答