forked from jeremymailen/kotlinter-gradle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
154 lines (130 loc) · 4.04 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
154
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.5.20"
id("com.gradle.plugin-publish") version "0.15.0"
`java-gradle-plugin`
`maven-publish`
id("org.jmailen.kotlinter") version "3.4.5"
idea
}
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 = "3.5.0"
group = "org.jmailen.gradle"
description = projectDescription
object Versions {
const val androidTools = "4.2.2"
const val jetbrainsAnnotations = "20.1.0"
const val junit = "4.13.2"
const val ktlint = "0.42.1"
const val mockitoKotlin = "3.1.0"
}
dependencies {
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin")
compileOnly("com.android.tools.build:gradle:${Versions.androidTools}")
listOf(
"ktlint-core",
"ktlint-reporter-checkstyle",
"ktlint-reporter-json",
"ktlint-reporter-html",
"ktlint-reporter-plain",
"ktlint-ruleset-experimental",
"ktlint-ruleset-standard"
).forEach { module ->
implementation("com.pinterest.ktlint:$module:${Versions.ktlint}")
}
testImplementation("junit:junit:${Versions.junit}")
testImplementation("org.mockito.kotlin:mockito-kotlin:${Versions.mockitoKotlin}")
testImplementation("org.jetbrains:annotations:${Versions.jetbrainsAnnotations}")
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
tasks {
val generateVersionProperties = register("generateVersionProperties") {
doLast {
val resourcesDir = sourceSets.main.get().resources.sourceDirectories.asPath
File(mkdir(resourcesDir), "version.properties").writeText("version = $version")
}
}
processResources {
dependsOn(generateVersionProperties)
}
withType<KotlinCompile>().configureEach {
kotlinOptions {
apiVersion = "1.4"
languageVersion = "1.4"
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
// Required to put the Kotlin plugin on the classpath for the functional test suite
withType<PluginUnderTestMetadata>().configureEach {
pluginClasspath.from(configurations.compileOnly)
}
wrapper {
gradleVersion = "7.1.1"
}
}
val sourcesJar by tasks.registering(Jar::class) {
dependsOn(JavaPlugin.CLASSES_TASK_NAME)
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles sources JAR"
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
gradlePlugin {
plugins {
create("kotlinterPlugin") {
id = pluginId
implementationClass = "org.jmailen.gradle.kotlinter.KotlinterPlugin"
}
}
}
pluginBundle {
website = webUrl
vcsUrl = githubUrl
description = project.description
tags = listOf("kotlin", "ktlint", "lint", "format", "style", "android")
plugins {
named("kotlinterPlugin") {
displayName = "Kotlin Lint plugin"
}
}
}
artifacts {
add(configurations.archives.name, sourcesJar)
}
publishing {
publications.withType<MavenPublication> {
artifact(sourcesJar.get())
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")
}
}
}
}
}