How to create Maven 2 repository in your LAN

in

Maven is my new development tool in Java world. I used to use Ant. But the build.xml and the jar management often make me crazy. Why bothers to bring along your jars in the project as you move into another PC. Or, why bothers to have duplicated jar in you PC as you get more projects? Why don't share them among the projects? So, I try maven 2.

Since Maven use remote repository by default, I think it is easier for developers in my office to have local repository to cache jars from remote repository. This urged me since I also have set up a local debian repository in my office (apt-cacher).

Ok, lets start configuring artifactory which I think it's the best repository server.

Assumption: The developer's PC has Maven 2 installed

In Repository server

  1. Download artifactory.war in http://www.jfrog.org/download.php
  2. Deploy the war in Jetty server (you can also use Tomcat) which already run as service in a server. Say, http://192.168.1.2:8080/artifactory

In a developer PC with installed Maven

Change Maven global repository:

  1. Create new profile in $M2_HOME/conf/settings.xml
    1. <profile>
    2. <id>artifactory-repository</id>
    3. <repositories>
    4. <repository>
    5. <id>central</id>
    6. <url>http://192.168.1.2:8080/artifactory/repo</url>
    7. <snapshots>
    8. <enabled>false</enabled>
    9. </snapshots>
    10. </repository>
    11. <repository>
    12. <id>snapshots</id>
    13. <url>http://192.168.1.2:8080/artifactory/repo</url>
    14. <releases>
    15. <enabled>false</enabled>
    16. </releases>
    17. </repository>
    18. </repositories>
    19. <pluginRepositories>
    20. <pluginRepository>
    21. <id>central</id>
    22. <url>http://192.168.1.2:8080/artifactory/plugins-releases</url>
    23. <snapshots>
    24. <enabled>false</enabled>
    25. </snapshots>
    26. </pluginRepository>
    27. <pluginRepository>
    28. <id>snapshots</id>
    29. <url>http://192.168.1.2:8080/artifactory/plugins-snapshots</url>
    30. <releases>
    31. <enabled>false</enabled>
    32. </releases>
    33. </pluginRepository>
    34. </pluginRepositories>
    35. </profile>
  2. Acticate this profile
    1. <activeProfiles>
    2. <activeProfile>artifactory-repository</activeProfile>
    3. </activeProfiles>

Have fun with your new Maven local repository
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <pre>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <c>, <cpp>, <cs>, <dos>, <drupal5>, <drupal6>, <java>, <javascript>, <perl>, <php>, <python>, <ruby>, <sql>, <vim>, <xml>.
  • Syntax highlight code surrounded by the {syntaxhighlighter OPTIONS}...{/syntaxhighlighter} tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.