gradlecargo

Cargo use installed container (Local "C:\tomcat) instead of AppData/Local/Temp


I want to use local tomcat container which is already installed in c:\tomcat instead of cargo downloading container automatically in temp folder. Please help me here. What am i doing wrong?

Here is my build.gradle so far

group = "com.biw.hc"
version = "0.1.0_SNAPSHOT"

buildscript {
ext {
springBootVersion = "1.2.3.RELEASE"
tomcatVersion = "8.0.20"
logbackJaninoVersion = "2.7.8"
}
repositories {
jcenter()
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "net.saliman:gradle-cobertura-plugin:2.2.7"
classpath "com.bmuschko:gradle-cargo-plugin:2.1"
}
}

apply plugin: "spring-boot"
apply plugin: "java"
apply plugin: "groovy"
apply plugin: 'war'
apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: 'com.bmuschko.cargo'

apply plugin: "net.saliman.cobertura"

bootRepackage {
mainClass = 'com.biw.hc.admin.Application'
}

war {
archiveName 'hcadmin.war'
}

repositories {
mavenLocal()
jcenter()
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
}

dependencies {
providedRuntime "org.apache.tomcat.embed:tomcat-embed-core"
providedRuntime "org.apache.tomcat.embed:tomcat-embed-el"
providedRuntime "org.apache.tomcat.embed:tomcat-embed-logging-juli"
providedRuntime "org.apache.tomcat.embed:tomcat-embed-websocket"
providedRuntime "org.apache.tomcat:tomcat-jdbc:${tomcatVersion}"
providedRuntime "org.apache.tomcat:tomcat-juli:${tomcatVersion}"
providedRuntime "org.apache.tomcat:tomcat-dbcp:${tomcatVersion}"

compile ("org.springframework.boot:spring-boot-starter-web:${springBootVersion}") {
    exclude module: "spring-boot-starter-tomcat:${springBootVersion}"
}
compile "org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}"
compile "org.springframework.boot:spring-boot-starter-thymeleaf:${springBootVersion}"
compile "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
compile("org.codehaus.janino:janino:${logbackJaninoVersion}")

// BIW dependencies...
compile "com.biw.hc:hc-core:0.1.0-SNAPSHOT"

// security dependencies...
compile "org.springframework.boot:spring-boot-starter-security:${springBootVersion}"

// testing dependencies...
testCompile "org.codehaus.groovy:groovy-all:2.2.0"
testCompile "org.spockframework:spock-core:0.7-groovy-2.0"
testCompile "org.spockframework:spock-spring:0.7-groovy-2.0"
testCompile "org.springframework:spring-test:2.5"
testCompile "org.springframework.boot:spring-boot-starter-test:${springBootVersion}"
compile('org.codehaus.groovy.modules.http-builder:http-builder:0.5.1')

def cargoVersion = '1.4.5'
cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
      "org.codehaus.cargo:cargo-ant:$cargoVersion"
}

cargo {
containerId = 'tomcat8x'
port = 8080

deployable {
    file = file('build/libs/hcadmin.war')
    context = 'hcadmin'
}

local {
    homeDir = file('C:\\apache-tomcat-8.0.21')
    outputFile = file('build/output.log')
    containerProperties {
        property 'cargo.tomcat.webappsDirectory', 'build/libs'
    }
}
}

Solution

  • I came up with a solution like this instead of using cargo plugin

    build.mustRunAfter clean
    
    task deploy(dependsOn: ['clean', 'build', 'deployWar']) << {
        println '*********************'
        println 'hcadmin.war installed'
        println '*********************'
    }
    
    task deployWar(type: Copy) {
        from war
        into System.env.'TOMCAT_HOME' + "\\webapps"
    }