I have a maven project that generates a jar file, and i want to be able to execute that jar after it has been installed in my local maven repo. I have all the project properties I need in order to be able to construct the directory path to the jar. But, the problem I'm having is converting ${project.groupId} to a platform independent directory path. For example, the artifact gets installed here:
C:\Documents and Settings\myusername\.m2\repository\edu\ucd\chem\springbatch\0.0.1-SNAPSHOT\springbatch-0.0.开发者_C百科1-SNAPSHOT.jar
So, to construct that path using maven project properties, I have:
${settings.localRepository}${file.separator}${project.groupId}${file.separator}${project.name}${file.separator}${project.version}${file.separator}${project.build.finalName}.${project.packaging}
That generates:
C:\Documents and Settings\myusername\.m2\repository\edu.ucd.chem\springbatch\0.0.1-SNAPSHOT\springbatch-0.0.1-SNAPSHOT.jar
The only problem is that the groupId (edu.ucd.chem) isn't converted to a directory path (edu/ucd/chem). Is there a maven property already for this? Or do I need to manually convert the periods (.) to whatever file.separator I have? If I have to do it manually, how do I accomplish that?
Thanks!
Hmm, maybe you can launch the generated jar in your target folder ${project.build.directory}
instead.
While not an answer to the question, maven dependency plugin has a useRepositoryLayout
parameter, which constructs the same directory layout as the repository.
精彩评论