views:

173

answers:

1

I am finding a way how to copy any files to my web server using maven. I have a maven project which contains a sets of html, js, properties and configuration files.

I would like pack my stuff and deploy to repository. After that in another maven project I would like to unpack files from artifact, filtering resources and copy to the specifying folders on the server.

What is a best way to do it?

maven-dependency-plugin can unpack artifact but I didn't find how to use resource filtering in this case and how to specify several output directories.

A: 

I would create as many distributions as required using the maven assembly plugin and use filtering at assembly time. You could then deploy these assemblies to a repository and, indeed, use the maven dependency plugin to retrieve and unpack an assembly from a given machine. More on assemblies in the Chapter 8. Maven Assemblies of Sonatype's book.

Update: An alternative if you don't want to deploy "filtered" assemblies would be to create the assembly from the targeted machine (still using profiles and filtering as suggested). The created distribution would contain the right content in the right folders (you can do that with assemblies) and you would just have to decompress the archive for the last step.

Pascal Thivent
I guess it is not a good idea to store in the repository filtered artifacts. Filtering is environment specific thing.
eugenn
@eugenn What's the problem with storing "filtered" artifacts or environment specific artifacts? This actually happens a lot, especially with distributions that may be platform specific (this is a trivial example but a .zip or a .tar.gz may use different end-of-line char). Non filtered artifacts are useless anyway.
Pascal Thivent
For example I have dozen environments for deploying my app. If I would apply filtering for any artifact at building time then need to deploy to a repo dozens different artifacts. Or I can keep one "unfiltered" version (raw) in the repo and use filtering then I produce a final app only.I would like to be able generate "unfilterd" artifact in one project (it's ok) and produce, customize the final application in the second project. The second project should remove placeholders from artifacts which were generated in the first project.
eugenn