-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
164 lines (141 loc) · 5.09 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import javax.tools.JavaCompiler
apply from: 'libraries.gradle'
group = 'com.travelzen'
version = '1.0'
allprojects {
buildDir = 'target'
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'maven'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
mavenLocal()
maven { url 'http://10.19.248.200:30080/nexus/content/groups/public' }
//maven { url 'http://10.19.248.200:30080/nexus/content/repositories/elasticsearch' }
//maven { url 'https://maven.alfresco.com/nexus/content/groups/public' }
mavenCentral()
maven { url 'https://artifacts.elastic.co/maven' }
//maven { url 'http://10.19.248.200:30080/nexus/content/groups/public' }
//maven { url 'https://raw.github.com/dianping/cat/mvn-repo' }
}
eclipse {
classpath {
downloadSources=true
}
}
configurations {
provided {
// todo : need to make sure these are non-exported
description = 'Non-exported compile-time dependencies.'
}
configurations {
all*.exclude group: 'org.bouncycastle', module: 'bcprov-jdk15on'
//all*.exclude group: 'commons-logging', module: 'commons-logging'
//all*.exclude group: 'log4j'
//all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
all*.exclude group: 'org.eclipse.jetty.orbit'
all{resolutionStrategy.cacheChangingModulesFor 1, 'seconds'}
// all { resolutionStrategy.force 'org.apache.httpcomponents:httpcore:4.3.2' }
// all { resolutionStrategy.force 'org.apache.httpcomponents:httpclient:4.3.4' }
}
tzresources{
description = 'share resources.'
}
}
sourceSets.main.compileClasspath += configurations.provided
eclipse.classpath.plusConfigurations += configurations.provided
sourceSets.main.resources {
if (project.hasProperty('profile')) {
srcDir 'src/main/resources-' + project.profile
srcDir 'src/test/resources-' + project.profile
}
}
tasks.withType(JavaCompiler) { options.encoding = 'UTF-8' }
eclipseProject.doLast {
if (!new File("$projectDir/src").exists() && !new File("$projectDir/gen-java").exists()) {
ant.delete dir: '.settings'
ant.delete file: '.project'
ant.delete file: '.classpath'
}
}
task 'create-dirs' << {
sourceSets*.java.srcDirs*.each { it.mkdirs() }
sourceSets*.resources.srcDirs*.each { it.mkdirs() }
}
task listJars << {
configurations.compile.each { File file -> println file.name }
}
task zip(type: Zip) {
from ('script') { into('bin') }
from ('src/main/resources') { into('conf') }
if (project.hasProperty('profile'))
from ('src/main/resources-' + project.profile) { into('conf') }
into('lib') {
from ('lib')
from (jar.outputs.files)
from (configurations.compile)
}
}
zip.doFirst {
if (new File("$projectDir/script").exists()) {
classpath = new File("$projectDir/script/.classpath")
if (!classpath.exists()) classpath.createNewFile()
cp = 'CLASSPATH='
for(file in new File("$projectDir/lib").listFiles()) cp += '../lib/' + file.name + ';'
for(file in configurations.compile) cp += '../lib/' + file.name + ';'
for(file in jar.outputs.files) cp += '../lib/' + file.name + ';'
classpath.text = cp.substring(0, cp.length() - 1)
}
}
tasks.withType(War) {
manifest {
attributes("Implementation-Title": project.name,
"Implementation-Version": project.version,
"Built-By": System.getProperty('user.name'),
"Built-JDK": System.getProperty('java.version'),
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
)
}
}
tasks.withType(Jar) {
manifest {
attributes("Implementation-Title": project.name,
"Implementation-Version": project.version,
"Built-By": System.getProperty('user.name'),
"Built-JDK": System.getProperty('java.version'),
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
)
}
}
task packageTests(type: Jar) {
baseName = "${project.archivesBaseName}-test"
from sourceSets.test.output
}
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn:javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
// 编译groovy代码时采用 MacRoman
tasks.withType(GroovyCompile) {
groovyOptions.encoding = 'MacRoman'
}
// 编译JAVADOC文件时采用 UTF-8
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
}
// 编译JAVA文件时采用 UTF-8
tasks.withType(JavaCompiler) {
options.encoding = 'UTF-8'
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
}