Grails项目中如何强制更新org.codehaus.groovy:groovy-all子依赖
groovy-all Dependency in Grails Absolutely! You can absolutely override the transitive groovy-all dependency pulled in by grails-bootstrap—even without explicitly declaring grails-bootstrap in your BuildConfig.groovy. Here's how to do it reliably:
1. Explicitly Declare the Desired Version
The simplest way is to add groovy-all directly to your dependencies block with the version you want. Grails' dependency resolver will prioritize this explicit declaration over any transitive versions from other dependencies like grails-bootstrap.
Add this to your BuildConfig.groovy:
dependencies { // Keep your existing dependencies here compile 'org.codehaus.groovy:groovy-all:2.4.13' }
2. Force the Version (For Edge Cases)
If the explicit declaration doesn't resolve the conflict (rare, but possible in complex dependency trees), you can use the force flag to tell Grails to ignore any conflicting transitive versions entirely:
dependencies { compile ('org.codehaus.groovy:groovy-all:2.4.13') { force = true } // Your other project dependencies... }
Alternatively, if you prefer a global override, use the dependencyManagement block to lock the version across your entire project:
dependencyManagement { dependencies { dependency 'org.codehaus.groovy:groovy-all:2.4.13' } }
3. Verify the Fix
To make sure the override worked, generate a dependency report with this Grails command:
grails dependency-report
This will create an HTML report (look in your project's target folder) where you can search for groovy-all to confirm it's using version 2.4.13, and that it's no longer being pulled in by grails-bootstrap.
Quick Note on Compatibility
Before deploying, make sure to test your project thoroughly. Groovy 2.4.13 is generally compatible with Grails versions that use 2.3.x Groovy, but there might be minor API changes or edge cases. Run your test suite and smoke-test key functionality to avoid surprises.
内容的提问来源于stack exchange,提问作者abbas

