Search code examples
javagradlecatalina

configure catalina.properties gradle project


I have a Gradle Project, and I need add to the catalina.properties file:

org.apache.catalina.startup.ContextConfig.jarsToSkip=bcprov*.jar

But I don't know where I can find this file in my gradle project.


Solution

  • It's not clear if you are using gradle-tomcat plugin or not, but if you are: you could create a task that copy the catalina.propetiesconfig file to the temporary Tomcat directory, and make the tomcatRun depends on this task. The catalina.properties file could be stored in your project resources , e.g.: in src/main/conf

    ext{
        // path to catalina.properties in your project
        catalinaPropertiesPath = 'src/main/conf/catalina.properties'
    
        // path to temporary directory used by gradle-tomcat plugin
        tomcatTmpRunDir = "$buildDir/tmp/tomcatRun/conf"
    }
    
    // copy catalina.properties conf file
    task copyCatalinaProperties(type: Copy){
        from( catalinaPropertiesPath)
        into(tomcatTmpRunDir)
    
    }
    
    // create task dependency
    tomcatRun.dependsOn copyCatalinaProperties
    

    ( based on solution given here : https://stackoverflow.com/a/15069636/6899896 )