Navigating Artifactory

Start Tomcat, open the browser and navigate http://localhost:8080/artifactory

Navigating Artifactory

Navigating Artifactory

     

Start Tomcat, open the browser and navigate http://localhost:8080/artifactory

Here is the artifactory home page shown below: 

Sign in username as 'admin' and password as 'password'. You can view the content of the repository simply by clicking on the Repository Browser link.

V.  Configuring maven to use the new repository: 

You can use either of the settings.xml  or the pom.xml files to configure maven to use the local repository.

  • Configure maven using settings.xml file: Maven uses the settings.xml file contained in .m2 folder inside the C\Document and Setting\Administrator to get the location of the maven repository. In case of  no repository is specified then maven uses the default repository from ibiblio.org. We will have to make changes in the settings.xml file to use the new repository. Here is the settings.xml shown below:
<profiles>
<profile>
<id>dev</id>
<properties>
<tomcat6x.home>C:/InstalledPrograms/apache-tomcat-6.0</tomcat6x.home>
</properties>
<repositories>
<repository>
<id>central</id>
<url>http://localhost:8080/artifactory/repo</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://localhost:8080/artifactory/repo</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://localhost:8080/artifactory/repo</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>http://localhost:8080/artifactory/repo</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
  • Configure maven using project "pom.xml" : We can also set the repository settings through the pom.xml file. Simple pom.xml is shown below:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>test</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>central</id>
<url>http://localhost:8080/artifactory/repo</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://localhost:8080/artifactory/repo</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://localhost:8080/artifactory/repo</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>http://localhost:8080/artifactory/repo</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
 

VI.  Building using the new maven repository

While building the maven project, all the repositories should be downloaded using the new repository. The console will show the server maven uses as shown below:

Login into your new repository through the web browser and you see that the artifactory has downloaded and cached the artifacts from ibiblio.

It provides an advance search facility that can  be used to search an artifact simply by using the advanced search technique.

 

VII.   Installing artifacts to the repository :
 
We can use the web UI or maven command line to install the artifacts. Installation process through the web UI is simpler and faster and does not require any change in the configuration. While installation through the command line requires changes in the configuration in settings.xml and then we can use it in other scripts.

Installing artifacts using the web UI: Steps involved in the installation process are shown below:
  1. Upload artifact (e.g. 'jar' file or 'pom' file) and deploy using Artifact Deployer.
  1. If you upload the jar file then the artifactory will create the pom.xml file as well as you can also specify which repository to upload to.
  1. Once uploading is complete successfully, the artifact along with the ?pom.xml? file created by artifactory appears in the repository.

Installing artifacts from maven command line:
Using the command 'maven clean install' maven only packages and installs the artifact to the local repository. We need to add the additional configuration section in the settings.xml file to install it to the local internal repository. Steps involved in whole of the process are shown below:

settings.xml

<settings>

<servers>
<server>
<id>organisation-internal</id>
<username>admin</username>
<password>password</password>
</server>
</servers>

</settings>

The command given below is used to install an artifact to internal maven repository.

mvn deploy:deploy-file -DrepositoryId=organisation-internal -Durl=http://localhost:8080/artifactory/private-internal-repository
-DgroupId=test -DartifactId=test -Dversion=1.1 -Dpackaging=jar -Dfile=target/test-1.1.jar

Both the repository id and the server id defined in the settings.xml should be same. The url should include the repository name to which the artifact is to be installed. The artifactory and the new artifacts appeared in the repository creates the 'pom' (pom.xml) file for us automatically.

VIII.  Other Artifactory features: 

  • Backup the repository: Backup policy is specified in the <ARTIFACTORY_INSTALLATION _FOLDER>/etc/artifactory .config.xml and 'cron' expression specifies the backup configuration. Backup configuration is shown below:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://artifactory.jfrog.org/xsd/1.0.0"
xsi:schemaLocation="http://artifactory.jfrog.org/xsd/1.0.0
http://www.jfrog.org/xsd/artifactory-v1_0_0.xsd">
<!-- Backup every 12 hours -->
<backupCronExp>0 0 /12 * * ?</backupCronExp>
<localRepositories>
<localRepository>
<key>private-internal-repository</key>
<description>Private internal repository</description>
<handleReleases>true</handleReleases>
<handleSnapshots>true</handleSnapshots>
</localRepository>
<localRepository>
<key>3rd-party</key>
<description>3rd party jars added manually</description>
<handleReleases>true</handleReleases>
<handleSnapshots>false</handleSnapshots>
</localRepository>
</localRepositories>
<remoteRepositories>
<remoteRepository>
<key>ibiblio</key>
<handleReleases>true</handleReleases>
<handleSnapshots>false</handleSnapshots>
<excludesPattern>org/artifactory/**,org/jfrog/**</excludesPattern>
<url>http://repo1.maven.org/maven2</url>
</remoteRepository>
</remoteRepositories>
</config>

The directory ?<ARTIFACTORY_INSTALLATION _FOLDER>/backups? contains the backups. The local repository on the developer's machine and the backups both have the same format. It allow us the repository contents to migrate easily to another implementation of maven repository.

Other features: 

  • Use the web UI to delete the artifacts
  • Use the web UI to search for artifacts.
  • Bulk import/export all artifacts in repository.
  • If tomcat is not required then we can use the included jetty web server.

The overall conclusion is that an internal maven repository helps us to avoid conflicts due to different versions of libraries and it also speeds up the build process. Artifactory seems the better product among the 4 common maven repository. It has all the features that a good maven repository should have. The organization will not be locked into this tool since migration of the repository to another implementation is rather easy. A web UI simplifies the use of the repository even for the peoples who don't know the working of the repository.