是否有任何缺点将API code成JAR的类一起? [英] Is there any disadvantage to putting API code into a JAR along with the classes?

查看:221
本文介绍了是否有任何缺点将API code成JAR的类一起?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中,如果打包源$ C ​​$ C(的.java)文件与类(的的.class)最IDE的像Eclipse将显示code中的javadoc注释沿罐完成。

In Java if you package the source code (.java) files into the jar along with classes (.class) most IDE's like eclipse will show the javadoc comments for code completion.

IIRC有一些做像JMock的几个开源项目。

IIRC there are few open-source projects that do this like JMock.

可以说,我已经完全分离我的API code从执行code,让我有类似的myproject-api.jar文件和myproject的-impl.jar中是否有任何理由为什么我不应该把源$在我的myproject-api.jar文件C $ C吗?

Lets say I have cleanly separated my API code from implementation code so that I have something like myproject-api.jar and myproject-impl.jar is there any reason why I should not put the source code in my myproject-api.jar ?

由于表现如何?大小?

为什么其它的项目做到这一点?

Why don't other projects do this?

编辑:除了Maven的下载问题将它伤害任何东西把我的源入类罐子,支持尽可能多的开发人员尽可能(行家与否)

推荐答案

由于一般分布的原因:

如果你保持独立的二进制文件和源代码,你只能你所需要的下载。结果
例如:

if you keep separate binaries and sources, you can download only what you need.
For instance:


  • MyProject的-api.jar文件 MyProject的-impl.jar中

  • MyProject的-API-src.jar MyProject的-implement执行-src.jar

  • myproject-api-docs.zip myproject-impl-docs.zip

  • myproject-api.jar and myproject-impl.jar
  • myproject-api-src.jar and myproject-impl-src.jar
  • myproject-api-docs.zip and myproject-impl-docs.zip

现在,<一个href=\"http://stackoverflow.com/questions/310720/get-source-jar-files-attached-to-eclipse-for-maven-managed-dependencies\">m2eclipse - Maven的Eclipse的可以download来源自动以及

mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true 

现在,它也可以<一个href=\"http://stackoverflow.com/questions/907659/how-do-i-get-eclipse-to-show-the-javadoc-from-my-classes-without-including-source\">generate正确的POM 以源或javadoc的罐子当有人宣布你的罐子依赖prevent分布。结果
在OP评论:

Now, it can also generate the right pom to prevent distribution of the source or javadoc jar when anyone declare a dependency on your jar.
The OP comments:

也无法想象的下载大小是一个问题(我的意思是这是2010年10万对夫妇不应该是一个问题)。

also can't imagine download size being an issue (i mean it is 2010 a couple 100k should not be a problem).

那么实际上它(即大小)是一个问题。结果
Maven的已经遭受从一半下载互联网上的第一个版本综合症。结果
如果下载的的来源和/或的javadoc,即开始真正讨厌的。

Well actually it (i.e. "the size) is a problem.
Maven suffers already from the "downloading half the internet on first build" syndrome.
If that downloads also sources and/or javadocs, that begins to be really tiresome.

另外,在分配方面包括在部署:在的 Web应用服务器,在它里面来部署源的罐子没有真正的好处。

Plus, the "distribution" aspect includes the deployment: in a webapp server, there is no real advantage to deploy a jar with sources in it.

最后,如果你真的需要与源关联的二进制文件,这个<一个href=\"http://stackoverflow.com/questions/1751551/maven-how-to-export-project-with-sources-and-dependencies\">SO Maven的问题可以帮助。

Finally, if you really need to associate sources with binaries, this SO question on Maven could help.

这篇关于是否有任何缺点将API code成JAR的类一起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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