Maven: July 2009 Archives

Maven is a life saver for Java. It provides some much needed convention, but at the same time it can be really tricky to figure out how to do some basic configuration. One problem I struggled with was setting up an Artifactory repository which required authentication for the uploading and downloading or jars.

To save you some time, here are some steps with the minimal required configuration:

  1. Install artifactory as described on their website
  2. Create a user that you will use for access. Make sure that they have access but they do not need to be an administrator.
  3. Encrypt this user’s password mvn --encrypt-password . You should get a result that looks something like this: {COQLCE6DU6GtcS5P=}
  4. Create your ~/.m2/settings.xml file and add this content to it. This will teach your maven how to download libraries from your repository.
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<pluginGroups> 
<pluginGroup>org.grails</pluginGroup></pluginGroups> 
  <servers>
    <server>
        <id>myrepo.example.com</id>
        <username>johndoe</username>
        <password>{the encrypted password from the previous step}</password>
    </server>
  </servers>
  <profiles>
    <profile>
      <id>default</id>
      <repositories>
          <repository>
              <id>myrepo.example.com</id>
              <url>http://myrepo.example.com:8090/artifactory/repo</url>
          </repository>
      </repositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>default</activeProfile>
  </activeProfiles>
</settings>
  1. Add this to each of your pom.xml files (or to your project root pom). This is how your projects know to deploy your libraries. The user name and password will be used from settings.xml which is why it’s important for the two server IDs to match.
    <distributionManagement>
        <repository>
            <id>myrepo.example.com</id>
            <name>myrepo.example.com</name>
            <url>http://myrepo.example.com:8090/artifactory/libs-releases-local</url>
        </repository>
        <snapshotRepository>
            <id>myrepo.example.com</id>
            <name>myrepo.example.com</name>
            <url>http://myrepo.example.com:8090/artifactory/libs-snapshots-local</url>
            <uniqueVersion>false</uniqueVersion>
        </snapshotRepository>
    </distributionManagement>
0 Votes

About this Archive

This page is an archive of entries in the Maven category from July 2009.

Maven: May 2009 is the previous archive.

Find recent content on the main index or look in the archives to find all content.

Maven: Monthly Archives