maven package

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven package相关的知识,希望对你有一定的参考价值。

Shell Script

 

#!/bin/bash
#-----------------------------------------------
# FileName: pack.sh
# Reversion: 1.2
# Date: 2017/06/15
# Author: zhengwenqiang
# Email: [email protected]126.com.cn
# Description: mvn package with specialized maven profile.
# Notes: 
# Execute this script with GNU environment which cound be initialized through installation of mingw on windows.
# Copyright: 2017(c) zhengwenqiang
# License: GPL
#-----------------------------------------------

if [ -n $M2_HOME -o -n $MAVEN_HOME ] ; then
# delete target directory.
    [ -d target ] && mvn clean
# package war file with profile which id is deploy
    [ $? -eq 0 ] && mvn package -Pdeploy
elif [ -z $M2_HOME -a -z $MAVEN_HOME ] ; then
    echo "could not exec mvn cmd, error!"
fi 

pom.xml

<profiles>
    <profile>
    <!-- 批量部署 -->
    <id>deploy</id>
    <properties>
    <finalName>warName</finalName>
    </properties>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <configuration>
                            <target>
                                <copy todir="${basedir}/target/classes/" overwrite="true">
                                <fileset dir="${basedir}/release/deploy/resources/"/>
                                </copy>
                                <copy todir="${basedir}/src/webapp/WEB-INF/" overwrite="true">
                                <fileset dir="${basedir}/release/deploy/WEB-INF/"/>
                                </copy>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    </profile>
</profiles>

Project Structure

技术分享

 

以上是关于maven package的主要内容,如果未能解决你的问题,请参考以下文章

将特定目录及其内容添加到Universal目标

maven web项目的web.xml报错The markup in the document following the root element must be well-formed.(代码片段

VSCode插件开发全攻略代码片段设置自定义欢迎页

怎么使用maven package命令

maven package生成的包在哪

在idea中使用maven打包项目跳过测试代码