有人知道是否可以在Maven存储库中找到源jar吗?
当前回答
下载任何工件使用
mvn dependency:get -Dartifact=groupId:artifactId:version:packaging:classifier
对于Groovy源代码,这将是
mvn dependency:get -Dartifact=org.codehaus.groovy:groovy-all:2.4.6:jar:sources
对于Groovy的javadoc,您将使用
mvn dependency:get -Dartifact=org.codehaus.groovy:groovy-all:2.4.6:jar:javadoc
这将把给定的工件放到本地Maven存储库中,通常是$HOME/.m2/存储库。
Dependency:sources只下载项目依赖项的源代码,不下载插件源代码,也不下载插件内部定义的依赖项的源代码。
其他回答
配置和运行maven-eclipse插件(例如从命令行mvn eclipse:eclipse)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
</plugins>
</build>
为了调试,你也可以使用“Java反编译器”,如:JAD,并在运行中反编译源代码(尽管生成的源代码永远不会与原始源代码相同)。然后将JAD作为插件安装到Eclipse或您喜欢的IDE中。
如果你正在使用eclipse,你也可以打开Preferences > Maven并选择下载Artifact Sources,这将使pom.xml保持完整,并将你的源代码或java文档(如果选中)保存在你的机器位置~/.m2中进行开发
IntelliJ idea的maven idea插件允许您指定是否应该解析和下载源代码和java文档
mvn idea:idea -DdownloadSources=true -DdownloadJavadocs=true
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
推荐文章
- 在流中使用Java 8 foreach循环移动到下一项
- 访问限制:'Application'类型不是API(必需库rt.jar的限制)
- 用Java计算两个日期之间的天数
- 如何配置slf4j-simple
- 在Jar文件中运行类
- 带参数的可运行?
- 我如何得到一个字符串的前n个字符而不检查大小或出界?
- 我可以在Java中设置enum起始值吗?
- Java中的回调函数
- c#和Java中的泛型有什么不同?和模板在c++ ?
- 在Java中,流相对于循环的优势是什么?
- Jersey在未找到InjectionManagerFactory时停止工作
- 在Java流是peek真的只是调试?
- Recyclerview不调用onCreateViewHolder
- 将JSON字符串转换为HashMap