Question

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?

Was it helpful?

Solution 2

Should be done as explained here

task copyJs << {

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

    copy {
        into 'src/main/webapp/js'
        from('js') {
            include '**/*.js'
        }
    }
}

OTHER TIPS

Another option would be to use a copy task:

task copyJs(type:Copy){
    into('src/main/webapp/js')
    from('js') {
        include '**/*.js'
    }
}

This has the benefit, that the output dir is automatically created if it does not yet exists. Another benefit of using the copy task instead of the copy operation as in the answer above is, that the copy task supports incremental build execution (up-to-date checks).

regards, René

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top