Edit me

Overview

Apache Maven logo

Anchor uses Apache Maven as a build automation tool.

Maven combines:

  • a build-tool (similar to Ant), and
  • repositories for storing versioned artefacts (JARs).

There exists a private local maven repository ($HOME/.m2/ sub-directory in your home-directory) where artifacts may be stored, before being synchronized with the main repository server for packages.

Plugins

Maven’s configuration combines many plugins, and some key third-party libraries are integrated via this mechanism into Anchor’s build process.

Example commands

Tutorials on Maven are widely available. Here follows a very brief introduction.

Maven’s build process is centered around https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html.

To perform a build task, simply open a command-shell and change directory to where a pom.xml is located. Then execute maven with a phase as an argument. All necessary prior phases are also executed.

For example, the following command, executes the deploy phase, which builds, installs the binary output in the local maven repository, and then copies the final binaries onto the repository-server.

$ mvn deploy

The following command will only execute only as far as the install phase.

$ mvn install

The following command will delete all binary-files (a different lifecycle).

$ mvn clean

These commands can be executed in the top-level directory (and thus applied to all sub-modules), or for a specific module only in the respective subdirectory.

Installation

  1. Download from Apache Maven

  2. Add the bin/ directory to $PATH

  3. Setup a .m2/settings.xml file as outlined below to access the Anchor repositories.

Settings file

The project uses GitHub Packages as a repository serve (provides versioned JARs) that is needed to build Anchor.

It is found at:

https://maven.pkg.github.com/anchoranalysis/ANCHOR-REPOSITORY-NAME

where ANCHOR-REPOSITORY-NAME should be substituted with the respect repository name e.g. anchor or anchor-plugins etc.

This repository requires a token from GitHub to read from (and requires credentials from Owen Feehan to write to).

The credentials (username/token) should be specified in your private maven settings, e.g. in $HOME/.m2/settings.xml where $HOME is the user’s home directory`.

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
    <servers>
        <server>
            <id>github</id>
            <username>YOUR_USERNAME</username>
            <password>YOUR_TOKEN</password>
        </server>  
        <server>
            <id>path-pattern-finder</id>
            <username>YOUR_USERNAME</username>
            <password>YOUR_TOKEN</password>
        </server>  	    
    </servers>

    <profiles>
        <profile>
            <id>anchorTestConfig</id>
            <properties>
                <anchor.home.test>C:\SOMEDIRECTORY\Apps\anchor\</anchor.home.test>
                <anchor.home.deploy>C:\SOMEDIRECTORY\Apps\anchor\</anchor.home.deploy>
                <maven.test.skip>true</maven.test.skip>
                <maven.javadoc.skip>true</maven.javadoc.skip>
            </properties>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>anchorTestConfig</activeProfile>
    </activeProfiles>

</settings>

Replace YOUR_USERNAME and YOUR_TOKEN appropriately, and update the anchor.home.test and anchor.home.deploy variable to match the path where Anchor will be deployed to.

Multi-module projects

Anchor uses a multi-module setup with a hierarchy of pom.xml files from the top-level directory to each nested module.

Each module pom.xml outlines an artifiactID and version that determine how it is stored in the repository server.

Actually Anchor uses several multi-module projects, each in its own repository.

This is a convenient location for global settings for the build process.

Steps for adding a new plugin module

Based in the root directory of a multi-module respository:

  1. Create a sub-directory containing the new module in anchor-plugins or anchor-plugins-gpl depending on license.
  2. Add module name to the pom.xml in the root directory of this repository.
  3. Add a dependency in anchor-assembly:
    1. if it’s the regular MIT license (i.e. not-GPL), then add a dependency in /addplugins/pom.xml
    2. if it’s GPL, then add a dependency in /anchor-assembly/pom.xml
Tags: build