Allure:目标文件夹中的环境文件在maven clean上被删除.如何在每次构建时生成它?

iho*_*ain 3 java testng maven allure

说明将environment.xml添加到Allure结果目录(https://github.com/allure-framework/allure-core/wiki/Environment),但是这个文件夹在mvn clean上被删除,所以文件被删除了.有没有办法在每次构建时生成此文件?

谢谢.

Inn*_*nty 7

只要把你的src/main/resources/,并通过复制到结果目录的Maven插件资源mvn testmvn site:

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-allure-environment</id>
            <phase>pre-site</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${basedir}/target/allure-results</outputDirectory>
                <resources>
                    <resource>
                        <directory>src/main/resources</directory>
                        <includes>
                            <include>environment.xml</include>
                        </includes>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)