private void createProGuardFile(Set<String> keepNames) throws IOException {
        JavaFileManager.Location location = StandardLocation.SOURCE_OUTPUT;
        final String relativeName = UUID.randomUUID().toString();
        FileObject resource = processingEnv.getFiler().createResource(location, "", relativeName);

        final String name = resource.getName();
        final int targetIndexOf = name.indexOf("target");
        final int buildIndexOf = name.indexOf("build");
        final String basePath;
        if (targetIndexOf > 0) {
            basePath = name.substring(0, targetIndexOf);
        } else if (buildIndexOf > 0) {
            basePath = name.substring(0, buildIndexOf);
        } else {
            basePath = "";
            System.out.println("dagger-helper: could not get base path of: \"" + name + "\"");
        }
        File file = new File(basePath, "dagger-proguard-keepnames.cfg");
        if (file.exists() && keepNames.isEmpty()) {
            return;
        }

        System.out.println("dagger-helper: generating output file " + file.getAbsolutePath());
        FileOutputStream outputStream = null;
        try {
            outputStream = new FileOutputStream(file);
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream));
            writer.write("# do not modify that file, it's rewriting on each build by dagger-proguard-helper and your changes will be removed");
            writer.newLine();
            for (String className : keepNames) {
                writer.write("-keepnames class ");
                writer.write(className);
                writer.newLine();
            }
            writer.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (outputStream != null) {
                try {
                    outputStream.close();
                } catch (IOException ignored) {
                }
            }
        }
    }