-
Notifications
You must be signed in to change notification settings - Fork 26
/
build.gradle
103 lines (94 loc) · 2.72 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
/**
* https://github.com/wangfei1975/superlog
* Build file using win64 libraries.
*
* TODO allow the project to be built for mac64.
*/
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: "java"
apply plugin: 'gradle-one-jar'
apply from: 'genbuildinfo.gradle'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.rholder:gradle-one-jar:1.0.4'
}
}
repositories {
mavenCentral()
}
defaultTasks = ["clean", "deploy", "docs"]
version = "1.0.9"
def WORKSPACE_DIR = "../"
def MAIN_CLASS_NAME = "feiw.Slogmain"
def DEPLOY_DIR = "./"
sourceSets.main.java.srcDirs = ["./build/generated-sources", "./src"]
sourceSets.main.resources.includes = ["./resources", "./screenshots"] // latter location probably not important
dependencies {
compile 'com.google.code.gson:gson:2.2.+'
def dirName
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
dirName = 'win64'
} else if (Os.isFamily(Os.FAMILY_MAC)) {
dirName = 'mac64'
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
dirName = 'linux64'
}
compile fileTree(dir: "./lib/"+dirName, include: "*.jar")
}
task('showCache') << {
configurations.compile.each { println it }
}
//tasks.genBuildInfo.dependsOn generateProto
tasks.compileJava.dependsOn genBuildInfo
/*
tasks.each {
if (!it.name.equals('showCache')) {
it.dependsOn showCache
}
}
*/
task myjar(type: OneJar) {
mainClass = "$MAIN_CLASS_NAME"
mergeManifestFromJar = true
additionalDir = file('resources')
// archiveName = "superlog-" + "$version" + ".jar"
}
// http://stackoverflow.com/questions/21721119/creating-runnable-jar-with-gradle
jar {
manifest {
attributes 'Timestamp': String.valueOf(System.currentTimeMillis())
attributes 'Implementation-Title': 'github.com/wangfei1975/superlog',
'Implementation-Version': version
}
doFirst {
println("Creating JAR file: " + myjar.archivePath);
}
}
tasks.myjar.doLast() {
println 'Done'
}
task deploy(dependsOn: myjar) << {
println("Deploying Jar to location: " + removeLastChar(new File(DEPLOY_DIR).getAbsolutePath()) + myjar.archiveName);
copy {
from myjar.archivePath
into DEPLOY_DIR
}
}
task docs() << {
println()
println("==================================================================")
println("To execute: ")
println("cd " + removeLastChar(new File(DEPLOY_DIR).getAbsolutePath()))
println("java -jar " + myjar.archiveName);
println("==================================================================")
}
def removeLastChar(String specifiedString) {
if (specifiedString == null)
throw new GradleException("Specified String is NULL!");
if (specifiedString.length() == 0)
throw new GradleException("Specified String is empty!");
return specifiedString.substring(0, specifiedString.length()-1);
}