Christian Lutz
Christian Lutz

Reputation: 538

Maven: How to change resources target directory of a maven build

I have a build problem with maven. I wrote a custom checkstyle check for my project. For internationalization checkstyle provides capabilities for using localized property files with log messages. These files need to be placed in the same directory as the check's class file. In my modules jar i want to have my property files in

src/main/resources/messages_xy.properties

copied to the package directory of my custom check.

My current workaround is to place the message_xy.properties files in the src/main/java/**/ directory. But i hope that there is a better solution, that i can stick to maven's conventions.

Example for clarification:

My maven module looks like this:

/checkstyle
  [...]
  /src/main/java/package/name/
    CustomCheck.java
  /src/main/resources
    messages.properties
    messages_de.properties
  [...]

after calling mvn install if want to have a jar in my target folder with the following structure:

/checkstyle.jar
  [...]
  /package/name/
    CustomCheck.java
    messages.properties
    messages_de.properties
  [...]

Thanks for your help.

Upvotes: 0

Views: 1162

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328800

Just create the necessary folders below /src/main/resources, i.e.:

/module
  [...]
  /src/main/java/package/name/
    CustomCheck.java
  /src/main/resources/package/name/
    messages.properties
    messages_de.properties

Upvotes: 3

Related Questions