各大城市网站哪里做,微信小程序是怎么做出来的,北京个人制作网站有哪些内容,烟台市建设工程质量检测网站文章目录 配置示例 其他官网文档问题maven打包插件是如何和打包动作关联在一起的?配置文件中 goal是必须的吗? maven自定义插件内容很多#xff0c;也不易理解#xff0c;这里把maven打包插件单拿出来#xff0c;作为入口试着理解下。 配置示例
plugingroupI… 文章目录 配置示例 其他官网文档问题maven打包插件是如何和打包动作关联在一起的?配置文件中 goal是必须的吗? maven自定义插件内容很多也不易理解这里把maven打包插件单拿出来作为入口试着理解下。 配置示例
plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-jar-plugin/artifactIdversion3.2.2/versionconfiguration!--要使用的打包配置.--archive!-- 创建的归档文件是否包含以下pom.xml 和pom.properties Maven 文件,默认是true --addMavenDescriptortrue/addMavenDescriptor!-- 生成MANIFEST.MF的设置 --manifest!-- 为依赖包添加路径, 这些路径会写在MANIFEST文件的Class-Path下 --addClasspathtrue/addClasspath!-- 这个jar所依赖的jar包添加classPath的时候的前缀如果这个jar本身和依赖包在同一级目录则不需要添加 --classpathPrefixlib//classpathPrefix!-- jar启动入口类 --mainClasscom.example.demo.DemoApplication/mainClass/manifestmanifestEntries!-- 在Class-Path下添加配置文件的路径 --!--Class-Path../config//Class-Path--/manifestEntries/archive!-- jar包的位置其中${project.build.directory}默认为 target/ --outputDirectory${project.build.directory}/outputDirectory!--过滤掉不希望包含在jar中的文件--excludesexclude${project.basedir}/xml/*/exclude/excludes!--要包含的文件列表--includes!-- 打jar包时打包class文件和config目录下面的 properties文件 --!-- 有时候可能需要一些其他文件这边可以配置包括剔除的文件等等 --include**/*.class/includeinclude**/*.properties/include/includes/configuration
/plugin
如上标签就是打包插件自定义的。其他的如等都是maven基础标签。
所有标签中的内容都是用Parameter注入的如果必填加上 required true。
Parameter(defaultValue ${project.build.outputDirectory}, required true)private File classesDirectory;其他
官网文档
apache打包插件官网地址 https://maven.apache.org/plugins/maven-jar-plugin/jar-mojo.html
github地址 https://github.com/apache/maven-jar-plugin.git
问题
maven打包插件是如何和打包动作关联在一起的?
创建类的时候就定义了。 defaultPhase LifecyclePhase.PACKAGE 这一行就是。
Mojo(name jar,defaultPhase LifecyclePhase.PACKAGE,requiresProject true,threadSafe true,requiresDependencyResolution ResolutionScope.RUNTIME)
public class JarMojo extends AbstractJarMojo {}配置文件中 goal是必须的吗?
想要解答这个问题先要知道控制执行有几种方式。
两种 1、 Mojo注解中defaultPhase设置默认phase(阶段)。 2、配置文件中指定。 如
plugingroupIdcom.example/groupIdartifactIdmy-plugin/artifactIdversion1.0.0/versionexecutions!-- 在compile阶段执行插件的goal-1目标 --executionidexecution-1/idphasecompile/phasegoalsgoalgoal-1/goal/goals/execution!-- 在install阶段执行插件的goal-2和goal-3目标 --executionidexecution-2/idphaseinstall/phasegoalsgoalgoal-2/goalgoalgoal-3/goal/goals/execution/executions
/plugin这样也实现了goal和phase的绑定。
那么另外一个问题也迎刃而解maven自定义插件可以有多个goal(mojo)吗? 当然可以参考maven-install-plugin有两个mojoinstall和install-file。