gpt4 book ai didi

coding-style - Gradle build.gradle 代码风格

转载 作者:行者123 更新时间:2023-12-04 04:22:27 30 4
gpt4 key购买 nike

Gradle有代码风格吗build.gradle文件?

当然,对于 groovy 片段,Groovy 规则可以适用,
但是对于 Gradle DSL 有什么约定吗?

putting plugin configuration right after apply

apply plugin: 'application'
mainClassName = "com.example.MainClass"

对于 Maven,我通常使用 POM Reference , 但把 <!-- Build Settings -->作为最后一节。

作为build.gradle对于某些项目来说可能会增长很长时间,如果有标准的引用结构会很好。

最佳答案

As build.gradle can grow quite long for some project, it would be nice to have standard structure for references.

除了遵循 Opal (*) 建议的一致顺序之外,将大型构建脚本拆分为多个较小的脚本也是一种很好的做法。例如,您可以拥有 gradle/dependencies.gradlegradle/publishing.gradlegradle/integrationTest.gradle 等,所有这些使用 apply from: 包含到 build.gradle 中。在多项目构建中,为每个子项目使用单独的构建脚本。

(*) 我的一般准则是按照抽象级别对声明进行排序,最抽象的声明排在第一位,任务声明排在最后。

关于coding-style - Gradle build.gradle 代码风格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24380463/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com