Add files to conf directory from IntelliJ

I have some JasperReports I want to persist.

At the moment I have to save them in the \deploy\tomcat\conf\app-core\reports directory and access them with:

stream = resources.getResourceAsStream("/reports/myreport.jrxml")

Every time the app is started it obviously rebuilds the tomcat directories.

Is it possible to have them in a folder within intelliJ and have them created each time the app is deployed?

You can add some action to the end of any Gradle task including deploy, for example:

task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
    appName = 'app-core'
    appJars('app-global', 'app-core')
}

deploy.doLast {
    copy {
        from "$rootProject.rootDir/etc/foo.txt"
        into "$cuba.tomcat.dir/conf/app-core"
    }
}

Also notice that deploy task depends on clearConf, so the whole content of conf is cleared except the files listed in the task’s exclude parameter.

Awesome, thanks Konstantin that works perfectly.
I noticed that if I create a folder in my project folder, e.g. E:/Cuba/MyProject/MyFolder it will copy all contents to the conf/app-core directory upon build which works better for me (so I don’t have to do it for every file, but instead copy all files from the folder).

deploy.doLast { 
    copy { 
        from "E:/Cuba/MyProject/MyFolder" 
        into "$cuba.tomcat.dir/conf/app-core" 
    } 
} 

Thanks again!

Sure, you can find a lot of options in Gradle docs: https://docs.gradle.org/3.4/javadoc/org/gradle/api/file/CopySpec.html