【问题标题】:Maven Flyway Executing PluginMaven Flyway 执行插件
【发布时间】:2018-10-17 16:29:48
【问题描述】:

我有一个 flyway 项目,在 ANY 调用 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>

但只有当您使用 LOCAL 配置文件集执行 flyway:migrate 时,才会执行 groovy 插件。

如何将其设置为在每次调用 flyway:migrate 时都运行插件,而不管配置文件如何。

【问题讨论】:

    标签: maven groovy pom.xml maven-plugin flyway


    【解决方案1】:

    彻底改变方法怎么样?如果您切换到基于 Java 的 Flyway 回调,您想要完成的工作实际上非常简单,而后者又会调用您想要的 Groovy 脚本。见https://flywaydb.org/documentation/callbacks

    【讨论】:

      猜你喜欢
      • 2020-04-04
      • 2019-12-21
      • 1970-01-01
      • 2014-08-30
      • 1970-01-01
      • 2021-01-18
      • 2011-09-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多