Grails BuildConfig.groovy,构建、编译和运行时之间的区别?

发布于 2024-12-25 01:58:11 字数 454 浏览 5 评论 0原文

BuildConfig.groovy 中的 buildruntimecompile 之间有什么区别 (1.3.7)

grails.project.dependency.resolution = {

    plugins {
        build "acme:acme-cache:latest.integration"
    }

    dependencies {
        build "com.foo.bar:foobar:1.0.5"       
        runtime "org.apache.httpcomponents:httpclient:4.0.3"
        compile("com.thoughtworks.xstream:xstream:1.3.1")
    }
}

What's the difference between build, runtime, and compile, in BuildConfig.groovy (1.3.7)

grails.project.dependency.resolution = {

    plugins {
        build "acme:acme-cache:latest.integration"
    }

    dependencies {
        build "com.foo.bar:foobar:1.0.5"       
        runtime "org.apache.httpcomponents:httpclient:4.0.3"
        compile("com.thoughtworks.xstream:xstream:1.3.1")
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一影成城 2025-01-01 01:58:11
  • build - 仅构建过程需要的依赖项
  • runtime - 运行应用程序所需的依赖项,但不编译它,例如特定数据库供应商的 JDBC 实现。这在编译时通常不需要,因为代码仅依赖于 JDBC API,而不是
  • 其编译时和运行时都需要的特定实现。这是最常见的情况

还有其他一些依赖范围:

  • test - 仅测试需要的依赖项,例如模拟/测试库
  • provided - 依赖项在编译时需要,但不应与应用程序一起打包(通常因为它是由容器提供的)。 Servlet API 就是一个例子
  • build - dependency that is only needed by the build process
  • runtime - dependency that is needed to run the application, but not compile it e.g. JDBC implementation for specific database vendor. This would not typically be needed at compile-time because code depends only the JDBC API, rather than a specific implementation thereof
  • compile - dependency that is needed at both compile-time and runtime. This is the most common case

There are a couple of other dependency scopes:

  • test - dependency that is only needed by the tests, e.g. a mocking/testing library
  • provided - dependency that is needed at compile-time but should not be packaged with the app (usually because it is provided by the container). An example is the Servlet API
迷雾森÷林ヴ 2025-01-01 01:58:11

似乎之前的两个答案在编译和构建之间的区别上存在冲突。我认为 build 的范围包括 grailscompilegrailsrun-app,而compile只是前者。

It seems the 2 previous answers conflict on the distinction between compile and build. I believe that build is the scope that includes grails compile and grails run-app, while compile is just the former.

早乙女 2025-01-01 01:58:11

从 Grails 3 开始,依赖项由 Gradle 管理。 grails-app/conf/BuildConfig.groovy 文件 已被项目根目录中的 build.gradle 文件替换

Grails 用户指南解释如何使用 gradle 设置 grails 依赖。另请参阅相关 Gradle 文档,了解有关使用 Gradle 管理依赖项的更多详细信息。

Starting from Grails 3, dependencies are managed by Gradle. The grails-app/conf/BuildConfig.groovy file has been replaced by the build.gradle file in the project's root.

The Grails user guide explain how to set grails depencies with gradle. See also the related Gradle documentation for further details on managing dependencies using it.

何以心动 2025-01-01 01:58:11

几个 grails 命令有助于说明其中的差异。考虑 grails run-appgrailscompile。 grailscompile 是编译步骤,将包含编译时依赖项。 grails run-app 是运行步骤,将包含运行时依赖项。构建依赖项是运行任何这些命令可能需要的任何内容,例如,挂钩某些构建事件的自定义脚本。

因此,当您需要确定包含依赖项时,您会选择最适合的一个。

A couple grails commands help illustrate the difference. Consider grails run-app and grails compile. grails compile is the compile step and will include compile-time dependencies. grails run-app is the run step and will include runtime dependencies. Build dependencies are anything that you might need to run any of these commands, for example, a custom script that hooks into some build events.

So you would pick the one that best fits when you need to be certain the dependency is included.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文