views:

135

answers:

1

For my current project I want to integrate a maven plug-in for database migrations. For this plug-in to work, however, I have to obtain the database settings inside my POM. My database settings are currently placed inside a hibernate.properties file, positioned in a directory that is marked as maven resource. For a variety of reasons I do not want to duplicate my database configurations in both the pom and hibernate.properties.

I'm aware that maven offers a "filtering" ability which makes it possible to specify the database settings as property inside my POM, and reference them inside my hibernate.properties as ${property_name}. But as I'm using multiple maven profiles, with different property resources, this is not a suitable solution. Instead I'd like my database configurations to be loaded from a property file inside my classpath (e.g. classpath:hibernate.properties), and use these properties in my migration plug-in configuration.

I have already tried the org.codehaus.mojo » properties-maven-plugin, but this plug-in only accepts absolute locations. Is there a plug-in which can scan all my maven resources for a certain property?

A: 

If you need an absolute path, use ${basedir}/your/relative/path/here/.... ${basedir} expands to the absolute path of the directory of the current pom.xml.

Aaron Digulla
my property files are located over x amount of (mvn) resources. i cannot just say ${basedir}/my_dir, because my_dir can vary per profile on which i run my mvn project.
Jeroen
So? Define a property per profile and use ${basedir} in it to build the path.
Aaron Digulla