I've run into some problems when practicing with Maven in IntelliJ and somehow the resource files in my class path never gets included in the built JAR.
My module structure:
src/main/java/com/abc/Main.class
src/main/java/com/abc/Messages.class
src/main/java/com/abc/messages_en.properties the not included resource files.
src/main/java/com/abc/messages_es.properties
src/main/resources/ misc resources
Project builds successfully, but when I run the JAR file, I would receive a error message as below. And when I unpacked the JAR file, the messages_xx.properties files are missing.
Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name com.abc.messages, locale en
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:845)
at org.jis.Messages.<init>(Messages.java:42)
at org.jis.Main.main(Main.java:205)
My pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<includes>
<include>${basedir}/src/main/java/com/abc/*.properties</include>
</includes>
<archive>
<manifest>
<mainClass>com.abc.Main</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Came across many similar threads on SO but the solutions don't seem to fit my case. Any suggestions what's happening here? I've been trying to figure out why this happened for a while now but haven't found an answer yet. It would be great if someone could give me some hints. Thanks a lot.