Im reading about Maven and Gradle and cant place where and what they are/do.
I know they are for build automation for Java but what does that mean?
Dont Java projects just get compiled? can somebody please explain these two and which is better or mostly used.
Im guessing like everything they have their strengths and weaknesses and are applied depending on what you doing.
Is it strictly for building mobile projects?
I'm with you, I haven't been involved in anything big and complex to use them. When I was using Netbeans it automatically did the build and compile etc, including creating a WAR file from a click. However I understand Netbeans generates a large ANT xml file (similar to Maven and Gradle I believe) to do this. So for Netbean projects, these processes are in the background and you don't necessarily see them.
In larger projects, when deploying a new app, or updating one, there things that need to get done such as folders created and copied, resources copied into folders etc, there are dependencies that need to be managed with databases etc. This is all done using build tools.
This is not a complete answer, but others might be able to add.
Builds are not just about compiling and packaging a program's source into binary executables, although those are the most basic tasks preformed as part of a build. It can also mean running tests, making sure dependencies are available (jar files of libraries and other projects your project uses), generating documentation, copying build artifacts to repositories, deploying build artifacts, and many other tasks. This entire process can get complex and complicated and you don't want to be typing commands to perform each task every time you do a build. With build automation, all you'd do is run one relatively simple command and the build tool will do the rest for you.
Dependency management is the second biggest problem with builds. Some projects will depend on many other different projects/libraries like Spring, JUnit, Hibernate or some other ORM framework, etc. These might have their own dependencies, and those dependencies their own. Given that, the number of direct and indirect dependencies your code may have on other JAR files can get quite large and the task of determining what those are and what the actual command is to build and run your project is can be very volatile. Manually tracking all that can become very cumbersome and error-prone so having a tool that does it all for you relieves you of most of the nitty-gritty work that needs to be done. All you have to do is specify what the direct dependencies are and the tool will do the rest of the work for you.
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
For any reasonably complex application, you don't "just compile" the Java files. You have to organize the classes produced by the compiling process, you'll generally package the results into a deployable component such as a JAR, WAR, or EAR file. And you'll probably be depending on some third-party libraries which would need to be fetched from some global repository and included into the build. For example, the log4j logging library.
Maven is a magic wizard that, given a properly-organized project, can handle all those tasks and more. I use the term "magic" deliberately, since unlike the Ant build tool, you don't have explicit build rules in a Maven project, but rather built-in goal processors that use plug-in components called "mojos" to do their work. Much of the magic is accomplished automatically just buy putting the right files in the right directories.
Every Maven project has a pom.xml file that describes the parts of the project that Maven cannot deduce automatically. The POM specifies the name and version of the component to be produced, what special plugins it might need to do so, and the component dependencies that must be fetched from external sources.
This dependency fetching is one of Maven's most powerful features. I can take almost any Maven project, run a "mvn clean" command to delete its working files, zip up the cleaned project, email it to the other side of the Earth, and be assured that anyone anywhere can re-build everything armed with only an unzip program, a Java compiler and Maven.
Maven also supports secondary goals such as automatically running unit tests and building documentation (like JavaDocs). I even use it to build OS installer packages for my projects so that a system administrator can deploy and maintain my Java apps just like any other system application.
Gradle is what you get when you start looking beyond Java. Maven is designed specifically for Java-based projects. Gradle understands that there are other languages used in modern IT shops as well.
"privilege" comes from the Latin words for "private" and "law" (legal) and dates to feudal times. To "claim privilege" meant that you were above the laws that applied to the common people.