#!/bin/bash
#修改 spring-boot-maven-plugin 配置
#增加 maven-dependency-plugin 配置

numStart=`grep -n -B4 'spring-boot-maven-plugin' pom.xml | grep '<plugin>' | awk -F- '{print $1}'`

numEnd=`grep -n -A4 'spring-boot-maven-plugin' pom.xml | grep '</plugin>' | awk -F- '{print $1}'`

sed -i "${numStart},${numEnd}d" pom.xml

sed -i "${numStart}i\                    </plugin>" pom.xml
sed -i "${numStart}i\                        </executions>" pom.xml
sed -i "${numStart}i\                            </execution>" pom.xml
sed -i "${numStart}i\                                </configuration>" pom.xml
sed -i "${numStart}i\                                    <outputDirectory>\${project.build.directory}/libs</outputDirectory>" pom.xml
sed -i "${numStart}i\                                    <includeScope>runtime</includeScope>" pom.xml
sed -i "${numStart}i\                                    <type>jar</type>" pom.xml
sed -i "${numStart}i\                                <configuration>" pom.xml
sed -i "${numStart}i\                                </goals>" pom.xml
sed -i "${numStart}i\                                    <goal>copy-dependencies</goal>" pom.xml
sed -i "${numStart}i\                                <goals>" pom.xml
sed -i "${numStart}i\                                <phase>package</phase>" pom.xml
sed -i "${numStart}i\                                <id>copy</id>" pom.xml
sed -i "${numStart}i\                            <execution>" pom.xml
sed -i "${numStart}i\                        <executions>" pom.xml
sed -i "${numStart}i\                        <artifactId>maven-dependency-plugin</artifactId>" pom.xml
sed -i "${numStart}i\                        <groupId>org.apache.maven.plugins</groupId>" pom.xml
sed -i "${numStart}i\                    <plugin>" pom.xml

sed -i "${numStart}i\                    </plugin>" pom.xml
sed -i "${numStart}i\                        </configuration>" pom.xml
sed -i "${numStart}i\                            </includes>" pom.xml
sed -i "${numStart}i\                                </include>" pom.xml
sed -i "${numStart}i\                                    <artifactId>\${project.artifactId}</artifactId>" pom.xml
sed -i "${numStart}i\                                    <groupId>\${project.groupId}</groupId>" pom.xml
sed -i "${numStart}i\                                <include>" pom.xml
sed -i "${numStart}i\                            <includes>" pom.xml
sed -i "${numStart}i\                            <layout>ZIP</layout>" pom.xml
sed -i "${numStart}i\                        <configuration>" pom.xml
sed -i "${numStart}i\                        <artifactId>spring-boot-maven-plugin</artifactId>" pom.xml
sed -i "${numStart}i\                        <groupId>org.springframework.boot</groupId>" pom.xml
sed -i "${numStart}i\                    <plugin>" pom.xml
