有人知道是否可以在Maven存储库中找到源jar吗?
当前回答
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 The first command will attempt to download source code for each of the dependencies in your pom file. The second command will attempt to download the Javadocs. 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. 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
其他回答
要下载某些特定的源代码或javadoc,我们需要包括GroupIds -它是一个逗号分隔的值,如下所示
mvn dependency:sources -DincludeGroupIds=com.jcraft,org.testng -Dclassifier=sources
注意,分类器不是用逗号分隔的,要下载javadoc,我们需要使用分类器javadoc再次运行上述命令
mvn dependency:sources -DincludeGroupIds=com.jcraft,org.testng -Dclassifier=javadoc
我还使用eclipse插件将项目放到eclipse工作区中。 因为我在一个不同的项目中工作过,我发现可以使用eclipse而不使用maven-eclipse-plugin。这使得它更容易在不同的环境中使用,并使maven比eclipse更容易使用。并且不需要更改pom.xml文件。
所以,我推荐加布里埃尔·拉米雷斯的方法。
在eclipse中-点击项目然后:
.
您可以在这个相关问题中找到相关信息:获取附加到Eclipse的源jar文件,以获得maven管理的依赖关系 如果你使用eclipse maven插件,那么使用'mvn eclipse:eclipse -DdownloadSources=true'
如果您想手动找到任何工件的源jar文件,请转到特定工件的maven存储库位置,并在Files中单击“view All”。你可以找到源jar文件。