According to Codehaus , the maven ${basedir}
property exists
If you include a property file in your resources that has a ${basedir}
placeholder, and enable filtering for the resource plugin , you will find that there is a temporary substitution of the database in the properties file. You can then load it using the Properties
instance in the code.
in / src / main / resources, create a file called project.properties containing
project.basedir=${basedir}
Then, in the POM, enable filtering for / src / main / resources, as described in the maven filter filtering documentation linked above.
Then in the code at runtime, load the properties file into the Properties
instance
Properties props = new Properties(); props.load(this.getClass().getResourceAsStream("project.properties")); String basedir = props.get("project.basedir");
An alternative would be to process some source files and make a replacement there by connecting to the process-sources
phase, but this is unlikely to be easy to explain.
source share