Gradle学习记录

这篇博客记录了Gradle的学习心得,包括如何同步Intellij与Gradle项目、配置应用顺序、项目与任务的基本概念,以及一系列实用的Gradle命令,如初始化、编译、查询依赖和性能分析等。
摘要由CSDN通过智能技术生成

本文只是作为自己平时学习和工作记录


 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 in gradle 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'
    }
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值