diff --git a/servicetalk-bom-internal/build.gradle b/servicetalk-bom-internal/build.gradle index f83c82473b..910160261c 100644 --- a/servicetalk-bom-internal/build.gradle +++ b/servicetalk-bom-internal/build.gradle @@ -16,7 +16,6 @@ apply plugin: "servicetalk-core" apply plugin: "java-platform" -apply plugin: "maven-publish" dependencies { constraints { diff --git a/servicetalk-bom/build.gradle b/servicetalk-bom/build.gradle index 6652e2ada5..f1bcbd39e4 100644 --- a/servicetalk-bom/build.gradle +++ b/servicetalk-bom/build.gradle @@ -16,7 +16,6 @@ apply plugin: "servicetalk-core" apply plugin: "java-platform" -apply plugin: "maven-publish" rootProject.subprojects.findAll { !it.name.contains("bom") && !it.name.contains("examples") }.each { dependencies.constraints.add("api", it) diff --git a/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ProjectUtils.groovy b/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ProjectUtils.groovy index 9a35468dbe..b35ec96b8b 100644 --- a/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ProjectUtils.groovy +++ b/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ProjectUtils.groovy @@ -134,7 +134,7 @@ final class ProjectUtils { configFile.exists() ? configFile : project.file("$project.projectDir/$path") } - private static void addQualityTask(Project project) { + static void addQualityTask(Project project) { project.configure(project) { project.task("quality") { description = "Run all quality analyzers for all source sets" diff --git a/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ServiceTalkCorePlugin.groovy b/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ServiceTalkCorePlugin.groovy index 11353aa4fb..387c1df846 100644 --- a/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ServiceTalkCorePlugin.groovy +++ b/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ServiceTalkCorePlugin.groovy @@ -15,11 +15,15 @@ */ package io.servicetalk.gradle.plugin.internal +import com.jfrog.bintray.gradle.tasks.BintrayUploadTask import org.gradle.api.GradleException import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.XmlProvider import org.gradle.api.plugins.quality.Checkstyle +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.api.publish.maven.internal.artifact.FileBasedMavenArtifact import static io.servicetalk.gradle.plugin.internal.ProjectUtils.addBuildContextExtensions import static io.servicetalk.gradle.plugin.internal.ProjectUtils.appendNodes @@ -31,13 +35,14 @@ import static io.servicetalk.gradle.plugin.internal.Versions.CHECKSTYLE_VERSION import static io.servicetalk.gradle.plugin.internal.Versions.TARGET_VERSION class ServiceTalkCorePlugin implements Plugin { - void apply(Project project, boolean includeBintrayPlugin = true) { + void apply(Project project, boolean publishesArtifacts = true) { enforceUtf8FileSystem() addBuildContextExtensions project applyCheckstylePlugin project applyIdeaPlugin project - if (includeBintrayPlugin) { + if (publishesArtifacts) { + applyMavenPublishPlugin project applyBintrayPlugin project } } @@ -123,6 +128,12 @@ class ServiceTalkCorePlugin implements Plugin { } } + private static void applyMavenPublishPlugin(Project project) { + project.configure(project) { + pluginManager.apply("maven-publish") + } + } + private static void applyBintrayPlugin(Project project) { project.configure(project) { pluginManager.apply("com.jfrog.bintray") @@ -147,15 +158,6 @@ class ServiceTalkCorePlugin implements Plugin { key = bintrayKey publications = ["mavenJava"] - // Temporary workaround for https://github.com/bintray/gradle-bintray-plugin/issues/229 - def groupPath = project.group.replaceAll('\\.', '/') - filesSpec { - from "$buildDir/publications/mavenJava" - include "module.json" - into "$groupPath/$project.name/$project.version" - rename ".*", "$project.name-${project.version}.module" - } - pkg { userOrg = "servicetalk" repo = "servicetalk" @@ -166,6 +168,27 @@ class ServiceTalkCorePlugin implements Plugin { override = true publish = true } + + // Temporary workaround for https://github.com/bintray/gradle-bintray-plugin/issues/229 + PublishingExtension publishing = project.extensions.getByType(PublishingExtension) + project.tasks.withType(BintrayUploadTask) { + doFirst { + publishing.publications.withType(MavenPublication).each { publication -> + File moduleFile = project.buildDir.toPath() + .resolve("publications/${publication.name}/module.json").toFile() + + if (moduleFile.exists()) { + publication.artifact(new FileBasedMavenArtifact(moduleFile) { + @Override + protected String getDefaultExtension() { + return "module" + } + }) + } + } + } + } + } } } diff --git a/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ServiceTalkLibraryPlugin.groovy b/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ServiceTalkLibraryPlugin.groovy index 5a8698d11d..0a7d1f58b3 100644 --- a/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ServiceTalkLibraryPlugin.groovy +++ b/servicetalk-gradle-plugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ServiceTalkLibraryPlugin.groovy @@ -51,7 +51,6 @@ final class ServiceTalkLibraryPlugin extends ServiceTalkCorePlugin { private static void applyJavaLibraryPlugin(Project project) { project.configure(project) { pluginManager.apply("java-library") - pluginManager.apply("maven-publish") sourceCompatibility = TARGET_VERSION targetCompatibility = TARGET_VERSION