Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude a specific package of a jar dependency in Grails project?

In my Grails project, I used library A. One of A's dependencies is B. In B jar, there's a package (named C) that I want to exclude from my project (because it duplicates an existing package in JDK and causes error when starting up the application). But I don't know the correct syntax to do this. I tried the below codes but it does not work

dependencies {  
     runtime ('A-library') {  
            excludes(<what-I-should-write-here>)  
     }
}

Could you please help me on this? Thank you so much

like image 862
Đinh Hồng Châu Avatar asked Dec 08 '25 20:12

Đinh Hồng Châu


1 Answers

You can only include/exclude B completely, you can't include/exclude certain packages of B. To achieve your goal you would need to find (or create) a modified version of B that has the duplicate packages removed. Then change your BuildConfig.groovy to:

dependencies {  
     runtime ('A-library') {  
            excludes('B-library')  
     }
     runtime 'B-library-with-duplicate-packages-excluded'
}
like image 175
Dónal Avatar answered Dec 11 '25 18:12

Dónal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!