I saw that in Eclipse
I can define User Libraries - to make setting the classpath easier (and probably for other reasons as well).
我在Eclipse中看到,我可以定义用户库 - 使类路径设置更容易(也可能出于其他原因)。
The problem is, that these libraries are only available in the workspace, and if I want other people using the same project to use them - I need to export my user library and they need to import it.
问题是,这些库只在工作区中可用,如果我希望其他人使用同一个项目 - 我需要导出我的用户库,他们需要导入它。
Is there any functionality like this on the project level? I basically need to have a 'classpath group' - can it be done?
项目级别有这样的功能吗?我基本上需要一个'classpath group' - 可以做到吗?
If not, is there an automatic way to auto import the user library to the workspace when importing the project?
如果没有,导入项目时是否有自动导入用户库到工作区的方法?
I'm using Eclipse 3.6
.
我正在使用Eclipse 3.6。
4 个解决方案
#1
5
JDT has the 2 concepts, user libraries and classpath variables. In the classpath variable, you can add jars to your project. Other team members have to fill in the variables in their workspace so their classpath is complete. This is useful when external jars might be in different locations on each team members local file system.
JDT有2个概念,用户库和类路径变量。在classpath变量中,您可以将jar添加到项目中。其他团队成员必须在其工作空间中填写变量,以便完成其类路径。当外部jar可能位于每个团队成员本地文件系统的不同位置时,这很有用。
The USER_LIBRARY is a container for adding a logical group of local jars all at once. For example, the JRE_LIB container represents a number of local jars. But as you've seen, it points to a local set of jars meant to be used in multiple projects (as the JRE is added to multiple projects).
USER_LIBRARY是一个用于一次添加逻辑本地jar组的容器。例如,JRE_LIB容器表示许多本地jar。但正如您所见,它指向一个本地的罐子集合,用于多个项目(因为JRE被添加到多个项目中)。
Aside from export/import (which you're already doing), I don't believe you can check CLASS_LIBRARIES into a project's SCM. If there was, the preference page would have a "Configure Project specific settings" link at the top.
除了导出/导入(您已经在进行)之外,我不相信您可以将CLASS_LIBRARIES检查到项目的SCM中。如果有,则首选项页面顶部会显示“配置项目特定设置”链接。
Your best bet is to simply add the jars to the project, so they'll be included in the SCM. If they can be in different locations depending on the rest of your team, then use a classpath variable so it can be set in each workspace. That's the least amount of hassle as far as team members checking out the project and being ready to go.
最好的办法是简单地将罐子添加到项目中,这样它们就会被包含在SCM中。如果它们可以位于不同的位置,具体取决于团队的其他成员,则使用类路径变量,以便可以在每个工作区中进行设置。就团队成员检查项目并准备好进行而言,这是最少的麻烦。
#2
2
The best way IMO is to use m2eclipse - Maven plugin for eclipse. In Maven all the dependencies are defined in pom.xml and downloaded automatically as needed. This means that the only thing you share with your team is pom.xml - your project definition.
IMO的最佳方式是使用m2eclipse - Maven插件进行eclipse。在Maven中,所有依赖项都在pom.xml中定义,并根据需要自动下载。这意味着您与团队分享的唯一内容是pom.xml - 您的项目定义。
There is a lot more advantages when using m2eclipse vs standard eclipse approch. More information is at http://www.sonatype.com/books/m2eclipse-book/reference/
使用m2eclipse与标准的eclipse approch有很多优点。更多信息请访问http://www.sonatype.com/books/m2eclipse-book/reference/
#3
0
The way I have used user libraries is for something like Ant. Define a user library "ant" for all the jars in ANT_HOME/lib. If including this in your Eclipse .classpath and then sharing with other users, they will get a build problem report until they create that "ant" user library themselves. It's useful, but you need to share knowledge on how to create the library. If you're using it for simple cases like above, then instructions for adding the right jars to the library are straightforward.
我使用用户库的方式就像Ant一样。为ANT_HOME / lib中的所有jar定义用户库“ant”。如果在Eclipse .classpath中包含它,然后与其他用户共享,他们将获得构建问题报告,直到他们自己创建“ant”用户库。它很有用,但您需要分享有关如何创建库的知识。如果您将其用于上述简单的情况,那么将正确的jar添加到库中的说明很简单。
Another approach I've used is to build classpaths pointing into a folder (or folders) defined as a variable in Eclipse. See File -> New Folder -> Advanced -> Link to folder in the file system -> Variables
. This lets you setup (again at workspace level) variable references to one or more folders. You can then build your Eclipse classpath/s with reference to the folder/s.
我使用的另一种方法是构建指向Eclipse中定义为变量的文件夹(或文件夹)的类路径。请参阅文件系统中的文件 - >新建文件夹 - >高级 - >链接到文件夹 - >变量。这使您可以设置(在工作区级别)对一个或多个文件夹的变量引用。然后,您可以参考文件夹/ s构建Eclipse类路径。
So say in your development environment, everyone needs to have a directory called "thirdparty" containing all the external jars dependencies (probably in hierarchy within that dir: thirdparty/apache; thirdparty/sun; ...). You define "thirdparty" as a variable pointing to wherever that dir is on your current system, you create a folder in your project/s using the variable. You can then setup (and share) classpath using paths into that folder.
所以在开发环境中,每个人都需要有一个名为“thirdparty”的目录,其中包含所有外部jar依赖项(可能在该目录中的层次结构中:thirdparty / apache; thirdparty / sun; ...)。您将“thirdparty”定义为指向当前系统上dir所在位置的变量,您可以使用该变量在项目中创建一个文件夹。然后,您可以使用路径进入该文件夹来设置(和共享)类路径。
It's similar to User Library and with similar limitations. The limitation is that the other users you share your project with must create variable folder/s as you have. But it's more flexible in that they don't have to add the jars explicitly as they do with a library; rather, your classpath/s in Eclipse point into the folder, as required for each project.
它类似于用户库,具有类似的限制。限制是您与项目共享的其他用户必须创建变量文件夹。但它更灵活,因为它们不必像库存那样明确地添加罐子;相反,Eclipse中的classpath / s指向每个项目所需的文件夹。
Note that although the folder variable is defined at workspace level, it can be reused in multiple projects, each of which builds their classpaths (.classpath files) with different references into the folder).
请注意,虽然文件夹变量是在工作区级别定义的,但它可以在多个项目中重用,每个项目都使用不同的引用构建其类路径(.classpath文件)到文件夹中。
This is maybe something easier to show than to describe with words, but I hope it makes sense.
这可能比用文字描述更容易展示,但我希望它有意义。
#4
0
The following link might help,
以下链接可能有所帮助,
#1
5
JDT has the 2 concepts, user libraries and classpath variables. In the classpath variable, you can add jars to your project. Other team members have to fill in the variables in their workspace so their classpath is complete. This is useful when external jars might be in different locations on each team members local file system.
JDT有2个概念,用户库和类路径变量。在classpath变量中,您可以将jar添加到项目中。其他团队成员必须在其工作空间中填写变量,以便完成其类路径。当外部jar可能位于每个团队成员本地文件系统的不同位置时,这很有用。
The USER_LIBRARY is a container for adding a logical group of local jars all at once. For example, the JRE_LIB container represents a number of local jars. But as you've seen, it points to a local set of jars meant to be used in multiple projects (as the JRE is added to multiple projects).
USER_LIBRARY是一个用于一次添加逻辑本地jar组的容器。例如,JRE_LIB容器表示许多本地jar。但正如您所见,它指向一个本地的罐子集合,用于多个项目(因为JRE被添加到多个项目中)。
Aside from export/import (which you're already doing), I don't believe you can check CLASS_LIBRARIES into a project's SCM. If there was, the preference page would have a "Configure Project specific settings" link at the top.
除了导出/导入(您已经在进行)之外,我不相信您可以将CLASS_LIBRARIES检查到项目的SCM中。如果有,则首选项页面顶部会显示“配置项目特定设置”链接。
Your best bet is to simply add the jars to the project, so they'll be included in the SCM. If they can be in different locations depending on the rest of your team, then use a classpath variable so it can be set in each workspace. That's the least amount of hassle as far as team members checking out the project and being ready to go.
最好的办法是简单地将罐子添加到项目中,这样它们就会被包含在SCM中。如果它们可以位于不同的位置,具体取决于团队的其他成员,则使用类路径变量,以便可以在每个工作区中进行设置。就团队成员检查项目并准备好进行而言,这是最少的麻烦。
#2
2
The best way IMO is to use m2eclipse - Maven plugin for eclipse. In Maven all the dependencies are defined in pom.xml and downloaded automatically as needed. This means that the only thing you share with your team is pom.xml - your project definition.
IMO的最佳方式是使用m2eclipse - Maven插件进行eclipse。在Maven中,所有依赖项都在pom.xml中定义,并根据需要自动下载。这意味着您与团队分享的唯一内容是pom.xml - 您的项目定义。
There is a lot more advantages when using m2eclipse vs standard eclipse approch. More information is at http://www.sonatype.com/books/m2eclipse-book/reference/
使用m2eclipse与标准的eclipse approch有很多优点。更多信息请访问http://www.sonatype.com/books/m2eclipse-book/reference/
#3
0
The way I have used user libraries is for something like Ant. Define a user library "ant" for all the jars in ANT_HOME/lib. If including this in your Eclipse .classpath and then sharing with other users, they will get a build problem report until they create that "ant" user library themselves. It's useful, but you need to share knowledge on how to create the library. If you're using it for simple cases like above, then instructions for adding the right jars to the library are straightforward.
我使用用户库的方式就像Ant一样。为ANT_HOME / lib中的所有jar定义用户库“ant”。如果在Eclipse .classpath中包含它,然后与其他用户共享,他们将获得构建问题报告,直到他们自己创建“ant”用户库。它很有用,但您需要分享有关如何创建库的知识。如果您将其用于上述简单的情况,那么将正确的jar添加到库中的说明很简单。
Another approach I've used is to build classpaths pointing into a folder (or folders) defined as a variable in Eclipse. See File -> New Folder -> Advanced -> Link to folder in the file system -> Variables
. This lets you setup (again at workspace level) variable references to one or more folders. You can then build your Eclipse classpath/s with reference to the folder/s.
我使用的另一种方法是构建指向Eclipse中定义为变量的文件夹(或文件夹)的类路径。请参阅文件系统中的文件 - >新建文件夹 - >高级 - >链接到文件夹 - >变量。这使您可以设置(在工作区级别)对一个或多个文件夹的变量引用。然后,您可以参考文件夹/ s构建Eclipse类路径。
So say in your development environment, everyone needs to have a directory called "thirdparty" containing all the external jars dependencies (probably in hierarchy within that dir: thirdparty/apache; thirdparty/sun; ...). You define "thirdparty" as a variable pointing to wherever that dir is on your current system, you create a folder in your project/s using the variable. You can then setup (and share) classpath using paths into that folder.
所以在开发环境中,每个人都需要有一个名为“thirdparty”的目录,其中包含所有外部jar依赖项(可能在该目录中的层次结构中:thirdparty / apache; thirdparty / sun; ...)。您将“thirdparty”定义为指向当前系统上dir所在位置的变量,您可以使用该变量在项目中创建一个文件夹。然后,您可以使用路径进入该文件夹来设置(和共享)类路径。
It's similar to User Library and with similar limitations. The limitation is that the other users you share your project with must create variable folder/s as you have. But it's more flexible in that they don't have to add the jars explicitly as they do with a library; rather, your classpath/s in Eclipse point into the folder, as required for each project.
它类似于用户库,具有类似的限制。限制是您与项目共享的其他用户必须创建变量文件夹。但它更灵活,因为它们不必像库存那样明确地添加罐子;相反,Eclipse中的classpath / s指向每个项目所需的文件夹。
Note that although the folder variable is defined at workspace level, it can be reused in multiple projects, each of which builds their classpaths (.classpath files) with different references into the folder).
请注意,虽然文件夹变量是在工作区级别定义的,但它可以在多个项目中重用,每个项目都使用不同的引用构建其类路径(.classpath文件)到文件夹中。
This is maybe something easier to show than to describe with words, but I hope it makes sense.
这可能比用文字描述更容易展示,但我希望它有意义。
#4
0
The following link might help,
以下链接可能有所帮助,