I have question regarding dependency resolution fo...
# gradle
v
I have question regarding dependency resolution for plugins. I have the following situation: • A plugin (https://github.com/Stvad/kask-gradle-plugin) that depends on the library I’ve developed - https://github.com/Stvad/kask • The library is build/served by https://jitpack.io. It’s presented as a maven repo -
maven(url = "<https://jitpack.io>")
• The plugin is published on the gradle plugin portal. When I’m trying to use the plugin though I’m facing several problems: • If I just use the plugin via
id("org.stvad.kask") version "0.1.1"
entry in
plugins
section, the project fails initial configuration, with the following error (basically gradle is looking for dependency in the wrong place and not finding it):
Copy code
Could not find com.github.Stvad:kask:-SNAPSHOT.
Searched in the following locations:
  - file:/Users/sitalov/.gradle/caches/4.10/embedded-kotlin-repo-1.2.60-2/repo/com/github/Stvad/kask/-SNAPSHOT/maven-metadata.xml
  - file:/Users/sitalov/.gradle/caches/4.10/embedded-kotlin-repo-1.2.60-2/repo/com/github/Stvad/kask/-SNAPSHOT/kask--SNAPSHOT.jar
  - <https://plugins.gradle.org/m2/com/github/Stvad/kask/-SNAPSHOT/maven-metadata.xml>
  - <https://plugins.gradle.org/m2/com/github/Stvad/kask/-SNAPSHOT/kask--SNAPSHOT.pom>
  - <https://plugins.gradle.org/m2/com/github/Stvad/kask/-SNAPSHOT/kask--SNAPSHOT.jar>
Required by:
    project : > org.stvad.kask:org.stvad.kask.gradle.plugin:0.1.1 > org.stvad:kask-gradle-plugin:0.1.1
I can work around that problem by adding the following configuration in the project settings:
Copy code
kotlin
pluginManagement {
    repositories {
        gradlePluginPortal()
        maven(url = "<https://jitpack.io>")
    }
}
Which, works, I guess =/, but I’m surprised I have to do this. But after that I have more troubles - my understanding was that plugin dependencies should be transitively available to the project using that plugin. But it does not seem to work for me - in order to make the aforementioned library usable from the project that is applying the plugin, I had to explicitly declare repository and dependency configurations. Which means that to use the plugin properly user would have to: 1) apply it; 2) change plugin repo configuration; 3) add new repo to the project; 4) add explicit library dependency to the project. Which seems rather cumbersome. What I want to achieve is situation when a user of a plugin just needs to apply it and does not have to worry about dependency any dependency declarations. I’d appreciate your advice on how I can achieve that!
n
you can avoid the plugin stuff by publishing it on the gradle-plugin repo, and maybe you could make your plugin modify the dependencies of the project it is added to so the user does not have to configure it manually ? if you figure out how i would be interested in the solutin since i also plan to make a gradle plugin to do some compiletime code generation
v
gradle-plugin repo
it’s already there =\
Also, as I mention - transitive dependencies supposed to just work (at least it’s my interpretation of https://discuss.gradle.org/t/transitive-dependencies-from-plugins/5428) and they don’t - I’m probably doing something wrong there =\
fyi created a thread on gradle forums - https://discuss.gradle.org/t/dependency-resolution-in-plugin-depending-on-the-package-from-custom-repository/28629 in case people there know a better way 😛