diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 87f3709e41..0000000000 --- a/build.gradle +++ /dev/null @@ -1,91 +0,0 @@ -allprojects { - apply plugin: 'java-library' - apply plugin: 'maven-publish' - - compileJava.options.encoding = 'UTF-8' - compileTestJava.options.encoding = 'UTF-8' - - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - - version 'v0.24.8' - group 'com.github.TeamNewPipe' - - repositories { - mavenCentral() - maven { url "https://jitpack.io" } - } - - afterEvaluate { - publishing { - publications { - mavenJava(MavenPublication) { - from components.java - } - } - } - } - - ext { - nanojsonVersion = "e9d656ddb49a412a5a0a5d5ef20ca7ef09549996" - jsr305Version = "3.0.2" - junitVersion = "5.14.1" - checkstyleVersion = "10.26.1" - } -} - -dependencies { - api project(':extractor') - implementation project(':timeago-parser') -} - -subprojects { - tasks.register('sourcesJar', Jar) { - dependsOn classes - archiveClassifier.set('sources') - from sourceSets.main.allSource - } - - // Protobuf files would uselessly end up in the JAR otherwise, see - // https://github.com/google/protobuf-gradle-plugin/issues/390 - tasks.withType(Jar).configureEach { - exclude '**/*.proto' - includeEmptyDirs false - } - - tasks.withType(Test).configureEach { - testLogging { - events "skipped", "failed" - showStandardStreams = true - exceptionFormat = 'full' - } - } - - artifacts { - archives sourcesJar - } -} - -// https://discuss.gradle.org/t/best-approach-gradle-multi-module-project-generate-just-one-global-javadoc/18657/21 -tasks.register('aggregatedJavadocs', Javadoc) { - destinationDir = layout.buildDirectory.file("docs/javadoc").get().asFile - title = "$project.name $version" - // options.memberLevel = JavadocMemberLevel.PRIVATE - options.links 'https://docs.oracle.com/javase/11/docs/api/' - options.encoding 'UTF-8' - // Fixes unknown tag @implNote; the other two were added precautionary - options.tags = [ - "apiNote:a:API Note:", - "implSpec:a:Implementation Requirements:", - "implNote:a:Implementation Note:" - ] - - subprojects.each { project -> - project.tasks.withType(Javadoc).each { javadocTask -> - source += javadocTask.source - classpath += javadocTask.classpath - excludes += javadocTask.excludes - includes += javadocTask.includes - } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000000..22e20dfdfb --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,38 @@ +/* + * SPDX-FileCopyrightText: 2025 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +plugins { + alias(libs.plugins.google.protobuf) apply false +} + +allprojects { + apply(plugin = "java-library") + + tasks.withType { + options.encoding = Charsets.UTF_8.toString() + } + + extensions.configure { + toolchain { + languageVersion.set(JavaLanguageVersion.of(11)) + } + } +} + +subprojects { + // https://discuss.gradle.org/t/best-approach-gradle-multi-module-project-generate-just-one-global-javadoc/18657/21 + // Fixes unknown tag @implNote; the other two were added precautionary + tasks.withType().configureEach { + (options as StandardJavadocDocletOptions).apply { + encoding = Charsets.UTF_8.toString() + links = listOf("https://docs.oracle.com/javase/11/docs/api/") + tags = listOf( + "apiNote:a:API Note:", + "implSpec:a:Implementation Requirements:", + "implNote:a:Implementation Note:" + ) + } + } +} diff --git a/extractor/build.gradle b/extractor/build.gradle deleted file mode 100644 index 22da78a09e..0000000000 --- a/extractor/build.gradle +++ /dev/null @@ -1,71 +0,0 @@ -plugins { - id "checkstyle" - id "com.google.protobuf" version "0.9.6" -} - -test { - // Pass on downloader type to tests for different CI jobs. See DownloaderFactory.java and ci.yml - if (System.properties.containsKey('downloader')) { - systemProperty('downloader', System.getProperty('downloader')) - } - useJUnitPlatform() - dependsOn checkstyleMain // run checkstyle when testing -} - -checkstyle { - getConfigDirectory().set(rootProject.file("checkstyle")) - ignoreFailures false - showViolations true - toolVersion checkstyleVersion -} - -// Exclude Protobuf generated files from Checkstyle -checkstyleMain.exclude("org/schabi/newpipe/extractor/services/youtube/protos") - -checkstyleTest { - enabled false // do not checkstyle test files -} - -ext { - rhinoVersion = '1.8.1' - protobufVersion = '4.33.2' -} - -dependencies { - implementation project(':timeago-parser') - - implementation "com.github.TeamNewPipe:nanojson:$nanojsonVersion" - implementation 'org.jsoup:jsoup:1.21.2' - implementation "com.google.code.findbugs:jsr305:$jsr305Version" - implementation "com.google.protobuf:protobuf-javalite:$protobufVersion" - - implementation "org.mozilla:rhino:$rhinoVersion" - implementation "org.mozilla:rhino-engine:$rhinoVersion" - - checkstyle "com.puppycrawl.tools:checkstyle:$checkstyleVersion" - - testImplementation platform("org.junit:junit-bom:$junitVersion") - testImplementation 'org.junit.jupiter:junit-jupiter-api' - testRuntimeOnly 'org.junit.platform:junit-platform-launcher' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' - testImplementation 'org.junit.jupiter:junit-jupiter-params' - - testImplementation "com.squareup.okhttp3:okhttp:5.3.2" - testImplementation 'com.google.code.gson:gson:2.13.2' -} - -protobuf { - protoc { - artifact = "com.google.protobuf:protoc:$protobufVersion" - } - - generateProtoTasks { - all().configureEach { task -> - task.builtins { - java { - option "lite" - } - } - } - } -} diff --git a/extractor/build.gradle.kts b/extractor/build.gradle.kts new file mode 100644 index 0000000000..3e90d45d79 --- /dev/null +++ b/extractor/build.gradle.kts @@ -0,0 +1,144 @@ +/* + * SPDX-FileCopyrightText: 2025 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.gradle.api.tasks.testing.logging.TestLogEvent + +plugins { + alias(libs.plugins.google.protobuf) + checkstyle + `maven-publish` +} + +java { + withSourcesJar() + withJavadocJar() +} + +// 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 +} + +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") +} + +tasks.checkstyleTest { + isEnabled = false // do not checkstyle test files +} + +dependencies { + implementation(project(":timeago-parser")) + + 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 { + create("release") { + groupId = "net.newpipe" + artifactId = "extractor" + version = "v0.24.8" + + afterEvaluate { + from(components["java"]) + } + + 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" + } + } + } + } + repositories { + maven { + name = "local" + url = uri(layout.buildDirectory.dir("maven")) + } + } + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000000..770df7cc11 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,35 @@ +# +# SPDX-FileCopyrightText: 2025 NewPipe e.V. +# SPDX-License-Identifier: GPL-3.0-or-later +# + +[versions] +checkstyle = "10.26.1" +gson = "2.13.2" +jsr305 = "3.0.2" +junit = "5.14.1" +jsoup = "1.21.2" +okhttp = "5.3.2" +protobuf-lib = "4.33.2" +protobuf-plugin = "0.9.6" +rhino = "1.8.1" +teamnewpipe-nanojson = "e9d656ddb49a412a5a0a5d5ef20ca7ef09549996" + +[libraries] +google-jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "jsr305" } +google-gson = { module = "com.google.code.gson:gson", version.ref = "gson" } +google-protobuf = { module = "com.google.protobuf:protobuf-javalite", version.ref = "protobuf-lib" } +junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" } +junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api" } +junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" } +junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params" } +junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" } +jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" } +mozilla-rhino-core = { module = "org.mozilla:rhino", version.ref = "rhino" } +mozilla-rhino-engine = { module = "org.mozilla:rhino-engine", version.ref = "rhino" } +newpipe-nanojson = { module = "com.github.TeamNewPipe:nanojson", version.ref = "teamnewpipe-nanojson" } +puppycrawl-checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" } +squareup-okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } + +[plugins] +google-protobuf = { id = "com.google.protobuf", version.ref = "protobuf-plugin" } diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 81908ff580..0000000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -include 'extractor', 'timeago-parser', 'timeago-generator' -rootProject.name = 'NewPipeExtractor' \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000000..9ad111c29c --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2025 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + maven(url = "https://jitpack.io") + } +} +include("extractor", "timeago-parser", "timeago-generator") +rootProject.name = "NewPipeExtractor" diff --git a/timeago-generator/build.gradle b/timeago-generator/build.gradle deleted file mode 100644 index 8e8e73907d..0000000000 --- a/timeago-generator/build.gradle +++ /dev/null @@ -1,5 +0,0 @@ -dependencies { - implementation "com.github.TeamNewPipe:nanojson:$nanojsonVersion" - implementation "com.google.code.findbugs:jsr305:$jsr305Version" - implementation project(":timeago-parser") -} diff --git a/timeago-generator/build.gradle.kts b/timeago-generator/build.gradle.kts new file mode 100644 index 0000000000..a031834ec1 --- /dev/null +++ b/timeago-generator/build.gradle.kts @@ -0,0 +1,10 @@ +/* + * SPDX-FileCopyrightText: 2025 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +dependencies { + implementation(libs.newpipe.nanojson) + implementation(libs.google.jsr305) + implementation(project(":timeago-parser")) +} diff --git a/timeago-parser/build.gradle b/timeago-parser/build.gradle deleted file mode 100644 index 7e1cbb679d..0000000000 --- a/timeago-parser/build.gradle +++ /dev/null @@ -1,3 +0,0 @@ -dependencies { - implementation "com.google.code.findbugs:jsr305:$jsr305Version" -} diff --git a/timeago-parser/build.gradle.kts b/timeago-parser/build.gradle.kts new file mode 100644 index 0000000000..32926250ac --- /dev/null +++ b/timeago-parser/build.gradle.kts @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2025 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +dependencies { + implementation(libs.google.jsr305) +}