Search code examples
antgradleantbuilder

gradle - multiple module project - ant wrong execution dir


I've a multiple module projecy managed by gradle. The directory structure is as follows:

  • monitoring
    • client
    • server

When I invoke 'gradle war' on monitoring level I obtain the following exeception:

"monitoring/js does not exist."

Which comes from client's build.gradle:

task copyJs << {

     'mkdir src/main/webapp/js'.execute()

     def ant = new groovy.util.AntBuilder()
     ant.copy(todir: 'src/main/webapp/js') {
          fileset(dir: 'js') {
               include(name: '**/*.js')
          }
     }
}

The exception occurs because the mentioned task is executed on the root level of the project. How to change it to be executed on the appropriate (client) level? How to change the basedir for the ant task that is used?


Solution

  • Should be done as explained here

    task copyJs << {
    
        file('src/main/webapp/js').mkdir()
    
        copy {
            into 'src/main/webapp/js'
            from('js') {
                include '**/*.js'
            }
        }
    }