|
| 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 | +} |
0 commit comments