Search in sources :

Example 6 with ShipkitConfiguration

use of org.shipkit.gradle.configuration.ShipkitConfiguration in project shipkit by mockito.

the class UploadGistsPlugin method apply.

@Override
public void apply(final Project project) {
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    TaskMaker.task(project, UPLOAD_GISTS_TASK, UploadGistsTask.class, new Action<UploadGistsTask>() {

        @Override
        public void execute(UploadGistsTask uploadGistsTask) {
            uploadGistsTask.setDescription("Uploads to Gist files provided by 'filesToUpload' task property.");
            uploadGistsTask.setGitHubApiUrl(conf.getGitHub().getApiUrl());
            uploadGistsTask.setGitHubWriteToken(conf.getLenient().getGitHub().getWriteAuthToken());
        }
    });
}
Also used : ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) UploadGistsTask(org.shipkit.internal.gradle.release.tasks.UploadGistsTask)

Example 7 with ShipkitConfiguration

use of org.shipkit.gradle.configuration.ShipkitConfiguration in project shipkit by mockito.

the class GitPlugin method apply.

public void apply(final Project project) {
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    TaskMaker.task(project, GIT_COMMIT_TASK, GitCommitTask.class, new Action<GitCommitTask>() {

        public void execute(final GitCommitTask t) {
            t.setDescription("Commits all changed files using generic --author and aggregated commit message");
            t.setGitUserName(conf.getGit().getUser());
            t.setGitUserEmail(conf.getGit().getEmail());
            t.setCommitMessagePostfix(conf.getGit().getCommitMessagePostfix());
        }
    });
    TaskMaker.task(project, GIT_TAG_TASK, ShipkitExecTask.class, new Action<ShipkitExecTask>() {

        public void execute(final ShipkitExecTask t) {
            t.mustRunAfter(GIT_COMMIT_TASK);
            final String tag = GitUtil.getTag(conf, project);
            t.setDescription("Creates new version tag '" + tag + "'");
            t.execCommand(execCommand("Creating tag", "git", "tag", "-a", tag, "-m", GitUtil.getCommitMessage("Created new tag " + tag, conf.getGit().getCommitMessagePostfix())));
        }
    });
    TaskMaker.task(project, GIT_PUSH_TASK, GitPushTask.class, new Action<GitPushTask>() {

        public void execute(final GitPushTask t) {
            t.setDescription("Pushes automatically created commits to remote repo.");
            t.mustRunAfter(GIT_COMMIT_TASK);
            t.mustRunAfter(GIT_TAG_TASK);
            t.dependsOn(GitBranchPlugin.IDENTIFY_GIT_BRANCH);
            t.getTargets().add(GitUtil.getTag(conf, project));
            t.setDryRun(conf.isDryRun());
            GitUrlInfo info = new GitUrlInfo(conf);
            t.setUrl(info.getGitUrl());
            t.setSecretValue(info.getWriteToken());
            project.getPlugins().apply(GitBranchPlugin.class).provideBranchTo(t, new Action<String>() {

                @Override
                public void execute(String branch) {
                    t.getTargets().add(branch);
                }
            });
        }
    });
    final Task performPush = TaskMaker.task(project, PERFORM_GIT_PUSH_TASK, Task.class, new Action<Task>() {

        public void execute(final Task t) {
            t.setDescription("Performs gitCommit, gitTag and gitPush tasks and all tasks dependent on them.");
            t.dependsOn(GIT_COMMIT_TASK, GIT_TAG_TASK, GIT_PUSH_TASK);
        }
    });
    TaskMaker.task(project, PERFORM_GIT_COMMIT_CLEANUP_TASK, Task.class, new Action<Task>() {

        public void execute(final Task t) {
            t.setDescription("Performs " + SOFT_RESET_COMMIT_TASK + " and " + GIT_STASH_TASK + " tasks.");
            t.dependsOn(SOFT_RESET_COMMIT_TASK, GIT_STASH_TASK);
            t.mustRunAfter(performPush);
        }
    });
    TaskMaker.task(project, GIT_STASH_TASK, ShipkitExecTask.class, new Action<ShipkitExecTask>() {

        public void execute(final ShipkitExecTask t) {
            t.setDescription("Stashes current changes");
            t.execCommand(execCommand("Stashing changes", "git", "stash"));
            t.mustRunAfter(SOFT_RESET_COMMIT_TASK);
        }
    });
    TaskMaker.task(project, SOFT_RESET_COMMIT_TASK, ShipkitExecTask.class, new Action<ShipkitExecTask>() {

        public void execute(final ShipkitExecTask t) {
            t.setDescription("Removes last commit, using 'reset --soft HEAD~'");
            t.execCommand(execCommand("Removing last commit", "git", "reset", "--soft", "HEAD~"));
        }
    });
    TaskMaker.task(project, TAG_CLEANUP_TASK, ShipkitExecTask.class, new Action<ShipkitExecTask>() {

        public void execute(final ShipkitExecTask t) {
            t.setDescription("Deletes version tag '" + getTag(conf, project) + "'");
            t.execCommand(execCommand("Deleting version tag", "git", "tag", "-d", getTag(conf, project)));
            t.mustRunAfter(performPush);
        }
    });
}
Also used : Action(org.gradle.api.Action) ShipkitExecTask(org.shipkit.gradle.exec.ShipkitExecTask) IdentifyGitBranchTask(org.shipkit.gradle.git.IdentifyGitBranchTask) GitCommitTask(org.shipkit.gradle.git.GitCommitTask) Task(org.gradle.api.Task) GitPushTask(org.shipkit.gradle.git.GitPushTask) ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) ShipkitExecTask(org.shipkit.gradle.exec.ShipkitExecTask) GitPushTask(org.shipkit.gradle.git.GitPushTask) GitCommitTask(org.shipkit.gradle.git.GitCommitTask)

Example 8 with ShipkitConfiguration

use of org.shipkit.gradle.configuration.ShipkitConfiguration in project shipkit by mockito.

the class ComparePublicationsPlugin method apply.

@Override
public void apply(final Project project) {
    project.getPlugins().apply(JavaPublishPlugin.class);
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    final Jar sourcesJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.SOURCES_JAR_TASK);
    String basePreviousVersionArtifactPath = getBasePreviousVersionArtifactPath(project, conf, sourcesJar);
    final File previousSourcesJar = new File(basePreviousVersionArtifactPath + "-sources.jar");
    final CreateDependencyInfoFileTask dependencyInfoTask = TaskMaker.task(project, "createDependencyInfoFile", CreateDependencyInfoFileTask.class, new Action<CreateDependencyInfoFileTask>() {

        @Override
        public void execute(final CreateDependencyInfoFileTask task) {
            task.setDescription("Creates a file with all declared runtime dependencies.");
            task.setOutputFile(new File(project.getBuildDir(), DEPENDENCY_INFO_FILENAME));
            task.setConfiguration(project.getConfigurations().getByName("runtimeClasspath"));
            task.setProjectVersion(project.getVersion().toString());
            DeferredConfiguration.deferredConfiguration(project, new Runnable() {

                @Override
                public void run() {
                    task.setProjectGroup(project.getGroup().toString());
                }
            });
        }
    });
    sourcesJar.getMetaInf().from(dependencyInfoTask.getOutputFile());
    sourcesJar.dependsOn(dependencyInfoTask);
    TaskMaker.task(project, DOWNLOAD_PUBLICATIONS_TASK, DownloadPreviousPublicationsTask.class, new Action<DownloadPreviousPublicationsTask>() {

        @Override
        public void execute(final DownloadPreviousPublicationsTask t) {
            t.setDescription("Downloads artifacts of last released version and stores it locally for comparison");
            DeferredConfiguration.deferredConfiguration(project, new Runnable() {

                @Override
                public void run() {
                    DefaultArtifactUrlResolver artifactUrlResolver = new DefaultArtifactUrlResolverFactory().getDefaultResolver(project, sourcesJar.getBaseName(), conf.getPreviousReleaseVersion());
                    String previousVersionSourcesJarUrl = getDefaultIfNull(t.getPreviousSourcesJarUrl(), "previousSourcesJarUrl", "-sources.jar", artifactUrlResolver);
                    t.setPreviousSourcesJarUrl(previousVersionSourcesJarUrl);
                    t.setPreviousSourcesJarFile(previousSourcesJar);
                }
            });
        }
    });
    TaskMaker.task(project, COMPARE_PUBLICATIONS_TASK, ComparePublicationsTask.class, new Action<ComparePublicationsTask>() {

        public void execute(final ComparePublicationsTask t) {
            t.setDescription("Compares artifacts and poms between last version and the currently built one to see if there are any differences");
            t.dependsOn(DOWNLOAD_PUBLICATIONS_TASK);
            t.setComparisonResult(new File(project.getBuildDir(), "publications-comparison.txt"));
            t.setPreviousSourcesJar(previousSourcesJar);
            // Set local sources jar for comparison with previously released
            t.compareSourcesJar(sourcesJar);
        }
    });
}
Also used : CreateDependencyInfoFileTask(org.shipkit.internal.gradle.java.tasks.CreateDependencyInfoFileTask) ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) DownloadPreviousPublicationsTask(org.shipkit.gradle.java.DownloadPreviousPublicationsTask) ComparePublicationsTask(org.shipkit.gradle.java.ComparePublicationsTask) DefaultArtifactUrlResolverFactory(org.shipkit.internal.comparison.artifact.DefaultArtifactUrlResolverFactory) Jar(org.gradle.api.tasks.bundling.Jar) DefaultArtifactUrlResolver(org.shipkit.internal.comparison.artifact.DefaultArtifactUrlResolver) File(java.io.File)

Example 9 with ShipkitConfiguration

use of org.shipkit.gradle.configuration.ShipkitConfiguration in project shipkit by mockito.

the class JavaPublishPlugin method apply.

public void apply(final Project project) {
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    project.getPlugins().apply(JavaLibraryPlugin.class);
    project.getPlugins().apply("maven-publish");
    final Jar sourcesJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.SOURCES_JAR_TASK);
    final Jar javadocJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.JAVADOC_JAR_TASK);
    GradleDSLHelper.publications(project, new Action<PublicationContainer>() {

        public void execute(PublicationContainer publications) {
            MavenPublication p = publications.create(PUBLICATION_NAME, MavenPublication.class, new Action<MavenPublication>() {

                public void execute(MavenPublication publication) {
                    publication.from(project.getComponents().getByName("java"));
                    publication.artifact(sourcesJar);
                    publication.artifact(javadocJar);
                    publication.setArtifactId(((Jar) project.getTasks().getByName("jar")).getBaseName());
                    PomCustomizer.customizePom(project, conf, publication);
                }
            });
            LOG.info("{} - configured '{}' publication", project.getPath(), p.getArtifactId());
        }
    });
    // so that we flesh out problems with maven publication during the build process
    project.getTasks().getByName("build").dependsOn("publishToMavenLocal");
}
Also used : Action(org.gradle.api.Action) ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) PublicationContainer(org.gradle.api.publish.PublicationContainer) MavenPublication(org.gradle.api.publish.maven.MavenPublication) Jar(org.gradle.api.tasks.bundling.Jar)

Example 10 with ShipkitConfiguration

use of org.shipkit.gradle.configuration.ShipkitConfiguration in project shipkit by mockito.

the class ReleaseNotesPlugin method apply.

public void apply(final Project project) {
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    project.getPlugins().apply(VersioningPlugin.class);
    project.getPlugins().apply(GitHubContributorsPlugin.class);
    releaseNotesTasks(project, conf);
}
Also used : ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin)

Aggregations

ShipkitConfiguration (org.shipkit.gradle.configuration.ShipkitConfiguration)15 ShipkitConfigurationPlugin (org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin)15 Task (org.gradle.api.Task)6 Action (org.gradle.api.Action)4 ShipkitExecTask (org.shipkit.gradle.exec.ShipkitExecTask)4 BintrayExtension (com.jfrog.bintray.gradle.BintrayExtension)2 File (java.io.File)2 Jar (org.gradle.api.tasks.bundling.Jar)2 GitPushTask (org.shipkit.gradle.git.GitPushTask)2 UpdateReleaseNotesTask (org.shipkit.gradle.notes.UpdateReleaseNotesTask)2 UploadGistsTask (org.shipkit.internal.gradle.release.tasks.UploadGistsTask)2 BintrayUploadTask (com.jfrog.bintray.gradle.BintrayUploadTask)1 Optional (java.util.Optional)1 Plugin (org.gradle.api.Plugin)1 Project (org.gradle.api.Project)1 PublicationContainer (org.gradle.api.publish.PublicationContainer)1 MavenPublication (org.gradle.api.publish.maven.MavenPublication)1 GitCommitTask (org.shipkit.gradle.git.GitCommitTask)1 IdentifyGitBranchTask (org.shipkit.gradle.git.IdentifyGitBranchTask)1 ComparePublicationsTask (org.shipkit.gradle.java.ComparePublicationsTask)1