Skip to content

Commit 8ca16be

Browse files
authored
Merge pull request #1409 from TeamNewPipe/kotlinDSL
2 parents 05e0e4c + 2dc56b6 commit 8ca16be

11 files changed

Lines changed: 257 additions & 172 deletions

File tree

build.gradle

Lines changed: 0 additions & 91 deletions
This file was deleted.

build.gradle.kts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 NewPipe e.V. <https://newpipe-ev.de>
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*/
5+
6+
plugins {
7+
alias(libs.plugins.google.protobuf) apply false
8+
}
9+
10+
allprojects {
11+
apply(plugin = "java-library")
12+
13+
tasks.withType<JavaCompile> {
14+
options.encoding = Charsets.UTF_8.toString()
15+
}
16+
17+
extensions.configure<JavaPluginExtension> {
18+
toolchain {
19+
languageVersion.set(JavaLanguageVersion.of(11))
20+
}
21+
}
22+
}
23+
24+
subprojects {
25+
// https://discuss.gradle.org/t/best-approach-gradle-multi-module-project-generate-just-one-global-javadoc/18657/21
26+
// Fixes unknown tag @implNote; the other two were added precautionary
27+
tasks.withType<Javadoc>().configureEach {
28+
(options as StandardJavadocDocletOptions).apply {
29+
encoding = Charsets.UTF_8.toString()
30+
links = listOf("https://docs.oracle.com/javase/11/docs/api/")
31+
tags = listOf(
32+
"apiNote:a:API Note:",
33+
"implSpec:a:Implementation Requirements:",
34+
"implNote:a:Implementation Note:"
35+
)
36+
}
37+
}
38+
}

extractor/build.gradle

Lines changed: 0 additions & 71 deletions
This file was deleted.

extractor/build.gradle.kts

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 NewPipe e.V. <https://newpipe-ev.de>
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*/
5+
6+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
7+
import org.gradle.api.tasks.testing.logging.TestLogEvent
8+
9+
plugins {
10+
alias(libs.plugins.google.protobuf)
11+
checkstyle
12+
`maven-publish`
13+
}
14+
15+
java {
16+
withSourcesJar()
17+
withJavadocJar()
18+
}
19+
20+
// Protobuf files would uselessly end up in the JAR otherwise, see
21+
// https://github.com/google/protobuf-gradle-plugin/issues/390
22+
tasks.jar {
23+
exclude("**/*.proto")
24+
includeEmptyDirs = false
25+
}
26+
27+
tasks.test {
28+
// Test logging setup
29+
testLogging {
30+
events = setOf(TestLogEvent.SKIPPED, TestLogEvent.FAILED)
31+
showStandardStreams = true
32+
exceptionFormat = TestExceptionFormat.FULL
33+
}
34+
35+
// Pass on downloader type to tests for different CI jobs. See DownloaderFactory.java and ci.yml
36+
if (System.getProperties().containsKey("downloader")) {
37+
systemProperty("downloader", System.getProperty("downloader"))
38+
}
39+
useJUnitPlatform()
40+
dependsOn(tasks.checkstyleMain) // run checkstyle when testing
41+
}
42+
43+
checkstyle {
44+
configDirectory = rootProject.file("checkstyle")
45+
isIgnoreFailures = false
46+
isShowViolations = true
47+
toolVersion = libs.versions.checkstyle.get()
48+
}
49+
50+
// Exclude Protobuf generated files from Checkstyle
51+
tasks.checkstyleMain {
52+
exclude("org/schabi/newpipe/extractor/services/youtube/protos")
53+
}
54+
55+
tasks.checkstyleTest {
56+
isEnabled = false // do not checkstyle test files
57+
}
58+
59+
dependencies {
60+
implementation(project(":timeago-parser"))
61+
62+
implementation(libs.newpipe.nanojson)
63+
implementation(libs.jsoup)
64+
implementation(libs.google.jsr305)
65+
implementation(libs.google.protobuf)
66+
67+
implementation(libs.mozilla.rhino.core)
68+
implementation(libs.mozilla.rhino.engine)
69+
70+
checkstyle(libs.puppycrawl.checkstyle)
71+
72+
testImplementation(platform(libs.junit.bom))
73+
testImplementation(libs.junit.jupiter.api)
74+
testRuntimeOnly(libs.junit.platform.launcher)
75+
testRuntimeOnly(libs.junit.jupiter.engine)
76+
testImplementation(libs.junit.jupiter.params)
77+
78+
testImplementation(libs.squareup.okhttp)
79+
testImplementation(libs.google.gson)
80+
}
81+
82+
protobuf {
83+
protoc {
84+
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.lib.get()}"
85+
}
86+
87+
generateProtoTasks {
88+
all().forEach { task ->
89+
task.builtins {
90+
named("java") {
91+
option("lite")
92+
}
93+
}
94+
}
95+
}
96+
}
97+
98+
// Run "./gradlew publishReleasePublicationToLocalRepository" to generate release JARs locally
99+
publishing {
100+
publications {
101+
create<MavenPublication>("release") {
102+
groupId = "net.newpipe"
103+
artifactId = "extractor"
104+
version = "v0.24.8"
105+
106+
afterEvaluate {
107+
from(components["java"])
108+
}
109+
110+
pom {
111+
name = "NewPipe Extractor"
112+
description = "A library for extracting data from streaming websites, used in NewPipe"
113+
url = "https://github.com/TeamNewPipe/NewPipeExtractor"
114+
115+
licenses {
116+
license {
117+
name = "GNU GENERAL PUBLIC LICENSE, Version 3"
118+
url = "https://www.gnu.org/licenses/gpl-3.0.txt"
119+
}
120+
}
121+
122+
scm {
123+
url = "https://github.com/TeamNewPipe/NewPipeExtractor"
124+
connection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git"
125+
developerConnection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git"
126+
}
127+
128+
developers {
129+
developer {
130+
id = "newpipe"
131+
name = "Team NewPipe"
132+
email = "team@newpipe.net"
133+
}
134+
}
135+
}
136+
}
137+
repositories {
138+
maven {
139+
name = "local"
140+
url = uri(layout.buildDirectory.dir("maven"))
141+
}
142+
}
143+
}
144+
}

gradle/libs.versions.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# SPDX-FileCopyrightText: 2025 NewPipe e.V. <https://newpipe-ev.de>
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
#
5+
6+
[versions]
7+
checkstyle = "10.26.1"
8+
gson = "2.13.2"
9+
jsr305 = "3.0.2"
10+
junit = "5.14.1"
11+
jsoup = "1.21.2"
12+
okhttp = "5.3.2"
13+
protobuf-lib = "4.33.2"
14+
protobuf-plugin = "0.9.6"
15+
rhino = "1.8.1"
16+
teamnewpipe-nanojson = "e9d656ddb49a412a5a0a5d5ef20ca7ef09549996"
17+
18+
[libraries]
19+
google-jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "jsr305" }
20+
google-gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
21+
google-protobuf = { module = "com.google.protobuf:protobuf-javalite", version.ref = "protobuf-lib" }
22+
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
23+
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api" }
24+
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" }
25+
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params" }
26+
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" }
27+
jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
28+
mozilla-rhino-core = { module = "org.mozilla:rhino", version.ref = "rhino" }
29+
mozilla-rhino-engine = { module = "org.mozilla:rhino-engine", version.ref = "rhino" }
30+
newpipe-nanojson = { module = "com.github.TeamNewPipe:nanojson", version.ref = "teamnewpipe-nanojson" }
31+
puppycrawl-checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" }
32+
squareup-okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
33+
34+
[plugins]
35+
google-protobuf = { id = "com.google.protobuf", version.ref = "protobuf-plugin" }

settings.gradle

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)