ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Gradle build.gradle

2020-06-15 13:54:43  阅读:425  来源: 互联网

标签:plugin grails Gradle 区域 build apply org gradle


Summary

  • 配置文件的各个部分

buildscript 区域

  • 该区域中有 repositories、dependencies 配置,标识 gradle 脚本自身需要使用的资源。
  • 而在build.gradle文件中直接声明的依赖项、仓库地址等信息是项目自身需要的资源。
buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:hibernate5:${gormVersion - ".RELEASE"}"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.15.1"
    }
}

基本属性

version "0.1"
group "com.next"

plugin 插件

  • 如果想把项目导入到 eclipse 当中,需要使用一个Eclipse插,会生成一些文件。
apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "war"
apply plugin: "org.grails.grails-web"
apply plugin: "asset-pipeline"
apply plugin: "org.grails.grails-gsp"

repositories 区域

  • 不同于 buildscript 区域中的配置,这里配置的是项目内容所需要的仓库地址,告诉Gradle在哪里可以找到这些依赖。
    repositories {
        // 本地仓库
        mavenLocal()
        // 在线仓库
        maven { url "https://repo.grails.org/grails/core" }
    }

dependencies 区域

  • 不同于buildscript 区域中的配置,这里配置的是项目内容所需要的依赖信息
  • 留意版本上的 + 号,它会在编译的时候找到最新的包
dependencies {
    // compile 阶段需要使用的依赖,如下两种写法都可以。
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'

    // runtime 阶段需要使用到的依赖。
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.15.+"
    testCompile "org.grails:grails-web-testing-support"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.+"
    // 第三方jar包的一种添加方式
    compile fileTree(dir: 'libs', include: '*.jar')
}

bootRun 区域

bootRun {
    jvmArgs('-Dspring.output.ansi.enabled=always')
    jvmArgs('-Xmx4096m')
    addResources = true
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

grails 区域?

  • 不知道这是不是 gradle 的标准配置,尚未深入了解。
  • 在 Windows 终端启动 grails 程序的时候,会因为文件或者命令太长导致启动失败,配置上这个就好了。
grails {
    pathingJar = true
}

assets 区域?

assets {
    minifyJs = true
    minifyCss = true
}

标签:plugin,grails,Gradle,区域,build,apply,org,gradle
来源: https://www.cnblogs.com/duchaoqun/p/13130435.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有