i have recently migrated to gradle 8. i have dependency as configuration in (7.5 gradle), seems in 8, its been changed in 8.
jsoup group: ‘org.jsoup’, name: ‘jsoup’, version: ‘1.16.1’
apply from: ‘config.gradle’
configurations.jsoup ==> ??? how to call this, this is not working, imports in java class not resolving
my class has complilation isssues of jsoup, i searched entire internet, but not able to figureout working sytax
this gradle documenation is waste, finally got anser in stackoverflow…
I have to object. The Gradle documentation had its weaknesses, but overall it is a pretty good documentation for a software.
That SO answer on the other hand is horribly wrong, it shows various bad practices you should never mimic, is unsafe and broken and should better be deleted.
The question is, why your actually want to create a separate configuration at all. If your code depends on jsoup for its implementation, just declare it as
implementation dependency, no need for any custom configuration.
Also, how you create the configuration, you are creating a deprecated setup of a configuration that is just the default for backwards compatibility.
And if you make
implementation, that means any dependencies declared in
implementation are automatically also declared on
jsoup, but that of course does not automatically make what your only declare on
jsoup available for configuration somewhere. If at all, the extends should maybe be the other way around. But as I said, just declare the dependency on
implementation instead and don’t create a custom configuration.
And as another note, “apply from” is highly discouraged nowadays. Instead of these script plugins you should use convention plugins, for example implemented as precompiled script plugins in
buildSrc or an included build. They look almost the same but do not have many of the problems and quirks you will hit sooner or later when using legacy script plugins.