Search in sources :

Example 11 with ShipkitConfiguration

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

the class GradlePortalPublishPlugin method apply.

@Override
public void apply(final Project project) {
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    project.getPlugins().apply("com.gradle.plugin-publish");
    // Above also applies 'java' plugin
    final Task publishPlugins = project.getTasks().getByName(PUBLISH_PLUGINS_TASK);
    LazyConfiguration.lazyConfiguration(publishPlugins, new Runnable() {

        @Override
        public void run() {
            authenticate(PUBLISH_KEY_PROPERTY, project, PUBLISH_KEY_ENV, envVariables);
            authenticate(PUBLISH_SECRET_PROPERTY, project, PUBLISH_SECRET_ENV, envVariables);
        }
    });
    publishPlugins.onlyIf(new Spec<Task>() {

        @Override
        public boolean isSatisfiedBy(Task t) {
            if (conf.isDryRun()) {
                LOG.info("dryRun is enabled, skipping '{}' using 'onlyIf'", t.getName());
            }
            return !conf.isDryRun();
        }
    });
}
Also used : Task(org.gradle.api.Task) ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin)

Example 12 with ShipkitConfiguration

use of org.shipkit.gradle.configuration.ShipkitConfiguration 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)

Example 13 with ShipkitConfiguration

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

the class TestDownstreamPlugin method apply.

public void apply(final Project project) {
    IncubatingWarning.warn("downstream-testing plugin");
    project.getPlugins().apply(UploadGistsPlugin.class);
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    final File logsDirectory = project.getBuildDir();
    final UploadGistsTask uploadGistsTask = (UploadGistsTask) project.getTasks().findByName(UploadGistsPlugin.UPLOAD_GISTS_TASK);
    uploadGistsTask.setFilesToUpload((ConfigurableFileTree) project.fileTree(logsDirectory).include("*.log"));
    boolean shouldUploadLogs = ciContext.isCiBuild() && !StringUtil.isEmpty(conf.getLenient().getGitHub().getWriteAuthToken());
    if (shouldUploadLogs) {
        LOG.debug("  Skipping UploadGists task execution -> test-downstream plugin will not send logs to Gist (setting uploadGists.enabled=false)." + "  It's only enabled when build is run in CI environment and GH_WRITE_TOKEN env property is set.");
    }
    uploadGistsTask.setEnabled(shouldUploadLogs);
    TaskMaker.task(project, TEST_DOWNSTREAM_TASK, TestDownstreamTask.class, new Action<TestDownstreamTask>() {

        @Override
        public void execute(TestDownstreamTask task) {
            task.setDescription("Runs all downstream tests.");
            task.setLogsDirectory(logsDirectory);
            task.setUploadGistsTask(uploadGistsTask);
            task.setGitHubUrl(conf.getGitHub().getUrl());
        }
    });
}
Also used : ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) File(java.io.File) UploadGistsTask(org.shipkit.internal.gradle.release.tasks.UploadGistsTask)

Example 14 with ShipkitConfiguration

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

the class GitConfigPlugin method apply.

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

        public void execute(final ShipkitExecTask t) {
            t.setDescription("Overwrites local git 'user.name' with a generic name. Intended for CI.");
            t.execCommand(ExecCommandFactory.execCommand("Setting git user name", "git", "config", "--local", "user.name", conf.getGit().getUser()));
        }
    });
    TaskMaker.task(project, SET_EMAIL_TASK, ShipkitExecTask.class, new Action<ShipkitExecTask>() {

        public void execute(final ShipkitExecTask t) {
            t.setDescription("Overwrites local git 'user.email' with a generic email. Intended for CI.");
            t.execCommand(ExecCommandFactory.execCommand("Setting git user email", "git", "config", "--local", "user.email", conf.getGit().getEmail()));
        }
    });
}
Also used : ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) ShipkitExecTask(org.shipkit.gradle.exec.ShipkitExecTask)

Example 15 with ShipkitConfiguration

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

the class UpgradeDownstreamPlugin method apply.

@Override
public void apply(final Project project) {
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    upgradeDownstreamExtension = project.getExtensions().create("upgradeDownstream", UpgradeDownstreamExtension.class);
    final Task performAllUpdates = TaskMaker.task(project, UPGRADE_DOWNSTREAM_TASK, new Action<Task>() {

        @Override
        public void execute(final Task task) {
            task.setDescription("Performs dependency upgrade in all downstream repositories.");
        }
    });
    DeferredConfiguration.deferredConfiguration(project, new Runnable() {

        @Override
        public void run() {
            notNull(upgradeDownstreamExtension.getRepositories(), "'upgradeDownstream.repositories'");
            for (String consumerRepositoryName : upgradeDownstreamExtension.getRepositories()) {
                Task cloneTask = CloneGitRepositoryTaskFactory.createCloneTask(project, conf.getGitHub().getUrl(), consumerRepositoryName);
                Task performUpdate = createProduceUpgradeTask(project, consumerRepositoryName);
                performUpdate.dependsOn(cloneTask);
                performAllUpdates.dependsOn(performUpdate);
            }
        }
    });
}
Also used : ShipkitExecTask(org.shipkit.gradle.exec.ShipkitExecTask) Task(org.gradle.api.Task) 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