### Run Affected Unit Tests in Sample Project Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md Example of navigating to the sample project directory and running affected unit tests with the module detector enabled, demonstrating initial setup and verification of the plugin's functionality. ```bash cd sample ./gradlew runAffectedUnitTests -Paffected_module_detector.enable ``` -------------------------------- ### Install Affected Module Detector via Plugin Management Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md This snippet demonstrates how to install the Affected Module Detector Gradle plugin using the modern `pluginManagement` block in `settings.gradle(.kts)` and applying it in the `plugins` block of your root `build.gradle(.kts)`. The plugin is published to Maven Central. ```Groovy // settings.gradle pluginManagement { repositories { mavenCentral() gradlePluginPortal() } } // root build.gradle plugins { id("com.dropbox.affectedmoduledetector") version "" } ``` ```Kotlin // settings.gradle.kts pluginManagement { repositories { mavenCentral() gradlePluginPortal() } } // root build.gradle.kts plugins { id("com.dropbox.affectedmoduledetector") version "" } ``` -------------------------------- ### Install Affected Module Detector via Buildscript Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md This snippet shows an alternative method to install the Affected Module Detector Gradle plugin using the older `buildscript` block for dependencies and then applying the plugin with `apply plugin` in your root `build.gradle`. ```Groovy buildscript { repositories { mavenCentral() } dependencies { classpath "com.dropbox.affectedmoduledetector:affectedmoduledetector:" } } //rootproject apply plugin: "com.dropbox.affectedmoduledetector" ``` -------------------------------- ### Affected Module Detector Configuration Parameters Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md Detailed documentation for the configuration parameters available in the `affectedModuleDetector` and `affectedTestConfiguration` blocks, explaining their purpose, usage, and possible values. This includes parameters for path management, logging, change comparison, module filtering, and custom task integration. ```APIDOC AffectedModuleDetectorConfiguration: baseDir: string Description: The root directory for all of the `pathsAffectingAllModules`. Used to validate the paths exist. pathsAffectingAllModules: list Description: Paths to files or folders which if changed will trigger all modules to be considered affected. logFilename: string Description: A filename for the output detector to use. logFolder: string Description: A folder to output the log file in. specifiedBranch: string Description: A branch to specify changes against. Must be used in combination with configuration `compareFrom = "SpecifiedBranchCommit"`. specifiedRawCommitSha: string Description: A raw commit SHA to specify changes against. Must be used in combination with configuration `compareFrom = "SpecifiedRawCommitSha"`. ignoredFiles: list Description: A set of files that will be filtered out of the list of changed files retrieved by git. buildAllWhenNoProjectsChanged: boolean Description: If true, the plugin will build all projects when no projects are considered affected. compareFrom: enum Description: A commit to compare the branch changes against. Values: - PreviousCommit: compare against the previous commit. - ForkCommit: compare against the commit the branch was forked from. - SpecifiedBranchCommit: compare against the last commit of `$specifiedBranch` using `git rev-parse` approach. - SpecifiedBranchCommitMergeBase: compare against the nearest ancestors with `$specifiedBranch` using `git merge base` approach. - SpecifiedRawCommitSha: compare against the provided raw commit SHA. Note: specify the branch to compare changes against using the `specifiedBranch` configuration before the `compareFrom` configuration. excludedModules: list Description: A list of modules that will be excluded from the build process, can be the name of a module, or a regex against the module gradle path. includeUncommitted: boolean Description: If uncommitted files should be considered affected. top: string Description: The top of the git log to use. Must be used in combination with configuration `includeUncommitted = false`. customTasks: list Description: Set of CustomTask objects. See [CustomTask](https://github.com/dropbox/AffectedModuleDetector/blob/main/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleConfiguration.kt). AffectedTestConfiguration: assembleAndroidTestTask: string Description: Task for assembling Android release tests. runAndroidTestTask: string Description: Task for running connected Android release tests. jvmTestTask: string Description: Task for running JVM release tests. ``` -------------------------------- ### Run Affected Unit Tests for All Affected Projects Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md Demonstrates how to execute unit tests on all projects affected by a change, including both directly changed and dependent projects, by enabling the `affected_module_detector.enable` flag. ```bash ./gradlew runAffectedUnitTests -Paffected_module_detector.enable ``` -------------------------------- ### Git Commit for Release Preparation Source: https://github.com/dropbox/affectedmoduledetector/blob/main/RELEASING.md Creates a Git commit message to mark the preparation for a new software release, typically after updating version numbers in project files like `gradle.properties`. ```bash git commit -am "Prepare for release X.Y.Z." ``` -------------------------------- ### Git Tag for Release Version Source: https://github.com/dropbox/affectedmoduledetector/blob/main/RELEASING.md Creates an annotated Git tag for a specific release version (X.Y.Z), associating a descriptive message with the tag for better release management and traceability. ```bash git tag -a vX.Y.X -m "Version X.Y.Z" ``` -------------------------------- ### Publish Affected Module Detector Plugin to Local Maven Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md Command to publish the `affectedmoduledetector` plugin artifact to the local Maven repository, making it available for local project consumption and testing. ```bash ./gradlew :affectedmoduledetector:publishToMavenLocal ``` -------------------------------- ### Run Affected Unit Tests for Changed Projects Only Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md Shows how to run unit tests exclusively on projects that have directly changed, using the `affected_module_detector.enable` and `affected_module_detector.changedProjects` flags. ```bash ./gradlew runAffectedUnitTests -Paffected_module_detector.enable -Paffected_module_detector.changedProjects ``` -------------------------------- ### Affected Module Detector Plugin APIs Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md This section documents the key APIs exposed by the Affected Module Detector Gradle plugin, enabling programmatic interaction with its functionality. These APIs are useful for custom Gradle tasks or plugins. ```APIDOC AffectedModuleDetector: configureTaskGuard(task: Task): void description: Applies an 'onlyIf' guard on a given task, preventing its execution if the project is not affected. task: The Gradle Task instance to apply the guard to. usage_notes: Can be called either during configuration or execution phase of Gradle. isProjectAffected(project: Project): boolean description: Returns a boolean indicating whether the specified project has been considered affected by recent changes. project: The Gradle Project instance to check. usage_notes: Can only be called after the project has been configured. ``` -------------------------------- ### Git Commit for Next Development Version Source: https://github.com/dropbox/affectedmoduledetector/blob/main/RELEASING.md Creates a Git commit to signify the transition to the next development cycle, typically after incrementing the project version to a SNAPSHOT or development state. ```bash git commit -am "Prepare next development version." ``` -------------------------------- ### Git Push Release Commit and Tags Source: https://github.com/dropbox/affectedmoduledetector/blob/main/RELEASING.md Pushes the current branch's commits and all local tags to the remote repository, making the release commit and its associated version tag visible and accessible to others. ```bash git push && git push --tags ``` -------------------------------- ### Run Affected Unit Tests for Dependent Projects Only Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md Illustrates how to execute unit tests solely on projects that are dependent on changed projects, by enabling `affected_module_detector.enable` and `affected_module_detector.dependentProjects`. ```bash ./gradlew runAffectedUnitTests -Paffected_module_detector.enable -Paffected_module_detector.dependentProjects ``` -------------------------------- ### Configure Affected Module Detector Plugin Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md This Groovy snippet demonstrates how to configure the Affected Module Detector plugin in a Gradle project's root build script. It sets up base directories, paths affecting all modules, logging, comparison strategies, excluded modules, ignored files, and custom tasks for impact analysis. ```groovy affectedModuleDetector { baseDir = "${project.rootDir}" pathsAffectingAllModules = [ "buildSrc/" ] logFilename = "output.log" logFolder = "${project.rootDir}/output" compareFrom = "PreviousCommit" //default is PreviousCommit excludedModules = [ "sample-util", ":app|library:.+" ] ignoredFiles = [ ".*\\.md", ".*\\.txt", ".*README" ] buildAllWhenNoProjectsChanged = true // default is true includeUncommitted = true top = "HEAD" customTasks = [ new AffectedModuleConfiguration.CustomTask( "runDetektByImpact", "detekt", "Run static analysis tool without auto-correction by Impact analysis" ) ] } ``` -------------------------------- ### Configure Custom Task in Affected Module Detector Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md Demonstrates how to declare a custom Gradle task within the `affectedModuleDetector` configuration block in `build.gradle`, specifying its name, command, and description for impact analysis. This allows integrating custom build steps with the plugin's affected module detection. ```groovy affectedModuleDetector { // ... customTasks = [ new AffectedModuleConfiguration.CustomTask( "runDetektByImpact", "detekt", "Run static analysis tool without auto-correction by Impact analysis" ) ] // ... } ``` -------------------------------- ### Add Affected Module Detector to buildSrc Dependencies Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md To develop a custom Gradle plugin that utilizes the Affected Module Detector's APIs, add the plugin as an `implementation` dependency to your `buildSrc` project's `dependencies` list. ```Groovy implementation("com.dropbox.affectedmoduledetector:affectedmoduledetector:") ``` -------------------------------- ### Configure Affected Module Test Tasks Source: https://github.com/dropbox/affectedmoduledetector/blob/main/README.md This Groovy snippet shows how to customize the variant-specific test tasks for affected modules within the Affected Module Detector plugin. It allows specifying custom tasks for assembling Android tests, running connected Android tests, and executing JVM tests. ```groovy affectedTestConfiguration { assembleAndroidTestTask = "assembleAndroidReleaseTest" runAndroidTestTask = "connectedAndroidReleaseTest" jvmTestTask = "testRelease" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.