I’m working on client’s Java 8 application in IntelliJ IDEA that requires adding / re-adding two JAR files as Global Libraries to every component in the project after every code change. (Yes, this is insane.) As one can imagine, going through the process of deleting the existing Global Library references and re-adding them through the UI is time consuming and annoying. Because there are hundreds of developers working on the same code base, I cannot change this tedious process.
The steps I have to take in IntelliJ Idea after every Maven clean and install (clean install -X -DskipTests
):
- Navigate to
File > Project Structure... > Platform Settings > Global Structure
- Select an existing global library (*.jar) and copy its file path.
- Delete the global library reference
- Add a new global library reference using the path copied in Step 2
- Select all modules (Control+A) when the
Choose Modules
pop-up is displayed - Repeat steps for all *.jar files that are to be global modules.
As a relative Java-newbie, I’m not sure why running the Maven clean and install commands invalidates the existing global library references, but it does. Note that one of the global library references, the one that is grayed-out in the snapshot, is actually compiled as part of the project itself.
Is there a way I can programmatically remove and re-add Global Libraries without going through the Intellij UI? I already have a batch script that runs to create a new Docker container after each code change, so it’d be ideal to add a few more lines of code to that script to handle the global library references.