tags:

views:

37

answers:

1

I need to know the complete filename of a specific artifact in Maven. I looked at versions-maven-plugin but it seems to change the pom itself. Is there another way to reach my goal? I want to store the complete artifact name in a property so I can pick it up in Java code.

+1  A: 

Normally you have your dependencies and let maven do all the work of retrieving the files from the repository for you. But you want to use it in your Java code - what Java code? Are you writing your own mojo that will be doing something during the install phase of your lifecycle? Then you should be able to access the artifacts that are currently being processed, from there it's not a problem to get the filename. But maybe you've got just the groupId, artifactId, version and type of an already existing artifact. With these informations it should be no problem to navigate to your local maven repository, open the directory: groupId/artifactId/version and look what files you've got there. Usually there should be your .pom a .jar, maybe a md5-hashsum and some maven-metadata. If you're not sure which file's the interesting one: take that one with the biggest filesize.

xor_eq
Thanks for your answer. I'm not writing a mojo, just adapting some code for a home-written testing framework by a customer. I wanted to avoid writing Java code and just pass the full filename from Maven to the Java code, using a property. As a workaround I now use the <stripVersion> tag in the maven-dependency-plugin, so I don't have to handle versions and always have the same filename.
Maurits Rijk