Eclipse:通过本地属性将源/ javadoc附加到库中 [英] Eclipse: Attach source/javadoc to a library via a local property
问题描述
我的SVN存储库中有一个第三方库,我想在Eclipse中将source / javadoc与它本地关联。即,应该有一些本地设置(例如, local.properties
文件中的条目),它将源/ javadoc与JAR文件相关联,但不包含通过 .classpath
将本地依赖关系引入存储库。理想情况下,我会有
lib_src_dir = / my / path / to / lib / src
$ c $在 local.properties
然后
$ b $中的c>
b
< classpathentry kind =libpath =lib.jarsourcepath =$ {lib_src_dir}>
在 .classpath
中。这可以做吗
@ VonC的答案很有帮助...有没有办法从文本文件中加载路径变量(例如, local.properties
)而不是通过Window - > Preferences - > General - > Workspace - > Linked Resources?
p>我相信这会更好地实现:
- 创建一个链接的文件夹与
- 链接资源的声明
链接的资源定义一个路径变量,该变量将等于 /我/ path / to / lib / src
链接的文件夹将引用您链接的资源
< img src =https://i.stack.imgur.com/cwywG.gifalt =链接资源>
(可以使用一个变量,而不是一个固定的路径,带有变量按钮)
该变量实际上是本地(到自己的工作区),并将通过链接资源
首选项屏幕进行修改。
链接的文件夹也可以是...链接的文件,从而允许通过相对路径(相对于变量)引用归档。
然后这个链接的文件(这里是一个链接的归档)可以与源
属性中的 classpathentry
相关联。
链接资源的问题在于首选项中的工作区本地。
您可以导出首选项一个 [myPrefs.epf]
文件,然后修剪导出的文件,以便只留下包含 pathvariable
:
/instance/org.eclipse.core.resources/pathvariable.MY_DIRECTORY= / my / path / to / lib / src
任何人都可以导入这个特殊的首选项文件,只影响链接资源
part。
该解决方案不是很令人满意,因为 .epf
首选项文件无法在项目中自动加载。
当我使用定义路径的链接资源设置项目时,我总是留下一个大的$ c> README.txt 在我的项目的根目录,以煽动所述项目的用户使用他/她自己的固定本地路径定义相同的链接资源。
DevByStarlight 在评论该项目(2011年10月以来不太活跃) workspacemechanic 。
Workspace Mechanic通过调整首选项,添加扩展位置等来自动维护Eclipse环境。您可以使用它:
- 在整个公司,本地团队甚至自己的团队之间创建一个一致的环境许多工作区
- 节省设置新工作空间的时间
- 创建确保您最喜欢的新偏好适用于所有当前和未来工作空间的任务。 (这是我们最喜欢的功能之一!)
Workspace Mechanic的行为的关键是
任务
。
一个任务描述了一个简单的测试和一个动作,运行时会更改环境,以便测试随后通过。
任务
可以有多种形式:首选项文件,Java类,Groovy脚本和Eclipse扩展。您可以轻松地定义自己的任务。
它附带了一系列脚本:
I have a third-party library in my SVN repository and I'd like to associate source/javadoc with it locally in Eclipse. I.e., there should be some local setting (for example, an entry in the local.properties
file) that associates the source/javadoc with the JAR file, but which doesn't introduce local dependencies into the repository via .classpath
. Ideally I'd have
lib_src_dir = /my/path/to/lib/src
in local.properties
and then
<classpathentry kind="lib" path="lib.jar" sourcepath="${lib_src_dir}">
in .classpath
. Can this be done?
[EDIT] @VonC's answer is helpful... Is there a way to load Path Variables from a text file (e.g., local.properties
) instead of going through Window -> Preferences -> General -> Workspace -> Linked Resources?
I believe this would be better achieved through:
- the creation of a linked folder combined with
- the declaration of a linked resource
The linked resource defines a path variable which would be equals to /my/path/to/lib/src
The linked folder would refers to your linked resource
(you can use a variable and not a fixed path, with the "Variable" button)
The variable is actually always local (to one's workspace), and will be modified through the Linked Resources
preference screen.
The linked folder can also be... a linked file, thus allowing the reference of an archive through a relative path (relative to the variable).
Then this linked file (here a linked archive) can be associated to your classpathentry
in the "source
" attribute.
The problem with Linked Resources is they are local to the workspace, in the preferences.
You can export the preferences in a [myPrefs.epf]
file, and then trim the exported file in order to leave only the lines containing pathvariable
:
/instance/org.eclipse.core.resources/pathvariable.MY_DIRECTORY=/my/path/to/lib/src
Anyone can then import this special preference file, which will only affect the "Linked Resources
" part.
That solution is not very satisfying, since the .epf
preference file can not be loaded automatically in the project.
When I setup a project with a linked resources defining a path, I always leave a big README.txt
at the root of my project, in order to incite the user of said project to define that same linked resources with his/her own fixed local path.
Several bugs are in progress to enhance this situation or around the Linked Resources topic.
Especially:
- Exporting a project with linked resources
- Relative paths without variables
- Have linked resources relative to workspace paths
- Would like to use path relative to workspace root
DevByStarlight mentions in the comments the project (not very active since Oct. 2011) workspacemechanic.
The Workspace Mechanic automates maintenance of your Eclipse environment by tweaking preferences, adding extension locations, and so on. You can use it to:
- Create a consistent environment among groups as large as the entire company, your local team, or even among your own many workspaces
- Save time setting up new workspaces
- Create tasks that ensure your favorite new preferences are applied to all your current and future workspaces. (This is one of our favorite features!)
The key to the Workspace Mechanic's behavior is the
Task
.
A task describes a simple test and an action that, when run, changes the environment so the test will subsequently pass.
Tasks
can come in many forms: preference files, Java classes, Groovy scripts and Eclipse extensions. You can easily define your own Tasks.
It comes with a collection of scripts:
这篇关于Eclipse:通过本地属性将源/ javadoc附加到库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!