I am using Maven in my projects from last couple of years, and the automatically downloading the Jars from repository feature of maven is really helpful for developers. But If you are using Eclipse and want to read/analyse Source Code or Java Doc of API then you need the jar file that contains the Source code and java doc of the API, but unfortunately maven does not download and attach the source code and java doc of the APIs automatically.

Maven provides some different ways to download and attach that source code and Java Doc:

  • Using maven eclipse plugin
  • Using maven dependency plugin

Note: The sources and javadocs of the libraries must exist in the repository so that the plugin can download it and attach it.

1. Maven eclipse plugin:

Maven dependencies that are deployed with the source and javadocs can be downloaded and attached to the Eclipse library by using maven-eclipse-plugin. It can be done by:

  • passing command-line argument to the maven-eclipse-plugin, or
  • by declaring in the pom.xml

1.1 passing command-line argument to maven-eclipse-plugin:

This example shows that how to do this by passing command line argument to the maven-eclipse-plugin:

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

1.2 declaring in the pom.xml

This sample pom shows that how to declare downloadSources and downloadJavadocs configuration in pom.xml

<project>

<build>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-eclipse-plugin</artifactId>

<configuration>

<downloadSources>true</downloadSources>

<downloadJavadocs>true</downloadJavadocs>

</configuration>

</plugin>

</plgins>

</build>

</project>

2. Maven dependency plugin:

maven-dependency-plugin provides a goal named sources that resolves the project source dependencies from the repository.

usage:

mvn dependency:sources

mvn dependency:resolve -Dclassifier=javadoc

This is useful when you want the source attachments downloaded to your local repository and you don’t want to use the eclipse plugin to do this since the eclipse plugin creates/overwrites the eclipse files.

Download/Attach source-code/java-docs with maven dependencies的更多相关文章

  1. Attach source code to a Netbeans Library Wrapper Module

    http://rubenlaguna.com/wp/2008/02/22/attach-source-code-to-a-netbeans-library-wrapper-module/ Attach ...

  2. Spring 4 MVC example with Maven - [Source Code Download]

    In this tutorial, we show you a Spring 4 MVC example, using Maven build tool. Technologies used : Sp ...

  3. maven下载源码和java docs

    方法一: mvn dependency:sources mvn dependency:resolve -Dclassifier=javadoc The first command will attem ...

  4. How to build the Robotics Library from source code on Windows

    The Robotics Library is an open source C++ library for robot kinematics, motion planning and control ...

  5. [转]Native Java Bytecode Debugging without Source Code

    link from:http://www.crowdstrike.com/blog/native-java-bytecode-debugging-without-source-code/index.h ...

  6. Artistic Style 3.1 A Free, Fast, and Small Automatic Formatter for C, C++, C++/CLI, Objective‑C, C#, and Java Source Code

    Artistic Style - Index http://astyle.sourceforge.net/ Artistic Style 3.1 A Free, Fast, and Small Aut ...

  7. Java Sound : generate play sine wave - source code

    转载自:http://ganeshtiwaridotcomdotnp.blogspot.com/2011/12/java-sound-generate-play-sine-wave.html Work ...

  8. Sound (audio file) player in java - working source code example

    转载自:http://ganeshtiwaridotcomdotnp.blogspot.com/2011/12/sound-audio-file-player-in-java-working.html ...

  9. VS Code Java 3月更新|代码补全、Maven 以及 Java 插件预览版本新升级!

    Nick Zhu Senior Program Manager, Developer Division at Microsoft 大家好,欢迎来到 Visual Studio Code Java 的 ...

随机推荐

  1. MySQL中视图和普通表的区别

    1.视图是数据库数据的特定子集.可以禁止所有用户访问数据库表,而要求用户只能通过视图操作数据,这种方法可以保护用户和应用程序不受某些数据库修改的影响. 2.视图是抽象的,他在使用时,从表里提取出数据, ...

  2. IOS-网络(数据安全:MD5加密)

    // // ViewController.m // IOS_0129_HTTP请求 // // Created by ma c on 16/1/29. // Copyright © 2016年 博文科 ...

  3. Spring的注解@Qualifier(二十五)

    转载:https://www.cnblogs.com/smileLuckBoy/p/5801678.html 近期在捯饬spring的注解,现将遇到的问题记录下来,以供遇到同样问题的童鞋解决~ 先说明 ...

  4. 为什么样本方差自由度(分母)为n-1

    一.概念.条件及目的 1.概念 要理解样本方差的自由度为什么是n-1,得先理解自由度的概念: 自由度,是指附加给独立的观测值的约束或限制的个数,即一组数据中可以自由取值的个数. 2.成立条件 所谓自由 ...

  5. docker部署mysql

    1. 下载 [root@localhost my.Shells]# ./dockerStart.sh start or stop start Redirecting to /bin/systemctl ...

  6. iOS开发之 - 键盘处理神器 IQKeyboardManager

    平常在开发中,用到输入框的地方不胜其数,当输入框位于屏幕底部时,弹起的键盘很可能覆盖输入框,导致用户看不到输入结果,体验较差...... IQKeyboardManager 可以很简单快捷的解决键盘遮 ...

  7. 对MYSQL慢查询slow query 日志记录内容的疑惑

    初始:由于新装服务器出现CPU占用过高,响应不及时的问题排查,因为环境基于最基础的LAMP构架 想到开启 MYSQL slow_query_log 慢查询日志做原因分析: 但是看到日志内容之后有点茫然 ...

  8. BZOJ2124: 等差子序列(树状数组&hash -> bitset 求是否存在长度为3的等差数列)

    2124: 等差子序列 Time Limit: 3 Sec  Memory Limit: 259 MBSubmit: 2354  Solved: 826[Submit][Status][Discuss ...

  9. Codeforces 1006C:Three Parts of the Array(前缀和+map)

    题目链接:http://codeforces.com/problemset/problem/1006/C (CSDN又改版了,复制粘贴来过来的题目没有排版了,好难看,以后就截图+题目链接了) 题目截图 ...

  10. 使用TortoiseGit+码云管理项目代码

    1.下载安装msysgit. 2.下载安装tortoisegit. 3.创建ssh密钥. 开始–所有程序–TortoiseGit–PuTTYgen 生成方法:点击“Generate”后,鼠标在key下 ...