public void run()

in winegrower-extension/winegrower-build/winegrower-build-common/src/main/java/org/apache/winegrower/extension/build/common/Build.java [52:113]


    public void run() {
        final File distroFolder = new File(configuration.workDir, configuration.artifactId + "-winegrower-distribution");
        if (distroFolder.exists()) {
            delete(distroFolder);
        }

        Stream.of("bin", "conf", "logs", "lib").forEach(i -> new File(distroFolder, i).mkdirs());

        for (final String ext : asList("sh", "bat")) {
            try (final BufferedReader reader = new BufferedReader(new InputStreamReader(
                    Thread.currentThread().getContextClassLoader().getResourceAsStream("bin/winegrower." + ext)))) {
                write(new File(distroFolder, "bin/winegrower." + ext), StringSubstitutor.replace(reader.lines().collect(joining("\n")),
                        new HashMap<String, String>() {{
                            put("main", configuration.main);
                        }}));
            } catch (final IOException e) {
                throw new IllegalStateException(e.getMessage(), e);
            }
        }

        copyProvidedFiles(configuration.basedir, distroFolder);

        Stream.of("conf", "logs").forEach(folder ->
                write(new File(distroFolder, folder + "/you_can_safely_delete.txt"), "Just there to not loose the folder cause it is empty, you can safely delete."));

        configuration.jars.forEach(it -> addLib(distroFolder, it));

        final Path prefix = configuration.skipArchiveRootFolder ? distroFolder.toPath() : distroFolder.getParentFile().toPath();
        for (final String format : configuration.formats) {
            final File output = new File(configuration.workDir, configuration.artifactId + "-winegrower-distribution." + format);

            switch (format.toLowerCase(ENGLISH)) {
                case "tar.gz":
                    try (final TarArchiveOutputStream tarGz =
                                 new TarArchiveOutputStream(new GZIPOutputStream(new FileOutputStream(output)))) {
                        tarGz.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
                        for (final String entry : distroFolder.list()) {
                            tarGz(tarGz, new File(distroFolder, entry), prefix);
                        }
                    } catch (final IOException e) {
                        throw new IllegalStateException(e.getMessage(), e);
                    }
                    break;
                case "zip":
                    try (final ZipArchiveOutputStream zos =
                                 new ZipArchiveOutputStream(new FileOutputStream(output))) {
                        for (final String entry : distroFolder.list()) {
                            zip(zos, new File(distroFolder, entry), prefix);
                        }
                    } catch (final IOException e) {
                        throw new IllegalStateException(e.getMessage(), e);
                    }
                    break;
                default:
                    throw new IllegalArgumentException(format + " is not supported");
            }
        }

        if (!configuration.keepExplodedFolder) {
            delete(distroFolder);
        }
    }