Reputation: 9886
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
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?
Upvotes: 1
Views: 672
Reputation: 20107
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)
Upvotes: 2