Skip to content
Open
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
316 changes: 161 additions & 155 deletions app/build.gradle.kts

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
plugins {
`kotlin-dsl`
}
14 changes: 14 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
rootProject.name = "build-logic"

dependencyResolutionManagement {
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
repositories {
gradlePluginPortal()
}
}
71 changes: 29 additions & 42 deletions jacoco.gradle.kts → ...kotlin/nextcloud.jacoco-report.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2025 Jimly Asshiddiqy
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
plugins {
jacoco
}

import org.gradle.testing.jacoco.plugins.JacocoPlugin
import org.gradle.testing.jacoco.plugins.JacocoPluginExtension
import org.gradle.testing.jacoco.tasks.JacocoReport
import org.gradle.testing.jacoco.plugins.JacocoTaskExtension
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.register


apply<JacocoPlugin>()

// Use version from version catalog
configure<JacocoPluginExtension> {
toolVersion = extensions
.getByType<VersionCatalogsExtension>()
jacoco {
toolVersion = the<VersionCatalogsExtension>()
.named("libs")
.findVersion("jacoco")
.get()
Expand All @@ -31,7 +19,8 @@ configure<JacocoPluginExtension> {

val flavor = "gplay"
val buildType = "Debug"
val variant = "${flavor.replaceFirstChar(Char::titlecase)}${buildType.replaceFirstChar(Char::titlecase)}"
val variantName = "$flavor$buildType"
val variant = variantName.replaceFirstChar(Char::titlecase)

val fileFilter = listOf(
// data binding
Expand All @@ -54,7 +43,6 @@ val fileFilter = listOf(
"**/*\$ViewBinder*.*",
"**/*Component*.*",
"**/*BR*.*",
"**/Manifest*.*",
"**/*\$Lambda\$*.*",
"**/*Companion*.*",
"**/*Module*.*",
Expand Down Expand Up @@ -83,51 +71,50 @@ val fileFilter = listOf(
"**/composables/**"
)

// Configure test tasks to include Jacoco instrumentation
tasks.withType<Test>().configureEach {
extensions.configure(JacocoTaskExtension::class) {
extensions.configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = true
excludes = listOf("jdk.internal.*")
}
}

// Main Jacoco report task
val jacocoReport = tasks.register<JacocoReport>("jacocoTest${variant}UnitTestReport") {
description = "Generates the JaCoCo coverage report for the $variantName unit tests."
group = LifecycleBasePlugin.VERIFICATION_GROUP
dependsOn("test${variant}UnitTest")

reports {
xml.required.set(true)
html.required.set(true)
csv.required.set(false)

// Output locations
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco/${name}"))
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/${name}/jacoco.xml"))
xml.required = true
html.required = true
csv.required = false
xml.outputLocation = layout.buildDirectory.file("reports/jacoco/$name/jacoco.xml")
}

// Directories
val kotlinClasses = fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/${variant}"))
val javacClasses = fileTree(layout.buildDirectory.dir("intermediates/javac/${variant}/classes"))
val intermediates = layout.buildDirectory.dir("intermediates")
val kotlinClasses = intermediates.map { it.dir("built_in_kotlinc/$variantName/compile${variant}Kotlin/classes") }
val javacClasses = intermediates.map { it.dir("javac/$variantName/compile${variant}JavaWithJavac/classes") }

classDirectories.setFrom(files(kotlinClasses, javacClasses))
classDirectories.setFrom(
fileTree(kotlinClasses) { exclude(fileFilter) },
fileTree(javacClasses) { exclude(fileFilter) }
)
sourceDirectories.setFrom(
files(
"src/main/java",
"src/$flavor/java",
"src/${buildType.lowercase()}/java"
)
"src/main/java",
"src/$flavor/java",
"src/${buildType.lowercase()}/java"
)
executionData.setFrom(
fileTree(layout.buildDirectory.asFile) {
fileTree(layout.buildDirectory) {
include(
"jacoco/test${variant}UnitTest.exec",
"outputs/unit_test_code_coverage/${variant}UnitTest/test${variant}UnitTest.exec"
"outputs/unit_test_code_coverage/${variantName}UnitTest/test${variant}UnitTest.exec"
)
}
)
}

// Backward compatibility alias
tasks.register("jacocoTest${variant}UnitTest") {
description = "Runs the $variantName unit tests and generates their JaCoCo coverage report."
group = LifecycleBasePlugin.VERIFICATION_GROUP
dependsOn("test${variant}UnitTest", jacocoReport)
}
9 changes: 5 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ plugins {
}

tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
description = "Deletes the root project build directory."
delete(layout.buildDirectory)
}

tasks.register<Copy>("installGitHooks") {
description = "Install git hooks"

val sourceFolder = "${rootProject.projectDir}/scripts/hooks"
val destFolder = "${rootProject.projectDir}/.git/hooks"
val sourceFolder = layout.projectDirectory.dir("scripts/hooks")
val destFolder = layout.projectDirectory.dir(".git/hooks")

from(sourceFolder) { include("*") }
into(destFolder)
eachFile { println("${sourceFolder}/${file.path} -> ${destFolder}/${file.path}") }
eachFile { println("$sourceFolder/$path -> $destFolder/$path") }
}
15 changes: 14 additions & 1 deletion gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,10 @@
<trusting group="com.caverock" name="androidsvg" version="1.4"/>
<trusting group="com.caverock" name="androidsvg-aar" version="1.4"/>
</trusted-key>
<trusted-key id="F3FF33E96F18AA62DD580F9651FBF517CE6D6B80" group="gradle" name="gradle"/>
<trusted-key id="F3FF33E96F18AA62DD580F9651FBF517CE6D6B80">
<trusting group="gradle" name="gradle"/>
<trusting group="org.gradle.kotlin" name="gradle-kotlin-dsl-plugins" version="6.7.13"/>
</trusted-key>
<trusted-key id="F4DD59C90148BDC52BEB90A4530AA5F25C25011F">
<trusting group="commons-codec"/>
<trusting group="commons-io"/>
Expand Down Expand Up @@ -35566,6 +35569,11 @@
<sha256 value="a79dd002fb038183ff286a2635be2e68c103b87e0e64717d8d44bfd017fd33ea" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.gradle.kotlin.kotlin-dsl" name="org.gradle.kotlin.kotlin-dsl.gradle.plugin" version="6.7.13">
<artifact name="org.gradle.kotlin.kotlin-dsl.gradle.plugin-6.7.13.pom">
<sha256 value="770d3e472164cfbdb5f8f8a6cd008b07e8c25f484ed7d3bd823b57ae5a4252da" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="org.greenrobot" name="eventbus" version="3.3.1">
<artifact name="eventbus-3.3.1.aar">
<sha256 value="c9385f4a570f8b2ef6f8f752690077ed538c358fd4755032ab80501755838f11" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -38275,6 +38283,11 @@
<sha256 value="70b071dc4074995076c97c749792ebcff69f10e636d1e2f2c68de0de023e0239" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-gradle-plugins-bom" version="2.4.21">
<artifact name="kotlin-gradle-plugins-bom-2.4.21.pom">
<sha256 value="624c0c869b3fcf1665afec9c5c51a807be0a8c983931ebb188548ddcdb055780" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-klib-abi-reader" version="2.3.0">
<artifact name="kotlin-klib-abi-reader-2.3.0.jar">
<sha256 value="41e31422eb5eb224b9a475fe80eb8d06eb21ad34fb7d0a408d2c972a7abb8cbb" origin="Generated by Gradle"/>
Expand Down
7 changes: 2 additions & 5 deletions scripts/analysis/lint-up.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
# User name for git commits made by this script.
TRAVIS_GIT_USERNAME = String.new("Drone CI server")

# File name and relative path of generated Lint report. Must match build.gradle file:
# lintOptions {
# htmlOutput file("[FILE_NAME].html")
# }
LINT_REPORT_FILE = String.new("app/build/reports/lint/lint.html")
# File name and relative path of the HTML report that AGP generates for lintGplayDebug.
LINT_REPORT_FILE = String.new("app/build/reports/lint-results-gplayDebug.html")

# File name and relative path of previous results of this script.
PREVIOUS_LINT_RESULTS_FILE=String.new("scripts/analysis/lint-results.txt")
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
rootProject.name = "Nextcloud"

pluginManagement {
includeBuild("build-logic")

resolutionStrategy.eachPlugin {
if (requested.id.id == "shot") useModule("com.karumi:shot:${requested.version}")
}
Expand All @@ -25,7 +27,6 @@ pluginManagement {
}
}

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
Expand Down
Loading