0

I'm adding dependencies as below but it include too many unnecessary jars as well

dependencies {
 
    // Add all the jar dependencies from the lib folder. 
    compile fileTree(dir: '../lib', include: ['/**/*.jar'])
}

So, I picked up something as below.

dependencies {
 
    // Add all the jar dependencies from the lib folder. 
    compile fileTree(
                  dir: '../lib',
                  includes: [
                        'commons-codec-1.11/commons-codec-1.11.jar',
                        'ehcache-2.10.5/ehcache-2.10.5.jar',
                        'json/json.jar',
                        '...so on...'
    ])

}

is there any better way to manage this includes dependencies?

Swapnil Kotwal
  • 5,418
  • 6
  • 48
  • 92
  • 1
    May I ask why you include local jars instead of online ones, and defer to Gradle to download them as needed? – afterburner Aug 04 '20 at 09:59
  • I'm actually working on POC to move decade old enterprise project to new build tool Gradle.. for my POC I'm expected to use local jars and yes the final plan is to move it to maven or S3 repositories – Swapnil Kotwal Aug 04 '20 at 10:18
  • That's a bit more effort on your end, but the accepted answer from here will make it easier for you to move onto maven repositories later on: https://stackoverflow.com/questions/20700053/how-to-add-local-jar-file-dependency-to-build-gradle-file – afterburner Aug 04 '20 at 10:21
  • Answers are same like what my question already have... there is nothing new in it. I hope whatever syntax I've used is the best one? – Swapnil Kotwal Aug 04 '20 at 10:23
  • The syntax is okay. However, what the accepted answer has over your question is already an idiomatic way of declaring dependencies in Gradle, and a repositories block. When you move from your POC, it will be easier to swap out repositories. Furthermore, updating the declared dependencies will be easier, as you won't have to re-declare everything, just update the GAV coordinates. – afterburner Aug 04 '20 at 10:26
  • OKay... So shall delete the question as there is no concrete answer for it? What says? – Swapnil Kotwal Aug 04 '20 at 10:53
  • 1
    Feel free to keep it, others might find it useful – afterburner Aug 04 '20 at 11:30

0 Answers0