是否有一种方法可以将maven配置为始终下载源代码和javadocs?每次指定-DdownloadSources=true -DdownloadJavadocs=true(这通常伴随着运行mvn compile两次,因为我忘记了第一次)变得相当乏味。
当前回答
为了跟踪kevinarpe的答案,这对sources和Javadocs都做了:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<goals>
<goal>sources</goal>
<goal>resolve</goal>
</goals>
</execution>
</executions>
<configuration>
<classifier>javadoc</classifier>
</configuration>
</plugin>
</plugins>
</build>
其他回答
我认为每个插件都可以做到。请参阅Maven书中的这一章。
你可以配置依赖插件来下载源代码(尽管我自己没有尝试过:-)。
打开settings.xml文件~/.m2/settings.xml(如果它不存在就创建它)。添加添加了属性的部分。然后确保activeProfiles包含新的概要文件。
<settings>
<!-- ... other settings here ... -->
<profiles>
<profile>
<id>downloadSources</id>
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>downloadSources</activeProfile>
</activeProfiles>
</settings>
编辑:正如Jingguo Yao提到的,这只适用于Eclipse IDE -同样也可以在您选择的IDE中配置。在Eclipse via Window -> Preferences -> Maven菜单中,尽管这可能必须在每个工作空间级别和新的Eclipse安装中完成。
或者在你的pom.xml中配置maven-dependency-plugin在一个单独的概要文件中,并根据需要运行它——将它保留在主构建中会导致在不需要源代码或java文档的构建节点上的构建时间(不必要的拉长(更不用说空间了)。最好在一些组织或部门的父pom.xml中配置,否则它将在不同的地方重复
我必须使用KeyStore来下载jar。如果您有任何与证书相关的问题,您可以使用以下方法:
mvn clean install dependency:sources -Dmaven.test.skip=true -Djavax.net.ssl.trustStore="Path_To_Your_KeyStore"
如果你想知道如何创建密钥库,这是一个非常好的链接: 在代理后使用Maven和SSL的问题
不确定,但是你应该能够通过在settings.xml中设置一个默认的活动配置文件来做一些事情
See
参见http://maven.apache.org/guides/introduction/introduction-to-profiles.html
对于依赖级的源代码(pom.xml),您可以添加:
<classifier>sources</classifier>
推荐文章
- 如何格式化Joda-Time DateTime仅为mm/dd/yyyy?
- 如何在POM.xml中引用环境变量?
- 如何在android中复制一个文件?
- 将整数转换为字符串,以逗号表示千
- 接口方法的最终参数-有什么意义?
- Java中的@UniqueConstraint注释
- 如何在清洁模式下运行eclipse ?如果我们这样做会发生什么?
- 获取java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory异常
- Java中的正则表达式命名组
- c#和Java的主要区别是什么?
- 什么是NullPointerException,我如何修复它?
- 在Java中使用“final”修饰符
- 无法在Flutter上找到捆绑的Java版本
- 如何在Kotlin解析JSON ?
- 如何在新的材质主题中改变背面箭头的颜色?