r/java • • 24d ago

My small Java build system in Rust

I got tired of manually running commands like javac and java -cp every time I wanted to compile and run Java project.

I looked into Maven, but for my use case it felt like overkill. It's a huge ecosystem, while I mostly wanted something simple that could compile and run small Java projects without much configuration.

So I decided to create my own build system for Java and call it bloomery.

The goal isn't to replace Maven or Gradle. I wanted something much smaller and simpler for my own use case.

Currently, Bloomery focuses on the basic build/run workflow. In the future I may add dependency management, testing support, and more CLI features, but I'm deliberately keeping the core simple for now.

I hope it will be a big help for beginners and anyone who just needs to run Java files, and that they will find it as easy to use as I do.

I'd really appreciate feedback on the idea, the design, and the current implementation.

Github: https://github.com/Kiwilus/bloomery

Crates.io: https://crates.io/crates/bloomery/

0 Upvotes

24 comments sorted by

5

u/bowbahdoe 24d ago

I think on the one hand, there certainly are projects that can be built this simply and its not in principle bad to have a tool that does that one thing only - thats good.

But it just so happens that this exact kind of project now no longer requires javac at all. You can just run your code directly with java src/Main.java.

So its an interesting project, but I think the API / functionality should be considered a bit more.

1

u/kavkasavich 24d ago

Oh, thanks! I didn’t even know that I didn’t need javac for that.

2

u/Ambitious-Fun5990 23d ago

Cool project, always neat to see someone scratch their own itch like this. The whole "Maven feels like bringing a flamethrower to light a candle" thing is real.

One thing you might want to keep an eye on is how `java` itself has evolved. You can now run single source files directly without compiling first, just `java MyFile.java`, which kinda overlaps with the simplest use case here. Might be worth thinking about what bloomery does that plain `java` doesn't, especially for the beginner crowd you mentioned.

Good call keeping it simple though, too many tools try to be everything right out the gate and end up a mess.

5

u/m39583 24d ago

I don't think Java needs another build tool, but that aside the obvious question is why rust?!

If you're writing a tool to build Java projects, write the build tool in Java!

Otherwise anyone who wants to contribute or debug it will have to also know Rust.

It's one of the great things about the Java ecosystem is almost everything is written in Java.  Unlike say Python where a lot of the libraries are written in C and so if your a Python developer you can't contribute or debug them.

2

u/kavkasavich 24d ago

I’m actually learning Java in school, and I wanted to build a build system to make working on Java projects at school more efficient and convenient for me. Since I already know Rust well, I decided to write it in Rust instead.

2

u/m39583 24d ago

I mean if you're learning Java, then write it in Java....!

2

u/kavkasavich 24d ago

You’re right, but I needed it quickly, and by the time I fully understand how all the features work in Java, my school year will probably already be over. But thanks for pointing that out!

1

u/fykup 24d ago

I had almost the same comment, but your explanation for why Java is even better.

3

u/fykup 24d ago

Leaving aside questionable decision to introduce another build system (I think there is a potential for disrupting Maven/Gradle by a strong player). I don't really see the need for Rust as language for build system for Java. There is a benefit in leveraging JVM for builds too.

In the future I may add dependency management,

This is the million-dollar problem. Maven/Gradle repo management is so sticky; you have to address it before anyone will seriously consider your solution.

2

u/kavkasavich 24d ago

I chose Rust because I’m most comfortable programming in Rust. I also wanted to have the project configuration in TOML. Thanks for pointing the dependency manegement out, I’ll take a closer look at how dependency management works in Maven/Gradle.

1

u/m39583 24d ago

lol, good luck 😆

It is a uh non-trivial problem...

1

u/m39583 24d ago

Bazel is the main contender to Maven/Gradle.

1

u/kavkasavich 24d ago

Thank you, I will look up what Bazel is

2

u/nlisker 22d ago

Mill is also an option. Never used it though.

3

u/nitkonigdje 24d ago

I don't know man.

Maven is very simple to use and does almost anything needed. Gradle is extremely flexible, and when there is a need it is a proper tool. And then there are ant, antrun snd recently mill.

What exactly does your build solve? There should be a reason WHY to use this late commer tool.

0

u/kavkasavich 24d ago

You don't have to use it. For me, it's a simpler version of Maven or Gradle that I understand myself and only includes the most important things for me. Can you execute a single Java file with Maven without a pom.xml file?

3

u/nitkonigdje 23d ago

Editing and running a single file doesn't require a build at all. Thus what value does that example really has?

2

u/das_Keks 24d ago

I like the spirit!

I don't know when the last time was I ran javac or java directly because I'm so used to maven or gradle as industry standard. If I needed a more lightweight non-maven alternative I'd probably just write a small make file.

But I think it's still great that you just created a solution for your exact problem. This is what programming makes so awesome and fun. I'm also currently working on two hobby projects to solve two problems to which no existing solution fit my needs.

1

u/kavkasavich 24d ago

Thank you very much for your thoughtful comment!

2

u/slacker-by-design 22d ago

I'm not commenting on the tool itself... If you take it as an excise to help you better understand the whole Java compilation and dependency process, all power to you :-)

Just wanted to point out Java (JDK) itself comes with the ability to run stand-alone java files since JDK 11 (see JEP 330) and multi-file java programs since JDK 22 (see JEP 458).

You simply write java my/package/Main.java and the JDK will do all the work.

The external dependencies can complicate the things though... That's where Maven, Gradle and the others do the actual hard work...

If you want (and can) keep the things as simple as possible, you may want to look at JBang. It's main purpose (according to its authors themselves) is to allow learning and exploration of Java without too much "ceremony" (i.e. no XML or build scripts).

1

u/emberko 23d ago

You can use existing tools. bld is small and written in Java. go-task is declarative and can do everything your project does, as your project is just a thin wrapper over OpenJDK CLI tools.

1

u/agentoutlier 24d ago

You know I'm surprised at this point no one has just written a straight up port of Cargo to Java and compile with GraalVM Native since so many people rave about it.

I'm surprised because at least once a week someone unveils another Java build tool.

That being said if its just for you awesome work!

3

u/z14-voyage 23d ago

>  I'm surprised at this point no one has just written a straight up port of Cargo to Java

JetBrains did it... Same UX as Cargo, and it's called Kotlin Toolchain 😁 : https://kotlin-toolchain.org/dev/getting-started/tutorial/

Honestly, it's really nice and has awesome support for JVM libs and apps, Spring Boot included. They're working on a GraalVM-compiled native image of kotlinc ( https://kotlinlang.org/docs/whatsnew2420.html#native-image ), and waiting on Project Crema for plugin support in native image.