All Products
Search
Document Center

Manage gradle dependencies

Last Updated: Apr 01, 2021

Configure a dependency repository

Gradle provides the function of configuring a dependency repository. The following shows an example of a common dependency repository of mPaaS:

  1. allprojects {
  2. repositories {
  3. mavenLocal()
  4. flatDir {
  5. dirs 'libs'
  6. }
  7. maven {
  8. credentials {
  9. username "*******"
  10. password "*******"
  11. }
  12. url "http://mvn.cloud.alipay.com/nexus/content/repositories/releases/"
  13. }
  14. maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
  15. maven {url 'http://maven.aliyun.com/nexus/content/repositories/google'}
  16. }
  17. }
  • mavenLocal: Maven local repository You can change the path of a local repository. For more information, see Local Maven repository.
  • flatDir: Dependency under the libs directory of the project. For more information about a flatDir repository, see Flat directory repository.
  • Maven: The example contains the Maven repositories of Ant Financial (mvn.cloud.alipay.com) and Alibaba Cloud (maven.aliyun.com). For more information about amaven repository, see Custom Maven repositories.

You can add dependency repositories under repositories. For more information, see Repository Types.

Configure a release repository

Gradle provides the function of configuring release repositories. This topic introduces common examples of release repositories to help you modify the path of the local Maven repository ( ~/.m2 by default) and add a custom release repository.

Release repository example

Generally, the build.gradle file contains the following configuration:

  1. uploadArchives {
  2. repositories {
  3. mavenLocal()
  4. }
  5. }

This means that the release repository is Local Maven repository. That is, the .jar package created by the project is automatically released to the local Maven repository.

Modify the local Maven repository path

Local Maven repository (mavenLocal). The default path is~/.m2. You can modify the path. For more information, see Local Maven repository.

Customize a release repository

You can add a custom release repository as required. The following shows an example.

  1. uploadArchives {
  2. mavenDeployer {
  3. mavenLocal()
  4. repository(url: "your_repository_url") {
  5. authentication(userName: '*****', password: '*****')
  6. }
  7. snapshotRepository(url: "your_repository_url") {
  8. authentication(userName: '*****', password: '*****')
  9. }
  10. }
  11. }