Gradle

官方文档
支持java版本对照
使用指引
例子
故障
多项目 includeBuild
多模块
gradle.properties for Build Environment

Build Environment

Command-line flags such as –build-cache. These have precedence优先 over properties and environment variables
System properties such as systemProp.http.proxyHost=somehost.org stored in a gradle.properties file in a root project directory.
Gradle properties such as org.gradle.caching=true that are typically stored in a gradle.properties file in a project directory or in the GRADLE_USER_HOME.
Environment variables such as GRADLE_OPTS sourced by the environment that executes Gradle.

command

upgrade

1
2
3
4
5
6
7
8
#  扫描并查看弃用视图 view the deprecations view of the generated build scan
gradle help --scan
# 或者查看全部警告,来确认是否有弃用内容
gradle help --warning-mode=all
# 手动清除不再支持的 plugins
# to update the project to 7.4.2.
gradle wrapper --gradle-version 7.4.2
# try to run the project

gradle.properties

org.gradle.caching=(true,false)

When set to true, Gradle will reuse重复使用 task outputs from any previous build, when possible, resulting in much faster builds.
Learn more about using the build cache.
By default, the build cache is not enabled.

org.gradle.caching.debug=(true,false)

When set to true, individual单独的 input property hashes and the build cache key for each task are logged on the console.
Learn more about task output caching.
Default is false

org.gradle.configureondemand=(true,false)

Enables incubating孵化 configuration on demand需要, where Gradle will attempt to configure only necessary projects.
Default is false.

org.gradle.console=(auto,plain,rich,verbose)

Customize定制 console output coloring or verbosity赘述.
Default depends on how Gradle is invoked调用. See command-line logging for additional details.

org.gradle.continuous.quietperiod=(# of quiet period millis)

When using continuous连续的 build, Gradle will wait for the quiet period时段 to pass before triggering触发 another build.
Any additional额外的 changes within this quiet period restart waiting for the quiet period.
Default is 250 milliseconds.

org.gradle.daemon=(true,false)

When set to true the Gradle Daemon is used to run the build.
Default is true, builds will be run using the daemon.

org.gradle.daemon.idletimeout=(# of idle millis)

Gradle Daemon will terminate(使)停止 itself after specified指定 number of idle空闲 milliseconds.
Default is 10800000 (3 hours).

org.gradle.debug=(true,false)

When set to true, Gradle will run the build with remote debugging enabled, listening on port 5005.
Note that this is the equivalent相同的 of adding -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 to the JVM command line and will suspend挂起 the virtual machine until a debugger is attached所附的.
Default is false.

org.gradle.debug.host=(host address)

Specifies指定 the host address to listen on or connect to when debug is enabled.
In the server mode on Java 9 and above, passing * for the host will make the server listen on all network interfaces.
By default, no host address is passed to JDWP, so on Java 9 and above, the loopback address is used, while earlier versions listen on all interfaces.

org.gradle.debug.port=(port number)

Specifies the port number to listen on when debug is enabled.
Default is 5005.

org.gradle.debug.server=(true,false)

If set to true and debugging is enabled, Gradle will run the build with the socket-attach mode of the debugger.
Otherwise, the socket-listen mode is used.
Default is true.

org.gradle.debug.suspend=(true,false)

When set to true and debugging is enabled, the JVM running Gradle will suspend until a debugger is attached.
Default is true.

org.gradle.java.home=(path to JDK home)

Specifies the Java home for the Gradle build process.
The value can be set to either a jdk or jre location, however, depending on what your build does, using a JDK is safer.
This does not affect the version of Java used to launch the Gradle client VM (see Environment variables).
A reasonable default is derived from your environment (JAVA_HOME or the path to java) if the setting is unspecified.

org.gradle.jvmargs=(JVM arguments)

Specifies the JVM arguments used for the Gradle Daemon.
The setting is particularly尤其;特别 useful for configuring JVM memory settings for build performance性能.
This does not affect the JVM settings for the Gradle client VM.
The default is -Xmx512m -XX:MaxMetaspaceSize=384m.

org.gradle.logging.level=(quiet,warn,lifecycle,info,debug)

When set to quiet, warn, lifecycle, info, or debug, Gradle will use this log level.
The values are not case sensitive这些值不区分大小写. See Choosing a log level.
The lifecycle level is the default.

org.gradle.logging.stacktrace=(internal,all,full)

Specifies whether stacktraces堆栈磁道 should be displayed as part of the build result upon在…之上 an exception. See also the –stacktrace command-line option.
When set to internal, a stacktrace is present出现 in the output only in case of internal exceptions.
When set to all or full, a stacktrace is present出现 in the output for all exceptions and build failures.
Using full doesn’t truncate截断 the stacktrace, which leads to a much more verbose冗长的 output.
Default is internal.

org.gradle.parallel=(true,false)

When configured, Gradle will fork up付出;支付 to org.gradle.workers.max JVMs to execute projects in parallel.
To learn more about parallel task execution, see the section on Gradle build performance.
Default is false.

org.gradle.priority=(low,normal)

Specifies the scheduling priority调度优先级 for the Gradle daemon and all processes launched by it. See also performance command-line options.
Default is normal.

org.gradle.vfs.verbose=(true,false)

Configures verbose冗长的 logging when watching the file system.
Default is false.

org.gradle.vfs.watch=(true,false)

Toggles切换 watching the file system.
When enabled Gradle re-uses再利用 information it collects about the file system between builds.
Enabled by default on operating systems where Gradle supports this feature.

org.gradle.warning.mode=(all,fail,summary,none)

When set to all, summary or none, Gradle will use different warning type display. See Command-line logging options for details.
Default is summary.

org.gradle.welcome=(never,once)

Controls whether Gradle should print a welcome message.
If set to never then the welcome message will be suppressed.
If set to once then the message is printed once for each new version of Gradle.
Default is once.

org.gradle.workers.max=(max # of worker processes)

When configured, Gradle will use a maximum of the given number of workers. See also performance command-line options.
Default is number of CPU processors.

example

1
2
3
org.gradle.caching=true
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true