Maven - How to add a directory in build?

2

I'm having trouble adding a directory from my project into the * .jar file.

I've added the following code to my pom.xml :

      <resource>               
            <directory>migration/</directory>
            <includes>
                <include>**/*.sql</include>
            </includes>
      </resource>

But this only includes the .sql files and does not add the directory " migration "

Project structure below:

 + meuprojeto
 |---src/main/java
 |---src/test/java
 |---Maven Dependencies
 |---migration
    
asked by anonymous 12.03.2018 / 21:09

1 answer

2

already provides a default structure for you by files of non-code resources. The location for this is src/main/resources/ for production code and src/test/resources/ for test. Maven will do it all in the classpath.

For your case, just the folder migration and its contents like this:

+ meuprojeto
 |---src/main/java
 |---src/main/resources/migration
 |---src/test/java
 |---Maven Dependencies

I have tested this in a webservice using Flyway for the embedded database migration.

If you are using Eclipse, the IDE may involve some. Maybe the option with% ALT + F5 resolves. Alternatively: Right click on the update Maven project directory and select src/main/resources . Finally, the last alternative I imagine is: delete the Eclipse project (keep the content on disk) and then have a Maven project imported again.

    
12.03.2018 / 23:52