-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle.kts
127 lines (115 loc) · 3.69 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
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.kotlin.jvm)
alias(libs.plugins.dokka)
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint)
alias(libs.plugins.publishOnCentral)
alias(libs.plugins.gitSemVer)
alias(libs.plugins.publish)
alias(libs.plugins.conventional.commits)
}
group = "it.nicolasfarabegoli"
description = "Plugin to check if commits are 'Conventional Commits' compliant"
inner class ProjectInfo {
val longName = "Template for Gradle Plugins"
val website = "https://github.com/nicolasfara/conventional-commits"
val vcsUrl = "$website.git"
val scm = "scm:git:$website.git"
val pluginImplementationClass = "$group.gradle.ConventionalCommits"
val tags = listOf("conventional-commit")
}
val info = ProjectInfo()
repositories {
mavenCentral()
gradlePluginPortal()
}
java {
targetCompatibility = JavaVersion.VERSION_1_8
}
dependencies {
api(kotlin("stdlib"))
api(gradleApi())
api(gradleKotlinDsl())
testImplementation(gradleTestKit())
testImplementation(libs.bundles.kotest)
implementation(libs.mordant)
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
allWarningsAsErrors = true
}
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
exceptionFormat = TestExceptionFormat.FULL
}
}
gradlePlugin {
plugins {
website.set(info.website)
vcsUrl.set(info.vcsUrl)
create("") {
id = "$group.${project.name}"
displayName = info.longName
description = project.description
implementationClass = info.pluginImplementationClass
tags.set(info.tags)
}
}
}
// Enforce Kotlin version coherence
configurations.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")
}
}
}
signing {
if (System.getenv()["CI"].equals("true", ignoreCase = true)) {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
}
}
/*
* Publication on Maven Central and the Plugin portal
*/
publishOnCentral {
projectLongName.set(info.longName)
projectDescription.set(description ?: TODO("Missing description"))
projectUrl.set(info.website)
scmConnection.set(info.scm)
publishing {
publications {
withType<MavenPublication> {
pom {
scm {
connection.set("git:[email protected]:nicolasfara/${rootProject.name}")
developerConnection.set("git:[email protected]:nicolasfara/${rootProject.name}")
url.set("https://github.com/nicolasfara/${rootProject.name}")
}
developers {
developer {
name.set("Nicolas Farabegoli")
email.set("[email protected]")
url.set("https://www.nicolasfarabegoli.it/")
}
}
}
}
}
}
}
detekt {
config.setFrom("${rootDir.absolutePath}/detekt.yml")
}