Search code examples
javaandroidgoogle-app-engineandroid-studiodatastore

How do I share entity objects between multiple endpoints in Google App Engine using appengineEndpointsGetClientLibs?


I have an entity to send a contactList to a java enpoint in Google App Engine:

@Entity
public class ContactList {

    private ArrayList<Contact> list;

    public ArrayList<Contact> getList() {
        return list;
    }

    public void setList(ArrayList<Contact> list) {
        this.list = list;
    }
}

I have another endpoint that I would like to send the same entity to. When developing both Enpoints in Android Studio I have one class for the shared entity:

package.shared.entities.ContactList

But when generating the client libs, it generates two versions of the entity:

package.enpointA.model.ContactList
package.enpointB.model.ContactList

How do I share entity objects between multiple endpoints of a Google App Engine java backend using appengineEndpointsGetClientLibs?


Solution

  • Yeah this is a consequence of the generation service. It actually generates and archive for each endpoint. The gradle plugin merges those in to one archive but preserves all the package paths. I think a way around this is to manage your API as one endpoint and as multiple classes. https://cloud.google.com/appengine/docs/java/endpoints/multiclass