# Gradel init not working

**URL:** <https://discuss.gradle.org/t/gradel-init-not-working/42726>\
**Category:** Help/Discuss\
**Created:** [April 21, 2022, 4:47pm UTC](https://discuss.gradle.org/t/gradel-init-not-working/42726 "2022-04-21T16:47:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaiser101](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@kaiser101](https://discuss.gradle.org/u/kaiser101)\
**Post date:** [April 21, 2022, 4:47pm UTC](https://discuss.gradle.org/t/gradel-init-not-working/42726/1 "2022-04-21T16:47:56Z")

</div>

I am trying to convert a maven project to gradle using gradle init. We need to use our organization’s maven repo and cannot access the central maven repo at [repo.maven.org](http://repo.maven.org) directly.

However even after adding the following in init.gradle script, I get error that gradle is not able to resolve the dependencies.

```gradle
allprojects {
    buildscript {
        repositories {
            mavenLocal()
            maven {
                url "my maven repo"
            }
            mavenCentral()
        }
    }

    repositories {
        mavenLocal()
        maven {
            url "my maven repo"
        }
        mavenCentral()
    }

    settingsEvaluated {
        pluginManagement {
            repositories {
                mavenLocal()
                maven {
                    url "my maven repo"
                }
                mavenCentral()
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [April 22, 2022, 11:43am UTC](https://discuss.gradle.org/t/gradel-init-not-working/42726/2 "2022-04-22T11:43:17Z")

</div>

> and cannot access the central maven repo at [repo.maven.org](http://repo.maven.org/) directly.

That’s what `mavenCentral()` is. If you do not want to look there directly, you need to remove those.

So what exactly can not be found? A plugin? A normal compile/runtime dependency? Not 100% sure it is related, but it is strange the way you define the plugin repos. Why do you delay that? Assuming it is plugins your build cannot resolve, this actually could be related. Plus, you do not even specify the standard plugin repo (`gradlePluginPortal()`).

Just move the `pluginManagement {}` block into your `settings.gradle` file and drop the `settingsEvaluated {}` part:

```gradle
// in `settings.gradle`

pluginManagement {
    repositories {
        mavenLocal()
        maven {
            url ...
        }
        // unless you also do not want to directly access the standard plugin repo
        gradlePluginPortal()
    }
}

```

---

<div class="post-metadata">

**Author:** ![kaiser101](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@kaiser101](https://discuss.gradle.org/u/kaiser101)\
**Post date:** [April 22, 2022, 12:57pm UTC](https://discuss.gradle.org/t/gradel-init-not-working/42726/3 "2022-04-22T12:57:27Z")

</div>

Ok I created a new file called settings.gradle in the ~/.gradle directory (same place where I have the init.gradle file) and dropped the pluginManagement section there. However I am still getting the same error. This is what the build is trying to resolve and fails.

```gradle
> :init > Resolve dependencies of :detachedConfiguration1 > aether-connector-basic-1.1.0.pom
> :init > Resolve dependencies of :detachedConfiguration1 > aether-transport-wagon-1.1.0.pom
> :init > Resolve dependencies of :detachedConfiguration1 > wagon-provider-api-3.4.2.pom
> :init > Resolve dependencies of :detachedConfiguration1 > maven-core-3.6.3.pom
> :init > Resolve dependencies of :detachedConfiguration1 > maven-compat-3.6.3.pom
> :init > Resolve dependencies of :detachedConfiguration1 > wagon-http-3.4.2.pom

```

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [April 22, 2022, 3:08pm UTC](https://discuss.gradle.org/t/gradel-init-not-working/42726/4 "2022-04-22T15:08:09Z")

</div>

What creates these detached Configurations? Those are special and something would have created them explicitly

---

<div class="post-metadata">

**Author:** ![kaiser101](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@kaiser101](https://discuss.gradle.org/u/kaiser101)\
**Post date:** [April 22, 2022, 6:05pm UTC](https://discuss.gradle.org/t/gradel-init-not-working/42726/5 "2022-04-22T18:05:34Z")

</div>

I dont think so. I get the same messages on my personal PC when I try to create a gradle project from a maven one. Only difference is my personal PC does not have a artifactory maven repo and resolves dependencies from the net directly.

---

<div class="post-metadata">

**Author:** ![Steve\_Ebersole](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/steve_ebersole/32/9763_2.png) [@Steve\_Ebersole](https://discuss.gradle.org/u/Steve_Ebersole)\
**Post date:** [April 22, 2022, 6:12pm UTC](https://discuss.gradle.org/t/gradel-init-not-working/42726/6 "2022-04-22T18:12:51Z")

</div>

No idea how that relates to what I asked.

I am going to assume you understand what a Gradle Configuration is and start from there. Various things create these Configurations - plugins, your build, etc.

There is a special kind of Configuration called detached - see [ConfigurationContainer - Gradle DSL Version 7.4.2](https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ConfigurationContainer.html#org.gradle.api.artifacts.ConfigurationContainer:detachedConfiguration(org.gradle.api.artifacts.Dependency%5B%5D)).

So I am asking who creates these.

---

<div class="post-metadata">

**Author:** ![kaiser101](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@kaiser101](https://discuss.gradle.org/u/kaiser101)\
**Post date:** [April 26, 2022, 11:03am UTC](https://discuss.gradle.org/t/gradel-init-not-working/42726/7 "2022-04-26T11:03:02Z")

</div>

I have no idea what creates this detachedconfiguration. I also tried to convert a simple spring boot project which I created from [start.spring.io](http://start.spring.io) from maven to gradle using gradle init and I got the same detachedConfiguration messages.

My other question is even if that be the case, how can I force the reoslution of the artifacts in the detachedConfiguration to point to my organizations maven repo instead of trying to resolve it from [Central Repository:](https://repo.maven.apache.org/maven2/)

---

<div class="post-metadata">

**Author:** ![kaiser101](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@kaiser101](https://discuss.gradle.org/u/kaiser101)\
**Post date:** [January 13, 2023, 8:53am UTC](https://discuss.gradle.org/t/gradel-init-not-working/42726/8 "2023-01-13T08:53:18Z")

</div>

The gradle init plugin creates these detached configurations.

Also currently there seems to be no way to resolve them from a custom maven repo. And I cannot access the repo at [repo.maven.org](http://repo.maven.org)

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [January 14, 2023, 3:05am UTC](https://discuss.gradle.org/t/gradel-init-not-working/42726/9 "2023-01-14T03:05:57Z")

</div>

As far as I know, you cannot influence that.

The plugin adding the `init` task is not only using a detached configuration, it also uses a detached resolver that is completely independent from what you write in any build script, settings script, or init script.

For this detached resolver it uses hard-coded `mavenCentral()` to resolve these dependencies it needs for getting the model out of your POM to create a Gradle build from it.

The only way would be outside of Gradle, using some Proxy or DNS trickery.

But it is probably easier to just create the Gradle build from scratch instead of using the `init` task for the conversion.
