I’ve been rewriting on of my gradle plugins that currently defines dependencies in the afterEvaluate block. The main issue is that this creates a lot of spaghetti with static variables being present here and there, and is generally not that configurable anyways. Plus it’s incompatible with the configuration cache.
So, instead of generating the dependencies at configuration time, I now generate them through tasks. This works decently well enough, except with the issue that I don’t know how to get the dependencies attached to the configurations (while I could just add them directly to the JavaCompile tasks, that is a bit involved and wouldn’t fly all too well with IDEs anyways).
In the past (pre-rewrite), I would declare a flatfile maven repository and declare the dependencies using the standard dependency notation. While that approach technically still works, it still requires one to know what the dependencies will be at configuration time (if that’s done in a task, IDEs will be completely oblivious to the dependencies), and also has the issue of IDEs not running the tasks that generate the dependencies by default.
So, my current approach would be to ensure that when a configuration is resolved, the dependent tasks get executed. Unfortunately, something along the way of configurations[“myConfig“].getBuildDependencies().add(myTask)did not seem to have any effect - which I suppose is understandable. Basically, I’m looking for the opposite of myTask.dependsOn(configurations[“myConfig“].getTaskDependencyFromProjectDependency(true, “myTask”)).