Home > database >  How to point to custom folder in configuration block in pom.xml file
How to point to custom folder in configuration block in pom.xml file

Time:11-21

I have application.properties in /etc folder like this: etc/project/application.properties, but I can't find a way how to point to it inside pom.xml configuration section.

So far I have:

   <build>
        <plugins>
            <plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>8.0.5</version>
                <configuration>
                    <driver>org.postgresql.Driver</driver>
                    <configFiles>
                        <configFile>/etc/project/application.properties</configFile> //<-- does not work!
                    </configFiles>
                </configuration>
     ...

any help?

CodePudding user response:

See Flyway Maven plugin, Config files:

It is also possible to point Flyway at one or more additional config files. This is achieved by supplying the System property flyway.configFiles as follows:

$ mvn -Dflyway.configFiles=path/to/myAlternativeConfig.conf flyway:migrate

To pass in multiple files, separate their names with commas:

$ mvn -Dflyway.configFiles=path/to/myAlternativeConfig.conf,other.conf flyway:migrate

So, contrary to the usual Maven convention configFiles is the name of the property, not a collection of properties:

                <configuration>
                    <driver>org.postgresql.Driver</driver>
                    <flyway.configFiles>/etc/project/application.properties</flyway.configFiles>  <!-- this should work -->
                    <!-- <configFiles>/etc/project/application.properties</configFiles> -->  <!-- or this -->
                </configuration>

If neither works try:

    <properties>
        <flyway.configFiles>/etc/project/application.properties</flyway.configFiles>
    <properties>

CodePudding user response:

accroding to flyway maven plugin’s official doc: flyway maven plugin doc

you can supplying the System property flyway.configFiles as follows:

$ mvn -Dflyway.configFiles=path/to/myAlternativeConfig.conf flyway:migrate

or use the FLYWAY_CONFIG_FILES environment variable

  • Related