Is there any way to add dependency to a gradle or maven project programmatically ? I am trying to modify a java file using eclipse JDT. One of my changes requires a method from apache-commons. So I have to check programmatically whether the library is already included and if not I have to add the dependency. Is there any way or tool that helps me?
You should not modify build file, like pom.xml or build.gradle for that needs. I think, it's a better idea to check if the library is in the project's classpath and if it's not - gently ask a developer to add it. That's how, for example, generating of toString works in IDEA: if certain libraries are available in the project corresponding options become available: 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With