forked from mapfish/mapfish-print
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
429 lines (362 loc) · 13.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
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
import org.gradle.api.plugins.jetty.JettyRun
group = 'org.mapfish.print'
version = '2.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'project-report'
defaultTasks 'test', 'jar', 'war', 'imageMagickWar', 'standalone', 'install'
repositories {
mavenRepo url: "http://download.osgeo.org/webdav/geotools"
mavenCentral()
mavenRepo url: "http://www.ibiblio.org/maven2"
}
configurations {
compile.transitive = true
proguard
}
dependencies {
def springVersion = "3.1.0.RELEASE"
compile ("org.springframework:spring-context:$springVersion","org.springframework:spring-web:$springVersion",'com.lowagie:itext:2.1.5', 'xerces:xercesImpl:2.4.0', 'org.json:json:20080701', 'org.jyaml:jyaml:1.3',
'xalan:xalan:2.7.0', 'log4j:log4j:1.2.14', 'com.vividsolutions:jts:1.8',
"org.mapfish.geo:mapfish-geo-lib:1.2.0", 'commons-httpclient:commons-httpclient:3.1',
'org.geotools:gt-epsg-hsql:8.6','org.apache.pdfbox:pdfbox:1.6.0', 'javax.media:jai_core:1.1.3',
'javax.media:jai_imageio:1.1', 'javax.media:jai_codec:1.1.3')
compile ('org.apache.xmlgraphics:batik-transcoder:1.7'){
exclude module: 'fop'
}
providedCompile 'javax.servlet:servlet-api:2.5'
testCompile ('junit:junit:4.7', 'org.mockito:mockito-core:1.9.5')
proguard 'net.sf.proguard:proguard:4.4'
}
def gitRevision() {
try {
def cmd = "git rev-parse HEAD"
def proc = cmd.execute()
return proc.getText()
} catch (Exception e) {
return "Error occurred while trying to execute git commandline tool: "+e
}
}
manifest.mainAttributes(
'Main-Class':'org.mapfish.print.ShellMapPrinter',
'Build-Time': new Date().getDateTimeString(),
'git-revision': gitRevision())
sourceCompatibility = 1.6
targetCompatibility = 1.6
compileJava.options.compilerArgs = ['-Xlint:deprecation', '-Xlint:unchecked']
jar {
enabled = true
baseName = "print-lib"
}
war {
baseName = "print-servlet"
manifest.mainAttributes(
'Build-Time': new Date().getDateTimeString(),
'git-revision': gitRevision())
}
task imageMagickWar (type: War) {
baseName = "print-servlet"
manifest.mainAttributes(
'Build-Time': new Date().getDateTimeString(),
'git-revision': gitRevision())
classifier = "IMG-MAGICK"
from fileTree('sample-spring/imagemagick')
}
task standalone (type: Jar) {
baseName = "print-standalone"
manifest = jar.manifest
from sourceSets.main.output
def dependencies = configurations.compile.resolve().findAll{ file ->
return !file.name.contains("servlet-api")
}
def serviceDir = new File("$buildDir/META-INF/services")
def metaInfDir = new File("$buildDir/META-INF/")
for(file in dependencies) {
def files = zipTree(file).matching {
exclude 'META-INF/**'
exclude 'LICENSE'
}
from files
}
doFirst {
serviceDir.deleteDir()
serviceDir.mkdirs()
for(file in dependencies.findAll({it.name.matches("((gt)|(spring-)).*")})) {
zipTree(file).matching {
include 'META-INF/services/*'
include 'META-INF/spring.*'
}.each {f ->
def base = serviceDir
if (f.name.startsWith("spring")) {
base = metaInfDir;
}
new File(base,f.name) << f.getText("UTF-8")
}
}
}
from fileTree(buildDir).matching{include 'META-INF/*'}
into ""
}
task libJavadocJar(type: Jar, dependsOn: javadoc) {
baseName = 'print-lib'
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task libSourcesJar(type: Jar) {
baseName = 'print-lib'
from sourceSets.main.allSource
classifier = 'sources'
}
task standaloneJavadocJar(type: Jar, dependsOn: javadoc) {
baseName = 'print-standalone'
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task standaloneSourcesJar(type: Jar) {
baseName = 'print-standalone'
from sourceSets.main.allSource
classifier = 'sources'
}
task show << {
// sourceSets.main.classes.asFileTree.each {println it}
println gitRevision()
}
artifacts {
archives jar, war, imageMagickWar, standalone, libSourcesJar, libJavadocJar, standaloneSourcesJar, standaloneJavadocJar
}
def artifactFilterMapping = ['lib':'print-lib', 'standalone':'print-standalone', 'war':'print-servlet']
configure(install.repositories.mavenInstaller) {
artifactFilterMapping.each {entry ->
addFilter(entry.key) { artifact, file ->
artifact.name.contains entry.value
}
}
}
/*
* This upload Archives configuration I took from:
* http://jedicoder.blogspot.ch/2011/11/automated-gradle-project-deployment-to.html
*
* For deploying see section about "Create a gradle properties file"
*/
// need to sign jars for uploading releases to maven central
if (Boolean.parseBoolean(enablePublishing)) {
apply plugin: 'signing'
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://$host/service/local/staging/deploy/maven2") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
snapshotRepository(url: "https://$host/content/repositories/snapshots") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
uniqueVersion = false
}
artifactFilterMapping.each {entry ->
addFilter(entry.key) { artifact, file ->
artifact.name.contains entry.value
}
}
pom('lib').project {
name 'print-lib'
packaging 'jar'
description 'Library for generating PDFs and images from oneline webmapping services'
}
pom('war').project {
name 'print'
packaging 'war'
description 'Web application for generating PDFs and images from oneline webmapping services'
}
pom('standalone').project {
name 'print-standalone'
packaging 'jar'
description 'Application for generating PDFs and images from oneline webmapping services. All dependencies are included'
}
artifactFilterMapping.keySet().each { filterName ->
pom(filterName).project {
url 'http://www.mapfish.org/doc/print/'
scm {
url 'scm:git@github.com:mapfish/mapfish-print.git'
connection 'scm:git@github.com:mapfish/mapfish-print.git'
developerConnection 'scm:git@github.com:mapfish/mapfish-print.git'
}
licenses {
license {
name 'GNU General Public License'
url 'http://www.gnu.org/licenses/#GPL'
distribution 'repo'
}
}
developers {
developer {
id 'jesseeichar'
name 'Jesse Eichar'
}
developer {
id 'geekdenz'
name 'Tim-Hinnerk Heuer'
}
}
mailingLists {
mailingList {
name ='Users'
subscribe='users-subscribe@mapfish.org'
unsubscribe='users-subscribe@mapfish.org'
post='users@mapfish.org'
archive='http://www.mapfish.org/pipermail/users/'
}
mailingList {
name ='Dev'
subscribe='dev-subscribe@mapfish.org'
unsubscribe='dev-subscribe@mapfish.org'
post='dev@mapfish.org'
archive='http://www.mapfish.org/pipermail/dev/'
}
}
}
}
}
}
}
} else {
uploadArchives << {
throw new IllegalStateException("Cannot upload archives because enablePublishing property is not true. It is $enablePublishing")
}
}
/*
uploadArchives << {
def ssl = new SSL()
repositories.mavenDeployer {
pom.project {
licenses {
license {
name 'GNU General Public License V3'
url 'http://www.gnu.org/licenses/'
}
}
}
name = 'dev.mapfish.org deployer'
configuration = configurations.deployerJars
logger.debug("Using ${ssl.privateKey()} for privateKey file")
logger.debug("Using ${ssl.passphrase()} for privateKey passphrase")
repository(url: "scp://dev.mapfish.org/var/www/dev.mapfish.org/htdocs/maven/repository") {
authentication( userName: "admin", privateKey: ssl.privateKey(), passphrase: ssl.passphrase())
}
snapshotRepository(url: "scp://dev.mapfish.org/var/www/dev.mapfish.org/htdocs/maven/repository") {
authentication( userName: "admin", privateKey: ssl.privateKey(), passphrase: ssl.passphrase())
uniqueVersion = false
}
}
}*/
def prop(key) {
return System.getProperty(key) == null ? null : "--${key}=${System.getProperty(key)}"
}
task run(dependesOn: compileJava) << {
def warning = """[WARNING] config parameter is required.
Usage:
gradle run -Dconfig={value} [-Dspec={value}] [-Dverbose={value}] [-Doutput={value}] [-DclientConfig] [-Dreferer={value}] [-Dlog4jConfig={value}]
Params:
-Dconfig={String}: Filename for the configuration (templates&CO)
-Dspec={String}: The location of the description of what has to be printed. By default, STDIN (defaults to [null])
-Dverbose={int}: Used only if log4jConfig is not specified. 3 if you want everything, 2 if you want the debug information (stacktraces are shown), 1 for infos and 0 for only warnings and errors (defaults to [1])
-Doutput={String}: The destination file. By default, STDOUT (defaults to [null])
-DclientConfig={on|off}: Get the config for the client form. Doesn't generate a PDF (defaults to [off])
-Dreferer={String}: Referer address to use when doing queries (defaults to [null])
-Dlog4jConfig={String}: Property file for the log4j configuration (defaults to [null])
Example:
gradle run -Dconfig=samples/config.yaml -Dspec=samples/spec.json -Doutput=/tmp/print-out.pdf
"""
def args = [prop("config"),prop("spec"),prop("output"),prop("verbose"),prop("clientConfig"),prop("referer"),prop("log4jConfig")]
if(prop("config") == null) {
println(warning)
} else {
ant.java(classname: 'org.mapfish.print.ShellMapPrinter', fork: false, logError: false,
classpath: "${sourceSets.main.runtimeClasspath.asPath}") {
for(a in args.findAll {it!=null}){
arg(value: a)
}
}
}
}
run.description = 'Run mapfish print from commandline. All commandline parameters apply. Execute task without system parameters to get help'
jettyRun {
httpPort = 8080
scanTargets = (fileTree("src/main/").include("webapp/WEB-INF/**") + fileTree(compileJava.destinationDir)).files
reload = 'manual'
}
task jettyRunImgMgk (type: JettyRun) {
description = 'Run mapfish-print within jetty with the imagemagick format installed'
httpPort = 8080
def imgMagickSpring = file("sample-spring/imagemagick/WEB-INF/classes/imagemagick-spring-application-context-override.xml")
scanTargets = (fileTree("src/main/").include("webapp/WEB-INF/**") + fileTree(compileJava.destinationDir)).files
reload = 'manual'
def tmpFile = file("src/main/webapp/WEB-INF/classes/imagemagick-spring-application-context-override.xml")
tmpFile.deleteOnExit()
doFirst {
//tmpFile.createNewFile()
tmpFile << imgMagickSpring.bytes
}
doLast {
tmpFile.delete()
}
}
/*
This task is not ready for prime time. I do not know what parameters the class expects
task runWarTest(dependsOn: jettyRunWar) << {
description = "run load test on embedded jetty"
try {
testServer = System.properties('testServer') :?
def constructor
ant.java(
classname: 'integration.HeavyLoad', fork:false,
classpath: "${configurations.testCompile.asPath}")
{
arg(value: "http://localhost:$httpPort/print")
arg(value: "samples/spec.json")
}
} finally {
jettyStop.execute()
}
}*/
def proguardConfig = file("$buildDir/proguardconfig.pro")
def proguardOutput = file("$buildDir/standalone.min.jar")
task generateProguardConfigFile << {
logger.info('Creating proguard configuration file for obfsucate task')
proguardConfig.withWriter{
writer ->
writer << "-injars ${standalone.archivePath}\n"
writer << "-outjars ${proguardOutput}\n"
writer << '-printseeds\n'
writer << '-dontskipnonpubliclibraryclasses\n'
writer << '-dontskipnonpubliclibraryclassmembers\n'
writer << '-keepclasseswithmembers public class * {\n'
writer << ' public static void main(java.lang.String[]);\n'
writer << '}\n'
// writer << '-optimizations !code/simplification/cast' + '\n'
writer << '-allowaccessmodification\n'
}
}
task minify(dependsOn: [generateProguardConfigFile]) << {
inputs.file standalone.archivePath
outputs.file proguardOutput
ant.taskdef(resource: 'proguard/ant/task.properties',
classpath: configurations.proguard.asPath )
ant.proguard(configuration: proguardConfig)
}
minify.description = 'Minify standalone jar, not yet functioning'
/*
task debug(type: JettyRun) {
//httpPort = 8080
scanTargets = (fileTree("src/main/").include("webapp/WEB-INF/**") + fileTree(compileJava.destinationDir)).files
reload = 'manual'
jettyConfig = file('jetty-debug.xml')
//jettyEnvXml = file('jetty-debug.xml')
}
*/