So please tell me how to set classifier and extension in dependency correctly and
what do I have to do to access classifier and extension of my dependencies within a gradle task?
Extensions and classifiers are attributes of a dependency’s artifacts. For each dependency you can call getArtifacts, which will return a set of DependencyArtifact.
Note, getArtifacts is not available for all subinterfaces of Dependency.
Side question; Do you really want the configured dependencies, or do you want the resolved dependencies? In my example, the configured dependencies have a version of +, but a resolved version would be something like 4.12
Some extra notes; As a general best practice, you’ll want to avoid using these during Gradle’s configuration phase. Triggering the resolution of a configuration during the config phase can cause you annoyances and sometimes issues/failures.
Time will be spent resolving the configuration even if it may not be needed. For example, running gradle tasks usually has no need for dependency resolution, so don’t waste time doing it when Gradle configures the project.
1.1 An extension to #1, a failed dependency resolve during the configuration phase is very frustrating when your trying to use the various reporting tasks (tasks, model, projects, components, etc).
Resolving a configuration before the config phase is complete may result in the configuration’s settings being incomplete at the time of resolution. This can happen when there exists config code after you resolve the configuration (some settings of a configuration will cause a failure if the configuration has already been resolved).
There may be more good reasons not to resolve a configuration during the config phase, but those are my personal top two.