-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
321 lines (283 loc) · 8.61 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
plugins {
id "java"
id "maven"
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'org.asciidoctor.jvm.pdf' version '3.3.2'
}
version '7.3.4'+System.getProperty('release','-SNAPSHOT')
group 'ch.interlis'
sourceCompatibility = "1.6"
targetCompatibility = "1.6"
compileJava.options.encoding = 'US-ASCII'
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
maven {
url "http://jars.interlis.ch"
}
}
Properties properties = new Properties()
File propFile=project.rootProject.file('user.properties')
if(propFile.exists()){
properties.load(propFile.newDataInputStream())
}
def git = System.getProperty('git',properties.get('git','git'))
def windir = System.getProperty('windir',properties.get('windir',""))
def wix_candle = System.getProperty('wix_candle',properties.get('wix_candle','candle.exe'))
def wix_light = System.getProperty('wix_light',properties.get('wix_light','light.exe'))
def repos_pwd = System.getProperty('repos_pwd',properties.get('repos_pwd','repos_pwd'))
def repos_usr = System.getProperty('repos_usr',properties.get('repos_usr','repos_usr'))
def repos_url = System.getProperty('repos_url',properties.get('repos_url','repos_url'))
def downloads_pwd = System.getProperty('downloads_pwd',properties.get('downloads_pwd','downloads_pwd'))
def downloads_usr = System.getProperty('downloads_usr',properties.get('downloads_usr','downloads_usr'))
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine git, 'rev-parse', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
def generatedResources = "$buildDir/generated-resources/main"
def extractedIli2cJar = "$buildDir/ili2cJar"
def extractedJtsJar = "$buildDir/jtsJar"
sourceSets {
main {
output.dir(generatedResources, builtBy: 'generateMyResources')
java {
srcDirs = ['src']
}
compileClasspath += project.configurations.compileOnly
}
}
task generateMyResources {
def versionPropsFile = new File(generatedResources,"ch/interlis/ili2fme/Version.properties")
def version="$project.version"
def hash=getGitHash()
inputs.property("version","$project.version")
inputs.property("hash",getGitHash())
outputs.files "$versionPropsFile"
doLast {
def versionProps = new Properties()
versionProps.setProperty('version', version)
versionProps.setProperty('versionCommit', hash)
versionPropsFile.getParentFile().mkdirs();
versionProps.store(versionPropsFile.newWriter(), null);
}
}
configurations {
deployerJars
ftpAntTask
ili2cTool { transitive = false }
jtsJar { transitive = false }
}
dependencies {
implementation group: 'ch.interlis', name: 'iox-ili', version: '1.23.3'
implementation group: 'ch.interlis', name: 'ili2c-tool', version: "5.6.2"
implementation group: 'ch.interlis', name: 'ili2c-core', version: "5.6.2"
compileOnly "com.vividsolutions:jts-core:1.14.0"
compileOnly files("lib/pluginbuilder.jar")
jtsJar "com.vividsolutions:jts-core:1.14.0"
ili2cTool("ch.interlis:ili2c-tool:5.6.2"){
artifact {
//useful when some artifact properties unconventional
name = 'ili2c-tool' //artifact name different than module name
extension = 'zip'
type = 'zip'
classifier = 'bindist'
}
}
deployerJars "org.apache.maven.wagon:wagon-ftp:3.3.3"
deployerJars "org.apache.maven.wagon:wagon-ssh:3.3.3"
ftpAntTask "org.apache.ant:ant-commons-net:1.10.7"
}
jar {
enabled = true
manifest {
attributes(
"Main-Class": 'ch.interlis.ili2fme.AboutDialog',
"Class-Path": 'ili2c.jar jts-core-1.14.0.jar'
)
}
}
asciidoctor {
sourceDir file('docs')
outputDir file('build/docs')
resources {
from('docs') {
include 'media/*.png'
}
}
}
asciidoctorPdf {
sourceDir file('docs')
sources {
include 'ili2fme.adoc' //, 'another.adoc', 'third.adoc'
}
//options '-o': 'test.pdf'
//attributes '-o' : 'test.pdf'
outputDir file('build/docs')
baseDirFollowsSourceDir()
/*attributes {
imagesdir= 'docs'
//'imagesoutdir' => './images'
} */
}
task getIli2cToolJar(type: Copy){
from {
zipTree(configurations.ili2cTool.singleFile).matching { include '**/ili2c.jar' }.singleFile
}
into "$extractedIli2cJar"
}
task getJtsJar(type: Copy){
from {
configurations.jtsJar.singleFile
}
into "$extractedJtsJar"
}
compileJava.dependsOn getIli2cToolJar
task bindist(type: Zip,dependsOn: getJtsJar){
group = BasePlugin.BUILD_GROUP
description = 'Assembles the binary distribution of this project'
baseName = project.name
destinationDir = file('dist')
def fme="FME Suite"
from(jar) {
rename '.+','ili2fme.jar'
into "${fme}/plugins/"
}
from(getIli2cToolJar){
into "${fme}/plugins/"
}
from(getJtsJar){
into "${fme}/plugins/"
}
from("other"){
include "ch.ehi.fme.Main.fmf"
into "${fme}/metafile/"
}
from("other"){
include "interlis2.db"
into "${fme}/formatsinfo/"
}
from("other"){
include "ilimodels/*.ili", "ili22models/*.ili","converter/*.fmi","iligml/**/*.xsd"
into "${fme}/plugins/interlis2/"
}
from ("$projectDir"){
include "docs/LICENSE.*","docs/README.txt","docs/CHANGELOG.txt","docs/interlis2.pdf"
}
}
task('msi',dependsOn: getJtsJar) {
group = BasePlugin.BUILD_GROUP
description = 'Assembles the MSI distribution of this project'
def msiFile = new File("dist","${project.name}-${project.version}.msi")
outputs.files "$msiFile"
doLast {
def strippedVersion="${project.version}".replace("-SNAPSHOT","")
def basedir=projectDir
def candleCmd=["${wix_candle}", "-v", "-arch=x64", "-dversion=$strippedVersion", "-dbasedir=${basedir}", "-out", "OUT/ILI2FME.WIXOBJ", "setup/ili2fme.wxs"]
def lightCmd=["${wix_light}","-v", "-sval","-b", "setup", "-pdbout", "OUT/ILI2FME.WIXPDB", "-out", "$msiFile", "OUT/ILI2FME.WIXOBJ"]
if(windir==""){
candleCmd.add(0,"wine")
lightCmd.add(0,"wine")
}
copy {
from jar
into 'build/jar'
rename '.+','ili2fme.jar'
}
exec {
commandLine candleCmd
}
exec {
commandLine lightCmd
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
from ('.'){
include 'docs/*.adoc'
include 'docs/media/*.png'
}
}
javadoc{
failOnError = false
options.addBooleanOption 'Xdoclint:none', true
//options.addStringOption('Xdoclint:none', '-quiet')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
archives(bindist.archivePath) {
type 'zip'
classifier 'bindist'
builtBy bindist
}
archives(files(msi.outputs).singleFile) {
type 'msi'
classifier 'bindist'
builtBy msi
}
}
def githubRepoUrl = 'https://github.com/claeis/ili2fme'
def pomConfig = {
licenses {
license {
name "LGPL 2.1"
url "https://github.com/claeis/ili2fme/blob/master/docs/LICENSE.lgpl"
}
}
developers {
developer {
id "claeis"
name "Claude Eisenhut"
email "[email protected]"
}
}
scm {
url githubRepoUrl
}
}
uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
repository(url: repos_url){
authentication(userName: repos_usr, password: repos_pwd)
}
}
}
}
task uploadBin(dependsOn: [bindist,msi,asciidoctorPdf]) {
doLast {
new File("$buildDir/docs/ili2fme.pdf").renameTo("$buildDir/docs/ili2fme-${project.version}.pdf")
ant.taskdef(name: 'ftp',
classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
classpath: configurations.ftpAntTask.asPath)
def dist= bindist.archiveFile.get().asFile.parent
def name=bindist.archiveFile.get().asFile.name
def json = groovy.json.JsonOutput.toJson([filename: 'https://downloads.interlis.ch/ili2fme/'+name, version: project.version ,date: new Date().format( 'yyyy-MM-dd' )])
def releaseFile = new File(dist,project.name+"-release.json")
releaseFile.write(json)
ant.ftp(server: "jql.ftp.infomaniak.com", userid: downloads_usr, password: downloads_pwd,
remoteDir: "/ili2fme", passive:"yes") {
fileset(dir: dist ) {
include(name: name)
include(name: releaseFile.name)
include(name: "${project.name}-${project.version}.msi")
}
fileset(dir: "$buildDir/docs/" ) {
include(name: "ili2fme-${project.version}.pdf")
}
}
}
}