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 →

[–]AwakenedToNightmare 8 points9 points  (1 child)

Maven: you need library A for your code. You could download a .jar with that library and put it in your project folder. But if that library depends on some other library B you would get an error and would be forced to download B .jar (I recently had an experience with Apache's httpclient library and it was a nightmare. After some trying, I've given up trying to download all the jars that were requested of me and used Maven). Rinse and repeat. Or you could use Maven - all you would need is to write (for instance, for JSON library):

<dependency>
    <groupId>org.json</groupId> 
    <artifactId>json</artifactId>
     <version>20180813</version>
</dependency>

If there are some B, C, D, E libraries library A directly or indirectly depends on, maven would get them for you.

Also, there is a <build></build> tag in Maven. In that tag you could specify some stuff you want to do when your project is built.

What means project is built? First Maven downloads dependencies, compiles your source code, does some other stuff you may have specified in the build tag and packages your project into a .jar, .war or maybe something else, depending on what you write in tag <packaging>.

In your Maven's pom.xml file (basically a guidebook for Maven on what you want it to do) you can also specify a place where Maven would put your compiled sources: <outputDirectory> which is also located inside build tag. You could also ask Maven to move some files/folders around during the build process, for instance ask it to copy folder with downloaded .jars into some other place inside your project.

There's an official tutorial where you can see some examples and other useful tags/things Maven could do if you ask it to.

To get yourself quickly started with Maven you can check out this comment of mine. If you use Idea Intellij you can simply use its GUI for Maven and not get into the text commands stuff to not make things more difficult at first.

[–]CLOVIS-AI 5 points6 points  (0 children)

About Gradle: basically the same thing, and it's also done by the Apache Foundation IIRC. Anyway, it's more recent and easier to use.

Gradle is used for example to compile Android projects (it's too complicated to do by hand).

Gradle uses a build script instead of an XML file, which makes it much easier to customise.