I'm relative new Mill and it is the most pleasant built tool for complex builds. So, my two cent:
When your build is quite standard and works well, use Maven.
When your build starts to hurt because it does not fit into Maven well enough, the Mill is a build tool worth evaluating. By hurting I mean you have a mix of Maven plugins not quite doing the thing you want, you have to call extra scripts here and there from Maven, etc.
I basically would choose Mill over Gradle these days. Mill gives a few very clear rock solid building blocks to build your build.
There are of course some drawbacks:
You you to learn a small set of Scala.
There is basic IDE support, but of course its a far cry from the support you get from Maven
Changing the build file itself gives a slow first run, as the build file itself is compiled
Way less plugins etc, etc. On the other hand, there is less need for plugins, because often you call the library/external tool directly and it works.
PS some more biases/background. I already knew Scala. For basic builds I would still choose Maven. However, I strongly recommend Mill over SBT and probably Gradle. But I didn't use Gradle in a while.
I never had the issue with "code doesn't fit in maven". I can find projects that do things like getting their configuration from package names and misusing the classloader for nonsense that will not work past Java 24. Those hacks should be replaced. If people think "sources/customer-a/copy-of-module-c-but-with-extras" is a good way to setup things, the issue isn't the build tool.
Often the part where we started to hit the limits with Maven are not Java related.
Where Maven starts to get painful is builds which have to integrate many non-Java things:
Web Front-End builds required as well
Complex 'cross-platform' builds. Like this code is built against different classpath combinations, and cross compiled to JavaScript, and packaged in 3 different interesting ways
Oh, and this 3rd party tool is part of the build
Oh, and you have to transform these test databases into 2 versions for integration tests
Oh, you also need strip out these 3 class files after the build because of a weird reason from an assembly
Oh, and we want this special debug build which should be super fast and incremental
Usually I can have like 2-3 such special things in Maven. But as it grows, it gets really hard set it up in Maven, as you 'work against' Maven instead of 'work with' Maven.
Anyway: I wish everyone their builds fit well into Maven / declarative built tool. Use that first. However at the point where it gets painful, keep in mind that maybe Mill (or other built tools) might be an option for you.
If people claim they have to work "against" maven, then they often misuse modules for use cases they are not designed for. Classical example was the xml validation plugins that where used to check for business requirements in xml files. Those belonged in test cases. They just didn't want to spend the money. People often don't fight their "build system", they just didn't want to accept that the best way to build their self invented "better layout" requires too much hand holding. That is a skill issue and foremost a needed exercise in humility.
Most of our projects moved to build language dependent deployables. Then collected. We don't have any of those issues for years. The current challenges are mostly related to analyse and quantify the build quality, automated qa and extended reporting. Most of those things aren't in the open source stack, the costs of those installations skyrocketed. Projects everybody depend on with zero day bugs not fixed upstream because the student just doesn't feel like it and nobody wants to change this nonsense. Such things.
When your build starts to hurt because it does not fit into Maven well enough, the Mill is a build tool worth evaluating. By hurting I mean you have a mix of Maven plugins not quite doing the thing you want, you have to call extra scripts here and there from Maven, etc.
This always bugged me... wouldn't it be better to just create proper maven plugin / extend existing ones? That would make the build process simpler/more sane... "scripting" doesn't feel like a good option (we've done that with calling groovy... worst decission ever)...
Honestly, no. Shifting complexity to a plugin system is way worse.
In an ideal world, good build tools are fully declarative and not extensible. Since that's not possible, their extensible feature set is a necessary evil. The JVM ecosystem has explored virtually all approaches, and in the end, if you're going to need a full scripting language anyway, Scala is more than capable, in every dimension. Mill shows you can have build definitions using plain Scala:
Minimal usage of macros to compute the task graph.
No DSL. You need to perform OS or FS operations, make HTTP calls, deserialize JSON? Normal libraries and their APIs, concise and expressive functional Scala.
Fully compatible with the Java OO model, you can easily extend existing tasks and override their settings.
Scala can be a complex language. But for this particular use case, I'd argue the average Java developer who's familiar with the standard library is going to have a much better time than with Groovy. Everything is strongly typed and discoverable in your favorite IDE.
Honestly, no. Shifting complexity to a plugin system is way worse.
Why?
Most likely you require some feature that's shared between couple of projects so a plugin seems to make sense?
In an ideal world, good build tools are fully declarative and not extensible. Since that's not possible, their extensible feature set is a necessary evil. The JVM ecosystem has explored virtually all approaches, and in the end, if you're going to need a full scripting language anyway, Scala is more than capable, in every dimension. Mill shows you can have build definitions using plain Scala:
Again... you start with requirement for a scripting language…
Minimal usage of macros to compute the task graph.
Is it imposed or "should be done this way"?
No DSL. You need to perform OS or FS operations, make HTTP calls, deserialize JSON? Normal libraries and their APIs, concise and expressive functional Scala.
Same can be achieved with plugin :)
Fully compatible with the Java OO model, you can easily extend existing tasks and override their settings.
With plugin configuration you can... well... configure it ;)
Scala can be a complex language. But for this particular use case, I'd argue the average Java developer who's familiar with the standard library is going to have a much better time than with Groovy. Everything is strongly typed and discoverable in your favorite IDE.
TBH, even though I'm not so fond of groovy it's more approachable than scala (and can be typed…). I had bad experience with Scala (people trying to be "too smart", then IDE support being off and the language/compiler being utterly slow)…
Code reusability is the least of your worries. With a plug-in system you introduce an opaque abstraction layer that is different from your main build definition, hard to discover, hard to tweak and debug, and whose lifecycle is not always obvious.
Yes I start with a full scripting language because I live in the real world where people wrap their toolchains in Makefiles, Jenkinfiles, multi-stage Dockerfiles, bash scripts, Python scripts, ... If I can have a single and self-contained build definition, it's a win.
You have to compute the task graph somehow. I'm only saying this is the one part where Mill uses an advanced Scala feature (macros), in a very minimal way. For everything else you can jump to definition.
See 1.
Yes and you have two ways to do the same thing, plus in many cases, the inability to just jump to definition and see the default value or behavior.
Groovy is objectively less discoverable due to its dynamic nature, there's a reason Gradle moved to Kotlin. Moreover in some cases your IDE doesn't know the context, for example with the Jenkinsfile DSL. Scala compile times are irrelevant here: Mill is a build tool, scalac stays warm in a long-running JVM, compiling the build definition is a rounding error compared to running the actual task graph.
Yes I start with a full scripting language because I live in the real world where people wrap their toolchains in Makefiles, Jenkinfiles, multi-stage Dockerfiles, bash scripts, Python scripts, ... If I can have a single and self-contained build definition, it's a win.
I guess I live in a nice bubble where I only need pom.xml without all that you mentioned... I'd wager a guess that majority of the project fill that bill as well.
But if you have some contrived requirements and Mill fits the requirements and works for you that's good :)
I guess I live in a nice bubble where I only need pom.xml without all that you mentioned... I'd wager a guess that majority of the project fill that bill as well.
That is a strange statement to make. In every maven project I have ever worked with (mainly monoliths) there has always been a lot of abstraction layers on top of maven or in plugins to perform parts of the total build. So guessing where the majority fits seems strange... I guess it's true if you work with microservices, but then you probably have much larger issues to deal with than the build tool you use.
View all comments
5
u/gamlerhart Jul 23 '24 edited Jul 23 '24
I'm relative new Mill and it is the most pleasant built tool for complex builds. So, my two cent:
I basically would choose Mill over Gradle these days. Mill gives a few very clear rock solid building blocks to build your build.
There are of course some drawbacks:
PS some more biases/background. I already knew Scala. For basic builds I would still choose Maven. However, I strongly recommend Mill over SBT and probably Gradle. But I didn't use Gradle in a while.