我的maven项目依赖于通过另一个外部项目通过liquibase创建的数据库架构。 为了测试我的项目,我需要在机器上生成此数据库结构。 是否可以在项目的pom本身中指定liquibase项目的详细信息(组ID,工件,版本等,以及必需的liquibase参数),以便在执行任何测试之前生成db结构。
附言::如果项目确实存在于我的机器中,我知道可以使用以下类似的内容:
<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文件的路径。
P.P.S::如果不可能的话,请让我知道并提出一些替代方案,因为我确实被困在这里。
答案 0 :(得分:2)
您应该通过在类路径中添加项目jar并提供其他必要的参数(例如db详细信息等)来执行liquibase jar,而不是依赖项:unpack。
答案 1 :(得分:1)
您可以使用依赖插件将包含liquibase xml文件的项目生成的工件解压缩到“目标”目录的子文件夹中。 目标应该是dependency:unpack。 然后,您只需要在测试类中配置liquibase即可加载这些文件。
亲切的问候