Maven高级应用--编译全模块包-dist包

1. 在需要生成dist包的模块级别,新建文件夹xxx-xxxx-dist

2. 进入目录,新建pom.xml,建议copy

3. dependencies节点,把要编译成全局包的应用引入进来

<!-- 引入依赖模块 -->
<dependency> <groupId>xxx.xxx.xxxx</groupId> <artifactId>xxx-xxx-core</artifactId> <version>${project.version}</version> </dependency>

4. build节点设置文件名称

<finalName>xxx-core</finalName>

5. build->plugins节点新增如下插件

插件一:生成dist包

<!-- 生成xxx-core包 -->
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-shade-plugin</artifactId>
   <version>1.4</version>
   <executions>
      <execution>
        <phase>package</phase>
        <goals>
            <goal>shade</goal>
        </goals>
        <configuration>
            <createSourcesJar>true</createSourcesJar>
            <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
           <artifactSet>
            <includes>
                <include>xxx.xxx.xxx:xxx-core-*</include>
              </includes>
           </artifactSet>
       </configuration>
     </execution>
   </executions>
</plugin>

插件二:输出到指定目录

<!-- 输出到上级目录 -->
  <plugin>
   <artifactId>maven-antrun-plugin</artifactId>
   <executions>
    <execution>
    <phase>package</phase>
    <goals>
     <goal>run</goal>
    </goals>
    <configuration>
     <tasks>
      <copy file="${project.build.directory}/xxx-core.jar" tofile="${project.basedir}/../xxx-core.jar" overwrite="true" />
      <copy file="${project.build.directory}/xxx-core-javadoc.jar" tofile="${project.basedir}/../xxx-core-javadoc.zip" overwrite="true" />
     </tasks>
    </configuration>
    </execution>
   </executions>
  </plugin>

插件三:生成javadoc包

<!-- 生成javadoc包 -->
  <plugin>
   <artifactId>maven-javadoc-plugin</artifactId>
   <version>3.0.1</version>
   <executions>
    <execution>
   <id>attach-javadoc</id>
   <goals>
     <goal>jar</goal>
   </goals>
   <configuration>
     <doclint>none</doclint>
   </configuration>
    </execution>
   </executions>
   <configuration>
    <includeDependencySources>true</includeDependencySources>
    <dependencySourceIncludes>
        <dependencySourceInclude>xxx.xxx.xxx:xxx-core-*</dependencySourceInclude>
    </dependencySourceIncludes>
    <show>public</show>
    <charset>UTF-8</charset>
    <encoding>UTF-8</encoding>
    <docencoding>UTF-8</docencoding>
    <links>
    <link>http://docs.oracle.com/javase/7/docs/api</link>
    </links>
    <tags>
    <tag>
     <name>@author</name>
     <placement>a</placement>
     <head>作者</head>
    </tag>
    <tag>
     <name>@email</name>
     <placement>a</placement>
     <head>作者邮箱</head>
    </tag>
    <tag>
     <name>@date</name>
     <placement>a</placement>
     <head>创建时间</head>
    </tag>
    </tags>
   </configuration>
</plugin>

 

posted @ 2019-03-27 14:11  ζ  简单ヾ°  阅读(1309)  评论(0编辑  收藏  举报