2

Currently I am working on Google App Engine Modules. I am referring to the documentation

I am confused as how to handle model classes or common classes. Previously I was using back-end in that all code was kept in the project but now with modules I don't get how to manage common code.

Harshal Patil
  • 6,659
  • 8
  • 41
  • 57
yogesh
  • 463
  • 6
  • 15

2 Answers2

4

I've created Appstart (https://github.com/omerio/appstart) a boilerplate maven based multi-module App Engine application that demonstrates the use of technologies like Guice, Jersey, Objectify, Cloud EndPoints and has 3 modules a fronend module, backend module and common module which includes all the common classes including the model, which should show you an example of how to manage common code. The folder contains the following modules/maven projects

  • appstart-backend
  • appstart-common
  • appstart-ear
  • appstart-frontend

The backend module only contains code required for the backend, the frontend contains the frontend code and the common module contains common code. The projects are setup inside a parent folder 'appstart' with a parent maven POM. The common module is included in both the frontend and backend using a maven dependency:

<!-- Common module dependency -->
    <dependency>
        <groupId>uk.co.inetria.appstart</groupId>
        <artifactId>appstart-common</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

When you change the common code you can run mvn clean then install from the appstart-ear directory and it should update all dependent projects. I hope this helps

omerio
  • 1,186
  • 7
  • 16
  • This should definitely be marked as the right answer. I've been searching all day to find how to do this and this is the only working/clean way that I have found so far – user1084563 Oct 24 '14 at 01:18
  • I am not using Maven Based Project so not preferred this solution. – yogesh Nov 01 '14 at 08:53
  • @omerio is there a way to use appstart-frontend as the main artifact and not have the ear? What would that look like if so? I am in a project right now that is kind of like this, but without the ear is why i am asking. Thank you! – j_walker_dev Apr 12 '15 at 01:35
  • @j_walker_dev yes you can use the frontend module alone, just cd into the frontend directory and deploy to appengine, you can also move the common config from the parent pom into the frontend pom – omerio Apr 12 '15 at 22:39
1

I factor out the common logic into a separate JAR shared by the different modules.

Andy Dennie
  • 6,012
  • 2
  • 32
  • 51
  • But every time, when i changed some line in that common code then i have to builds jar once again and have to add in different modules separately. – yogesh Oct 09 '14 at 05:17
  • Yes that's true. I suppose another option would be to put the common code in a separate source directory that the different modules include in their source paths. – Andy Dennie Oct 09 '14 at 12:39
  • Please vote for this issue so it can be fixed: GAE WTP Eclipse plugin does not support shared referenced projects (shared code): https://code.google.com/p/googleappengine/issues/detail?id=10652 – Andre Oct 26 '14 at 10:59