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-x.y.z.zip in http://www.jfrog.org/download.php. This distribution contains built-in Jetty server.
- Extract into /opt directory so you'll see /opt/artifactory-x.y.z/artifactory.jar
- Install as service
cd /opt/artifactory-x.y.z/bin sudo ./install.sh
You may need to add JAVA_HOME in the service by adding line
. /etc/environment
in line 48 of /etc/init.d/artifactory. The /etc/environment file should contain
JAVA_HOME=/usr/lib/jvm/java-6-sun
or others which specify your JAVA_HOME
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:8081/artifactory/repo</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>snapshots</id> <url>http://192.168.1.2:8081/artifactory/repo</url> <releases> <enabled>false</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://192.168.1.2:8081/artifactory/plugins-releases</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>snapshots</id> <url>http://192.168.1.2:8081/artifactory/plugins-snapshots</url> <releases> <enabled>false</enabled> </releases> </pluginRepository> </pluginRepositories> </profile>
- Activate this profile by adding in the same settings.xml file
<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