Grails BuildConfig.groovy,构建、编译和运行时的区别? [英] Grails BuildConfig.groovy, difference between build, compile, and runtime?

查看:23
本文介绍了Grails BuildConfig.groovy,构建、编译和运行时的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

BuildConfig.groovy (1.3.7) 中 buildruntimecompile 的区别是什么?)

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")
    }
}

推荐答案

  • build - 只有构建过程需要的依赖项
  • runtime - 运行应用程序所需的依赖项,但不编译它,例如特定数据库供应商的 JDBC 实现.这在编译时通常不需要,因为代码仅依赖于 JDBC API,而不是其特定实现
  • compile - 编译时和运行时都需要的依赖项.这是最常见的情况
    • 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 - 仅测试需要的依赖项,例如一个模拟/测试库
      • provided - 编译时需要但不应与应用程序打包的依赖项(通常是因为它由容器提供).一个例子是 Servlet API
      • 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

      这篇关于Grails BuildConfig.groovy,构建、编译和运行时的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆