maven-compiler-plugin
在pom.xml中没有声明的加入这个plugin时,是按照1.3来进行编译的。
可以在这个plugin中指定source和target的版本,当指定的版本是1.5,而用到的编译器确实jdk1.6时,即使源码中用到了JDK1.6库中的方法,照样可以编译通过。
当然,如果source中有泛型,设定版本为1.3,还是编译不过的。
这里source和target版本的含义应该是指定java虚拟机所能识别的版本号。
在上面这个case中,jdk1.6编译的,目标版本1.5编译后,在1.5的虚拟机上运行错误,提示所用1.6库中的方法不存在。
可如果编译目标版本是1.6,然后在1.5虚拟机上运行错误提示Bad version number in .class file。
所以,如果希望在1.5编译时就发现错误,就要用1.5的编译器。
maven-antrun-plugin
ant是一个老牌的项目打包管理系统了,目前虽然已经慢慢被maven取代,但其功能的强大仍然是很多场合下的首选,尤其是众多的task可以基本满足任何需求。其实在maven中也有使用ant的需求,比如不同环境打包编译时使用不同的配置信息等,或者是说做一些文件删除、复制之类的事情,这有些是maven做不来的,而ant就可以了,况且maven中已经有了maven-antrun-plugin插件,专门为在maven中运行ant做好了准备。 使用这个插件,只需要在项目的pom文件中定义如下插件片段:
Java代码
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>compile</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <delete file="${project.build.directory}/classes/abc.properties" />
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
这里,我们在maven的编译阶段执行一些文件的删除操作,比如将测试环境的配置文件删除,复制生产环境的配置文件等等,我们都可以使用ant的task来定义。通过ant的maven插件,可以将ant的强大功能也都引入到maven中来,实现二者的强强结合。 参考文档: 1、maven-antrun-plugin插件:http://maven.apache.org/plugins/maven-antrun-plugin/ 2、ant的task列表总览:http://ant.apache.org/manual/tasksoverview.html
maven-surefire-plugin
The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports in 2 different file formats:
- Plain text files (*.txt)
- XML files (*.xml)
By default, these files are generated at ${basedir}/target/surefire-reports.
Goals Overview
The Surefire Plugin has only 1 goal:
- surefire:test runs the unit tests of an application.
maven-eclipse-plugin
Maven Eclipse plugin是用来生成eclipse的project文件的,如(.classpath、.project等)。
maven-source-plugin
The Source Plugin creates a jar archive of the source files of the current project. The jar file is, by default, created in the project's target directory.
当使用一个普通的jar包时,集成环境(比如Eclipse)没有足够的信息用来显示类的javadoc,连接口参数的名称都会变成arg0,arg1等等这样的样式。为了显示javadoc,我们必须手工指定库的源码所在。而像我这么懒的程序员,怎么可能靠手工解决问题呢?
我们可以用Maven的source plugin来方便的解决这个问题。在编译jar包的时候,plugin可以编一个源码包。把它部署到你的Maven源中,用Maven的eclipse plugin就可以直接将源码加到classpath并在集成环境使用了。
分享到:
相关推荐
maven工具包 org\apache\maven\....
Apache MyFaces Trinidad Maven Plugins.zip
Maven更新问题 今天Maven在更新的时候发现一直更新不成功,总结下解决方法。 在apache-maven-3.5.2/conf/setting.xml中加入以下配置即可解决 alimaven aliyun maven ...
在你的 eclipse 安装的根目录下创建两个文件夹:links,mavenPlugins(文件夹名称可自定义),把eclipse-maven3-plugin.7z解压后的features和plugins文件夹放到mavenPlugins文件夹下(必须如此,注意解压后文件夹的...
Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project
Discover when and how to use the various Apache Maven plugins Generate and publish your project documentation using Apache Maven Analyze and control code quality and code coverage using Apache Maven ...
Customize the build process to suit your enterprise needs by developing custom Maven plugins, lifecycles, and archetypes Implement and deploy a Maven repository manager to manage the build process in ...
GitHub Maven Plugins Collection of Maven plugins that integrate with GitHub. These plugins are built on top of API v3 through the GitHub Java library. Released builds are available from Maven Central...
Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具
Build your own custom plugins and get to know how Maven extension points are used Troubleshoot build issues with greater confidence Optimize Maven's configuration settings Write custom lifecycles and ...
eclipse4.5 mars 64位 自带Maven插件
hadoop 使用 maven3.3 仓库 5hadoop 使用 maven3.3 仓库 5
在<plugins></plugins>中添加 <groupId>org.apache.maven.plugins <artifactId>maven-compiler-plugin <version>3.8.1 <source>1.8 <target>1.8 </plugin>
< groupId>com.dkanejs.maven.plugins</ groupId> < artifactId>docker-compose-maven-plugin $VERSION 关于 Maven插件,用于通过Maven运行基本的docker-compose命令。 它可以用作Maven生命周期的一部分,也...
maven-plugins:[不建议使用] Apache Maven插件的镜像
Some Maven plugins may not work when importing projects or updating source folders. 解决办法有2种: 1、 在eclipse.ini中添加VM启动参数,制定eclipse启动使用的vm,修改后的文件内容如下 -showsplash org...
下载适用于Maven的插件 这是一个插件,旨在帮助Maven用户在Maven构建的一部分中以不同的协议下载不同的文件。 关于artifactId的警告:在1.1版之前,插件artifactId以前是maven-download-plugin ,但是Maven约定使该...
Maven 1.x插件(http://maven.apache.org/maven-1.x/)-从单个项目描述符管理项目的所有方面(测试,文档,分发)! 该项目提供了由于许可证不同而未与Maven捆绑在一起的插件。
<groupId>org.apache.maven.plugins <artifactId>maven-shade-plugin <version>3.1.0 <phase>package <goal>shade implementation="org.apache.maven.plugins.shade.resource....
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装