Can Google App Engine Modules share source code just like Maven Modules?
Asked Answered
M

1

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?

Monorail answered 9/12, 2014 at 20:22 Comment(0)
M
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.

Myel answered 25/1, 2015 at 15:3 Comment(7)
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)?Monorail
It's a unix convention: en.wikipedia.org/wiki/Symbolic_link And yes, App Engine support this in production. Some info here: cloud.google.com/appengine/docs/java/…Myel
This is the correct link: cloud.google.com/appengine/docs/python/…Myel
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.Monorail
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?Monorail
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.Myel
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 (cloud.google.com/appengine/docs/python/…) talks about symbolic links. So I'm going to go ahead and accept your solution. Thanks again!Monorail

© 2022 - 2024 — McMap. All rights reserved.