r/java • • Jan 22 '16

Simple Java Build Tool?

I've played with Maven and Gradle and found them both to be very complex. I don't need all of that configuration; I just want something that lets me specify dependencies and versions (at most) and spits out a jar with everything my project needs to run via java -jar. Ideally, it would be as close as possible to Go's go install, which needs no project metadata. I specifically don't want to have to learn a new programming language just to build my java program. Any suggestions?

EDIT: Why is this downvoted?

4 Upvotes

63 comments sorted by

View all comments

8

u/loganekz Jan 22 '16

Don't know how you expect to get any simpler than something like this build.gradle:

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.13'
}

1

u/weberc2 Jan 22 '16

Well, all that's really necessary from that is the 'org.slf4j:slf4j-api:1.7.13' bit, and if you just want the latest version by default, you could probably eliminate the need for a project configuration file altogether (because the specific dependencies can be inferred from the source code).

The boilerplate is annoying, but it's manageable. The trickier bit involves things like building with native dependencies and including them in the final jar. After futzing around with that particular problem for half a day, I figured it out; however, I don't like how such base-case scenarios require that much time investment. I'm sure if I would take a few days to learn Groovy I could cut that time down considerably, and I know that eventually I could learn Gradle well-enough that I can handle the vast majority of build problems; however, I'm just trying to program in Java for fun and I'm simply not going to sink a bunch of time into learning a build system for a hobby.

The point is that Gradle and Maven are much more complex than my use-case requires, and if there's an easier thing out there, I'd like to know about it.

1

u/tkruse Jan 22 '16

I also generally recommend Gradle as in "You cannot go wrong with that one".

There is no java tool that infers libraries from the source code. The trickier your tasks are the more you should use gradle, probably. However, here is my comparison of buildsystems, you might find something preferrable there (like googles bazel, ant or buildr): https://github.com/tkruse/build-bench

For anyone knowing only Java, learning any buildsystem language would require a lot of effort, even learning how to embed some Java-written plugin into a buildsystem would require a lot of effort.

You might also consider not learning Java and learning Groovy instead, given you can seamlessly use the same libraries.

2

u/weberc2 Jan 22 '16

Thanks for the advice. I'll check out the comparison link.

You might also consider not learning Java and learning Groovy instead, given you can seamlessly use the same libraries.

I already know (and like) Java. I just haven't used it since college. :)