一份IDEA + gradle + spring项目的build.gradle清单

group 'com.superserver'
version '1.0-SNAPSHOT'

// 应用Gradle各插件
apply plugin: 'java'
apply plugin: 'war' // war包生产插件
apply plugin: 'idea'
apply plugin: 'org.akhikhl.gretty' // 应用gretty插件

version = "" // 项目版本
//Gretty Embedded Jetty
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.akhikhl.gretty:gretty:+'
    }
}

// 指定JDK版本
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext {
    jvmVersion = "1.8"
    springVersion = "4.0.6.RELEASE"
    sl4jVersion = "1.7.6"
}

repositories {
    // maven    def cn = "http://maven.oschina.net/content/groups/public/"
    def abroad = "http://central.maven.org/maven2/"
    // 先从url中下载jar若没有找到,则在artifactUrls中寻找
    maven {
        url cn
        artifactUrls abroad
    }
}

[compileJava, compileTestJava, javadoc]*.options*.encoding = "UTF-8"


dependencies {
    def springVersion = "4.0.6.RELEASE"
    def hibernateVer = "4.3.6.Final"

    // providedCompile在编译时提供,不会写入war
    providedCompile(
            "javax.servlet:javax.servlet-api:3.1.0",
            "javax.servlet.jsp:jsp-api:2.2.1-b03"
    )
    // 引入项目中/libs中的jar
    compile files( 'libs/spring-framework-bom-4.0.6.RELEASE.jar')

    compile("org.apache.taglibs:taglibs-standard-impl:1.2.1")
    // aspectjtools-1.6.11是测可试用版本,使用其他版本会报"dataSource无法注入"Exception
    compile("javax:javaee-api:7.0",
            "javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:1.2.1",
            "org.aspectj:aspectjtools:1.6.11",
            "antlr:antlr:2.7.7",
            "org.aspectj:aspectjrt:1.6.11",
            "org.aspectj:aspectjmatcher:1.6.11")

    compile("org.apache.commons:com.springsource.org.apache.commons.fileupload:1.2.1",
            "commons-codec:commons-codec:1.6",
            "commons-collections:commons-collections:3.2.1",
            "commons-lang:commons-lang:2.6",
            "commons-logging:commons-logging:1.2",
            "commons-pool:commons-pool:1.5.5",
            "org.apache.commons:commons-lang3:3.1")

    // 数据库连接部分依赖
    compile("mysql:mysql-connector-java:5.1.36")
    compile("com.mchange:mchange-commons-java:0.2.3.4",
            "redis.clients:jedis:2.0.0",
            "net.sf.ehcache:ehcache-core:2.4.3")
    compile("org.hibernate:hibernate-c3p0:$hibernateVer",
            "org.hibernate:hibernate-core:$hibernateVer",
            "org.hibernate:hibernate-entitymanager:$hibernateVer",
            "org.hibernate:hibernate-ehcache:$hibernateVer",
            "org.hibernate.common:hibernate-commons-annotations:4.0.5.Final")
    // Spring4.0.6依赖
    compile("org.springframework:spring-aop:$springVersion",
            "org.springframework:spring-orm:$springVersion",
            "org.springframework:spring-jdbc:$springVersion",
            "org.springframework:spring-instrument-tomcat:$springVersion",
            "org.springframework:spring-instrument:$springVersion",
            "org.springframework:spring-framework-bom:$springVersion",
            "org.springframework:spring-expression:$springVersion",
            "org.springframework:spring-core:$springVersion",
            "org.springframework:spring-context-support:$springVersion",
            "org.springframework:spring-context:$springVersion",
            "org.springframework:spring-beans:$springVersion",
            "org.springframework:spring-aspects:$springVersion",
            "org.springframework:spring-test:$springVersion",
            "org.springframework:spring-tx:$springVersion",
            "org.springframework:spring-web:$springVersion",
            "org.springframework:spring-webmvc:$springVersion",
            "org.springframework:spring-webmvc-portlet:$springVersion")

    // json相关依赖
    compile("com.alibaba:fastjson:1.2.7",
            "com.jayway.jsonpath:json-path:0.8.1",
            "net.minidev:json-smart:1.1.1",
            "org.jsoup:jsoup:1.7.2")

    compile("org.codehaus.jackson:jackson-core-asl:1.9.2","org.codehaus.jackson:jackson-mapper-asl:1.9.2")

    compile("org.dom4j:com.springsource.org.dom4j:1.6.1")

    compile("com.google.guava:guava:17.0")

    // 测试编译时的依赖
    testCompile("org.assertj:assertj-core:1.5.0",
            "org.hamcrest:hamcrest-core:1.3",
            "junit:junit:4.11")
}
// gretty相关配置
gretty {
    port = 8080
    contextPath = "/${project.name}"
    servletContainer = 'jetty9' // or tomcat7
}

// 部署wartomcatTask
task deploy (dependsOn: war){
    copy {
        from "build/libs"
        into "F:/software/tomcat7/webapps"  // 换成你的tomcat目录
        include "*.war"
    }
}

你可能感兴趣的:(其它)