Say two modules mod1
and mod2
have the following structure:
root
├── mod1/src/main/resources/db-migrations
| ├── v1
| | ├── a.sql
| | └── b.sql
| └── v2
| ├── c.sql
| └── d.sql
|
└── mod2/src/main/resources/db-migrations
├── v1
| ├── e.sql
| └── f.sql
└── v2
├── g.sql
└── h.sql
I want to copy all files from db-migrations
into a single top-level directory, but grouped by version first, and by module second. So the output should look like this:
root/all-db-migrations
├── v1
| ├── mod1
| | ├── a.sql
| | └── b.sql
| └── mod2
| ├── e.sql
| └── f.sql
└── v2
├── mod1
| ├── c.sql
| └── d.sql
└── mod2
├── g.sql
└── h.sql
If the directory structure wasn't inversed (module name before version), this is easy with the maven resource plugin by just copying the entire db-migrations
directory for each module:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-database-migrations</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>../all-db-migrations/${project.artifactId}
</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/db-migrations</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
However, I could not find a solution to do such a copy operation as described above.