Gradle init not using custom repo when converting maven project

Viewed 208

I am trying to convert a maven project to gradle. Our maven project uses a custom repository for dependencies, and we can not download anything from ordinary repos. When running command

gradle init -I ./init.gradle

I am getting errors and I can see on the command line that it is trying to connect to the https://repo.maven.apache.org/maven2. I have tried using the init.gradle script from userhome and gradlehome, but there was no change. I also added the custom repo to pom.xml since I saw someone say gradle uses those if available, but it didn't. This is my init.gradle for reference:

apply plugin: EnterpriseRepositoryPlugin

class EnterpriseRepositoryPlugin implements Plugin<Gradle> {

    void apply(Gradle gradle) {
        gradle.settingsEvaluated { settings ->
            settings.pluginManagement {
                repositories {
                    maven {
                      url "custom_repository_url"
                    }
                }    
            }
        }
    }
} 

I also tried this at first:

allprojects {
    buildscript {
        repositories {
           mavenLocal()
           maven { url "custom_repository_url"}
        }
      } 
    repositories {
        mavenLocal()
        maven {
          url "custom_repository_url"
        }
    }
}

I have also tried adding a build.gradle with the following task and running it:

tasks.register('showRepos') {
    doLast {
        println "All repos:"
        println repositories.collect { it.name }
    }
}

This only printed out the custom repo. However deleting this and running gradle init still connects to the https://repo.maven.apache.org/maven2.

Edit:

It seems this question won't be solved. In case you found this when looking for an answer, I have found this solution that might work for you. I wasn't so lucky.

https://github.com/gradle/gradle/issues/19884

I have also crated an issue on github. Maybe there will be an answer there.

https://github.com/gradle/gradle-native/issues/1097

0 Answers
Related