1
+ import kotlinx.team.infra.*
2
+
3
+ val jmhVersion: String by project
4
+ val kotlin_version: String by project
5
+
6
+ buildscript {
7
+ val kotlin_version: String by project
8
+ val infra_version: String by project
9
+
10
+ val kotlinDevUrl by extra { rootProject.properties[" kotlin_repo_url" ] }
11
+ repositories {
12
+ maven(" https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/maven" )
13
+ mavenCentral()
14
+ kotlinDevUrl?.let {
15
+ maven { url = uri(it.toString()) }
16
+ }
17
+ }
18
+ dependencies {
19
+ classpath(" kotlinx.team:kotlinx.team.infra:$infra_version " )
20
+ classpath(" org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version " )
21
+ }
22
+ }
23
+
24
+ plugins {
25
+ `java- gradle- plugin`
26
+ `maven- publish`
27
+ id(" com.gradle.plugin-publish" ) version " 0.21.0"
28
+ kotlin(" jvm" ) version " 1.9.0"
29
+ }
30
+
31
+ apply (plugin = " org.jetbrains.kotlin.jvm" )
32
+ apply (plugin = " kotlinx.team.infra" )
33
+
34
+ configure<InfraExtension > {
35
+ teamcity {
36
+ libraryStagingRepoDescription = project.name
37
+ }
38
+
39
+ publishing {
40
+ include(" :" )
41
+
42
+ libraryRepoUrl = " https://github.com/Kotlin/kotlinx-benchmark"
43
+ }
44
+ }
45
+
46
+
47
+
48
+ logger.info(" Using Kotlin ${kotlin_version} for project ${project.name} " )
49
+
50
+ repositories {
51
+ mavenCentral()
52
+ gradlePluginPortal()
53
+
54
+ project.properties[" kotlinDevUrl" ]?.let { url ->
55
+ maven { setUrl(url.toString()) }
56
+ }
57
+ }
58
+
59
+ pluginBundle {
60
+ website = " https://github.com/Kotlin/kotlinx-benchmark"
61
+ vcsUrl = " https://github.com/Kotlin/kotlinx-benchmark.git"
62
+ tags = listOf (" benchmarking" , " multiplatform" , " kotlin" )
63
+ }
64
+
65
+ gradlePlugin {
66
+ plugins {
67
+ register(" benchmarkPlugin" ) {
68
+ id = " org.jetbrains.kotlinx.benchmark"
69
+ implementationClass = " kotlinx.benchmark.gradle.BenchmarksPlugin"
70
+ displayName = " Gradle plugin for benchmarking"
71
+ description = " Toolkit for running benchmarks for multiplatform Kotlin code."
72
+ }
73
+ }
74
+ }
75
+
76
+ sourceSets {
77
+ main {
78
+ kotlin.srcDir(" main/src" )
79
+ java.srcDir(" main/src" )
80
+ resources.srcDir(" main/resources" )
81
+ }
82
+ test {
83
+ kotlin.srcDir(" test/src" )
84
+ java.srcDir(" test/src" )
85
+ resources.srcDir(" test/resources" )
86
+ }
87
+ }
88
+
89
+ tasks.withType< org.jetbrains.kotlin.gradle.tasks.KotlinCompile > ().configureEach {
90
+ kotlinOptions {
91
+ freeCompilerArgs + = " -opt-in=kotlin.RequiresOptIn"
92
+ apiVersion = " 1.4"
93
+ }
94
+ }
95
+
96
+ dependencies {
97
+ implementation(" org.jetbrains.kotlin:kotlin-reflect:$kotlin_version " )
98
+ implementation(" com.squareup:kotlinpoet:1.3.0" )
99
+ implementation(" org.jetbrains.kotlin:kotlin-util-klib-metadata:$kotlin_version " )
100
+ implementation(" org.jetbrains.kotlin:kotlin-util-klib:$kotlin_version " )
101
+ implementation(" org.jetbrains.kotlin:kotlin-util-io:$kotlin_version " )
102
+ compileOnly(" org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:$kotlin_version " )
103
+ compileOnly(" org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version " )
104
+ compileOnly(" org.openjdk.jmh:jmh-generator-bytecode:$jmhVersion " )
105
+ }
106
+
107
+ tasks.register(" overridePluginVersion" ) {
108
+ description = " Overrides BenchmarksPlugin.PLUGIN_VERSION during release builds"
109
+ onlyIf {
110
+ project.findProperty(" releaseVersion" ) != null
111
+ }
112
+ doLast {
113
+ val benchmarksPluginFile = " ${projectDir} /main/src/kotlinx/benchmark/gradle/BenchmarksPlugin.kt"
114
+ val releaseVersion = project.findProperty(" releaseVersion" ) as String?
115
+ ant.withGroovyBuilder {
116
+ " replaceregexp" (
117
+ " file" to benchmarksPluginFile,
118
+ " match" to """ const val PLUGIN_VERSION = "[\d.]+-SNAPSHOT"""" ,
119
+ " replace" to """ const val PLUGIN_VERSION = "$releaseVersion """" ,
120
+ " encoding" to " UTF-8"
121
+ )
122
+ }
123
+ }
124
+ }
125
+
126
+ tasks.named(" compileKotlin" ).configure {
127
+ dependsOn(" overridePluginVersion" )
128
+ }
129
+
130
+ if (project.findProperty(" publication_repository" ) == " space" ) {
131
+ // publish to Space repository
132
+ publishing {
133
+ repositories {
134
+ maven {
135
+ name = " space"
136
+ url = uri(" https://maven.pkg.jetbrains.space/kotlin/p/kotlinx/dev" )
137
+ credentials {
138
+ username = project.findProperty(" space.user" ) as String?
139
+ password = project.findProperty(" space.token" ) as String?
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
0 commit comments