Search code examples
google-cloud-endpointsgoogle-cloud-endpoints-v2

CanonicalName not used for generated class in Cloud Endpoint V2


During the Migration of our Cloud Endpoint from v1 to V2, we noticed that the name of the Service Definition class generated in the client does not use canonicalName defined in the @Api annotation definition

For example

@Api(name = "customer",
canonicalName = "CustomerAPI",
version = "v1",
...
public class CustomerEndpoint {
...

Generates customer-v1-java.zip and the Service Definition class is generated with the name Customer rather than CustomerAPI.

Our app's build.gradle looks as follows

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.cloud.tools.endpoints-framework-client'
apply plugin: 'io.fabric'

...

dependencies {

    ...

    endpointsServer project(path: ':servers:api', configuration: 'endpoints')
}

While the build.gradle in servers/api is as follows

buildscript {
repositories {
    mavenCentral()
    jcenter()
}
dependencies {
    // App Engine Gradle plugin
    classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'

    // Endpoints Frameworks Gradle plugin
    classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
    }
}

...

apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'

...

dependencies {
    providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
    compile 'jstl:jstl:1.2'
    compile group: 'javax.inject', name: 'javax.inject', version: '1'
    compile group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '1.9.49'
    compile group: 'com.google.endpoints', name: 'endpoints-framework', version: '2.0.8'

...

}

appengine {
    deploy {   // deploy configuration
        version = findProperty("appengine.deploy.version")
        def promoteProp = findProperty("appengine.deploy.promote")
        if (promoteProp != null) {
            promote = new Boolean(promoteProp)
        }
    }
    run {
        host = "0.0.0.0"
        port = 8080
        jvmFlags = ['-Ddatastore.backing_store=../../../local_db.bin']
    }
}

def projectId = 'some-api-project'

endpointsServer {
    hostname = "${projectId}.appspot.com"
}

endpointsClientLibs {
    hostname = "${projectId}.appspot.com"
}

Any ideas why the canonicalName is not being respected?


Solution

  • Simply put, it's a bug/accidentally omission. I will have it fixed in the next release.