Search in sources :

Example 1 with UpdateReleaseNotesTask

use of org.shipkit.gradle.notes.UpdateReleaseNotesTask in project shipkit by mockito.

the class BintrayReleasePlugin method apply.

public void apply(final Project project) {
    project.getPlugins().apply(ReleasePlugin.class);
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    final Task gitPush = project.getTasks().getByName(GitPlugin.GIT_PUSH_TASK);
    final Task performRelease = project.getTasks().getByName(ReleasePlugin.PERFORM_RELEASE_TASK);
    project.allprojects(subproject -> {
        subproject.getPlugins().withType(ShipkitBintrayPlugin.class, plugin -> {
            Task bintrayUpload = subproject.getTasks().getByName(ShipkitBintrayPlugin.BINTRAY_UPLOAD_TASK);
            performRelease.dependsOn(bintrayUpload);
            // bintray upload after git push so that when git push fails we don't publish jars to bintray
            // git push is easier to undo than deleting published jars (not possible with Central)
            bintrayUpload.mustRunAfter(gitPush);
            final BintrayExtension bintray = subproject.getExtensions().getByType(BintrayExtension.class);
            deferredConfiguration(subproject, () -> {
                UpdateReleaseNotesTask updateNotes = (UpdateReleaseNotesTask) project.getTasks().getByName(ReleaseNotesPlugin.UPDATE_NOTES_TASK);
                String userSpecifiedRepo = conf.getLenient().getReleaseNotes().getPublicationRepository();
                if (userSpecifiedRepo != null) {
                    updateNotes.setPublicationRepository(userSpecifiedRepo);
                } else {
                    updateNotes.setPublicationRepository(BintrayUtil.getRepoLink(bintray));
                }
            });
        });
        subproject.getPlugins().withType(JavaBintrayPlugin.class, plugin -> {
            // Making git push run as late as possible because it is an operation that is hard to reverse.
            // Git push will be executed after all tasks needed by bintrayUpload
            // but before bintrayUpload.
            // Using task path as String because the task comes from maven-publish new configuration model
            // and we cannot refer to it in a normal way, by task instance.
            String mavenLocalTask = subproject.getPath() + ":" + MAVEN_LOCAL_TASK;
            gitPush.mustRunAfter(mavenLocalTask);
        });
    });
}
Also used : Task(org.gradle.api.Task) UpdateReleaseNotesTask(org.shipkit.gradle.notes.UpdateReleaseNotesTask) ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) UpdateReleaseNotesTask(org.shipkit.gradle.notes.UpdateReleaseNotesTask) BintrayExtension(com.jfrog.bintray.gradle.BintrayExtension)

Example 2 with UpdateReleaseNotesTask

use of org.shipkit.gradle.notes.UpdateReleaseNotesTask in project shipkit by mockito.

the class ReleaseNotesPlugin method releaseNotesTasks.

private static void releaseNotesTasks(final Project project, final ShipkitConfiguration conf) {
    final FetchReleaseNotesTask releaseNotesFetcher = TaskMaker.task(project, FETCH_NOTES_TASK, FetchReleaseNotesTask.class, new Action<FetchReleaseNotesTask>() {

        public void execute(final FetchReleaseNotesTask t) {
            t.setDescription("Fetches release notes data from Git and GitHub and serializes them to a file");
            t.setOutputFile(new File(project.getBuildDir(), "detailed-release-notes.ser"));
            t.setGitHubApiUrl(conf.getGitHub().getApiUrl());
            t.setGitHubReadOnlyAuthToken(conf.getGitHub().getReadOnlyAuthToken());
            t.setGitHubRepository(conf.getGitHub().getRepository());
            t.setPreviousVersion(conf.getPreviousReleaseVersion());
            t.setTagPrefix(conf.getGit().getTagPrefix());
            t.setIgnoreCommitsContaining(conf.getReleaseNotes().getIgnoreCommitsContaining());
            t.setIgnoredContributors(conf.getTeam().getIgnoredContributors());
        }
    });
    final Task contributorsFetcher = project.getTasks().getByName(GitHubContributorsPlugin.FETCH_CONTRIBUTORS);
    TaskMaker.task(project, UPDATE_NOTES_TASK, UpdateReleaseNotesTask.class, new Action<UpdateReleaseNotesTask>() {

        public void execute(final UpdateReleaseNotesTask t) {
            t.setDescription("Updates release notes file. Run with '-Ppreview' if you only want to see the preview.");
            configureDetailedNotes(t, releaseNotesFetcher, project, conf, contributorsFetcher);
            boolean previewMode = project.hasProperty(PREVIEW_PROJECT_PROPERTY);
            t.setPreviewMode(previewMode);
            if (!previewMode) {
                File releaseNotesFile = project.file(conf.getReleaseNotes().getFile());
                GitPlugin.registerChangesForCommitIfApplied(singletonList(releaseNotesFile), "release notes updated", t);
                t.getOutputs().file(releaseNotesFile);
            }
        }
    });
}
Also used : FetchReleaseNotesTask(org.shipkit.gradle.notes.FetchReleaseNotesTask) Task(org.gradle.api.Task) UpdateReleaseNotesTask(org.shipkit.gradle.notes.UpdateReleaseNotesTask) UpdateReleaseNotesTask(org.shipkit.gradle.notes.UpdateReleaseNotesTask) FetchReleaseNotesTask(org.shipkit.gradle.notes.FetchReleaseNotesTask) File(java.io.File)

Example 3 with UpdateReleaseNotesTask

use of org.shipkit.gradle.notes.UpdateReleaseNotesTask in project shipkit by mockito.

the class GradlePortalReleasePlugin method apply.

@Override
public void apply(final Project project) {
    project.getPlugins().apply(ReleasePlugin.class);
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    final Task performRelease = project.getTasks().getByName(ReleasePlugin.PERFORM_RELEASE_TASK);
    final Task gitPush = project.getTasks().getByName(GitPlugin.GIT_PUSH_TASK);
    project.allprojects(new Action<Project>() {

        @Override
        public void execute(final Project subproject) {
            subproject.getPlugins().withId("com.gradle.plugin-publish", new Action<Plugin>() {

                @Override
                public void execute(Plugin plugin) {
                    subproject.getPlugins().apply(PluginDiscoveryPlugin.class);
                    subproject.getPlugins().apply(PluginValidationPlugin.class);
                    subproject.getPlugins().apply(GradlePortalPublishPlugin.class);
                    subproject.getPlugins().apply(ComparePublicationsPlugin.class);
                    Task publishPlugins = subproject.getTasks().getByName(GradlePortalPublishPlugin.PUBLISH_PLUGINS_TASK);
                    // perform release will actually publish the plugins
                    performRelease.dependsOn(publishPlugins);
                    // git push is easier to revert than perform release
                    publishPlugins.mustRunAfter(gitPush);
                    // We first build plugins to be published, then do git push, we're using 'buildArchives' for that
                    // We know that "buildArchives" task exists because 'com.gradle.plugin-publish' applies Java plugin
                    Task archivesTask = subproject.getTasks().getByName("buildArchives");
                    publishPlugins.dependsOn(archivesTask);
                    gitPush.mustRunAfter(archivesTask);
                    UpdateReleaseNotesTask updateNotes = (UpdateReleaseNotesTask) project.getTasks().getByName(ReleaseNotesPlugin.UPDATE_NOTES_TASK);
                    updateNotes.setPublicationRepository(conf.getReleaseNotes().getPublicationRepository());
                }
            });
        }
    });
}
Also used : Project(org.gradle.api.Project) Task(org.gradle.api.Task) UpdateReleaseNotesTask(org.shipkit.gradle.notes.UpdateReleaseNotesTask) Action(org.gradle.api.Action) ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) UpdateReleaseNotesTask(org.shipkit.gradle.notes.UpdateReleaseNotesTask) PluginValidationPlugin(org.shipkit.internal.gradle.plugin.PluginValidationPlugin) ComparePublicationsPlugin(org.shipkit.internal.gradle.java.ComparePublicationsPlugin) GitPlugin(org.shipkit.internal.gradle.git.GitPlugin) GradlePortalPublishPlugin(org.shipkit.internal.gradle.plugin.GradlePortalPublishPlugin) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) PluginDiscoveryPlugin(org.shipkit.internal.gradle.plugin.PluginDiscoveryPlugin) ReleaseNotesPlugin(org.shipkit.internal.gradle.notes.ReleaseNotesPlugin) Plugin(org.gradle.api.Plugin)

Aggregations

Task (org.gradle.api.Task)3 UpdateReleaseNotesTask (org.shipkit.gradle.notes.UpdateReleaseNotesTask)3 ShipkitConfiguration (org.shipkit.gradle.configuration.ShipkitConfiguration)2 ShipkitConfigurationPlugin (org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin)2 BintrayExtension (com.jfrog.bintray.gradle.BintrayExtension)1 File (java.io.File)1 Action (org.gradle.api.Action)1 Plugin (org.gradle.api.Plugin)1 Project (org.gradle.api.Project)1 FetchReleaseNotesTask (org.shipkit.gradle.notes.FetchReleaseNotesTask)1 GitPlugin (org.shipkit.internal.gradle.git.GitPlugin)1 ComparePublicationsPlugin (org.shipkit.internal.gradle.java.ComparePublicationsPlugin)1 ReleaseNotesPlugin (org.shipkit.internal.gradle.notes.ReleaseNotesPlugin)1 GradlePortalPublishPlugin (org.shipkit.internal.gradle.plugin.GradlePortalPublishPlugin)1 PluginDiscoveryPlugin (org.shipkit.internal.gradle.plugin.PluginDiscoveryPlugin)1 PluginValidationPlugin (org.shipkit.internal.gradle.plugin.PluginValidationPlugin)1