Skip to content

Commit d45d54f

Browse files
Merge branch 'main' into miken/AffectedTasksPlugin
2 parents 9b3d721 + a89b9b0 commit d45d54f

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,17 @@ In the example below, we're showing a hypothetical project graph and what projec
3939

4040
Apply the project to the root `build.gradle`:
4141
```
42-
apply plugin: "com.dropbox.detector.AffectedModuleDetector"
42+
buildscript {
43+
repositories {
44+
maven {
45+
url "https://plugins.gradle.org/m2/"
46+
}
47+
}
48+
dependencies {
49+
classpath "com.dropbox.affectedmoduledetector:affectedmoduledetector:0.1.0"
50+
}
51+
}
52+
apply plugin: "com.dropbox.affectedmoduledetector"
4353
```
4454

4555
Optionally, you can specify the configuration block for the detector:
@@ -51,19 +61,27 @@ Optionally, you can specify the configuration block for the detector:
5161
]
5262
logFilename = "output.log"
5363
logFolder = "${project.rootDir}/output"
64+
variantToTest = "debug"
5465
}
5566
```
5667

5768
- `baseDir`: The root directory for all of the `pathsAffectingAllModules`. Used to validate the paths exist.
5869
- `pathsAffectingAllModules`: Paths to files or folders which if changed will trigger all modules to be considered affected
5970
- `logFilename`: A filename for the output detector to use
6071
- `logFolder`: A folder to output the log file in
72+
- `variantToTest`: which variant to use for newly registered task
73+
74+
The plugin will create a few top level tasks that will assemble or run tests for only affected modules:
75+
* gradlew runAffectedUnitTests - runs jvm tests
76+
* gradlew runAffectedAndroidTests - runs connected tests
77+
* gradlew assembleAffectedAndroidTests - assembles but does not run on device tests, useful when working with device labs
78+
6179

6280
## Sample Usage
6381

6482
To run this on the sample app, try running the following command:
6583
```
66-
./gradlew test -Paffected_module_detector.enable
84+
./gradlew runAffectedUnitTests -Paffected_module_detector.enable
6785
```
6886

6987
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 it's dependent modules.

affectedmoduledetector/build.gradle

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
id 'java-gradle-plugin'
55
id 'maven-publish'
66
id "com.gradle.plugin-publish" version "0.12.0"
7+
id 'signing'
78
}
89

910

@@ -26,18 +27,25 @@ ext {
2627
VERSION = "0.1.1-SNAPSHOT"
2728
GIT_URL = 'https://github.com/Dropbox/AffectedModuleDetector'
2829
GROUP_ID = "com.dropbox.affectedmoduledetector"
30+
SONATYPE_SNAPSHOT_URL = "https://oss.sonatype.org/content/repositories/snapshots/"
31+
SONATYPE_STAGING_URL = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
2932
}
3033

3134
group = GROUP_ID
3235
version = VERSION
3336
description = DESCRIPTION
3437

38+
java {
39+
withJavadocJar()
40+
withSourcesJar()
41+
}
42+
3543
publishing {
3644
publications {
3745
maven(MavenPublication) {
3846
pom {
3947
name = 'Affected Module Detector'
40-
description = 'A Gradle Plugin to determine which modules were affected in a commit.'
48+
description = DESCRIPTION
4149
url = GIT_URL
4250
licenses {
4351
license {
@@ -63,7 +71,7 @@ publishing {
6371
}
6472
repositories {
6573
maven {
66-
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
74+
url version.endsWith('SNAPSHOT') ? SONATYPE_SNAPSHOT_URL : SONATYPE_STAGING_URL
6775
credentials {
6876
username project.hasProperty("SONATYPE_USERNAME") ? project.property("SONATYPE_USERNAME") : "username"
6977
password project.hasProperty("SONATYPE_PASSWORD") ? project.property("SONATYPE_PASSWORD") : "password"
@@ -95,3 +103,9 @@ pluginBundle {
95103
}
96104
}
97105

106+
107+
signing {
108+
if (!version.endsWith('SNAPSHOT')) {
109+
sign publishing.publications.maven
110+
}
111+
}

0 commit comments

Comments
 (0)