<?xml version="1.0" encoding="UTF-8"?&gt;
<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"&gt;

    <!--全局build--&gt;
    <build&gt;
        <finalName&gt;platform-sms-admin</finalName&gt;
        <plugins&gt;
            <plugin&gt;
                <groupId&gt;org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies-to-admin-web-service</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeClassifiers>jar-with-dependencies</includeClassifiers>
                            <outputDirectory>${project.basedir}/target/platform-sms-admin/plugin</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>assemble</id>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <attach>false</attach>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.courage.platform.sms.admin.SmsAdminApplication</mainClass>
                        </manifest>
                    </archive>
                    <excludes>
                        <exclude>**/*.properties</exclude>
                        <exclude>**/*.xml</exclude>
                        <exclude>**/*.yml</exclude>
                        <exclude>static/**</exclude>
                        <exclude>public/**</exclude>
                        <exclude>templates/**</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!--如果 pom 中有任何一个 profile 通过其他方式被激活的话,所有配置成默认激活的 profile 都会自动失效 .
    mvn help:active-profiles 查看当前激活的 profile
    mvn help:all-profiles 查看所有的 profile-->
    <profiles>
        <profile>
            <!--不同环境Profile的唯一id 激活方式 mvn clean install -P npm,otherProfile-->
            <id>npm</id>
            <properties>
                <!--profiles.active是自定义字段(名字随便起),自定义字段可以有多个-->
                <!--resource文件中的.properties配置使用@profiles.active@方式读取
            properties标签下的内容-->
                <profiles.active>dev</profiles.active>
            </properties>
            <activation>
                <file>
                    <!--如果指定的文件存在,则激活profile。 -->
                    <exists>${basedir}/file2.properties</exists>
                    <!--如果指定的文件不存在,则激活profile。 -->
                    <missing>${basedir}/file1.properties</missing>
                </file>
                <!--当匹配jdk检测到,profile被激活。例如,1.4激活JDK1.4,1.4.0_2,而!1.4激活所有版本不是以1.4开头的JDK。 -->
                <jdk>1.5</jdk>
                <!--激活方式 mvn clean install -D env=npm-->
                <property>
                    <!--激活profile的属性的名称 -->
                    <name>env</name>
                    <!--激活profile的属性的值 -->
                    <value>npm</value>
                </property>
                <!--mvn激活Profiles时如果不指定P后面的参数默认使用当前profile.  mvn clean package-->
                <activeByDefault>true</activeByDefault>
            </activation>
            <!--profile指定环境下的build-->
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <version>3.0.0</version>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>src/main/resources/public</directory>
                                </fileset>
                            </filesets>
                        </configuration>
                    </plugin>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.0.2</version>
                        <executions>
                            <execution>
                                <id>copy Vue.js frontend content</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>src/main/resources/public</outputDirectory>
                                    <overwrite>true</overwrite>
                                    <resources>
                                        <resource>
                                            <directory>${project.parent.basedir}/admin-ui/target/dist</directory>
                                            <includes>
                                                <include>static/</include>
                                                <include>index.html</include>
                                                <include>avatar.gif</include>
                                                <include>logo.png</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>dev</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property>
                    <name>env</name>
                    <value>!prod</value>
                </property>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <descriptors>
                                <descriptor>${basedir}/src/main/assembly/dev.xml</descriptor>
                            </descriptors>
                            <finalName>platform-sms-admin</finalName>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

        </profile>

        <profile>

            <id>prod</id>
            <activation>
                <property>
                    <name>env</name>
                    <value>prod</value>
                </property>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <descriptors>
                                <descriptor>src/main/assembly/prod.xml</descriptor>
                            </descriptors>
                            <finalName>platform-sms-admin</finalName>
                            <outputDirectory>${project.basedir}/target</outputDirectory>
                        </configuration>
                    </plugin>
                </plugins>
            </build>

        </profile>
    </profiles>

</project>

原文地址:https://blog.csdn.net/qq_41551345/article/details/134672635

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_3470.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注