Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add all sub-directories JARs into dependencies in IntelliJ IDEA

I have a folder with multiple sub-directories, which all have a JAR file in each of them. This is a simplified structure of the files:

lib/
|
|__lib1/
|  |_version1/
|  | |_lib1-1.0.jar
|  |_version2/
|  | |_lib1-2.0.jar
|
|__lib2/
|  |_version1/
|  | |_lib2-1.0.jar
|  |_version2/
|  | |_lib2-2.0.jar

Now, I would like to add all of the JARs recursively into the dependencies list inside of the Project Strucutre (in IntelliJ IDEA 14).

Is there a quick way of achieving this without having to expand all directories and select the artifacts manually?

like image 722
Momo Avatar asked Jan 07 '23 18:01

Momo


2 Answers

In your project home directory, there exists an .iml file add this under <library> : <jarDirectory url="url to the folder containing jars" recursive = "true">

Worked for me.

like image 175
Karan Thakkar Avatar answered Jan 10 '23 08:01

Karan Thakkar


On IntelliJ 2019.2

  1. Open the "Project Structure" (Command-;)
  2. Select "Libraries" from the left list
  3. Push the + button to add a library, navigate to directory or your choice and click "Open". When IntelliJ asks to identify the category of files of the directory, pick "Jar Directory".
  4. Click "OK" and close this window.
  5. Locate the .idea/libraries/system.xml file in your project and open it.
  6. Locate the entry for the folder you just added as a library and change the 'recursive' argumument from false to true.
  7. Save the file

As soon as you save IntelliJ will recurse through the directories and add all the jars it can find to the entry of your library in the project navigator.

like image 29
Riccardo De Menna Avatar answered Jan 10 '23 09:01

Riccardo De Menna