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.
org.apache.maven.plugins:maven-dependency-plugin:3.3.0:unpack. Description: Goal that retrieves a list of artifacts from the repository and unpacks them in a defined location.
The dependency plugin provides the capability to manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location.
The Assembly Plugin for Maven enables developers to combine project output into a single distributable archive that also contains dependencies, modules, site documentation, and other files. Your project can easily build distribution "assemblies" using one of the prefabricated assembly descriptors.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With