Maven - How to add a directory to build?

Asked

Viewed 456 times

2

I’m having a hard time adding one directory of my project inside the archive *.jar.

I added the code below in my pom.xml :

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

Only that includes only the files .sql and does not add the directory "Migration"

Structure of the project below:

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

1 answer

3


The already provides a default structure for you by non-code resource files. The location for this is in src/main/resources/ for production code and src/test/resources/ for testing. Maven will be able to put everything in the classpath.

For your case, just put the folder migration and its contents thus:

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

I already tested this on a webservice using Flyway for the migration of the embedded database.

If you are using Eclipse, the IDE may imply a bit. Maybe the option update Maven project ALT+F5 resolve. Another alternative: right-click on the directory src/main/resources and select add to build path. Finally, the last alternative I imagine is: delete the Eclipse project (keep it on disk) and then have a Maven project imported again.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.