[英]how do I add open source API code to an eclipse project?
I have to write a java application which I'm putting together using eclipse and it relies on open source code. 我必须编写一个使用eclipse组合在一起的Java应用程序,它依赖于开源代码。 This application needs to be self-contained, meaning that I'm supposed to create a jar file that has no external dependencies.
该应用程序必须是独立的,这意味着我应该创建一个没有外部依赖关系的jar文件。
I can use the open source code when I reference the jar files in the project's build path, but the idea is to have the actual source code as part of the eclipse project, side-by-side with my code. 当我在项目的构建路径中引用jar文件时,可以使用开源代码,但其想法是将实际的源代码作为eclipse项目的一部分,与我的代码并排放置。
The source code can be found here: http://hc.apache.org/ , but when I import an existing file system into my project I can't quite get things to work. 可以在以下位置找到源代码: http : //hc.apache.org/ ,但是当我将现有文件系统导入到我的项目中时,我无法完全正常工作。 The packages end up with the wrong names, breaking references, and I can't do anything.
这些软件包的名称以错误的名称结尾,破坏了引用,并且我什么也做不了。 Notice that the folder containing the source code has this structure:
请注意,包含源代码的文件夹具有以下结构:
httpcomponents-client-4.2.3\
src\
httpmime\
httpclient-osgi
httpclient-contrib
httpclient-cache
httpclient-benchmark
httpclient
fluent-hc
each of those subfolders has src/main/java/org/apache subfolders. 这些子文件夹中的每一个都有src / main / java / org / apache子文件夹。
Can someone please explain how to do this? 有人可以解释一下该怎么做吗? Am I supposed to import everything one java file at a time?
我是否应该一次将所有内容导入一个Java文件?
Use a tool like OneJar , FatJar , JarJar , etc. to create a single-jar application. 使用诸如OneJar , FatJar , JarJar等工具创建单个jar应用程序。
As Charlie mentioned, the Maven Shade plugin is another choice, particularly if you're already using Maven. 正如Charlie提到的, Maven Shade插件是另一种选择,特别是如果您已经在使用Maven。 If you're not, consider it or another transitive dependency management tool.
如果不是,请考虑使用它或其他可传递依赖项管理工具。
Some tool should be used, IMO, and it's more important the more dependencies you have. 应该使用某些工具IMO,并且您拥有的依赖项越多越重要。
Alternatively you could use a jar class loader and include the jar file in your artifact. 或者,您可以使用jar类加载器 ,并将jar文件包含在工件中。
I would most definitely not include the source of dependencies in your own project. 我绝对不会在您自己的项目中包括依赖项的来源 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.