包括Java项目作为库 [英] Include Java project as library

查看:179
本文介绍了包括Java项目作为库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个项目在我的Eclipse工作区:

I have three projects in my eclipse workspace:

EventKitchenCore
EventKitchenDesktop
EventKitchenAndroid

EventKitchenCore 包含所有的核心功能,而 EventKitchenDesktop EventKitchenAndroid 是本质上只是不同的用户界面。

EventKitchenCore contains all the core functionality, and EventKitchenDesktop and EventKitchenAndroid are essentially just different user interfaces.

我有 EventKitchenCore 补充并作为一个库 EventKitchenDesktop ,但我无法弄清楚如何作为一个库添加到 EventKitchenAndroid

I have EventKitchenCore added and working as a library in EventKitchenDesktop, however I am unable to figure out how to add it as a library to EventKitchenAndroid.

如何做到这一点?这将是在屁股痛到要导出为在 LIB 目录每次罐子我做出改变......

How do I do this? It would be a pain in the tush to have to export as a jar in the lib directory every time I make a change...

我尝试添加核心项目性状> Java构建路径>库性状> Android的>库,但没有运气:\

I tried adding the Core project in Properties > Java Build Path > Libraries and Properties > Android > Library, but no luck :\

更新 - 现在,我得到了它通过导出核心项目的libs文件夹中的JAR工作。不过,我经常更改,就像我说的,这是在屁股痛。

Update - for now, I got it working by exporting the core project as a jar in the libs folder. However I make frequent changes, and like I said, it's a pain in the tush.

推荐答案

Eclipse已经内置蚂蚁的支持。你可以利用它来自动创建当前项目的JAR,并把它放在另一个项目的文件夹中。

Eclipse has builtin Ant support. You can make use of it to automatically create a JAR of the current project and put it in a folder of another project.

EventKitchenAndroid EventKitchenCore 项目都在同一个工作区,创建一个的build.xml 文件中的 EventKitchenCore 项目,该项目只包含这样的:

Provided that EventKitchenAndroid and EventKitchenCore projects are both in the same workspace, create a build.xml file in EventKitchenCore project which contains just this:

<?xml version="1.0" encoding="UTF-8"?>
<project name="EventKitchenCore" default="createjar">
    <target name="createjar">
        <jar destfile="../EventKitchenAndroid/libs/EventKitchenCore.jar" basedir="bin" />
    </target>
</project>

要进行测试,在Eclipse中选择文件和preSS <大骨节病>控制 + <大骨节病> F11 运行它作为Ant构建文件。如果一切正常,你想要的方式,那么你可以告诉Eclipse来自动执行每次项目建成这个构建文件。转到 EventKitchenCore 建筑工地的项目属性的属性,点击的导入... 的,选择<$您刚才创建C C>的build.xml 文件。

To test it, select the file in Eclipse and press Ctrl+F11 to run it as Ant build file. If it works the way you want, then you can tell Eclipse to automatically execute this build file everytime the project is built. Go to the project properties of EventKitchenCore and in the Builders property, click Import... and select the build.xml file you just created.

现在,将每次执行的项目建成。您可以通过pressing手动强制项目的构建<大骨节病>控制 + <大骨节病> B 。又见我刚刚创建的视频演示。

Now, it will be executed everytime the project is built. You can manually force the build of a project by pressing Ctrl+B. See also the video demo I just created.

这篇关于包括Java项目作为库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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