{"id":1995,"date":"2017-05-12T10:07:51","date_gmt":"2017-05-12T08:07:51","guid":{"rendered":"http:\/\/blog.rabahi.net\/?page_id=1995"},"modified":"2017-05-12T10:50:52","modified_gmt":"2017-05-12T08:50:52","slug":"cargo-maven2-plugin","status":"publish","type":"page","link":"https:\/\/blog.rabahi.net\/?page_id=1995","title":{"rendered":"cargo-maven2-plugin"},"content":{"rendered":"<p>Cargo maven plugin allows you to deploy your webapp in a container (tomcat, jetty, jboss, &#8230;).<br \/>\nHere is an example that shows how to deploy your webapp in tomcat container and launch integration tests.<\/p>\n<h1>Add cargo maven plugin<\/h1>\n<p>We ask maven to fire the goal &#8216;start&#8217; at the phase &#8216;pre-integration-test&#8217; to start the container.<br \/>\nThis will have the benefit to be able to launch integration tests at the phase &#8216;integration_test&#8217;.<br \/>\nThen we will fire the goal &#8216;stop&#8217; at the phase &#8216;post-integration-test&#8217; to stop the container.<\/p>\n<pre lang=\"xml\">\r\n<plugins>\r\n(...)\r\n\r\n  <plugin>\r\n    <groupId>org.codehaus.cargo<\/groupId>\r\n    <artifactId>cargo-maven2-plugin<\/artifactId>\r\n    <version>${cargo-plugin.version}<\/version>\r\n    <executions>\r\n      <execution>\r\n        <id>start-container<\/id>\r\n        <phase>pre-integration-test<\/phase>\r\n\t<goals>\r\n\t  <goal>start<\/goal>\r\n\t<\/goals>\r\n      <\/execution>\r\n      <execution>\r\n\t<id>stop-container<\/id>\r\n\t<phase>post-integration-test<\/phase>\r\n\t<goals>\r\n\t  <goal>stop<\/goal>\r\n\t<\/goals>\r\n      <\/execution>\r\n    <\/executions>\r\n    <configuration>\r\n      <!-- Container configuration -->\r\n      <container>\r\n\t<containerId>tomcat8x<\/containerId>\r\n\t<type>installed<\/type>\r\n        <artifactInstaller>\r\n          <groupId>org.apache.tomcat<\/groupId>\r\n          <artifactId>tomcat<\/artifactId>\r\n          <version>${tomcat.version}<\/version>\r\n          <type>zip<\/type>\r\n          <extractDir>${project.build.directory}\/cargo\/installs<\/extractDir>\r\n        <\/artifactInstaller>\r\n      <\/container>\r\n\r\n      <!-- Configuration to use with the container or the deployer -->\r\n      <configuration>\r\n        <home>${project.build.directory}\/catalina-base<\/home>\r\n\t<properties>\r\n\t  <cargo.servlet.port>8080<\/cargo.servlet.port>\r\n          <!-- valid values : low, medium or high -->\r\n\t  <cargo.logging>medium<\/cargo.logging>\r\n          <cargo.protocol>http<\/cargo.protocol>\r\n\t<\/properties>\r\n      <\/configuration>\r\n\r\n      <!-- Context configuration -->\r\n      <deployables>\r\n\t<deployable>\r\n\t  <properties>\r\n\t    <context>\/<\/context>\r\n\t  <\/properties>\r\n\t<\/deployable>\r\n      <\/deployables>\r\n\r\n    <\/configuration>                \r\n  <\/plugin>\r\n\r\n(...)\r\n<\/plugins>\r\n<\/pre>\n<h1>Launch integration tests<\/h1>\n<p>When the container is started, we launch maven-failsafe-plugin goal &#8216;integration-test&#8217; at phase &#8216;integration-test&#8217;.<\/p>\n<pre lang=\"xml\">\r\n<plugins>\r\n(...)\r\n\r\n  <plugin>\r\n    <groupId>org.apache.maven.plugins<\/groupId>\r\n    <artifactId>maven-failsafe-plugin<\/artifactId>\r\n    <version>${maven-failsafe.version}<\/version>\r\n    <executions>\r\n      <execution>\r\n\t<id>integration-test<\/id>\r\n\t<goals>\r\n\t  <goal>integration-test<\/goal>\r\n\t<\/goals>\r\n     <\/execution>\r\n     <execution>\r\n       <id>verify<\/id>\r\n         <goals>\r\n\t   <goal>verify<\/goal>\r\n\t <\/goals>\r\n     <\/execution>\r\n   <\/executions>\r\n   <configuration>\r\n     <encoding>UTF-8<\/encoding>\r\n   <\/configuration>\r\n <\/plugin>\r\n\r\n(...)\r\n<\/plugins>\r\n<\/pre>\n<h1>Read More<\/h1>\n<ul>\n<li><a href=\"https:\/\/codehaus-cargo.github.io\/cargo\/Maven2+plugin.html\">cargo-maven2-plugin doc<\/a><\/li>\n<li><a href=\"https:\/\/maven.apache.org\/guides\/introduction\/introduction-to-the-lifecycle.html#Built-in_Lifecycle_Bindings\">maven build lifecycle<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Cargo maven plugin allows you to deploy your webapp in a container (tomcat, jetty, jboss, &#8230;). Here is an example that shows how to deploy your webapp in tomcat container and launch integration tests. Add cargo maven plugin We ask maven to fire the goal &#8216;start&#8217; at the phase &#8216;pre-integration-test&#8217; to start the container. This [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":884,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1995","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1995","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1995"}],"version-history":[{"count":9,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1995\/revisions"}],"predecessor-version":[{"id":2009,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1995\/revisions\/2009"}],"up":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/884"}],"wp:attachment":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}