• gradle基础的build文件模板_jetty


    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开发,红色部分的配置为必须的。

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

      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 = true
    101 }
    102 
    103 findbugs {
    104     sourceSets = [sourceSets.main]
    105     ignoreFailures = true
    106     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     

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

  • 相关阅读:
    CF1109D Sasha and Interesting Fact from Graph Theory 组合数
    和与或 数位dp
    G
    E. String Multiplication dp
    Obtain a Permutation 乱搞
    CF1061E Politics 费用流
    mysql连接报错
    编译安装nginx
    SQL四种语言:DDL,DML,DCL,TCL
    Linux 常用管理命令
  • 原文地址:https://www.cnblogs.com/SummerinShire/p/6055151.html
Copyright © 2020-2023  润新知