链接 Maven Flyway 命令

发布于 2024-11-02 06:26:46 字数 221 浏览 3 评论 0原文

如何使用 Maven 将 Flyway 命令链接成单个命令?

例如,我想运行mvninitializeflyway:clean,然后运行mvninitializecompileflyway:migrate。但是,mvninitializeflyway:cleancompileflyway:migrate失败。

谢谢!

How can Flyway commands be chained into a single command using Maven?

For example, I want to run mvn initialize flyway:clean followed by mvn initialize compile flyway:migrate. However, mvn initialize flyway:clean compile flyway:migrate fails.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蓝梦月影 2024-11-09 06:26:46

我刚刚检查

mvn initialize flyway:clean compile flyway:migrate

了 Maven 2.2.1 和 Maven 3.0.3,它每次都有效。

你能仔细检查一下吗?如果您认为确实发现了问题,请在问题跟踪器 通过必要的步骤来重现它,我会尽力尽快修复它。

I just checked

mvn initialize flyway:clean compile flyway:migrate

with both Maven 2.2.1 and Maven 3.0.3 and it works every time.

Could you double check this? In case you think you really found a problem, please file an issue in the Issue Tracker with the necessary steps to reproduce it and I'll do my best to fix it asap.

嗫嚅 2024-11-09 06:26:46

这将使您能够链接 Maven 步骤,只需在其中添加您想要的目标

<profile>
        <id>clean-migrate</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>process-resources1</id>
                            <goals>
                                <goal>resources</goal>
                            </goals>
                            <!-- Populate the database before querydsl-sql runs -->
                            <phase>generate-sources</phase>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.googlecode.flyway</groupId>
                    <artifactId>flyway-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>process-resources2</id>
                            <goals>
                                <goal>clean</goal>
                                <goal>migrate</goal>
                            </goals>
                            <phase>generate-sources</phase>
                        </execution>
                    </executions>
                    <version>1.4.2</version>
                    <configuration>
                        <driver>oracle.jdbc.driver.OracleDriver</driver>
                        <url>jdbc:oracle:thin:@${database-hostname}:${database-port}:${database-sid}</url>
                        <user>${database-username}</user>
                        <password>${database-password}</password>
                        <schemas>${database-schema}</schemas>
                        <table>schema_history</table>
                        <initialVersion>0.1.00</initialVersion>
                        <initialDescription>Base Migration</initialDescription>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

您还需要在 settings.xml 中添加以下内容

<profile>
  <id>inject-flyway-properties</id>
    <properties>
      <database-hostname>${env.DB_HOSTNAME}</database-hostname>
      <database-port>${env.DB_PORT}</database-port>
      <database-username>${env.DB_USER}</database-username>
      <database-password>${env.DB_PASSWORD}</database-password>
      <database-sid>${env.DB_DEFAULT_SID}</database-sid>
      <database-schema>${env.DB_SCHEMA}</database-schema>
    </properties>
</profile>

That will give you the ability to chain maven steps, just add the goals you want in there

<profile>
        <id>clean-migrate</id>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>process-resources1</id>
                            <goals>
                                <goal>resources</goal>
                            </goals>
                            <!-- Populate the database before querydsl-sql runs -->
                            <phase>generate-sources</phase>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.googlecode.flyway</groupId>
                    <artifactId>flyway-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>process-resources2</id>
                            <goals>
                                <goal>clean</goal>
                                <goal>migrate</goal>
                            </goals>
                            <phase>generate-sources</phase>
                        </execution>
                    </executions>
                    <version>1.4.2</version>
                    <configuration>
                        <driver>oracle.jdbc.driver.OracleDriver</driver>
                        <url>jdbc:oracle:thin:@${database-hostname}:${database-port}:${database-sid}</url>
                        <user>${database-username}</user>
                        <password>${database-password}</password>
                        <schemas>${database-schema}</schemas>
                        <table>schema_history</table>
                        <initialVersion>0.1.00</initialVersion>
                        <initialDescription>Base Migration</initialDescription>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

You will also need the following in your settings.xml

<profile>
  <id>inject-flyway-properties</id>
    <properties>
      <database-hostname>${env.DB_HOSTNAME}</database-hostname>
      <database-port>${env.DB_PORT}</database-port>
      <database-username>${env.DB_USER}</database-username>
      <database-password>${env.DB_PASSWORD}</database-password>
      <database-sid>${env.DB_DEFAULT_SID}</database-sid>
      <database-schema>${env.DB_SCHEMA}</database-schema>
    </properties>
</profile>
如痴如狂 2024-11-09 06:26:46

如果我理解文档正确,您必须配置 maven-flyway 插件来完成工作并将其绑定到 Maven 的正确阶段,而不是您可以使用默认的 Maven 调用,例如 mvn clean package 或 mvn clean verify。

If i understand the docs correct you have to configure the maven-flyway plugin to do the work and bound it to the correct phases of maven than you can use the default maven calls like mvn clean package or mvn clean verify.

抱猫软卧 2024-11-09 06:26:46

您可以使用 配置文件 将“命令”捆绑在一起。完成后你只需调用:

mvn -Pmy-profile

You can use profiles in order to bundle "commands" together. Once it's done you just call:

mvn -Pmy-profile
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文