zoukankan      html  css  js  c++  java
  • Gradle build.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
    }
  • 相关阅读:
    【转】一句话设计模式
    【转】Bad Smell(代码的坏味道)
    【转】[重构]Primitive Obsession
    【转】22种代码的坏味道,一句话概括
    【转】C#中的implicit 和 explicit
    【转】100本最棒的英文侦探小说
    [转]Visual Studio调试之符号文件
    【转】简要分析unity3d中剪不断理还乱的yield
    apache https配置步骤
    apache https配置步骤
  • 原文地址:https://www.cnblogs.com/duchaoqun/p/13130435.html
Copyright © 2011-2022 走看看