-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
199 lines (160 loc) · 5.93 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// 主仓库
repositories {
jcenter()
maven { url 'repo' }
}
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.edu.sc.seis.gradle:launch4j:2.3.0"
}
}
String swtGroupId = 'org.eclipse.swt', swtVersion = '3.7.2'
def osDependencies = []
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
println System.properties['os.arch']
println System.properties['sun.arch.data.model']
// 区分32位和64位
String arch = System.getenv("PROCESSOR_ARCHITECTURE")
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432")
Boolean is64Arch = (arch && arch.endsWith("64")) \
|| (wow64Arch && wow64Arch.endsWith("64"))
// 这里除了需要看系统外, 还需要看jvm是否是64的, 防止32位启动64无法正常运行
String jvmArch = System.properties['sun.arch.data.model']
is64Arch = is64Arch && jvmArch && jvmArch.endsWith("64")
if (is64Arch) {
osDependencies << String.format("%s:%s:%s", swtGroupId, 'org.eclipse.swt.win32.win32.x86_64', swtVersion)
} else {
osDependencies << String.format("%s:%s:%s", swtGroupId, 'org.eclipse.swt.win32.win32.x86', swtVersion)
}
} else {
// 全部编译
osDependencies << String.format("%s:%s:%s", swtGroupId, 'org.eclipse.swt.win32.win32.x86_64', swtVersion)
}
////// -----------------------Java编译依赖配置开始 ---------------------------//////////
apply plugin: 'java'
// 显示定义工程源码结构
sourceSets {
main {
java {
srcDirs = ["src/main/java"]
}
resources {
srcDirs = ["src/main/resources"]
includes = ["**/*.*"]
}
}
test {
java {
srcDirs = ["src/test/java"]
}
}
}
dependencies {
// The production code uses Guava
compile 'com.google.guava:guava:20.0'
// 这里的lombok是经过定制的, 里面增强了setterbound的功能
compileOnly 'com.aiziyuer:com.aiziyuer.lombok:1.16.12'
// 系统相关的依赖
compile osDependencies
// JFace类库
compile 'org.eclipse.jface:org.eclipse.jface:3.7.0.v20110928-1505'
compile 'org.eclipse.core:org.eclipse.core.commands:3.6.0.I20110111-0800'
compile 'org.eclipse.osgi:org.eclipse.osgi:3.7.2.v20120110-1415'
// databing相关的几个类库
compile 'com.aiziyuer:com.ibm.icu:4.4.2.v20110823'
compile 'com.aiziyuer:org.eclipse.core.databinding:1.4.0.I20110111-0800'
compile 'com.aiziyuer:org.eclipse.core.databinding.beans:1.2.100.I20100824-0800'
compile 'com.aiziyuer:org.eclipse.core.databinding.observable:1.4.0.I20110222-0800'
compile 'com.aiziyuer:org.eclipse.core.databinding.property:1.4.0.I20110222-0800'
compile 'com.aiziyuer:org.eclipse.jface.databinding:1.5.0.I20100907-0800'
// xwt类库
compile 'com.aiziyuer:org.eclipse.e4.xwt:0.9.1.20170208.160755'
compile 'com.aiziyuer:org.eclipse.e4.xwt.forms:0.9.1.20170208.160755'
compile 'com.aiziyuer:org.pushingpixels.trident:1.2.0.v20100204-1500'
// 配置Log4j
String LOG4J_VERSION = '2.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: LOG4J_VERSION
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: LOG4J_VERSION
// yaml工具类
compile group: 'com.esotericsoftware.yamlbeans', name: 'yamlbeans', version: '1.08'
// 通用工具包
compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.8.3'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
// ssh类库
compile group: 'com.jcraft', name: 'jsch', version: '0.1.53'
// 测试用框架
testCompile 'junit:junit:4.12'
}
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
options.encoding = 'UTF-8'
}
////// -----------------------Java编译依赖配置开始 ---------------------------//////////
///// ------------------------打包配置开始---------------------------------///////
apply plugin: "edu.sc.seis.launch4j"
String APP_NAME = 'EtcdSprite'
String PACKAGE_DIR = String.format("%s/%s", buildDir, APP_NAME)
task copyStaticFile(type: Copy) {
copy {
// 拷贝图标
from 'icons/etcd-seeklogo.com.ico'
into PACKAGE_DIR + '/icons'
rename { fileName -> APP_NAME + '.ico' }
}
copy {
// 拷贝配置文件
from 'config/log4j2.xml'
into PACKAGE_DIR + '/config'
}
copy {
// 拷贝应用配置文件
from 'config/template.l4j.ini'
into PACKAGE_DIR
rename { fileName -> APP_NAME + '.l4j.ini' }
}
copy {
// 数据文件
from 'config/data'
into PACKAGE_DIR + '/config/data'
}
}
tasks.createExe.dependsOn('copyStaticFile')
launch4j {
outputDir = APP_NAME
mainClassName = "com.aiziyuer.app.CoreApplication"
icon = String.format("%s/icons/%s.ico", PACKAGE_DIR, APP_NAME)
}
///// ------------------------打包配置开始---------------------------------///////
//// -------------------------发布配置开始--------------------------------///////
task zipDist(type: Zip){
// 指定需要压缩的目录
from "${buildDir}/${APP_NAME}"
// 指定发布前需要哪个执行哪个任务
dependsOn { [ "createExe"] }
}
//// -------------------------发布配置结束--------------------------------///////
//// -------------------------IDE支持开始--------------------------------////////
apply plugin: "eclipse"
eclipse {
classpath {
// 配置下载源码和javadoc
downloadSources = true
downloadJavadoc = true
}
}
apply plugin: "idea"
idea {
module {
// 配置下载源码和javadoc
downloadJavadoc = true
downloadSources = true
}
}
//// -------------------------IDE支持结束--------------------------------////////