从 Maven 存储库获取源 JAR [英] Get source JARs from Maven repository

查看:42
本文介绍了从 Maven 存储库获取源 JAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道您是否可以在 Maven 存储库上找到源 JAR 文件吗?

Does anyone have any idea if you can find source JARs on Maven repositories?

推荐答案

Maven Micro-Tip:获取源代码和 Javadocs

当您在 IDE 中使用 Maven 时,您经常会发现您的 IDE 需要为您的库依赖项解析源代码和 Javadoc.有一个简单的方法可以实现这个目标.

Maven Micro-Tip: Get sources and Javadocs

When you're using Maven in an IDE you often find the need for your IDE to resolve source code and Javadocs for your library dependencies. There's an easy way to accomplish that goal.

mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc

第一个命令将尝试下载 pom 文件中每个依赖项的源代码.

The first command will attempt to download source code for each of the dependencies in your pom file.

第二个命令将尝试下载 Javadoc.

The second command will attempt to download the Javadocs.

Maven 在这里受图书馆打包者的支配.因此,其中一些没有打包源代码,而其中许多没有 Javadoc.

Maven is at the mercy of the library packagers here. So some of them won't have source code packaged and many of them won't have Javadocs.

如果您有很多依赖项,使用它也可能是个好主意包含/排除以获取特定工件,以下命令例如,将只下载依赖项的源代码特定的 artifactId:

In case you have a lot of dependencies it might also be a good idea to use inclusions/exclusions to get specific artifacts, the following command will for example only download the sources for the dependency with a specific artifactId:

mvn dependency:sources -DincludeArtifactIds=guava

来源:http://tedwise.com/2010/01/27/maven-micro-tip-get-sources-and-javadocs/

文档:https://maven.apache.org/plugins/maven-dependency-plugin/sources-mojo.html

这篇关于从 Maven 存储库获取源 JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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