Is there any maven sleep functionality?

后端 未结 2 1959
失恋的感觉
失恋的感觉 2021-02-19 15:32

I have maven profile set for testing where in pre-integration-tests maven starts two jetty servers and afterwards tests are started. The problem I\'ve stumbled into is in the se

相关标签:
2条回答
  • 2021-02-19 15:53

    I have created a maven-sleep-plugin once. Not sure how much it works now, you can try and let us know.

    Usage (after checking out the source and building):

    <plugin>
        <groupId>org.jboss.maven.plugins</groupId>
        <artifactId>maven-sleep-plugin</artifactId>
        <version>1.0</version>
        <executions>
            <execution>
                <id>sleep-5-seconds</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>sleep</goal>
                </goals>
                <configuration>
                     <delay>5</delay>
                </configuration>
            </execution>
       </executions>
    </plugin>
    
    0 讨论(0)
  • 2021-02-19 16:00

    You can do it with the help of the maven antrun plugin. Something like this:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <configuration>
            <tasks>
                <sleep seconds="5" />
            </tasks>
        </configuration>
        <executions>
            <execution>
                <id>sleep-for-a-while</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>run</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    

    EDIT: In case someone will catch this. Based on the comment from jl, tasks have indeed been deprecated and here is the same thing based on using targets instead. Sligthly reorganized but has the same function.

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.8</version>
        <executions>
            <execution>
                <id>sleep-for-a-while</id>
                <phase>pre-integration-test</phase>
                <configuration>
                    <target>
                        <sleep seconds="5" />
                    </target>
                </configuration>
                <goals>
                    <goal>run</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    
    0 讨论(0)
提交回复
热议问题