diff --git a/.github/workflows/ci_test_and_publish.yml b/.github/workflows/ci_test_and_publish.yml index 2f7644d..521864d 100644 --- a/.github/workflows/ci_test_and_publish.yml +++ b/.github/workflows/ci_test_and_publish.yml @@ -23,7 +23,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '17' + java-version: '21' - name: Upload Artifacts run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel @@ -60,7 +60,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '17' + java-version: '21' - name: Run tests uses: reactivecircus/android-emulator-runner@v2 with: diff --git a/.github/workflows/sample_app.yml b/.github/workflows/sample_app.yml index d2bb0a4..93e5f68 100644 --- a/.github/workflows/sample_app.yml +++ b/.github/workflows/sample_app.yml @@ -20,7 +20,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '17' + java-version: '21' - name: Build sample run: | ./gradlew :affectedmoduledetector:publishToMavenLocal diff --git a/affectedmoduledetector/build.gradle b/affectedmoduledetector/build.gradle index c2b4269..6663ffb 100644 --- a/affectedmoduledetector/build.gradle +++ b/affectedmoduledetector/build.gradle @@ -9,12 +9,12 @@ plugins { apply from: rootProject.file("gradle/jacoco.gradle") java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } kotlin { - jvmToolchain(11) + jvmToolchain(21) } jacoco { diff --git a/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetector.kt b/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetector.kt index c00ca92..96ecc29 100644 --- a/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetector.kt +++ b/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetector.kt @@ -213,7 +213,7 @@ abstract class AffectedModuleDetector(protected val logger: Logger?) { ) logger.lifecycle("projects evaluated") - val projectGraph = ProjectGraph(rootProject) + val projectGraph = ProjectGraph(rootProject, logger.toLogger()) val dependencyTracker = DependencyTracker(rootProject, logger.toLogger()) val provider = setupWithParams(rootProject) { spec -> val parameters = spec.parameters @@ -265,7 +265,8 @@ abstract class AffectedModuleDetector(protected val logger: Logger?) { } internal fun isProjectEnabled(project: Project): Boolean { - return project.hasProperty(ENABLE_ARG) + val enabledProvider = project.providers.gradleProperty(ENABLE_ARG) + return enabledProvider.isPresent && enabledProvider.get() != "false" } private fun getModulesProperty(project: Project): Set? { @@ -656,7 +657,7 @@ class AffectedModuleDetectorImpl( } private fun findContainingProject(filePath: String): ProjectPath? { - return projectGraph.findContainingProject(filePath).also { + return projectGraph.findContainingProject(filePath, logger).also { logger?.info("search result for $filePath resulted in ${it?.path}") } } diff --git a/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/DependencyTracker.kt b/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/DependencyTracker.kt index 3d5f519..a7b66e1 100644 --- a/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/DependencyTracker.kt +++ b/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/DependencyTracker.kt @@ -28,29 +28,32 @@ import java.io.Serializable * Utility class that traverses all project dependencies and discover which modules depend on each * other. This is mainly used by [AffectedModuleDetector] to find out which projects should be run. */ -class DependencyTracker(rootProject: Project, logger: Logger?) : Serializable { - val dependentList: Map> +class DependencyTracker(private val rootProject: Project, private val logger: Logger?) : Serializable { - init { + private val dependentList: Map> by lazy { val result = mutableMapOf>() - val stringBuilder = StringBuilder() rootProject.subprojects.forEach { project -> + logger?.info("checking ${project.path} for dependencies") project.configurations.forEach { config -> - config.dependencies.filterIsInstance().forEach { - stringBuilder.append( - "there is a dependency from ${project.path} (${config.name}) to " + - it.dependencyProject.path + - "\n" - ) - result.getOrPut(it.dependencyProject.projectPath) { mutableSetOf() }.add(project.projectPath) - } + logger?.info("checking config ${project.path}/$config for dependencies") + config + .dependencies + .filterIsInstance() + .forEach { + logger?.info( + "there is a dependency from ${project.projectPath} to " + + it.path, + ) + result.getOrPut(ProjectPath(it.path)) { mutableSetOf() } + .add(project.projectPath) + } } } - logger?.info(stringBuilder.toString()) - dependentList = result + result } fun findAllDependents(projectPath: ProjectPath): Set { + logger?.info("finding dependents of $projectPath") val result = mutableSetOf() fun addAllDependents(projectPath: ProjectPath) { if (result.add(projectPath)) { @@ -58,7 +61,8 @@ class DependencyTracker(rootProject: Project, logger: Logger?) : Serializable { } } addAllDependents(projectPath) - // the projectPath isn't a dependent of itself + logger?.info("dependents of $projectPath is $result") + // the project isn't a dependent of itself return result.minus(projectPath) } } diff --git a/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/ProjectGraph.kt b/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/ProjectGraph.kt index 75c7d58..ea3d4f5 100644 --- a/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/ProjectGraph.kt +++ b/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/ProjectGraph.kt @@ -70,10 +70,6 @@ class ProjectGraph(project: Project, logger: Logger? = null) : Serializable { return rootNode.find(sections, 0, logger) } - fun getRootProjectPath(): ProjectPath? { - return rootNode.projectPath - } - val allProjects by lazy { val result = mutableSetOf() rootNode.addAllProjectPaths(result) @@ -109,6 +105,10 @@ class ProjectGraph(project: Project, logger: Logger? = null) : Serializable { } } } + + fun getRootProjectPath(): ProjectPath? { + return rootNode.projectPath + } } fun Project.getSupportRootFolder(): File = project.rootDir diff --git a/affectedmoduledetector/src/test/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetectorIntegrationTest.kt b/affectedmoduledetector/src/test/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetectorIntegrationTest.kt index 4eec50c..570ec0d 100644 --- a/affectedmoduledetector/src/test/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetectorIntegrationTest.kt +++ b/affectedmoduledetector/src/test/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetectorIntegrationTest.kt @@ -57,11 +57,10 @@ class AffectedModuleDetectorIntegrationTest { """buildscript { | repositories { | google() - | jcenter() | } | dependencies { - | classpath "com.android.tools.build:gradle:7.4.0" - | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25" + | classpath "com.android.tools.build:gradle:8.6.1" + | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.0" | } |} |plugins { @@ -70,7 +69,6 @@ class AffectedModuleDetectorIntegrationTest { |allprojects { | repositories { | google() - | jcenter() | } |}""".trimMargin() ) @@ -151,11 +149,10 @@ class AffectedModuleDetectorIntegrationTest { """buildscript { | repositories { | google() - | jcenter() | } | dependencies { - | classpath "com.android.tools.build:gradle:7.4.0" - | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25" + | classpath "com.android.tools.build:gradle:8.6.1" + | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.0" | } |} |plugins { @@ -167,7 +164,6 @@ class AffectedModuleDetectorIntegrationTest { |allprojects { | repositories { | google() - | jcenter() | } |}""".trimMargin() ) diff --git a/build.gradle b/build.gradle index 67da978..035b13e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.9.25" + ext.kotlin_version = "2.2.0" repositories { google() mavenCentral() @@ -13,7 +13,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath("org.jlleitschuh.gradle:ktlint-gradle:11.4.2") classpath("org.jacoco:org.jacoco.core:0.8.10") - classpath "com.vanniktech:gradle-maven-publish-plugin:0.19.0" + classpath "com.vanniktech:gradle-maven-publish-plugin:0.34.0" } } @@ -28,8 +28,11 @@ allprojects { allprojects { plugins.withId("com.vanniktech.maven.publish") { - mavenPublish { - sonatypeHost = "S01" + mavenPublishing { + // sonatypeHost = "CENTRAL_PORTAL" + publishToMavenCentral() + + signAllPublications() } } } diff --git a/gradle.properties b/gradle.properties index ee6c721..14d1cc4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,7 +22,7 @@ kotlin.code.style=official # POM GROUP = com.dropbox.affectedmoduledetector -VERSION_NAME=0.5.1-SNAPSHOT +VERSION_NAME=0.6.0-SNAPSHOT POM_ARTIFACT_ID = affectedmoduledetector POM_NAME = Affected Module Detector diff --git a/gradle/jacoco.gradle b/gradle/jacoco.gradle index c237511..4ce099e 100644 --- a/gradle/jacoco.gradle +++ b/gradle/jacoco.gradle @@ -48,7 +48,7 @@ project.afterEvaluate { reports { xml.required = true - xml.destination = file("${buildDir}/reports/jacoco/report.xml") + xml.outputLocation = file("${buildDir}/reports/jacoco/report.xml") html.required = true } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 19cfad9..d30212c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/sample/buildSrc/build.gradle.kts b/sample/buildSrc/build.gradle.kts index e577417..bc078df 100644 --- a/sample/buildSrc/build.gradle.kts +++ b/sample/buildSrc/build.gradle.kts @@ -2,7 +2,7 @@ * Copyright (c) 2020, Dropbox, Inc. All rights reserved. */ plugins { - kotlin("jvm") version "1.9.25" + kotlin("jvm") version "2.2.0" `java-gradle-plugin` } @@ -13,7 +13,7 @@ repositories { } dependencies { - implementation("com.dropbox.affectedmoduledetector:affectedmoduledetector:0.5.1-SNAPSHOT") + implementation("com.dropbox.affectedmoduledetector:affectedmoduledetector:0.6.0-SNAPSHOT") testImplementation("junit:junit:4.13.1") testImplementation("com.nhaarman:mockito-kotlin:1.5.0") testImplementation("com.google.truth:truth:1.0.1") diff --git a/sample/buildSrc/src/main/kotlin/com/dropbox/sample/Dependencies.kt b/sample/buildSrc/src/main/kotlin/com/dropbox/sample/Dependencies.kt index ea4550b..7fae42f 100644 --- a/sample/buildSrc/src/main/kotlin/com/dropbox/sample/Dependencies.kt +++ b/sample/buildSrc/src/main/kotlin/com/dropbox/sample/Dependencies.kt @@ -3,8 +3,8 @@ package com.dropbox.sample object Dependencies { private object Versions { - const val KOTLIN_VERSION = "1.9.25" - const val DETEKT_VERSION = "1.20.0" + const val KOTLIN_VERSION = "2.2.0" + const val DETEKT_VERSION = "1.23.8" } object Libs { diff --git a/sample/gradle/wrapper/gradle-wrapper.properties b/sample/gradle/wrapper/gradle-wrapper.properties index 19cfad9..d30212c 100644 --- a/sample/gradle/wrapper/gradle-wrapper.properties +++ b/sample/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/sample/sample-app/build.gradle b/sample/sample-app/build.gradle index 3a516c7..cc07cff 100644 --- a/sample/sample-app/build.gradle +++ b/sample/sample-app/build.gradle @@ -32,11 +32,11 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_21 + targetCompatibility JavaVersion.VERSION_21 } kotlinOptions { - jvmTarget = '11' + jvmTarget = '21' } } diff --git a/sample/sample-util/build.gradle b/sample/sample-util/build.gradle index 36469b4..3eebc8b 100644 --- a/sample/sample-util/build.gradle +++ b/sample/sample-util/build.gradle @@ -30,11 +30,11 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_21 + targetCompatibility JavaVersion.VERSION_21 } kotlinOptions { - jvmTarget = '11' + jvmTarget = '21' } }