Run all related target instances on the command line

I have a group of SQL commands attached to a phase pre-integration-test, the task of which is to create a "test" database and application to it.

Sometimes I just want to “rebuild” my test database without using everything else in the life cycle. For example, if my test catastrophically fails and fastens the test database, I may have to rebuild it several times until I find out what the problem is.

Here my POM looks like this:

<profile>
    <id>test-setup-teardown</id>
       <activation>
           <activeByDefault>true</activeByDefault>
       </activation>
       <build>
           <plugins>
               <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>sql-maven-plugin</artifactId>
                    <version>1.3</version>

                    <dependencies>
                        <dependency>
                            <groupId>${database-dependency-groupId}</groupId>
                            <artifactId>${database-dependency-artifactId}</artifactId>
                            <version>${database-dependency-version}</version>
                        </dependency>
                    </dependencies>

                    <configuration>
                        <url>${test-database-admin-url}</url>
                        <username>${test-database-admin-username}</username>
                        <password>${test-database-admin-password}</password>
                        <driver>${database-driver}</driver>
                        <autocommit>true</autocommit>
                    </configuration>

                    <executions>
                        <execution>
                            <id>test-database-pre-setup</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>execute</goal>
                            </goals>
                            <configuration>
                                <sqlCommand>${test-database-teardown}</sqlCommand>
                                <onError>continue</onError>
                            </configuration>
                        </execution>

                        <execution>
                            <id>test-database-setup</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>execute</goal>
                            </goals>
                            <configuration>
                                <sqlCommand>${test-database-setup}</sqlCommand>
                            </configuration>
                        </execution>

                        <execution>
                            <id>test-database-schema</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>execute</goal>
                            </goals>
                            <configuration>
                                <url>${test-database-url}</url>
                                <username>${database-user}</username>
                                <password>${database-password}</password>
                                <srcFiles>
                                    <srcFile>${basedir}/metadata/build/database/${database-engine}/appx.sql</srcFile>
                                </srcFiles>
                            </configuration>
                        </execution>

                        <execution>
                            <id>test-database-teardown</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>execute</goal>
                            </goals>
                            <configuration>
                                <sqlCommand>${test-database-teardown}</sqlCommand>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

How can I run all the executions of this profile? Something like mvn sql:executeonly launches one of the executions (the latter, I think).

, , pre-integration-test validate, -, :

mvn validate -Pforce-rebuild,test-setup-teardown

, , , POM. , !

<ed> , id ? </ed>

+3
2

, id ?

. .

sql:execute , , ( script, srcFiles ).

, , " " () sql-maven-plugin , rebuild, validate validate . - :

mvn -Prebuild

, , ( , ), , ( ).

+1

"pre-integration-test" - , .

mvn -Ptest-setup-teardown pre-integration-test

- , , .. -DskipTests=true ( , ):

mvn -Ptest-setup-teardown pre-integration-test -DskipTests=true
0

Source: https://habr.com/ru/post/1729634/


All Articles