-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
146 lines (130 loc) · 4.01 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
plugins {
kotlin("jvm") version "1.9.10"
`maven-publish`
signing
id("org.jetbrains.dokka") version "1.9.0"
id("com.google.devtools.ksp") version "1.9.10-1.0.13" apply false
}
allprojects {
repositories {
mavenCentral()
}
}
val ktlint: Configuration by configurations.creating
dependencies {
ktlint("com.pinterest:ktlint:0.42.0")
}
val outputDir = "${project.buildDir}/reports/ktlint/"
val inputFiles = project.fileTree(mapOf("dir" to ".", "include" to "**/*.kt"))
val ktlintCheck by tasks.creating(JavaExec::class) {
inputs.files(inputFiles)
outputs.dir(outputDir)
description = "Check Kotlin code style."
classpath = ktlint
group = "verification"
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("**/*.kt")
}
val ktlintFormat by tasks.creating(JavaExec::class) {
inputs.files(inputFiles)
outputs.dir(outputDir)
description = "Fix Kotlin code style deviations."
classpath = ktlint
group = "verification"
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("-F", "**/*.kt")
}
subprojects {
apply(plugin = "kotlin")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "signing")
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "11"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "11"
}
}
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
val dokkaJar by tasks.creating(org.gradle.jvm.tasks.Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
}
val sourcesJar by tasks.creating(org.gradle.jvm.tasks.Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val pomArtifactId: String? by project
if (pomArtifactId != null) {
publishing {
publications {
create<MavenPublication>("maven") {
val versionName: String by project
val pomGroupId: String by project
groupId = pomGroupId
artifactId = pomArtifactId
version = versionName
from(components["java"])
artifact(dokkaJar)
artifact(sourcesJar)
pom {
val pomDescription: String by project
val pomUrl: String by project
val pomName: String by project
description.set(pomDescription)
url.set(pomUrl)
name.set(pomName)
scm {
val pomScmUrl: String by project
val pomScmConnection: String by project
val pomScmDevConnection: String by project
url.set(pomScmUrl)
connection.set(pomScmConnection)
developerConnection.set(pomScmDevConnection)
}
licenses {
license {
val pomLicenseName: String by project
val pomLicenseUrl: String by project
val pomLicenseDist: String by project
name.set(pomLicenseName)
url.set(pomLicenseUrl)
distribution.set(pomLicenseDist)
}
}
developers {
developer {
val pomDeveloperId: String by project
val pomDeveloperName: String by project
id.set(pomDeveloperId)
name.set(pomDeveloperName)
}
}
}
}
}
signing {
sign(publishing.publications["maven"])
}
repositories {
maven {
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
val versionName: String by project
url = if (versionName.endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
credentials {
username = project.property("NEXUS_USERNAME")?.toString()
password = project.property("NEXUS_PASSWORD")?.toString()
}
}
}
}
}
}