将Eclipse库项目添加到Eclipse构建路径? [英] Adding Android library project to Eclipse build path?

查看:572
本文介绍了将Eclipse库项目添加到Eclipse构建路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多模块的Android Maven项目,它由几个项目和一个Android库项目(baselib)组成,我在那里运行非基于Android的JUnit测试。





只要我运行Maven的测试,它就可以工作。当我使用Run-> As JUnit测试运行Eclipse的baselib JUnit测试时,我没有获得当前版本。这意味着JUnit测试的更改在我创建Maven之前没有任何效果。我想到将bin文件夹添加到Eclipse构建路径,但是我在Eclipse中收到一条错误消息:



< blockquote>

无法嵌套输出文件夹... baselib-TRUNK / bin / classes
... baselib-TRUNK / bin


这不清楚。所以我想到将jar本身添加到构建路径。我添加一次作为外部jar,然后一次作为jar。但是我仍然没有获得当前版本的代码,尽管如果我修改并保存一些代码,jar的时间戳具有当前版本。 (在Eclipse中检查自动构建)。输出文件夹被Eclipse的构建路径配置识别为... / bin / classes,它在pom.xml中设置。我还尝试添加 / bin / test-classes 来构建包含测试类本身的路​​径,但仍然没有新版本的代码。



为什么这不能获得当前版本,我该如何解决这个问题?

解决方案

由于图书馆项目在同一个工作区,我们可以直接引用该项目。打开项目的首选项,然后点击Android部分。





现在,您将看到一个用于引用库项目的窗口。



点击添加...按钮,选择所需的项目,点击确定,然后点击应用。
只有标记为库的项目才能以此方式进行选择和引用。如果您的项目没有出现,请打开他们的首选项,并在此窗口中标记是库框。



您的项目现在将引用这些库,包括任何你对他们的改变这比使用jar更好,如果你的图书馆将会改变。否则,您将不得不每次更改时删除并重新添加该jar。


I have a multi module Android Maven project which consists of several projects and an Android library project (baselib) where I run non Android based JUnit tests.

This works as long as I run the test by Maven. When I run the baselib JUnit tests by Eclipse with Run->As JUnit test, I don't get the current version. That means that changes in the JUnit test have no effect until I make a Maven build.

I thought about adding the bin folder to the Eclipse build path, but I get an error message in Eclipse:

Cannot nest output folder ...baselib-TRUNK/bin/classes inside ...baselib-TRUNK/bin

That's somehow clear. So I thought about adding the jar itself to the build path. I added it once as external jar, then once as jar. But I still don't get the current version of the code although the timestamp of the jar has the current version if I modify and save some code. (Build Automatically is checked in Eclipse). Output folder is recognized by Eclipse's build path configuration as .../bin/classes which is set in pom.xml. I also tried to add /bin/test-classes to build path which contains the test class itself, but still no new version of the code.

Why does this not work to get the current version and how can I solve this?

解决方案

Since the library projects are in the same workspace, we can reference the project directly. Open the preferences for your project and click on the "Android" section.

Now, you will see a window for referencing library projects.

Click the "Add..." button, select the projects you want, click "OK", and hit "Apply". Only projects that are marked as libraries can be selected and referenced in this manner. If your projects are not appearing, open their preferences and mark the "Is Library" box in this window of their preferences.

Your project will now reference these libraries, including any changes you make to them. This is better than using a jar if your libraries will be subject to change. Otherwise, you would have to remove and re-add the jar every time you make a change.

这篇关于将Eclipse库项目添加到Eclipse构建路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆