5

I'm using Google App Engine to create a project consisting of multiple Google Modules. How do I set up my project (using Maven) so that I can share source code such as Objectify object model definitions, shared utility code, and unit test code across the modules?

I'm hoping the answer is simple and that I can just use Maven as suggested in answers such as these:

However, I'm concerned there might be something special about Google App Engine modules that makes them different from Maven modules. And then maybe the approaches above won't work.

As an example of why I'm concerned, notice that Google says "Although Java EE supports WAR files, module configuration uses unpacked WAR directories only." yet some of the solutions given above suggest packaging the shared code into JAR files. I realize WAR and JAR are different but I'm worried I'll waste my time trying to make something work that can't.

Any advice on how to share code among Google App Engine modules?

Community
  • 1
  • 1
Michael Osofsky
  • 11,429
  • 16
  • 68
  • 113

1 Answers1

5

I have a share directory that contains code I want to share between modules.

Then I can make symlinks from my modules directories to the share directory.

The symlinks can be of a file, sub-directory, or the whole share directory itself.

Eyal Levin
  • 16,271
  • 6
  • 66
  • 56
  • Thanks for the idea @eyalev. When you say symlinks, is that a unix convention, a Maven convention, a Google App Engine convention, or something else? And to be clear, does Google App Engine support symlinks in production (as opposed just to the development server)? – Michael Osofsky Jan 26 '15 at 17:06
  • 1
    It's a unix convention: http://en.wikipedia.org/wiki/Symbolic_link And yes, App Engine support this in production. Some info here: https://cloud.google.com/appengine/docs/java/#adding_third_party_python_libraries – Eyal Levin Jan 26 '15 at 17:18
  • 1
    This is the correct link: https://cloud.google.com/appengine/docs/python/#adding_third_party_python_libraries – Eyal Levin Jan 26 '15 at 17:25
  • Thank you @eyalev, I'll need to set aside some time at some point to try this since I had the problem a while ago. But I really appreciate your idea, it sounds promising. – Michael Osofsky Jan 26 '15 at 17:46
  • I've almost got it working but do you have trouble making symbolic links work with source control? Don't symbolic links have to be relative to a globally accessible path that's "above" the project directory? For example, if I have `~/myproj/share/` I can make a link `ln -s ~/myproj/share ~/myrpoj/module1/share`. This allows module1 code to reference content in `share`. My source control, BitBucket, recognizes `module1/share`. But will another developer have to set up the symlink if s/he names the project directory `theproj` instead of `myproj`? – Michael Osofsky Feb 10 '15 at 00:40
  • 1
    From the directory where I want to create the symlink I usually do something like: `ln -s ../share share`. Then I believe it will work for others as well regardless of the project name. – Eyal Levin Feb 10 '15 at 09:55
  • Oh that's brilliant @eyalev. I tried it and it worked. The only thing I haven't verified is that Google App Engine allows this in production. But I know you said it does and the python link you provided (https://cloud.google.com/appengine/docs/python/#adding_third_party_python_libraries) talks about symbolic links. So I'm going to go ahead and accept your solution. Thanks again! – Michael Osofsky Feb 10 '15 at 16:39