How to force Intellij to use my gradle task for build and deploy?

Hi!

I am trying to run tomcat webapp inside Intellij IDEA. The problem is that I have my custom task inside build.gradle, which is:

processResources.dependsOn("copyProperties")
task copyProperties(type: Copy) {
    from 'src/main/resources/properties'
    into 'build/resources/main'
    include(PROPERTIES_FILE)
    rename(PROPERTIES_FILE, 'application.properties')
    includeEmptyDirs = false
}

Intellij never calls it and I get Exception during application startup because the resource file is missing.

Thanks in advance for help, Artur