title: Cargo embedded tomcat: custom context.xml
body: <p>I am using cargo to automate war deployment on Tomcat. However, i get a trouble: i can`t replace default tomcat files with my custom as my files are copied first and then get overwritten by default. I spent hours for resolving this problem but nothing works. Here is my pom.xml</p>
  
  <pre><code>    &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
                           &lt;executions&gt;
                               &lt;execution&gt;
                                   &lt;id&gt;replace-tomcat-users-xml&lt;/id&gt;
                                   &lt;phase&gt;process-test-resources&lt;/phase&gt;
                                   &lt;goals&gt;
                                       &lt;goal&gt;copy-resources&lt;/goal&gt;
                                   &lt;/goals&gt;
                                   &lt;configuration&gt;
                                       &lt;outputDirectory&gt;${basedir}/target/apache-tomcat-${version.tomcat}/conf/&lt;/outputDirectory&gt;
                                       &lt;resources&gt;
                                           &lt;resource&gt;
                                               &lt;directory&gt;src/test/resources/&lt;/directory&gt;
                                               &lt;includes&gt;
                                                   &lt;include&gt;context.xml&lt;/include&gt;
                                               &lt;/includes&gt;
                                           &lt;/resource&gt;
                                       &lt;/resources&gt;
                                   &lt;/configuration&gt;
                               &lt;/execution&gt;
                               &lt;execution&gt;
                                   &lt;id&gt;replace-tomcat-users-xml-cargo&lt;/id&gt;
                                   &lt;phase&gt;process-test-resources&lt;/phase&gt;
                                   &lt;goals&gt;
                                       &lt;goal&gt;copy-resources&lt;/goal&gt;
                                   &lt;/goals&gt;
                                   &lt;configuration&gt;
                                       &lt;outputDirectory&gt;${basedir}/target/cargo/installs/tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}&lt;/outputDirectory&gt;
                                       &lt;resources&gt;
                                           &lt;resource&gt;
                                               &lt;directory&gt;src/test/resources/&lt;/directory&gt;
                                               &lt;includes&gt;
                                                   &lt;include&gt;context.xml&lt;/include&gt;
                                               &lt;/includes&gt;
                                           &lt;/resource&gt;
                                       &lt;/resources&gt;
                                   &lt;/configuration&gt;
                               &lt;/execution&gt;
                           &lt;/executions&gt;
                       &lt;/plugin&gt;
  </code></pre>
  
  <p>and here is cargo using:</p>
  
  <pre><code>&lt;plugin&gt;
                         &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt;
                         &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt;
                         &lt;version&gt;1.4.11&lt;/version&gt;
                         &lt;configuration&gt;
                             &lt;skip&gt;false&lt;/skip&gt;
                             &lt;container&gt;
                                 &lt;containerId&gt;tomcat7x&lt;/containerId&gt;
                                 &lt;log&gt;${project.build.directory}/cargo.log&lt;/log&gt;
                                 &lt;artifactInstaller&gt;
                                     &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                                     &lt;artifactId&gt;tomcat&lt;/artifactId&gt;
                                     &lt;version&gt;${version.tomcat}&lt;/version&gt;
                                     &lt;type&gt;zip&lt;/type&gt;
                                 &lt;/artifactInstaller&gt;
                                 &lt;systemProperties&gt;
                                     &lt;tomcat.home.dir&gt;
                                         ${basedir}/target/cargo/installs/apache-tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}
                                     &lt;/tomcat.home.dir&gt;
                                     &lt;tomcat.server.home.dir&gt;
                                         ${basedir}/target/cargo/installs/apache-tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}
                                     &lt;/tomcat.server.home.dir&gt;
                                 &lt;/systemProperties&gt;
                                 &lt;dependencies&gt;
                                     &lt;dependency&gt;
                                         &lt;groupId&gt;mysql&lt;/groupId&gt;
                                         &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
                                     &lt;/dependency&gt;
                                 &lt;/dependencies&gt;
                             &lt;/container&gt;
                             &lt;configuration&gt;
  
                                 &lt;configfile&gt;
                                     &lt;file&gt;${basedir}/target/cargo/installs/context.xml&lt;/file&gt;
                                     &lt;todir&gt;conf/&lt;/todir&gt;
                                     &lt;tofile&gt;context.xml&lt;/tofile&gt;
                                     &lt;configfile&gt;true&lt;/configfile&gt;
                                     &lt;overwrite&gt;true&lt;/overwrite&gt;
                                 &lt;/configfile&gt;
                                 &lt;properties&gt;
                                     &lt;cargo.servlet.port&gt;8080&lt;/cargo.servlet.port&gt;
                                     &lt;!--Тут менять--&gt;
                                     &lt;cargo.servlet.users&gt;admin:admin:manager-script&lt;/cargo.servlet.users&gt;
                                     &lt;cargo.jvmargs&gt;
                                         -Xmx1024m -XX:MaxPermSize=512m
                                         -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
                                         -Xnoagent
                                         -Djava.compiler=NONE
                                     &lt;/cargo.jvmargs&gt;&lt;/properties&gt;
                             &lt;/configuration&gt;
  </code></pre>