gradle / gradle-native

The home of Gradle's support for natively compiled languages
https://blog.gradle.org/introducing-the-new-cpp-plugins
Apache License 2.0
91 stars 8 forks source link

Gradle not using custom repository during gradle init #1097

Open semih-toprak opened 2 years ago

semih-toprak commented 2 years ago

I am trying to migrate my project from maven, but I can not access the custom company repository. Gradle connects to the central repository by default, and disregards both my maven settings.xml and init.gradle. The issue is the same as https://github.com/gradle/gradle/issues/19884 but I am using a windows machine.

Expected Behavior

Gradle should use the repository settings from init.gradle.

Current Behavior

Gradle ignores the settings and tries to access https://repo.maven.apache.org/maven2 instead and gets blocked by corporate proxy. Same settings work fine while running any other gradle command, such as build.

Context

I can not convert a maven project to gradle while behind a corporate proxy that blocks maven repos.

Steps to Reproduce (for bugs)

1- Be behind a proxy that blocks maven repos. 2- Have a maven project 3- Open maven project folder and run gradle init with init.gradle config.

Your Environment

init.gradle file:

    allprojects {

        repositories {

            mavenLocal()

        maven { url "custom-repo" }

        maven { url "custom-repo" }

        maven { url "custom-repo" }
    }
}

Settings xml:

<mirrors>
    <mirror>
        <mirrorOf>*</mirrorOf>
        <name>remote-repos</name>
        <url>custom-repo</url>
        <id>remote-repos</id>
    </mirror>
<!--  This was added in case * mirror did not work, but changed nothing. -->
    <mirror>
        <mirrorOf>central</mirrorOf>
        <name>apache-repo</name>
        <url>custom-repo</url>
        <id>apache-repo</id>
    </mirror>
</mirrors>
<!--  This was added in case mirrors did not work, but changed nothing.  -->
<repositories>
            <repository>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>central</id>
                <name>libs-release</name>
                <url>custom-repo</url>
            </repository>
            <repository>
                <snapshots />
                <id>snapshots</id>
                <name>libs-snapshot</name>
                <url>custom-repo</url>
            </repository>
        </repositories>

This is probably because it did not use my repo settings and got blocked by proxy.

motoroler commented 1 year ago

Hi! any update on this issue? I experience the same problem - try to transform maven project to gradle one, but it fails because my laptop behind firewall and it can't reach private repos

madorb commented 1 year ago

this is the wrong project. https://github.com/gradle/gradle/issues/20596