2

TLDR: I want to download plugin id("org.gradle.kotlin.kotlin-dsl") using proxy.

I work in a big corporation and there are strict rules regarding internet access. I have to download every library using corpo proxy.

Lately I've implemented buildSrc, and inside it I have build.gradle with following content:

plugins {
    id("org.gradle.kotlin.kotlin-dsl") version "1.3.3"
    id("groovy")
}

repositories {
    maven { url "http://corpo.proxy....." }
    maven { url "http://corpo.proxy....." }
}

dependencies {
    gradleApi()
    localGroovy()

    implementation 'commons-codec:commons-codec:1.15'

    implementation 'com.squareup:javapoet:1.10.0'
    implementation 'com.squareup:kotlinpoet:1.0.0-RC1'
    compileOnly("com.android.tools.build:gradle:4.0.1")

    implementation("com.android.tools.build:gradle:4.0.1")
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20")
}

Also, following this topic: How can the gradle plugin repository be changed? I've implemented pluginManagement inside settings.gradle:

pluginManagement {
    resolutionStrategy {
        eachPlugin {
            if (requested.id.namespace == 'org.gradle.sample') {
                useModule('org.gradle.sample:sample-plugins:1.0.0')
            }
        }
    }
    repositories {
        maven { url "http://corpo.proxy..." }
        maven { url "http://corpo.proxy..." }
    }
}

But unfortunately gradle is still trying to download kotlin-dsl plugin via google url, instead of using proxy url.

What am I doing wrong?

Many thanks!

TheD3luxed
  • 178
  • 1
  • 8
  • This is the way. Just ran your code without the `build.{repositories|dependencies}` sections and it failed as expected with `could not resolve plugin artifact 'org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:1.3.3' Searched in the following repositories: maven(http://corpo.proxy...) maven2(http://corpo.proxy...)`. Why do you think your code's not using the proxy? – Alex Mar 02 '22 at 14:48
  • @Alex Because our jenkins builds are failing, and in the logs I don't see any references to proxy's urls. What gradle version are you using? – TheD3luxed Mar 03 '22 at 08:07
  • My version are: Android Gradle Plugin Version 4.0.1, Gradle Version 6.1.1 – TheD3luxed Mar 03 '22 at 08:12
  • Tested originally with 4.9, the same outcome with 6.1.1. No android plugin used. What's the error you're getting? That should have been mentioned in your post. – Alex Mar 03 '22 at 09:19

0 Answers0