# Configuring Gradle to use internal mirror instead of internet for everything

**URL:** <https://discuss.gradle.org/t/configuring-gradle-to-use-internal-mirror-instead-of-internet-for-everything/25862>\
**Category:** Help/Discuss\
**Created:** [February 16, 2018, 12:19pm UTC](https://discuss.gradle.org/t/configuring-gradle-to-use-internal-mirror-instead-of-internet-for-everything/25862 "2018-02-16T12:19:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vbezhenar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vbezhenar](https://discuss.gradle.org/u/vbezhenar)\
**Post date:** [February 16, 2018, 12:19pm UTC](https://discuss.gradle.org/t/configuring-gradle-to-use-internal-mirror-instead-of-internet-for-everything/25862/1 "2018-02-16T12:19:52Z")

</div>

I’m using Gradle to build my projects. Those projects must be able to build in the offline environment. I’ve collected all dependencies and installed a webserver with those dependencies in maven2 format. Now I have to configure Gradle to use this webserver instead of trying to reach internet. Also I don’t want to change my projects, I want it to be machine-specific configuration.

With Maven I solved it this way: create file `~/.m2/settings.xml` with the following content:

```
<settings>
  <mirrors>
    <mirror>
      <id>internal-mirror</id>
      <mirrorOf>*</mirrorOf>
      <url>http://192.168.1.20:9123</url>
    </mirror>
  </mirrors>
</settings>

```

But with Gradle it’s not so easy, especially using new DSL for plugins. I’ve come with the following monstrous configuration, but I’m not sure if it’s enough. I suspect that there must be easier way, but I didn’t find it yet, documentation on this matter seems to be very sparse. So I put the following into `~/.gradle/init.d/repositories.gradle`:

```
initscript {
  gradle.settingsEvaluated { settings ->
    settings.pluginManagement {
      repositories {
        maven {
          url "http://192.168.1.20:9123"
        }
      }
    }
  }
}
allprojects {
  buildscript {
    repositories {
      maven {
        url "http://192.168.1.20:9123"
      }
    }
  }
  repositories {
    maven {
      url "http://192.168.1.20:9123"
    }
  }
}

```

Is it a proper way to declare mirror for everything?
