在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):dropbox/AffectedModuleDetector开源软件地址(OpenSource Url):https://github.com/dropbox/AffectedModuleDetector开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):Affected Module DetectorA Gradle Plugin to determine which modules were affected by a set of files in a commit. One use case for this plugin is for developers who would like to only run tests in modules which have changed in a given commit. OverviewThe AffectedModuleDetector will look at the last commit and determine which files have changed, it will then build a dependency graph of all the modules in the project. The detector exposes a set of APIs which can be used to determine whether a module was considered affected. GitThe module detector assumes that it is being applied to a project stored in git and a git client is present on the system. It will query the last commit on the current branch to determine the list of files changed. Dependency TrackerThe tracker will evaluate the project and find all modules and their dependencies for all configurations. Affected Module DetectorThe detector allows for three options for affected modules:
These options can be useful depending on how many tests your project has and where in the integration cycle you would like to run them. For example, Changed Projects may be a good options when initially sending a Pull Requests, and All Affected Projects may be useful to use when a developer merges their pull request. The detector exposes APIs which will be helpful for your plugin to use. In particular, it exposes:
In the example below, we're showing a hypothetical project graph and what projects would be considered affected if the All Affected Projects option was used and a change was made in the Installation// settings.gradle(.kts)
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
// root build.gradle(.kts)
plugins {
id("com.dropbox.affectedmoduledetector") version "<latest-version>"
} Note that the plugin is currently published to Maven Central, so you need to add it to the repositories list in the Alternatively, it can be consumed via manual buildscript dependency + plugin application. Apply the project to the root buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.dropbox.affectedmoduledetector:affectedmoduledetector:<LATEST_VERSION>"
}
}
//rootproject
apply plugin: "com.dropbox.affectedmoduledetector" If you want to develop a plugin using the APIs, add this to your
ConfigurationYou can specify the configuration block for the detector in the root project: affectedModuleDetector {
baseDir = "${project.rootDir}"
pathsAffectingAllModules = [
"buildSrc/"
]
logFilename = "output.log"
logFolder = "${project.rootDir}/output"
compareFrom = "PreviousCommit" //default is PreviousCommit
excludedModules = [
"sample-util"
]
includeUncommitted = true
top = "HEAD"
customTasks = [
new AffectedModuleConfiguration.CustomTask(
"runDetektByImpact",
"detekt",
"Run static analysis tool without auto-correction by Impact analysis"
)
]
}
By default, the Detector will look for affectedTestConfiguration {
assembleAndroidTestTask = "assembleAndroidReleaseTest"
runAndroidTestTask = "connectedAndroidReleaseTest"
jvmTestTask = "testRelease"
} The plugin will create a few top level tasks that will assemble or run tests for only affected modules:
Sample UsageRunning the plugin generated tasks is quite simple. By default, if Running All Affected Projects (Changed Projects + Dependent Projects)To run all the projects affected by a change, run one of the tasks while enabling the module detector.
Running All Changed ProjectsTo run all the projects that changed, run one of the tasks (while enabling the module detector) and with
Running All Dependent ProjectsTo run all the dependent projects of projects that changed, run one of the tasks (while enabling the module detector) and with
Using the Sample projectTo run this on the sample app:
You should see zero tests run. Make a change within one of the modules and commit it. Rerunning the command should execute tests in that module and its dependent modules. Custom tasksIf you want to add a custom gradle command to execute with impact analysis
you must declare AffectedModuleConfiguration.CustomTask
which is implementing AffectedModuleTaskType in the configuration in // ...
affectedModuleDetector {
// ...
customTasks = [
new AffectedModuleConfiguration.CustomTask(
"runDetektByImpact",
"detekt",
"Run static analysis tool without auto-correction by Impact analysis"
)
]
// ...
} NOTE: Please, test all your custom commands.
If your custom task doesn't work correctly after testing, might be your task quite complex
and for correct working must using more gradle's api.
Hence, you must create NotesSpecial thanks to the AndroidX for originally developing this project at https://android.googlesource.com/platform/frameworks/support/+/androidx-main/buildSrc/src/main/kotlin/androidx/build/dependencyTracker License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论