diff --git a/buildSrc/src/main/kotlin/artifacts.kt b/buildSrc/src/main/kotlin/artifacts.kt index 452c7879348..a18492121fe 100644 --- a/buildSrc/src/main/kotlin/artifacts.kt +++ b/buildSrc/src/main/kotlin/artifacts.kt @@ -229,23 +229,6 @@ fun Project.publish(moduleMetadata: Boolean = false, configure: MavenPublication publication.configure() } -fun Project.publishWithLegacyMavenPlugin(body: Upload.() -> Unit = {}): Upload { - apply() - - if (artifactsRemovedDiagnosticFlag) { - error("`publish()` should be called before removing artifacts typically done in `noDefaultJar()` or `runtimeJar()` call") - } - - afterEvaluate { - if (configurations.findByName("classes-dirs") != null) - throw GradleException("classesDirsArtifact() is incompatible with publish(), see sources comments for details") - } - - return (tasks.getByName("uploadArchives") as Upload).apply { - body() - } -} - fun Project.idePluginDependency(block: () -> Unit) { val shouldActivate = rootProject.findProperty("publish.ide.plugin.dependencies")?.toString()?.toBoolean() == true if (shouldActivate) { diff --git a/buildSrc/src/main/kotlin/plugins/PublishedKotlinModule.kt b/buildSrc/src/main/kotlin/plugins/PublishedKotlinModule.kt deleted file mode 100644 index 016a51c988c..00000000000 --- a/buildSrc/src/main/kotlin/plugins/PublishedKotlinModule.kt +++ /dev/null @@ -1,173 +0,0 @@ -@file:Suppress("DEPRECATION") -package plugins - -import org.codehaus.groovy.runtime.InvokerHelper -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.artifacts.Dependency -import org.gradle.api.artifacts.maven.Conf2ScopeMappingContainer -import org.gradle.api.artifacts.maven.MavenDeployment -import org.gradle.api.artifacts.maven.MavenResolver -import org.gradle.api.plugins.MavenPluginConvention -import org.gradle.api.plugins.MavenRepositoryHandlerConvention -import org.gradle.api.publication.maven.internal.deployer.MavenRemoteRepository -import org.gradle.api.tasks.Upload -import org.gradle.kotlin.dsl.* -import org.gradle.plugins.signing.Sign -import org.gradle.plugins.signing.SigningExtension -import kotlin.properties.Delegates - -/** - * Configures a Kotlin module for publication. - */ -open class PublishedKotlinModule : Plugin { - - private fun String.toBooleanOrNull() = listOf(true, false).firstOrNull { it.toString().equals(this, ignoreCase = true) } - - override fun apply(project: Project) { - - project.run { - - plugins.apply("maven") - - configurations.maybeCreate("publishedRuntime").apply { - the() - .conf2ScopeMappings - .addMapping(0, this, Conf2ScopeMappingContainer.RUNTIME) - } - - configurations.maybeCreate("publishedCompile").apply { - the() - .conf2ScopeMappings - .addMapping(0, this, Conf2ScopeMappingContainer.COMPILE) - } - - if (!project.hasProperty("prebuiltJar")) { - plugins.apply("signing") - - val signingRequired = project.findProperty("signingRequired")?.toString()?.toBooleanOrNull() - ?: project.property("isSonatypeRelease") as Boolean - - configure { - isRequired = signingRequired - sign(configurations["archives"]) - useGpgCmd() - } - - tasks.named("signArchives").configure { - enabled = signingRequired - } - } - - fun MavenResolver.configurePom() { - pom.project { - withGroovyBuilder { - "licenses" { - "license" { - "name"("The Apache Software License, Version 2.0") - "url"("http://www.apache.org/licenses/LICENSE-2.0.txt") - "distribution"("repo") - } - } - "name"("${project.group}:${project.name}") - "packaging"("jar") - // optionally artifactId can be defined here - "description"(project.description) - "url"("https://kotlinlang.org/") - "licenses" { - "license" { - "name"("The Apache License, Version 2.0") - "url"("http://www.apache.org/licenses/LICENSE-2.0.txt") - } - } - "scm" { - "url"("https://github.com/JetBrains/kotlin") - "connection"("scm:git:https://github.com/JetBrains/kotlin.git") - "developerConnection"("scm:git:https://github.com/JetBrains/kotlin.git") - } - "developers" { - "developer" { - "name"("Kotlin Team") - setProperty("organization", "JetBrains") - "organizationUrl"("https://www.jetbrains.com") - } - } - } - } - pom.whenConfigured { - dependencies.removeIf { - InvokerHelper.getMetaClass(it).getProperty(it, "scope") == "test" - } - - dependencies - .find { - InvokerHelper.getMetaClass(it).getProperty(it, "groupId") == "org.jetbrains.kotlin" - && InvokerHelper.getMetaClass(it).getProperty(it, "artifactId") == "kotlin-stdlib" - } - ?.also { - InvokerHelper.getMetaClass(it).setProperty(it, "exclusions", emptyList()) - logger.warn("WARNING! Removed exclusions from kotlin-stdlib dependency of ${this.artifactId} artifact's maven metadata, check kotlin-stdlib dependency of ${project.path} project") - } - } - } - - tasks.named("uploadArchives").configure { - - val preparePublication = project.rootProject.tasks.named("preparePublication").get() - - dependsOn(preparePublication) - - val username: String? by preparePublication.extra - val password: String? by preparePublication.extra - val repoUrl: String by preparePublication.extra - - var repository by Delegates.notNull() - - repositories { - withConvention(MavenRepositoryHandlerConvention::class) { - - mavenDeployer { - withGroovyBuilder { - "beforeDeployment" { - val signing = project.the() - if (signing.isRequired) - signing.signPom(delegate as MavenDeployment) - } - - "repository"("url" to repoUrl)!!.also { repository = it as MavenRemoteRepository }.withGroovyBuilder { - if (username != null && password != null) { - "authentication"("userName" to username, "password" to password) - } - } - } - - configurePom() - } - } - } - - doFirst { - repository.url = repoUrl - } - } - - val install = if (tasks.names.contains("install")) tasks.getByName("install") as Upload - else tasks.create("install", Upload::class.java) - install.apply { - configuration = project.configurations.getByName(Dependency.ARCHIVES_CONFIGURATION) - description = "Installs the 'archives' artifacts into the local Maven repository." - repositories { - withConvention(MavenRepositoryHandlerConvention::class) { - mavenInstaller { - configurePom() - } - } - } - } - - tasks.register("publish") { - dependsOn(tasks.named("uploadArchives")) - } - } - } -} diff --git a/libraries/commonConfiguration.gradle b/libraries/commonConfiguration.gradle index c0d54d95539..9b1811d68a7 100644 --- a/libraries/commonConfiguration.gradle +++ b/libraries/commonConfiguration.gradle @@ -126,13 +126,6 @@ task preparePublication { } } -ext.signPom = { Project project, MavenDeployer deployer -> - deployer.beforeDeployment { MavenDeployment deployment -> - if (project.signing.required) - project.signing.signPom(deployment) - } -} - ext.configurePublishing = { Project project, configure = { } -> ArtifactsKt.publish(project, false) { publication -> configure.delegate = publication @@ -144,72 +137,6 @@ ext.configurePluginMarkers = { Project project, withEmptyJars = true -> PluginMarkersKt.publishPluginMarkers(project, withEmptyJars) } -ext.configureLegacyPublishing = { Project project -> - project.configure(project) { - apply plugin: 'maven' - - if (!project.hasProperty('prebuiltJar')) { - apply plugin: 'signing' - - signing { - required { (project.properties["signingRequired"] ?: project.isSonatypeRelease) } - sign configurations.archives - useGpgCmd() - } - - signArchives { - enabled signing.required - } - } - - uploadArchives { - def prepareTask = rootProject.preparePublication - dependsOn prepareTask - - doFirst { - repositories.mavenDeployer.repository.url = prepareTask.repoUrl - } - - repositories { - mavenDeployer { - signPom(project, it) - - repository(url: prepareTask.repoUrl) { - authentication(userName: prepareTask.username, password: prepareTask.password) - } - pom.project { - name "${project.group}:${project.name}" - packaging 'jar' - // optionally artifactId can be defined here - description project.description - url 'https://kotlinlang.org/' - licenses { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - scm { - url 'https://github.com/JetBrains/kotlin' - connection 'scm:git:https://github.com/JetBrains/kotlin.git' - developerConnection 'scm:git:https://github.com/JetBrains/kotlin.git' - } - developers { - developer { - name 'Kotlin Team' - organization = 'JetBrains' - organizationUrl 'https://www.jetbrains.com' - } - } - } - } - } - } - - task publish(dependsOn: uploadArchives) - } -} - ext.configureJvmIrBackend = { Project project -> project.tasks.withType(KotlinCompile.class) { task -> task.kotlinOptions {