博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
gradle基础的build文件模板_jetty
阅读量:7283 次
发布时间:2019-06-30

本文共 5525 字,大约阅读时间需要 18 分钟。

group '组织名'version '版本号' /* 支持的插件 */apply plugin: 'java' // 项目基础变成语言支持为javaapply plugin: 'war' // 可将项目打包成war形式运行apply plugin: 'eclipse' // 支持ECLIPSE的导入和编辑apply plugin: 'eclipse-wtp' // 支持ECLIPSE-WEB的导入和编辑apply plugin: 'idea' // 支持IntelliJ IDEA直接导入和编辑apply plugin: 'jetty' // 使用jetty作为服务器,也可自行替换为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开发,红色部分的配置为必须的。

 

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

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 40             'javax.servlet:jstl:1.1.2', 41             'taglibs:standard:1.1.2' 42     ) 43     compile( 44             fileTree(dir: 'lib', include: ['*.jar']), /* 包含lib文件夹下的所有jar文件 */ 45             'com.google.guava:guava:20.0', 46  47             'org.springframework:spring-core:' + springVersion, 48             'org.springframework:spring-web:' + springVersion, 49             'org.springframework:spring-webmvc:' + springVersion, 50             'org.springframework:spring-aop:' + springVersion, 51  52             'org.aspectj:aspectjrt:' + aspectjVersion, 53             'org.aspectj:aspectjweaver:' + aspectjVersion, 54             'org.aspectj:aspectjtools:' + aspectjVersion, 55             /* 日志 */ 56             'org.slf4j:slf4j-api:1.7.23', 57             'org.slf4j:slf4j-log4j12:1.7.23', 58             'log4j:log4j:1.2.17', 59             'commons-logging:commons-logging:1.2', 60             /* 连接池 */     61             'com.alibaba:druid:1.0.27', 62             /* json */ 63             'org.codehaus.jackson:jackson-mapper-asl:1.9.13', 64             'org.codehaus.jackson:jackson-core-asl:1.9.13', 65             'com.fasterxml.jackson.core:jackson-core:' + jacksonVersion, 66             'com.fasterxml.jackson.core:jackson-databind:' + jacksonVersion, 67             'com.fasterxml.jackson.core:jackson-annotations:' + jacksonVersion, 68  69             'org.apache.poi:poi:3.15', 70             'org.apache.poi:poi-ooxml:3.15', 71             'com.github.virtuald:curvesapi:1.04', 72             'commons-codec:commons-codec:1.10', 73             'org.apache.poi:poi-ooxml-schemas:3.15', 74             'org.apache.commons:commons-collections4:4.1', 75             'commons-io:commons-io:2.2', 76             'commons-fileupload:commons-fileupload:1.3.2', 77  78             'com.belerweb:pinyin4j:2.5.1' 79     ) 80     testCompile( 81             'junit:junit:4.12', 82             'org.hamcrest:hamcrest-core:1.3', /* 一个测试用的工具 */ 83             'org.springframework:spring-test:' + springVersion 84     ) 85 } 86  87 /* jettyRun 的配置 */ 88 jettyRun { 89     httpPort = 8080 90     reload = "automatic" 91     scanIntervalSeconds = 1 92     contextPath = 'dataImport' 93 } 94  95 test { 96     ignoreFailures = true 97 } 98  99 pmd {100     ignoreFailures = true101 }102 103 findbugs {104     sourceSets = [sourceSets.main]105     ignoreFailures = true106     reportsDir = file("$project.buildDir/findbugsReports")107     effort = "default"108     reportLevel = "medium"109 }110 111 task wrapper(type: Wrapper) {112     gradleVersion = '2.14.1'113 }114

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

转载于:https://www.cnblogs.com/SummerinShire/p/6055151.html

你可能感兴趣的文章
探究call 和 apply 的原理
查看>>
988-从叶结点开始的最小字符串
查看>>
莫比乌斯反演初步与实际应用
查看>>
最佳在线图表软件
查看>>
java中具有继承关系的类及其对象初始化顺序
查看>>
Intellij IDEA 开发 Spring-boot项目 热部署,自动部署
查看>>
PHP 实现归并排序算法
查看>>
GraphQL 学习
查看>>
3分钟带你看懂android中的Binder机制
查看>>
说说vue-cli中使用flexible和px2rem-loader
查看>>
浅析 Vue 2.6 中的 nextTick 方法
查看>>
JavaScript链式调用实例
查看>>
webpack构建和性能优化探索
查看>>
区块链 | ETH投票项目
查看>>
simhash+汉明距离计算文本相似度
查看>>
mocha
查看>>
Node.js和NoSQL开发比特币加密货币应用程序(下)
查看>>
[LeetCode] 348. Design Tic-Tac-Toe
查看>>
移动端的适配及布局
查看>>
跨域访问
查看>>