Can I find a file with wildcards in its path?

I’m writing a task to execute OpenCover.Console.exe, and I know the general area that the file will be in, but I don’t definitely know the path. Because it’s a package downloaded into the source tree by Nuget, the version could get updated and the build script might not be updated to match. For example, the location is currently “packages/OpenCover.4.5.3207/OpenCover.Console.exe”. But if a new version comes out, and the package version is updated, the build script won’t be pointing to the correct location any more.

If I could specify

"packages/OpenCover.*/OpenCover.Console.exe"

, I’d be set, but that isn’t working. As a workaround, I think it would work if I did something like this:

FileTree tree = fileTree(dir: 'packages').matching {
        include '**/OpenCover.Console.exe'
    }

and then used the only element of the FileTree, but that feels like I’m misusing what FileTrees are intended for.

Thanks.

I would go with fileTree and the getSingleFile() method. If not there are any number of groovy/java techniques for scanning for files in a directory.

Thanks for the advice – I wasn’t sure if it were wrong in some way to go with fileTree and getSingleFile.