Reputation: 2197
Trying to configure my project to use Liquibase with a Parent POM.
Parent POM config:
<dependencies>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase-plugin.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase-plugin.version}</version>
<configuration>
<propertyFileWillOverride>true</propertyFileWillOverride>
<propertyFile>src/main/resources/db/liquibase.properties</propertyFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
In the child project I have (among others):
<build>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<configuration>
<propertyFile>src/main/resources/db/liquibase.properties</propertyFile>
</configuration>
</plugin>
</build>
Then I try to run mvn liquibase:generateChangeLog
but I get (in the Parent project):
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.4.1:generateChangeLog (default-cli) on project credisfera-middleware-parent: Failed to resolve the properties file. -> [Help 1]
Looks like maven or the plugin is trying to resolve the property file in the parent directory, which should not happen. If I remove propertyFile from the parent POM I get another error saying property file was not specified.
Edit 1: my project structre
Parent POM
-- project1 POM
-- project2 POM
I want to run Liquibase on project2 POM, which has liquibase dependency and plugin configured too.
How to config it?
Upvotes: 0
Views: 1043
Reputation: 2197
I think I found out what is happening.
When I command mvn liquibase:whatever, maven understands that it shall run this command in the current POM. This explains why liquibase plugin complains about not being able to resolve the property file (as super POM has none).
The problem is I can't run maven directly on the child project as it dependes on another projects listed in the parent POM. Maven options of --also-make and --projects would help if it wouldn't introduce the same problem again: maven trying to run liquibase on the parent POM.
The solution I found was running mvn liquibase:whatever using Eclipse and marking the option "Resolve Workspace Artifacts". In this case Eclipse won't try to run mvn liquibase in any other project but on the child project I run the build.
Upvotes: 1