繁体   English   中英

Maven Flyway执行插件

[英]Maven Flyway Executing Plugin

我有一个flyway项目,在对flyway:migrate 任何调用时,我都想运行groovy插件来执行一些groovy脚本。 这是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

  <dependencies>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>2.4.15</version>
    </dependency>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
        <version>5.0.6</version>
    </dependency>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>6.1.0.jre8</version>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>LOCAL</id>
      <build>
        <plugins>
          <plugin>
              <groupId>org.codehaus.gmaven</groupId>
              <artifactId>groovy-maven-plugin</artifactId>
              <version>2.0</version>
              <executions>
                  <execution>
                      <phase>package</phase>
                      <goals>
                          <goal>execute</goal>
                      </goals>
                      <configuration>
                          <source>${pom.basedir}/fooScript.groovy</source>
                      </configuration>
                  </execution>
              </executions>
          </plugin>
          <plugin>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-maven-plugin</artifactId>
            <version>5.0.6</version>
            <configuration>
              <url>${url}</url>
              <user>${user}</user>
              <password>${pass}</password>
              <locations>${locations}</locations>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

但是groovy插件仅在您执行flyway:migrate with LOCAL profile set时才执行。

我如何设置它,以便每次调用flyway:migrate都运行插件,而不考虑配置文件。

完全改变方法怎么样? 如果您切换到基于Java的Flyway回调,而实际上又要调用所需的Groovy脚本,那么您要尝试实现的功能实际上是微不足道的。 参见https://flywaydb.org/documentation/callbacks

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM