Copy task doesn't fail (or log) when source file is missing

Viewed 119

My Copy task copies multiple sources:

For example:

task initConfig(type: Copy) {
    from('src/main/config') {
        include '**/*.properties'
        include '**/*.xml'
        filter(ReplaceTokens, tokens: [version: '2.3.1'])
    }
    from('src/main/config') {
        exclude '**/*.properties', '**/*.xml'
    }
    from('src/main/languages') {
        rename 'EN_US_(.*)', '$1'
    }
    into 'build/target/config'
}

When one of the sources doesn't exist, the task doesn't fail nor log an error.

  1. Using "inputs.sourceFiles.empty" as a solution works just for a single source:

    Fail Gradle Copy task if source directory not exist

  2. Using assert to each source...is not an elegant solution since I have a lot of sources.

    assert file("bla bla").exists()

How can I fail the task when one of the sources is missing?

0 Answers
Related