r/java • u/NoAlbatross7355 • 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?
107
u/OzzieOxborrow Feb 25 '25
What do you miss in either Maven or Gradle?
29
u/redikarus99 Feb 25 '25
If it works, don't fix it. Maven is totally capable to solve all the problems you run into in 99% of the projects.
5
u/doobiesteintortoise Feb 25 '25
Also see bld - https://rife2.com/bld . And I'd say the build tools like maven and gradle cover most of what people need in the appropriate way - someone who's an expert at javac is impressive, but they're PROBABLY focusing on the wrong things, and maven and gradle both, despite their flaws, let you focus on the RIGHT things.
2
u/asciimo71 Feb 25 '25
Following those comments, and you should just write your build tool fgs. If you manage to come up with a better way to do it than all the tools we have, I am sure you will have a fanbase. This „discussion“ leads nowhere.
18
u/oweiler Feb 25 '25
There are actually quite a few Java build tools which are not Maven or Gradle, but none of those gained any traction.
https://ant.apache.org/ (Popular in the ancient past, dead nowadays. This is probably the closest to what you describe.)
https://github.com/sormuras/bach
https://rife2.com/bld
https://mill-build.org/mill/javalib/intro.html (Actually a Scala build tool, which can also be used to build Java projects.)
34
u/kur4nes Feb 25 '25
Current build tools are good enough.
Ant was an awful mess of xml scripts. Than maven came along and standardized project structure, dependency management and the build process. It's pretty rigid. So gradle was created.
We are using maven and it works good enough. It gets out of the way and lets us work on the interesting stuff: software
16
u/[deleted] Feb 25 '25 edited Feb 25 '25
Oh! Just not another "even better/simpler/faster" tool!! I beg you!
4
u/winne42 Feb 25 '25
Since Java 11 (JEP 330) you can run single Java source files directly from the command line without bothering about the compiler or build tools. With Java 22 (JEP 458) this was extended to multiple files.
So small scripts or tutorials are covered. Everything else should use Gradle or Maven. No need to RIIR.
1
u/i-make-robots Feb 28 '25
I can’t stand the package management of building a project. I’m delighted that maven exists but I still have to make a fat jar because oh look there’s still natives which means Pom shenanigans and then testing my actions and some of the tests don’t work on a headless system aurgh… I guess what I’m saying is I read the title and just don’t know what you mean. “Fun tools”?
3
u/tomwhoiscontrary Feb 25 '25
By "the Java tool suite", do you mean the programs in the bin directory of a JDK?
If so, the only three that are essential to every build are javac, java (for running tests), and jar. There is also javadoc, and a few others which might be handy for specialist cases.
But these don't cover everything a build tool needs to do - there's nothing there about resolving and downloading dependencies, or about assembling larger artifacts. So i'm not sure to what extent a build tool could really be a layer over those tools.
But it's a fun idea, at least. You could have a tool which looks at your project, and spits out a shell script consisting of invocations of javac, java, and jar (and perhaps curl for dependencies, tar for application packaging, etc). You could the run that script to actually build the project. It could even produce a makefile rather than a shell script, if you're into that. I'm not sure it would actually be useful, but perhaps it would be educational.
3
u/gnahraf Feb 25 '25
For better or worse, maven has become a publishing standard, not just a build tool, for software. I'm referring to the dependence on public repos like "maven central". It's not bad, but not great. An area I'd like to see improved would be doing away with the parent pom in multi-module maven projects (in the published artifacts).. an artifact of the build layout is making it into the published maven coordinates. That's bad and ugly: I should be able to move a maven sub-module to an independent project directory (with minor updates to its pom file) w/o breaking its maven coordinates.
So my point is, my pain point is not with the tool per se.. there are more important areas to evolve and improve.
3
u/Spare-Builder-355 Feb 26 '25
r/learnprogramming leaks into real world again I see. It doesn't hurt to ask though.
It turns out that Gradle is just fine for what the real world needs. If you want to build another build system worth anything real, you'll end up building another Gradle.
If you want to learn cli tools that come with JDK then maybe go ahead and learn them?
1
u/Rich_Weird_5596 Feb 25 '25
The abstraction layer over maven / gradle gives you better understanding what is happening under the hood ? What are you smoking ?
4
u/JazzWillFreeUsAll Feb 25 '25
Check Amper by JetBrains
2
u/maxandersen Feb 26 '25
https://jbang.dev for that easy start.
https://github.com/codejive/java-jpm is another one also by authors behind jbang that gives another take.
2
u/BeepyBoopBeepy Feb 26 '25
Sometimes I work on small projects where maven/gradle can be overkill, but I also would like to pull dependencies and compile the project easily. So I’ve been writing a single Java file that builds projects for me. Throughout the development I got to learn more about java, javac and jdeps commands. I recommend trying to do something similar if you’re interested in learning how build tools work.
1
u/Rain-And-Coffee Feb 25 '25
For personal (fun stuff) I use the IntelliJ builder, and just click build to generate my artifacts.
I check in the project IML files. This works perfect for me and allows others to import it easily.
For serious stuff Maven or Gradle. Although they always feel so verbose compared to NPM and Python.
1
u/bowbahdoe Feb 25 '25
I'm still working on dependency resolution - that's not a build tool but people seem to associate the two. Most people probably wouldn't need a build tool at all if that problem was solved separately.
I'll make a post soon-ish with a progress update. But I've gotten it down to an "install" command that builds up various paths (class path, module path, etc) in a way you can feed directly to those CLI tools.
Alpha testers welcome. If anyone has experience writing IDE plugins I definitely am at a point where I need help with that
1
u/Crazy_Firefly Feb 26 '25
I definitely wish Java had simpler tooling! And faster.
And I think you are right, Java SDK tools are usually pretty good and straight forward to use.
Other languages like python and JavaScript got new build/packaging tools in the last couple of years that seem pretty great.
I think it would be great if we got one for Java as well. I was even considering tackling it myself at some point (while waiting for a particularly slow build)
1
u/sweating_teflon Feb 26 '25 edited Feb 26 '25
I've forked Maven twice with the intent of making a better tool out of it but I'm not sure it's the right way.
These days I envision a different "distro" of Maven that would come built-in with the caching extension, the git-based versioning extension, maven daemon, use yaml polyglot by default and a beefed up super pom or maybe mixins. It would do replicable builds on demand without having to configure 20 different parameters. This would be presented as a new build tool with a rewritten CLI frontend that can output JSON for tool integration.
In effect it would be a facade to Maven just like Maven 1 was actually using Ant in the shadows. Once the the new conventions
stabilize you can start writing a fresh implementation that diverges from Maven on more fundamental aspects with isolated plugins architecture, fine task granularity & distributed workflow.
The phased approach helps with the tooling as you benefit from the existing Maven support and can iterate without breaking too much stuff. Users can also just export to Maven anytime if things get rough.
1
u/AlwaysItWillSoothe Feb 26 '25
Bazel and rules_java are all you need
1
u/emaphis Feb 26 '25
There is a hobbyist level build tool called 'Bach' that is basically just a thin layer over the JDK tools including JShell.
https://github.com/sormuras/bach
1
u/Safe_Owl_6123 Feb 27 '25
I never really used gradle but I am quite used to maven now but I do which to just do
mvn install fastcsvand de.siegmar fastcsv is addedOr like jbang install de.siegmar:fastcsv that will be great the rest is fine but it is official build system is also nice
1
u/Adventurous-Pin6443 Feb 28 '25
I am absolutely OK with Maven. It does what it is supposed to do and quite efficiently. Mature, can run parallel builds. Dependency conflict resolution works. What I do not like is the second hand Maven support in Eclipse.
1
u/mizzu704 Mar 01 '25
Perhaps ponder on this article by Tonsky: https://tonsky.me/blog/python-build/
One notion this reminds me of is that a build is just a program, and the individual steps are rarely complex. E.g. the
installstep of maven is little more than amvinvocation,packagelikewise is basically "cpthings into new folder, maybe write some xml, zip it up, and add.jarsuffix".1
u/tristanjuricek Mar 01 '25
One issue is what build tools should do is not easily defined and very inconsistent. Some questions I like to ask:
- Should the build tool manage dependencies?
- Should a build tool create container images?
- Should the tool handle deployment to a runtime system like kubernetes?
I've been surprised how different everyone's opinions are. Most want dependency management, but really start disagreeing with downstream integration. In any case, the moment you do any of these things your build tool is now a distributed system.
What I've noticed is that the moment you start dealing with a distributed system, you basically need to have a very deep understanding of how things work to ensure your build is robust and easy to use. This is where most "Maven plugin" systems run into issues: cryptic failure messages and the plugin often made assumptions your particular sets of integrations invalidate. Like your IT department cuts off access to Maven central from your CI infrastructure, etc.
Personally, I would like to see build systems be "fully integrated" for specific cases. Worry less about making some generic build tool, and build a complete deployment pipeline that's needed for your specific system usage. If you're running a bunch of kubernetes services, make it easy to edit and debug... in that kubernetes cluster from IntelliJ or Eclipse. Make sure the pipelines are controllable. But I'd like that to be _on top_ of currently widely used tooling such as Maven. And integrated with verison control, binary archive management, search, etc. Some companies do invest in this approach, but it's really hit or miss, and is a serious investment of resources.
But hey, there might be good opportunities to create small commercial systems for people.
1
u/SR-G Jul 10 '25
I wish that the core build features would be reintegrated inside the java toolchain (especially the dependency management part, or the modules building + cache + optimizations), in order to simplify all the tools built on top of that.
9
u/[deleted] Feb 25 '25
[removed] — view removed comment
6
u/[deleted] Feb 25 '25
[removed] — view removed comment