Hi, I have an idea of a plugin and I am wondering:
Is there any simple way to get “aar” or “jar” files from strings like '‘com.makeramen:roundedimageview:2.1.0’ (external dependencies from maven etc)?
This Groovy method in the context of a Project is enough to get all JAR files that would be included by the dependency String:
def resolveDependencyString(String dependencyString) {
def dependency = dependencies.create(dependencyString)
configurations.detachedConfiguration(dependency).resolve()
}
Note: The returned result is a Set<File>
which includes any transitive dependencies. If you need only first level dependencies, take a look at ResolvedConfiguration
from the Configuration
instead.
the @ in the shortcut notation is used to look for the provided extension attribute of the dependency
'com.makeramen:roundedimageview:2.1.0@aar'
will resolve to the artifacts with extension aar
50.4.1.2. Artifact only notationAs
said above, if no module descriptor file can be found, Gradle by
default
downloads a jar with the name of the module. But sometimes, even if the
repository contains module descriptors, you want to download only the
artifact jar, without
the dependencies.
[14]
And sometimes you want to download a zip from a repository, that does not have module descriptors. Gradle provides an artifact only
notation for those use cases - simply prefix the extension that you want to be downloaded with ‘@’ sign: