Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Cargo
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h3>Definition</h3><table class="wysiwyg-macro" data-macro-name="excerpt" data-macro-parameters="atlassian-macro-output-type=BLOCK" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2V4Y2VycHQ6YXRsYXNzaWFuLW1hY3JvLW91dHB1dC10eXBlPUJMT0NLfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>Cargo provides Ant tasks to perform all the operations available from the Java API</p></td></tr></table><table class="wysiwyg-macro" data-macro-name="info" data-macro-parameters="title=Functional tests" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2luZm86dGl0bGU9RnVuY3Rpb25hbCB0ZXN0c30&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>The usage of Cargo for executing functional tests on a container does not mandate these ANT tasks. You could directly use the Cargo Java API from your Java unit test classes (JUnit, TestNG, etc), as described on the <a class="confluence-link" href="/display/CARGO/Functional+testing" data-linked-resource-id="49249" data-linked-resource-type="page" data-linked-resource-default-alias="Functional testing" data-base-url="http://docs.codehaus.org">Functional testing</a> page.</p></td></tr></table><h3>Explanation</h3><p>Before using the Ant API you need to register the Cargo Ant tasks into Ant. This is done in the following manner:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><taskdef resource="cargo.tasks"> <classpath> <pathelement location="${cargo-core-uberjar.jar}"/> <pathelement location="${cargo-ant.jar}"/> </classpath> </taskdef> </pre></td></tr></table><p>Some additional dependencies might also be required for the ANT task. Please see the <a class="confluence-link" href="/display/CARGO/Installation" data-linked-resource-id="17486" data-linked-resource-type="page" data-linked-resource-default-alias="Installation" data-base-url="http://docs.codehaus.org">Installation</a> page for details.</p><h2>The Cargo ANT tasks in detail</h2><p>Here are the different task actions available to call on this plugin:</p><table class="confluenceTable"><tbody><tr><th class="confluenceTh"><p>Action</p></th><th class="confluenceTh"><p>Description</p></th></tr><tr><td class="confluenceTd"><p><code><strong>start</strong></code></p></td><td class="confluenceTd"><p>Start a container. That task will:</p><ul><li style="list-style-type: none;"><ul><li class="confluence-link">If the task configuration requires so, installs the container.</li><li class="confluence-link">If the task configuration defines a container with a <a href="http://docs.codehaus.org/display/CARGO/Standalone+Local+Configuration">standalone local configuration</a>, it will create the configuration.</li><li class="confluence-link">If the task configuration contains one or more <a href="http://docs.codehaus.org/display/CARGO/Deployable">deployables</a>, it will deploy these to the container automatically.</li><li class="confluence-link">And, of course, start the container.</li></ul></li></ul><p><strong>Note</strong>: A container that's started with the <code>start</code> task will automatically shut down as soon as the parent ANT instance quits (i.e., you see a <code>BUILD SUCCESSFUL</code> or <code>BUILD FAILED</code> message). If you want to start a container and perform manual testing, see our next task <code>run</code>.</p></td></tr><tr><td class="confluenceTd"><p><code><strong>run</strong></code></p></td><td class="confluenceTd"><p>Start a container and wait for the user to press <code>CTRL + C</code> to stop. That task will:</p><ul><li style="list-style-type: none;"><ul><li class="confluence-link">If the task configuration requires so, installs the container.</li><li class="confluence-link">If the task configuration defines a container with a <a class="confluence-link" href="/display/CARGO/Standalone+Local+Configuration" data-linked-resource-id="13087" data-linked-resource-type="page" data-linked-resource-default-alias="Standalone Local Configuration" data-base-url="http://docs.codehaus.org">standalone local configuration</a>, it will create the configuration.</li><li class="confluence-link">If the task configuration contains one or more <a class="confluence-link" href="/display/CARGO/Deployable" data-linked-resource-id="13115" data-linked-resource-type="page" data-linked-resource-default-alias="Deployable" data-base-url="http://docs.codehaus.org">deployables</a>, it will deploy these to the container automatically.</li><li class="confluence-link">And, of course, start the container and wait for the user to press <code>CTRL + C</code> to stop.</li></ul></li></ul></td></tr><tr><td class="confluenceTd"><p><code><strong>stop</strong></code></p></td><td class="confluenceTd"><p>Stop a container.</p></td></tr><tr><td colspan="1" class="confluenceTd"><code><strong>restart</strong></code></td><td colspan="1" class="confluenceTd"><p>Stop and start again a container. If the container was not running before calling <code>restart</code>, it will simply be started.</p></td></tr><tr><td class="confluenceTd"><p><code><strong>configure</strong></code></p></td><td class="confluenceTd"><p>Create the configuration for a <a class="confluence-link" href="/display/CARGO/Local+Container" data-linked-resource-id="45798" data-linked-resource-type="page" data-linked-resource-default-alias="Local Container" data-base-url="http://docs.codehaus.org">local container</a>, without starting it. Note that the <code>start</code> and <code>run</code> actions will also install the container automatically.</p></td></tr><tr><td class="confluenceTd"><p><code><strong>deploy</strong></code></p></td><td class="confluenceTd"><p>Deploy a deployable to a running container.</p></td></tr><tr><td class="confluenceTd"><p><code><strong>undeploy</strong></code></p></td><td class="confluenceTd"><p>Undeploy a deployable from a running container.</p></td></tr><tr><td class="confluenceTd"><p><code><strong>redeploy</strong></code></p></td><td class="confluenceTd"><p>Undeploy and deploy again a deployable. If the deployable was not deployed before calling <code>redeploy</code>, it will simply be deployed.</p></td></tr></tbody></table><table class="wysiwyg-macro" data-macro-name="info" data-macro-parameters="title=Wait after the container has started" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2luZm86dGl0bGU9V2FpdCBhZnRlciB0aGUgY29udGFpbmVyIGhhcyBzdGFydGVkfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>Many wonder the difference between the <code>start</code> and <code>run</code> actions:</p><ul><li>If you want to just start the container and then do other tasks (for example, execute tests), use the <code>start</code> action. That action should therefore <span style="text-decoration: underline;">ONLY</span> be used for integration testing.</li><li>If you want start the container and have ANT "blocked" afterwards (i.e., until you press <code>CTRL + C</code> to stop), use the <code>run</code> action. <code>run</code> is therefore the action to use for manual testing.</li></ul></td></tr></table><h3>Examples</h3><p><img class="editor-inline-macro" src="/plugins/servlet/confluence/placeholder/macro?definition=e2FuY2hvcjpleGFtcGxlc30&locale=en_GB&version=2" data-macro-name="anchor" data-macro-default-parameter="examples"></p><h4>Orion 2.x</h4><p>Here's a full example showing how to deploy a WAR, and expanded WAR and an EAR in an Orion 2.x container. Please note that the <code>output</code> and <code>log</code> attribute are optional. The <code>property</code> elements allow you to tune how the container is configured. Here we're telling it to start on port 8180 and to generate the maximum amount of logs in the container <code>output</code> file.</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><taskdef resource="cargo.tasks"> <classpath> <pathelement location="path/to/cargo-uberjar.jar"/> <pathelement location="path/to/cargo-ant-tasks.jar"/> </classpath> </taskdef> <cargo containerId="orion2x" home="c:/apps/orion-2.0.3" output="target/output.log" log="target/cargo.log" action="start"> <configuration> <property name="cargo.servlet.port" value="8180"/> <property name="cargo.logging" value="high"/> <deployable type="war" file="path/to/my/simple.war"/> <deployable type="war" file="path/to/my/expandedwar/simple"/> <deployable type="ear" file="path/to/my/simple.ear"/> </configuration> </cargo> </pre></td></tr></table><h4>Tomcat 5.x</h4><p>This example gives a walk through of how to get a Cargo Ant build to work with Tomcat 5.x .</p><h5>Prerequisites</h5><ul><li>It is assumed that <a href="http://tomcat.apache.org">Tomcat 5.x</a> is already installed</li><li>The cargo-core-uberjar.jar and cargo-ant.jar JARs have been downloaded</li><li>A mimimum knowledge of Ant is required</li><li>User already has a <code>war</code> target that properly generates a working war file</li></ul><h5>Steps</h5><p>Follow the following steps to configure your <code>build.xml</code> :</p><ul><li>Create a folder under your basedir called cargolib that will hold cargo-core-uberjar.jar and cargo-ant.jar</li></ul><ul><li>Define a property for cargolib</li></ul><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><property name="cargolib.dir" value="${basedir}/cargolib"/> </pre></td></tr></table><ul><li>Define 2 new properties <code>cargo-uberjar</code> and <code>cargo-antjar</code> as shown below:</li></ul><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><property name="cargo-uberjar" value="${cargolib.dir}/cargo-core-uberjar.jar"/> <property name="cargo-antjar" value="${cargolib.dir}/cargo-ant.jar"/> </pre></td></tr></table><ul><li><p>Add additional properties for defining the following:</p><table class="confluenceTable"><tbody><tr><th class="confluenceTh"><p>Property</p></th><th class="confluenceTh"><p>Description</p></th></tr><tr><td class="confluenceTd"><p>tomcat.home</p></td><td class="confluenceTd"><p>Installation directory of tomcat5x</p></td></tr><tr><td class="confluenceTd"><p>tomcatlog.dir</p></td><td class="confluenceTd"><p>This is where our logs are going to be generated</p></td></tr><tr><td class="confluenceTd"><p>tomcatconfig.dir</p></td><td class="confluenceTd"><p>Cargo needs an empty config folder</p></td></tr><tr><td class="confluenceTd"><p>pathtowarfile</p></td><td class="confluenceTd"><p>The full path of the war file e.g c:/devtools/myapp/dist/myfile.war</p></td></tr></tbody></table></li></ul><ul><li><p>Add the following code to your build.xml :</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><taskdef resource="cargo.tasks"> <classpath> <pathelement location="${cargo-uberjar}"/> <pathelement location="${cargo-antjar}"/> </classpath> </taskdef> <target name="cargostart" depends="war"> <delete dir="${tomcatconfig.dir}" /> <mkdir dir="${tomcatlog.dir}"/> <mkdir dir="${tomcatconfig.dir}"/> <echo message="Starting Cargo..."/> <echo message="Using tomcat.home = ${tomcat.home} "/> <echo message="Using war = ${mywarfile} "/> <echo message="Jars used = ${cargo-uberjar} , ${cargo-antjar}"/> <cargo containerId="tomcat5x" home="${tomcat.home}" output="${tomcatlog.dir}/output.log" log="${tomcatlog.dir}/cargo.log" action="start"> <configuration home="${tomcatconfig.dir}"> <property name="cargo.servlet.port" value="8080"/> <property name="cargo.logging" value="high"/> <deployable type="war" file="${mywarfile}"/> </configuration> </cargo> </target> </pre></td></tr></table></li></ul><h4>Remote deployment</h4><p>Here's a full example showing how to deploy a WAR to a remote Tomcat 6.x container.</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><taskdef resource="cargo.tasks"> <classpath> <pathelement location="path/to/cargo-uberjar.jar"/> <pathelement location="path/to/cargo-ant-tasks.jar"/> </classpath> </taskdef> <cargo containerId="tomcat6x" action="deploy" type="remote"> <configuration type="runtime"> <property name="cargo.hostname" value="production27"/> <property name="cargo.servlet.port" value="8080"/> <property name="cargo.remote.username" value="admin"/> <property name="cargo.remote.password" value=""/> <deployable type="war" file="path/to/simple-war.war"> <property name="context" value="application-context"/> </deployable> </configuration> </cargo> </pre></td></tr></table><p>For more details, please check the example in the <a class="confluence-link" href="/display/CARGO/Remote+Container" data-linked-resource-id="45808" data-linked-resource-type="page" data-linked-resource-default-alias="Remote Container" data-base-url="http://docs.codehaus.org">Remote Container</a> section for the ANT tasks. The ANT tasks support the deployer actions <code>deploy</code>, <code>undeploy</code> and <code>redeploy</code>.</p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced