1

给定以下 maven pom.xml 开发配置文件

<profiles>
    <profile>
        <id>development</id>

        <build>
            <plugins>
                <plugin>
                    <groupId>org.liquibase</groupId>
                    <artifactId>liquibase-maven-plugin</artifactId>
                    <version>3.0.4</version>
                    <executions>
                        <execution>
                            <id>01-liquibase.dropAll</id>
                            <phase>process-resources</phase>
                            <configuration>
                                [...skip...]
                            </configuration>
                            <goals>
                                <goal>dropAll</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </build>
    </profile>
</profiles>

和 pom.xml 的主要部分:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-maven-plugin</artifactId>
            <version>2.2.2</version>

            <configuration>
                <includes>package/pm/entity/**/*.class</includes>
                <addDefaultConstructor>true</addDefaultConstructor>
                <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
                <persistenceXmlFile>${project.parent.basedir}/forms-webapp/src/main/resources/META-INF/persistence.xml</persistenceXmlFile>
            </configuration>
            <executions>
                <execution>
                    <id>02-enhancer</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>enhance</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.apache.openjpa</groupId>
                    <artifactId>openjpa</artifactId>
                    <version>2.2.2</version>
                </dependency>
            </dependencies>
        </plugin>

        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.0.4</version>
            <executions>

                <execution>
                    <id>03-liquibase.update</id>
                    <phase>process-resources</phase>
                    <configuration>
                        [...skipped...]
                    </configuration>
                    <goals>
                        <goal>update</goal>
                    </goals>
                </execution>

                <!-- for tests -->
                <execution>
                    <id>04-liquibase-test.dropAll</id>
                    <phase>process-test-resources</phase>
                    <configuration>
                        [...skipped...]
                    </configuration>
                    <goals>
                        <goal>dropAll</goal>
                    </goals>
                </execution>

                <execution>
                    <id>05-liquibase-test.update</id>
                    <phase>process-test-resources</phase>
                    <configuration>
                        [...skipped...]
                    </configuration>
                    <goals>
                        <goal>update</goal>
                    </goals>
                </execution>

            </executions>
        </plugin>

    </plugins>
</build>

我希望执行将按以下顺序运行:

……

01-liquibase.dropAll

03-liquibase.update

……

但在构建日志中我看到:

[INFO] --- liquibase-maven-plugin:3.0.4:update (03-liquibase.update) @ forms-entity ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO]   File: src/main/resources/liquibase.properties
[INFO]   'classpath' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:postgresql://localhost/pman_trunk
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] 
[INFO] --- liquibase-maven-plugin:3.0.4:dropAll (01-liquibase.dropAll) @ forms-entity ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO]   File: src/main/resources/liquibase.properties
[INFO]   'classpath' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:postgresql://localhost/pman_trunk
[INFO] ------------------------------------------------------------------------

有没有办法解决这个错误的执行顺序?

4

1 回答 1

1

id01-liquibase.dropAll03-liquibase.update的执行在同一阶段执行。

您始终可以将带有 id 的执行移至01-liquibase.dropAll较早的阶段,例如generate-resources

                        <id>01-liquibase.dropAll</id>
                        <phase>process-resources</phase>

请参阅Maven 生命周期参考中的默认生命周期部分。

于 2013-09-18T12:42:31.623 回答