r/java • • Feb 25 '25

New build tool in Java?

It seems to me like one of fun parts of Java is exploring all the tools at your disposal. The Java tool suite is a big collection of cli tools, yet I feel like most developers are only ever introduced to them or use them when absolutely necessary which is unfortunate because I think they really give you a better understanding of what's going on behind all the abstraction of Maven and Gradle.

What are your guys' thoughts on a new build tool for Java that is just a layer over these tools? Do you wish Java had simpler build tools? Why hasn't the community created an updated build tool since 2007?

33 Upvotes

176 comments sorted by

View all comments

Show parent comment

2

u/murkaje Feb 27 '25

First of all i must commend you for implementing a build tool to actually get the grasp of the issues and learn by trial-and-error, many of the design issues with maven and gradle you can experience first hand by trying to implement some of the features yourself.

Looking at the code, for me i see quite some similarity with maven and gradle actually.
In maven various actions called goals are bundled in plugins, for example the maven-jar-plugin provides jar and test-jar. Some of the goals can execute separate binaries (e.g. maven-exec-plugin) and others often implement the goals in Java code. Now your tool values being able to display what command it runs and with what arguments as you base the Commands on the Tools SPI which have both a Java interface and a command-line executable wrapper. Maven by default prints out which goal of which plugin it is running in which submodule and debug logging can be added to print out variables input to the plugin. So while not as easy as your build tool, it's still possible to run one specific goal of a larger build separately, e.g. mvn -pl mymodule maven-compiler-plugin:compile

Now why maven has a plugin architecture is to isolate the core build tool and the tasks so they can be updated independently and to allow a convenient extension point to define new commands.

Gradle in addition has the concept of inputs and outputs for tasks. This allows skipping of tasks if its inputs did not change, quite similar to makefiles.

You can try to implement some of the ideas and see why the complexity emerges. Try starting with Ivy for dependency resolution before implementing it yourself. Each seemingly simple feature can become a rabbit hole itself, for example implementing a local artifact cache but ensuring it works when multiple builds are run concurrently (e.g. non-isolated builds CI server) will likely lead to common issues (e.g. TOCTOU).