group '组织名'
version '版本号'

/* 支持的插件 */
apply plugin: 'java' // 项目基础变成语言支持为java
apply plugin: 'war' // 可将项目打包成war形式运行
apply plugin: 'eclipse' // 支持ECLIPSE的导入和编辑
apply plugin: 'eclipse-wtp' // 支持ECLIPSE-WEB的导入和编辑
apply plugin: 'idea' // 支持IntelliJ IDEA直接导入和编辑
apply plugin: 'jetty' // 使用jetty作为服务器,也可自行替换为tomcat作为服务器 sourceCompatibility = 1.6 // jdk版本
targetCompatibility = 1.6
compileJava.options.encoding = 'UTF-8' // 使gradle支持中文字符,如果没有这段配置,代码中的中文字符将会出现无法编译性错误
compileTestJava.options.encoding = 'UTF-8'
sourceSets.main.output.classesDir = file("bin") // 为了配合eclipse而定义的文件结构 

repositories { 
  maven {
    url "http://maven.aliyun.com/nexus/content/groups/public/" // 这个仓库好,下载jar包的速度超级快
  }
  mavenLocal() // maven本地仓库
  mavenCentral() // maven远程仓库
  flatDir name: 'localRepository', dirs: 'lib'
} // 综合版本控制
project.ext {
springVersion = '4.3.2.RELEASE' /* 框架版本控制 */
aspectjVersion = '1.8.9'
jacksonVersion = '2.8.4'
} dependencies {
providedCompile ( // 为了eclipse能正常编译
'javax.servlet:servlet-api:3.0-alpha-1',
'tomcat:servlet:4.1.36',
'javax.servlet:jstl:1.1.2',
'taglibs:standard:1.1.2' /* JSP的扩展标记库 */
)
compile (
'com.google.guava:guava:20.0',
'org.springframework:spring-web:' + springVersion,
'org.springframework:spring-webmvc:' + springVersion,
'org.springframework:spring-aop:' + springVersion
runtime (
'org.slf4j:slf4j-log4j12:1.7.5',
'log4j:log4j:1.2.17'
)
testCompile (
'junit:junit:4.4',
'org.springframework:spring-test:' + springVersion
)
} jettyRunWar.contextPath = '' /* jettyRun 的配置 */
jettyRun {
httpPort = 8080 // 服务端口,可自定义
reload = "automatic" // 当代码重新编译时,系统会自动重载
scanIntervalSeconds = 1
contextPath = '项目名或者为空,即ROOT'
} task wrapper(type: Wrapper) {
gradleVersion = '2.14.1' // gradle的版本选择,可自定义版本
}

注释:我认为,针对与java开发,红色部分的配置为必须的。

再来一个新版本的,跟之前的版本类似,部分小地方有改动。

 group 'com.cloud13th'
version '1.0' apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'jetty'
apply plugin: 'pmd'
apply plugin: 'findbugs' /* 代码检查工具 */ sourceCompatibility = 1.8 /* JDK版本和编译版本 */
targetCompatibility = 1.8 /* 支持中文字符 */
[compileJava, compileTestJava, javadoc]*.options*.encoding = "UTF-8" sourceSets.main.output.classesDir = file("bin") repositories {
maven {
url "http://maven.aliyun.com/nexus/content/groups/public/"
}
mavenLocal()
mavenCentral()
flatDir name: 'localRepository', dirs: 'lib'
} project.ext {
springVersion = '4.3.4.RELEASE'
aspectjVersion = '1.8.9'
jacksonVersion = '2.8.4'
} dependencies {
providedCompile(
'javax.servlet:servlet-api:3.0-alpha-1',
'javax.servlet:jstl:1.1.2',
'taglibs:standard:1.1.2'
)
compile(
fileTree(dir: 'lib', include: ['*.jar']), /* 包含lib文件夹下的所有jar文件 */
'com.google.guava:guava:20.0', 'org.springframework:spring-core:' + springVersion,
'org.springframework:spring-web:' + springVersion,
'org.springframework:spring-webmvc:' + springVersion,
'org.springframework:spring-aop:' + springVersion, 'org.aspectj:aspectjrt:' + aspectjVersion,
'org.aspectj:aspectjweaver:' + aspectjVersion,
'org.aspectj:aspectjtools:' + aspectjVersion,
/* 日志 */
'org.slf4j:slf4j-api:1.7.23',
'org.slf4j:slf4j-log4j12:1.7.23',
'log4j:log4j:1.2.17',
'commons-logging:commons-logging:1.2',
/* 连接池 */
'com.alibaba:druid:1.0.27',
/* json */
'org.codehaus.jackson:jackson-mapper-asl:1.9.13',
'org.codehaus.jackson:jackson-core-asl:1.9.13',
'com.fasterxml.jackson.core:jackson-core:' + jacksonVersion,
'com.fasterxml.jackson.core:jackson-databind:' + jacksonVersion,
'com.fasterxml.jackson.core:jackson-annotations:' + jacksonVersion, 'org.apache.poi:poi:3.15',
'org.apache.poi:poi-ooxml:3.15',
'com.github.virtuald:curvesapi:1.04',
'commons-codec:commons-codec:1.10',
'org.apache.poi:poi-ooxml-schemas:3.15',
'org.apache.commons:commons-collections4:4.1',
'commons-io:commons-io:2.2',
'commons-fileupload:commons-fileupload:1.3.2', 'com.belerweb:pinyin4j:2.5.1'
)
testCompile(
'junit:junit:4.12',
'org.hamcrest:hamcrest-core:1.3', /* 一个测试用的工具 */
'org.springframework:spring-test:' + springVersion
)
} /* jettyRun 的配置 */
jettyRun {
httpPort = 8080
reload = "automatic"
scanIntervalSeconds = 1
contextPath = 'dataImport'
} test {
ignoreFailures = true
} pmd {
ignoreFailures = true
} findbugs {
sourceSets = [sourceSets.main]
ignoreFailures = true
reportsDir = file("$project.buildDir/findbugsReports")
effort = "default"
reportLevel = "medium"
} task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
}

无关的讯息自动忽略掉吧,只取需要的就行。

gradle基础的build文件模板_jetty的更多相关文章

  1. gradle基础的build文件模板_tomcat

    group '组织名' version '版本号' /* 支持的插件 */ apply plugin: 'java' // 项目基础变成语言支持为java apply plugin: 'war' // ...

  2. Gradle基础

    什么是Gradle? Gradle是一种依赖管理工具,基于Groovy语言,面向Java应用为主,它抛弃了基于XML的各种繁琐配置,取而代之的是一种基于Groovy的内部领域特定(DSL)语言. Gr ...

  3. Android studio:Groovy 与 Gradle 基础【三】

    转载:http://www.apkbus.com/forum.php?mod=viewthread&tid=255064&extra=page%3D2%26filter%3Dautho ...

  4. Android Studio系列教程四--Gradle基础

    Android Studio系列教程四--Gradle基础 2014 年 12 月 18 日 DevTools 本文为个人原创,欢迎转载,但请务必在明显位置注明出处!http://stormzhang ...

  5. 【转】Android Studio安装配置学习教程指南 Gradle基础--不错

    原文网址:http://www.linuxidc.com/Linux/2015-02/113890p4.htm 其实很早之前也写了一篇Gradle的基础博客,但是时间很久了,现在Gradle已经更新了 ...

  6. android studio学习----gradle基础

    Gradle是一种依赖管理工具,基于Groovy语言,面向Java应用为主,它抛弃了基于XML的各种繁琐配置,取而代之的是一种基于Groovy的内部领域特定(DSL)语言. 安装Gradle 在And ...

  7. Gradle系列之Android Gradle基础配置

    原文发于微信公众号 jzman-blog,欢迎关注交流. 通过前面几篇文章学习了 Gradle 基础知识以及 Gradle 插件相关的知识,关于 Gradle 及其插件相关知识请先阅读下面几篇文章: ...

  8. 基于androidstudio3.0的build文件配置问题

    最近,在研究APP自动化相关的东西,在搭建环境的时候,遇到的坑以及最后解决的方法,不过目前很多东西了解得还不是很细,暂时先简单的记录一下一.build配置文件 主要分为两种: 1.工程下的build配 ...

  9. Maven 项目依赖 pom 文件模板

    下面是网上down的 pom 文件模板: <!-- 属性 --> <properties> <spring.version>4.2.4.RELEASE</sp ...

随机推荐

  1. SQL 学习笔记

    1.判断数据库中某个值是否为null(而不是'null',空字符串'',若干个空格' ') 一定不能用=null 或 !=null,而要用is null 或 is not null. 2.在sqlse ...

  2. 不错的判断 UITextView 内容不超过20个字符串的方法

    - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSSt ...

  3. 纪念逝去的岁月——C++实现一个队列(使用类模板)

    1.代码 2.运行结果 1.代码 #include <stdio.h> #include <string.h> template <typename T> clas ...

  4. Equal Sum Sets

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=49406 题意: 输入n,k,s,求在不小于n的数中找出k个不同的数 ...

  5. [LintCode] Maximal Rectangle 最大矩形

    Given a 2D boolean matrix filled with False and True, find the largest rectangle containing all True ...

  6. mysql体系结构

    mysql逻辑架构: 第一层,即最上一层,所包含的服务并不是MySQL所独有的技术.它们都是服务于C/S程序或者是这些程序所需要的:连接处理,身份验证,安全性等等. 第二层值得关注.这是MySQL的核 ...

  7. ZK 长时操作带进度条

    LongProcess.zul: <?xml version="1.0" encoding="UTF-8"?> <window id=&quo ...

  8. hdu N皇后问题

    此题是很基本的dfs的题目 ,但是要打表,否则会超时. 这题的思路就是从第一行一直放到第n行,因此行方面的判断就可以省略了.因此只要判断列方面和斜线方面是否满足条件,列方面用一个vis数组来记录是否已 ...

  9. Learn ZYNQ Programming(1)

    GPIO LED AND KEY: part1:gpio leds and gpio btns combination. (include 1~4) part2:use gpio btns inter ...

  10. SubmitText 中配置lua 运行环境

    一 新建编译系统 二.使用新建的编译系统 三配置 { "cmd": ["lua", "$file"], "file_regex&q ...