Prequisites

Verify your installation works by running the following command in a command prompt / terminal window: mvn -version

Building

To build Codehaus Cargo:

The Codehaus Cargo build contains functional tests. Those tests are run on different containers. The first time you build Codehaus Cargo it will download those container distributions which will take some time (the containers are installed into core/samples/java/installs). If you want to tell Codehaus Cargo to run only on some specific container, see below.

Selecting containers

The default list of containers to run on depends a property cargo.containers defined in CARGOHOME/core/samples/pom.xml. It can also be supplied at the command line by using profiles (-P<containerId>).

For example if you only want to run on Tomcat 8.x you'd run: mvn -Ptomcat8x clean install

Proxy settings

If you need to build Codehaus Cargo from behind a proxy, proceed as follows:

ArtifactTransferException with Maven 3.8.1 onwards

With Maven 3.8.1 onwards you might get errors such as:

org.eclipse.aether.transfer.ArtifactTransferException:
Could not transfer artifact org.ow2.jonas.tools.configurator:api:pom:1.10.14-SNAPSHOT from/to maven-default-http-blocker (http://0.0.0.0/):
Blocked mirror for repositories: [ow2-snapshot (http://repository.ow2.org/nexus/content/repositories/snapshots, default, snapshots)]

To work around the issue, create a settings.xml file in your .m2 home which overrides the HTTP-based OW2 SNAPSHOTS repository:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <mirrors>
    <mirror>
      <id>ow2-snapshot-override</id>
      <name>ow2-snapshot-override</name>
      <url>https://repo.maven.apache.org/maven2</url>
      <mirrorOf>ow2-snapshot</mirrorOf>
    </mirror>
  </mirrors>
</settings>

Building with older or newer versions of the JDK

Codehaus Cargo has support for very old and very new containers, which implies it has quite a broad combination of Java source and target version requirements:

The only version of the JDK that can build with all these constraints is the JDK 11. We hence have certain modules of the Codehaus Cargo build that do not activate on JDK 8, and some others that don't activate on JDK 12 onwards. On these JDKs, you hence will get exceptions such as:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.6.1:copy (copy-test-ear) on project cargo-core-container-jonas:
Unable to find/resolve artifact.: Could not find artifact org.codehaus.cargo:simple-ear:ear:1.10.14-SNAPSHOT -> [Help 1]

To build on these JDKs, you can either have a "pre-build" in JDK 11, or use the snapshots repository by adding the below to your Maven settings.xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>
    <profile>
      <id>sonatype-snapshots-repository</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <repositories>
        <repository>
          <id>sonatype-snapshots</id>
          <name>Sonatype Snapshots</name>
          <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>
</settings>