在多个客户端项目中使用多个 android 库项目的不同修订版(在 Eclipse 中)
首先,我对库项目的大部分了解来自 google 文档 以及此 文章。
设置
在我的 Eclipse 工作区中,我有几个导入 Android 库的客户端项目。每个客户端导入一组不同的库,并且一些库相互导入。
每个客户端都有自己的 Subversion 存储库,所有库都位于一个 Subversion 存储库中。
一切都构建和执行良好。
问题
- 客户端项目和库没有同步发展。一些客户项目需要旧版本的库。人们必须在 Eclipse 中创建大量项目。某些库项目必须根据库存储库的不同版本多次创建。
- 我需要有很多库,因为对于单个库项目,其所有资源最终都会出现在客户端项目中,即使客户端实际上不使用其中任何一个。我在这儿吗?
- 我将同一库的不同版本签入工作区。使用 Eclipse,不可能导入多个库项目,因为 Eclipse 项目在 .project 文件中具有相同的名称(Eclipse 在尝试导入第二个库时会抱怨这一点)
- Eclipse?
编辑
Jarek Potiuk 的答案有效。但它只是解决了第 3 点中描述的问题。我仍然必须在 Eclipse 中单独创建每个库项目。
有没有一种解决方案可以让我不需要在 Eclipse 中为每个导入的库项目创建一个项目?有人有 ant 的工作解决方案吗?
First of all I have most of my knowlege about library projects from the google docs and a detailed description of the android build system in this article.
Setup
In my Eclipse workspace I have several client projects that import android libraries. Each client imports a different set of libraries and also some libraries import each other.
Each client has its own subversion repository and all the libraries are in one single subversion repository.
All builds and executes well.
Problems
- The client projects and the libraries are not evolving synchronously. Some client projects need older revisions of the libraries. One has to create lots of projects in Eclipse. Some libraries projects have to be created multiple times from different revisions of the library repository.
- I need to have lots of libraries because with a single library project all its resources would end up in the client project, even if the client actually does not use any of them. Am I right here?
- I check out different revisions of the same library into the workspace. With Eclipse it's not possible to import more than one library projects, because the eclipse projects have the same name in .project file (Eclipse complains about that when trying to import the second one)
- Eclipse??
EDIT
The answer of Jarek Potiuk works. But it just solves the Problem described in point 3. I still have to create each library project individually in Eclipse.
Is there a solution where I don't need to create a project in Eclipse for each library project imported? Has someone a working solution with ant?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让我解释一下我们如何处理它。我们正在使用 Mercurial subrepo,但在您的情况下使用 svn:externals 应该完全相同。
0)先决条件:确保您的 .project 和 .classpath 文件与您的项目一起提交到存储库......
1)在主项目中,我们有一个“subrepo”目录,我们将所有外部库(作为子目录)保存在那里。在 Mercurial 中,它是使用 subrepo 完成的,在 svn 中,您应该能够使用 svn:externals 配置链接到特定版本的库(SVN 标记或分支 URL): http://svnbook.red-bean.com/en/1.0/ch07s03.html
2) 最终效果是,当您签出主项目时,您会自动签出 subrepo 目录中的依赖库。到目前为止,一切都很好。
3)现在在 Eclipse 中,主目录失败,因为它没有链接库......在这种情况下你做什么 - “添加新的 Java 项目”,输入唯一的项目名称(例如libraryprojectname-mainprojectname取消选中“使用默认位置”并浏览到子存储库的库,然后将此项目添加为 Android 中的依赖项目...注意,唯一名称不会更改! .project 名称,但是它会让 Eclipse 签出多个库项目......
4) 现在,当你的项目编译时,将所有内容(包括 .project 和 .classpath 文件)提交到 repo...
5) 每当有人签出项目、库将以正确的版本检出,唯一需要的额外步骤是重复第 3 点 - 为子存储库添加新的 Java 项目并为该项目指定一个唯一的名称...就是这样(Eclipse 无论如何都会在内部引用子存储库) /library 目录不唯一 姓名)
Let me explain how we deal with it. We are using mercurial subrepo but it should be exactly the same using svn:externals in your case.
0) prerequisite: make sure your .project and .classpath files are commited to repo with your projects....
1) In main project we have a "subrepo" directory and we keep all the external libraries (as subdirectories) there. In mercurial it is done using subrepo, in svn you should be able to link to particular version of the library (SVN tag or branch URL) using svn:externals configuration: http://svnbook.red-bean.com/en/1.0/ch07s03.html
2) Net effect is that when you checkout the main project you automatically checkout the dependent libraries in subrepo directory. So far so good.
3) Now in eclipse you get the main directory failing, because it does not have the library linked..... What you do in this case - "Add new Java Project", type in UNIQUE project name (for example libraryprojectname-mainprojectname. Uncheck "Use default location" and browse to subrepo's library. Eclipse will configure the project for you from existing .project. Add this project as depending project in Android and possibly in eclipse as well... Note! the UNIQUE name will not change the .project name, but it will let eclipse to have more than one of your library projects checked out.....
4) Now when your project compiles commit everything (including .project and .classpath files) to repo...
5) Whenever someone checks out the project, library will be checked out in proper version and the only extra step needed is to repeat point 3) - add new Java Project for subrepo and give the project a unique name... That's about it (Eclipse will internally anyhow refer to subrepo/library directory not to the unique name)