symon
symon

Reputation: 650

How can I copy files with maven after the test phase?

Throughout the test phase i generate a XML file based on some runtime properties. how can I have maven copy this from src/test/resources/environment.xml to /target/allure-results/?

I can generate the XML no problem, but how can I then move it? right now it copies at the beginning of the test phase. I have tried using verify instead, but that doesn't work. I need to copy this file upon completion of the maven test phase

  <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.7</version>
                <executions>
                    <execution>
                        <id>copy-resource-one</id>
                        <phase>test</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/allure-results</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/test/resources/allure_settings/</directory>
                                    <includes>
                                        <include>environment.xml</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Upvotes: 3

Views: 1119

Answers (1)

miskender
miskender

Reputation: 7938

As far as I know, there is no post-test phase for maven. You can use prepare-package phase to do what you want. But it won't be executed with mvn test command. You have to execute command that at least past package phase.
There is post-integration-test phase, but you have run your tests in integration-test. (But it happens after package phase, so I think it wont work for you).
You can check detais at https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Upvotes: 3

Related Questions