Examples of ReleaseConvention


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

    @TaskAction
    public void rollback() throws Exception {
        final Git git = git(getProject());
        final Repository repo = repository(getProject());
        final ReleaseConvention releaseConvention = releaseConvention(getProject());

        final File transactionFile = new File(repo.getDirectory().getParentFile(), ".releaseTransaction");
        final BufferedReader reader;
        try {
            reader = new BufferedReader(new FileReader(transactionFile));
        }
        catch (FileNotFoundException e) {
            log.info("No transaction in progress");
            return;
        }
        final String line = reader.readLine();
        final String[] parts = line.split(";", 2);
        final String sha = parts[0];
        final String version = parts[1];

        final String tag = MessageFormat.format(releaseConvention.getTagFormat(), version);
        if (repo.resolve(tag) != null) {
            log.info("Deleting tag: " + tag);
            git.tagDelete().setTags(tag).call();
        }
View Full Code Here

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

public class ReleaseEnsureCleanWorkspaceTask extends DefaultTask {
    private static final Logger log = Logging.getLogger(ReleaseEnsureCleanWorkspaceTask.class);

    @TaskAction
    public void release() throws Exception {
        final ReleaseConvention releaseConvention = releaseConvention(getProject());

        if (releaseConvention.isEnsureWorkspaceClean()) {
            final Repository repo = repository(getProject());
            final Git git = new Git(repo);

            if (git.status().call().hasUncommittedChanges()) {
                throw new ReleaseException("The working tree has uncommitted changes");
View Full Code Here

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.version", 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

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

        }
        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*).*",
                    "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

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

        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

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

import static co.tomlee.gradle.plugins.release.tasks.TaskHelpers.*;

public class ReleaseNextVersionTask extends DefaultTask {
    @TaskAction
    public void updateVersion() throws Exception {
        final ReleaseConvention releaseConvention = releaseConvention(getProject());

        String version = findProperty(getProject(), "gradle.release.nextVersion", null);
        final String nextVersion;
        if (StringUtils.isEmpty(version)) {
            version = getVersionWithoutSnapshot(getProject());
            final String[] parts = version.split("\\.");
            final int last = Integer.parseInt(parts[parts.length - 1]);
            final StringBuilder sb = new StringBuilder();
            for (int i = 0; i < parts.length - 1; i++) {
                sb.append(parts[i]).append(".");
            }
            sb.append(last + 1);
            if (releaseConvention.isUsingSnapshots()) {
                sb.append("-SNAPSHOT");
            }
            nextVersion = sb.toString();
        }
        else {
            nextVersion = version;
        }
        setVersion(getProject(), nextVersion);

        final Git git = git(getProject());

        if (git.status().call().hasUncommittedChanges()) {
            final String commitMessage =
                    MessageFormat.format(releaseConvention.getNextVersionCommitMessageFormat(), nextVersion);
            commitPropertiesFile(getProject(), commitMessage);
        }
    }
View Full Code Here

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

import static co.tomlee.gradle.plugins.release.tasks.TaskHelpers.*;

public class ReleaseTagTask extends DefaultTask {
    @TaskAction
    public void tag() throws Exception {
        final ReleaseConvention releaseConvention = releaseConvention(getProject());
        final Git git = git(getProject());

        git.tag().setName(MessageFormat.format(releaseConvention.getTagFormat(), getVersion(getProject()))).call();
    }
View Full Code Here

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

        }
        setVersion(getProject(), commitVersion);

        final Git git = git(getProject());
        if (git.status().call().hasUncommittedChanges()) {
            final ReleaseConvention releaseConvention = releaseConvention(getProject());
            final String commitMessage =
                MessageFormat.format(releaseConvention.getThisVersionCommitMessageFormat(), version);
            commitPropertiesFile(getProject(), commitMessage);
        }
    }
View Full Code Here

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

        }
        setVersion(getProject(), commitVersion);

        final Git git = git(getProject());
        if (git.status().call().hasUncommittedChanges()) {
            final ReleaseConvention releaseConvention = releaseConvention(getProject());
            final String commitMessage =
                MessageFormat.format(releaseConvention.getThisVersionCommitMessageFormat(), commitVersion);
            commitPropertiesFile(getProject(), commitMessage);
        }
    }
View Full Code Here

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

        else {
            nextVersion = version;
        }
        setVersion(getProject(), nextVersion);

        final ReleaseConvention releaseConvention = releaseConvention(getProject());
        final String commitMessage =
            MessageFormat.format(releaseConvention.getNextSnapshotCommitMessage(), nextVersion);
        commitPropertiesFile(getProject(), commitMessage);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.