本文只是作为自己平时学习和工作记录
http://groovy-lang.org/gdk.html
1. 如何同步Intellij和Gradle项目,解决加入新的build.gradle后,但是intellij探测的问题。
方法:
1)打开Gradle Tool Window,View | Tool Windows | Gradle
2) 单击Refresh all Gradle projects
2. The configuration is applied in following order (if an option is configured in multiple locations the last one wins):
- from
gradle.properties
in project build dir. - from
gradle.properties
ingradle user home
. - from system properties, e.g. when
-Dsome.property
is set on the command line. -Psome.property is for project.
3. Everything in Gradle sits on top of two basic concepts: projects and tasks.
Every Gradle build is made up of one or more projects.
Each project is made up of one or more tasks.
******************************************************************
* Useful Commands
*******************************************************************
#初始化 - 创建build.gradle和wrap文件
gradle init
gradle init --type java-library
#编译指定项目
gradle -b <build_file_path> <task>
gradle -p <subdir> <task>
#查询所有项目
gradle -q projects
#查询项目依赖
gradle -q dependencies
#查看编译性能详细报表
gradle --profile <tasks>
#查询Gradle配置属性
gadle -q properties
#daemon操作
#It is recommended that the Daemon is used in all developer environments. It is recommend to disable the Daemon for Continuous Integration and build server environments.
gradle --daemon
gradle --foreground
gradle --status
gradle --stop
#exclude module dependencies
If you want to exclude module dependencies, there is a -a
, or --no-rebuild
option to skip other subprojects/modules.
If you want to skip the compilation, or resources tasks, you can use the -x
option.
Failing a build on version conflict
To make gradle fail the build on encountering a conflict, we can do the following:
configurations.all {
resolutionStrategy {
failOnVersionConflict()
}
}
Forcing a certain version
To force a certain version number for all dependencies:
configurations.compile {
resolutionStrategy {
force 'groupId:artifactId:desiredVersion'
}
}