diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..77feb3181 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,44 @@ +# +# SPDX-FileCopyrightText: 2025 NewPipe e.V. +# SPDX-License-Identifier: GPL-3.0-or-later +# + +root = true + +[*.{kt,kts}] +ktlint_standard_annotation = disabled +ktlint_standard_argument-list-wrapping = disabled +ktlint_standard_backing-property-naming = disabled +ktlint_standard_blank-line-before-declaration = disabled +ktlint_standard_blank-line-between-when-conditions = disabled +ktlint_standard_chain-method-continuation = disabled +ktlint_standard_class-signature = disabled +ktlint_standard_comment-wrapping = disabled +ktlint_standard_enum-wrapping = disabled +ktlint_standard_function-expression-body = disabled +ktlint_standard_function-literal = disabled +ktlint_standard_function-signature = disabled +ktlint_standard_indent = disabled +ktlint_standard_kdoc = disabled +ktlint_standard_max-line-length = disabled +ktlint_standard_mixed-condition-operators = disabled +ktlint_standard_multiline-expression-wrapping = disabled +ktlint_standard_multiline-if-else = disabled +ktlint_standard_no-blank-line-in-list = disabled +ktlint_standard_no-consecutive-comments = disabled +ktlint_standard_no-empty-first-line-in-class-body = disabled +ktlint_standard_no-empty-first-line-in-method-block = disabled +ktlint_standard_no-line-break-after-else = disabled +ktlint_standard_no-semi = disabled +ktlint_standard_no-single-line-block-comment = disabled +ktlint_standard_package-name = disabled +ktlint_standard_parameter-list-wrapping = disabled +ktlint_standard_property-naming = disabled +ktlint_standard_spacing-between-declarations-with-annotations = disabled +ktlint_standard_spacing-between-declarations-with-comments = disabled +ktlint_standard_statement-wrapping = disabled +ktlint_standard_string-template-indent = disabled +ktlint_standard_trailing-comma-on-call-site = disabled +ktlint_standard_trailing-comma-on-declaration-site = disabled +ktlint_standard_try-catch-finally-spacing = disabled +ktlint_standard_when-entry-bracing = disabled diff --git a/.gitignore b/.gitignore index 1352b6917..49267a9f0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ captures/ *.iml *~ .weblate +.kotlin *.class app/debug/ app/release/ diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c4cd5aee9..5cf357c74 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -13,8 +13,6 @@ plugins { checkstyle } -apply(from = "check-dependencies.gradle.kts") - val gitWorkingBranch = providers.exec { commandLine("git", "rev-parse", "--abbrev-ref", "HEAD") }.standardOutput.asText.map { it.trim() } @@ -25,6 +23,15 @@ java { } } +kotlin { + compilerOptions { + // TODO: Drop annotation default target when it is stable + freeCompilerArgs.addAll( + "-Xannotation-default-target=param-property" + ) + } +} + android { compileSdk = 36 namespace = "org.schabi.newpipe" @@ -160,7 +167,7 @@ tasks.register("runKtlint") { outputs.dir(outputDir) mainClass.set("com.pinterest.ktlint.Main") classpath = configurations.getByName("ktlint") - args = listOf("src/**/*.kt") + args = listOf("--editorconfig=../.editorconfig", "src/**/*.kt") jvmArgs = listOf("--add-opens", "java.base/java.lang=ALL-UNNAMED") } @@ -169,10 +176,14 @@ tasks.register("formatKtlint") { outputs.dir(outputDir) mainClass.set("com.pinterest.ktlint.Main") classpath = configurations.getByName("ktlint") - args = listOf("-F", "src/**/*.kt") + args = listOf("--editorconfig=../.editorconfig", "-F", "src/**/*.kt") jvmArgs = listOf("--add-opens", "java.base/java.lang=ALL-UNNAMED") } +tasks.register("checkDependenciesOrder") { + tomlFile = layout.projectDirectory.file("../gradle/libs.versions.toml") +} + afterEvaluate { tasks.named("preDebugBuild").configure { if (!System.getProperties().containsKey("skipFormatKtlint")) { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 000000000..713cead4b --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2025 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +plugins { + `kotlin-dsl` +} + +repositories { + gradlePluginPortal() +} diff --git a/app/check-dependencies.gradle.kts b/buildSrc/src/main/kotlin/CheckDependenciesOrder.kt similarity index 73% rename from app/check-dependencies.gradle.kts rename to buildSrc/src/main/kotlin/CheckDependenciesOrder.kt index fc77148db..8bf92d8cd 100644 --- a/app/check-dependencies.gradle.kts +++ b/buildSrc/src/main/kotlin/CheckDependenciesOrder.kt @@ -4,18 +4,27 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -tasks.register("checkDependenciesOrder") { - group = "verification" - description = "Checks that each section in libs.versions.toml is sorted alphabetically" +import org.gradle.api.DefaultTask +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.TaskAction - val tomlFile = file("../gradle/libs.versions.toml") +abstract class CheckDependenciesOrder : DefaultTask() { - doLast { - if (!tomlFile.exists()) { - throw GradleException("TOML file not found") - } + @get:InputFile + abstract val tomlFile: RegularFileProperty - val lines = tomlFile.readLines() + init { + group = "verification" + description = "Checks that each section in libs.versions.toml is sorted alphabetically" + } + + @TaskAction + fun run() { + val file = tomlFile.get().asFile + if (!file.exists()) error("TOML file not found") + + val lines = file.readLines() val nonSortedBlocks = mutableListOf>() var currentBlock = mutableListOf() var prevLine = "" @@ -50,7 +59,7 @@ tasks.register("checkDependenciesOrder") { } if (nonSortedBlocks.isNotEmpty()) { - throw GradleException( + error( "The following lines were not sorted:\n" + nonSortedBlocks.joinToString("\n\n") { it.joinToString("\n") } ) diff --git a/gradle.properties b/gradle.properties index ed32303da..01e1aa01f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,3 +4,6 @@ android.nonTransitiveRClass=true android.useAndroidX=true org.gradle.jvmargs=-Xmx2048M --add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED systemProp.file.encoding=utf-8 + +# https://docs.gradle.org/current/userguide/configuration_cache.html +org.gradle.configuration-cache=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 10e60455f..38fca9b2e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,47 +4,47 @@ # [versions] -acra = "5.11.3" -agp = "8.13.0" +acra = "5.13.1" +agp = "8.13.1" appcompat = "1.7.1" -assertj = "3.24.2" +assertj = "3.27.6" autoservice = "1.1.1" bridge = "v2.0.2" cardview = "1.0.0" -checkstyle = "10.26.1" -constraintlayout = "2.1.4" -core = "1.12.0" -desugar = "2.0.4" -documentfile = "1.0.1" -exoplayer = "2.18.7" -fragment = "1.6.2" +checkstyle = "12.1.2" +constraintlayout = "2.2.1" +core = "1.17.0" +desugar = "2.1.5" +documentfile = "1.1.0" +exoplayer = "2.19.1" +fragment = "1.8.9" groupie = "2.10.1" jsoup = "1.21.2" junit = "4.13.2" -junit-ext = "1.1.5" -kotlin = "1.9.25" -ksp = "1.9.25-1.0.20" -ktlint = "0.45.2" -leakcanary = "2.12" -lifecycle = "2.6.2" +junit-ext = "1.3.0" +kotlin = "2.2.21" +ksp = "2.3.2" +ktlint = "1.8.0" +leakcanary = "2.14" +lifecycle = "2.9.4" # Newer versions require minSdk >= 23 localbroadcastmanager = "1.1.0" markwon = "4.6.2" -material = "1.11.0" +material = "1.13.0" media = "1.7.1" -mockitoCore = "5.6.0" -okhttp = "4.12.0" -phoenix = "2.1.2" +mockitoCore = "5.20.0" +okhttp = "5.3.2" +phoenix = "3.0.0" #noinspection NewerVersionAvailable,GradleDependency --> 2.8 is the last version, not 2.71828! picasso = "2.8" preference = "1.2.1" prettytime = "5.0.8.Final" -recyclerview = "1.3.2" -room = "2.6.1" -runner = "1.5.2" +recyclerview = "1.4.0" +room = "2.7.2" # Newer versions require minSdk >= 23 +runner = "1.7.0" rxandroid = "3.0.2" rxbinding = "4.0.0" rxjava = "3.1.12" -sonarqube = "4.0.0.2929" +sonarqube = "7.0.1.6134" statesaver = "1.4.1" # TODO: Drop because it is deprecated and incompatible with KSP2 stetho = "1.6.0" swiperefreshlayout = "1.1.0" @@ -60,8 +60,8 @@ teamnewpipe-nanojson = "e9d656ddb49a412a5a0a5d5ef20ca7ef09549996" # to cause jitpack to regenerate the artifact. teamnewpipe-newpipe-extractor = "3af73262cc60cf555fd5f1d691f6c58e2db38ef5" viewpager2 = "1.1.0" -webkit = "1.9.0" -work = "2.8.1" +webkit = "1.14.0" +work = "2.10.5" # Newer versions require minSdk >= 23 [libraries] acra-core = { module = "ch.acra:acra-core", version.ref = "acra" } @@ -87,7 +87,7 @@ androidx-runner = { module = "androidx.test:runner", version.ref = "runner" } androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swiperefreshlayout" } androidx-viewpager2 = { module = "androidx.viewpager2:viewpager2", version.ref = "viewpager2" } androidx-webkit = { module = "androidx.webkit:webkit", version.ref = "webkit" } -androidx-work-runtime = { module = "androidx.work:work-runtime-ktx", version.ref = "work" } +androidx-work-runtime = { module = "androidx.work:work-runtime", version.ref = "work" } androidx-work-rxjava3 = { module = "androidx.work:work-rxjava3", version.ref = "work" } assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" } evernote-statesaver-compiler = { module = "com.evernote:android-state-processor", version.ref = "statesaver" } @@ -119,7 +119,7 @@ newpipe-nanojson = { module = "com.github.TeamNewPipe:nanojson", version.ref = " noties-markwon-core = { module = "io.noties.markwon:core", version.ref = "markwon" } noties-markwon-linkify = { module = "io.noties.markwon:linkify", version.ref = "markwon" } ocpsoft-prettytime = { module = "org.ocpsoft.prettytime:prettytime", version.ref = "prettytime" } -pinterest-ktlint = { module = "com.pinterest:ktlint", version.ref = "ktlint" } +pinterest-ktlint = { module = "com.pinterest.ktlint:ktlint-cli", version.ref = "ktlint" } puppycrawl-checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" } reactivex-rxandroid = { module = "io.reactivex.rxjava3:rxandroid", version.ref = "rxandroid" } reactivex-rxjava = { module = "io.reactivex.rxjava3:rxjava", version.ref = "rxjava" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a79e..f8e1ee312 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 57939822b..8a848873f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,8 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78 -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionSha256Sum=72f44c9f8ebcb1af43838f45ee5c4aa9c5444898b3468ab3f4af7b6076c5bc3f +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cbb4..adff685a0 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -83,7 +85,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -111,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -130,10 +132,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -141,7 +146,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -149,7 +154,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -166,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -198,16 +202,15 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 6689b85be..e509b2dd8 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,22 +59,21 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell