开发者

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

开发者 https://www.devze.com 2023-03-08 08:40 出处:网络
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 a

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 app开发者_如何学运维lication). 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


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'
}


That's not how it works. Dependency management works on jar files (and plugins), not classes or packages. If you need to exclude a class or package you need to specify a different version that doesn't include them, or if necessary rebuild the jar yourself with those classes removed.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号