@Override
    public void buildFunctionIfNecessary(FunctionConf functionConf) {
        // Snapshot the directory before installing dependencies
        List<Path> beforeSnapshot = getDirectorySnapshot(functionConf);
        loggingHelper.logInfoWithName(log, functionConf.getFunctionName(), "Copying Greengrass SDK");
        copySdk(log, functionConf, resourceHelper, ioHelper);
        if (hasDependencies(functionConf.getBuildDirectory())) {
            loggingHelper.logInfoWithName(log, functionConf.getFunctionName(), "Installing Python dependencies");
            installDependencies(functionConf);
        }
        // Snapshot the directory after installing dependencies
        List<Path> afterSnapshot = getDirectorySnapshot(functionConf);
        List<Path> addedFiles = new ArrayList<>(afterSnapshot);
        addedFiles.removeAll(beforeSnapshot);
        loggingHelper.logInfoWithName(log, functionConf.getFunctionName(), "Packaging function for AWS Lambda");
        File tempFile = Try.of(() -> ioHelper.getTempFile("python-lambda-build", "zip")).get();
        // Get the directories, longest named directories first
        List<Path> addedDirectories = addedFiles
                .stream()
                .filter(path -> path.toFile().isDirectory())
                .sorted(Comparator.comparingInt(path -> path.toString().length()).reversed())
                .collect(Collectors.toList());
        // Get the possible Python directories (don't include *dist-info and bin)
        // NOTE: This is an esoteric fix for Zope being broken which breaks Twisted - https://github.com/kpdyer/fteproxy/issues/66
        List<Path> possibleBrokenPythonDirectories = addedDirectories
                .stream()
                .filter(path -> !path.toString().endsWith(DIST_INFO))
                .filter(path -> !path.toString().endsWith(BIN))
                .filter(path -> !path.resolve(INIT_PY).toFile().exists())
                .collect(Collectors.toList());
        // "Touch" the file to fix this issue
        possibleBrokenPythonDirectories.stream()
                .map(path -> path.resolve(INIT_PY).toFile())
                .forEach(this::touchAndIgnoreExceptions);
        ZipUtil.pack(functionConf.getBuildDirectory().toFile(), tempFile);
        moveDeploymentPackage(functionConf, tempFile);
    }
@Override
    public void buildFunctionIfNecessary(FunctionConf functionConf) {
       
        List<Path> beforeSnapshot = getDirectorySnapshot(functionConf);
        loggingHelper.logInfoWithName(log, functionConf.getFunctionName(), "Copying Greengrass SDK");
        copySdk(log, functionConf, resourceHelper, ioHelper);
        if (hasDependencies(functionConf.getBuildDirectory())) {
            loggingHelper.logInfoWithName(log, functionConf.getFunctionName(), "Installing Python dependencies");
            installDependencies(functionConf);
        }
       
        List<Path> afterSnapshot = getDirectorySnapshot(functionConf);
        List<Path> addedFiles = new ArrayList<>(afterSnapshot);
        addedFiles.removeAll(beforeSnapshot);
        loggingHelper.logInfoWithName(log, functionConf.getFunctionName(), "Packaging function for AWS Lambda");
        File tempFile = Try.of(() -> ioHelper.getTempFile("python-lambda-build", "zip")).get();
       
        List<Path> addedDirectories = addedFiles
                .stream()
                .filter(path -> path.toFile().isDirectory())
                .sorted(Comparator.comparingInt(path -> path.toString().length()).reversed())
                .collect(Collectors.toList());
       
       
        List<Path> possibleBrokenPythonDirectories = addedDirectories
                .stream()
                .filter(path -> !path.toString().endsWith(DIST_INFO))
                .filter(path -> !path.toString().endsWith(BIN))
                .filter(path -> !path.resolve(INIT_PY).toFile().exists())
                .collect(Collectors.toList());
       
        possibleBrokenPythonDirectories.stream()
                .map(path -> path.resolve(INIT_PY).toFile())
                .forEach(this::touchAndIgnoreExceptions);
        ZipUtil.pack(functionConf.getBuildDirectory().toFile(), tempFile);
        moveDeploymentPackage(functionConf, tempFile);
    }
@override public void buildfunctionifnecessary(functionconf functionconf) { list<path> beforesnapshot = getdirectorysnapshot(functionconf); logginghelper.loginfowithname(log, functionconf.getfunctionname(), "copying greengrass sdk"); copysdk(log, functionconf, resourcehelper, iohelper); if (hasdependencies(functionconf.getbuilddirectory())) { logginghelper.loginfowithname(log, functionconf.getfunctionname(), "installing python dependencies"); installdependencies(functionconf); } list<path> aftersnapshot = getdirectorysnapshot(functionconf); list<path> addedfiles = new arraylist<>(aftersnapshot); addedfiles.removeall(beforesnapshot); logginghelper.loginfowithname(log, functionconf.getfunctionname(), "packaging function for aws lambda"); file tempfile = try.of(() -> iohelper.gettempfile("python-lambda-build", "zip")).get(); list<path> addeddirectories = addedfiles .stream() .filter(path -> path.tofile().isdirectory()) .sorted(comparator.comparingint(path -> path.tostring().length()).reversed()) .collect(collectors.tolist()); list<path> possiblebrokenpythondirectories = addeddirectories .stream() .filter(path -> !path.tostring().endswith(dist_info)) .filter(path -> !path.tostring().endswith(bin)) .filter(path -> !path.resolve(init_py).tofile().exists()) .collect(collectors.tolist()); possiblebrokenpythondirectories.stream() .map(path -> path.resolve(init_py).tofile()) .foreach(this::touchandignoreexceptions); ziputil.pack(functionconf.getbuilddirectory().tofile(), tempfile); movedeploymentpackage(functionconf, tempfile); }