是否有一种方法可以将maven配置为始终下载源代码和javadocs?每次指定-DdownloadSources=true -DdownloadJavadocs=true(这通常伴随着运行mvn compile两次,因为我忘记了第一次)变得相当乏味。
当前回答
我使用Maven 3.3.3,无法获得默认配置文件在用户或全局设置.xml文件中工作。
作为一种变通方法,您还可以在pom.xml文件中添加一个额外的构建插件。
<properties>
<maven-dependency-plugin.version>2.10</maven-dependency-plugin.version>
</properties>
<build>
<plugins>
<!-- Download Java source JARs. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>sources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
其他回答
我认为每个插件都可以做到。请参阅Maven书中的这一章。
你可以配置依赖插件来下载源代码(尽管我自己没有尝试过:-)。
只是整合和准备了一个命令来解决源代码和文档下载…
mvn dependency:sources dependency:resolve -Dclassifier=javadoc
在NetBeans上: 打开你的项目资源管理器->依赖项->[file.jar]右键单击->下载Javadoc
打开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中配置,否则它将在不同的地方重复
我使用Maven 3.3.3,无法获得默认配置文件在用户或全局设置.xml文件中工作。
作为一种变通方法,您还可以在pom.xml文件中添加一个额外的构建插件。
<properties>
<maven-dependency-plugin.version>2.10</maven-dependency-plugin.version>
</properties>
<build>
<plugins>
<!-- Download Java source JARs. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>sources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
推荐文章
- Java 8接口方法中不允许“同步”的原因是什么?
- 如何找到Java堆大小和内存使用(Linux)?
- 使用Enum实现单例(Java)
- RabbitMQ与通道和连接之间的关系
- buildSessionFactory()配置方法在Hibernate中已弃用?
- Spring MVC -如何获得所有的请求参数在一个地图在Spring控制器?
- 如何在Java中按两个字段排序?
- 文件之间的差异。路径中的分隔符和斜杠
- 在方法参数中使用NotNull注释
- Spring MVC中处理可选参数的@RequestParam
- 禁用maven下载进度指示
- Tomcat:如何查找正在运行的Tomcat版本?
- “java”、“javaw”和“javaws”之间有什么区别?
- 将Date对象转换为日历对象
- 在Java中保存最后N个元素的大小有限的队列