문제

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?

도움이 되었습니까?

해결책

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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top