Nailgun
Nailgun

Reputation: 4169

Flyway - not copy sql resources

I'm using flyway in my java web project.

My migrations are placed in src/main/resources/db/migration

Now I want to exclude sql resources from the target war so I add to my pom.xml:

<project>
    ...
    <build>
    ...
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                   <exclude>**/*.sql</exclude>
               </excludes>
            </resource>
        </resources>
    ...
    </build>
</project>

But then flyway doesn't work because in grabs migrations from the target.

So how could I use flyway but avoid copying sql to my war?

Upvotes: 3

Views: 697

Answers (2)

Nailgun
Nailgun

Reputation: 4169

My solution was to exclude files from copying to the target war instead of excluding the resources from copying to target classes. Here is the way to do it:

<project>
    ...
    <build>
        ...
        <plugins>
             <plugin>
                  <artifactId>maven-war-plugin</artifactId>
                  <version>2.2</version>
                  <configuration>
                      <warName>my</warName>
                      <packagingExcludes>**/*.sql</packagingExcludes>
                  </configuration>
             </plugin>
         ...
         </plugins>
        ...
     </build>
     ...
 </project>

Upvotes: 0

Konstantin V. Salikhov
Konstantin V. Salikhov

Reputation: 4653

You can extract your migrations to separate maven module with pom packaging and make your app dependent of this module. You can see example of migration module here

Upvotes: 0

Related Questions