Maven开发实战-插件使用

212 阅读1分钟

Maven开发实战-插件使用

对常见的Maven插件使用进行整理,根据使用情况持续更新插件使用列表。

License插件使用

对编写的文件提供统一的license头信息进行管理维护 license-maven-plugin

常见license模板

  • 使用说明
<?xml version="1.0" encoding="utf-8"?>
<plugin>
    <groupId>com.mycila</groupId>
    <artifactId>license-maven-plugin</artifactId>
    <version>4.1</version>
    <configuration>
    <!--header头部信息参参数定义,通过${owner}方式引用-->
    <properties>
    <owner>XXX</owner>
    <email>XXX@qq.com</email>
    </properties>
    <strictCheck>false</strictCheck>
    <!--头部信息文件配置-->
    <header>${project.baseUri}/../license/templates/VANLU-WEAVER.txt</header>
    <!--排除文件-->
    <excludes>
    <exclude>**/README</exclude>
    <exclude>src/test/resources/**</exclude>
    <exclude>src/main/resources/**</exclude>
    </excludes>
    </configuration>
</plugin>
  • 插件Goals
license:check: 检查文件是否有license header信息
license:format: 更新、添加license header信息
license:remove: 移除已有的license header信息
  • license模板参考 注意: license中不要带注释相关内容,license插件会自动添加
    Copyright (c) 2012-2028, ${owner} All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the xxx developer nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

ProGuard混淆插件使用

ProGuard是一个压缩、优化和混淆Java字节码文件的免费的工具,它可以删除无用的类、字段、方法和属性。可以删除没用的注释,最大限度地优化字节码文件。它还可以使用简短的无意义的名称来重命名已经存在的类、字段、方法和属性。常常用于Android开发用于混淆最终的项目,增加项目被反编译的难度 proguard
proguard-maven-plugin