• maven 之将项目打包压缩。


    用mavne打包的时候。默认只会打成jar包,但是他还需要依赖一些lib或者config。

    打包的时候都需要这些,最后打成zip,或者tar.gz 这样的包发布。

    需要一个maven-assembly-plugin插件

    pom.xml:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>appStoreServer</groupId>
        <artifactId>appStoreServer</artifactId>
        <version>1.0</version>
        <packaging>jar</packaging>
        <name>appStoreServer-source</name>
        <url>http://maven.apache.org</url>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
    
        <dependencies>
            *****
        </dependencies>
        
        <build>
            <finalName>xxxServer</finalName>
            <plugins>
                <!-- 自动复制maven依赖包到lib目录 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.1</version>
                    <executions>
                        <execution>
                            <id>copy</id>
                            <phase>install</phase>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                            <configuration>
                                <outputDirectory>lib</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                    </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
                <plugin>
                  <artifactId>maven-resources-plugin</artifactId>
                  <version>2.5</version>
                  <executions>
                    <execution>
                      <id>copy-resources</id>
                      <phase>validate</phase>
                      <goals>
                        <goal>copy-resources</goal>
                     </goals>
                    <configuration>
                       <outputDirectory>target/classes/com/xxx/app/dao/impl</outputDirectory>
                       <resources>          
                         <resource>
                           <directory>src/main/java/com/xxx/app/dao/impl</directory>
                        <includes>
                            <include>*.xml</include>
                        </includes>
                           <filtering>true</filtering>
                         </resource>
                       </resources>              
                     </configuration>            
                   </execution>
                 </executions>
               </plugin>
                    <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <configuration>
                        <!-- not append assembly id in release file name -->
                        <appendAssemblyId>false</appendAssemblyId>
                        <descriptors>
                            <descriptor>assembly.xml</descriptor>
                        </descriptors>
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                 </plugin>
            </plugins>
        </build>
    </project>

    assembly.xml

    <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
      <id>appStore</id>
      <formats>
          <format>tar.gz</format>
      </formats>
      <fileSets>
          <fileSet>
              <directory>${project.build.directory}</directory>
              <outputDirectory>/</outputDirectory>
              <includes>
                  <include>*.jar</include>
              </includes>
          </fileSet>
          <fileSet>
              <directory>config</directory>
              <outputDirectory>/config/</outputDirectory>
              <includes>
                  <include>*.xml</include>
                  <include>*.properties</include>
              </includes>
          </fileSet>
          <fileSet>
              <directory>bin</directory>
              <outputDirectory>/</outputDirectory>
              <includes>
                  <include>*.bat</include>
                  <include>*.py</include>
              </includes>
          </fileSet>
          <fileSet>
              <directory>lib</directory>
              <outputDirectory>/lib/</outputDirectory>
              <includes>
                  <include>*.jar</include>
              </includes>
          </fileSet>
      </fileSets>
      <baseDirectory>${project.build.finalName}-${project.version}</baseDirectory>
     </assembly>
  • 相关阅读:
    Map之类的东西
    [待码][BZOJ1858]SCOI2010序列操作 jzyzoj1655
    Linux 系统时间和硬件时间
    自动化运维之puppet的学习(如何找到你需要的模块)
    linux 搭建hexo博客
    坚持不懈之linux haproxy的配置文件关键字查询手册
    坚持不懈之linux haproxy 配置文件 详情
    Linux Haproxy 安装和部署
    linux 破解版confluence安装
    zookeeper 简介
  • 原文地址:https://www.cnblogs.com/montya/p/2874392.html
Copyright © 2020-2023  润新知