Eclipse - 外部JAR和git [英] Eclipse - External JARs and git

查看:171
本文介绍了Eclipse - 外部JAR和git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用eclipse来处理Java。另外我使用git来同步我的笔记本电脑和我的台式电脑之间的项目。

现在的问题如下:我在项目中添加了外部JAR(Slick-Util,LWJGL)。

但是每个设备上的每个库的路径都是另一个。因此,每次我开始在其他设备上工作时,都必须更改jar文件和javadocs的路径。

这些库都存储在我的eclipse工作区中。所以库和项目都在同一个文件夹中。而且这个文件夹也是用git来提交的。

有没有办法改变eclipse的设置(或者做其他的事情),所以我不必每次都改变库和javadoc的路径?

I am currently using eclipse for working with Java. Additionaly I use git to synchronize my project between my laptop and my desktop PC.
The problem is now the following: I added external JARs to the project (Slick-Util, LWJGL).
But the path to each library is another on each device. So everytime I start working on the other device, I have to change the path to the jar files and the javadocs.
The libraries are all stored in my eclipse workspace. So the libraries and the projects are all in the same folder. And this folder is also commited with git.
Is there a way to change the eclipse settings (or do something else) so I do not have to change the path to the libraries and javadocs everytime?

我已经搜索并搜索了它,但是我找不到它。

I already googled and searched for it, but I could not find something about it.

推荐答案

只是不要将库的jar添加到git。有多种针对java的构建工具,它们为您管理依赖关系 - 您只需声明要使用的库,然后构建工具会在构建时为您下载它。

Just don't add the libraries' jars to git. There are multiple build tools for java, which manage dependencies for you - you just state the libraries you're going to use, and the build tool downloads it for you at build time.

我会推荐 Gradle ,但

I would recommend Gradle, but Maven is also a very popular choice.

在gradle中,您将创建一个文件 build。

In gradle, you would create a file build.gradle, and define your dependencies in it:

apply plugin: 'eclipse'
apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.lwjgl.lwjgl:lwjgl:2.9.0'
    compile 'org.lwjgl.lwjgl:lwjgl_util:2.9.0'
}

然后,您可以从命令行运行 gradle eclipse - 这会将您使用的库添加到eclipse中的类路径中。当你想编译和打包项目时,你可以从命令行运行 gradle build 。你应该阅读它,如果你打算使用它,我所描述的可能不完全是你需要的。

Then you would run gradle eclipse from the command line - that would add the libraries you use to the classpath in eclipse. And when you want to compile and package your project you would run gradle build from the command line. You should read about it if you're going to use it, what I describe may not be exactly what you need.

另外,那里使用LWJGL和maven的说明

这篇关于Eclipse - 外部JAR和git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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