-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.gradle
274 lines (249 loc) · 8.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
allprojects {
group 'ch.interlis'
apply plugin: "java"
apply plugin: "maven"
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
compileJava.options.encoding = 'US-ASCII'
}
version '1.14.6'+System.getProperty('release','-SNAPSHOT')
configurations {
deployerJars
ftpAntTask
}
// to get the latest SNAPSHOT uncomment the following lines
//configurations.all {
// check for updates every build
// resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
//}
dependencies {
compile group: 'ch.ehi', name: 'ehibasics', version: '1.4.1'
compile group: 'ch.interlis', name: 'iox-api', version: '1.0.4'
compile group: 'ch.interlis', name: 'iox-ili', version: '1.23.4'
compile group: 'ch.interlis', name: 'ili2c-tool', version: "5.6.3"
compile group: 'ch.interlis', name: 'ili2c-core', version: "5.6.3"
testCompile group: 'junit', name: 'junit', version: '4.12'
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"
//ftpAntTask "org.apache.ant:ant-commons-net:1.10.14"
ftpAntTask "org.apache.ant:ant-commons-net:1.9.16" // muss zu gradle builtin ant version passen!
testRuntime project('demoplugin')
}
repositories {
mavenLocal()
mavenCentral()
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 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 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 docs_pwd = System.getProperty('docs_pwd',properties.get('docs_pwd','docs_pwd'))
def docs_usr = System.getProperty('docs_usr',properties.get('docs_usr','docs_usr'))
def python= System.getProperty('python',properties.get('python','python'))
def rst2html= System.getProperty('rst2html',properties.get('rst2html','rst2html'))
def github_token= System.getProperty('github_token',properties.get('github_token','github_token'))
def html_outfile=new File(project.buildDir,'docs/ilivalidator.html')
def generatedResources = "$buildDir/generated-resources/main"
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine git, 'rev-parse', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
sourceSets {
main {
output.dir(generatedResources, builtBy: 'generateMyResources')
java {
srcDirs = ['src','gensrc']
}
resources {
srcDirs =[ 'src', 'resources']
include 'META-INF/native-image/**'
include "**/*.properties"
exclude "**/Version.properties"
}
}
test {
java {
srcDirs = ['test/src','pluginsrc']
}
resources {
srcDirs = ['test/data','plugins']
}
}
}
task generateMyResources {
def versionPropsFile = new File(generatedResources,"org/interlis2/validator/Version.properties")
def version="$project.version"
def hash=getGitHash()
inputs.property("version","$project.version")
inputs.property("hash",getGitHash())
outputs.file versionPropsFile
doLast {
def versionProps = new Properties()
versionProps.setProperty('version', version)
versionProps.setProperty('versionCommit', hash)
versionPropsFile.getParentFile().mkdirs();
versionProps.store(versionPropsFile.newWriter(), null);
}
}
def readChangeLog = { ->
def resp=""
def skip=false
def sec=0
new File("docs/CHANGELOG.txt").eachLine { line ->
if(line.startsWith("-------")){
sec++
}else{
if(sec==1){
if(skip){
}else{
if(line.trim()==""){
skip=true
}else{
resp+=line+"\n"
}
}
}
}
}
return resp
}
task readChanges {
doLast {
logger.quiet "----"
logger.quiet readChangeLog()
logger.quiet "----"
}
}
def createGithubReleaseFunc = { ->
def body = [tag_name:"$project.name-$project.version",name:"$project.name-$project.version",body:readChangeLog(),draft:false,prerelease:false,generate_release_notes:false]
def req = new URL("https://api.github.com/repos/claeis/$project.name/releases").openConnection()
req.setRequestMethod("POST")
req.setRequestProperty("Content-Type", "application/json; charset=UTF-8")
req.setRequestProperty("Accept", "application/vnd.github+json")
req.setRequestProperty("Authorization", "Bearer $github_token")
req.setRequestProperty("X-GitHub-Api-Version", "2022-11-28")
req.setDoOutput(true)
req.getOutputStream().write(groovy.json.JsonOutput.toJson(body).getBytes("UTF-8"))
if(req.getResponseCode()!=201){
logger.quiet "Status code: ${req.getResponseCode()}" // HTTP request done on first read
def resp = new groovy.json.JsonSlurper().parseText(req.getInputStream().getText())
logger.quiet "Response: ${resp}"
}
return
}
task createGithubRelease {
doLast {
createGithubReleaseFunc()
}
}
task usrdoc(type:Exec) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = 'Builds the user documentation (html)'
def infile=new File(project.projectDir,'docs/ilivalidator.rst')
inputs.file infile
outputs.file html_outfile
doFirst{
new File(project.buildDir,'docs').mkdir()
}
workingDir = project.buildDir
executable python
args = [rst2html, infile, html_outfile]
}
task bindist(type: Zip){
baseName = project.name
destinationDir = file('dist')
from jar
into('docs'){
from files(fileTree("docs").include("LICENSE.*"),"docs/README.txt","docs/CHANGELOG.txt","docs/Beispiel1.ili","docs/Beispiel1.ini","docs/Beispiel1.xtf","docs/IliVErrors.ili",html_outfile)
}
into('libs'){
from configurations.runtimeClasspath
//def jars=[]
//subprojects.each {
// jars+=it.libsDir
//}
//from jars
}
// version = '1.0.6'
}
jar {
manifest {
attributes(
"Main-Class": "org.interlis2.validator.Main",
"Class-Path": configurations.runtimeClasspath.collect { 'libs/'+it.getName() }.join(' '))
}
}
artifacts {
archives(bindist.archivePath) {
type 'zip'
classifier 'bindist'
builtBy bindist
}
archives(jar.archivePath){
builtBy jar
}
}
test {
testLogging.exceptionFormat = 'full'
}
uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
repository(url: 'ftp://ftp.interlis.ch'){
authentication(userName: repos_usr, password: repos_pwd)
}
}
}
}
task uploadBin(dependsOn: bindist) {
doLast {
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/ilivalidator/'+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: "/ilivalidator", passive:"yes") {
fileset(dir: dist ) {
include(name: name)
include(name: releaseFile.name)
}
}
createGithubReleaseFunc()
}
}
task uploadDoc(){ // dependsOn: [usrdoc,ilidoc]) {
doLast {
ant.taskdef(name: 'ftp',
classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
classpath: configurations.ftpAntTask.asPath)
def remoteDir="/ilivalidator/"+project.version
ant.ftp(action:"mkdir", server: "jql.ftp.infomaniak.com", userid: docs_usr, password: docs_pwd,
remoteDir: remoteDir, passive:"yes") {
}
ant.ftp(server: "jql.ftp.infomaniak.com", userid: docs_usr, password: docs_pwd,
remoteDir: remoteDir, passive:"yes") {
fileset(dir: "build/docs") {
include(name: "ilivalidator.html")
}
}
}
}