mill-buildr: Splitting large build.sc
files into an scala project itself.
#2014
Replies: 2 comments 1 reply
-
as a totally unrelated side note: we do have a picture of @lihaoyi at work to bless all our developments. his awesome libraries and book has helped us a lot to get over the difficult times. |
Beta Was this translation helpful? Give feedback.
-
I remember that we discussed something like this in the chats. Nice it worked out for you. And thank you for sharing! In the meantime, I experimented with |
Beta Was this translation helpful? Give feedback.
-
At work we've been using mill since about late 2018 and never looked back!. Thanks to all people who have made of
mill
an awesome tool.Our build.sc which was initially tiny grew a lot of modules over time (all in a mono-repo, eg, models, daos, remote-services, web-server, etc). About two years ago we started splitting our build.sc into smaller modules (other
$file
importable.sc
files) and mill always worked fine but the ".sc
editing" experience was not that good even using IntelliJ, they certainly looked like scala files but not-so-experienced developers were missing auto-completion and jump-to-definition features from their IDE. At the time I believe there was no bsp integration and all we had was GenIdea, but IntelliJ was not very good at finding references over lots of.sc
files.So, it was really important for me to make code on our "build-definitions" editable by anyone on the team. Have them use their IDE with all features while editing our build project, just like editing any other mill-scala project.
Trying to find a solution for this, I found a hack (we have been using this since about ~2020 and finally extracted the code to share with other people). The trick is, define a
buildr
project which has all our modules definitions as traits (a regular mill-scala project) and then load the runClasspath into the mill's interp runtime. After that, allbuild.sc
file does is just create top level objects, basically just a list of objects extending their particular module implementations. This way thebuild.sc
keeps small and clean and all the meat is in thebuildr
project.So, this
BuildrModule
can be seen more as a pattern than a library, anyways, just shared a repo if other people having huge mill-projects can benefit from this idea:https://github.com/vic/mill-buildr
(see the example
build.sc
and examplebuildr/src/*.scala
on the repo)Beta Was this translation helpful? Give feedback.
All reactions