-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
181 lines (155 loc) · 5.28 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import org.gradle.jvm.tasks.Jar
import java.io.ByteArrayOutputStream
import java.time.Instant
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.util.Properties
val localPropertiesFile = project.rootProject.file("local.properties")
val localProperties = Properties()
if (localPropertiesFile.canRead())
localProperties.load(localPropertiesFile.inputStream())
plugins {
kotlin("jvm") version "1.9.23"
kotlin("plugin.serialization") version "1.9.23"
id("maven-publish")
signing
id("com.palantir.git-version") version "3.0.0"
id("org.jetbrains.dokka") version "1.9.20"
id("com.github.jk1.dependency-license-report") version "2.8"
}
fun run(command: String): String {
ByteArrayOutputStream().use { output ->
exec {
commandLine("sh", "-c", command)
standardOutput = output
}
return output.toString().trim()
}
}
val versionDetails: groovy.lang.Closure<com.palantir.gradle.gitversion.VersionDetails> by extra
fun version(): String = versionDetails().run {
if (commitDistance == 0 && isCleanTag && lastTag.matches(Regex("""\d+\.\d+\.\d+""")))
version
else (
System.getenv("GITHUB_RUN_NUMBER")?.let { "ci-${branchName}-$it-${gitHash}" }
?: "dev-${branchName}-${
DateTimeFormatter.ofPattern("yyyyMMddHHmmss").withZone(ZoneId.of("UTC")).format(Instant.now())
}-${gitHash}"
)
}
group = "com.eidu"
version = version()
kotlin {
jvmToolchain(8)
}
licenseReport {
allowedLicensesFile = File("$projectDir/allowed-licenses.json")
}
tasks.named("checkLicense") {
// The checkLicense task does not declare this input itself, so we do it here. This ensures
// that a modification of the file causes the checkLicense task to be re-evaluated.
inputs.file("$projectDir/allowed-licenses.json")
}
tasks.named("check") {
dependsOn("checkLicense")
}
repositories {
mavenCentral()
}
dependencies {
// Kotlin JVM
api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23")
// KotlinX Serialization
api("org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.3")
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
// Logging
api("org.slf4j:slf4j-api:2.0.12")
// Learning Packages
implementation("net.dongliu:apk-parser:2.6.10")
// Unit Tests
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.2")
testImplementation("io.mockk:mockk:1.13.10")
testImplementation("com.willowtreeapps.assertk:assertk:0.28.0")
}
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + listOf(
"-Xopt-in=kotlin.RequiresOptIn"
)
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + listOf(
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
)
}
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
val sourcesJar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.getByName("main").allSource)
}
publishing {
repositories {
maven {
name = "MavenCentral"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("MAVEN_CENTRAL_USERNAME")
password = System.getenv("MAVEN_CENTRAL_PASSWORD")
}
}
}
publications.create<MavenPublication>("maven") {
val javadocJar = tasks.register("javadocJar$name", Jar::class) {
archiveClassifier.set("javadoc")
archiveBaseName.set("javadoc-${[email protected]}")
from(tasks.dokkaHtml)
}
artifactId = rootProject.name
version = project.version.toString()
from(components["java"])
artifact(javadocJar.get())
artifact(sourcesJar)
pom {
name = rootProject.name
description = "Support for reading EIDU learning packages"
url = "https://github.com/EIDU/learning-packages"
licenses {
license {
name = "GNU Affero General Public License, version 3 (AGPLv3)"
url = "https://raw.githubusercontent.com/EIDU/learning-packages/main/LICENSE"
}
}
developers {
developer {
id = "berlix"
name = "Felix Engelhardt"
url = "https://github.com/berlix/"
}
}
scm {
connection = "scm:git:ssh://[email protected]/EIDU/learning-packages.git"
developerConnection = "scm:git:ssh://[email protected]/EIDU/learning-packages.git"
url = "https://github.com/EIDU/learning-packages"
}
}
signing {
useInMemoryPgpKeys(
System.getenv("SIGNING_KEY_ID"),
System.getenv("SIGNING_KEY"),
System.getenv("SIGNING_PASSWORD")
)
sign(this@create)
}
}
}
ProcessBuilder("git config --local core.hooksPath git-hooks".split(" ")).start()