@@ -3,6 +3,7 @@ package kotlinx.benchmark.gradle
3
3
import org.gradle.api.*
4
4
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation
5
5
import java.io.InputStream
6
+ import java.net.URLDecoder
6
7
import java.util.*
7
8
import java.util.concurrent.TimeUnit
8
9
@@ -24,15 +25,15 @@ private fun Project.generatedAndroidProjectDir(target: AndroidBenchmarkTarget, c
24
25
androidBenchmarkBuildDir(target, compilation).resolve(GENERATED_ANDROID_PROJECT_NAME )
25
26
26
27
private fun Project.createSetupAndroidProjectTask (target : AndroidBenchmarkTarget , compilation : KotlinJvmAndroidCompilation ) {
27
- task<DefaultTask >(" setup${compilation.name.capitalize()} AndroidProject" ) {
28
+ task<DefaultTask >(" setup${compilation.name.capitalize(Locale . ROOT )} AndroidProject" ) {
28
29
group = " benchmark"
29
30
description = " Sets up an empty android project to generate benchmarks into"
30
31
31
32
doFirst {
32
33
sync {
33
34
it.apply {
34
35
val pluginJarPath = BenchmarksPlugin ::class .java.protectionDomain.codeSource.location.path
35
- from(project.zipTree(pluginJarPath))
36
+ from(project.zipTree(URLDecoder .decode( pluginJarPath, " UTF-8 " ) ))
36
37
into(androidBenchmarkBuildDir(target, compilation))
37
38
include(" $GENERATED_ANDROID_PROJECT_NAME /**" )
38
39
}
@@ -55,11 +56,10 @@ private fun Project.createSetupAndroidProjectTask(target: AndroidBenchmarkTarget
55
56
}
56
57
57
58
private fun Project.createUnpackAarTask (target : AndroidBenchmarkTarget , compilation : KotlinJvmAndroidCompilation ) {
58
- // TODO: capitalize(Locale.ROOT) everywhere in the project. For toLower/UpperCase() as well.
59
- task<DefaultTask >(" unpack${compilation.name.capitalize()} Aar" ) {
59
+ task<DefaultTask >(" unpack${compilation.name.capitalize(Locale .ROOT )} Aar" ) {
60
60
group = " benchmark"
61
61
description = " Unpacks the AAR file produced by ${target.name} compilation '${compilation.name} '"
62
- dependsOn(" bundle${compilation.name.capitalize()} Aar" )
62
+ dependsOn(" bundle${compilation.name.capitalize(Locale . ROOT )} Aar" )
63
63
doLast {
64
64
logger.info(" Unpacking AAR file produced by ${target.name} compilation '${compilation.name} '" )
65
65
@@ -77,15 +77,15 @@ private fun Project.createUnpackAarTask(target: AndroidBenchmarkTarget, compilat
77
77
}
78
78
79
79
private fun generateSourcesTaskName (target : AndroidBenchmarkTarget , compilation : KotlinJvmAndroidCompilation ): String {
80
- return " ${target.name}${compilation.name.capitalize()}${BenchmarksPlugin .BENCHMARK_GENERATE_SUFFIX } "
80
+ return " ${target.name}${compilation.name.capitalize(Locale . ROOT )}${BenchmarksPlugin .BENCHMARK_GENERATE_SUFFIX } "
81
81
}
82
82
83
83
private fun Project.createAndroidBenchmarkGenerateSourceTask (target : AndroidBenchmarkTarget , compilation : KotlinJvmAndroidCompilation ) {
84
84
task<DefaultTask >(generateSourcesTaskName(target, compilation)) {
85
85
group = " benchmark"
86
86
description = " Generates Android source files for ${target.name} compilation '${compilation.name} '"
87
- dependsOn(" unpack${compilation.name.capitalize()} Aar" )
88
- dependsOn(" setup${compilation.name.capitalize()} AndroidProject" )
87
+ dependsOn(" unpack${compilation.name.capitalize(Locale . ROOT )} Aar" )
88
+ dependsOn(" setup${compilation.name.capitalize(Locale . ROOT )} AndroidProject" )
89
89
90
90
doLast {
91
91
@@ -94,7 +94,7 @@ private fun Project.createAndroidBenchmarkGenerateSourceTask(target: AndroidBenc
94
94
val targetDir = generatedAndroidProjectDir(target, compilation)
95
95
.resolve(" microbenchmark/src/androidTest/kotlin" )
96
96
97
- check( targetDir.exists() )
97
+ targetDir.mkdirs( )
98
98
99
99
generateBenchmarkSourceFiles(targetDir, classDescriptors)
100
100
}
@@ -122,7 +122,7 @@ private fun detectAndroidDevice() {
122
122
123
123
// Use shell command to execute separate project gradle task
124
124
private fun Project.createAndroidBenchmarkExecTask (target : AndroidBenchmarkTarget , compilation : KotlinJvmAndroidCompilation ) {
125
- task<DefaultTask >(" android${compilation.name.capitalize()} Benchmark" ) {
125
+ task<DefaultTask >(" android${compilation.name.capitalize(Locale . ROOT )} Benchmark" ) {
126
126
group = " benchmark"
127
127
description = " Executes benchmarks for ${target.name} compilation '${compilation.name} '"
128
128
dependsOn(generateSourcesTaskName(target, compilation))
0 commit comments