-
Notifications
You must be signed in to change notification settings - Fork 81
/
build.gradle.kts
90 lines (86 loc) · 3.46 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
val developerId: String by project
val developerName: String by project
val developerUrl: String by project
val releaseGroup: String by project
val releaseArtifact: String by project
val releaseVersion: String by project
val releaseDescription: String by project
val releaseUrl: String by project
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.maven.publish) apply false
}
allprojects {
group = releaseGroup
version = releaseVersion
}
subprojects {
plugins.withType<com.android.build.gradle.LibraryPlugin>().configureEach {
modify(the<com.android.build.gradle.LibraryExtension>())
}
plugins.withType<com.android.build.gradle.AppPlugin>().configureEach {
modify(the<com.android.build.gradle.internal.dsl.BaseAppModuleExtension>())
}
plugins.withType<CheckstylePlugin>().configureEach {
configure<CheckstyleExtension> {
toolVersion = libs.versions.checkstyle.get()
configFile = rootDir.resolve("rulebook_checks.xml")
}
// only in Android, checkstyle task need to be manually defined
tasks {
val checkstyle = register<Checkstyle>("checkstyle") {
group = LifecycleBasePlugin.VERIFICATION_GROUP
source("src")
include("**/*.java")
exclude("**/gen/**", "**/R.java")
classpath = files()
}
named("check").get().dependsOn(checkstyle)
}
}
plugins.withType<com.vanniktech.maven.publish.MavenPublishBasePlugin> {
configure<com.vanniktech.maven.publish.MavenPublishBaseExtension> {
configure(com.vanniktech.maven.publish.AndroidSingleVariantLibrary())
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.Companion.S01)
signAllPublications()
pom {
name.set(project.name)
description.set(releaseDescription)
url.set(releaseUrl)
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set(developerId)
name.set(developerName)
url.set(developerUrl)
}
}
scm {
url.set(releaseUrl)
connection.set("scm:git:https://github.com/$developerId/$releaseArtifact.git")
developerConnection.set("scm:git:ssh://[email protected]/$developerId/$releaseArtifact.git")
}
}
}
}
}
fun modify(extension: com.android.build.gradle.BaseExtension) {
extension.setCompileSdkVersion(libs.versions.sdk.target.get().toInt())
extension.defaultConfig {
minSdk = libs.versions.sdk.min.get().toInt()
targetSdk = libs.versions.sdk.target.get().toInt()
version = releaseVersion
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
extension.compileOptions {
targetCompatibility = JavaVersion.toVersion(libs.versions.jdk.get())
sourceCompatibility = JavaVersion.toVersion(libs.versions.jdk.get())
}
}