Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set global repositories for gradle that I can use them in each gradle project

It's slow to visit the maven official repositories from my country, so I want to try some local repositories first.

Is it able to add them to some global gradle configuration file, that I can just use them in each gradle project, without modifying the project-scope build.gradle file?

like image 376
Freewind Avatar asked May 11 '14 08:05

Freewind


People also ask

How do you add dependency from one project to another in Gradle?

Dependency types To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build.gradle file.

Can I use different Gradle versions for different modules?

Gradle does not support multiple Gradle versions in the same multi project build. This is also not supported in composite builds. Given the constraints, the easiest solution would be to work with a local repository to which you publish and from which you fetch your cross project dependencies.


2 Answers

I would suggest to use the init.gradle script which is located in your home folder $HOME/.gradle/init.gradle which might contain the following content:

allprojects {
    repositories {
        mavenLocal()
        maven {
          url "http://localhost:8081/nexus/content/groups/public/"
        }
    }
}
like image 168
khmarbaise Avatar answered Oct 11 '22 23:10

khmarbaise


I guess that what are You looking for are init scripts.

like image 35
Opal Avatar answered Oct 11 '22 22:10

Opal