当前位置:K88软件开发文章中心编程工具Gradle → 文章内容

Gradle Gradle 命令行的基本使用

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-24 10:31:23

ts - Displays the sub-projects of root project 'projectReports'.properties - Displays the properties of root project 'projectReports'.tasks - Displays the tasks runnable from root project 'projectReports' (some of the displayed tasks may belong to subprojects).To see all tasks and more detail, run with --all.默认情况下,这只会显示那些被分组的任务。你可以通过为任务设置 group 属性和 description 来把 这些信息展示到结果中。更改任务报告内容build.gradledists { description = 'Builds the distribution' group = 'build'}当然你也可以用--all 参数来收集更多任务信息。这会列出项目中所有任务以及任务之间的依赖关系。Obtaining more information about tasksgradle -q tasks --all的输出结果:\> gradle -q tasks --all\------------------------------------------------------------All tasks runnable from root project\------------------------------------------------------------Default tasks: distsBuild tasks\-----------clean - Deletes the build directory (build)api:clean - Deletes the build directory (build)webapp:clean - Deletes the build directory (build)dists - Builds the distribution [api:libs, webapp:libs] docs - Builds the documentationapi:libs - Builds the JAR api:compile - Compiles the source fileswebapp:libs - Builds the JAR [api:libs] webapp:compile - Compiles the source filesBuild Setup tasks\-----------------init - Initializes a new Gradle build. [incubating]wrapper - Generates Gradle wrapper files. [incubating]Help tasks\----------dependencies - Displays all dependencies declared in root project 'projectReports'.dependencyInsight - Displays the insight into a specific dependency in root project 'projectReports'.help - Displays a help messageprojects - Displays the sub-projects of root project 'projectReports'.properties - Displays the properties of root project 'projectReports'.tasks - Displays the tasks runnable from root project 'projectReports' (some of the displayed tasks may belong to subprojects).获取任务帮助信息执行 gradle help --task someTask 可以显示指定任务的详细信息。或者多项目构建中相同任务名称的所有任务的信息。如下例。获取任务帮助gradle -q help --task libs 的输出结果\> gradle -q help --task libsDetailed task information for libsPaths :api:libs :webapp:libsType Task (org.gradle.api.Task)Description Builds the JAR这些结果包含了任务的路径、类型以及描述信息等。获取依赖列表执行 gradle dependencies 会列出项目的依赖列表,所有依赖会根据任务区分,以树型结构展示出来。如下例。获取依赖信息gradle -q dependencies api:dependencies webapp:dependencies 的输出结果\> gradle -q dependencies api:dependencies webapp:dependencies\------------------------------------------------------------Root project\------------------------------------------------------------No configurations\------------------------------------------------------------Project :api - The shared API for the application\------------------------------------------------------------compile\--- org.codehaus.groovy:groovy-all:2.2.0testCompile\--- junit:junit:4.11 \--- org.hamcrest:hamcrest-core:1.3\------------------------------------------------------------Project :webapp - The Web application implementation\------------------------------------------------------------compile+--- project :api| \--- org.codehaus.groovy:groovy-all:2.2.0\--- commons-io:commons-io:1.2testCompileNo dependencies虽然输出结果很多,但这对于了解构建任务十分有用,当然你可以通过--configuration 参数来查看 指定构建任务的依赖情况。过滤依赖信息gradle -q api:dependencies --configuration testCompile 的输出结果\> gradle -q api:dependencies --configuration testCompile\------------------------------------------------------------Project :api - The shared API for the application\------------------------------------------------------------testCompile\--- junit:junit:4.11 \--- org.hamcrest:hamcrest-core:1.3查看特定依赖执行 Running gradle dependencyInsight 可以查看指定的依赖情况。如下例。获取特定依赖gradle -q webapp:dependencyInsight --dependency groovy --configuration compile 的输出结果\> gradle -q webapp:dependencyInsight --dependency groovy --configuration compileorg.codehaus.groovy:groovy-all:2.2.0\--- project :api \--- compile这对于了解依赖关系、了解为何选择此版本作为依赖十分有用。了解更多请参阅依赖检查报告。dependencyInsight 任务是'Help'任务组中的一个。这项任务需要进行配置才可以。如果用了 Java 相关的插件,那么 dependencyInsight 任务已经预先被配置到'Compile'下了。你只需要通过'--dependency'参数来制定所需查看的依赖即可。如果你不想用默认配置的参数项你可以通过 '--configuration' 参数来进行指定。了解更多请参阅依赖检查报告。获取项目属性列表执行 gradle properties 可以获取项目所有属性列表。如下例。属性信息gradle -q api:properties 的输出结果\> gradle -q api:properties\------------------------------------------------------------Project :api - The shared API for the application\------------------------------------------------------------allprojects: [project ':api']ant: org.gradle.api.internal.project.DefaultAntBuilder@12345antBuilderFactory: org.gradle.api.internal.project.DefaultAntBuilderFactory@12345artifacts:

上一页  [1] [2] [3]  下一页


Gradle Gradle 命令行的基本使用