繁体   English   中英

如何最小化Maven POM.XML文件

[英]How can I minimize Maven POM.XML file

我是Maven的新手,我正在尝试对现有项目进行一些改进。 我敢肯定,有一种有效的方法可以用参数构建概要文件,或者以某种方式减小任务的行数。

当前的配置文件是这样构建的:

    <profile>
        <id>green</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.smart.soapui</groupId>
                    <artifactId>soapui-pro-maven-plugin</artifactId>
                    <version>5.1.2</version>
                    <configuration>
                        <projectFile>resources/api/API-NEW-automation.xml</projectFile>
                        <junitReport>true</junitReport>
                        <reportName>sanity-api</reportName>
                        <printReport>true</printReport>
                        <reportFormat>HTML</reportFormat>
                        <outputFolder>target</outputFolder>
                        <projectProperties>
                            <value>message=Running API Sanity test</value>
                        </projectProperties>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>validate</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <tasks>
                                    <delete file="src/main/resources/config.properties" />
                                    <copy file="src/main/resources/green/config.properties"
                                        tofile="src/main/resources/config.properties" />
                                    <delete file="src/main/resources/TestData.properties" />
                                    <copy file="src/main/resources/green/TestData.properties"
                                        tofile="src/main/resources/TestData.properties" />
                                    <delete file="src/main/resources/loginTestData.csv" />
                                    <copy file="src/main/resources/green/loginTestData.csv"
                                        tofile="src/main/resources/loginTestData.csv" />
                                    <delete file="src/main/resources/browsingTestData.csv" />
                                    <copy file="src/main/resources/green/browsingTestData.csv"
                                        tofile="src/main/resources/browsingTestData.csv" />
                                    <delete file="src/main/resources/endUsersDetails.csv" />
                                    <copy file="src/main/resources/green/endUsersDetails.csv"
                                        tofile="src/main/resources/endUsersDetails.csv" />
                                </tasks>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

由于每个配置文件都具有这些任务(并且这里显示的内容不止如此),因此我使用了通用代码。 你们有没有经历过类似的事情?

谢谢。

您可以通过编写自己的自定义Ant任务(也将概要文件ID作为参数传递)并外部化属性文件的路径来实现。 然后,您可以在每个配置文件中单独调用自定义ant任务。 有关如何编写自定义ant任务的链接,请参见此处

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM