在战争打包之前将文件复制到ant脚本中

时间:2019-04-18 07:21:14

标签: maven ant war

我想在战争打包之前覆盖一个文件,但是没有运气。在组装Webapp之前或打包战争之后,我的文件都会被覆盖

我尝试了以下信息的解决方案:Run ant task in maven build phase before war is packaged?

但是没有任何结果,它在组装webapp之前仍在执行脚本。而且这真的不适合我,因为战争包装后我需要执行另一个蚂蚁脚本

我的蚂蚁脚本执行

<execution>
                        <id>replace-index</id>
                        <phase>package</phase>
                        <configuration>
                            <target>
                                <ant antfile="${basedir}/src/main/deploy/replaceIndex.xml" target="replace">
                                    <property name="project.build.finalName" value="${project.build.finalName}" />
                                    <property name="project.packaging" value="${project.packaging}" />
                                </ant>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>

我的maven-war-plugin声明

<plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
                    <webappDirectory>${project.build.directory}/${project.name}</webappDirectory>
                    <hostedWebapp>${project.build.directory}/${project.name}</hostedWebapp>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <LastRelease>${lastRelease}</LastRelease>
                        <Environment>${environment}</Environment>
                            <SCM-Revision>${buildNumber}</SCM-Revision>
                            <SCM-Url>${project.scm.connection}</SCM-Url>
                            <Build-Time>${maven.build.timestamp}</Build-Time>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
[INFO] Executing tasks

main:

replace:
     [copy] Copying 1 file to /home/florian/IdeaProjects/gc-ui-sfr-si2r-bol/target/gc-ui-sfr-online
     [copy] Copying /home/florian/IdeaProjects/gc-ui-sfr-si2r-bol/target/gc-ui-sfr-online/WEB-INF/classes/index.html to /home/florian/IdeaProjects/gc-ui-sfr-si2r-bol/target/gc-ui-sfr-online/index.html
     [echo] index.html replaced 
[INFO] Executed tasks
[INFO] 
[INFO] --- maven-war-plugin:2.6:war (default-war) @ gc-ui-sfr-online ---
[INFO] Packaging webapp
[INFO] Assembling webapp [gc-ui-sfr-online] in [/home/florian/IdeaProjects/gc-ui-sfr-si2r-bol/target/gc-ui-sfr-online]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/florian/IdeaProjects/gc-ui-sfr-si2r-bol/src/main/webapp]
[INFO] Webapp assembled in [181 msecs]
[INFO] Building war: /home/florian/IdeaProjects/gc-ui-sfr-si2r-bol/target/gc-ui-sfr-online.war

您可以看到我的脚本在webapp组装之前已执行

0 个答案:

没有答案