Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to configure maven plugin from a property file #679

Closed
adelinor opened this issue Jan 17, 2014 · 8 comments
Closed

Allow to configure maven plugin from a property file #679

adelinor opened this issue Jan 17, 2014 · 8 comments

Comments

@adelinor
Copy link

It would be extremely useful to be able to get the values for the flyway maven plugin configuration from a property file. For instance:

<plugin>
    ...
    <configuration>
        <url>${jdbc.url}</url>
        <user>${jdbc.user}</user>
        <password>${jdbc.password}</password>
    </configuration>
</plugin>

The Maven properties plugin is not invoked when running flyway goals such as:

mvn flyway:info

Having this working would be extremely useful.

@adelinor
Copy link
Author

I raised an enhancement request with the MOJO project: MOJO-2005 but from the developer's comment, it does not look like there is anything they can do to help.

@axelfontaine
Copy link
Contributor

Thanks for your suggestion. Your properties plugin argument convinced me. Accepted.

This can build nicely on the property support present for the command-line tool.

Pull request welcome.

Cheers
Axel

@axelfontaine
Copy link
Contributor

Implemented.

@adelinor
Copy link
Author

I just tried release 3.0 of the maven plugin with the configFile configuration option. It works brilliantly! Also it simplifies quite significantly the POM.XML: at least 30 lines less. Thank you for that.

@abhi2495
Copy link

abhi2495 commented Jul 11, 2020

Hey @adelinor @axelfontaine @MikielAgutu @Lyeeedar @juliahayward ,

I am trying to load the flyway properties from my application.yaml , but they dont seem to work. Can you please help me figure out what am I doing wrong here.

I am trying to invoke the flyway clean goal, using the command:

mvn org.codehaus.mojo:properties-maven-plugin:read-project-properties flyway:clean

my POM.xml:

...
...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0.0</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>read-project-properties</goal>
            </goals>
            <configuration>
              <files>
                <file>${project.basedir}/src/main/resources/application.yaml</file>
              </files>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-maven-plugin</artifactId>
        <version>6.5.0</version>
        <configuration>
          <url>${spring.datasource.url}</url>
          <user>${spring.datasource.username}</user>
          <password>${spring.datasource.password}</password>
        </configuration>
      </plugin>
...
...

My application yaml:

spring:
  datasource:
    url: jdbc:h2:mem:public;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL;INIT=CREATE SCHEMA IF NOT EXISTS "public";
    username: root
    password:

@juliahayward
Copy link
Contributor

@abhi2495 What do you see happen? Do you get an error stack trace, a silent failure, a process hanging, something else?

@abhi2495
Copy link

@juliahayward When I run the maven command, the build fails with the log:

org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password!

@juliahayward juliahayward reopened this Jul 13, 2020
@MikielAgutu
Copy link

#2876 tracks the new problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants