hbm files aren't copied to target directory when running unit tests

Answered

I'm using IntelliJ 2017.2.3 Ultimate.

Our project has - for historical reasons - Hibernate mapping files under the source folder. Because of that, I seem unable to mark their containing directory as a Resource directory - I can only exclude it.

Preferences > Build > Compiler > Clear output directory on rebuild is selected

When I run a unit test (Before launch: Build, Activate tool window), the resource files aren't copied - causing failing tests, because changes aren't picked up.

It's a multi-module maven project. I don't want to build everything, and I'd rather not do a mvn clean install -DskipTests instead of a Build.

How can I fix the issue (and make IntelliJ copy the changed hbm files)?

Also, why is the target folder not cleared, even though the compiler settings say it should be?

3 comments
Comment actions Permalink

You should configure Maven to handle resources located in the source directories like described at https://stackoverflow.com/questions/23289098/how-to-copy-resource-to-src-target-directory-with-maven.

Target directory contains not only the compiler output, but also artifacts. Clean action deletes compiler output only.

0
Comment actions Permalink

But if I run JUnit tests without running maven first, will IntelliJ honour the maven config, or not (i.e will the files be there or not)? :)

0
Comment actions Permalink

Yes, it will honor the configuration from pom.xml.

0

Please sign in to leave a comment.