-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle.kts
136 lines (123 loc) · 3.94 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
@file:Suppress("SuspiciousCollectionReassignment")
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION as KOTLIN_VERSION
plugins {
`java-gradle-plugin`
alias(libs.plugins.dokka)
alias(libs.plugins.gitSemVer)
alias(libs.plugins.gradle.plugin.publish)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.qa)
alias(libs.plugins.publishOnCentral)
alias(libs.plugins.multiJvmTesting)
alias(libs.plugins.taskTree)
}
group = "org.danilopianini"
class ProjectInfo {
val projectId = "$group.$name"
val fullName = "Gradle Git-Sensitive Semantic Versioning Plugin"
val projectDetails = "A Gradle plugin that forces semantic versioning and relies on git to detect the project state"
val pluginImplementationClass = "org.danilopianini.gradle.gitsemver.GitSemVer"
val websiteUrl = "https://github.com/DanySK/$name"
val vcsUrl = "$websiteUrl.git"
val scm = "scm:git:$websiteUrl.git"
val tags = listOf("git", "semver", "semantic versioning", "vcs", "tag")
}
val info = ProjectInfo()
gitSemVer {
maxVersionLength.set(20)
buildMetadataSeparator.set("-")
}
repositories {
mavenCentral()
gradlePluginPortal()
}
multiJvm {
maximumSupportedJvmVersion.set(latestJavaSupportedByGradle)
}
dependencies {
api(gradleApi())
api(gradleKotlinDsl())
implementation(kotlin("stdlib-jdk8"))
testImplementation(gradleTestKit())
testImplementation(libs.bundles.kotlin.testing)
}
// Enforce Kotlin version coherence
configurations.matching { it.name != "detekt" }.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin" && requested.name.startsWith("kotlin")) {
useVersion(KOTLIN_VERSION)
because("All Kotlin modules should use the same version, and compiler uses $KOTLIN_VERSION")
}
}
}
publishOnCentral {
projectDescription.set(info.projectDetails)
projectLongName.set(info.fullName)
projectUrl.set(info.websiteUrl)
scmConnection.set(info.scm)
repository("https://maven.pkg.github.com/DanySK/${rootProject.name}".lowercase(), name = "github") {
user.set("danysk")
password.set(System.getenv("GITHUB_TOKEN"))
}
}
tasks {
withType<Test> {
useJUnitPlatform()
testLogging {
showCauses = true
showStackTraces = true
showStandardStreams = true
events(*TestLogEvent.values())
}
}
withType<KotlinCompile> {
kotlinOptions {
allWarningsAsErrors = true
freeCompilerArgs += listOf("-opt-in=kotlin.RequiresOptIn", "-Xinline-classes")
}
}
}
if ("true" == System.getenv("CI")) {
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
}
}
publishing {
publications {
withType<MavenPublication> {
pom {
developers {
developer {
name.set("Danilo Pianini")
email.set("danilo.pianini@gmail.com")
url.set("http://www.danilopianini.org/")
}
}
}
}
}
}
gradlePlugin {
plugins {
website.set(info.websiteUrl)
vcsUrl.set(info.vcsUrl)
create("long") {
id = info.projectId
displayName = info.fullName
description = info.projectDetails
implementationClass = info.pluginImplementationClass
tags.set(info.tags)
}
create("short") {
id = "$group.git-sensitive-semantic-versioning"
displayName = info.fullName
description = info.projectDetails
implementationClass = info.pluginImplementationClass
tags.set(info.tags)
}
}
}