Can’t build from root lectures directory #1

Closed nigel.stanger opened this issue on 5 Apr 2022 - 4 comments

nigel.stanger commented on 5 Apr 2022

Building in each individual lecture’s directory is fine, e.g:

cd lec01
gradle

But building all lectures in the lecture root directory doesn’t work, because build.gradle.kts tries to import lecture.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 in lecture.gradle.kts.

The root build.gradle.kts would not declare the plugin, relying on the subprojects for that.

See:

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.:

  • making the buildSrc directory a Git submodule
  • setting up Gradle tasks to automatically clone/pull

These all sound like too much hassle. Let’s just stick with having a copy of the plugin in each lectures repository.

nigel.stanger added a commit that referenced this issue on 9 Nov 2022
0433059 Initial ¾-assed version of script plugin (#1)
nigel.stanger added a commit that referenced this issue on 20 Nov 2022
a5f3a28 Reimplemented plugin in Java (closes #1)
nigel.stanger closed this issue on 20 Nov 2022
Labels

Priority
default
Milestone
No milestone
Assignee
nigel.stanger
1 participant