Maven工具(二)

131 阅读1分钟

生命周期与插件

clean生命周期 清理工作

pre-clean:执行一些需要在clean之前完成的工作 clean:清除所有上次构建生成的文件 post-clean:执行一些需要在clean之后立刻完成的工作

<phases>
  <phase>pre-clean</phase>
  <phase>clean</phase>
  <phase>post-clean</phase>
</phases>
<default-phases>
  <clean>
    org.apache.maven.plugins:maven-clean-plugin:3.2.0:clean
  </clean>
</default-phases>

default生命周期 核心工作,例如编译,测试,打包,部署等

image.png

<phases>
  <phase>validate</phase>
  <phase>initialize</phase>
  <phase>generate-sources</phase>
  <phase>process-sources</phase>
  <phase>generate-resources</phase>
  <phase>process-resources</phase>
  <phase>compile</phase>
  <phase>process-classes</phase>
  <phase>generate-test-sources</phase>
  <phase>process-test-sources</phase>
  <phase>generate-test-resources</phase>
  <phase>process-test-resources</phase>
  <phase>test-compile</phase>
  <phase>process-test-classes</phase>
  <phase>test</phase>
  <phase>prepare-package</phase>
  <phase>package</phase>
  <phase>pre-integration-test</phase>
  <phase>integration-test</phase>
  <phase>post-integration-test</phase>
  <phase>verify</phase>
  <phase>install</phase>
  <phase>deploy</phase>
</phases>

site生命周期 产生报告,发布站点等

pre-site:执行一些需要在生成站点文档之前完成的工作 site:生成项目的站点文档 post-site:执行一些需要在生成站点文档之后完成的工作,并且为部署做准备 site-deploy:将生成的站点文档部署到特定的服务器上

<phases>
  <phase>pre-site</phase>
  <phase>site</phase>
  <phase>post-site</phase>
  <phase>site-deploy</phase>
</phases>
<default-phases>
  <site>
    org.apache.maven.plugins:maven-site-plugin:3.12.1:site
  </site>
  <site-deploy>
    org.apache.maven.plugins:maven-site-plugin:3.12.1:deploy
  </site-deploy>
</default-phases>

插件 支持生命周期运行

<build>
    <plugins>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.4.0</version>
        <executions>
          <execution>
            <id>auto-clean</id>
            // 执行的生命周期
            <phase>initialize</phase>
            // 对什么进行打包
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

分模块开发与设计

image.png

模块聚合

image.png

image.png

image.png

image.png

模块继承

image.png

image.png

image.png

image.png

父工程进行依赖管理 image.png

image.png

属性定义与使用

属性:也就是变量,定义之后,可以在其他地方使用 image.png

image.png

image.png

image.png

版本管理

资源配置

image.png

多环境配置

image.png

image.png

跳过测试

image.png

image.png

image.png

私服

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png