-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
114 lines (88 loc) · 3.36 KB
/
build.gradle.kts
File metadata and controls
114 lines (88 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import util.other.generateSource
plugins {
`kotlin-dsl`
alias(libs.plugins.conventions.jvm)
alias(libs.plugins.conventions.gradle.publish)
alias(libs.plugins.gradle.plugin.publish)
}
group = "org.jetbrains.kotlinx"
version = rootProject.libs.versions.kotlinx.rpc.get()
kotlin {
explicitApi()
jvmToolchain(17)
}
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0
languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0
}
}
dependencies {
implementation(libs.kotlin.gradle.plugin)
testImplementation(libs.kotlin.gradle.plugin)
testImplementation(gradleTestKit())
testImplementation(platform(libs.junit5.bom))
testImplementation(libs.kotlin.test.junit5)
testImplementation(libs.junit5.jupiter)
testImplementation(libs.junit5.jupiter.api)
testRuntimeOnly(libs.junit5.platform.launcher)
testImplementation(libs.logback.classic)
}
tasks.test {
val forwardOutput: Boolean = (properties.getOrDefault("gradle.test.forward.output", "false")
as String).toBooleanStrictOrNull() ?: false
systemProperty("gradle.test.forward.output", forwardOutput)
useJUnitPlatform()
val includedBuild = gradle.includedBuild("protoc-gen")
dependsOn(includedBuild.task(":grpc:publishAllPublicationsToBuildRepoRepository"))
dependsOn(includedBuild.task(":protobuf:publishAllPublicationsToBuildRepoRepository"))
}
// This block is needed to show plugin tasks on --dry-run
// and to not run task actions on ":plugin:task --dry-run".
// The bug is known since June 2017 and still not fixed.
// The workaround used below is described here: https://github.com/gradle/gradle/issues/2517#issuecomment-437490287
if (gradle.parent != null && gradle.parent!!.startParameter.isDryRun) {
gradle.startParameter.isDryRun = true
}
gradlePlugin {
plugins {
create("plugin") {
id = "org.jetbrains.kotlinx.rpc.plugin"
displayName = "kotlinx.rpc Gradle Plugin"
implementationClass = "kotlinx.rpc.RpcGradlePlugin"
description = """
The plugin ensures correct RPC configurations for your project, that will allow proper code generation.
""".trimIndent()
}
}
}
generateSource(
name = "Versions",
text = """
package kotlinx.rpc
/**
* The version of the kotlinx.rpc library.
*/
public const val LIBRARY_VERSION: String = "$version"
/**
* The version of the buf tool used to generate protobuf.
*/
public const val BUF_TOOL_VERSION: String = "${libs.versions.buf.tool.get()}"
""".trimIndent(),
chooseSourceSet = { main }
)
val globalRootDir: String by extra
generateSource(
name = "TestVersions",
text = """
package kotlinx.rpc
const val KOTLIN_VERSION: String = "${libs.versions.kotlin.lang.get()}"
const val BUILD_REPO: String = "${File(globalRootDir).resolve("build/repo").absolutePath}"
""".trimIndent(),
chooseSourceSet = { test }
)
logger.lifecycle("[Gradle Plugin] kotlinx.rpc project version: $version")