Android使用Gradle编译命令大全

1、gradle -help

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]
--console               Specifies which type of console output to generate. Valu
es are 'plain', 'auto' (default) or 'rich'.
--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 Daem
on 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.
--include-build         Includes the specified build in the composite. [incubati
ng]
-m, --dry-run           Runs the builds with all task actions disabled.
--max-workers           Configure the number of concurrent workers Gradle is all
owed to use. [incubating]
--no-daemon             Do not use the Gradle Daemon to run the build.
--offline               The build should operate without accessing network resou
rces.
-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 cu
rrent directory.
--parallel              Build projects in parallel. Gradle will attempt to deter
mine the optimal number of executor threads to use. [incubating]
--profile               Profiles build execution time and generates a report in
the <build_dir>/reports/profile directory.
--project-cache-dir     Specifies the project-specific cache directory. Defaults
 to .gradle in the root project directory.
-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 exc
eptions.
-s, --stacktrace        Print out the stacktrace for all exceptions.
--status                Shows status of running and recently stopped Gradle Daem
on(s).
--stop                  Stops the Gradle Daemon if it is running.
-t, --continuous        Enables continuous build. Gradle does not exit and will
re-execute tasks when task file inputs change. [incubating]
-u, --no-search-upward  Don't search in parent folders for a settings.gradle fil
e.
-v, --version           Print version info.
-x, --exclude-task      Specify a task to be excluded from execution.


2、gradle tasks

The TaskInputs.source(Object) method has been deprecated and is scheduled to be

removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instea
d.
Incremental java compilation is an incubating feature.
:tasks


------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------


Android tasks
-------------
androidDependencies - Displays the Android dependencies of the project.
signingReport - Displays the signing info for each variant.
sourceSets - Prints out all the source sets defined in this project.


Build tasks
-----------
assemble - Assembles all variants of all applications and secondary packages.
assembleAndroidTest - Assembles all the Test applications.
assembleDebug - Assembles all Debug builds.
assembleRelease - Assembles all Release builds.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend
on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
clean - Deletes the build directory.
compileDebugAndroidTestSources
compileDebugSources
compileDebugUnitTestSources
compileReleaseSources
compileReleaseUnitTestSources
mockableAndroidJar - Creates a version of android.jar that's suitable for unit t
ests.


Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]


Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root projec
t 'LaohuSDKTest'.
components - Displays the components produced by root project 'LaohuSDKTest'. [i
ncubating]
dependencies - Displays all dependencies declared in root project 'LaohuSDKTest'
.
dependencyInsight - Displays the insight into a specific dependency in root proj
ect 'LaohuSDKTest'.
help - Displays a help message.
model - Displays the configuration model of root project 'LaohuSDKTest'. [incuba
ting]
projects - Displays the sub-projects of root project 'LaohuSDKTest'.
properties - Displays the properties of root project 'LaohuSDKTest'.
tasks - Displays the tasks runnable from root project 'LaohuSDKTest' (some of th
e displayed tasks may belong to subprojects).


Install tasks
-------------
installDebug - Installs the Debug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug b
uild.
uninstallAll - Uninstall all applications.
uninstallDebug - Uninstalls the Debug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Deb
ug build.
uninstallRelease - Uninstalls the Release build.


Verification tasks
------------------
check - Runs all checks.
connectedAndroidTest - Installs and runs instrumentation tests for all flavors o
n connected devices.
connectedCheck - Runs all device checks on currently connected devices.
connectedDebugAndroidTest - Installs and runs the tests for debug on connected d
evices.
deviceAndroidTest - Installs and runs instrumentation tests using all Device Pro
viders.
deviceCheck - Runs all device checks using Device Providers and Test Servers.
lint - Runs lint on all variants.
lintDebug - Runs lint on the Debug build.
lintRelease - Runs lint on the Release build.
test - Run unit tests for all variants.
testDebugUnitTest - Run unit tests for the debug build.
testReleaseUnitTest - Run unit tests for the release build.


Other tasks
-----------
assembleDefault
clean
extractProguardFiles
jarDebugClasses
jarReleaseClasses
transformResourcesWithMergeJavaResForDebugUnitTest
transformResourcesWithMergeJavaResForReleaseUnitTest


To see all tasks and more detail, run gradle tasks --all


To see more detail about a task, run gradle help --task <task>


BUILD SUCCESSFUL


Total time: 2.194 secs



e.g. 我需要gradle编译出的androidTest的apk,但是使用gradle build编译的apk中不包含这个,于是使用gradle assembleAndroidTest进行编译,成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值