Maven war plugin copies arbitrary files

I apologize that this is certainly the basic material for maven / war, but I am not a maven user. I just have to hack this thing into a maven based project.

What I need to do is copy the (essentially arbitrary) directory and files to the root of my war. I need them to appear as resources available over HTTP when the war unfolds.

I can't just put them in the โ€œright placeโ€ in the source tree. This is because the files in question are actually the source files of my project. I understand that this is a little strange, but this is a draft documentation, and I need to show the source and effect in the same war.

So, in general, how do I configure the maven war plugin to copy this directory, along with its contents, to the root of my war? (By the way, I tried to understand the documentation of this tool, but it seems to be based on such a deep understanding of maven that it seems to me that I will never understand this without studying maven first, and I too pressed the time to do it now !)

Many TIA Toby.

+6
source share
2 answers

You can try:

  • use the copy-resources plugin. Use the plugin to copy the source files to target before the outbreak of war.

  • or configure maven-war-plugin to enable additional resources.

+8
source

Thanks Drew, it led me to where I needed to go. At the bottom, I added a sample pom fragment from the link that you provided for the copy resources to my pom.xml with the following changes:

<outputDirectory> target / $ {project.name} - $ {project.version} / sources ...

<directory> src / main / java ...

I copied this from the link you gave, and then edited the element to point to src / main / java, which took my files and outputDirectory for the aggregate target / $ {project.name} - $ {project. version} / sources. I found that $ {project.name} was associated with the project, and the version came from $ {project.version}, which seemed to resolve the last small bits of the problem.

Thanks again. Toby

+1
source

Source: https://habr.com/ru/post/958118/


All Articles