Deployment to Tomcat with Gradle

Hi, I am new to gradle and I am migrating from maven.

Could somebody help me with deployment war to remote tomcat?
In maven I am doing it in this way and i could not find analoge for that i gradle:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>tomcat-maven-plugin</artifactId>
  <configuration>
    <server>dev</server>
    <url>http://some.remote.server:8080/manager/text</url>
    <path>/some-path</path>
  </configuration>
</plugin>

I think you best bet is the Cargo plugin. The plugin supports deployment to Tomcat via the Manager app.

1 Like

Thanks, Cargo is really good option, but I meet the problem with server credentials. In maven they are located in settings.xml and choosen for appropriate server( in my example it is dev) but in Cargo, as understand, they have to be hardcoded in build file.

Here is my cargo configuration.
And username and password must have some values but in my project I can’t just hardcode them.

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.bmuschko:gradle-cargo-plugin:2.2.3'
    }
}

apply plugin: 'com.bmuschko.cargo'

dependencies {
    cargo 'org.codehaus.cargo:cargo-core-uberjar:1.4.5',
            'org.codehaus.cargo:cargo-ant:1.4.5'
}

cargo {
    containerId = 'tomcat7x'
    port = 8080

    deployable {
        context = '/some-path'
    }

    remote {
        hostname = 'some.remote.server'
        username = ''
        password = ''
    }

You can read the credentials from something else. You don’t have to put the information into the build script as plain text. For example you could use the Gradle credentials plugin.

Thank you for your answer, it is the best option for me.