-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
338 lines (283 loc) · 9.43 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
import java.text.SimpleDateFormat
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'com.github.hierynomus.license'
apply plugin: 'checkstyle'
apply plugin: 'application'
apply plugin: 'ch.raffael.pegdown-doclet'
apply from: project.file( 'etc/publish.gradle' )
defaultTasks 'clean', 'build'
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0"
classpath 'ch.raffael.pegdown-doclet:pegdown-doclet:1.3'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {url 'https://jitpack.io'}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'license'
apply plugin: 'checkstyle'
defaultTasks 'clean', 'build'
compileJava {options.encoding = 'UTF-8'}
javadoc {options.encoding = "UTF-8"}
// compileGroovy {options.encoding = "UTF-8"}
license {
header rootProject.file( 'etc/HEADER' )
ignoreFailures true
strictCheck true
mapping 'yaml', 'SCRIPT_STYLE'
mapping 'yml', 'SCRIPT_STYLE'
excludes( ['**/*.archive',
'**/*.md5',
'**/*.txt',
'**/*.bmp',
'**/*.png',
'**/*.jpg',
'**/*.yaml',
'**/*.yml',
'**/*.properties',
'**/less-rhino-1.7.4.js',
'**/coffee-script.js',
'**/banner.txt',
'**/config.yaml'] )
ext.year = Calendar.getInstance().get( Calendar.YEAR )
ext.name = 'Amelia Sara Greene'
ext.email = '[email protected]'
}
checkstyle {
configFile = rootProject.file( 'etc/checkstyle.xml' )
configProperties = ["basedir": project.projectDir]
}
configurations {
required
}
dependencies {
configurations.compile.extendsFrom( configurations.required )
}
task dependenyBundler {
doFirst {
def depend = configurations.required.collect {it.isDirectory() ? it : zipTree( it )}
if ( depend.size > 0 )
{
println 'Bundled required libs into jar: ' + depend
rootProject.jar.from( depend )
}
}
}
jar.dependsOn dependenyBundler
}
def rootDir = rootProject.rootDir
subprojects {
buildDir = new File( rootDir, '/build/' )
libsDirName = new File( rootDir, '/build/dist/' )
artifacts {archives jar}
}
// Tells Gradle to include the sourceSets from all subprojects into the main
sourceSets {
main {
java {
rootProject.getSubprojects().each {
it.sourceSets.main.java.srcDirs.each {
srcDir it
}
}
}
}
}
dependencies {
testCompile( group: 'junit', name: 'junit', version: '4.12' ) {
exclude group: 'org.hamcrest'
}
testCompile 'org.hamcrest:hamcrest-library:1.3'
compile project( ':AmeliaCommonLib' )
compile project( ':AmeliaAppLib' )
compile project( ':AmeliaScriptingLib' )
compile project( ':AmeliaStorageLib' )
compile project( ':AmeliaPluginsLib' )
compile project( ':AmeliaLogLib' )
compile project( ':HoneyNetworking' )
compile project( ':AmeliaNetworkingLib' )
compile project( ':AmeliaUsersLib' )
compile group: 'net.sf.jopt-simple', name: 'jopt-simple', version: '4.7'
// Used for Networking HTTP and TCP
// compile group: 'io.netty', name: 'netty-all', version: '4.1.23.Final'
// compile group: 'io.netty', name: 'netty-all', version: '5.0.0.Alpha2'
// Used to Make Database Connections
// compile group: 'com.rethinkdb', name: 'rethinkdb-driver', version: '2.3.3'
// compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.35'
// compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.8.11.2'
// compile group: 'com.h2database', name: 'h2', version: '1.4.187'
// Used for Programming Convenience
// compile group: 'com.google.guava', name: 'guava', version: '18.0'
// compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'
// compile group: 'commons-io', name: 'commons-io', version: '2.4'
// compile group: 'commons-net', name: 'commons-net', version: '3.3'
// compile group: 'commons-codec', name: 'commons-codec', version: '1.9'
// Used to load configs
// compile group: 'org.yaml', name: 'snakeyaml', version: '1.13'
// Used by JS Minimizer
// compile group: 'com.google.javascript', name: 'closure-compiler', version: 'r2388'
// compile group: 'org.mozilla', name: 'rhino', version: '1.7R4'
// Used by Less Preprocessor
// compile group: 'com.asual.lesscss', name: 'lesscss-engine', version: '1.3.0'
// Used to format Time and Dates
// compile group: 'org.ocpsoft.prettytime', name: 'prettytime', version: '3.2.5.Final'
// Used to format Phone Numbers
// compile group: 'com.googlecode.libphonenumber', name: 'libphonenumber', version: '7.0.4'
// Used for serialization
// compile group: 'com.google.code.gson', name: 'gson', version: '2.3'
// compile group: 'org.json', name: 'json', version: '20160810'
// Used by MavenUtils and some scripts
// compile group: 'org.apache.httpcomponents', name: 'fluent-hc', version: '4.3.5'
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
Properties buildProperties = getBuildProperties();
mainClassName = "io.amelia.main.EntryPoint"
def rawVersion = buildProperties.getProperty( "versionMajor" ) + "." + buildProperties.getProperty( "versionMinor" ) + "." + buildProperties.getProperty( "versionRevision" )
def jenkins_build = System.getenv( "BUILD_NUMBER" )
def travis_build = System.getenv( "TRAVIS_BUILD_NUMBER" )
def buildNumber = '0'
group 'io.amelia'
description = 'Honey Pot Server is a multi-protocol networking server offering groovy scripting, plugins, ssl, events, orm, and much more.'
distsDirName = 'dist'
libsDirName = 'dist'
if ( System.getenv( "RELEASE" ) != null )
{
version = buildProperties.getProperty( "versionMajor" ) + "." + buildProperties.getProperty( "versionMinor" ) + "." + buildProperties.getProperty( "versionRevision" ) + "-" + System.getenv( "RELEASE" )
}
else if ( jenkins_build != null )
{
version = rawVersion + '-jenkins+B' + jenkins_build
buildNumber = jenkins_build
}
else if ( travis_build != null )
{
version = rawVersion + '-travis+B' + travis_build
buildNumber = travis_build
}
else
{
version = rawVersion + '-git+H' + gitDescribe()
}
def gitDescribe()
{
try
{
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
catch ( Throwable e )
{
return "unknown"
}
}
def getBuildProperties()
{
try
{
Properties props = new Properties()
props.load( new FileInputStream( new File( "./src/main/resources/build.properties" ) ) )
return props
}
catch ( Throwable e )
{
return 0
}
}
eclipse {
project {name = buildProperties.getProperty( "gitRepo", "HoneyPotServer" )}
}
jar {
manifest {
attributes 'Implementation-Title': buildProperties.getProperty( "productName", 'Honey Pot Server' )
attributes 'Implementation-Version': version
attributes 'Implementation-Vendor': buildProperties.getProperty( "devName", 'Amelia Sara Greene' )
attributes 'Implementation-Vendor-Id': buildProperties.getProperty( "devEmail", '[email protected]' )
attributes 'Main-Class': mainClassName
}
/*rootProject.getAllprojects().each {
try
{
println it.configurations.bundleJar
def depend = it.configurations.bundleJar.collect {it}
println 'Bundled dependency "' + depend + '" into jar file.'
from depend
}
catch ( MissingPropertyException e )
{
e.printStackTrace()
println 'No jar dependencies for project: ' + it.getName()
// Ignore Exception thrown when configuration is missing.
}
}*/
}
task sourcesArchive( type: Zip ) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocArchive( type: Zip, dependsOn: 'javadoc' ) {
classifier = 'javadoc'
from javadoc.destinationDir
}
/**
* Writes the project dependencies to a resource file for dependency injection within the application*/
task writeDependenciesFile {
doFirst {
def allDependencies = []
rootProject.getAllprojects().each {
allDependencies += it.getConfigurations().getByName( "runtime" ).getAllDependencies().withType( ExternalModuleDependency )
// Remove all dependencies that were already bundled into the jar file
allDependencies.removeAll( it.getConfigurations().getByName( "required" ).getAllDependencies().withType( ExternalModuleDependency ) )
}
def output = ""
allDependencies.unique().each {
output += it.group + ":" + it.name + ":" + it.version + "\n"
}
def file = file( "src/main/resources/dependencies.txt" )
file.parentFile.mkdirs()
def fos = new FileOutputStream( file )
fos.write( ( byte[] ) output.getBytes() )
fos.close()
}
}
task writePropertiesFile {
doFirst {
SimpleDateFormat sdf = new SimpleDateFormat( "EEE, d MMM yyyy HH:mm:ss Z" )
Properties props = new Properties()
props.load( new FileInputStream( file( "src/main/resources/build.properties" ) ) )
props.setProperty( "project.builtOn", sdf.format( new Date() ) )
props.setProperty( "project.build", buildNumber )
props.setProperty( "project.version", version.toString() )
File f2 = file( "build/dist/build.properties" )
File f3 = file( "build/resources/main/build.properties" )
f2.parentFile.mkdirs()
f3.parentFile.mkdirs()
OutputStream out2 = new FileOutputStream( f2 )
OutputStream out3 = new FileOutputStream( f3 )
props.store( out2, "Build Properties File" )
props.store( out3, "Build Properties File" )
}
}
build.dependsOn writeDependenciesFile
jar.dependsOn writePropertiesFile
artifacts {archives jar, sourcesArchive, javadocArchive}