3

I'm trying to use a library project with my Google AppEngine project as a project on build path.

Is there a way to get that included in the AppEngine project without having to copy the entire source or make a jar ?

I only use a small portion of the library so it seems like overkill to copy the whole jar and a lot of work to find the dependencies within the source to get only the parts I'm using.

Saad Farooq
  • 13,172
  • 10
  • 68
  • 94
  • 1
    Seems strange that Google haven't addressed this issue so far. – AlikElzin-kilaka Jan 31 '14 at 23:03
  • There are other motivations for wanting this. Example: Developing a library to be used by a GAE project. You don't want to create a jar on every small change you test. Referencing a library project from a GAE project would solve this scenario as well. – AlikElzin-kilaka Mar 05 '14 at 10:07

3 Answers3

4

I added an ant project builder that copies the class files from the dependent project. The ant file resides in the gae project and copies the class files from the referenced project. Here's the ant:

<?xml version="1.0" encoding="UTF-8"?>
<project name="CommonsCopy" default="copy" basedir=".">
    <target name="copy">
        <copy todir="war/WEB-INF/classes">
            <fileset dir="../Commons/bin" includes="**/*.class">
            </fileset>
        </copy>
    </target>
</project>

I named it 'CommonsCopyBuilder.xml' as it copies code from a commons project.

This will copy the files to the appropriate location just before running the project.

AlikElzin-kilaka
  • 34,335
  • 35
  • 194
  • 277
  • 1
    It took me a bit to figure out exactly how to do that (http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2FgettingStarted%2Fqs-93_project_builder.htm) but then it worked just fine. I placed mine as part of the Common source and had it copy from there to the dependent projects because it seemed to run less often that way -- only when Common was touched and not every time the derived project was built. – Brian White Nov 26 '13 at 00:24
3

You are not going to like this answer, but No.

In order to include the library as a dependency in the project once deployed the required library must be found in your WEB-INF/lib directory as a jar. This is going to require you to you to create a jar based on the library you want to use. The other option is to do just as you said pull the dependent source into your project and use it from there.

During development you can make the library project a dependency of your app engine project by doing the following:

Under Project->Properties->Java Build Path->Projects Tab
select the "Add.." button to add a subproject to your build.

Note: This will not address the the running in a production environment.

Chris Johnson
  • 2,631
  • 2
  • 18
  • 17
0

I managed to do this by creating the libary project is a "Web Fragment Project" and adding it to the "Deployment Assembly" in the project properties of the app engine project.

However, the app engine project does not seem to work with non-trivial dependency structures. In my case, I had two app engine modules within an EAR, both depending on the libary project. However, the Google plugin only bundled the library project with one of the modules, never with both at the same time despite identical configurations. Obviously a bug.

My work-around was to add a linked source folder to the app engine projects, pointing to the source folder of the library project. Ugly, but it does the job.

Luzius
  • 41
  • 3