MJar
MJar

Reputation: 784

Gradle allow insecure repository mirror

I'm starting a new project. For which I don't need any local dependencies. But in our org we use local maven mirrors that run on http. With maven settings.xml

<mirrors>
    <mirror>
        <id>nexus-local</id>
        <mirrorOf>external:*</mirrorOf>
        <url>http://nexus-local.org.com/nexus/content/groups/public</url>
    </mirror>
</mirrors>

I tried to configure the unsecure connection in gradle to make it happy, like

    repositories {
        maven {
            url "http://nexus-local.org.com/nexus/content/groups/public"
            allowInsecureProtocol = true
        }
    }
    repositories {
        maven {
            url = uri("http://nexus-local.org.com/nexus/content/groups/public")
            isAllowInsecureProtocol = true
        }
    }

But in both cases when I run gradle it just crashes with error (so the result is the same as without this configuration):

* What went wrong:
A problem occurred configuring root project 'panic'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://nexus-local.org.com/nexus/content/groups/public)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.

What am I doing wrong?

Upvotes: 2

Views: 5891

Answers (1)

Kapil Ratnani
Kapil Ratnani

Reputation: 73

Just faced this issue in my Org. Solved it by adding below in ~/.gradle/init.gradle

allprojects {
    repositories {
        maven {
          url "http://artifactory.myorg.org/repo/"
          allowInsecureProtocol true
        }
        mavenLocal()
    }
}

Hope this works.

Upvotes: 2

Related Questions