Gradle之build文件基本配置说明

Gradle管理的工程里,build.gradle文件对项目起着非常重要的作业,本人用scala写了一个demo工程,大致结构如下:

在这里插入图片描述

看一下我的build.gradle 文件

// 项目归属和版本号
group 'com.tencent.pcg'
version '1.0-SNAPSHOT'

// buildscript中的声明是gradle脚本自身需要使用的资源。
// 可以声明的资源包括依赖项、第三方插件、maven仓库地址等
buildscript {
    repositories {
        maven { url 'http://maven.oa.com/nexus/content/repositories/central'}
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.4.RELEASE")
    }
}

// 使用 java 插件
apply plugin: 'java'
// 使用 springboot 框架
apply plugin: 'org.springframework.boot'
// 使用 Scala 插件
apply plugin: 'scala'

// 打的 jar 包的名称和版本信息
jar {
    baseName = 'data-qulity-guard'
    version = '0.0.1'
}

// demo main程序入口
task run(type: JavaExec, dependsOn: classes) {
    main = 'com.tencent.pcg.ReadApiDemo'
    classpath = sourceSets.main.runtimeClasspath
}

sourceCompatibility = 1.8

// 指定本地仓库 / 远程仓库
repositories {
    mavenCentral()
    // 使用公司内部的远程仓库
    maven { url 'http://maven.oa.com/nexus/content/repositories/central'}
    maven { url 'http://maven.oa.com/nexus/content/repositories/mqq/'}
    maven { url 'http://maven.oa.com/nexus/content/groups/public/'}
}

// 依赖配置,引入依赖的 kafka,scala
dependencies {
    compile("org.springframework.boot:spring-boot-starter-web:1.5.4.RELEASE")
    compile("org.springframework.boot:spring-boot-starter:1.5.4.RELEASE")
    compile("org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2")
    compile("mysql:mysql-connector-java:5.1.21")
    compile("org.scala-lang:scala-library:2.11.4")
    testCompile("org.springframework.boot:spring-boot-starter-test")
    compile("org.apache.kafka:kafka_2.11:0.8.2.1")
    compile("qq-central:msg_fetch_api_3.0:1.0.0-SNAPSHOT"){
        exclude group: 'org.apache.kafka', module: 'kafka_2.10'
    }
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

写好 build 文件后刷新拉取最新配置

在这里插入图片描述

更新完成后本地测试没问题,即可直接点击 assemble 打 jar包
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值