-
Notifications
You must be signed in to change notification settings - Fork 50
/
build.gradle.kts
153 lines (131 loc) · 4.3 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`java-gradle-plugin`
`maven-publish`
idea
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradle.publish)
alias(libs.plugins.kotlinter)
}
repositories {
mavenCentral()
google()
}
val pluginId = "org.jmailen.kotlinter"
val githubUrl = "https://github.com/jeremymailen/kotlinter-gradle"
val webUrl = "https://github.com/jeremymailen/kotlinter-gradle"
val projectDescription = "Lint and formatting for Kotlin using ktlint with configuration-free setup on JVM and Android projects"
version = "4.4.1"
group = "org.jmailen.gradle"
description = projectDescription
configurations {
register("testRuntimeDependencies") {
extendsFrom(compileOnly.get())
attributes {
// KGP publishes multiple variants https://kotlinlang.org/docs/whatsnew17.html#support-for-gradle-plugin-variants
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME))
attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY))
}
}
configureEach {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin" && requested.name.startsWith("kotlin")) {
useVersion(getKotlinPluginVersion())
}
}
}
}
dependencies {
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin")
compileOnly(libs.android.tools.gradle)
implementation(libs.bundles.ktlint.engine)
implementation(libs.bundles.ktlint.reporters)
implementation(libs.bundles.ktlint.rulesets)
testImplementation(libs.bundles.junit.jupiter)
testImplementation(libs.commons.io)
testImplementation(libs.mockito.kotlin)
}
kotlin {
jvmToolchain(21)
}
tasks {
val generateVersionProperties = register("generateVersionProperties") {
val projectVersion = version
val propertiesFile = File(sourceSets.main.get().output.resourcesDir, "version.properties")
inputs.property("projectVersion", projectVersion)
outputs.file(propertiesFile)
doLast {
propertiesFile.writeText("version = $projectVersion")
}
}
processResources {
dependsOn(generateVersionProperties)
}
val targetJavaVersion = JavaVersion.VERSION_1_8
withType<JavaCompile>().configureEach {
options.release.set(targetJavaVersion.majorVersion.toInt())
}
withType<KotlinCompile>().configureEach {
kotlinOptions {
apiVersion = "1.8"
languageVersion = "1.8"
jvmTarget = targetJavaVersion.toString()
}
}
withType<Test>().configureEach {
useJUnitPlatform()
}
// Required to put the Kotlin plugin on the classpath for the functional test suite
withType<PluginUnderTestMetadata>().configureEach {
pluginClasspath.from(configurations.getByName("testRuntimeDependencies"))
}
wrapper {
gradleVersion = "8.9"
}
}
gradlePlugin {
website.set(webUrl)
vcsUrl.set(githubUrl)
plugins {
create("kotlinterPlugin") {
id = pluginId
displayName = "Kotlin Lint plugin"
description = project.description
tags.addAll(listOf("kotlin", "ktlint", "lint", "format", "style", "android"))
implementationClass = "org.jmailen.gradle.kotlinter.KotlinterPlugin"
}
}
}
java {
withSourcesJar()
}
publishing {
publications.withType<MavenPublication> {
pom {
name.set(project.name)
description.set(project.description)
url.set(webUrl)
scm {
url.set(githubUrl)
}
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("jeremymailen")
name.set("Jeremy Mailen")
}
developer {
id.set("mateuszkwiecinski")
name.set("Mateusz Kwieciński")
}
}
}
}
}