Aha, it’s possible to add source dependencies via Git URLs:
(via https://stackoverflow.com/a/56787382)
That means that the cores stuff could be wrapped up in an otago-lectures
plugin or similar, pushed to GitBucket, and imported as a dependency in each lectures project. No more multiple copies of the build script! All that’s needed on the local build script is the dependency and appropriate configuration (essentially what’s in the existing lecture.gradle.kts
).
This looks like more relevant documentation for building an external plugin: https://docs.gradle.org/current/userguide/custom_plugins.html. Initial development and testing could be done as a buildSrc
plugin inside (a copy of) a standard lectures tree. Convert to a standalone plugin once it’s fully working.
Ugh, Gradle plugins are a complete nightmare. Binary plugins need to be published to a (Maven) repository. The source dependencies mentioned above are a potential solution but have been “experimental” since 2018. They haven’t been documented nor has there been any further updates as far as I can tell.
apply( from = <URL>)
looked promising, but broke type safety, which made configuring the LaTeX plugin way more complicated, if not impossible — I couldn’t get it to work.
I’ve managed to get things working as a buildSrc
plugin. I think this is going to be the simplest solution in the end.
I toyed with the idea of automatic deployment, e.g.:
buildSrc
directory a Git submoduleThese all sound like too much hassle. Let’s just stick with having a copy of the plugin in each lectures repository.
Building in each individual lecture’s directory is fine, e.g:
But building all lectures in the lecture root directory doesn’t work, because
build.gradle.kts
tries to importlecture.gradle.kts
, which only exists in the lecture subdirectories.The solution might be to make the lecture infrastructure a script plugin instead. Then instead of symlinks, each lecture can have its own small
build.gradle.kts
that just declares the plugin, plus any custom build logic that currently goes inlecture.gradle.kts
.The root
build.gradle.kts
would not declare the plugin, relying on the subprojects for that.See: