how can I add an ENTIRE directory to a jar file?

To make my question clear, I will make up a concrete example.

Suppose that I have a directory named web that contains a file name index.html.

Now suppose that I want to configure IntelliJ, when it builds my module, to also build a jar file which contains the entire web directory.  That is, in the final jar, I want to see a directory entry inside it named web which in turn contains index.html.

I am aware that in File --> Project Structure --> Artifacts --> Output Layout that I can click on the + button and select Directory Content.  That almost works--it does add index.html to the final jar.  Unfortunately, as the name of the option Directory Content suggests, only the content of web is added to the final jar, but not web itself.

Is there any way in IntelliJ to tell Artifacts --> Output Layout to add an entire directory, not just its contents?

I can only see nastly workarounds, like

  1. chose Directory Content and select the parent directory of web.  That would work, it would inlcude web as  I desire, but it will also include everything else inside that parent  directory too (in my case, there is a bunch of other stuff besides web there).  I am part of a team, and do not have the luxury to rearrange stuff...
  2. do some custom manual postprocessing to add web (e.g. execute a bash script, or maybe figure out how to use IntelliJ's Post-processing Ant task)


I hope that I am missing something obvious...

2 comments
Comment actions Permalink

You can click on 'Create Directory' button (the first icon in the toolbar above the output layout tree) to create a directory entry in the layout and
then drag'n'drop 'Directory Content' element into it. Or you can do the same using 'Surround with...' -> 'Directory' item in the popup menu in the
output layout tree.

--
Nikolay Chashnikov
JetBrains
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Nikolay: your slution workes perfectly.  Thanks much!

0

Please sign in to leave a comment.