-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.gradle
122 lines (94 loc) · 4.56 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
group 'com.wenjun'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'jetty'
sourceCompatibility = 1.6
repositories {
//使用阿里云的maven仓库,速度比较快
maven { url "http://maven.aliyun.com/nexus/content/groups/public/" }
jcenter()
mavenCentral()
}
//设置项目编码
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
// 部署war到tomcat方式一, build/libs 下是编译好的war包
task deploy (dependsOn: war){
copy {
from "build/libs"
into "E:\\apache-tomcat-8.0.22\\webapps\\" // 换成你的tomcat目录
include "*.war"
}
}
//部署War文件到 tomcat方式二(Java代码实现)
task copyToMyTomcat << {
def warFileStr = 'OADemo-1.0-SNAPSHOT.war'
def outFileStr = 'OADemo.war'
def tomcatPathStr = 'E:\\apache-tomcat-8.0.22\\webapps\\'
println("ready copy war to tomcat "+tomcatPathStr)
File outputfile = new File(tomcatPathStr+"/"+outFileStr);
File inputFile = new File("build/libs/"+ warFileStr);
FileInputStream fis = new FileInputStream(inputFile);
FileOutputStream fos = new FileOutputStream(outputfile);
byte[] buffer = new byte[1024];
int len = -1;
while((len=(fis.read(buffer)))> 0){
fos.write(buffer,0,len);
}
fos.flush();
fos.close();
fis.close()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile group: 'junit', name: 'junit', version: '4.11'
// providedCompile 这个conf在java插件里是报错的,war里是正确的
// providedCompile 'javax.servlet:servlet-api:2.5'
compile 'javax.servlet:servlet-api:2.5'
compile group: 'javax.servlet.jsp', name: 'jsp-api', version: '2.2'
def springVersion = "4.2.9.RELEASE"
def hibernateVerion = "4.3.10.Final"
//Hibernate
compile ("org.hibernate:hibernate-core:$hibernateVerion")
//Hibernate jpa实体管理
compile ("org.hibernate:hibernate-entitymanager:$hibernateVerion")
//Hibernate 可选包 c3p0
compile ("org.hibernate:hibernate-c3p0:$hibernateVerion")
//Hibernate 可选包 ehcache
compile ("org.hibernate:hibernate-ehcache:$hibernateVerion")
// SpringMVC(下面不需要全部写完,因为gradle会根据依赖关系下载相应的jar,重复的忽略,但这里怕遗忘,即全部写全,查看依赖关系gradle dependencies)
compile("org.springframework:spring-context:$springVersion",
"org.springframework:spring-core:$springVersion",
"org.springframework:spring-aop:$springVersion",
"org.springframework:spring-orm:$springVersion",
// Spring JDBC是提供了一套JDBC抽象框架,用于简化JDBC开发。如JdbcTemplate
"org.springframework:spring-jdbc:$springVersion",
"org.springframework:spring-instrument-tomcat:$springVersion",
"org.springframework:spring-instrument:$springVersion",
"org.springframework:spring-expression:$springVersion",
"org.springframework:spring-context-support:$springVersion",
"org.springframework:spring-beans:$springVersion",
"org.springframework:spring-aspects:$springVersion",
"org.springframework:spring-test:$springVersion",
"org.springframework:spring-tx:$springVersion",
"org.springframework:spring-jms:$springVersion",
"org.springframework:spring-messaging:$springVersion",
"org.springframework:spring-oxm:$springVersion",
"org.springframework:spring-web:$springVersion",
"org.springframework:spring-webmvc:$springVersion",
"org.springframework:spring-webmvc-portlet:$springVersion")
// 数据校检(使用此校检需要注意 jstl使用的一个问题,具体自行百度)
// compile group: 'org.hibernate', name: 'hibernate-validator', version: '4.3.2.Final'
// 数据库连接部分依赖(注意用5.1.24版本,5.1.36 测试有问题)
compile("mysql:mysql-connector-java:5.1.24")
// java mail (包含mail和activation两个包)
compile group: 'javax.mail', name: 'mail', version: '1.4.7'
compile group: 'log4j', name: 'log4j', version: '1.2.16'
//文件上传(commons-io和commons-fileupload两个包)
compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.1'
// 加密组件
compile group: 'commons-codec', name: 'commons-codec', version: '1.9'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
}