[英]How to import source from GitHub into an Eclipse project
I am trying to use this tool from Google: https://github.com/pcj/google-options 我正在尝试从Google使用此工具: https : //github.com/pcj/google-options
In the example given by Google, they use: 在Google提供的示例中,他们使用:
import com.google.devtools.common.options.OptionsParser;
to allow their example code to use the command line parser. 允许他们的示例代码使用命令行解析器。
When I do this, Eclipse says the referenced files don't exist. 当我这样做时,Eclipse表示引用的文件不存在。
I have tried putting the source file from google-options
in a package in my project; 我试图将来自
google-options
的源文件放在我项目的一个包中; no luck. 没运气。 I tried running Google's example, and it won't even compile.
我尝试运行Google的示例,但它甚至无法编译。 It can't find all of the classes in its own src folder.
它无法在其自己的src文件夹中找到所有类。
Based on my research, I think there's either an issue with a .jar
file needing to be in the build path, something to do with Apache Ant, or an issue with GitHub I don't understand. 根据我的研究,我认为可能是在构建路径中需要存在
.jar
文件问题,与Apache Ant有关,或者与我不了解的GitHub有关。
I'm very new to GitHub; 我是GitHub的新手。 this is the first time I've tried to do anything like this.
这是我第一次尝试做这样的事情。
You should first import this project from GitHub to your local machine. 您应该首先将此项目从GitHub导入到本地计算机。
import
statement in your class means that classes from other packages should be imported to this class you're working on. import
语句意味着应该将其他包中的类导入到您正在使用的类中。 Import not from the remote source, but from local. 不是从远程源导入,而是从本地导入。
I figured it out. 我想到了。 It needs the
guava.jar
file found here added to the buildpath. 它需要
guava.jar
找到的文件在这里加入到构建路径。 After that, it has a couple weird dependency issues with javax, but I just removed those (it was Nullable and Immutable, if anyone's interested). 之后,它与javax存在一些奇怪的依赖关系问题,但我只是删除了这些问题(如果有人感兴趣,它是Nullable和Immutable)。
First you must clone the project and compile it, to do that put the following commands: 首先,您必须克隆项目并进行编译,然后执行以下命令:
cd {workspace}
cd {workspace}
git clone https://github.com/pcj/google-options.git
git clone https://github.com/pcj/google-options.git
mvn clean install
mvn clean install
File /Import...
choose Existing Maven project
, browse your workspace where the projetc was cloned. File /Import...
选择Existing Maven project
,浏览克隆了projetc的工作区。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.