Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Nextcloud Android Common Library
*
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023 Unpublished <unpublished@gmx.net>
* SPDX-FileCopyrightText: 2022 Tobias Kaminsky <tobias@kaminsky.me>
Expand Down Expand Up @@ -28,17 +29,11 @@ subprojects {
repositories {
google()
mavenCentral()
maven {
url = "https://jitpack.io"
content {
includeGroup "com.github.bitfireAT"
}
}
}
}

tasks.register('clean', Delete) {
delete rootProject.buildDir
delete rootProject.layout.buildDirectory
}

tasks.register('installGitHooks', Copy) {
Expand Down
18 changes: 4 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2018-2023 Tobias Kaminsky <tobias@kaminsky.me>
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
# SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
# SPDX-FileCopyrightText: 2023-2026 Alper Ozturk <alper.ozturk@nextcloud.com>
# SPDX-License-Identifier: MIT

# can be overriden by ~/.gradle/gradle.properties
Expand All @@ -10,22 +10,12 @@ NC_TEST_SERVER_USERNAME=test
NC_TEST_SERVER_PASSWORD=test
NC_TEST_SERVER_USERNAME2=admin
NC_TEST_SERVER_PASSWORD2=admin
android.useAndroidX=true
# android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false

# JVM arguments to optimize heap usage, enable heap dump on out-of-memory errors, and set the file encoding
org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8
android.useAndroidX=true
org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.dependency.verification.console=verbose
kotlin.daemon.jvmargs=-Xmx3072m
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configureondemand=true
android.defaults.buildfeatures.resvalues=true
android.usesSdkInManifest.disallowed=false
android.uniquePackageNames=false
android.dependency.useConstraints=true

# Enabled parallel sync for Gradle 9.4+
org.gradle.configuration-cache=true
org.gradle.tooling.parallel=true
41 changes: 12 additions & 29 deletions jacoco.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Nextcloud Android Common Library
*
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
* SPDX-License-Identifier: MIT
Expand All @@ -9,34 +10,19 @@
apply plugin: 'jacoco'

jacoco {
toolVersion = "$jacoco_version"
}

// Force Jacoco Version

subprojects {
configurations.all {
resolutionStrategy {
eachDependency { details ->
if ('org.jacoco' == details.requested.group) {
details.useVersion "$jacocoVersion"
}
}
}
}
toolVersion = "${rootProject.ext.jacoco_version}"
}

project.afterEvaluate { project ->

tasks.withType(Test) {
tasks.withType(Test).configureEach {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}

final flavor = "Gplay"
final buildType = "Debug"
final variant = "$flavor${buildType.capitalize()}"
final taskName = "jacocoTest${variant.capitalize()}UnitTestReport"
final variant = buildType.toLowerCase()
final taskName = "jacocoTest${buildType}UnitTestReport"

task "$taskName"(type: JacocoReport, dependsOn: "test${buildType.capitalize()}UnitTest") {

Expand Down Expand Up @@ -99,19 +85,16 @@ project.afterEvaluate { project ->
/* INSERT ANY OTHER JUNK YOU WANT FILTERED OUT HERE */
]

final androidKotlinTree = fileTree(dir: "${project.buildDir}/tmp/kotlin-classes/${variant}", excludes: fileFilter)
final kotlinTree = fileTree(dir: "${project.buildDir}/classes/kotlin/main", excludes: fileFilter)
final javacTree = fileTree(dir: "${project.buildDir}/intermediates/javac/${variant}/classes", excludes: fileFilter)
final kotlinTree = fileTree(dir: project.layout.buildDirectory.dir("intermediates/built_in_kotlinc/${variant}/compile${buildType}Kotlin/classes"), excludes: fileFilter)
final javacTree = fileTree(dir: project.layout.buildDirectory.dir("intermediates/javac/${variant}/compile${buildType}JavaWithJavac/classes"), excludes: fileFilter)

final mainSrc = "${project.projectDir}/src/main/java"
final productFlavorSrc = "${project.projectDir}/src/${flavor}/java"
final buildTypeSrc = "${project.projectDir}/src/${buildType}/java"
final buildTypeSrc = "${project.projectDir}/src/${variant}/java"

sourceDirectories.setFrom files([mainSrc, productFlavorSrc, buildTypeSrc])
classDirectories.setFrom files([androidKotlinTree, kotlinTree, javacTree])
executionData.setFrom fileTree(dir: project.buildDir, includes: [
"jacoco/test${variant.capitalize()}UnitTest.exec",
"outputs/unit_test_code_coverage/${variant}UnitTest/test${variant.capitalize()}UnitTest.exec",
sourceDirectories.setFrom files([mainSrc, buildTypeSrc])
classDirectories.setFrom files([kotlinTree, javacTree])
executionData.setFrom fileTree(dir: project.layout.buildDirectory, includes: [
"outputs/unit_test_code_coverage/${variant}UnitTest/test${buildType}UnitTest.exec"
])
}
}
66 changes: 33 additions & 33 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
* SPDX-FileCopyrightText: 2023 Tobias Kaminsky <tobias@kaminsky.me>
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2023-2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2022 Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
* SPDX-License-Identifier: MIT
*/

import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask
import io.gitlab.arturbosch.detekt.Detekt

buildscript {
ext {
Expand All @@ -20,12 +21,12 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:9.4.1'
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:6.5.13'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.ext.kotlin_version}"
classpath "org.jetbrains.kotlin:kotlin-serialization:${rootProject.ext.kotlin_version}"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.8"
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
classpath "org.jacoco:org.jacoco.core:${rootProject.ext.jacoco_version}"
classpath "org.jacoco:org.jacoco.report:${rootProject.ext.jacoco_version}"
classpath "org.jacoco:org.jacoco.agent:${rootProject.ext.jacoco_version}"
}
}

Expand All @@ -42,7 +43,7 @@ apply plugin: 'io.gitlab.arturbosch.detekt'
apply plugin: 'maven-publish' // needed for JitPack.io

configurations {
all {
configureEach {
exclude group: 'com.google.firebase', module: 'firebase-core'
exclude group: 'org.ogce', module: 'xpp3' // xpp3 is for plain java, Android uses kxml2

Expand All @@ -51,7 +52,7 @@ configurations {
cacheChangingModulesFor 0, 'seconds'
eachDependency { details ->
if ('org.jacoco' == details.requested.group) {
details.useVersion "$jacoco_version"
details.useVersion "${rootProject.ext.jacoco_version}"
}
}

Expand All @@ -64,15 +65,12 @@ dependencies {

implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5'
api 'com.squareup.okhttp3:okhttp:5.5.1'
implementation 'com.github.bitfireAT:dav4jvm:3.0.2'
// in transition phase, we use old and new libs
implementation group: 'com.google.code.gson', name: 'gson', version: '2.15.0'
implementation 'com.google.code.gson:gson:2.15.0'
implementation 'androidx.annotation:annotation:1.11.0'
compileOnly 'com.google.code.findbugs:annotations:3.0.1'

implementation "androidx.core:core-ktx:1.19.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.google.guava:guava:33.7.2-jre'

implementation 'org.bouncycastle:bcpkix-jdk18on:1.86'

Expand All @@ -88,13 +86,9 @@ dependencies {
// JUnit4 Rules
androidTestImplementation "junit:junit:$junit_version"
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test:rules:1.7.0'

// Android JUnit Runner
androidTestImplementation 'androidx.test:runner:1.7.0'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.7.0'
androidTestImplementation 'commons-io:commons-io:2.22.0'
}

Expand All @@ -104,20 +98,20 @@ spotbugs {
reportLevel = Confidence.valueOf('MEDIUM')
}

tasks.withType(SpotBugsTask){task ->
tasks.withType(SpotBugsTask).configureEach { task ->
String variantNameCap = task.name.replace("spotbugs", "")
String variantName = variantNameCap.substring(0, 1).toLowerCase() + variantNameCap.substring(1)
dependsOn "compile${variantNameCap}Sources"

classes = files("$project.buildDir/intermediates/javac/${variantName}")
classes = files(layout.buildDirectory.dir("intermediates/javac/${variantName}"))
excludeFilter = file("${project.rootDir}/scripts/analysis/spotbugs-filter.xml")
reports {
xml {
required = true
}
html {
required = true
outputLocation = file("$project.buildDir/reports/spotbugs/spotbugs.html")
outputLocation = layout.buildDirectory.file("reports/spotbugs/spotbugs.html")
stylesheet = 'fancy.xsl'
}
}
Expand All @@ -128,16 +122,16 @@ android {

buildTypes {
debug {
enableUnitTestCoverage true
enableAndroidTestCoverage true
enableUnitTestCoverage = true
enableAndroidTestCoverage = true
}
}


lint {
abortOnError = true
disable 'MissingTranslation', 'GradleDependency', 'VectorPath', 'IconMissingDensityFolder', 'IconDensities', 'GoogleAppIndexingWarning', 'MissingDefaultResource', 'StringFormatInvalid', 'MissingQuantity', 'InvalidPackage'
htmlOutput = file("$project.buildDir/reports/lint/lint.html")
htmlOutput = layout.buildDirectory.file("reports/lint/lint.html").get().asFile
htmlReport = true
warningsAsErrors = true
targetSdk 36
Expand Down Expand Up @@ -201,22 +195,28 @@ tasks.register("combinedTestReport", JacocoReport) {
html.required = Boolean.TRUE
}

additionalSourceDirs.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories.setFrom files(subprojects.sourceSets.main.output)
executionData.setFrom project.fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/debugAndroidTest/connected/*coverage.ec'
final classExcludes = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*']

sourceDirectories.setFrom files("$projectDir/src/main/java")
classDirectories.setFrom files(
fileTree(dir: layout.buildDirectory.dir("intermediates/built_in_kotlinc/debug/compileDebugKotlin/classes"), excludes: classExcludes),
fileTree(dir: layout.buildDirectory.dir("intermediates/javac/debug/compileDebugJavaWithJavac/classes"), excludes: classExcludes)
)
executionData.setFrom project.fileTree(dir: project.layout.buildDirectory, includes: [
'outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec',
'outputs/code_coverage/debugAndroidTest/connected/**/*.ec'
])
}

detekt {
config.setFrom(files("detekt.yml"))
source.setFrom(files("$projectDir/src/"))
}

tasks.withType(Detekt).configureEach {
reports {
xml {
enabled = false
}
xml.required = false
}
config = files("detekt.yml")
input = files("$projectDir/src/")
}

afterEvaluate {
Expand All @@ -233,7 +233,7 @@ afterEvaluate {
}

jacoco {
toolVersion = "$jacoco_version"
toolVersion = "${rootProject.ext.jacoco_version}"
}

spotless {
Expand Down
Loading
Loading