Gradle Cargo tomcat deployment problem

Cargo is a Gradle plugin that can automatically deploy your application. But there some problems with it.

The first one is its hard to use in Eclipse, this plugin is designed to be used in a console, when you run the cargoRunLocal task, there are no ways to stop it in Eclipse, the task print a message in Eclipse console output as Press Ctrl-C to stop the container.... Its impossible to do in Eclipse.

Another problem is it doesn't allow you to set tomcat-users.xml which you must configure to be able to use the Tomcat GUI manager feature.

By default the application is deployed to a temp folder, for example

 
C:\Users\username\AppData\Local\Temp\cargo\conf
 

And each time the container is started, the tomcat-users.xml is overwrite. Gives no chances to change it.

And its hard to find any useful documentation about the issue with using Tomcat GUI manager in Cargo.

The circle of development and deployment with cargo in Eclipse is cumbersome. The automation is not actually very useful, and its very slow.

Here is what I do, I don't use cargo to tart and stop Tomcat server, I can goto the bin folder of Tomcat and execute catalina.bat run, the only thing I need to automate is copy the war file to C:\workspace3.8\SpringMVCExample\build\extract\apache-tomcat-7.0.30\apache-tomcat-7.0.30\webapps.

So I would like my build task do all the things it used to do, but at the end, it should copy the war file to Tomcat, and I can manually start Catalina server in command line. In my experience, start Catalina in command line is much faster than using cargo task.

Add those lines to gradle.build

 
task finalize << {
    println('after build')
    copy{
        from "${buildDir}\\libs"
        into "$buildDir/extract\\apache-tomcat-7.0.30\\apache-tomcat-7.0.30\\webapps"
        include '*.war'
      }
}
 
build.finalizedBy(finalize)
 

Another thing to notice is, changing JSP file needs to restart Tomcat, if you only changes java file, when you build, it will be updated.

See also: