Legacy Knowledge Base
Published Jun. 30, 2025

Adding custom jar in module project as it gets remove after gradle refresh.

Written By

Amit Tiwari

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

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.
Did this article resolve your issue ?

Legacy Knowledge Base