-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbuild.gradle.kts
118 lines (98 loc) · 3.6 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
110
111
112
113
114
115
116
117
118
@file:Suppress("UnusedPrivateProperty", "UnstableApiUsage")
import java.io.FileNotFoundException
plugins {
`kotlin-dsl`
signing
id("com.gradle.plugin-publish") version "1.2.1"
id("io.gitlab.arturbosch.detekt") version "1.23.6"
}
group = "org.gradle.toolchains"
val pluginVersion = property("pluginVersion") ?: throw GradleException("`pluginVersion` missing in gradle.properties!")
version = pluginVersion
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}
detekt {
buildUponDefaultConfig = true // preconfigure defaults
config.setFrom(project.rootProject.file("gradle/detekt.yml"))
// also check the project build file
source.from(project.buildFile)
}
dependencies {
implementation("com.google.code.gson:gson:2.10.1")
}
gradlePlugin {
vcsUrl = "https://github.com/gradle/foojay-toolchains"
website = "https://github.com/gradle/foojay-toolchains"
val discoToolchains by plugins.creating {
id = "org.gradle.toolchains.foojay-resolver"
implementationClass = "org.gradle.toolchains.foojay.FoojayToolchainsPlugin"
displayName = "Foojay Disco API Toolchains Resolver"
description = "Toolchains resolver using the Foojay Disco API for resolving Java runtimes."
tags = listOf("gradle", "toolchains")
}
val discoToolchainsConvenience by plugins.creating {
id = "org.gradle.toolchains.foojay-resolver-convention"
implementationClass = "org.gradle.toolchains.foojay.FoojayToolchainsConventionPlugin"
displayName = "Foojay Disco API Toolchains Resolver Convention"
description = "Toolchains resolver using the Foojay Disco API for resolving Java runtimes. Automatically configures toolchain management."
tags = listOf("gradle", "toolchains")
}
}
publishing {
repositories {
maven {
url = uri(layout.projectDirectory.dir("repo"))
}
}
}
signing {
useInMemoryPgpKeys(
project.providers.environmentVariable("PGP_SIGNING_KEY").orNull,
project.providers.environmentVariable("PGP_SIGNING_KEY_PASSPHRASE").orNull
)
setRequired({
providers.environmentVariable("CI").isPresent
})
}
testing {
suites {
val functionalTest by registering(JvmTestSuite::class) {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-test-junit5")
}
}
val test by getting(JvmTestSuite::class) {
useJUnitJupiter()
dependencies {
implementation("org.jetbrains.kotlin:kotlin-test-junit5")
}
}
}
}
gradlePlugin.testSourceSets(sourceSets.getAt("functionalTest"))
tasks.check {
// Run the functional tests as part of `check`
dependsOn(testing.suites.named("functionalTest"))
}
val readReleaseNotes by tasks.registering {
description = "Ensure we've got some release notes handy"
doLast {
val releaseNotesFile = file("release-notes-$version.txt")
if (!releaseNotesFile.exists()) {
throw FileNotFoundException("Couldn't find release notes file ${releaseNotesFile.absolutePath}")
}
val releaseNotes = releaseNotesFile.readText().trim()
require(!releaseNotes.isBlank()) { "Release notes file ${releaseNotesFile.absolutePath} is empty" }
gradlePlugin.plugins["discoToolchains"].description = releaseNotes
gradlePlugin.plugins["discoToolchainsConvenience"].description = releaseNotes
}
}
tasks.publishPlugins {
dependsOn(readReleaseNotes)
}
tasks.check {
dependsOn(tasks.named("detektTest"), tasks.named("detektFunctionalTest"))
}