Java 执行任务的动态渐变命令失败

Java 执行任务的动态渐变命令失败,java,gradle,aws-lambda,Java,Gradle,Aws Lambda,我正在尝试将Lambda zip文件发布到s3-s3://my aws Lambda//[release | SNAPSHOT]/。下面定义的任务,publishToS3失败并显示消息 Caused by: java.io.FileNotFoundException: /Users/me/my-lambda/build/distributions 当我跑的时候 ./gradlew clean build -x test -x release 谢谢你的帮助。谢谢 task buildZip(t

我正在尝试将Lambda zip文件发布到s3-
s3://my aws Lambda//[release | SNAPSHOT]/
。下面定义的任务,
publishToS3
失败并显示消息

Caused by: java.io.FileNotFoundException: /Users/me/my-lambda/build/distributions
当我跑的时候

./gradlew clean build -x test -x release
谢谢你的帮助。谢谢

task buildZip(type: Zip) {
    from compileJava
    from processResources
    into('lib') {
        from configurations.runtimeClasspath
    }
}

task publishToS3(type: Exec, dependsOn: buildZip) {
    onlyIf { file("${project.buildDir}/distributions").exist() }

    def artifacts = new FileNameByRegexFinder().getFileNames("${project.buildDir}/distributions", /.*\.zip/)
    assert artifacts.size() == 1

    def isSnapShot = artifacts[0].endsWith('-SNAPSHOT.zip')

    def releaseCmd = ("aws s3 cp " +
            "${artifacts[0]} " +
            "s3://my-aws-lambdas/${project.name}/${isSnapShot ? 'SNAPSHOT' : 'release'}/ ").trim().tokenize(' ') as List

    workingDir "${project.buildDir}/distributions"

    commandLine releaseCmd
}

build.dependsOn buildZip

如果您在UNIX环境中,可以使用
find
命令搜索文件并使用其输出

task scanFiles() {
    def a= "find ${project.buildDir} -name *.zip".execute().text
    String[] files=a.split('\n')
    if(files.length == 1){
        println("We'v got a file :"+a)
    }
    else if(files.length ==0){
        println("We've not no files ")
    }
    else{
        println("We've got multiple files\n"+a)
    }
}


您是否尝试过打印
releaseCmd
字符串?输出是什么?错误发生在
def artifacts=new FileNameByRegexFinder().getFileNames(${project.buildDir}/distributions“,/.\.zip/)
,因此无法解析该值。