I started a job in a company where they use Maven in combination with Git. I haven't worked with Maven before and I hope my question isn't too stupid. Why should one use Maven in combination with Git? From what I read Maven has a local, a central and can have a remote repository where it can find it's dependencies. This should enable a team of programmers to work together on the same code. What is the purpose of Git here? Would it be possible to program in a Team just with Maven and without the help of Git?
xml which is good for collaborative development as addition of dependencies doesn't require other developers to be informed as Maven automatically handles dependencies itself by downloading dependencies. Git is used for distributed version control which is very good to keep track code changes in your project.
The Local Repository When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named . m2.
Maven uses a declarative approach, where the project structure and contents are described, rather then the task-based approach used in Ant or in traditional make files, for example. This helps enforce company-wide development standards and reduces the time needed to write and maintain build scripts.
Well maven and git are for different purposes:
GIT
holds the sourcecode of your application
MAVEN
is used for dependency management. It holds the binary dependecies of your application. It also creates a abstraction of the used IDE. One developer can use eclipse and another intellij. The project can also be built with the commandline.
I guess it would be possible to work with just Maven. It might even not be totally horrible. However, Maven is system for distributing releases (even if they are snapshots or whatever). It is a totally different tool, than what a version control software is. I guess you could say Maven is the just the "distributed" part without the "version control" part of DVCS systems such as git.
A real version control can do a lot of stuff Maven does not support directly, such as merging, diffs, commit logs. I'm sure it would be possible to build an actual, fully featured version control system on top of Maven, with suitable plugins, but it would be very klunky and awkward to use. The likes of git
already do all this, and they have been designed to do it from the start, so they do it better than some hack on top of Maven could ever do, so I doubt nobody has actually tried.
I mean, you could do version control with just shared folder, naming conventions, manual log files, an IM group chat (irc channel) for synchronizing between developers, stock diff tools etc for comparing stuff, etc. It would just be horrible to use and very easy to "break" (in this case, easy to corrupt entire project and all its history). There has been a long evolution of version control systems, you can start reading about it for example here, and starting do it on top of Maven would be like jumping 30 years back in time.
When using Maven
, your project's dependencies are well defined in pom.xml
which is good for collaborative development as addition of dependencies doesn't require other developers to be informed as Maven
automatically handles dependencies itself by downloading dependencies.
Git is used for distributed version control which is very good to keep track code changes in your project.
Basically, these two tools make collaborative development easy. However, this is just a crash course description, there are many of advantages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With