문제

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?

도움이 되었습니까?

해결책 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'
        }
    }
}

다른 팁

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é

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top