The Gluster Blog

Gluster blog stories provide high-level spotlights on our users all over the world

Setting up Archiva to host your Maven Repo in 15 minutes

Gluster
2013-04-17
Archiva is a fully open alternative to Nexus – a simple web-ui for managing and serving up your maven repos. 

Setting up a maven repository is as simple as setting up a web accessible directory structure, for example, you can do this using nothing other than a public github repo .

Archiva vs. nexus vs … 

I’m not going to go into the details here, as there are plenty of lmgtfy resources on this.  Nexus is extremely sophisticated, and has a very professional look and feel with great scalability.  Archiva is the up-and-coming apache answer to nexus, and is slightly more “open”.  But either maven repository server has essentially the same core features for moderate to small size java projects.

Anyways… here goes – setting up archiva (in this case I’ve done this on EC2 in a machine with the correctly opened ports).

Directions for setting up Archiva (fedora/rhel) with open-jdk.

1) yum install glibc.i686 (fedora/rhel – this might only required for a minute open-jdk issue).

2) Update the conf.xml file (for example, to serve on another port than 8080 if you don’t want it to collide with another server).

3) apache-archiva-1.3.6/bin/archiva start

4) Test locally : run wget localhost:80/archiva , which should return something meaningful after a few seconds of initialization.

5) Now the server is running, but you need to set it up:

6) Setup an admin account, which will log you in.   (note, if you screw this up, you can delete it by deleting the data/databases/users directory).

You can add a jar to the repo and watch how archiva updates the maven repo for you,
8)Go to “http://<your_server>/archiva/upload!doUpload.action”, and then click “upload artifact”.

9) After you enter the fields in (don’t worry, this can be deleted), you will find that the following files have been amended in your installation:

./apache-archiva-1.3.6/data/repositories/snapshots/.indexer/_2.cfs
./apache-archiva-1.3.6/data/repositories/snapshots/<your group>/1/maven-metadata.xml
./apache-archiva-1.3.6/data/repositories/snapshots/<your group>/1/1/1-1.JAR
./apache-archiva-1.3.6/data/repositories/snapshots/<your group>/1/1/maven-metadata.xml
./apache-archiva-1.3.6/data/databases/archiva/log/log1.dat
./index.html

What happened?

Archiva has updated the internal maven information for you and created groups/versions/etc…

Now – you can go and delete the same repo via the user interface, and try the fancy, automated, command-liney strategy below – which will be more familiar to die-hard maven users who administer their own repos locally:

How to publish manually to a maven repo:

You can also directly publish to the internal archiva repo using standard mvn deploy:deploy syntax:

10) mvn deploy:deploy-file -Dfile=<path_to_jar> -DpomFile=<path_to_pom> -DrepositoryId=Internal -Durl=file:<path_to_archiva>/data/repositories/internal (deploys to the internal/ repository, as opposed to the snapshot/ repository).

11) Now, wait ! After you do this, you have to UPDATE the archiva database.   This allows archiva to see all the unprocessed artifacts that are in your repository. You can run these updates by clicking the convenient little buttons at http://<your_ip_address>/archiva/admin/database.action .

Yay: Now you can browse, deploy, delete, and publish your jars from a single interface.

So the moral of the story?  In spite of all the jargon, Maven repos are still really just a bunch of directories – but its the convention-over-configuration part that has turned maven into a universal language for JVM dependencies.

BLOG

  • 06 Dec 2020
    Looking back at 2020 – with g...

    2020 has not been a year we would have been able to predict. With a worldwide pandemic and lives thrown out of gear, as we head into 2021, we are thankful that our community and project continued to receive new developers, users and make small gains. For that and a...

    Read more
  • 27 Apr 2020
    Update from the team

    It has been a while since we provided an update to the Gluster community. Across the world various nations, states and localities have put together sets of guidelines around shelter-in-place and quarantine. We request our community members to stay safe, to care for their loved ones, to continue to be...

    Read more
  • 03 Feb 2020
    Building a longer term focus for Gl...

    The initial rounds of conversation around the planning of content for release 8 has helped the project identify one key thing – the need to stagger out features and enhancements over multiple releases. Thus, while release 8 is unlikely to be feature heavy as previous releases, it will be the...

    Read more