zoukankan      html  css  js  c++  java
  • Download/Attach source-code/java-docs with maven dependencies

    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.

  • 相关阅读:
    写了一个Windows服务,通过C#模拟网站用户登录并爬取BUG列表查询有没有新的BUG,并提醒我
    WCF快速上手(二)
    Oracle递归查询
    100多行代码实现6秒完成50万条多线程并发日志文件写入
    C#写日志工具类
    WPF定时刷新UI界面
    HttpUtil工具类
    WPF GridView的列宽度设置为按比例分配
    Visifire图表
    C# BackgroundWorker 的使用、封装
  • 原文地址:https://www.cnblogs.com/sos-blue/p/3515503.html
Copyright © 2011-2022 走看看