Build Systems - Local Repository

    Continuation of the previous post about assembly systems - BuildSystems - Intro


    A build system that describes dependencies at different levels and plugins for completing tasks.
    In a previous post, there are links to other articles that describe this system, the hallmark of which is the clearly defined assembly life cycle:

    • validate - validates project information
    • compile - compiles the source, in fact this is an appeal to the compiler plugin;
    • test - run unit tests
    • package - packaging classes in the specified format (zip, rar, jar, war, ear, etc.)
    • integration-test - run integration tests after assembly
    • verify - verifies the package is correct and meets quality requirements
    • install - “install” the assembly into the local repository
    • deploy - send a packet to the specified server

    Local Maven Repository

    But none of these articles described, which, in turn, was very useful for me - this is setting up a local repository.

    By default, the following directory is used as the local repository (OS: Windows)

    But over time, the repository grows and grows, and this fact, which constantly eats up a place on the system partition, began to disappoint in direct proportion to the growth of the repository.
    In addition, if suddenly you (like me) have several users configured with whom you work, then two such duplicate repositories begin to upset twice as much.

    To prevent this from happening, there is a good and elegant solution - move the local repository to another partition and configure all users on it.
    To do this, open the file

    Where we add the local repository setting

    When using a local repository, the size of the ".m2" directory remains equal to the order of 114Kb.

    Using plugins

    I also want to give a slightly extended example of working with plug-ins for creating archetype projects.

    Creating a project for Eclipse

    Call maven-eclipse-plugin
    mvn eclipse:eclipse

    Creating a project for IDEA

    Call maven-idea-plugin
    mvn idea:idea

    But when your execution of these commands does not bring the desired result, you should look at the help for the called plug-in, which can be called as follows:
    mvn :help

    where will be described the configuration and possible parameters for the plugin that you are accessing.

    As for generation, you can request help on archetypes as follows:
    mvn archetype:generate

    Ant + Ivy

    Ant is another
    Ivy build system - a dependency manager that can access various repositories and find the necessary information in them and load it into the local repository (some cache, on the local machine).

    Ant, in my opinion, gives a greater degree of freedom than Maven (in which, by the way, you can also access ant'a tasks / tasks), if only because you do not have to automate one of the necessary stages of your assembly To do this, implement your own Maven plugin. In other words, Ant is more adapted to quickly automate certain actions to build your project and where any step you take to the side will not be regarded as an escape and be punishable by execution.

    The list of what was on Habré about this system (the most general) (it is better to read again in the given order):

    Ivy local repository

    A similar problem with the placement and configuration of the local Ivy repository, which by default is located in

    The system configuration is read from "ivysettings.xml", which can also be connected as follows:

    But the placement of the local repository itself can be redefined in the “caches” section, specifying the attribute “defaultCacheDir”:

    This example uses the predefined variable / property (property) “ivy.settings.cache”.
    Ivysettings.xml example


    When getting acquainted with assembly systems, you need to stay calm, remember that it was invented / written / implemented "to help." Therefore, if something objectively does not suit you, there must be a way to either reconfigure it or minimize your dissatisfaction.

    Also popular now: