I have a custom task in a sub project build script in Groovy. It uses a third party library components FileUtils from commons-io. In my build script I’m getting the following error on the import line: unable to resolve class org.apache.commons.io.FileUtils.
The script is in a sub project. I tried adding the following to the sub project script without success:
apply pluing: ‘java’
apply plugin: ‘war’
buildScript {
dependencies {
classpath gradleApi()
classpath localGroovy()
classpath ‘commons-io:commons-io:2.0.1’
}
}
import org.apache.commons.io.FileUtils
class IncrementalSync extends DefaultTask {
@InputFiles
def FileCollection src
@OutputDirectory
def File destination
@TaskAction
void execute(IncrementalTaskInputs inputs) {
if (!inputs.incremental) {
FileUtils.forceDelete(destination)
}
inputs.outOfDate({ change ->
FileUtils.copyFile(change.file, targetFile(change.file))
} as Action)
inputs.removed({ change ->
FileUtils.forceDelete(targetFile(change.file))
} as Action)
}
def targetFile(def inputFile) {
new File(destination, change.file.name)
}
}