4

Is it possible to get the directory ${project.build.directory}/test-1.0-SNAPSHOT for my project?

I have to exclude certain files from this directory for a fortify scan and I just realized that when the version changes so does this directory. Is there a property I could use to replace the name of this directory?

John Mercier
  • 1,637
  • 3
  • 20
  • 44
  • 1
    see http://stackoverflow.com/questions/6129581/in-maven-how-to-rename-the-output-war-file-based-on-the-name-of-the-profile-i for ways to rename the war –  Mar 13 '15 at 19:27
  • There is nothing wrong with the name. What I need is a property for the name I can use instead of hard coding the name in my pom file. – John Mercier Mar 13 '15 at 19:38
  • 1
    the name is derived from the finalName inside the build. so maybee project.build.finalName ist what you are looking for? – wemu Mar 13 '15 at 22:35
  • 1
    The fortify scan can do it on it's own and does not needed an exploded folder..... – khmarbaise Mar 14 '15 at 12:15

1 Answers1

5

The value of ${project.build.directory} is the path to the build directory. This is a project property, prior to 3.0 a pom property and can be used only in a pom.xml file or in any resource that is being processed by the Maven Resource plugin’s filtering feature. It is not an environment variable that can be used on a bash command line, for example. Another project property of possible interest to you is ${project.build.finalName}, which refers to the final name of the file created when the built project is packaged.

If you can fix the path of the war including its name, that should solve the issue. Two ways for doing that are described in Maven: How to change path to target directory from command line?. One way allows doing it on the command line with a compilation -D switch but is not recommended; the other way defines a profile in pom.xml which hardcodes it and is also invoked with a compilation -D switch. See also Maven: specify the outputDirectory only for packaging a jar? for a similar approach which should work just as well for a war.

Additional references for maven properties and configuration include http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide and http://books.sonatype.com/mvnref-book/reference/resource-filtering-sect-properties.html. The last reference gives some examples of using project properties in pom.xml for certain purposes with good examples also in the comments.

Community
  • 1
  • 1