Skip to content

Generating a sample Maven dependency graph

amine BEN edited this page Sep 2, 2018 · 4 revisions

This wiki page aims at illustrating, by means of a simple example, how to use the maven-miner tool.

As you may have read in the project's README, Maven-miner runs in two execution modes. Batch mode or messaging pattern mode. While the batch mode runs as a combinations of non communicating Java programs, the messaging pattern mode relies on the well-known producer consumer pattern. In this tutorial, we illustrate the later mode.

Prerequisites

General Prerequisites

  • Docker (1.13.0+)
    • Docker-compose to run the maven-miner in docker-compose mode
  • Maven
  • bash
  • git

Preparing the environment

The runtime environment preparation runs in three phases:

  1. Cloning the repository
  2. Packaging the tools

Cloning the repository

The Maven-miner repository is shipped with utility scripts to simplify the use and execution of the tool. In order experience the tool in a smooth manner, it is recommended to first, clone the repository.

user@ubuntu$ git clone https://github.com/diverse-project/maven-miner.git $MAVEN_MINER

From now on, $MAVEN_MINER refers to the absolute path where maven-miner repository is cloned

Downloading the sample artifacts' info file

In order to make your journey exploring the maven-miner tool pleasant, we provide you with a file containing 10k randomly picked coordinates available here. Download the file and put it a location of your choice. From now on, $FILE_PATH refers to the absolute path of the artifacts file.

Packaging the tool

To create the project binaries, we've made at you disposal a script (prepare.sh) that packages the maven projects and puts them at the appropriate locations to be consumed by the the docker scripts later.

user@ubuntu~$ cd $MAVEN_MINER
user@ubuntu$MAVEN_MINER$ ./prepare.sh

after running the script, make sure that the folders $MAVEN_MINER/files/maven-aether and $MAVEN_MINER/files/maven-indexer contain miner-aether.jar and miner-indexer.jar respectively.

Running the tools

In order to run the tools, make sure you have docker and docker-compose installed.

The script run-wiki.sh is responsible for running a docker cluster to resolve the dependencies. This cluster is composed of 1 Neo4j node, 1 RabbitMQ, 1 publisher node, and N consumer nodes. In order not to hit a CPU bottleneck, it is recommended to specify an N no greater than (Number of core - 2).

Let $NEO4J_DUMP the location where you wish the graph data to be persisted. You can launch the script as follows:

user@ubuntu$MAVEN_MINER$ ./run-wiki.sh --neo4j_dump $NEO4J_DUMP --n-consumer N --from-file $FILE_PATH

In order to follow the execution progress you can access the RabbitMQ broker interface at http://localhost:15672. The username is user and password is user.

The neo4j server is passwordless and accessible at http://localhost:7474.

In the next tutorial we will present the schema of graph data and show some simple query examples.