Fail Gradle Copy task if source directory not exist

前端 未结 2 903
半阙折子戏
半阙折子戏 2021-01-13 03:57

I\'m using Gradle to create a build script. I want to protect the script from wrong properties, one of the tasks in the script is simple Copy task and I notice that when I p

2条回答
  •  醉酒成梦
    2021-01-13 04:46

    This worked for me:

    task copySpecificPlatform(type: Copy) {
        from 'source/directory'
        into 'target/directory'
        if(inputs.sourceFiles.empty) throw new StopExecutionException("No files found")
    }
    

提交回复
热议问题