-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
127 lines (106 loc) · 3.84 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
@file:Suppress("UnstableApiUsage")
import com.vanniktech.maven.publish.SonatypeHost
import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`kotlin-dsl`
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.binaryCompatibilityValidator)
alias(libs.plugins.detekt)
alias(libs.plugins.mavenPublish)
}
group = property("GROUP") as String
version = property("VERSION_NAME") as String
mavenPublishing {
publishToMavenCentral(SonatypeHost.S01, automaticRelease = true)
signAllPublications()
}
gradlePlugin {
website.set(property("POM_URL") as String)
vcsUrl.set(property("POM_SCM_URL") as String)
plugins.create("appVersioning") {
id = "io.github.reactivecircus.app-versioning"
displayName = "Android App Versioning Gradle Plugin."
description = "Gradle plugin for lazily generating Android app's versionCode & versionName from Git tags."
tags.set(listOf("android", "versioning"))
implementationClass = "io.github.reactivecircus.appversioning.AppVersioningPlugin"
}
}
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(23))
vendor.set(JvmVendorSpec.AZUL)
}
}
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
freeCompilerArgs.addAll(
"-Xjvm-default=all",
)
}
}
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()
}
val fixtureClasspath: Configuration by configurations.creating
tasks.pluginUnderTestMetadata {
pluginClasspath.from(fixtureClasspath)
}
val functionalTestSourceSet: SourceSet = sourceSets.create("functionalTest") {
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
runtimeClasspath += output + compileClasspath
}
val functionalTestImplementation: Configuration = configurations.getByName("functionalTestImplementation")
.extendsFrom(configurations.getByName("testImplementation"))
gradlePlugin.testSourceSets(functionalTestSourceSet)
val functionalTest by tasks.registering(Test::class) {
failFast = true
testLogging {
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
testClassesDirs = functionalTestSourceSet.output.classesDirs
classpath = functionalTestSourceSet.runtimeClasspath
}
val check by tasks.getting(Task::class) {
dependsOn(functionalTest)
}
val test by tasks.getting(Test::class) {
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
testLogging {
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
}
val fixtureAgpVersion: Provider<String> = providers
.environmentVariable("AGP_VERSION")
.orElse(providers.gradleProperty("AGP_VERSION"))
.orElse(libs.versions.agp.asProvider())
dependencies {
compileOnly(libs.agp.build)
compileOnly(libs.agp.common)
testImplementation(libs.junit)
testImplementation(libs.truth)
fixtureClasspath(libs.agp.build.flatMap { dependency ->
fixtureAgpVersion.map { version ->
"${dependency.group}:${dependency.name}:$version"
}
})
}
detekt {
source.from(files("src/"))
config.from(files("${project.rootDir}/detekt.yml"))
buildUponDefaultConfig = true
allRules = true
}
tasks.withType<Detekt>().configureEach {
jvmTarget = JvmTarget.JVM_22.target
reports {
html.outputLocation.set(file("build/reports/detekt/${project.name}.html"))
}
}
val detektFormatting = libs.plugin.detektFormatting.get()
dependencies.add("detektPlugins", detektFormatting)