Setup Maven:
- Download and Install latest Maven bundle.
- If you are accessing Internet via some proxy on your home and/or office networks than make sure you configured these proxy server settings in Maven Settings file.
- For example I’ve two proxy servers at my office network and one at home, and part of my maven settings file looks like this:
- Notice how I enabled my desired proxy server using <active>true</active>. There were cases when I have direct access to internet with out any proxy servers in between and in such cases all I had to do is to make sure “active” property of all of my proxy server settings are set to ‘false’.
Setup Archiva:
- Pre-requisite Tomcat 5.5+
- Download latest Archiva
- Install it as a WAR, the easiest way.
- Use embedded derby DB, no fancy stuff.
- Goto Archiva web administration area http://<server>:<port>/archiva/ and configure your admin user
- By clicking on “Repositories” button from the lhs menu, you can view following preconfigured repositories:
- Although, we can use above preconfigured repositories as it is, but for more clarity, we’ll going to do following changes
- Repository name of “Archiva Managed Internal Repository” to “Archiva Managed Internal Release Repository”
- Repository directory from “../internal” to “../releases”
- Repository URL from
“http://server:port/archiva/repository/internal/”
to
“http://server:port/archiva/repository/releases/” - Repository name of “Archiva Managed Snapshots Repository” to “Archiva Managed Internal Snapshot Repository”
- While changes to name and directory can be done by simply editing the repository record, the changes to URL can’t. So we will going to delete “Archiva Managed Internal Repository” and create a new record as follows:
- Select “Repositories” from the left hand side menu of Archiva web application. Then from the list of repositories click on “Delete” option of “Archiva Managed Internal Repository”
Click on “Delete Configuration and Contents”. - Again, select “Repositories” from the left hand side menu. Then click on “Add” option on the top right hand side of the page. Create new “Archiva Managed Internal Release Repository as follows
- Select “Repositories” from the left hand side menu of Archiva web application. Then from the list of repositories click on “Delete” option of “Archiva Managed Internal Repository”
- Because we don’t have to change the URL of “Archiva Managed Snapshots Repository” we can simply edit to make needed changes. Goto “Repositories”, click on “Edit” option from the “Archiva Managed Snapshots Repository” and change name from “Archiva Managed Snapshots Repository” to “Archiva Managed Snapshot Repository”:
- As shown in diagram below, all artifact requests from your maven clients should be directed to Archiva server which, on the bases of artifact type, release or snapshot, try to search in (local) internal repositories. If a matching artifact found than Archiva will serve the request directly, else, it will forward this request to other Remote repositories available over internet for resolution. Once, an artifact is recieved from remote repository, it will be cached first, in (local) internal repositories and then sent to the client as a response to its initial request.
- Next, we’ll going to configure network proxies. Select “Network Proxies” from left hand side menu of Archiva web application. Then, click on “Add” button on the top right hand side of the page. Fill the form with your network’s proxy information and click “Save Network Proxy”.
- Repeat step 11 to create as many proxies as you wish
- Now, we’ll going to create proxy connectors where each local or internal repository will be configured as a proxy to external or remote repositories.
- Click on “Proxy Connectors” from the left hand side menu, then select “Add” option from the top right hand side of the page and fill the form as follows:
Do note “White List” entry - Repeat the step again with following values
Do note “White List” entries - Repeat the step again with following values
- Repeat the step again with following values
- Now your Proxy Connectors list will look like this
Configure local internal repositories in your Maven Settings file:
- Create a new profile to configure newly created archiva managed repositories as follows:
- Profiles and their activation is a very handy feature because you can create as many profiles as you like and can activate or deactivate them based on different network environments.
- For example, there were cases when our Archiva Server hosting both internal Releases and Snapshots repositories was unavailable for some time. I simply deactivated “archiva” profile from my system’s maven settings file. I was then using remote maven repositories directly via internet. No idle time, no delay, no hurdles.
- Do note that we are using same repositories for plugins as well.
Ok, now you are all set to start using local internet repositories. Go ahead create a new project. Once done, point your browser to archiva web application. Click “Browse” from the left hand side menu, you can view all those groups, sub groups and artifacts which have been cached and served to the maven client up till now.
The story doesn’t ends here. We are still short of deploying our custom artifacts to local internal repositories.
Deploying to local internal repositories:
- In order to deploy your custom artifacts to local internet repositories, you need network access to machine hosting archiva repositories.
- Open your maven’s settings file and add server credentials as follows:
- Now, open your project’s POM file add following:
- All set, run maven’s deploy command and then browse your project’s artifact on archiva web application to verify that your it is uploaded successfully.