Issue
- The custom jar is getting removed after the Gradle refresh.
Environment
- Liferay DXP 7.0 and above
Resolution
- Create a folder libs inside the module project and place the custom jar in it and add the below code in the build.gradle:
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation name: 'jarname'
}
Additional Information
- The root cause is that Gradle knows absolutely nothing about Eclipse’s project templates and the like. You’re using Gradle as the build tool, so you must add dependencies using the appropriate Gradle techniques.
- Eclipse, with respect to maven and Gradle builds, is merely a front man, it is never actually doing builds itself, rather it is managing the invoke of the Gradle or maven tools. The project template and “referenced libraries” are Eclipse things that it can artificially layer into a build, but it does not actually modify the Gradle config (in build.gradle) to do anything with those libs.