Skip to content

Commit

Permalink
build: introduce -Pscan build parameter (#77)
Browse files Browse the repository at this point in the history
Signed-off-by: Jendrik Johannes <[email protected]>
  • Loading branch information
jjohannes authored Jan 13, 2025
1 parent 8a8dfd8 commit a149d55
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,17 @@ In a CI pipeline for PR validation with multiple steps use the following.

| Task and Parameters | Description |
|---------------------------------|------------------------------------------------------------------------|
| `./gradlew assemble --scan` | Build all artifacts (populates remote build cache) |
| `./gradlew qualityCheck --scan` | Run all checks except tests |
| `./gradlew test --scan` | Run all unit tests |
| `./gradlew <test-set> --scan` | Run all tests in _test-set_ (possibly on different agents in parallel) |
| `./gradlew assemble -Pscan` | Build all artifacts (populates remote build cache) |
| `./gradlew qualityCheck -Pscan` | Run all checks except tests |
| `./gradlew test -Pscan` | Run all unit tests |
| `./gradlew <test-set> -Pscan` | Run all tests in _test-set_ (possibly on different agents in parallel) |

Alternatively, if you are fine to do more in one pipeline step, you can use:

| Task and Parameters | Description |
|-------------------------------|-------------------------------------|
| `./gradlew build --scan` | `assemble` + `qualiyCheck` + `test` |
| `./gradlew <test-set> --scan` | Run all tests in _test-set_ |
| `./gradlew build -Pscan` | `assemble` + `qualiyCheck` + `test` |
| `./gradlew <test-set> -Pscan` | Run all tests in _test-set_ |

#### Environment

Expand All @@ -194,7 +194,7 @@ to coverage analysis services like Codecov.

| Task and Parameters | Description |
|-------------------------------------------|----------------------------------------------|
| `./gradlew testCodeCoverageReport --scan` | Generate a single XML with all coverage data |
| `./gradlew testCodeCoverageReport -Pscan` | Generate a single XML with all coverage data |

Report location: `gradle/aggregation/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml`

Expand All @@ -214,8 +214,8 @@ multiple times with different values for the `publishingPackageGroup` parameter.

| Task and Parameters | Description |
|--------------------------------------------------------------------------------------------------|----------------------------------------|
| `./gradlew releaseMavenCentral -PpublishingPackageGroup=<group> --no-configuration-cache --scan` | Publish artifacts to Maven central |
| `./gradlew publishPlugins --no-configuration-cache --scan` | Publish plugin to Gradle plugin portal |
| `./gradlew releaseMavenCentral -PpublishingPackageGroup=<group> --no-configuration-cache -Pscan` | Publish artifacts to Maven central |
| `./gradlew publishPlugins --no-configuration-cache -Pscan` | Publish plugin to Gradle plugin portal |

The following parameters may be used to tune or test the publishing (default is `false` for all parameters).

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Conventions for 'com.gradle.develocity' that automatically accept the terms of use for 'scans.gradle.com' if users opt-in via '--scan'
Conventions for 'com.gradle.develocity' that automatically accept the terms of use for 'scans.gradle.com' if users opt-in via '-Pscan'
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@ plugins { id("com.gradle.develocity") }

develocity {
buildScan {
val publishBuildScan =
providers.gradleProperty("scan").getOrElse("false").let {
if (it.isBlank()) true else it.toBoolean()
}

termsOfUseUrl = "https://gradle.com/help/legal-terms-of-use"
termsOfUseAgree = "yes"
// Enable Gradle Build Scan only with explicit '--scan'
publishing.onlyIf { false }
// Enable Gradle Build Scan only with explicit '-Pscan'
publishing.onlyIf { publishBuildScan }
}
}

if (gradle.startParameter.isBuildScan) {
logger.lifecycle(
"WARNING: running with '--scan' has negative effects on build caching, use '-Pscan' instead"
)
}

0 comments on commit a149d55

Please sign in to comment.