forked from jeremymailen/kotlinter-gradle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
158 lines (134 loc) · 4.31 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
155
156
157
158
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.4.31"
id("com.gradle.plugin-publish") version "0.13.0"
`java-gradle-plugin`
`maven-publish`
id("org.jmailen.kotlinter") version "3.3.0"
idea
}
repositories {
mavenCentral()
google()
jcenter() // remove after trove4j resolved https://youtrack.jetbrains.com/issue/KT-44730
}
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.4.0"
group = "org.jmailen.gradle"
description = projectDescription
object Versions {
const val androidTools = "4.1.2"
const val jetbrainsAnnotations = "20.1.0"
const val junit = "4.13"
const val ktlint = "0.41.0"
const val mockitoKotlin = "2.2.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("com.nhaarman.mockitokotlin2:mockito-kotlin:${Versions.mockitoKotlin}")
testImplementation("org.jetbrains:annotations:${Versions.jetbrainsAnnotations}")
}
tasks {
val generateVersionProperties = create("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.3"
languageVersion = "1.3"
jvmTarget = "1.8"
}
}
// Required to put the Kotlin plugin on the classpath for the functional test suite
withType<PluginUnderTestMetadata>().configureEach {
pluginClasspath.from(configurations.compileOnly)
}
wrapper {
gradleVersion = "6.8.3"
}
}
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)
}
val javadocJar by tasks.registering(Jar::class) {
dependsOn(JavaPlugin.JAVADOC_TASK_NAME)
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles javaDoc JAR"
archiveClassifier.set("javadoc")
from(tasks["javadoc"])
}
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)
add(configurations.archives.name, javadocJar)
}
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("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("jeremymailen")
name.set("Jeremy Mailen")
}
}
}
}
}