Question

I would like to write an Integration Test which test if the created jar behaves like expected. For that I have to know the path to the jar as well the name, but how to I get this Information. I do not like the idea of hard coding this. Is there a way to get the Information from maven? Or what is the best practice for that?

Was it helpful?

Solution

Assembled jar is placed inside directory which is accessible from maven properties

${project.build.directory}

Jar name is configured in Maven Assembly Plugin or assembly descriptor. For simplicity define property project.build.finalName in your pom.xml.

<properties>
    <project.build.finalName>my-artifact.jar</project.build.finalName>
</properties>

After this your jar is accessible with variable:

${project.build.directory}/my-artifact.jar

Simply filter this value with maven into application properties and voila :)

Is this helping you in any way?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top