Building
Prequisites
- Check out or download as a ZIP file the Codehaus Cargo source code from Github into a
CARGOHOME
directory (wherever you want on your machine). - Install the JDK 11. If you really want to build with JDK 8 or with JDK 12 and above, read our chapter on building with older or newer versions of the JDK.
- Install Maven 3.6.3 or later.
If you are using Maven 3.8.1 or newer, you might have someArtifactTransferException
s with the OW2 snapshot repository (which was defined as HTTP over a decade back). You can work around these using the instructions in the chapterArtifactTransferException
with Maven 3.8.1 onwards.
Verify your installation works by running the following command in a command prompt / terminal window: mvn -version
Building
To build Codehaus Cargo:
- Go to
CARGOHOME
and runmvn install
This will build the full Cargo project. - If you wish to clean all build-generated files,
cd
toCARGOHOME
and runmvn clean
First time build
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:
- Edit the
.m2/settings.xml
file from your home directory (C:\Documents and Settings\username
orC:\Users\username
on Windows), - Comment out the
<proxy>
element and fill in the proxy server settings accordingly.
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.16-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:
- Resin 3.x requires Java 6 (it cannot run with newer versions of Java), and since it is executed using a
ResinRun
class the whole Resin container must be compiled with Java 6 - In addition, as other containers such as JOnAS 5.x also require Java 6, all test samples need to be built using Java 6
- The Jetty Remote Deployer for Jetty 6.x as well as for Jetty 7.x to 9.x are built with Java 6, so we can support a broad range of Java versions on these Jetty containers
- At the same time, the Jetty Remote Deployer for Jetty 10.x onwards requires the JDK 11 (because Jetty 10.x requires JDK 11 or above)
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.7.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.16-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>