Search in sources :

Example 1 with BintrayUploadTask

use of com.jfrog.bintray.gradle.BintrayUploadTask 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)

Aggregations

BintrayExtension (com.jfrog.bintray.gradle.BintrayExtension)1 BintrayUploadTask (com.jfrog.bintray.gradle.BintrayUploadTask)1 ShipkitConfiguration (org.shipkit.gradle.configuration.ShipkitConfiguration)1 ShipkitConfigurationPlugin (org.shipkit.internal.gradle.configuration.ShipkitConfigurationPlugin)1