Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Of course you don't have to use an Installer if you want to use a container already installed on your machine.

Info
titleDifference between versions

The ZipURLInstaller has been changed between Cargo versions:

  • In Cargo version 1.1.0 and onwards, the ZipURLInstaller has two attributes:
    • downloadDir: Directory in which the container's distributable archive is downloaded. Defaults to ${java.io.tmpdir}/cargo/installs.
    • extractDir: Directory in which the container's distributable archive is extracted. Defaults to:
      • ${java.io.tmpdir}/cargo/installs on the Java API and ANT tasks
      • ${project.build.directory}/cargo/installs on the Maven2 plugin
  • In older versions, the ZipURLInstaller has only one attribute:
    • installDir: Directory in which the container's distributable archive is downloaded and extracted. Defaults to ${java.io.tmpdir}/cargo/installs.
       
      Similarly, the ZipURLInstaller constructor's parameters also reflect the same mechanism.

Example using the Java API

Code Block
// As described above, Cargo versions older than 1.1.0 accept only installDir,
// you therefore need to replace the "target/downloads", "target/extracts" to,
// for example, "target/installs"
Installer installer = new ZipURLInstaller(
    "http://download.eclipse.org/jetty/7.2.2.v20101205/dist/jetty-distribution-7.2.2.v20101205.tar.gz",
    "target/downloads", "target/extracts");
installer.install();

InstalledLocalContainer container = new Jetty7xInstalledLocalContainer(
    new Jetty7xStandaloneConfiguration("target/jetty7x"));
container.setHome(installer.getHome());
[...]

Example using the Ant API

Code Block
xml
xml
<!--
  Careful: As described above, Cargo versions older than 1.1.0 accept only installDir,
  you therefore need to set installDir instead of downloadDir and extractDir.
  -->
<cargo containerId="jetty7x" [...]>
  <zipUrlInstaller
      installUrl="http://download.eclipse.org/jetty/7.2.2.v20101205/dist/jetty-distribution-7.2.2.v20101205.tar.gz",
      downloadDir="target/downloads"
      extractDir="target/extracts"/>
  [...]
</cargo>

...

Code Block
xml
xml
  <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <configuration>
      <container>
        <containerId>jetty7x</containerId>
        <zipUrlInstaller>
          <url>http://download.eclipse.org/jetty/7.2.2.v20101205/dist/jetty-distribution-7.2.2.v20101205.tar.gz</url>
          <!--
            Careful: As described above, Cargo versions older than 1.1.0
            accept only installDir, you therefore need to set installDir
            instead of downloadDir and extractDir.
            -->
          <downloadDir>${project.build.directory}/downloads</downloadDir>
          <extractDir>${project.build.directory}/extracts</extractDir>
        </zipUrlInstaller>
      </container>
      [...]
    </configuration>
  </plugin>

...

Code Block
xml
xml
  <properties>
    <jetty.version>7.2.2.v20101205</jetty.version>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven2-plugin</artifactId>
        <version>${cargo.version}</version>
        <configuration>
          <container>
            <containerId>jetty7x</containerId>
            <artifactInstaller>
              <groupId>org.eclipse.jetty</groupId>
              <artifactId>jetty-distribution</artifactId>
              <version>${jetty.version}</version>
            </artifactInstaller>
          </container>
          [...]
        </configuration>
        [...]
      </plugin>
    </plugins>
  </build>
</project>

In older versions of Cargo, the CARGO ZipUrlInstaller can be used to reuse the Maven dependency. The example below illustrates that use case applied on Jetty 7:

...


  <properties>
    <jetty.version>7.2.2.v20101205</jetty.version>
  </properties>

  <!-- This will make Maven2 download the official Jetty 7 ZIP distribution -->
  <dependencies>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-distribution</artifactId>
      <version>${jetty.version}</version>
      <scope>test</scope>
      <type>zip</type>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven2-plugin</artifactId>
        <version>${cargo.version}</version>
        <configuration>
          <container>
            <containerId>jetty7x</containerId>
            <!-- Tell the ZipUrlInstaller to reuse the downloaded Jetty 7 ZIP distribution -->
            <zipUrlInstaller>
              <url>
                file:///${settings.localRepository}/org/eclipse/jetty/jetty-distribution/${jetty.version}/jetty-distribution-${jetty.version}.zip
              </url>
              <!--
                Careful: As described above, Cargo versions older than 1.1.0
                accept only installDir, you therefore need to set installDir
                instead of extractDir.
                -->
              <extractDir>${project.build.directory}/jetty-root</extractDir>
            </zipUrlInstaller>
          </container>
          [...]
        </configuration>
        [...]
      </plugin>
    </plugins>
  </build>
</project>