Tutorial :Can I package a single text file as a text file in a maven repo?



Question:

I have a single configuration file which I would like to include as a dependency in a maven pom.xml. I want to keep around several versions of this, and have it appear in the classpath. I realize I could wrap it in a jar, but others in my team would like to easily inspect its contents. Looking at the types allowed in the pom.xml, I only see things like pom, jar, war, ear, ... Basically just archives of some sort. So I'm wondering what the pom.xml might look like to package a single file. I would imaging the maven artifacts on inspecting the server to be something like

myconfig-0.0.1.cfg  myconfig-0.0.1.cfg.md5  myconfig-0.0.1.cfg.sha1  myconfig-0.0.1.pom  myconfig-0.0.1.pom.md5  myconfig-0.0.1.pom.sha1  

So is this possible? What would the pom.xml look like?


Solution:1

I would wrap the configuration file in a jar and use the Dependency plugin to dependency:unpack the jar during the generate-resources phase (see the Unpacking specific artifacts example). This would allow to version it easily, to add it as dependency easily, and to inspect it easily.


Solution:2

See this discussion, specifically on using the maven-install plugin to define an installable artifact:

https://stackoverflow.com/a/4245890/2491903


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »