forked from mapfish/mapfish-print
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
258 lines (205 loc) · 7.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
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
import com.camptocamp.gradle.plugin.*
import com.camptocamp.gradle.*
group = 'org.mapfish.print'
version = '1.2-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'project-report'
defaultTasks 'jar', 'war', 'standalone'
def MAPFISH_REPO='http://dev.mapfish.org/maven/repository'
repositories {
mavenRepo url: MAPFISH_REPO
mavenRepo url: "http://download.osgeo.org/webdav/geotools"
mavenRepo url: "http://www.ibiblio.org/maven2"
mavenCentral()
}
configurations {
deployerJars
compile.transitive = true
deployerJars.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',
'ch.thus:pvalsecc:0.9.2', 'xalan:xalan:2.7.0', 'log4j:log4j:1.2.14', 'com.vividsolutions:jts:1.8',
"org.mapfish.geo:mapfish-geo-lib:1.2-SNAPSHOT", 'commons-httpclient:commons-httpclient:3.1',
'org.geotools:gt-epsg-hsql:2.6.5','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'
deployerJars "org.apache.maven.wagon:wagon-ssh:1.0-beta-2"
proguard 'net.sf.proguard:proguard:4.4'
}
manifest.mainAttributes('Main-Class':'org.mapfish.print.ShellMapPrinter', 'Build-Time': new Date().getDateTimeString())
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())
}
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 {includes: ['META-INF/services/*','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 ""
}
println(standalone.inputs)
println(standalone.outputs)
task show << {
sourceSets.main.output.properties.each {println it}
}
artifacts {
archives jar, war, standalone
}
configure(install.repositories.mavenInstaller) {
addFilter('lib') { artifact, file ->
artifact.name.contains 'print-lib'
}
addFilter('standalone') { artifact, file ->
artifact.name.contains 'print-standalone'
}
addFilter('war') { artifact, file ->
artifact.name.contains 'print-servlet'
}
}
/*
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)
}
}
}
}
jettyRun {
httpPort = 8080
scanTargets = (fileTree("src/main/").include("webapp/WEB-INF/**") + fileTree(compileJava.destinationDir)).files
reload = 'manual'
}
/*
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)
}