-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
102 lines (86 loc) · 3.41 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
102 lines (86 loc) · 3.41 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
import com.vanniktech.maven.publish.GradlePublishPlugin
import org.gradle.plugins.signing.Sign
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlin.jvm)
`java-gradle-plugin`
alias(libs.plugins.plugin.publish)
alias(libs.plugins.maven.publish)
}
group = providers.gradleProperty("GROUP").get()
version = providers.gradleProperty("VERSION_NAME").get()
description = providers.gradleProperty("POM_DESCRIPTION").get()
dependencies {
implementation(libs.gson)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
testImplementation(gradleApi())
testRuntimeOnly(libs.junit.platform.launcher)
}
// Compile to JVM 17 bytecode so the plugin runs on any Gradle build using JDK 17+,
// even though this project may be built with a newer JDK.
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
gradlePlugin {
website.set(providers.gradleProperty("POM_URL"))
vcsUrl.set(providers.gradleProperty("POM_URL"))
plugins {
create("testingbot") {
id = "com.testingbot.gradle"
displayName = "TestingBot Gradle Plugin"
description = providers.gradleProperty("POM_DESCRIPTION").get()
implementationClass = "com.testingbot.gradle.TestingBotPlugin"
tags.set(listOf("testingbot", "espresso", "android", "mobile-testing", "app-automate"))
}
}
}
// --- Functional tests (Gradle TestKit) --------------------------------------
val functionalTest: SourceSet = sourceSets.create("functionalTest")
gradlePlugin.testSourceSets(functionalTest)
configurations["functionalTestImplementation"].extendsFrom(configurations["testImplementation"])
configurations["functionalTestRuntimeOnly"].extendsFrom(configurations["testRuntimeOnly"])
dependencies {
"functionalTestImplementation"(gradleTestKit())
}
val functionalTestTask = tasks.register<Test>("functionalTest") {
description = "Runs the functional tests using Gradle TestKit."
group = LifecycleBasePlugin.VERIFICATION_GROUP
testClassesDirs = functionalTest.output.classesDirs
classpath = functionalTest.runtimeClasspath
useJUnitPlatform()
shouldRunAfter(tasks.named("test"))
}
tasks.named("check") {
dependsOn(functionalTestTask)
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
// --- Publishing: Gradle Plugin Portal (plugin-publish) + Maven Central -------
mavenPublishing {
// Use the GradlePublishPlugin platform because com.gradle.plugin-publish already
// creates the publication, the sources/javadoc jars, and the plugin marker.
configure(GradlePublishPlugin())
// vanniktech 0.32+ targets the Central Portal only, so no SonatypeHost argument.
publishToMavenCentral(automaticRelease = true)
signAllPublications()
}
// Only sign when a key is configured (it is in the publish workflow). This keeps
// `build`, `publishPlugins --validate-only` and `publishToMavenLocal` working locally
// and in no-secrets PR builds, while Maven Central releases are still signed in CI.
val hasSigningKey =
providers.gradleProperty("signingInMemoryKey").isPresent ||
providers.gradleProperty("signing.keyId").isPresent
tasks.withType<Sign>().configureEach {
onlyIf { hasSigningKey }
}