简体   繁体   English

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

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

My maven project is dependent on a database schema created through another external project via liquibase.我的 maven 项目依赖于通过 liquibase 通过另一个外部项目创建的数据库模式。 For testing my project, I need to generate this database structure on my machine.为了测试我的项目,我需要在我的机器上生成这个数据库结构。 Is there a way to specify the liquibase project details(group id, artifact, version,etc. and requisite liquibase parameters) in my project's pom itself so that the db structure is generated before any tests are executed.有没有办法在我的项目的 pom 本身中指定 liquibase 项目详细信息(组 ID、工件、版本等和必需的 liquibase 参数),以便在执行任何测试之前生成 db 结构。

PS: I know I can use something like below if the project actually exists in my machine: 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>

I want to specify the proj-liquibase-db 's project coordinates here instead of the path to its pom file.我想在此处指定proj-liquibase-db的项目坐标,而不是其 pom 文件的路径。

PPS: If it is not possible, then please let me know and suggest some alternatives as I am really stuck here. PPS:如果这是不可能的,那么请让我知道并建议一些替代方案,因为我真的被困在这里。

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

you can unpack the artifact generated by the project containing the liquibase xml files in a subfolder of your "target" directory using the dependency plugin.您可以使用依赖项插件将包含 liquibase xml 文件的项目生成的工件解压缩到“目标”目录的子文件夹中。 The goal should be dependency:unpack.目标应该是依赖:解包。 Then you just have to configure liquibase in your test classes in order to load these files.然后你只需要在你的测试类中配置 liquibase 来加载这些文件。

Kind regards亲切的问候

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

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