Search in sources :

Example 1 with BintrayExtension

use of com.jfrog.bintray.gradle.BintrayExtension in project shipkit by mockito.

the class ShipkitBintrayPlugin method apply.

public void apply(final Project project) {
    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
    // TODO (maybe) since this plugin depends on bintray,
    // we need to either shade bintray plugin or ship this Gradle plugin in a separate jar
    // this way we avoid version conflicts and any bintray dependencies for users who don't use bintray
    project.getPlugins().apply("com.jfrog.bintray");
    // Configure some properties right away
    final BintrayExtension bintray = project.getExtensions().getByType(BintrayExtension.class);
    LOG.info("Configuring bintray plugin to publish automatically ({}.bintray.publish = true)", project.getPath());
    bintray.setPublish(true);
    final BintrayUploadTask bintrayUpload = (BintrayUploadTask) project.getTasks().getByName(BINTRAY_UPLOAD_TASK);
    bintrayUpload.doFirst(task -> {
        String welcomeMessage = uploadWelcomeMessage((BintrayUploadTask) task);
        LOG.lifecycle(welcomeMessage);
    });
    final BintrayExtension.PackageConfig pkg = bintray.getPkg();
    pkg.setPublicDownloadNumbers(true);
    pkg.getVersion().getGpg().setSign(true);
    // Defer configuration of other properties
    deferredConfiguration(project, () -> {
        // Below overwrites prior value in case the user configured dry run directly on the bintray extension.
        // It should be ok.
        bintray.setDryRun(conf.isDryRun());
        if (pkg.getDesc() == null) {
            pkg.setDesc(project.getDescription());
        }
        if (pkg.getName() == null) {
            pkg.setName(project.getGroup().toString());
        }
        if (pkg.getVersion().getVcsTag() == null) {
            pkg.getVersion().setVcsTag(conf.getGit().getTagPrefix() + project.getVersion());
        }
    });
    if (pkg.getWebsiteUrl() == null) {
        pkg.setWebsiteUrl(conf.getGitHub().getUrl() + "/" + conf.getGitHub().getRepository());
    }
    if (pkg.getIssueTrackerUrl() == null) {
        pkg.setIssueTrackerUrl(conf.getGitHub().getUrl() + "/" + conf.getGitHub().getRepository() + "/issues");
    }
    if (pkg.getVcsUrl() == null) {
        pkg.setVcsUrl(conf.getGitHub().getUrl() + "/" + conf.getGitHub().getRepository() + ".git");
    }
    LazyConfiguration.lazyConfiguration(bintrayUpload, () -> {
        String key = notNull(bintray.getKey(), "BINTRAY_API_KEY", "Missing 'bintray.key' value.\n" + "  Please configure Bintray extension or export 'BINTRAY_API_KEY' env variable.");
        bintray.setKey(key);
        // api key is set by Bintray plugin, based on 'bintray.key' value, before lazy configuration.
        // Hence we need to set it again here:
        bintrayUpload.setApiKey(key);
        // workaround for https://github.com/bintray/gradle-bintray-plugin/issues/170
        notNull(bintray.getUser(), "Missing 'bintray.user' value.\n" + "  Please configure Bintray extension.");
    });
}
Also used : ShipkitConfiguration(org.shipkit.gradle.configuration.ShipkitConfiguration) ShipkitConfigurationPlugin(org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin) BintrayUploadTask(com.jfrog.bintray.gradle.BintrayUploadTask) BintrayExtension(com.jfrog.bintray.gradle.BintrayExtension)

Example 2 with BintrayExtension

use of com.jfrog.bintray.gradle.BintrayExtension 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 3 with BintrayExtension

use of com.jfrog.bintray.gradle.BintrayExtension in project shipkit by mockito.

the class JavaBintrayPlugin method apply.

public void apply(Project project) {
    project.getPlugins().apply(JavaPublishPlugin.class);
    project.getPlugins().apply(ShipkitBintrayPlugin.class);
    project.getPlugins().apply(ComparePublicationsPlugin.class);
    if (shouldConfigurePublications(project)) {
        BintrayExtension bintray = project.getExtensions().getByType(BintrayExtension.class);
        bintray.setPublications(PUBLICATION_NAME);
    }
}
Also used : BintrayExtension(com.jfrog.bintray.gradle.BintrayExtension)

Example 4 with BintrayExtension

use of com.jfrog.bintray.gradle.BintrayExtension in project shipkit by mockito.

the class BintrayDefaultArtifactUrlResolver method getDefaultUrl.

/**
 * @return URL of artifact in Bintray, eg:
 * "https://bintray.com/shipkit/examples/download_file?file_path=org/mockito/release-tools-example/api/0.15.0/api-0.15.0.jar"
 */
@Override
public String getDefaultUrl(String extension) {
    BintrayExtension bintrayExtension = project.getExtensions().getByType(BintrayExtension.class);
    String userOrgOrName = bintrayExtension.getPkg().getUserOrg();
    if (userOrgOrName == null) {
        userOrgOrName = bintrayExtension.getUser();
    }
    return String.format("https://bintray.com/%s/%s/download_file?file_path=%s/%s/%s/%s-%s%s", userOrgOrName, bintrayExtension.getPkg().getRepo(), project.getGroup().toString().replace('.', '/'), artifactBaseName, previousVersion, artifactBaseName, previousVersion, extension);
}
Also used : BintrayExtension(com.jfrog.bintray.gradle.BintrayExtension)

Aggregations

BintrayExtension (com.jfrog.bintray.gradle.BintrayExtension)4 ShipkitConfiguration (org.shipkit.gradle.configuration.ShipkitConfiguration)2 ShipkitConfigurationPlugin (org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin)2 BintrayUploadTask (com.jfrog.bintray.gradle.BintrayUploadTask)1 Task (org.gradle.api.Task)1 UpdateReleaseNotesTask (org.shipkit.gradle.notes.UpdateReleaseNotesTask)1