2

I have a module for which I want a jar to be created. So, here is what I do:

  1. Adding a jar artifact, using the "From module with dependencies ..." option
  2. In "Jar files from libraries" I select "copy to the output directory and link via manifest"
  3. Leave all the defaults.

After that I can build the jar and all the dependencies would be placed near it in the same directory. So far so good.

Now I wish all the dependencies to be placed in a separate directory near the final jar. So, I repeat the same steps, but this time I create a new directory under the node in the artifact Output Layout tab (using the "Create Directory" button). Next I drag all the dependencies onto the new folder and apply the changes.

On the surface, everything is cool - the dependencies are indeed placed in the dedicated directory, but the MANIFEST.MF file is never updated! It should reference the dependencies via the new directory. As of now, the produced jar cannot be run - its dependencies are not visible.

This is unlike Eclipse, which does make sure the manifest file is correct when exporting a project as jar.

How can I workaround this problem, given that:

  • I want all the dependencies in a dedicated folder.
  • I want to use IntelliJ IDEA
  • I do not want to edit the manifest file manually.

I am using the latest download of the IntelliJ IDEA for windows - 11.1.2, build 117.418

Thanks.

mark
  • 59,016
  • 79
  • 296
  • 580
  • The issue is remaining until now. I think IntelliJ has some reason not to fix that. It's very small bugs compared to the IDE. Did anyone find any solution to this? without adding classpaths manually. – Pasindu Lakshan Sep 12 '21 at 23:41

1 Answers1

3

At the moment you have to update the classpath manually in the artifact configuration dialog so that it includes the subdirectory:

classpath

I've created an issue for this limitation, please star/vote.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904