radai
radai

Reputation: 24202

how to disable gradle build scan permanently?

I know I can add --no-scan on an individual command line (see https://docs.gradle.com/build-scan-plugin/), but I'm looking for a way to disable this in build.gradle, gradle.properties or settings.gradle so i dont have to always type it or set an alias.

Any Ideas on how that can be done?

Upvotes: 10

Views: 8231

Answers (4)

mnguyen0998
mnguyen0998

Reputation: 9

You can try the option "Modify run configuration" in the "Build" tab in the bottom navigation, then simply change the command in Run and click Apply. After that, restart Android studio enter image description here

Upvotes: 0

Michiel Haisma
Michiel Haisma

Reputation: 874

Add this to your main build.gradle file (groovy):

buildScan {
  server = 'https://gradle-build-scan-disabled'
}

Now, any attempt to run a --scan will result in an error.

Upvotes: 2

Jerome
Jerome

Reputation: 4582

You can query gradle parameters (tasks, flags...etc.) through StartParameter and fail a build early if it runs with --scan flag as reported by StartParameter.isBuildScan().

The release of Gradle is not specified in the question and that API is available since Gradle 3.1. I believe it was incubating until Gradle 5.X.

if (gradle.startParameter.isBuildScan()) {
    throw new GradleException("you shall not scan")
}

Upvotes: 4

swist
swist

Reputation: 1171

You can edit your hosts file on your computer and place the entry where it is sending the reports to 127.0.0.1. It will print some errors after every build, but that is all.

Another possibility is to add --no-scan to gradle command or wrapper script.

Upvotes: 4

Related Questions