Eclipse:通过本地属性将源/javadoc 附加到库 [英] Eclipse: Attach source/javadoc to a library via a local property

查看:39
本文介绍了Eclipse:通过本地属性将源/javadoc 附加到库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 SVN 存储库中有一个第三方库,我想在 Eclipse 中将 source/javadoc 与其本地关联.即,应该有一些本地设置(例如,local.properties 文件中的一个条目)将源/javadoc 与 JAR 文件相关联,但不会将本地依赖项引入存储库通过 .classpath.理想情况下我会

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

local.properties然后

<classpathentry kind="lib" path="lib.jar" sourcepath="${lib_src_dir}">

.classpath 中.这能做到吗?

in .classpath. Can this be done?

@VonC 的回答很有帮助...有没有办法从文本文件(例如,local.properties)加载路径变量而不是通过 Window -> Preferences ->常规 -> 工作区 -> 链接资源?

@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:

  • 创建链接文件夹结合
  • 链接资源的声明

链接的资源定义了一个路径变量,它等于 /my/path/to/lib/src

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)

该变量实际上始终是本地的(对于一个人的工作区),并且将通过 Linked Resources 首选项屏幕进行修改.

The variable is actually always local (to one's workspace), and will be modified through the Linked Resources preference screen.

链接的文件夹也可以是...链接的文件,从而允许通过相对路径(相对于变量)引用存档.
然后这个链接的文件(这里是一个链接的存档)可以在source"属性中关联到你的classpathentry.

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.

链接资源的问题在于它们位于工作区的本地,位于首选项中.
您可以导出[myPrefs.epf]文件中的首选项,然后修剪导出的文件以只留下包含pathvariable<的行/code>:

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

任何人都可以导入这个特殊的首选项文件,它只会影响Linked Resources"部分.

Anyone can then import this special preference file, which will only affect the "Linked Resources" part.

那个解决方案不是很令人满意,因为.epf首选项文件不能自动加载到项目中.
当我设置一个带有定义路径的链接资源的项目时,我总是在我的项目的根目录下留下一个大的 README.txt,以煽动所述项目的用户定义相同的链接资源使用他/她自己的固定本地路径.

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.

特别是:

DevByStarlight评论 项目(自 2011 年 10 月以来不太活跃)workspacemechanic.

DevByStarlight mentions in the comments the project (not very active since Oct. 2011) workspacemechanic.

Workspace Mechanic 通过调整首选项、添加扩展位置等自动维护 Eclipse 环境.你可以用它来:

The Workspace Mechanic automates maintenance of your Eclipse environment by tweaking preferences, adding extension locations, and so on. You can use it to:

  • 在整个公司、您的本地团队,甚至您自己的许多工作区之间创建一致的环境
  • 节省设置新工作区的时间
  • 创建任务以确保您最喜欢的新首选项应用于您当前和未来的所有工作区.(这是我们最喜欢的功能之一!)

工作区机械师行为的关键是Task.
任务描述了一个简单的测试和一个操作,该操作在运行时会改变环境,以便测试随后通过.
Tasks 可以有多种形式:首选项文件、Java 类、Groovy 脚本和 Eclipse 扩展.您可以轻松定义自己的任务.

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.

它带有一组脚本:

这篇关于Eclipse:通过本地属性将源/javadoc 附加到库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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