public static void main()

in src/main/java/org/apache/openejb/tools/release/cmd/AddVersion.java [61:105]


    public static void main(final String[] args) throws Exception {
        boolean setSnapshot = false;
        if (args.length > 0 && "set-snapshot".equals(args[0])) {
            setSnapshot = true;
        }

        boolean replaceSnapshot = false;
        if (args.length > 0 && "replace-snapshot".equals(args[0])) {
            replaceSnapshot = true;
        }

        final File workingDir = new File(Release.builddir, Release.openejbVersionName);
        final String[][] replacements = new String[][]{
                new String[]{currentVersion(Release.openejbVersion, replaceSnapshot),
                        nextVersion("openejb next version", Release.openejbVersion, replaceSnapshot, setSnapshot)},
                new String[]{currentVersion(Release.tomeeVersion, replaceSnapshot),
                        nextVersion("openejb next version", Release.tomeeVersion, replaceSnapshot, setSnapshot)}
        };

        // we hardcode the tomee or openejb version in some java, properties, pom (of course ;))...so simply take eveything we can
        // filtering image we have (gif and png) and win exe
        // .svn and target folders are ignored too
        final Collection<File> files = FileUtils.listFiles(workingDir,
                new AndFileFilter(
                        new AndFileFilter(
                                new NotFileFilter(new SuffixFileFilter(".gif", IOCase.INSENSITIVE)),
                                new NotFileFilter(new SuffixFileFilter(".png", IOCase.INSENSITIVE))),
                        new NotFileFilter(new SuffixFileFilter(".exe", IOCase.INSENSITIVE))
                ),
                new AndFileFilter(
                        new NotFileFilter(new NameFileFilter(".svn", IOCase.INSENSITIVE)),
                        new NotFileFilter(new NameFileFilter("target", IOCase.INSENSITIVE)))
        );

        for (final File file : files) {
            for (final String[] replacement : replacements) {
                final CountingFixedStringValueTokenHandler handlerCounting = new CountingFixedStringValueTokenHandler(replacement[1]);
                update(file, new FixedTokenReplacementInputStream(IO.read(file), replacement[0], handlerCounting));
                final int nbReplacements = handlerCounting.getReplacements();
                if (nbReplacements > 0) {
                    System.out.println(String.format("replaced %d times %s => %s in %s", nbReplacements, replacement[0], replacement[1], file.getPath()));
                }
            }
        }
    }