How to cache other dependencies than build tool in bitbucket pipelines ? Edited

I am able to cache the gradle specific dependencies, however, since there are other dependencies, viz., AWS Java SDK libraries that need to be downloaded and compiled, i wish to know of a way to cache these dependencies as well.