-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
169 lines (123 loc) · 3.4 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
// build file here
apply plugin: 'java'
apply plugin: 'findbugs'
apply plugin: 'maven'
def env = System.getenv()
//
// I defaults valgono per HUDSON
//
project.ext {
webapp_name = 'ObjectiveSync'
app_version = '0.1.4'
build_number = env["BUILD_NUMBER"]
version_class = 'ch/loway/oss/ObjectiveSync/CS.java'
build_time = "" + new Date()
}
repositories {
mavenCentral()
}
configurations {
ObjSync
}
dependencies {
ObjSync( 'mysql:mysql-connector-java:5.1.30' )
ObjSync( 'org.slf4j:slf4j-jdk14:1.7.7' )
ObjSync( 'com.h2database:h2:1.4.178' )
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.7'
testCompile 'junit:junit:4.10'
testCompile 'org.slf4j:slf4j-jdk14:1.7.7'
testCompile 'mysql:mysql-connector-java:5.1.30'
testCompile 'com.h2database:h2:1.4.178'
}
task solveDeps << {
copy {
from configurations.ObjSync
into "$buildDir/dependencies"
include '**/*.jar'
}
}
sourceSets {
main {
java {
srcDirs "$buildDir/classes_subst"
}
}
test {
java {
srcDirs "./tests"
}
}
}
task writeNewPom << {
pom {
project {
groupId 'ch.loway.oss.ObjectiveSync'
artifactId 'ObjectiveSync'
version project.ext.app_version
inceptionYear '2014'
licenses {
license {
name 'GNU LGPL v3'
}
}
}
}.writeTo("$buildDir/libs/ObjectiveSync-" + project.ext.app_version + ".pom")
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from "$buildDir/classes_subst"
archiveName project.ext.webapp_name + "-" + project.ext.app_version + "-sources.jar"
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
archiveName project.ext.webapp_name + "-" + project.ext.app_version + "-javadoc.jar"
}
jar {
manifest {
attributes("Implementation-Title": project.ext.webapp_name,
"Implementation-Version": project.ext.app_version)
}
archiveName project.ext.webapp_name + "-" + project.ext.app_version + ".jar"
from( "$buildDir/classes_subst" )
}
jar.dependsOn writeNewPom
jar.dependsOn sourcesJar
jar.dependsOn javadocJar
task setVersionInSources() {
doLast {
def cjd = new File( "$buildDir/classes_subst" )
cjd.mkdirs();
def FileTree tree = fileTree( dir: "./classes" )
//tree.each { File file -> println file }
copy {
from './classes'
into "$buildDir/classes_subst"
}
ant.replace( file: "$buildDir/classes_subst/" + project.ext.version_class,
token: "VERSION",
value: "VERSION = \"" + project.ext.app_version + "\"; //"
)
ant.replace( file: "$buildDir/classes_subst/" + project.ext.version_class,
token: "BUILD_N",
value: "BUILD_N = \"" + project.ext.build_number + " - " + project.ext.build_time + "\"; //"
)
}
}
compileJava.dependsOn setVersionInSources
// decide what to see -only one can be enabled
// get the HTML report from build/reports/findbugs/main.html
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
ignoreFailures = true
}
// Force sources to 1.5
compileJava {
sourceCompatibility="1.5"
targetCompatibility="1.5"
}