Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven war plugin ignores .properties file

Tags:

maven

I have a simple project with maven using the maven war plugin. When I clean the project and run mvn package the conf.properties file I have is always left out of my war file.

The conf.properties file is located at src/main/java/conf/conf.properties.

Any ideas on why this file is ignored?

Thanks in advance

like image 270
Alex Avatar asked Apr 08 '11 02:04

Alex


People also ask

How to exclude file from war?

It is possible to include or exclude certain files from the WAR file, by using the <packagingIncludes> and <packagingExcludes> configuration parameters.

Which file extensions are excluded for resource filtering by default in Maven?

The plugin will prevent binary files filtering without adding some excludes configuration for the following file extensions jpg , jpeg , gif , bmp and png . If you like to add supplemental file extensions this can simply achieved by using a configuration like the following: <project>

How do I create a WAR file in Maven?

Using the mvn:war:exploded command, we can generate the exploded WAR as a directory inside the target directory. This is a normal directory, and all the files inside the WAR file are contained inside the exploded WAR directory.

What is packagingExcludes?

packagingExcludes: The comma separated list of tokens to exclude from the WAR before packaging. With packagingExcludes, the tokens are completely excluded from the final war file. With warSourceExcludes, the tokens are just ignored when copying the war directory into the war file.


2 Answers

if you want to package your property files, put your property files in src/main/resources. This is the generic location for property files for all maven builds.

like image 149
uncaught_exceptions Avatar answered Sep 29 '22 12:09

uncaught_exceptions


In case you are unable to change the location of the properties file, you can add something like the following in your pom to indicate the alternate location. Refer to this as well.

<resources>
  <resource>  
    <directory>${basedir}/src/main/java/conf</directory>
  </resource>
</resources>
like image 45
Raghuram Avatar answered Sep 29 '22 12:09

Raghuram