Hey there :wave: I'm developing a Gradle plugin an...
# plugin-development
n
Hey there šŸ‘‹ I'm developing a Gradle plugin and I want to download a jar (r8 jar) from
<https://storage.googleapis.com/r8-releases/>
. I would normally add an ivy repository from my Gradle plugin to do this but this doesn't work if the consuming project has
Copy code
dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
}
I could use a Gradle task to download the jar but then it wouldn't be cached like a dependency download is. Are there other alternatives here?
t
• have a settings plugin that can declare the repository in the settings script (and use a BuildService to communicate the repositoriesMode to the project plugin so it can decide whether to declare the repository in the project) • bundle the JAR into your plugin (possibly even as a resource that you extract to a temporary directory) • ask the user to declare the repository themself, possibly with some configuration in your plugin to either have the plugin declare the repository or use one declared by the user But btw can't you get it from https://maven.google.com/web/index.html#com.android.tools:r8 ? Maybe they're not the same? That would make asking the user to declare the repository simpler on their side.
n
Thanks, yes r8 releases are published there but I want to get non-release version based on the sha. The consumer of my Gradle plugin should be able to specify the version via the sha.
I'm wanting to optimize the DownloadR8Task in the gr8 plugin.
v
Whether project- or settings-plugin, you should never declare any repository, that is extremely bad practice and will maybe give a warning, maybe fail, maybe be ignored, depending on repositories mode. The actual build should always control the repositories that are used, otherwise you can for example hardly follow company guidelines to only use internal audited and reliable mirrors / proxies. A plugin should never add any repository unasked or at the very least provide a way to opt-out of adding the repository. Providing some method in an extension that will add the repository is for example an easy to use way to opt-in into the repository adding.
šŸ‘ 2
e
https://github.com/gradle/gradle/issues/28530 possibly relevant, as I don't think you really care about that repository as such, you just want to fetch once specific artifact
āž• 2
a
there's an interesting workaround in https://github.com/gradle/gradle/issues/32225 that uses internal Gradle services Previous Slack thread
šŸ‘ 1