How to create Maven 2 repository in your LAN
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
- Download artifactory.war in http://www.jfrog.org/download.php
- 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:
- Create new profile in $M2_HOME/conf/settings.xml
- <profile>
- <id>artifactory-repository</id>
- <repositories>
- <repository>
- <id>central</id>
- <url>http://192.168.1.2:8080/artifactory/repo</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>snapshots</id>
- <url>http://192.168.1.2:8080/artifactory/repo</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>central</id>
- <url>http://192.168.1.2:8080/artifactory/plugins-releases</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </pluginRepository>
- <pluginRepository>
- <id>snapshots</id>
- <url>http://192.168.1.2:8080/artifactory/plugins-snapshots</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- </pluginRepository>
- </pluginRepositories>
- </profile>
- Acticate this profile
- <activeProfiles>
- <activeProfile>artifactory-repository</activeProfile>
- </activeProfiles>
Have fun with your new Maven local repository
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app

Comments
Post new comment