News for hackers. Stuff that matters.
Re:Exodus: Easily migrate your JVM code from Maven to Bazel by bedobi on Wednesday April 07, 2021 @02:59AM (#26721300)
I know nothing about Bazel, but I've never understood the JVM community's obsession with getting off Maven.

My experience of Gradle is Gradle projects require a PhD in Gradle AND intimate familiarity with the tastes of whoever implemented that particular project .gradle files likes to use it. Is Bazel like that too?

When we inherit codebases from other teams, often one of the first things we do is convert it from Gradle to Maven.

I honestly couldn't care less about how flexible and powerful Gradle or Bazel or some other build tool is compared to Maven. Maven is simple, the same in every project (this is huuuuuge), just works and gets out the way.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by Traubenfuchs on Wednesday April 07, 2021 @03:55AM (#26721649)
Maven is one of the most stable and "good enough" tools there is -which is why a significant part of software engineers hate it.

If you enjoy using gradle for its customizability and flexibility and power -you are doing it wrong. You have created an overengineered monster I would dread to work with. I don't want to learn groovy, I want to develop applications.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by chii on Wednesday April 07, 2021 @06:28AM (#26722815)
> which is why a significant part of software engineers hate it.

i used to hate maven - i was a big fan of Ant. But as time went on, i saw how useful maven was. Being _exactly_ the same in every project, requiring the same project file structure, requiring the same build steps, and the same build commands, etc.

People who own projects seem to believe their project's build is special and require custom stuff to make it work. It rarely is actually the case. Just shoehorn your project into maven.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by Freak_NL on Wednesday April 07, 2021 @03:07AM (#26721338)
> […] the same in every project (this is huuuuuge) […]

Hard to overstate how useful that is. Configuring something in a Maven build may be verbose or sometimes hard, but most of the time the build just does its thing, and all developers know at least `mvn clean install`.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by brown9-2 on Wednesday April 07, 2021 @07:15AM (#26723199)
One of the main goals of the project was “convention over configuration” and it succeeded well at that.
Re:Exodus: Easily migrate your JVM code from Maven to Bazel by krzyk on Wednesday April 07, 2021 @04:52AM (#26722022)
> My experience of Gradle is Gradle projects require a PhD in Gradle AND intimate familiarity with the tastes of whoever implemented that particular project .gradle files likes to use it. Is Bazel like that too?

This, I was quite happy to try out gradle when it appeared and when I read few tutorials it came to be: This is just Ant all over again, but this time instead of xml I get groovy.

Maven does one thing great: It forces you to use their build steps and every project has exactly the same steps.

Gradle is like Ant or CMake.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by utf_8x on Wednesday April 07, 2021 @03:27AM (#26721454)
Exactly. You could have a million line pom.xml and you'd still most likely just need `mvn clean package` to get a usable JAR. XML is a nasty format but it just works...
Re:Exodus: Easily migrate your JVM code from Maven to Bazel by nimrody on Wednesday April 07, 2021 @04:34AM (#26721904)
Maven just hides the complexity in its plugins which are implemented in Java.

If you don't need any plugin - then, yes, it's simple.

But once you need specialized plugins it's no better than gradle/bazel. The latter two lets you add some logic in the build scripts - so at least it's visible to users. If you need special functionality in Maven you have to write a plugin or gather a few plugins. And when it breaks down (as all tools do) -- it's difficult to find the code and understand the problems.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by krzyk on Wednesday April 07, 2021 @04:38AM (#26721938)
Writing Maven plugins is quite easy and doesn't require you to learn another language (like in case of gradle, you have to know groovy).
Re:Exodus: Easily migrate your JVM code from Maven to Bazel by tn1 on Wednesday April 07, 2021 @04:55AM (#26722038)
At least with Groovy, most Java programs are also valid groovy programs (the converse is not true, but not too different).
Re:Exodus: Easily migrate your JVM code from Maven to Bazel by krzyk on Wednesday April 07, 2021 @01:55PM (#26728395)
Yes, but with groovy you get magnitude slower compilation time, less efficient autocomplete.

And a language that has sometimes strange design choices.

Groovy is like PHP, if I need to upgrade from Java it would be Scala. At least I get a superior language for also magnitude slower builds.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by tn1 on Wednesday April 07, 2021 @07:50PM (#26733156)
Gradle has a Kotlin Script build script option these days too. I haven't tried it yet, so I'm not sure if it's any better.
Re:Exodus: Easily migrate your JVM code from Maven to Bazel by skinkestek on Wednesday April 07, 2021 @04:14AM (#26721766)
> Maven is simple, the same in every project (this is huuuuuge), just works and gets out the way.

Recently tried to find the correct and canonical way to set up a new, small spring boot project for a customer. No one could tell me how: "we just use spring initializr and copy the relevant files" From where? Uh, oh. So I tried to find a canonical solution. Did some research. At least 14 variants..! No clear winner.

Nobody really understands it it sees but at least they don't have to use the dreaded Maven.

(For those who don't know, Mavens main disadvantage is that it is written in xml. Since Maven files frequently gets over 30 lines long - especially if people don't know what they are doing - and (parent projects) needs to be updated twice a month on average because of updates to dependencies this is a living nightmare to some people ;-)

Might contain traces of both sarcasm, irony, exaggerations and other literary tools. Those who get it, feel free to laugh. Those who don't: After ~15 years in the field I've not seen anything working as well as Maven on the kind of projects and teams I work on and I also don't think I've seen any other project getting as much undeserved flak.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by twic on Wednesday April 07, 2021 @06:42AM (#26722941)
> Mavens main disadvantage is that it is written in xml

I would say that this is Maven's most obvious disadvantage. Its main disadvantage is its inflexibility.

I'm working on a little library right now that is sort of a facade for two possible backend libraries. Some code is shared, some depends on backend A, some on backend B. I want to separate the three kinds of source code, compile and test each against the correct dependencies (none, A, or B), and then put all the class files in one jar file.

In Gradle i would define some extra configurations for the A and B sides, then customise the standard jar task to include their output.

What would i do in Maven?

My Maven knowledge is pretty out of date, but i think the Maven answer would be "don't do that, create three modules and build and publish three artifacts". Or, to put it another way "our tool can't do that, so you should make life worse for your users, but we're going to insist that our way is actually the proper way to do it, for mysterious quasi-mystical reasons".

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by vips7L on Wednesday April 07, 2021 @07:34AM (#26723341)
> What would i do in Maven?

Typically customization of maven goals is done via profiles. You can modify the configuration of the plugins depending on which profile is active. Though I'm obviously not sure if it will solve your problem without knowing exact details.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by MaxBarraclough on Wednesday April 07, 2021 @06:15AM (#26722717)
> My experience of Gradle is Gradle projects require a PhD in Gradle AND intimate familiarity with the tastes of whoever implemented that particular project .gradle files likes to use it.

In the C++ world we have exactly the same problem with CMake.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by rualca on Wednesday April 07, 2021 @01:31PM (#26728048)
> In the C++ world we have exactly the same problem with CMake.

"Modern cmake" (i.e., target-based projects made possible since the release of cmake v3.0) is terribly easy and straight-forward, provided that your devteam understands the need to stay in their lane.

project(), add_executable()/add_library(), target_include_directories(), set_target_properties(), and add_directory(). This gets any MVP working, and any project 95% where they need to be.

Add in set() to define helper cars like proj_SOURCES, proj_HEADERS, and proj_INTERFACES, and option() to get fancy cacheable settings.

Cmake only becomes a problem if devteams have no idea on how to write simple code, and can't help themselves turning any hello world into a big bowl of spaghetti code. You don't need functions or macros or anything at all, unless you want to waste time feeling smart for writing towers of hanoi in cmake, or shoving square pegs into round holes.

In spite of having about a decade of experience with cmake projects under my belt, the only place I ever defined functions in cmake was to add boilerplate code to add unit tests to crest by just passing the source file name, and even that was not worth the trouble.

You can write stuff as convoluted and unmaintainable as you'd like, but that's on you, not the tool.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by MaxBarraclough on Wednesday April 07, 2021 @01:57PM (#26728444)
> You can write stuff as convoluted and unmaintainable as you'd like, but that's on you, not the tool.

In this case, it's also on the tool. CMake is a bad tool. Unfortunately it's the least bad one available for that task. I've rambled on this topic before. [0][1]

My most recent adventure with CMake was with its SWIG support. This was as painful and error-prone as everything else in CMake, and I've used CMake for years.

[0] https://news.ycombinator.com/item?id=24203172

[1] https://news.ycombinator.com/item?id=24565266

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by rualca on Wednesday April 07, 2021 @07:20PM (#26732904)
> In this case, it's also on the tool. CMake is a bad tool. Unfortunately it's the least bad one available for that task. I've rambled on this topic before. [0][1]

I completely disagree. Cmake is an exemplary tool which achieved the status of de-facto standard due to its design and simplicity.

Queue in the popular saying about how bad workers always blame their tools. If a worker does awful things, that's a reflection of how bad the worker is, not the tools.

Case in point: complaining about cmake because of its rudimentary BASIC-like scripting language is a huge red flag. If your idea of using cmake is to write scripts, you're either aiming to do something extremely exotic and exceptional, like adding macros that magically support frameworks like Qt or conan, or I dare say you do not know what you are doing. At all. I repeat: you only need to call about half a dozen cmake functions to declare build targets and define it's properties, and you've already met over 95% of any project needs. If instead you're in the business of mangling makefiles with BASIC you should really take a step back and reconsider what you're trying to do because odds are you're doing it very wrong.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by MaxBarraclough on Thursday April 08, 2021 @06:55AM (#26737267)
> achieved the status of de-facto standard due to its design and simplicity

CMake is miserable to work with, but has excellent cross-platform support, able to target many build systems and IDEs. It also has a wealth of package-detection libraries. It was first-to-market with this combination of virtues, and it's difficult for competing systems to beat CMake on those terms. These are much of the reason I continue to use CMake, the other main reason being that fragmentation is harmful in itself.

> Queue in the popular saying about how bad workers always blame their tools. If a worker does awful things, that's a reflection of how bad the worker is, not the tools.

You seem to be suggesting there can be no such thing as a poor tool.

When someone expresses dissatisfaction with a tool, and lays out numerous specific complaints born of their experience, that does not entitle you to imply they must just be incompetent, which is what you've done. You might refrain from borderline personal insults in future.

You've not substantiated the If a worker does awful things premise. I've written several well-functioning CMake scripts, always following the current best practices. My point isn't that it's impossible to do this, but that it's painful to achieve.

> complaining about cmake because of its rudimentary BASIC-like scripting language is a huge red flag

Writing scripts is the only way you can use CMake.

> If your idea of using cmake is to write scripts, you're either aiming to do something extremely exotic and exceptional, like adding macros that magically support frameworks like Qt or conan, or I dare say you do not know what you are doing.

Again, CMake is always script-driven.

Anyway, this response is misguided. The CMake scripting language is not intended only for small and simple scripts. I already addressed this point last time. [0] CMake package-detection scripts are enormous, and fail to follow any kind of standard pattern. Just look at this official first-party CMake script and tell me this is how it ought to look. [1] It's a trainwreck.

> you only need to call about half a dozen cmake functions to declare build targets and define it's properties, and you've already met over 95% of any project needs.

If you make the tiniest error anywhere along the line, you will get mysterious failures rather than helpful error messages. You might even get failures which only affect certain platforms. I've encountered this several times, as CMake fails to properly abstract away all the differences between the Windows and Unix build+link models, especially regarding shared libraries. Once you've got your script working, it will look as if CMake properly abstracts away these differences, but the existence of such failure modes belies the illusion.

A good metabuild system would aspire to make invalid states unrepresentable, or would at least help defend against common mistakes. CMake doesn't even try. It's fragile footguns all the way down.

A recent example of a failure mode that simply wouldn't happen in a better system (I mentioned another previously at [2]): I'm seeing CTest passing the string WORKING_DIRECTORY to my test script, as a command-line argument. Presumably it's incorrectly handling the WORKING_DIRECTORY marker in the argument list of add_test. Am I doing something wrong? Perhaps, but not that I can tell. Presumably this failure mode is only possible because of CMake's awful approach to parameter-handling, and would not have occurred in a well-designed system.

> If instead you're in the business of mangling makefiles with BASIC you should really take a step back and reconsider what you're trying to do because odds are you're doing it very wrong.

You're blindly assuming I'm misusing CMake. When I write CMake scripts, I always try to follow the current best-practices. Again, I do not appreciate you assuming that I have no idea what I'm doing simply because I disagree with you.

[0] https://news.ycombinator.com/item?id=24567450

[1] https://github.com/Kitware/CMake/blob/master/Modules/FindIma...

[2] https://news.ycombinator.com/item?id=24203172

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by AtlasBarfed on Wednesday April 07, 2021 @03:33PM (#26729920)
Maven issues:

XML. Ugh, the XML.

The backing company was a bit too eager to sell artifact repository software.

The lingo was pointlessly obscure (coordinates? artifacts? "project object model"?)

It didn't offer a couple key options (local jars without an artifact repository) so it was too inflexible.

Gradle did fly off the handle too quickly, breaks wayyy too much stuff with each release, has way too many releases and examples that don't work anymore... but on the other hand you can usually cobble together what you want from a couple sample builds and some stackoverflow.

What the JVM community probably needed was a YAML-based Maven with a bit more flexibility than maven provided.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by MrBuddyCasino on Wednesday April 07, 2021 @06:41AM (#26722939)
Also, IDE integration works a lot better. IntelliJ with Maven is a joy, with Gradle its a dog-slow shit-show.
Re:Exodus: Easily migrate your JVM code from Maven to Bazel by vbezhenar on Wednesday April 07, 2021 @06:59AM (#26723090)
Gradle have sane multi project management. Maven is very strange in that regard. Another issue with Maven is kind of hacky configuration for Kotlin build. For single project Java build Maven is my favourite tool.
Re:Exodus: Easily migrate your JVM code from Maven to Bazel by pas on Wednesday April 07, 2021 @04:02AM (#26721692)
Bazel's selling point is that it's designed to be integrated into various pipelines, handling complexity (multiple languages, platforms, targets, etc) AND being fast (cache what you can, so incremental builds are first class things).

Of course under the hood it's just a very complicated 'make', like every build tool is.

This likely just means unnecessary complexity for a simple Java project where the development just happens in IDEA (or Eclipse or even NetBeans) and the IDE builds and checks everything, and ... at release time someone just builds a package and it's done.

But in case of a project with a lot of services, dependencies, there's arguably some advantage to setting up Bazel to help with development. (Though the build/bzl files all look ugly and unintuitive, a bit like CMake :[ )

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by skinkestek on Wednesday April 07, 2021 @04:17AM (#26721783)
Does it encourage every team and every dev to create their own custom config that takes two hours to figure out like Gradle, or is it more like Maven where you only specify anything that isn't bog standard?
Re:Exodus: Easily migrate your JVM code from Maven to Bazel by foota on Wednesday April 07, 2021 @04:31AM (#26721890)
It's very standardized. I don't have any experience with using it with things outside a Java binary, but for that use case you basically have no choice but a number of java_library rules and a java_binary.

E.g., a simple project with no outside deps might be like (and I typed this out on my phone):

java_binary(name = "grep_bin", srcs = ["grep_main.java"], deps=["grep_lib"])

java_library(name="grep_lib", srcs =["grep_lib.java"])

Things get more opinionated when you pull in outside libraries, but even then bazel makes it fairly painless and integrates with other build systems where needed.

Take a look at the docs here for more info: https://docs.bazel.build/versions/master/be/java.html

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by izacus on Wednesday April 07, 2021 @05:30AM (#26722316)
No, it's actually the opposite - it has very rigid build rules with rigid inputs and outputs so the toolchain can reason about dependencies and it doesn't really allow adding arbitrary execution in the BUILD files to prevent code messing up caching and remote builds.

It was build to solve a problem of building software at scale across multiple languages, platforms in a single monorepo. And it's great at that. It becomes limiting as your use-case steps away from this "monorepo, across languages" approach.

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by pas on Wednesday April 07, 2021 @05:11AM (#26722152)
It has support for many languages (called rules [0]) and it has support for many tools for that specific language ecosystem.

For example the Scala rules have specs2 (a unit testing lib/harness/framework/thing) [1]

I have no idea how this all works in practice.

[0] https://github.com/bazelbuild/bazel/blob/master/site/docs/ru...

[1] https://github.com/bazelbuild/rules_scala/blob/master/exampl...

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by AzzieElbab on Wednesday April 07, 2021 @07:48AM (#26723454)
“ but I've never understood the JVM community's obsession with getting off Maven”

XML - if for whatever reason you decide to make a good product unpopular, just add XML

Re:Exodus: Easily migrate your JVM code from Maven to Bazel by psychiatrist24 on Wednesday April 07, 2021 @05:36AM (#26722383)
Yeah, my first thought "another build manager to worry about" - it's already annoying that some projects use Gradle, which I don't want to have to learn.