News for hackers. Stuff that matters.
Re:An Opinionated Guide to Modern Java Development, Part 1 by tieTYT on Thursday May 01, 2014 @01:19PM (#7681181)
> But the modern Java developer uses Gradle

I'm a little skeptical of this. More like the developer in the future uses Gradle. Usually when I go to a project's home page, I see documentation on how to include the Maven dependency, not the Gradle dependency. It's pretty obvious how to convert one format to the other, but my point is I think most people are using Maven.

Re:An Opinionated Guide to Modern Java Development, Part 1 by pswenson on Thursday May 01, 2014 @04:43PM (#7682573)
I'd say Gradle is the least awful of the 3 major build systems. Ant degrades into an unmaintainable mess as soon as any complexity enters the system. XML is a horrible scripting language, simple imperative constructs are very awkward (loops/variables/conditionals).

Maven also suffers from XML hell, but at least it has dependency management.

I've used gradle extensively and it is quite difficult to figure out what is going on. Using a debugger would be nice, but it simply doesn't work. Gradle is terribly slow on a big project, the update checks are the main culprit. They should be done automatically in the background to alleviate this pain.

Since gradle is compiled rather than interpreted, calling code in the project being built is difficult and convoluted. For example, if I want to call a DBUtil.cleanDB() method in my java code I can't reference DBUtil in my gradle script as it hasn't been built yet and the Gradle script won't compile. If gradle was interpreted this problem wouldn't exist....

I find the DSL unintuitive and the inability to specify the order of tasks execution is always a sore point.

On the positive, at least it's a language, not XML. I have never understood the java world's obsession with XML and forcing it in directions never intended. This XML obsession has led to java being a major laggard in automation tech. Java devs do many things manually that a Ruby/Python dev would be horrified at....

Re:An Opinionated Guide to Modern Java Development, Part 1 by izacus on Thursday May 01, 2014 @06:22PM (#7683027)
After doing couple of Android projects with Gradle I've felt like Maven is a godsend.

It might require writing some XML to declare what your project does, but at least it WORKS and at least it does not waste my time by forcing me to write code to include pieces of projects and properly process project (e.g. including native code, Robolectric testing, renderscript and some other things).

Also any compilation inside IDE's was orders of magnitude faster with Mvn than with Gradle... all in all setting up all the components with gradle took about 2-3x as much time. Mostly it seems like someone decided that because now you have code instead of XML for build configuration, they'll just skip most of the plugin design and force you to roll half of the build process on your own.

Right now (at least for Android), Gradle is a colossal waste of time due to lacking features, extremely slow execution and myriad of bugs which will eat away productive time on project.

Re:An Opinionated Guide to Modern Java Development, Part 1 by vorg on Thursday May 01, 2014 @07:07PM (#7683206)
> Right now (at least for Android), Gradle is a colossal waste of time due to lacking features, extremely slow execution and myriad of bugs which will eat away productive time on project

Are the sparse features, slow executes, and bugginess due to Gradle or due to the scripting language it uses? www.gradle.org/overview says they will happily support any community effort to create additional build script engines for Gradle. The Gradle developers had better do it themselves because after the Groovy++ fiasco, noone's going to put work into building something related to the Groovy ecosystem when it's likely to be skuttled and/or stolen later on.

Re:An Opinionated Guide to Modern Java Development, Part 1 by pjmlp on Friday May 02, 2014 @03:20AM (#7684471)
From the usual JUG discussion themes I also get the impression, if it wasn't for Gradle, the Groovy interest would be much lower nowadays.

There was a Grails wave here in Germany, but now I seldom see anything related to it.

Re:An Opinionated Guide to Modern Java Development, Part 1 by vorg on Friday May 02, 2014 @11:13AM (#7686155)
Yesterday's Who is hiring? (https://news.ycombinator.com/item?id=7679431) only had 1 mention of Groovy or Grails (and none of Gradle) out of over 400 comments. And many (most?) of the projects tagged Groovy on Github are triggered by a single Gradle build script for a project that uses some other language. These Gradle build scripts are often 30 lines long.

So I'm not sure how Groovy will fare in the future. Nothing seems to be taking its place, though, for testing and general manipulation of Java classes. Java and Scala are statically-compiled languages for building things, whereas dynamic Clojure seems to also be used for systems programming rather than scripting. I'm guessing Oracle will heavily promote Nashorn for scripting and JavaFX, but Javascript syntax doesn't seem quite as full-featured as Groovy for now.

Re:An Opinionated Guide to Modern Java Development, Part 1 by pjmlp on Friday May 02, 2014 @03:33PM (#7687647)
I seldom used it.

Back in 2009 there was a big Grails wave here in Germany. Many JUGs had Groovy and Grails talks.

There was also some people trying to use Groovy with JSF. Myself I attended a session promoted by Sun hitting at possible official support after the JSF 2.0 release.

To the point we added support to it in our in-house JSF framework SDK, still JSF 1.x based.

Since late 2010 I have been doing .NET land mostly and now back on Java land, I hardly see any Groovy besides Gradle.

Re:An Opinionated Guide to Modern Java Development, Part 1 by izacus on Friday May 02, 2014 @07:49AM (#7685120)
I think it's just mostly the fact that tools aren't complete: e.g. IDEs will parse Maven pom.xml and use internal builders to speed up compilation while when using Gradle you're always spawning the external builder.

Same goes with other things: we had to write Groovy code to handle build cases which Maven plugins handle by default. That's mostly an ecosystem issue.

Re:An Opinionated Guide to Modern Java Development, Part 1 by pswenson on Thursday May 01, 2014 @06:27PM (#7683045)
for normal dependency management you shouldn't need to write code. I've never done any android dev, so I can't comment on that. declaring a dependency is literally like this:

dependencies { compile group: 'commons-collections', name: 'commons-collections', version: '3.2' testCompile group: 'junit', name: 'junit', version: '4.+' }

But I am not going to be the great gradle defender :) I have many complaints..... I would have much preferred that Rake became the default build system for java. Sadly that approach never took off....

Re:An Opinionated Guide to Modern Java Development, Part 1 by izacus on Friday May 02, 2014 @07:48AM (#7685119)
Yeah, for normal dependencies that's true. But on Android you quickly get some additional things that have to be handled by the build system:

* Code generation from annotations (reflection on Android is slow, so doing code generation is way better) * Attaching native .so libraries in proper directories of APK (Maven plugin does that automatically, Gradle needed writing code for that to work) * Properly handling RenderScript backwards compatibility library (there was no Gradle support for that at all)

* Testing - Robolectric is still not supported which throws a wrench into whole Jenkins/TeamCity autotest stack and needs fiddling with emulators

Re:An Opinionated Guide to Modern Java Development, Part 1 by tieTYT on Thursday May 01, 2014 @05:30PM (#7682807)
> Maven also suffers from XML hell, but at least it has dependency management.

I don't find it that bad. The nice thing about it is how my IDE will auto complete almost everything and it should be possible to validate it without even using an IDE, as it has a schema. I agree with your complaints about Ant.

The thing I was hoping gradle would give me is the ability to write tests for my build. EG: I want to have more confidence that my maven filtering is working the way I want it to. But it sounds like gradle isn't built with that in mind.

Considering that groovy is dynamically typed, if my IDE doesn't auto complete (maybe it does) I think it's possible to make the argument that Maven is the least awful of the 3. At least the maven XML has a schema. I don't need yet another way to make a mistake in my build script (ie: typing issues).

> Java devs do many things manually that a Ruby/Python dev would be horrified at....

Such as?

Re:An Opinionated Guide to Modern Java Development, Part 1 by pswenson on Thursday May 01, 2014 @06:21PM (#7683023)
w/ regards to gradle using groovy.... in gradle I can easily add in variables to my dependencies, I can write conditionals (if System Prop X then include dependency Y).

Basically anything you can do in code, you can do in gradle very easily.

Auto-complete does work in IntelliJ 13 - at least for groovy code type stuff. Nothing for the gradle DSL (that could be implemented of course).

> Java devs do many things manually that a Ruby/Python dev would be horrified at....

Jenkins config - almost every one does this by hand. Jenkins jobs weren't really even designed to be automated (ironic, eh), you have to build a full xml doc for each job rather than say apply a similar change across all jobs (add in a -D param across all jobs for example). I know this is a Jenkins specific issue, but this mentality is very common in java land.

Others: have every dev manually install a database for their environment (Chef/Puppet/Ansible solve this - and what are they written in? Ruby/Python)

No one would ever use java for any scripting type work, the JVM startup time is awful + the file/string libs are far less powerful/usable than ruby/python.

Of course a java dev can learn one of the scripting langs, but they typically don't.

this is just my experience, but note I've seen a lot of shops...

Re:An Opinionated Guide to Modern Java Development, Part 1 by tieTYT on Thursday May 01, 2014 @08:01PM (#7683400)
> I can write conditionals (if System Prop X then include dependency Y).

I stand corrected. That would be extremely useful. Maven is really awkard about these things. EG: "I want to run integration tests but not unit tests". Here's how: http://stackoverflow.com/questions/6612344/prevent-unit-test... Pretty lame.

Re:An Opinionated Guide to Modern Java Development, Part 1 by pjmlp on Friday May 02, 2014 @03:21AM (#7684473)
A better solution is to use profiles.
Re:An Opinionated Guide to Modern Java Development, Part 1 by eeperson on Thursday May 01, 2014 @07:49PM (#7683363)
Writing tests for your build script is an interesting idea. I wonder if this would be easy to do in something like SBT where the build definition is itself an SBT project.
Re:An Opinionated Guide to Modern Java Development, Part 1 by nvarsj on Friday May 02, 2014 @03:54AM (#7684555)
Actually, Maven uses XML right - as configuration, not code. This is where Ant was terrible - you ended up writing imperative code with XML statements.
Re:An Opinionated Guide to Modern Java Development, Part 1 by smrtinsert on Friday May 02, 2014 @11:40AM (#7686335)
Declarative builds = intelligent tooling. Would json make it better? I hate editing json too. Personally I would go with toml but wait... that would look similar to something else...

Ant's real problem is that it never found a path towards next generation. Why isn't ivy included by default? I want something bigger and easier to use that isnt gradle or maven but is more along the lines of an Ant+ivy default. It should have a bootstrap script, it should understand default project directories... It should continue to be declarative, but it should have an xsd or similar descriptive format that can be used for tooling.

There is a future in the ant+ivy perspective that I don't see in other build tools.

Re:An Opinionated Guide to Modern Java Development, Part 1 by ryanobjc on Thursday May 01, 2014 @06:29PM (#7683057)
Ah see I know you aren't an intellij user because your "XML hell" comment makes no sense.

IntelliJ makes this a breeze. I'm sorry you aren't using it, that must make life really hard :-(

Re:An Opinionated Guide to Modern Java Development, Part 1 by pswenson on Thursday May 01, 2014 @06:39PM (#7683099)
that's absurd. 1) I can't embed code in XML. 2) Why should I use a format that takes 5x as much space to declare something as a more usable format?
Re:An Opinionated Guide to Modern Java Development, Part 1 by ternaryoperator on Thursday May 01, 2014 @07:12PM (#7683230)
Agreed. On top of which XML has no capacity for logic, barring an incredibly contrived construct.
Re:An Opinionated Guide to Modern Java Development, Part 1 by altcognito on Thursday May 01, 2014 @08:03PM (#7683405)
What kinds of logic are you putting in your builds? That's a sign you are doing things wrong.
Re:An Opinionated Guide to Modern Java Development, Part 1 by pswenson on Thursday May 01, 2014 @08:39PM (#7683523)
hmm I wonder why this got created? http://ant-contrib.sourceforge.net/tasks/tasks/

I wonder if anyone said this about HTML when javascript was introduced?

once a system starts getting complicated you inevitably need code.

two points:

* gradle builds can be completely declarative. you write code only if you need it

* builds also are often used for very specific automation. in ant, you end up having to write custom ant tasks. this is fairly painful compared to just creating new classes, tasks, or scripts directly in gradle.

Re:An Opinionated Guide to Modern Java Development, Part 1 by ryanobjc on Friday May 02, 2014 @01:24AM (#7684253)
I often find that "can be declarative" means that over the long term in a big project means "isn't declarative"

After all you can do functional programming in any language. Why do you need another.

Re:An Opinionated Guide to Modern Java Development, Part 1 by pron on Thursday May 01, 2014 @01:55PM (#7681481)
Specifying the dependency in Maven XML has become sort of a standard that even Gradle people use. Obviously, Maven has been around much, much longer, and a lot more people are still using it, but more and more are switching to Gradle. At the very least Gradle has come to a point that you don't have to worry about it not being maintained, or that there won't be people to ask if you've got a question.
Re:An Opinionated Guide to Modern Java Development, Part 1 by smrtinsert on Thursday May 01, 2014 @02:12PM (#7681625)
There are no winners in the build war despite the overwhelming online support for Gradle. Personally I'm not a fan of it. I find it on the slow side even compared to maven. I'd rather have declarative builds like Ant but therefore support better tooling than super freeform tools like Gradle that force you to drop into a language with about as much type safety as Javascript. Multi-project builds are also annoying, as Gradle has to parse and validate all the connected projects before proceeding with one single task on the build you're invoking due to its design. Very annoying stuff.
Re:An Opinionated Guide to Modern Java Development, Part 1 by eeperson on Thursday May 01, 2014 @03:13PM (#7682064)
The performance problems are definitely the most annoying part of using Gradle. The Gradle daemon helped a little but tended to break other things and Gradle was still pretty slow.

If you are looking for something faster and more declarative, you may want to check out SBT[0]. It is way faster than any of the other JVM build tools. Also, in the future[1] it should have much better tooling support than anything else on the JVM.

[0] - http://www.scala-sbt.org/ [1] - https://github.com/sbt/sbt/wiki/Client-server-split

Re:An Opinionated Guide to Modern Java Development, Part 1 by lomnakkus on Thursday May 01, 2014 @04:16PM (#7682467)
Right now, SBT + IDEA is a bit of a pain because they share the same target folder and IDEA sometimes overwrites/deletes .class files that your application (started via sbt run) hasn't loaded yet. Usually that leads to a few ClassDefNotFound errors and such. Hopefully that'll go away once we have a single SBT instance.

My two wishes for SBT would be: 1) A monadic style for .scala build files. It would make dealing with the immutable bits of project definitions so much more pleasant and we could avoid the weird semi-Scala syntax of .sbt files. And 2) A bottom-up approach similar to Pants. My team frequently end up getting a lot more project interdependencies than we bargain for simply because it's too easy to induce transitive dependencies.

Re:An Opinionated Guide to Modern Java Development, Part 1 by eeperson on Thursday May 01, 2014 @06:11PM (#7682986)
Would you mind elaborating on what you mean by a monadic style for .scala build files?

PS - You may already know this, but you can change IntelliJ's compile output directory [0].

[0] - http://www.jetbrains.com/idea/webhelp/configuring-module-com...

Re:An Opinionated Guide to Modern Java Development, Part 1 by lomnakkus on Thursday May 01, 2014 @06:31PM (#7683063)
Thank you, I haven't actually tried that. I really live the "I just want my IDE to work" philosophy (out of laziness), so I try to avoid configuration if I can. :)

About monadic style: I realize that it's a hard sell, but it's basically about leveraging for comprehensions (aka. do-notation) to specify your build. Shake is an example of this, although probably not particularly suited to building Scala code.

Re:An Opinionated Guide to Modern Java Development, Part 1 by eeperson on Thursday May 01, 2014 @06:45PM (#7683116)
Shake?
Re:An Opinionated Guide to Modern Java Development, Part 1 by lomnakkus on Saturday May 03, 2014 @12:08PM (#7691256)
Sorry, should've linked[1]. There's also a further link from there to a paper for your reading pleasure :).

[1] http://hackage.haskell.org/package/shake

Re:An Opinionated Guide to Modern Java Development, Part 1 by eeperson on Sunday May 04, 2014 @12:47PM (#7694855)
Thanks!
Re:An Opinionated Guide to Modern Java Development, Part 1 by EdwardDiego on Thursday May 01, 2014 @03:39PM (#7682228)
SBT has a terrible habit of breaking backwards compatibility, which has put me off it.
Re:An Opinionated Guide to Modern Java Development, Part 1 by eeperson on Thursday May 01, 2014 @03:55PM (#7682331)
I've never had to change anything between upgrades (aside from changing deprecated stuff). Are you referring to the jump between from 0.7 to 0.10 a few years ago or have you had more recent issues?
Re:An Opinionated Guide to Modern Java Development, Part 1 by EdwardDiego on Thursday May 01, 2014 @06:28PM (#7683050)
Yeah, I just went and had a look at the project in question and I'm being unfair to SBT, it was a plugin I use to package WARs that changed underneath me. The plugin was quite closely coupled to the version of SBT, but the latest variant of it (once I found out about the migration to a different artefact) seems good.
Re:An Opinionated Guide to Modern Java Development, Part 1 by tieTYT on Thursday May 01, 2014 @02:20PM (#7681679)
> I'd rather have declarative builds like Ant

Is that a typo? I'd say Ant is the opposite of declarative.

Re:An Opinionated Guide to Modern Java Development, Part 1 by twic on Thursday May 01, 2014 @02:55PM (#7681947)
It's interesting. Ant is a somewhat constrained imperative language. Gradle is a highly constrained declarative language built on top of, and with an escape hatch to, a completely unconstrained imperative language.

If you stay within the bounds of that the Gradle DSL can do, rather than throwing Groovy around (which is possible - i write a lot of Gradle, and very rarely write raw Groovy), then Gradle is rather nice and easy to reason about. But if you don't, well, you're going to have a bad time.

Re:An Opinionated Guide to Modern Java Development, Part 1 by oldmanjay on Thursday May 01, 2014 @02:43PM (#7681858)
I've definitely found gradle to be faster than maven, particularly using the daemon, and even more so considering the extensive support for understanding when a task is up-to-date. I haven't run a clean task in gradle in several months, but in maven it seemed to be a crapshoot if the clean was required or not. That saves a lot of time.
Re:An Opinionated Guide to Modern Java Development, Part 1 by pjmlp on Thursday May 01, 2014 @01:54PM (#7681479)
Gradle is mainly being pushed by Grails and Android development.

I don't know of any other project using it. We are always doing Maven or Ant.

If Gradle is the future I hope it gets improved, I gave up on Android Studio given its dependency on Gradle and how it drags my dual core with 8 GB to its knees when compiling.

Re:An Opinionated Guide to Modern Java Development, Part 1 by vorg on Thursday May 01, 2014 @07:38PM (#7683327)
> I gave up on Android Studio given its dependency on Gradle and how it drags my dual core with 8 GB to its knees when compiling

That could be the slow, dynamically-typed Groovy in Gradle that's dragging your machine. Gradle needs to bundle another build language. Since the goal of statically-typed (and hence speedier) Kotlin is to make it easier to write IntelliJ IDEA [1], on which Android Studio is built, instead of using Java, the logical choice is Kotlin.

Gradle's developer says they'll happily support any community effort to create additional build script engines other than Groovy, but it isn't a priority for them right now [2]. Perhaps the Kotlin team need to kick off a Kotlin build engine for Gradle (though because one of the Kotlin developers was a victim of the Groovy++ fiasco, I'd understand if the Kotlin people are hesitant about having anything more to do with Groovy ecosystem software like Gradle).

[1] http://blog.lunatech.com/2011/08/24/scala-ceylon-kotlin-goal...

[2] http://www.gradle.org/overview

Re:An Opinionated Guide to Modern Java Development, Part 1 by pjmlp on Friday May 02, 2014 @03:28AM (#7684488)
Kotlin was exactly the reason I was thinking to move from Eclipse ADT to Android Studio.

So far I have been using the Eclipse ADT/CDT for my hobby development, mainly with C++ (just graphics stuff).

Then I thought to try out Kotlin instead, but could not. It was worse than waiting for my NDK C++ builds to finish, with the whole computer at 100% CPU usage.

I ended up filing a ticket, like many other developers already did.

Re:An Opinionated Guide to Modern Java Development, Part 1 by pron on Thursday May 01, 2014 @01:58PM (#7681508)
https://github.com/search?q=gradle&type=Code&ref=searchresul...

I also know that Netflix use Gradle for pretty much all their Java stuff.

Re:An Opinionated Guide to Modern Java Development, Part 1 by elchief on Thursday May 01, 2014 @03:11PM (#7682054)
Spring is pushing it hard in all their new tutorials, even non-Grails. Which annoys the heck outta this Maven guy.
Re:An Opinionated Guide to Modern Java Development, Part 1 by eeperson on Thursday May 01, 2014 @02:57PM (#7681955)
Is Grails really pushing Gradle adoption? My experience has always been that the integration between the two is pretty bad. Are things better now that they finally... released a real Gradle plugin to support Grails 2?
Re:An Opinionated Guide to Modern Java Development, Part 1 by pjmlp on Thursday May 01, 2014 @03:01PM (#7681982)
That was my perception. I don't have Grails experience.
Re:An Opinionated Guide to Modern Java Development, Part 1 by revscat on Thursday May 01, 2014 @02:12PM (#7681617)
Southwest Airlines uses it.
Re:An Opinionated Guide to Modern Java Development, Part 1 by vanilla on Thursday May 01, 2014 @05:49PM (#7682894)
libGDX (cross plattform game lib.) also made a push to gradle
Re:An Opinionated Guide to Modern Java Development, Part 1 by pjmlp on Thursday May 01, 2014 @07:06PM (#7683200)
Because of Android moving to gradle I would say.
Re:An Opinionated Guide to Modern Java Development, Part 1 by dminor on Thursday May 01, 2014 @10:15PM (#7683832)
They tried maven first, then gradle. Their build is pretty customized, so gradle makes a bit more sense.
Re:An Opinionated Guide to Modern Java Development, Part 1 by sadris on Thursday May 01, 2014 @02:37PM (#7681814)
And Minecraft Forge.
Re:An Opinionated Guide to Modern Java Development, Part 1 by heavenlyhash on Thursday May 01, 2014 @04:45PM (#7682588)
Personal anecdote, I stopped trying to develop for MC Forge in version 1.7 because the gradle build they switched to was unbelievably slow and difficult to use. After several days of poking it, I still couldn't understand why asking gradle for a simple list of available tasks was taking >10 seconds, and when I tried to give my workspace to a friend on another computer, I discovered I had totally I failed to get a list of coherent commands that I was 100% sure could reproduce my workspace on a new machine, because of large amounts of scattered hidden state I had failed to detect. Part of this might be poor build config design, but gradle certainly helped enable a lot of poor behavior and certainly doesn't impress me with its performance for trivial tasks.
Re:An Opinionated Guide to Modern Java Development, Part 1 by jayd16 on Thursday May 01, 2014 @02:36PM (#7681804)
You should be skeptical. Many Android projects don't use Gradle. Gradle itself might be stable but Gradle issues are at the top of every single Android Studio release notes.

When that stops happening I'll start thinking about Gradle.

Re:An Opinionated Guide to Modern Java Development, Part 1 by java-lang on Thursday May 01, 2014 @04:21PM (#7682489)
> I'm a little skeptical of this.

The title did warn that it is an opinionated guide.

I think most projects that used Maven before Gradle don't have enough incentive to migrate. A lot of the new projects, however, start out with gradle: Vert.x, Crate.io, RxJava.

Re:An Opinionated Guide to Modern Java Development, Part 1 by bananas on Thursday May 01, 2014 @01:55PM (#7681484)
This. I can't see myself using Gradle any time soon. Literally everything I've touched is maven only and I don't want to learn another DSL on top of yet another language.
Re:An Opinionated Guide to Modern Java Development, Part 1 by EdwardDiego on Thursday May 01, 2014 @03:38PM (#7682219)
Yep, Maven is the defacto AFAICT. But so is Java 6 currently.