[kpm] Create new :kotlin-gradle-plugin-proto module
This commit is contained in:
committed by
Space
parent
58e2f6d5d7
commit
252c297112
@@ -15,6 +15,7 @@ if (isSnapshotTest) {
|
||||
repositories {
|
||||
clear()
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +30,8 @@ val incomingClasspath by configurations.creating {
|
||||
|
||||
dependencies {
|
||||
incomingClasspath(kotlin("gradle-plugin-idea", resolvedTestedVersion))
|
||||
incomingClasspath(testFixtures(kotlin("gradle-plugin-idea", resolvedTestedVersion)))
|
||||
incomingClasspath(kotlin("gradle-plugin-idea-proto", resolvedTestedVersion))
|
||||
}
|
||||
|
||||
val syncClasspath by tasks.register<Sync>("syncClasspath") {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
sourceSets.all {
|
||||
languageSettings.optIn("org.jetbrains.kotlin.gradle.kpm.idea.InternalKotlinGradlePluginApi")
|
||||
}
|
||||
}
|
||||
|
||||
publish()
|
||||
javadocJar()
|
||||
sourcesJar()
|
||||
|
||||
dependencies {
|
||||
api(project(":kotlin-gradle-plugin-idea"))
|
||||
implementation("com.google.protobuf:protobuf-java:3.19.4")
|
||||
implementation("com.google.protobuf:protobuf-kotlin:3.19.4")
|
||||
testImplementation(project(":kotlin-test:kotlin-test-junit"))
|
||||
testImplementation(testFixtures(project(":kotlin-gradle-plugin-idea")))
|
||||
}
|
||||
|
||||
configureKotlinCompileTasksGradleCompatibility()
|
||||
|
||||
sourceSets.main.configure {
|
||||
java.srcDir("src/generated/java")
|
||||
java.srcDir("src/generated/kotlin")
|
||||
}
|
||||
|
||||
tasks.register<Exec>("protoc") {
|
||||
val protoSources = file("src/main/proto")
|
||||
val javaOutput = file("src/generated/java/")
|
||||
val kotlinOutput = file("src/generated/kotlin/")
|
||||
|
||||
inputs.dir(protoSources)
|
||||
outputs.dir(javaOutput)
|
||||
outputs.dir(kotlinOutput)
|
||||
|
||||
doFirst {
|
||||
javaOutput.deleteRecursively()
|
||||
kotlinOutput.deleteRecursively()
|
||||
javaOutput.mkdirs()
|
||||
kotlinOutput.mkdirs()
|
||||
}
|
||||
|
||||
workingDir(project.projectDir)
|
||||
|
||||
commandLine(
|
||||
*arrayOf(
|
||||
"protoc",
|
||||
"-I=$protoSources",
|
||||
"--java_out=${javaOutput.absolutePath}",
|
||||
"--kotlin_out=${kotlinOutput.absolutePath}"
|
||||
) + protoSources.listFiles().orEmpty()
|
||||
.filter { it.extension == "proto" }
|
||||
.map { it.path },
|
||||
)
|
||||
|
||||
doLast {
|
||||
kotlinOutput.walkTopDown()
|
||||
.filter { it.extension == "kt" }
|
||||
.forEach { file -> file.writeText(file.readText().replace("public", "internal")) }
|
||||
|
||||
javaOutput.walkTopDown()
|
||||
.filter { it.extension == "java" }
|
||||
.forEach { file ->
|
||||
file.writeText(
|
||||
file.readText()
|
||||
.replace("public final class", "final class")
|
||||
.replace("public interface", "interface")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ dependencies {
|
||||
testImplementation(gradleApi())
|
||||
testImplementation(gradleKotlinDsl())
|
||||
testImplementation(project(":kotlin-gradle-plugin"))
|
||||
testImplementation(project(":kotlin-gradle-statistics"))
|
||||
testImplementation(project(":kotlin-gradle-plugin-idea-proto"))
|
||||
testImplementation(project(":kotlin-test:kotlin-test-junit"))
|
||||
|
||||
testImplementation("org.reflections:reflections:0.10.2") {
|
||||
@@ -28,6 +28,7 @@ dependencies {
|
||||
testFixturesImplementation(gradleApi())
|
||||
testFixturesImplementation(gradleKotlinDsl())
|
||||
testFixturesImplementation(project(":kotlin-tooling-core"))
|
||||
testFixturesImplementation(project(":kotlin-gradle-plugin-idea-proto"))
|
||||
testFixturesImplementation(project(":kotlin-test:kotlin-test-junit"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user