Things I tend to forget: Use ${basedir} in Maven.. ALWAYS!
If you come across different outcomes in your maven build depending on whether you invoked the maven command inside project's directory or its parent directory, you are doing it wrong somewhere. The build should be consistent. If that module is part of a big multi-module project, project should behave the same always even it's built in the command line or as a part of a build scheduled in a continuous integration server.
For example if you refer to a directory like <directory>target/site</directory> it will look for the target directory at the location the command was executed. This will make things inconsistent depending on whether you invoked it inside the sub-module or the parent project. But referring to it like <directory>${basedir}/target/site</directory> will make sure the target directory will always be searched in one location, the directory where the pom.xml lies. For some reason, if you want to point to the directory from which the maven command was executed use ${user.dir}
For a full list of Maven properties read Maven Properties Guide or this chapter on Sonatype's book, 'Maven: The Complete Reference'.
Read full article from Things I tend to forget: Use ${basedir} in Maven.. ALWAYS!
No comments:
Post a Comment