Can i save comment info in my Jar file(generated by Ant)?

試著忘記壹切 提交于 2019-12-11 01:03:26

问题


When I build my project to a Jar file with Ant, I generate javadoc the same time.

But when I use this Jar in a new Project, I can't see the Jar's comment in the Eclipse(pressing F2).

So I tried to add the javadoc files' location path in 'javadoc Location' of Properties of my new Project,it doesn't work, even if Eclipse tell me the 'Location is likely valid'.

When I open it in Browser,the Url is like file:///file:/C:/Users/topxebec/Desktop/doc/index.html, there's two prefix in the url,but in the eclipse I only have file:/C:/Users/topxebec/Desktop/doc/index.html,.

I tried to change it to C:/Users/tongxuebin/Desktop/doc/ but Eclipse said it was a Invalid URL.

So how to solve this problem? Or,can I simply save the comments in the Jar when it generated by Ant?


回答1:


It seems, that you can't put the javadoc in the same jar as the class files, so that eclipse will automatically show the doc.

A solution is to include the source-code. This will also help, if you need to debug the classes in that jar.

This answer: How can I build my jar file so that users who use the library will be able to see the javadoc in Eclipse covers that case. But it just boils down to:

<target name="jar.noCompile.src">  
    <jar destfile="${ant.project.name}.jar">  
      <fileset dir="${classes}"/>  
      <fileset dir="${src}" includes="**/*.java"/>  
    </jar>  
</target>  


来源:https://stackoverflow.com/questions/9817483/can-i-save-comment-info-in-my-jar-filegenerated-by-ant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!