Modify the location method of Gradle and Maven local repositories

About Maven configuration:

Developers who have used Maven should know that Maven can modify the packages downloaded by maven by configuring the settings.xml file under the conf folder. The default is the .m2 under the user folder of the c drive. Over time, the .m2 will become more and more The larger it is, the more it will naturally affect the response of windows, so generally we will move it to other non-system disks. Specifically, modify the following configuration:

The default is:

 <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
 -->

After modification:

<localRepository>D:/Maven/.m2/repo</localRepository>

This will download the downloaded package to the .m2 under the D drive.

Here is a good maven remote address, that is, the Alibaba Cloud maven address.

Later, I found the savior of domestic maven [Alibaba Cloud maven]. I am really grateful! The specific configuration is as follows, and the settings.xml file under conf is also operated:

Find and replace the original commented <mirrors> with the following:

<mirrors>
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>
  </mirrors>

That's it. Next, let's talk about the configuration of Gradle.

Gradle configuration

There may be many people who are wondering whether this Gradle can manually modify the local warehouse like maven. The answer is of course yes, and it is very simple. You only need to make a configuration in the environment variable as shown below:

That is, add a name named  GRADLE_USER_HOME  and the value is where you want to put the gradle repository.

In addition, it is said that Gradle has a Daemon configuration. Enabling this configuration can effectively improve the compilation speed.

The specific operations are as follows:

Create a gradle.properties file in the .gradle directory of our gradle warehouse, then open the file and add the following statement to save it:

org.gradle.daemon=true  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324520022&siteId=291194637