-
-
Notifications
You must be signed in to change notification settings - Fork 543
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
200 lines (169 loc) · 5.67 KB
/
build.gradle.kts
File metadata and controls
200 lines (169 loc) · 5.67 KB
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*
* SPDX-FileCopyrightText: 2025 NewPipe e.V. <https://newpipe-ev.de>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
val ciSigningKey: String? = System.getenv("PGP_PRIVATE_SIGNING_KEY")
val ciSigningPassword: String? = System.getenv("PGP_PRIVATE_SIGNING_KEY_PASSWORD")
val shouldSignCIRelease: Boolean
get() = !ciSigningKey.isNullOrEmpty() && !ciSigningPassword.isNullOrEmpty()
val lastCommitHash: String = providers.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
}.standardOutput.asText.map { it.trim() }.get()
plugins {
alias(libs.plugins.google.protobuf)
checkstyle
`maven-publish`
signing
}
java {
withSourcesJar()
withJavadocJar()
}
sourceSets {
main {
java.srcDir("../timeago-parser/src/main/java")
}
}
// Protobuf files would uselessly end up in the JAR otherwise, see
// https://github.com/google/protobuf-gradle-plugin/issues/390
tasks.jar {
exclude("**/*.proto")
includeEmptyDirs = false
}
tasks.test {
// Test logging setup
testLogging {
events = setOf(TestLogEvent.SKIPPED, TestLogEvent.FAILED)
showStandardStreams = true
exceptionFormat = TestExceptionFormat.FULL
}
// Pass on downloader type to tests for different CI jobs. See DownloaderFactory.java and ci.yml
if (System.getProperties().containsKey("downloader")) {
systemProperty("downloader", System.getProperty("downloader"))
}
useJUnitPlatform()
dependsOn(tasks.checkstyleMain) // run checkstyle when testing
}
// https://checkstyle.org/#JRE_and_JDK
tasks.withType<Checkstyle>().configureEach {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(21)
}
}
checkstyle {
configDirectory = rootProject.file("checkstyle")
isIgnoreFailures = false
isShowViolations = true
toolVersion = libs.versions.checkstyle.get()
}
// Exclude Protobuf generated files from Checkstyle
tasks.checkstyleMain {
exclude(
"org/schabi/newpipe/extractor/services/youtube/protos",
"org/schabi/newpipe/extractor/timeago"
)
}
tasks.checkstyleTest {
isEnabled = false // do not checkstyle test files
}
dependencies {
implementation(libs.newpipe.nanojson)
implementation(libs.jsoup)
implementation(libs.google.jsr305)
implementation(libs.google.protobuf)
implementation(libs.mozilla.rhino.core)
implementation(libs.mozilla.rhino.engine)
checkstyle(libs.puppycrawl.checkstyle)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.platform.launcher)
testRuntimeOnly(libs.junit.jupiter.engine)
testImplementation(libs.junit.jupiter.params)
testImplementation(libs.squareup.okhttp)
testImplementation(libs.google.gson)
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.lib.get()}"
}
generateProtoTasks {
all().forEach { task ->
task.builtins {
named("java") {
option("lite")
}
}
}
}
}
// Run "./gradlew publishReleasePublicationToLocalRepository" to generate release JARs locally
publishing {
publications {
val mavenGroupId = "net.newpipe"
val mavenArtifactId = "extractor"
fun MavenPublication.setupPOM() = pom {
name = "NewPipe Extractor"
description = "A library for extracting data from streaming websites, used in NewPipe"
url = "https://github.com/TeamNewPipe/NewPipeExtractor"
licenses {
license {
name = "GNU GENERAL PUBLIC LICENSE, Version 3"
url = "https://www.gnu.org/licenses/gpl-3.0.txt"
}
}
scm {
url = "https://github.com/TeamNewPipe/NewPipeExtractor"
connection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git"
developerConnection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git"
}
developers {
developer {
id = "newpipe"
name = "Team NewPipe"
email = "team@newpipe.net"
}
}
}
create<MavenPublication>("release") {
groupId = mavenGroupId
artifactId = mavenArtifactId
version = rootProject.version.toString()
afterEvaluate {
from(components["java"])
}
setupPOM()
}
create<MavenPublication>("snapshot") {
groupId = mavenGroupId
artifactId = mavenArtifactId
version = "$lastCommitHash-SNAPSHOT"
afterEvaluate {
from(components["java"])
}
setupPOM()
}
repositories {
maven {
name = "sonatype"
url = uri("https://central.sonatype.com/repository/maven-snapshots/")
credentials {
username = System.getenv("SONATYPE_MAVEN_CENTRAL_USERNAME")
password = System.getenv("SONATYPE_MAVEN_CENTRAL_PASSWORD")
}
}
maven {
name = "local"
url = uri(layout.buildDirectory.dir("maven"))
}
}
}
}
signing {
useInMemoryPgpKeys(ciSigningKey, ciSigningPassword)
sign(publishing.publications["snapshot"])
}
tasks.withType<Sign> {
onlyIf("Signing credentials are present (only used for maven central)") { shouldSignCIRelease }
}