可以“附加源”更容易流行的Java库? [英] Could "attach source" be made easier for popular Java libraries?

查看:86
本文介绍了可以“附加源”更容易流行的Java库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到这个障碍,当我的调试器进入一些类文件
没有相应的源。找到它往往很困难:




  • 您必须搜索托管相应项目的网站
    并找到它``下载源码'页面(例如,上次我在JPA API中搜索
    ,花了我几个小时才能获得资源)。或者,您可能需要
    才能从修订版控制中查看。


  • 您需要知道正在使用的确切版本。否则
    调试器可能会进入注释和空行:)


  • 没有打包源代码的约定,有些
    项目包括它在罐子本身;一些提供单独的zip文件;
    其他人将其放在zip中的 src / 子文件夹中。




我知道,当生成IDE配置文件时,Maven可以从其存储库下载源代码,并将
包含在src路径中。但是
Maven的回购在内容方面是如此糟糕,几乎没有lib实际上有
他们的源上传。



为什么这么复杂,当它可以做得很简单我们可以有
一些中央repo,它将一个类文件(或其散列)与从其编译的源
文件(或其链接)相关联。也许是一个相当巨大的回购,但
很简单的结构。一个IDE插件可以查询它来自动获取所需的内容。



你们有没有经历过这样的事?



如何获取附加的来源?

解决方案

m2eclipse ,IDEA将下载任何依赖关系的源和javadoc。可以通过右键单击依赖关系(或整个项目,如果您想要所有来源)并单击Maven->下载源来下载m2eclipse源。





在较新版本的m2eclipse您还可以通过转到窗口 - >首选项 - >Maven,然后选择下载人工神经源选项来自动下载源。当您在依赖性jar中打开一个目前没有可用资源的类型时,Maven将在后台下载源代码,并在后台更新源附件。




I run into this obstacle when my debugger steps into some classfile without corresponding source. Finding it is often difficult:

  • You have to search for the site hosting the respective project, and find its ``download source'' page (for instance, last time I searched for the JPA API, and it took me hours to obtain the sources). Or, you might be required to check it out from revision control.

  • You need to know the exact version you are using. Otherwise the debugger might step into comments and empty lines :)

  • There is no convention for packaging source code—some projects include it in the jar itself; some provide a separate zip file; others put it in a src/ subfolder within the zip.

I know Maven has the capability of downloading source from its repository and including it in the src paths when an IDE config file is generated. But Maven's repo is so poor in terms of content—few libs actually have their source uploaded.

Why is it so complicated when it can be made straightforward? We could have some central repo which relates a classfile (or a hash thereof) to the source file it was compiled from (or a link to it). Maybe a rather huge repo, but pretty simply structured. An IDE plugin could query it to fetch what's needed automatically.

Have you, guys, experienced the same?

How do you obtain the sources to attach?

解决方案

Both m2eclipse and IDEA will download the sources and javadocs for any dependencies. The m2eclipse sources can be downloaded by right-clicking on a dependency (or the whole project if you want all sources) and clicking Maven->Download Sources.

On newer versions of m2eclipse you can also automatically download sources by going to Window->Preferences...->Maven, then selecting the "Download Artifact Sources" option. When you open a type in a dependency jar that there are currently no sources available for, Maven will download the sources in the background and update the source attachment in the background.

这篇关于可以“附加源”更容易流行的Java库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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