diff --git a/.idea/dictionaries/4u7.xml b/.idea/dictionaries/4u7.xml
index 720bcaa440d..b9beee98b70 100644
--- a/.idea/dictionaries/4u7.xml
+++ b/.idea/dictionaries/4u7.xml
@@ -4,6 +4,7 @@
cidr
foldable
instrumentator
+ protobuf
redirector
diff --git a/buildSrc/src/main/kotlin/dependencies.kt b/buildSrc/src/main/kotlin/dependencies.kt
index 05a5582dc81..af0f018c8d2 100644
--- a/buildSrc/src/main/kotlin/dependencies.kt
+++ b/buildSrc/src/main/kotlin/dependencies.kt
@@ -64,15 +64,8 @@ fun DependencyHandler.projectRuntimeJar(name: String): ProjectDependency = proje
fun DependencyHandler.projectArchives(name: String): ProjectDependency = project(name, configuration = "archives")
fun DependencyHandler.projectClasses(name: String): ProjectDependency = project(name, configuration = "classes-dirs")
-val protobufLiteProject = ":custom-dependencies:protobuf:protobuf-lite"
-val protobufRelocatedProject = ":custom-dependencies:protobuf:protobuf-relocated"
-
-fun DependencyHandler.protobufLite(): ProjectDependency =
- project(protobufLiteProject, configuration = "default").apply { isTransitive = false }
-val protobufLiteTask = "$protobufLiteProject:prepare"
-
-fun DependencyHandler.protobufFull(): ProjectDependency =
- project(protobufRelocatedProject, configuration = "default").apply { isTransitive = false }
+fun Project.protobufLite(): String = "org.jetbrains.kotlin:protobuf-lite:" + findProperty("versions.protobuf-java") as String
+fun Project.protobufFull(): String = "org.jetbrains.kotlin:protobuf-relocated:" + findProperty("versions.protobuf-java") as String
fun File.matchMaybeVersionedArtifact(baseName: String) = name.matches(baseName.toMaybeVersionedJarRegex())
diff --git a/core/metadata/build.gradle.kts b/core/metadata/build.gradle.kts
index 54ce446e705..6be04082b07 100644
--- a/core/metadata/build.gradle.kts
+++ b/core/metadata/build.gradle.kts
@@ -20,11 +20,6 @@ sourceSets {
}
tasks.withType {
- dependsOn(protobufLiteTask)
sourceCompatibility = "1.6"
targetCompatibility = "1.6"
}
-
-tasks.withType {
- dependsOn(protobufLiteTask)
-}
diff --git a/custom-dependencies/protobuf/build.gradle.kts b/custom-dependencies/protobuf/build.gradle.kts
new file mode 100644
index 00000000000..0b171efb1fe
--- /dev/null
+++ b/custom-dependencies/protobuf/build.gradle.kts
@@ -0,0 +1,7 @@
+
+val protobufVersion by extra("2.6.1")
+
+allprojects {
+ group = "org.jetbrains.kotlin"
+ version = protobufVersion
+}
\ No newline at end of file
diff --git a/custom-dependencies/protobuf/protobuf-lite/build.gradle.kts b/custom-dependencies/protobuf/protobuf-lite/build.gradle.kts
index 8ed785c1368..cd8d182bbf9 100644
--- a/custom-dependencies/protobuf/protobuf-lite/build.gradle.kts
+++ b/custom-dependencies/protobuf/protobuf-lite/build.gradle.kts
@@ -6,21 +6,23 @@ import java.util.jar.JarEntry
import java.util.jar.JarFile
import java.util.zip.ZipOutputStream
+plugins {
+ base
+ `maven-publish`
+}
+
val relocatedProtobuf by configurations.creating
val relocatedProtobufSources by configurations.creating
-val resultsCfg = configurations.create("default")
-
-val protobufVersion = rootProject.extra["versions.protobuf-java"]
+val protobufVersion: String by rootProject.extra
val protobufJarPrefix = "protobuf-$protobufVersion"
val outputJarPath = "$buildDir/libs/$protobufJarPrefix-lite.jar"
dependencies {
- relocatedProtobuf(project(":custom-dependencies:protobuf:protobuf-relocated", configuration = "default"))
- relocatedProtobufSources(project(":custom-dependencies:protobuf:protobuf-relocated", configuration = "sources"))
+ relocatedProtobuf(project(":protobuf-relocated"))
}
-task("prepare") {
+val prepare by tasks.creating {
inputs.files(relocatedProtobuf) // this also adds a dependency
outputs.file(outputJarPath)
doFirst {
@@ -41,7 +43,11 @@ task("prepare") {
return result
}
- val allFiles = loadAllFromJar(relocatedProtobuf.singleFile)
+ val mainJar = relocatedProtobuf.resolvedConfiguration.resolvedArtifacts.single {
+ it.name == "protobuf-relocated" && it.classifier == null
+ }.file
+
+ val allFiles = loadAllFromJar(mainJar)
val keepClasses = arrayListOf()
@@ -80,18 +86,38 @@ task("prepare") {
}
}
}
- addArtifact("archives", this, outputs.files.singleFile) {
- classifier = ""
- }
- addArtifact(resultsCfg, this, outputs.files.singleFile) {
- classifier = ""
- }
}
-val clean by task {
- delete(buildDir)
+val mainArtifact = artifacts.add(
+ "default",
+ provider {
+ prepare.outputs.files.singleFile
+ }
+) {
+ builtBy(prepare)
+ classifier = ""
}
-artifacts.add("archives", relocatedProtobufSources.files.single()) {
+val sourcesArtifact = artifacts.add(
+ "default",
+ provider {
+ relocatedProtobuf.resolvedConfiguration.resolvedArtifacts.single { it.name == "protobuf-relocated" && it.classifier == "sources" }.file
+ }
+) {
classifier = "sources"
}
+
+publishing {
+ publications {
+ create("maven") {
+ artifact(mainArtifact)
+ artifact(sourcesArtifact)
+ }
+ }
+
+ repositories {
+ maven {
+ url = uri("${rootProject.buildDir}/internal/repo")
+ }
+ }
+}
diff --git a/custom-dependencies/protobuf/protobuf-relocated/build.gradle.kts b/custom-dependencies/protobuf/protobuf-relocated/build.gradle.kts
index 4e20d76d49c..98c077ec55e 100644
--- a/custom-dependencies/protobuf/protobuf-relocated/build.gradle.kts
+++ b/custom-dependencies/protobuf/protobuf-relocated/build.gradle.kts
@@ -2,61 +2,79 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.io.File
plugins {
- base
- id("pill-configurable")
+ `java-base`
+ `maven-publish`
+ id("com.github.johnrengelman.shadow") version "4.0.3" apply false
+}
+
+repositories {
+ jcenter()
}
val baseProtobuf by configurations.creating
val baseProtobufSources by configurations.creating
-val resultsCfg = configurations.getByName("default")
-val resultsSourcesCfg = configurations.create("sources")
-
-val protobufVersion = rootProject.extra["versions.protobuf-java"] as String
+val protobufVersion: String by rootProject.extra
val protobufJarPrefix = "protobuf-$protobufVersion"
val renamedSources = "$buildDir/renamedSrc/"
val outputJarsPath = "$buildDir/libs"
-val artifactBaseName = "protobuf-java-relocated"
-
-pill {
- libraryPath = File(outputJarsPath)
-}
-
-setProperty("archivesBaseName", "$artifactBaseName-$protobufVersion")
dependencies {
baseProtobuf("com.google.protobuf:protobuf-java:$protobufVersion")
baseProtobufSources("com.google.protobuf:protobuf-java:$protobufVersion:sources")
}
-val prepare by task {
+val prepare = task("prepare") {
destinationDir = File(outputJarsPath)
- baseName = artifactBaseName
version = protobufVersion
classifier = ""
- from(baseProtobuf.files.find { it.name.startsWith("protobuf-java") }?.canonicalPath)
+ from(
+ provider {
+ baseProtobuf.files.find { it.name.startsWith("protobuf-java") }?.canonicalPath
+ }
+ )
relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf" ) {
exclude("META-INF/maven/com.google.protobuf/protobuf-java/pom.properties")
}
- addArtifact("archives", this, this)
- addArtifact(resultsCfg.name, this, this)
}
-val relocateSources by task {
- from(zipTree(baseProtobufSources.files.find { it.name.startsWith("protobuf-java") && it.name.endsWith("-sources.jar") }
- ?: throw GradleException("sources jar not found among ${baseProtobufSources.files}")))
+artifacts.add("default", prepare)
+
+val relocateSources = task("relocateSources") {
+ from(
+ provider {
+ zipTree(baseProtobufSources.files.find { it.name.startsWith("protobuf-java") && it.name.endsWith("-sources.jar") }
+ ?: throw GradleException("sources jar not found among ${baseProtobufSources.files}"))
+ }
+ )
+
into(renamedSources)
+
filter { it.replace("com.google.protobuf", "org.jetbrains.kotlin.protobuf") }
}
-val prepareSources by task {
+val prepareSources = task("prepareSources") {
destinationDir = File(outputJarsPath)
- baseName = artifactBaseName
version = protobufVersion
classifier = "sources"
from(relocateSources)
- project.addArtifact("archives", this, this)
- addArtifact(resultsSourcesCfg.name, this, this)
-}
\ No newline at end of file
+}
+
+artifacts.add("default", prepareSources)
+
+publishing {
+ publications {
+ create("maven") {
+ artifact(prepare)
+ artifact(prepareSources)
+ }
+ }
+
+ repositories {
+ maven {
+ url = uri("${rootProject.buildDir}/internal/repo")
+ }
+ }
+}
diff --git a/custom-dependencies/protobuf/settings.gradle b/custom-dependencies/protobuf/settings.gradle
new file mode 100644
index 00000000000..c8dbba7a5cf
--- /dev/null
+++ b/custom-dependencies/protobuf/settings.gradle
@@ -0,0 +1 @@
+include ":protobuf-lite", ":protobuf-relocated"
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index da0cf825aad..90affe6c207 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -73,8 +73,6 @@ include ":kotlin-build-common",
":core:metadata.jvm",
":core:builtins",
":core:util.runtime",
- ":custom-dependencies:protobuf:protobuf-relocated",
- ":custom-dependencies:protobuf:protobuf-lite",
":custom-dependencies:android-sdk",
":idea:fir-view",
":idea:idea-jvm",
@@ -349,3 +347,6 @@ project(':kotlinx-serialization-ide-plugin').projectDir = file("$rootDir/plugins
project(':kotlin-serialization').projectDir = file("$rootDir/libraries/tools/kotlin-serialization")
project(':kotlin-serialization-unshaded').projectDir = file("$rootDir/libraries/tools/kotlin-serialization-unshaded")
project(':kotlin-idl2k').projectDir = file("$rootDir/libraries/tools/idl2k")
+
+
+includeBuild("custom-dependencies/protobuf")