forked from Kotlin/kotlinx-kover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
109 lines (85 loc) · 3.58 KB
/
build.gradle.kts
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
plugins {
kotlin("jvm") version "1.6.10"
`java-gradle-plugin`
`maven-publish`
signing
}
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
sourceSets {
create("functionalTest") {
compileClasspath += sourceSets.main.get().output + configurations.testRuntimeClasspath
runtimeClasspath += output + compileClasspath
}
}
dependencies {
implementation(gradleApi())
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
compileOnly("com.android.tools.build:gradle:4.2.2")
testImplementation(kotlin("test"))
"functionalTestImplementation"(gradleTestKit())
// dependencies only for plugin's classpath to work with Kotlin Multi-Platform and Android plugins
"functionalTestCompileOnly"("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
"functionalTestCompileOnly"("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.6.10")
"functionalTestCompileOnly"("org.jetbrains.kotlin:kotlin-compiler-runner:1.6.10")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.register<Test>("functionalTest") {
group = "verification"
testClassesDirs = sourceSets["functionalTest"].output.classesDirs
classpath = sourceSets["functionalTest"].runtimeClasspath
// While gradle testkit supports injection of the plugin classpath it doesn't allow using dependency notation
// to determine the actual runtime classpath for the plugin. It uses isolation, so plugins applied by the build
// script are not visible in the plugin classloader. This means optional dependencies (dependent on applied plugins -
// for example kotlin multiplatform) are not visible even if they are in regular gradle use. This hack will allow
// extending the classpath. It is based upon: https://docs.gradle.org/6.0/userguide/test_kit.html#sub:test-kit-classpath-injection
// Create a configuration to register the dependencies against
doFirst {
val file = File(temporaryDir, "plugin-classpath.txt")
file
.writeText(sourceSets["functionalTest"].compileClasspath.joinToString("\n"))
systemProperties["plugin-classpath"] = file.absolutePath
}
}
tasks.check { dependsOn("functionalTest") }
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
languageVersion = "1.5"
allWarningsAsErrors = true
// Suppress the warning about kotlin-reflect 1.3 and kotlin-stdlib 1.4 in the classpath.
// It's incorrect in this case because we're limiting API version to 1.3 anyway.
freeCompilerArgs = freeCompilerArgs + "-Xskip-runtime-version-check"
}
}
// override version in deploy
properties["DeployVersion"]?.let { version = it }
publishing {
publications {
// `pluginMaven` - standard name for the publication task of the `java-gradle-plugin`
create<MavenPublication>("pluginMaven") {
// `java` component will be added by the `java-gradle-plugin` later
addExtraMavenArtifacts(project, project.sourceSets.main.get().allSource)
}
}
addMavenRepository(project)
addMavenMetadata()
publications.withType(MavenPublication::class).all {
signPublicationIfKeyPresent(project)
}
}
gradlePlugin {
plugins {
create("Kover") {
id = "org.jetbrains.kotlinx.kover"
implementationClass = "kotlinx.kover.KoverPlugin"
displayName = "Kotlin Code Coverage Plugin"
description = "Evaluate code coverage for projects written in Kotlin"
}
}
}