Hi, I'm working on a multi-project repository usin...
# plugin-development
s
Hi, I'm working on a multi-project repository using Kotlin and Python. I'm trying to develop a plugin to mimic the standard Java/Kotlin behavior for declaring dependencies and packaging a project in the python world. Basically what I'd like to achieve is something of the sort:
Copy code
pythonProject {
  // ... additional extension properties here

  dependencies {
    implementation(":langchain-community:0.18.1")
    implementation(project(":grpc:stub:python"))
  }
}
The dependencies declared would then be processed by a task that puts them into a file and let python do the actual resolution (here the behavior departs from the standard dependency resolution mechanism). I've looked into custom dependency blocks, but that seems to hook into Gradle's standard artifact resolution and download, so I'm currently wondering what would be the best approach to model this. Is it better if I create my own container object? If so, what's the best way to enable calling the
implementation
function inside the extension block? Or is there a way to tweak the behavior of the default dependency resolution mechanism so that only project dependencies are resolved to an actual artifact while the others are ignored? Any hints are much appreciated
v
Iirc, what you should use / create is a
SelfResolvingDependency
that then can use Python for the actual resolution
v
Oh, ok. :-/ How about
FileCollectionDependency
then?
s
mmh yeah could be but the truth is that I don't need to resolve the dependency, all I need is the declared name and version and then I can add that to a
requirements.txt
file that python can use to resolve it
but I think the most interesting question for me is: even if I want to use a
FileCollectionDependency
, how do I set that up in a custom plugin extension? I'm a bit at a loss there, and the documentation is helping me only up to a point
v
You probably provide some function that produces it. The Kotlin/JS plugin for example has a
npm
function that produces a dependency that is both
FileCollectionDependency
and
SelfResolvingDependency
and that is resolved through NPM I think.
s
ah good to know, I will check out the implementation and see if I can steal some good trick from there 👍
v
Sorry if I'm not too concrete on this, never tried something like that.
s
all good, I'm so lost that any tip helps 😅
👌 1
v
Maybe worth a documentation improvement request on GitHub to document how you implement such a use-case idiomatically. 🙂
Another option could maybe be, that your plugin spins up a web server (can be in-process) that formally acts as a Maven Repository, but delegates to Python for doing the actual resolving.
Then users could just use any normal means to declare dependencies.
s
I like the kotlin js approach, as it seems to allow for definition of a custom dependency type. That type then could in my case resolve to an empty file list, thus being compatible with the default contract. Setting up a maven repo sounds a little too much work and machinery for the scope of the issue in my opinion
v
Doesn't sound like too much work imho. Java has capability to start an HTTP Server built-in. And you just have to answer GET requests for certain paths with certain files. Should not really be much effort imho. 🙂