Package co.tomlee.gradle.plugins.release

Examples of co.tomlee.gradle.plugins.release.ReleaseConvention


    public static ReleaseConvention releaseConvention(final Project project) {
        return (ReleaseConvention) project.getConvention().getByName("release");
    }

    public static String getVersion(final Project project) throws IOException {
        final ReleaseConvention releaseConvention = releaseConvention(project);

        String version = findProperty(project, "gradle.release.thisVersion", null);
        if (StringUtils.isEmpty(version)) {
            final File propertiesFile = project.file(releaseConvention.getPropertiesFile());
            final Properties properties = new Properties();
            try (final FileReader reader = new FileReader(propertiesFile)) {
                properties.load(reader);
            }
            version = properties.getProperty(releaseConvention.getVersionProperty());
            if (StringUtils.isEmpty(version)) {
                throw new IllegalStateException("No version number found in " + propertiesFile);
            }
        }
        return version;
View Full Code Here


        }
        return version;
    }

    public static void setVersion(final Project project, final String newVersion) throws IOException {
        final ReleaseConvention releaseConvention = releaseConvention(project);

        final String propertiesFilePath = releaseConvention.getPropertiesFile();
        final File propertiesFile = project.file(propertiesFilePath);

        project.setVersion(newVersion);

        try {
            project.getAnt().invokeMethod("replaceregexp", ImmutableMap.<String, Object>of(
                    "file", propertiesFile,
                    "match", "^(\\s*)" + Pattern.quote(releaseConvention.getVersionProperty()) + "(\\s*)=(\\s*)" + Pattern.quote(getVersion(project)),
                    "replace", "\\1" + releaseConvention.getVersionProperty() + "\\2=\\3" + newVersion,
                    "byline", true));
        }
        catch (BuildException e) {
            throw new GradleException("Unable to set new version in properties file", e);
        }
View Full Code Here

        return (Git) project.getExtensions().getByName(ReleasePlugin.GIT_PROPERTY);
    }

    public static void commitPropertiesFile(final Project project, final String commitMessage) throws Exception {
        final Git git = git(project);
        final ReleaseConvention releaseConvention = releaseConvention(project);
        git.commit()
                .setOnly(releaseConvention.getPropertiesFile())
                .setMessage(commitMessage)
                .call();
    }
View Full Code Here

        String version = getVersion(getProject());
        if (version.endsWith("-SNAPSHOT")) {
            version = getThisVersionWithoutSnapshot(getProject());
            setVersion(getProject(), version);

            final ReleaseConvention releaseConvention = releaseConvention(getProject());
            final String commitMessage =
                MessageFormat.format(releaseConvention.getPreTagCommitMessage(), version);
            commitPropertiesFile(getProject(), commitMessage);
        }
    }
View Full Code Here

TOP

Related Classes of co.tomlee.gradle.plugins.release.ReleaseConvention

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.