gradle命令参数

第一次在这里写博客,请大家勿笑。

gradle终于推出了新版本2.0了,对于JAVA环境支持到JAVA8了。相对于MAVEN而言用起来的确爽,因为配置文件写起来非常简洁直观,不像maven的xml非常臃肿,但是我这里只是讲解下gradle常用的命令行参数,不讲他的配置,因为相关的配置网上一大把的,如父项目、子项目的依赖,多模块的环境配置等等都在网上能找到,而唯独命令行参数网上没有,所以我就在这里列出gradle常用的非常重要的命令行参数,以供大家了解

1、gradle -v这个参数显示gradle的版本信息,如:

C:\Users\Administrator>gradle -v

------------------------------------------------------------
Gradle 2.0
------------------------------------------------------------

Build time:   2014-07-01 07:45:34 UTC
Build number: none
Revision:     b6ead6fa452dfdadec484059191eb641d817226c

Groovy:       2.3.3
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_05 (Oracle Corporation 25.5-b02)
OS:           Windows Server 2008 R2 6.1 amd64

2、gradle -h这是帮助命令,可以查看支持那些参数,如:

C:\Users\Administrator>gradle -h

USAGE: gradle [option...] [task...]

-?, -h, --help          Shows this help message.
-a, --no-rebuild        Do not rebuild project dependencies.
-b, --build-file        Specifies the build file.
-c, --settings-file     Specifies the settings file.
--configure-on-demand   Only relevant projects are configured in this build run. This means faster build for large multi
-project builds. [incubating]
--continue              Continues task execution after a task failure.
-D, --system-prop       Set system property of the JVM (e.g. -Dmyprop=myvalue).
-d, --debug             Log in debug mode (includes normal stacktrace).
--daemon                Uses the Gradle daemon to run the build. Starts the daemon if not running.
--foreground            Starts the Gradle daemon in the foreground. [incubating]
-g, --gradle-user-home  Specifies the gradle user home directory.
--gui                   Launches the Gradle GUI.
-I, --init-script       Specifies an initialization script.
-i, --info              Set log level to info.
-m, --dry-run           Runs the builds with all task actions disabled.
--no-color              Do not use color in the console output.
--no-daemon             Do not use the Gradle daemon to run the build.
--offline               The build should operate without accessing network resources.
-P, --project-prop      Set project property for the build script (e.g. -Pmyprop=myvalue).
-p, --project-dir       Specifies the start directory for Gradle. Defaults to current directory.
--parallel              Build projects in parallel. Gradle will attempt to determine the optimal number of executor thre
ads to use. [incubating]
--parallel-threads      Build projects in parallel, using the specified number of executor threads. [incubating]
--profile               Profiles build execution time and generates a report in the <build_dir>/reports/profile director
y.
--project-cache-dir     Specifies the project-specific cache directory. Defaults to .gradle in the root project director
y.
-q, --quiet             Log errors only.
--recompile-scripts     Force build script recompiling.
--refresh-dependencies  Refresh the state of dependencies.
--rerun-tasks           Ignore previously cached task results.
-S, --full-stacktrace   Print out the full (very verbose) stacktrace for all exceptions.
-s, --stacktrace        Print out the stacktrace for all exceptions.
--stop                  Stops the Gradle daemon if it is running.
-u, --no-search-upward  Don't search in parent folders for a settings.gradle file.
-v, --version           Print version info.
-x, --exclude-task      Specify a task to be excluded from execution.

3、gradle -g 指定本地缓存路径,这个命令非常有用,指定gradle下载的缓存路径,例如依赖文件、插件等,而gradle默认存储在用户的主目录下面,一旦更换一个用户后,就要再次下载很浪费时间,直接指定到其他所有用户共有的目录就方便多了,如:

C:\Users\Administrator>gradle -g e:\testdownloand
:help

Welcome to Gradle 2.0.

To run a build, run gradle <task> ...

To see a list of available tasks, run gradle tasks

To see a list of command-line options, run gradle --help

BUILD SUCCESSFUL

Total time: 3.63 secs


4、gradle -s输出详细的信息,排错时需要查看详细,加上这个参数即可。

5、gradle idea生成intellij的项目,可以加上-g参数同时用。

6、gradle eclipse生成eclipse的项目,可以加上-g参数同时用。



  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值