Configure dependency repositories and publishing repositories for your Gradle project.
Configure dependency repositories
Common mPaaS dependency repositories:
allprojects {
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
maven {
url "https://mvn.cloud.alipay.com/nexus/content/repositories/open/"
}
maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven{url 'http://maven.aliyun.com/nexus/content/repositories/google'}
}
}
-
mavenLocal: The local Maven repository. You can also change the path to the local repository.
-
flatDir: Dependencies in the project's libs folder.
-
maven: Remote Maven repositories, such as those from Ant Group (
mvn.cloud.alipay.com) and Alibaba Cloud (maven.aliyun.com).
Add dependency repositories under the repositories block.
Configure publishing repositories
The following examples show how to configure publishing repositories. You can change the local Maven repository path, which defaults to ~/.m2, or add a custom publishing repository.
Example of a publishing repository
A typical build.gradle file contains the following configuration:
uploadArchives {
repositories {
mavenLocal()
}
}
This sets the publishing repository to the local Maven repository. Project artifacts, such as .jar packages, are automatically published to this repository.
Change the local Maven repository path
The local Maven repository (mavenLocal) defaults to ~/.m2. You can change this path.
Custom publishing repository
To add a custom publishing repository, use the following configuration:
uploadArchives {
mavenDeployer {
mavenLocal()
repository(url: "your_repository_url") {
authentication(userName: '*****', password: '*****')
}
snapshotRepository(url: "your_repository_url") {
authentication(userName: '*****', password: '*****')
}
}
}