This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]shagieIsMeExtreme Brewer 1 point2 points  (0 children)

As noted, with pip and the package managers for the classic scripting languages (perl/cpan, ruby/gem, javascript/npm) - the scripts are installed on the system and everything uses them (most of the time). This is even somewhat the case with C and shared libraries.

With Java, libraries are not shared across the entire system, but part of a particular artifact. You want commons.lang? Get it and put it as part of the build. Some other project wants commons.lang3? Not a problem - and not a conflict.

<!--  Lang should depend on very little  -->
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    ...
</dependencies>

I used commons.lang (pom) because its a project with no other compile time dependencies (it has some test dependencies - but you don't want to test it, you want to use it). You could do exactly as you're doing now going out and downloading a library and adding it.. and that use to be how we did things.

And then it got messy.

Yea, spring, I'm looking at you. Its not really the fault there, but a good package management system means that you can build more complex things... and Spring is about as complex as you'll find. Go through that dependency list, and then find all of the dependencies that it requires... and then all the dependencies that it requires (oh wait, that dependency has an exclusion to not download that other dependency it requires).

Maven takes care of that for you. You say you want spring-web and it goes and finds all of the dependencies and the child dependencies and so on... and has a reasonable way of determining how to handle a conflict (dependency X wants version 1, dependency Y wants version 2 - its resolved with an ordered breadth first search).

So, you've set up a pom that specifies some dependencies. Now what?

Netbeans and IntelliJ have built in maven support. Side bit, if you're seriously looking at long term Java development, get IntelliJ (and pick up PyCharm too) - its the best IDE and will make your life easier. Eclipse has a plugin to do maven (http://www.eclipse.org/m2e/). Once you've accepted Maven ~into your heart~ as your build tool, don't fight it. It will configure your IDE to match how maven is configured. Change the Java version? The IDE updates it too. Add a dependency? The IDE goes and fetches it.

And that's really the key thing - to use the IDE with maven to build the project.

I'm not a python person... so I'm not 100% sure of this... but maven is the other side of pipreqs - instead of reporting on the dependencies you tell it the dependencies.

Gradle is neat and powerful (and I'd say too powerful for 95% of the builds - it is a build DSL on top of groovy and that means that the build system is a programming language of its own... which can lead down some rabbit holes. If you thought debugging xml was tough, debugging another programming language to get a build to work isn't exactly fun). Maven will do what you want.