1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00
NewPipe/app/build.gradle

359 lines
11 KiB
Groovy
Raw Normal View History

import com.android.tools.profgen.ArtProfileKt
import com.android.tools.profgen.ArtProfileSerializer
import com.android.tools.profgen.DexFile
plugins {
2024-11-22 20:59:39 +00:00
alias libs.plugins.android.application
alias libs.plugins.kotlin.android
alias libs.plugins.kotlin.compose
alias libs.plugins.kotlin.kapt
alias libs.plugins.kotlin.parcelize
alias libs.plugins.checkstyle
alias libs.plugins.sonarqube
alias libs.plugins.hilt
}
2015-09-04 00:15:03 +00:00
android {
2023-10-31 20:31:16 +00:00
compileSdk 34
2022-09-17 13:47:03 +00:00
namespace 'org.schabi.newpipe'
2015-09-04 00:15:03 +00:00
defaultConfig {
applicationId "org.schabi.newpipe"
resValue "string", "app_name", "NewPipe"
minSdk 21
targetSdk 33
Merge dev to refactor (#11427) * add NP icon for Android Studio's NewUI * Fix NPE in MediaSessionPlayerUi while destroying player * Update NewPipeExtractor to v0.24.1 * Add changelogs for hotfix release v0.27.1 (998) * Hotfix release v0.27.1 (998) * Update README.pt_BR.md (#11275) * Update Matrix room link, and prioritise it (#11350) * Update Matrix room link, and prioritise it * Update Matrix room link in CONTRIBUTING.md * Prioritise Matrix in contribution doc too * Update NewPipeExtractor to v0.24.2 * Hotfix release v0.27.2 (999) * Add changelogs for hotfix release v0.27.2 (999) * Don't warn about rhino class in proguard Likely related to https://github.com/mozilla/rhino/commit/01a7b20655602f7e2df59af744b47b77f678b6cf but I am not completely sure. I tested the app and it works well, so I think that org.mozilla.javascript.JavaToJSONConverters is not used really. This is the full list of errors: Missing class java.beans.BeanDescriptor (referenced from: java.lang.Object org.mozilla.javascript.JavaToJSONConverters.lambda$static$4(java.lang.Object)) Missing class java.beans.BeanInfo (referenced from: java.lang.Object org.mozilla.javascript.JavaToJSONConverters.lambda$static$4(java.lang.Object)) Missing class java.beans.IntrospectionException (referenced from: java.lang.Object org.mozilla.javascript.JavaToJSONConverters.lambda$static$4(java.lang.Object)) Missing class java.beans.Introspector (referenced from: java.lang.Object org.mozilla.javascript.JavaToJSONConverters.lambda$static$4(java.lang.Object)) Missing class java.beans.PropertyDescriptor (referenced from: java.lang.Object org.mozilla.javascript.JavaToJSONConverters.lambda$static$4(java.lang.Object)) * Remove code committed accidentally --------- Co-authored-by: Christian Schabesberger <chris.schabesberger@mailbox.org> Co-authored-by: Tobi <TobiGr@users.noreply.github.com> Co-authored-by: Stypox <stypox@pm.me> Co-authored-by: #27 <68751594+tag27@users.noreply.github.com> Co-authored-by: opusforlife2 <53176348+opusforlife2@users.noreply.github.com>
2024-08-11 02:41:50 +00:00
versionCode 999
versionName "0.27.2"
2019-10-04 12:59:08 +00:00
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
2015-09-04 00:15:03 +00:00
}
2015-09-04 00:15:03 +00:00
buildTypes {
debug {
debuggable true
2020-02-23 19:56:56 +00:00
// suffix the app id and the app name with git branch name
def workingBranch = getGitWorkingBranch()
def normalizedWorkingBranch = workingBranch.replaceFirst("^[^A-Za-z]+", "").replaceAll("[^0-9A-Za-z]+", "")
if (normalizedWorkingBranch.isEmpty() || workingBranch == "master" || workingBranch == "dev") {
// default values when branch name could not be determined or is master or dev
applicationIdSuffix ".debug"
resValue "string", "app_name", "NewPipe Debug"
} else {
applicationIdSuffix ".debug." + normalizedWorkingBranch
resValue "string", "app_name", "NewPipe " + workingBranch
archivesBaseName = 'NewPipe_' + normalizedWorkingBranch
}
}
release {
if (System.properties.containsKey('packageSuffix')) {
applicationIdSuffix System.getProperty('packageSuffix')
resValue "string", "app_name", "NewPipe " + System.getProperty('packageSuffix')
archivesBaseName = 'NewPipe_' + System.getProperty('packageSuffix')
}
minifyEnabled true
shrinkResources false // disabled to fix F-Droid's reproducible build
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
archivesBaseName = 'app'
}
2015-09-04 00:15:03 +00:00
}
2015-12-24 13:55:33 +00:00
2022-01-21 21:25:11 +00:00
lint {
2015-12-01 20:31:10 +00:00
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
// suppress false warning ("Resource IDs will be non-final in Android Gradle Plugin version
// 5.0, avoid using them in switch case statements"), which affects only library projects
disable 'NonConstantResourceId'
2015-12-01 20:31:10 +00:00
}
2016-02-05 16:09:29 +00:00
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
2023-04-20 09:31:45 +00:00
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
encoding 'utf-8'
2016-02-05 16:09:29 +00:00
}
kotlinOptions {
2023-04-20 09:31:45 +00:00
jvmTarget = JavaVersion.VERSION_17
}
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
2020-10-31 04:37:18 +00:00
buildFeatures {
viewBinding true
compose true
2024-10-22 19:40:16 +00:00
buildConfig true
2020-10-31 04:37:18 +00:00
}
packagingOptions {
2023-04-20 08:24:19 +00:00
resources {
// remove two files which belong to jsoup
// no idea how they ended up in the META-INF dir...
2023-11-17 21:58:30 +00:00
excludes += ['META-INF/README.md', 'META-INF/CHANGES',
// 'COPYRIGHT' belongs to RxJava...
'META-INF/COPYRIGHT']
2023-04-20 08:24:19 +00:00
}
}
2015-09-04 00:15:03 +00:00
}
2020-06-28 12:59:44 +00:00
configurations {
checkstyle
2020-10-31 20:55:45 +00:00
ktlint
2020-06-28 12:59:44 +00:00
}
2020-03-27 19:45:26 +00:00
checkstyle {
getConfigDirectory().set(rootProject.file("checkstyle"))
2020-03-27 19:45:26 +00:00
ignoreFailures false
showViolations true
2024-11-22 20:59:39 +00:00
toolVersion = libs.versions.checkstyle.get()
2020-03-27 19:45:26 +00:00
}
2023-11-01 01:28:24 +00:00
tasks.register('runCheckstyle', Checkstyle) {
2020-03-27 19:45:26 +00:00
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
exclude 'main/java/us/shandian/giga/**'
2020-06-28 12:59:44 +00:00
classpath = configurations.checkstyle
2020-03-27 19:45:26 +00:00
showViolations true
reports {
2021-07-06 16:16:20 +00:00
xml.getRequired().set(true)
html.getRequired().set(true)
2020-03-27 19:45:26 +00:00
}
}
2020-10-31 20:55:45 +00:00
def outputDir = "${project.buildDir}/reports/ktlint/"
def inputFiles = project.fileTree(dir: "src", include: "**/*.kt")
2023-11-01 01:28:24 +00:00
tasks.register('runKtlint', JavaExec) {
2020-10-31 20:55:45 +00:00
inputs.files(inputFiles)
outputs.dir(outputDir)
2021-07-06 16:16:20 +00:00
getMainClass().set("com.pinterest.ktlint.Main")
2020-10-31 20:55:45 +00:00
classpath = configurations.ktlint
args "src/**/*.kt"
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
2020-10-31 20:55:45 +00:00
}
2023-11-01 01:28:24 +00:00
tasks.register('formatKtlint', JavaExec) {
2020-10-31 20:55:45 +00:00
inputs.files(inputFiles)
outputs.dir(outputDir)
2021-07-06 16:16:20 +00:00
getMainClass().set("com.pinterest.ktlint.Main")
2020-10-31 20:55:45 +00:00
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
2020-10-31 20:55:45 +00:00
}
2020-05-01 18:09:52 +00:00
apply from: 'check-dependencies.gradle'
2020-04-20 15:01:36 +00:00
afterEvaluate {
if (!System.properties.containsKey('skipFormatKtlint')) {
preDebugBuild.dependsOn formatKtlint
}
preDebugBuild.dependsOn runCheckstyle, runKtlint, checkDependenciesOrder
2020-04-20 15:01:36 +00:00
}
2020-03-27 19:45:26 +00:00
2022-11-29 16:20:31 +00:00
sonar {
properties {
property "sonar.projectKey", "TeamNewPipe_NewPipe"
property "sonar.organization", "teamnewpipe"
property "sonar.host.url", "https://sonarcloud.io"
}
}
kapt {
correctErrorTypes true
}
2015-09-04 00:15:03 +00:00
dependencies {
/** Desugaring **/
2024-11-22 20:59:39 +00:00
coreLibraryDesugaring libs.desugar.jdk.libs.nio
/** NewPipe libraries **/
2024-11-22 20:59:39 +00:00
implementation libs.teamnewpipe.nanojson
implementation libs.teamnewpipe.newpipe.extractor
implementation libs.teamnewpipe.nononsense.filepicker
2020-05-01 14:06:02 +00:00
/** Checkstyle **/
2024-11-22 20:59:39 +00:00
checkstyle libs.tools.checkstyle
ktlint libs.tools.ktlint
/** Kotlin **/
2024-11-22 20:59:39 +00:00
implementation libs.kotlin.stdlib
/** AndroidX **/
2024-11-22 20:59:39 +00:00
implementation libs.androidx.appcompat
implementation libs.androidx.cardview
implementation libs.androidx.constraintlayout
implementation libs.androidx.core.ktx
implementation libs.androidx.documentfile
implementation libs.androidx.fragment.compose
implementation libs.androidx.lifecycle.livedata
implementation libs.androidx.lifecycle.viewmodel
implementation libs.androidx.localbroadcastmanager
implementation libs.androidx.media
implementation libs.androidx.preference
implementation libs.androidx.recyclerview
implementation libs.androidx.room.runtime
implementation libs.androidx.room.rxjava3
kapt libs.androidx.room.compiler
implementation libs.androidx.swiperefreshlayout
2021-10-19 21:31:59 +00:00
// Newer version specified to prevent accessibility regressions with RecyclerView, see:
// https://developer.android.com/jetpack/androidx/releases/viewpager2#1.1.0-alpha01
2024-11-22 20:59:39 +00:00
implementation libs.androidx.viewpager2
implementation libs.androidx.work.runtime
implementation libs.androidx.work.rxjava3
implementation libs.androidx.material
2017-04-26 19:32:20 +00:00
/** Third-party libraries **/
// Instance state boilerplate elimination
2024-11-22 20:59:39 +00:00
implementation libs.livefront.bridge
implementation libs.android.state
kapt libs.android.state.processor
// HTML parser
2024-11-22 20:59:39 +00:00
implementation libs.jsoup
2017-04-26 19:32:20 +00:00
// HTTP client
2024-11-22 20:59:39 +00:00
implementation libs.okhttp
2018-03-30 01:24:30 +00:00
// Media player
2024-11-22 20:59:39 +00:00
implementation libs.exoplayer.core
implementation libs.exoplayer.dash
implementation libs.exoplayer.database
implementation libs.exoplayer.datasource
implementation libs.exoplayer.hls
implementation libs.exoplayer.smoothstreaming
implementation libs.exoplayer.ui
implementation libs.extension.mediasession
// Metadata generator for service descriptors
2024-11-22 20:59:39 +00:00
compileOnly libs.auto.service
kapt libs.auto.service.kapt
// Manager for complex RecyclerView layouts
2024-11-22 20:59:39 +00:00
implementation libs.lisawray.groupie
implementation libs.lisawray.groupie.viewbinding
// Image loading
2024-11-22 20:59:39 +00:00
implementation libs.coil.compose
// Markdown library for Android
2024-11-22 20:59:39 +00:00
implementation libs.markwon.core
implementation libs.markwon.linkify
2020-05-01 14:06:02 +00:00
// Crash reporting
2024-11-22 20:59:39 +00:00
implementation libs.acra.core
2020-05-01 14:06:02 +00:00
// Properly restarting
2024-11-22 20:59:39 +00:00
implementation libs.process.phoenix
// Reactive extensions for Java VM
2024-11-22 20:59:39 +00:00
implementation libs.rxjava3.rxjava
implementation libs.rxjava3.rxandroid
// RxJava binding APIs for Android UI widgets
2024-11-22 20:59:39 +00:00
implementation libs.rxbinding4.rxbinding
2020-05-01 14:06:02 +00:00
// Date and time formatting
2024-11-22 20:59:39 +00:00
implementation libs.prettytime
// Jetpack Compose
2024-11-22 20:59:39 +00:00
implementation(platform(libs.androidx.compose.bom))
implementation libs.androidx.compose.material3
implementation libs.androidx.compose.adaptive
implementation libs.androidx.activity.compose
implementation libs.androidx.compose.ui.tooling.preview
implementation libs.androidx.lifecycle.viewmodel.compose
implementation libs.androidx.compose.ui.text // Needed for parsing HTML to AnnotatedString
implementation libs.androidx.compose.material.icons.extended
// Jetpack Compose related dependencies
2024-11-22 20:59:39 +00:00
implementation libs.androidx.paging.compose
implementation libs.androidx.navigation.compose
// Coroutines interop
2024-11-22 20:59:39 +00:00
implementation libs.kotlinx.coroutines.rx3
// Hilt
2024-11-22 20:59:39 +00:00
implementation libs.hilt.android
kapt(libs.hilt.compiler)
// Scroll
2024-11-22 20:59:39 +00:00
implementation libs.lazycolumnscrollbar
/** Debugging **/
// Memory leak detection
2024-11-22 20:59:39 +00:00
debugImplementation libs.leakcanary.object.watcher
debugImplementation libs.leakcanary.plumber.android
debugImplementation libs.leakcanary.android.core
// Debug bridge for Android
2024-11-22 20:59:39 +00:00
debugImplementation libs.stetho
debugImplementation libs.stetho.okhttp3
// Jetpack Compose
2024-11-22 20:59:39 +00:00
debugImplementation libs.androidx.compose.ui.tooling
/** Testing **/
2024-11-22 20:59:39 +00:00
testImplementation libs.junit
testImplementation libs.mockito.core
2024-11-22 20:59:39 +00:00
androidTestImplementation libs.androidx.junit
androidTestImplementation libs.androidx.runner
androidTestImplementation libs.androidx.room.testing
androidTestImplementation libs.assertj.core
2015-09-04 00:15:03 +00:00
}
static String getGitWorkingBranch() {
try {
def gitProcess = "git rev-parse --abbrev-ref HEAD".execute()
gitProcess.waitFor()
if (gitProcess.exitValue() == 0) {
return gitProcess.text.trim()
} else {
// not a git repository
return ""
}
} catch (IOException ignored) {
// git was not found
return ""
}
2020-03-27 19:45:26 +00:00
}
// fix reproducible builds
project.afterEvaluate {
tasks.compileReleaseArtProfile.doLast {
outputs.files.each { file ->
if (file.toString().endsWith(".profm")) {
println("Sorting ${file} ...")
def version = ArtProfileSerializer.valueOf("METADATA_0_0_2")
def profile = ArtProfileKt.ArtProfile(file)
def keys = new ArrayList(profile.profileData.keySet())
def sortedData = new LinkedHashMap()
Collections.sort keys, new DexFile.Companion()
keys.each { key -> sortedData[key] = profile.profileData[key] }
new FileOutputStream(file).with {
write(version.magicBytes$profgen)
write(version.versionBytes$profgen)
version.write$profgen(it, sortedData, "")
}
}
}
}
}