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
4 changes: 2 additions & 2 deletions .github/workflows/ci_test_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sample_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions affectedmoduledetector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String>? {
Expand Down Expand Up @@ -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}")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,41 @@ 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<ProjectPath, Set<ProjectPath>>
class DependencyTracker(private val rootProject: Project, private val logger: Logger?) : Serializable {

init {
private val dependentList: Map<ProjectPath, Set<ProjectPath>> by lazy {
val result = mutableMapOf<ProjectPath, MutableSet<ProjectPath>>()
val stringBuilder = StringBuilder()
rootProject.subprojects.forEach { project ->
logger?.info("checking ${project.path} for dependencies")
project.configurations.forEach { config ->
config.dependencies.filterIsInstance<ProjectDependency>().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<ProjectDependency>()
.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<ProjectPath> {
logger?.info("finding dependents of $projectPath")
val result = mutableSetOf<ProjectPath>()
fun addAllDependents(projectPath: ProjectPath) {
if (result.add(projectPath)) {
dependentList[projectPath]?.forEach(::addAllDependents)
}
}
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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProjectPath>()
rootNode.addAllProjectPaths(result)
Expand Down Expand Up @@ -109,6 +105,10 @@ class ProjectGraph(project: Project, logger: Logger? = null) : Serializable {
}
}
}

fun getRootProjectPath(): ProjectPath? {
return rootNode.projectPath
}
}

fun Project.getSupportRootFolder(): File = project.rootDir
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -70,7 +69,6 @@ class AffectedModuleDetectorIntegrationTest {
|allprojects {
| repositories {
| google()
| jcenter()
| }
|}""".trimMargin()
)
Expand Down Expand Up @@ -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 {
Expand All @@ -167,7 +164,6 @@ class AffectedModuleDetectorIntegrationTest {
|allprojects {
| repositories {
| google()
| jcenter()
| }
|}""".trimMargin()
)
Expand Down
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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"
}
}

Expand All @@ -28,8 +28,11 @@ allprojects {

allprojects {
plugins.withId("com.vanniktech.maven.publish") {
mavenPublish {
sonatypeHost = "S01"
mavenPublishing {
// sonatypeHost = "CENTRAL_PORTAL"
publishToMavenCentral()

signAllPublications()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle/jacoco.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions sample/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}

Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion sample/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions sample/sample-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down
6 changes: 3 additions & 3 deletions sample/sample-util/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down