繁体   English   中英

如何从外部项目的 pom 执行 maven liquibase pom?

[英]How to execute maven liquibase pom from an external project's pom?

我的 maven 项目依赖于通过 liquibase 通过另一个外部项目创建的数据库模式。 为了测试我的项目,我需要在我的机器上生成这个数据库结构。 有没有办法在我的项目的 pom 本身中指定 liquibase 项目详细信息(组 ID、工件、版本等和必需的 liquibase 参数),以便在执行任何测试之前生成 db 结构。

PS:我知道如果项目确实存在于我的机器中,我可以使用以下内容:

<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.1</version>
        <executions>
            <execution>
                <id>create-unitttest-db-schema</id>
                <phase>process-test-resources</phase>
                <goals>
                    <goal>exec</goal>
                </goals>
                <configuration>
                    <skip>${skipSchemaCreation}</skip>
                    <executable>mvn</executable>
                    <arguments>
                        <argument>-f</argument>
                        <argument>../proj-liquibase-db/pom.xml</argument>
                        <argument>-P${proj.test.liquibase.create.profile},create</argument>
                        <argument>clean</argument>
                        <argument>install</argument>
                        <argument>-DdefaultSchemaName=${proj.test.schema.unittest}</argument>
                    </arguments>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

我想在此处指定proj-liquibase-db的项目坐标,而不是其 pom 文件的路径。

PPS:如果这是不可能的,那么请让我知道并建议一些替代方案,因为我真的被困在这里。

您应该通过在类路径中添加项目 jar 并提供其他必要参数(如数据库详细信息等)来执行 liquibase jar,而不是依赖:解包。

您可以使用依赖项插件将包含 liquibase xml 文件的项目生成的工件解压缩到“目标”目录的子文件夹中。 目标应该是依赖:解包。 然后你只需要在你的测试类中配置 liquibase 来加载这些文件。

亲切的问候

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM