是否有一种方法可以将maven配置为始终下载源代码和javadocs?每次指定-DdownloadSources=true -DdownloadJavadocs=true(这通常伴随着运行mvn compile两次,因为我忘记了第一次)变得相当乏味。
当前回答
打开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中配置,否则它将在不同的地方重复
其他回答
在NetBeans上: 打开你的项目资源管理器->依赖项->[file.jar]右键单击->下载Javadoc
为了跟踪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书中的这一章。
你可以配置依赖插件来下载源代码(尽管我自己没有尝试过:-)。
在Netbeans中,您可以指示Maven在每个打开的项目上检查javadoc:
工具|选项| Java图标| Maven选项卡|依赖项类别|检查Javadoc下拉设置为每个项目打开。
关闭并重新打开Netbeans,您将在状态栏中看到Maven下载javadocs。
打开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中配置,否则它将在不同的地方重复
推荐文章
- 如何格式化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 ?
- 如何在新的材质主题中改变背面箭头的颜色?