News for hackers. Stuff that matters.
Re:What's in a Build Tool? by dlandis on Saturday March 05, 2016 @12:01AM (#11228487)
Ant and Maven are fairly obsolete at this point in the Java world having been superseded by Gradle, and so aren't really worthy of much discussion. But Gradle is quite good and I think it would stack up very well against the others including sbt. Like sbt, I think it fuses a task based and configuration based approach and also does dependency management.
Re:What's in a Build Tool? by pkd on Saturday March 05, 2016 @01:10AM (#11228621)
Definitely not Maven. Maven is ubiquitous in Java projects. Gradle has been pushed hard by Android, but I know that a lot of developers aren't convinced that putting code into configuration is a good idea. Maven even after all the XML crud remains insanely flexible and powerful.
Re:What's in a Build Tool? by TeMPOraL on Saturday March 05, 2016 @04:15AM (#11228953)
I have no opinion on Gradle at this point, though the developers you mention probably need a casual reminder that code == data, and complex enough XML spec is indistinguishable from a poorly formatted Abstract Syntax Tree (or Lisp code).
Re:What's in a Build Tool? by twic on Saturday March 05, 2016 @09:37AM (#11229602)
Maven is really not insanely flexible. I have a build in which i wanted three distinct test phases (unit, functional, and API contract). A simple requirement. But i couldn't have that without writing a plugin, or breaking out a dummy module for one of them. We ended up making the contract tests a special case of the unit tests, selected by passing in some flags; a consequence of that is that it's impossible to run both sets of tests in a single build.

tl;dr: Maven is the exact opposite of flexible.

Re:What's in a Build Tool? by tdurden on Saturday March 05, 2016 @03:00PM (#11230781)
creating profiles specific to each might help
Re:What's in a Build Tool? by twic on Saturday March 05, 2016 @05:33PM (#11231393)
I think i still couldn't run all three sets of tests in one build though, right?
Re:What's in a Build Tool? by tdurden on Sunday March 06, 2016 @03:43AM (#11232975)
You can activate multiple profiles per build if needed.
Re:What's in a Build Tool? by twic on Sunday March 06, 2016 @06:02PM (#11236028)
But i can't run a goal twice under different profiles, can i?
Re:What's in a Build Tool? by tdurden on Monday March 07, 2016 @07:42PM (#11242845)
No, but you can tie multiple plugin executions to a single phase.
Re:What's in a Build Tool? by smadge on Saturday March 05, 2016 @12:17AM (#11228533)
Yikes, I still use Maven. I don't like being left behind in the dust. Is there any compelling reason to prefer Gradle? What mistakes did Maven make that gradle avoided? One thing I am hesitant about is the I don't need my build tool to be a turing complete language.
Re:What's in a Build Tool? by a_imho on Saturday March 05, 2016 @06:31AM (#11229193)
Technology radar [1] said 'Adopt' in 2013: "Language-based build tools like Gradle and Rake continue to offer finer-grained abstractions and more flexibility long term than XML and plug-in based tools like Ant and Maven. This allows them to grow gracefully as projects become more complex."

My personal opinion after managing the build system of a fairly complex java project for years, I'm glad we skipped Maven in the evolution. For me the most important part was error messages, and the most helpful were Ant > Gradle > Maven. We had very different conventions than what Maven offered, and shaping it to our process was cumbersome. Coupled with Maven 2.x and 3.x never played nicely together (at least for me), now when I see a Maven build I just sigh (looking at you Atlassian)

Finally, strictly personal observation, but Ant/Maven tend to correlate with SVN (or older VCS) usage, which you can argue still does its job, but is pretty much considered obsolete.

[1] https://www.thoughtworks.com/radar/a-z#gradle

Re:What's in a Build Tool? by rlonstein on Saturday March 05, 2016 @09:39AM (#11229605)
Watch for complexity. Circa 2000 when Ant was popular I leveraged jython and inlined small python scripts into the rewrite of a grossly hairy onion of make, shell, and perl scripts that comprised a build system for a sprawling collection of JDK1.2/1.3 apps. In hindsight, this was probably a mistake because it solved the problems of "We can't manage this!" and "Anything outside the JVM is not portable!" it made very little inroad against complexity.
Re:What's in a Build Tool? by smadge on Saturday March 05, 2016 @08:19AM (#11229421)
Thanks, this is helpful! I didn't know about Technology Radar before now. Interestingly, they say "Subversion moves back into the Adopt section of the radar because it is a solid version control tool suitable for most teams."
Re:What's in a Build Tool? by twic on Saturday March 05, 2016 @09:57AM (#11229652)
For small projects, like a library or something, there isn't a huge difference. Your build is likely to follow the stereotypical compile - test - package cycle which both tools support out of the box.

There are a few advantages even for simple projects, though:

* I really like Gradle's wrapper feature, which means you can check in a small bootstrapper which downloads Gradle when you need it. That means you don't have to worry about installing the build tool, nor making sure you have the right version. It makes projects self-contained.

* Gradle caches downloaded dependencies in a directory which is distinct from your local repository. Maven just drops things into the local repository. To me, what Maven does is a fundamental confusion of purposes, and it makes it a headache to clean the cache, because you have no idea what is cached, and what is an irreplaceable locally-built artifact. Conversely, it makes it tough to look at your repository and work out what is an official artifact that came from the internet, and what is some crummy local thing you shouldn't rely on.

* Gradle knows about dependencies between tasks, and between tasks and files. When you run a build, Gradle can be fairly smart about what tasks it runs. If you're tweaking the packaging step, re-running the build won't run compile and test if the code hasn't changed. If you just want to run functional tests, tell Gradle, and it will re-compile if necessary, but won't unnecessarily run the unit tests. Doing this with Maven involves manually working out what phases are necessary for what you want to do, and then listing them all on the command line.

Gradle starts to pull ahead significantly for large projects, though. In those, you inevitably need to do more complicated things - code generation, running special tools, multiple kinds of tests, including extra bits and bobs in the packaging, etc. For those, Maven rapidly becomes painful, whereas Gradle's difficulty scales no more than linearly with the challenge.

On the flip side, there's no significant downside to Gradle itself. It's perhaps fractionally slower. It opens the door to writing loads of Groovy code and making your build a nightmare, but there's a simple way to avoid that - just don't do it. You never need to write full-blown code to do anything you could do in XML in Maven; you only need to write code where you would also need to do so in Maven, as a plugin.

And when that does happen, you'll find that writing plugins is also much, much nicer with Gradle than with Maven, and there are really lightweight ways to start - you can write new task definitions right in your build script (which is not nightmare-inducing, because they work inside the normal Gradle flow), then move them out to external modules as you wish.

I'd suggest giving Gradle a go on a small project, one where you don't anticipate a lot of build complexity, just to get a feel for it.

Re:What's in a Build Tool? by vorg on Sunday March 06, 2016 @07:17AM (#11233520)
> It opens the door to writing loads of Groovy code and making your build a nightmare, but there's a simple way to avoid that - just don't do it

The parent commenter said "I don't need my build tool to be a turing complete language". Perhaps s/he knows that when the language is there, people will use it, no matter how much someone in Change Control says "writing loads of Groovy code: just don't do it."

Re:What's in a Build Tool? by tdurden on Saturday March 05, 2016 @12:26AM (#11228546)
Ant maybe, but Maven is hardly obsolete. Most every Java project I run into uses Maven or Gradle, with Maven being more common.
Re:What's in a Build Tool? by kzhahou on Saturday March 05, 2016 @05:19AM (#11229063)
Gradle has superceded Maven in the same way that Node has replaced Java and C++ in production (hint: it hasn't).
Re:What's in a Build Tool? by aikah on Saturday March 05, 2016 @12:09AM (#11228512)
Isn't Gradle based on and using Maven (under the hood) ?
Re:What's in a Build Tool? by smadge on Saturday March 05, 2016 @01:37AM (#11228676)
Gradle allows you to 1) use maven plugins 2) download dependencies from maven repositories. So my understanding is that Gradle is backwards compatible but separate.