Gradle: Support allowInsecureProtocol in kotlin DSL

Created on 31 Dec 2019  Â·  1Comment  Â·  Source: gradle/gradle

Expected Behavior

allowInsecureProtocol should be supported in build.gradle.kts.

Current Behavior

repositories {
  maven(url = "http://example.com", allowInsecureProtocol = true)
}

results in:

  Line 26:   maven(url = "http://example.com", allowInsecureProtocol = true)
                                               ^ Cannot find a parameter with this name: allowInsecureProtocol

Context

One required repository is only available via HTTP, not HTTPS. Without the above, a warning is printed on every build:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings

or with --warning-mode all:

Using insecure protocols with repositories has been deprecated. This is scheduled to be removed in Gradle 7.0. Switch Maven repository 'maven(http://example.com)' to a secure protocol (like HTTPS) or allow insecure protocols, see https://docs.gradle.org/6.0.1/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol.
feature contributor

Most helpful comment

It does actually work, you're just doing it doubly wrong because the right way to do it doesn't actually appear to be documented anywhere.

Don't worry, so was I.

You want this.

repositories {
  maven {
    url = uri("http://example.com")
    isAllowInsecureProtocol = true
  }
}

Many tools that expect a strictly-Java-esque naming convention for 'properties'/getters and setters get confused by how Kotlin generates getters and setters for certain properties.

You can read my comment on this Jackson issue for more detail. The relevant Kotlin documentation is here.

>All comments

It does actually work, you're just doing it doubly wrong because the right way to do it doesn't actually appear to be documented anywhere.

Don't worry, so was I.

You want this.

repositories {
  maven {
    url = uri("http://example.com")
    isAllowInsecureProtocol = true
  }
}

Many tools that expect a strictly-Java-esque naming convention for 'properties'/getters and setters get confused by how Kotlin generates getters and setters for certain properties.

You can read my comment on this Jackson issue for more detail. The relevant Kotlin documentation is here.

Was this page helpful?
0 / 5 - 0 ratings