1. group '组织名'
  2. version '版本号'

  3. /* 支持的插件 */
  4. apply plugin: 'java' // 项目基础变成语言支持为java
  5. apply plugin: 'war' // 可将项目打包成war形式运行
  6. apply plugin: 'eclipse' // 支持ECLIPSE的导入和编辑
  7. apply plugin: 'eclipse-wtp' // 支持ECLIPSE-WEB的导入和编辑
  8. apply plugin: 'idea' // 支持IntelliJ IDEA直接导入和编辑
  9. apply plugin: 'jetty' // 使用jetty作为服务器,也可自行替换为tomcat作为服务器
  10.  
  11. sourceCompatibility = 1.6 // jdk版本
  12. targetCompatibility = 1.6
  1. compileJava.options.encoding = 'UTF-8' // 使gradle支持中文字符,如果没有这段配置,代码中的中文字符将会出现无法编译性错误
    compileTestJava.options.encoding = 'UTF-8'
  1. sourceSets.main.output.classesDir = file("bin") // 为了配合eclipse而定义的文件结构
  2.  
  3. repositories {
      maven {
        url "http://maven.aliyun.com/nexus/content/groups/public/" // 这个仓库好,下载jar包的速度超级快
      }
      mavenLocal() // maven本地仓库
      mavenCentral() // maven远程仓库
      flatDir name: 'localRepository', dirs: 'lib'
    }
  4.  
  5. // 综合版本控制
  6. project.ext {
  7. springVersion = '4.3.2.RELEASE' /* 框架版本控制 */
  8. aspectjVersion = '1.8.9'
  9. jacksonVersion = '2.8.4'
  10. }
  11.  
  12. dependencies {
  13. providedCompile ( // 为了eclipse能正常编译
  14. 'javax.servlet:servlet-api:3.0-alpha-1',
  15. 'tomcat:servlet:4.1.36',
  16. 'javax.servlet:jstl:1.1.2',
  17. 'taglibs:standard:1.1.2' /* JSP的扩展标记库 */
  18. )
  19. compile (
  20. 'com.google.guava:guava:20.0',
  21. 'org.springframework:spring-web:' + springVersion,
  22. 'org.springframework:spring-webmvc:' + springVersion,
  23. 'org.springframework:spring-aop:' + springVersion
  24. runtime (
  25. 'org.slf4j:slf4j-log4j12:1.7.5',
  26. 'log4j:log4j:1.2.17'
  27. )
  28. testCompile (
  29. 'junit:junit:4.4',
  30. 'org.springframework:spring-test:' + springVersion
  31. )
  32. }
  33.  
  34. jettyRunWar.contextPath = ''
  35.  
  36. /* jettyRun 的配置 */
  37. jettyRun {
  38. httpPort = 8080 // 服务端口,可自定义
  39. reload = "automatic" // 当代码重新编译时,系统会自动重载
  40. scanIntervalSeconds = 1
  41. contextPath = '项目名或者为空,即ROOT'
  42. }
  43.  
  44. task wrapper(type: Wrapper) {
  45. gradleVersion = '2.14.1' // gradle的版本选择,可自定义版本
  46. }

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

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

  1. group 'com.cloud13th'
  2. version '1.0'
  3.  
  4. apply plugin: 'java'
  5. apply plugin: 'war'
  6. apply plugin: 'eclipse'
  7. apply plugin: 'eclipse-wtp'
  8. apply plugin: 'idea'
  9. apply plugin: 'jetty'
  10. apply plugin: 'pmd'
  11. apply plugin: 'findbugs' /* 代码检查工具 */
  12.  
  13. sourceCompatibility = 1.8 /* JDK版本和编译版本 */
  14. targetCompatibility = 1.8
  15.  
  16. /* 支持中文字符 */
  17. [compileJava, compileTestJava, javadoc]*.options*.encoding = "UTF-8"
  18.  
  19. sourceSets.main.output.classesDir = file("bin")
  20.  
  21. repositories {
  22. maven {
  23. url "http://maven.aliyun.com/nexus/content/groups/public/"
  24. }
  25. mavenLocal()
  26. mavenCentral()
  27. flatDir name: 'localRepository', dirs: 'lib'
  28. }
  29.  
  30. project.ext {
  31. springVersion = '4.3.4.RELEASE'
  32. aspectjVersion = '1.8.9'
  33. jacksonVersion = '2.8.4'
  34. }
  35.  
  36. dependencies {
  37. providedCompile(
  38. 'javax.servlet:servlet-api:3.0-alpha-1',
  39. 'javax.servlet:jstl:1.1.2',
  40. 'taglibs:standard:1.1.2'
  41. )
  42. compile(
  43. fileTree(dir: 'lib', include: ['*.jar']), /* 包含lib文件夹下的所有jar文件 */
  44. 'com.google.guava:guava:20.0',
  45.  
  46. 'org.springframework:spring-core:' + springVersion,
  47. 'org.springframework:spring-web:' + springVersion,
  48. 'org.springframework:spring-webmvc:' + springVersion,
  49. 'org.springframework:spring-aop:' + springVersion,
  50.  
  51. 'org.aspectj:aspectjrt:' + aspectjVersion,
  52. 'org.aspectj:aspectjweaver:' + aspectjVersion,
  53. 'org.aspectj:aspectjtools:' + aspectjVersion,
  54. /* 日志 */
  55. 'org.slf4j:slf4j-api:1.7.23',
  56. 'org.slf4j:slf4j-log4j12:1.7.23',
  57. 'log4j:log4j:1.2.17',
  58. 'commons-logging:commons-logging:1.2',
  59. /* 连接池 */
  60. 'com.alibaba:druid:1.0.27',
  61. /* json */
  62. 'org.codehaus.jackson:jackson-mapper-asl:1.9.13',
  63. 'org.codehaus.jackson:jackson-core-asl:1.9.13',
  64. 'com.fasterxml.jackson.core:jackson-core:' + jacksonVersion,
  65. 'com.fasterxml.jackson.core:jackson-databind:' + jacksonVersion,
  66. 'com.fasterxml.jackson.core:jackson-annotations:' + jacksonVersion,
  67.  
  68. 'org.apache.poi:poi:3.15',
  69. 'org.apache.poi:poi-ooxml:3.15',
  70. 'com.github.virtuald:curvesapi:1.04',
  71. 'commons-codec:commons-codec:1.10',
  72. 'org.apache.poi:poi-ooxml-schemas:3.15',
  73. 'org.apache.commons:commons-collections4:4.1',
  74. 'commons-io:commons-io:2.2',
  75. 'commons-fileupload:commons-fileupload:1.3.2',
  76.  
  77. 'com.belerweb:pinyin4j:2.5.1'
  78. )
  79. testCompile(
  80. 'junit:junit:4.12',
  81. 'org.hamcrest:hamcrest-core:1.3', /* 一个测试用的工具 */
  82. 'org.springframework:spring-test:' + springVersion
  83. )
  84. }
  85.  
  86. /* jettyRun 的配置 */
  87. jettyRun {
  88. httpPort = 8080
  89. reload = "automatic"
  90. scanIntervalSeconds = 1
  91. contextPath = 'dataImport'
  92. }
  93.  
  94. test {
  95. ignoreFailures = true
  96. }
  97.  
  98. pmd {
  99. ignoreFailures = true
  100. }
  101.  
  102. findbugs {
  103. sourceSets = [sourceSets.main]
  104. ignoreFailures = true
  105. reportsDir = file("$project.buildDir/findbugsReports")
  106. effort = "default"
  107. reportLevel = "medium"
  108. }
  109.  
  110. task wrapper(type: Wrapper) {
  111. gradleVersion = '2.14.1'
  112. }

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

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. poj 3254 状压dp入门题

    1.poj 3254  Corn Fields    状态压缩dp入门题 2.总结:二进制实在巧妙,以前从来没想过可以这样用. 题意:n行m列,1表示肥沃,0表示贫瘠,把牛放在肥沃处,要求所有牛不能相 ...

  2. Node.js 手册查询-4-Express 方法

    express 标签(空格分隔): node.js express [TOC] 安装: 新版本中命令行工具分家了 npm install -g express //安装 express 然后 npm ...

  3. sencha 安装、学习

     sencha touch 是Extjs 的手机版,Extjs是创建富客户端的AJAX应用中的重量级框架,sencha touch当然就是面向触摸设备的重量级js框架,在做基于桌面的网页时经常用的js ...

  4. RecyclerView使用时遇到的问题

    一.概述 二.常见问题: 1.如何为RecyclerView的Item设置点击事件? 1.1 问题描述 类似于下列方法 RecyclerView.setOnItemClickListener(OnCl ...

  5. scala - Enumeration 诡异问题

    object WeekDay extends Enumeration { type WeekDay = Value val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Va ...

  6. HDU 4006 优先队列

    The kth great number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Oth ...

  7. 面试之Java多线程

    Java多线程1.什么是多线程2.为什么需要多线程  有什么优点和缺点3.怎么运行 一.多线程是在软件或硬件上并发执行的技术共享数据空间,内存资源和CPU二.优点:把长时间运行的程序任务放到后台处理, ...

  8. centos6 LVS-DR模式---分析

    LVS是什么就不多说了. 先上拓扑图 1台LVS   3台Realserver    一个客户端.  环境全部模拟全在内网环境(selinux和iptables关闭) 先简略说一下安装步骤: LVS上 ...

  9. thinkphp自定义权限管理之名称判断

    权限管理,就是给不同的用户分配不同的权限.当用户登录或者操作时候进行判断,来阻止用户进行权限以外的操作.本次讲的是当用户登录一刻,只显示权限开启的内容. 一.建立数据库. 1.权限表funcla.来存 ...

  10. BizTalk开发系列(三十六) Orchestration单实例执行

    BizTalk 是高效的消息处理引擎,采用多线程并发的方式来处理消息.也就是说当有消息被接收的时候就会产生一个新的消息处理实例.但有时目标系统可能并没有并发处理 的能力, 这时就需要在BizTalk中 ...