簡體   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