Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Meta question: why is Java build process so complicated? It really shouldn’t be, linking (the hardest part) is done by JVM at runtime, all you need is compile .java files to .class files (which you can do 1-by-1) and put them in a single .jar archive.


In simple projects it's fundamentally what you describe. But there are some fancy libraries which e.g. require bytecode weaving (some AOP libraries, JPA implementations) or generate code from annotations.

The other thing is that maven and gradle aren't just pure build tools, but they serve other roles too - chiefly dependency management, they are test runners, generate reports from those tests, can upload the generated JARs into artifact repositories, run the built application etc.


There are some other things. What you have described would work if jar has no dependencies (or is used as a library). When you build a deployable application you need stuff like:

- building fat jar (jar with all dependencies, including transitive ones) or even whole docker image or just deploying the jar you created to the maven repository

- unit tests

- integration tests, with things like starting database

- code coverage

- dependency checks (version clashes of transitive dependencies, security issues)

- code quality checks

Additionally it is nice if you can do following through maven CLI:

- update major/minor/patch version

- deploy application to chosen environment

- create javadocs for the project

Above things are done through plugins, which release versions independently. Additionally plugins might have dependencies - for example maven-checkstyle-plugin depend on checkstyle checkstyle library - you might want to override checkstyle library version that is used by the plugin. Some plugins' default configuration might also not work nicely with each other - you need to update those.

On top of that maven is using XML and on top of that maven creators chosen to make it even more verbose by ditching XML attributes. That way you end with really big pom.xml files (~3 times bigger than gradle file in this project).


Can we say that JS ecosystem did it right by splitting package management, bundling and testing into separate tools?


Bundling and testing in maven is already done by separate tools. It is just that maven have some defaults (dependent on the packaging selected) which tools may cover such tasks.

I think NPM made one step too far - it removed whole build structure from the build tool. NPM is just package manager and simple run utility (both based on horrible package.json configuration, even maven's verbose XML pom.xml are better). There is no compilation step, verification step etc. - there are just cli commands you can preconfigure in package.json.


Not if you go by the number of blog posts complaining about NPM and bundling in javascript


you can do that with a script or a makefile...really maven, ant, or gradle shine when you have to test, build for development/production, deploy, source control, dependency control, and what have yous.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: