如何将 javadoc 或源文件附加到 libs 文件夹中的 jars? [英] How to attach javadoc or sources to jars in libs folder?

查看:25
本文介绍了如何将 javadoc 或源文件附加到 libs 文件夹中的 jars?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于 Eclipse 的新版 ADT r17 插件添加了自动设置 JAR 依赖项的功能./libs 文件夹中的任何 .jar 文件现在都添加到构建配置中.不幸的是,Android Dependencies 类路径容器是不可修改的.

如何将 javadoc 和源文件附加到自动插入的 .jar(来自/libs 文件夹)?

解决方案

回答问题的最佳方式是总结 以下内容:

  1. 将库 .jar 放在 libs/ 文件夹中
  2. 使用以下内容创建一个 yourlibraryname.jar.properties 文件(不要忘记 .jar):

     doc=docs

  3. 将 javadocs 文件夹添加到 libs/ 文件夹.

您应该想出以下文件夹结构:

├── 文档│ ├── allclasses-frame.html│ ├── allclasses-noframe.html│ ├── com│ │ └── 谷歌│ │ └── 广告│ │ ├── Ad.html│ │ │ ....│ │ └── package-tree.html│ │ ...│ └── stylesheet.css├── GoogleAdMobAdsSdk-6.4.1.jar└── GoogleAdMobAdsSdk-6.4.1.jar.properties

不要忘记如上所述关闭并重新打开 Eclipse 项目!这是引用 GoogleAdMobAds Android 库的工作示例项目的屏幕截图.

New version of ADT r17 plugin for Eclipse added feature to automatically setup JAR dependencies. Any .jar files in the /libs folder are added to the build configuration now. Unfortunately Android Dependencies classpath container is non modifiable.

How can i attach javadoc and sources to the automatically inserted .jar (from /libs folder)?

解决方案

The best way to answer your question is to summarize the answers from Xavier, plastiv, VinceFR and Christopher.

Step by step guide

In order to link the sources and javadoc to a .jar library that is automatically linked by Eclipse you have to do the following:

  1. Place the library .jar file in the libs folder, and the associated source .jar and doc .jar files in separate subfolders such as libs/src and libs/docs. You can use a name other than src and docs if you want, but it's important that the .jar files aren't directly in the libs folder.
  2. Create a .properties file in the libs folder with the exact name of the actual library .jar (see example). Make sure you keep the .jar part.
  3. Specify the relative paths to the sources and javadoc .jar in the .properties file.
  4. Close and re-open the Eclipse project! Optionally, refresh the project by pressing F5.
  5. Select an object of the linked library in the source code.
  6. Open the Javadoc view in Eclipse to check the documentation (see screenshot).
  7. Open the source code declaration (default shortcut: F3) of the selected object.


Example

The example uses the Gson library.

Directory structure of the libs folder:

libs
├── docs
│   └── gson-2.2.2-javadoc.jar
├── gson-2.2.2.jar
├── gson-2.2.2.jar.properties
└── src
    └── gson-2.2.2-sources.jar

Contents of gson-2.2.2.jar.properties

src=src/gson-2.2.2-sources.jar
doc=docs/gson-2.2.2-javadoc.jar


Additional information

You can of course move the javadoc and sources .jar into other folders and specify relative paths. That's up to you. Placing the source and javadoc jars directly into the lib folder is possible but not recommended, as that causes documentation and source code to be included in your application.


Screenshot of the Eclipse JavaDoc panel:

Screenshot of an Eclipse project using Gson with Android 4.2.2.:


Referencing unpacked javadocs

In case you want to reference javadocs which are not provided as a packed .jar but simply as files and folders as asked by android developer in the comments do the following:

  1. Place the library .jar in the libs/ folder
  2. Create a yourlibraryname.jar.properties file (don't forget the .jar) with the following content:

     doc=docs
    

  3. Add the javadocs folders to the libs/ folder.

You should come up with the following folder structure:

├── docs
│   ├── allclasses-frame.html
│   ├── allclasses-noframe.html
│   ├── com
│   │   └── google
│   │       └── ads
│   │           ├── Ad.html
│   │           │   ....
│   │           └── package-tree.html
│   │   ...
│   └── stylesheet.css
├── GoogleAdMobAdsSdk-6.4.1.jar
└── GoogleAdMobAdsSdk-6.4.1.jar.properties

Do not forget to close and re-open the Eclipse project as mentioned above! Here is a screenshot of a working example project referencing the GoogleAdMobAds Android library.

这篇关于如何将 javadoc 或源文件附加到 libs 文件夹中的 jars?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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