Skip to main content

Gradle and Maven Configuration

Configure Maven​

  1. Configure local repository path

<localRepository>d:/mvnrepository</localRepository>

  1. Configure remote repository address
<mirror>  
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
  1. Configure JDK to 1.8
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>

Configure Gradle​

  1. In the init.d file under GRADLE_HOME, create a init.gradle configuration file:
allprojects {
repositories {
maven { url 'file:///D:/mvnrepository'}
mavenLocal()
maven { name "Alibaba" ; url "https://maven.aliyun.com/repository/public" }
maven { name "Bstek" ; url "http://nexus.bsdn.org/content/groups/public/" }
mavenCentral()
}

buildscript {
repositories {
maven { name "Alibaba" ; url 'https://maven.aliyun.com/repository/public' }
maven { name "Bstek" ; url 'http://nexus.bsdn.org/content/groups/public/' }
maven { name "M2" ; url 'https://plugins.gradle.org/m2/' }
}
}
}
  1. Gradle Enable Daemon Original Article Create a C:\Users\user\.gradle\gradle.properties file in user directory, file content:

    org.gradle.daemon=true

(if not exist "%USERPROFILE%/.gradle" mkdir "%USERPROFILE%/.gradle") && (echo org.gradle.daemon=true >> "%USERPROFILE%/.gradle/gradle.properties")  
  1. IDEA configure Gradle local repository address

image-20211212154508471

Handle Gradle Issues when Importing Source Code​

When I imported branch 2.5.x version code, using Gradle 5.6.4 caused issues. The reason is that old version of gradle lacks some features, e.g., OperationCompletionListener, error as follows:

Use wrapper gradle. That is execute ./gradlew in project root path, but it still reports failed: timeout

Then you need to change command to specify longer timeout, command as follows: ./gradlew -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.http.connectionTimeout=60000 --daemon Command from

Of course you can configure via IDE, this will also automatically use wrapper for build

Agreement
The code part of this work is licensed under Apache License 2.0 . You may freely modify and redistribute the code, and use it for commercial purposes, provided that you comply with the license. However, you are required to:
  • Attribution: Retain the original author's signature and code source information in the original and derivative code.
  • Preserve License: Retain the Apache 2.0 license file in the original and derivative code.
The documentation part of this work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License . You may freely share, including copying and distributing this work in any medium or format, and freely adapt, remix, transform, and build upon the material. However, you are required to:
  • Attribution: Give appropriate credit, provide a link to the license, and indicate if changes were made.
  • NonCommercial: You may not use the material for commercial purposes. For commercial use, please contact the author.
  • ShareAlike: If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.