forked from twitter/compose-rules
-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.gradle.kts
76 lines (65 loc) · 2.08 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
// Copyright 2024 Nacho Lopez
// SPDX-License-Identifier: Apache-2.0
import com.diffplug.gradle.spotless.SpotlessExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.spotless) apply false
}
allprojects {
val libs = rootProject.libs
pluginManager.apply(libs.plugins.spotless.get().pluginId)
configure<SpotlessExtension> {
val ktlintVersion = libs.versions.ktlint.get()
kotlin {
target("**/*.kt")
ktlint(ktlintVersion)
licenseHeaderFile(rootProject.file("spotless/copyright.txt"))
}
kotlinGradle {
target("*.kts")
ktlint(ktlintVersion)
}
}
plugins.withType<JavaPlugin> {
extensions.configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
// Treat all Kotlin warnings as errors
allWarningsAsErrors = true
freeCompilerArgs.addAll(
// Enable default methods in interfaces
"-Xjvm-default=all",
)
}
}
version = project.property("VERSION_NAME") ?: "0.0.0"
if (project != rootProject) {
pluginManager.apply(libs.plugins.mavenPublish.get().pluginId)
}
project.configurations.create("compileOnlyOrApi") {
isCanBeConsumed = false
isCanBeResolved = true
project.configurations.configureEach {
when {
name == "api" && project.hasProperty("uberJar") -> extendsFrom(this@create)
name == "compileOnly" -> extendsFrom(this@create)
name == "testImplementation" -> extendsFrom(this@create)
}
}
}
}
tasks.register("printVersion") {
doLast {
println(project.property("VERSION_NAME"))
}
}