Using workspace projects with AppEngine

点点圈 提交于 2019-12-06 07:18:22

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/9393278/using-workspace-projects-with-appengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!