-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle
183 lines (160 loc) · 5.06 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
group 'ch.interlis'
version '1.23.4'+System.getProperty('release','-SNAPSHOT')
apply plugin: "java"
apply plugin: "maven"
configurations {
deployerJars
}
//configurations.all {
// check for updates every build
// resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
//}
//System.out.println JavaVersion.current()
compileJava.options.encoding = 'US-ASCII'
if(!JavaVersion.current().isJava8()){
compileJava.options.compilerArgs.addAll(['--release', '6'])
}else{
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
}
//compileJava.options.compilerArgs << '-Xlint:unchecked'
//compileJava.options.deprecation = true
dependencies {
compile group: 'ch.ehi', name: 'ehibasics', version: '1.3.0'
compile group: 'ch.interlis', name: 'iox-api', version: '1.0.3'
compileOnly group: 'antlr', name: 'antlr', version: '2.7.6'
compile group: 'com.vividsolutions', name: 'jts-core', version: '1.14.0'
compile group: 'net.iharder', name: 'base64', version: '2.3.9'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testCompile group: 'org.xmlunit',name: 'xmlunit-matchers',version: '2.5.1'
testCompile group: 'org.xmlunit', name: 'xmlunit-core',version: '2.5.1'
compileOnly group: 'ch.interlis', name: 'ili2c-core', version: '5.5.4'
testImplementation (group: 'ch.interlis', name: 'ili2c-tool', version: '5.5.4'){
exclude group: 'ch.interlis', module: 'iox-ili'
}
testImplementation group: 'ch.interlis', name: 'ili2c-core', version: '5.5.4'
deployerJars "org.apache.maven.wagon:wagon-ftp:3.5.1"
deployerJars "org.apache.maven.wagon:wagon-ssh:3.5.1"
}
repositories {
mavenLocal()
maven {
url "http://jars.interlis.ch"
}
mavenCentral()
}
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 dburl = System.getProperty('dburl',properties.get('dburl'))
def dbusr = System.getProperty('dbusr',properties.get('dbusr'))
def dbpwd = System.getProperty('dbpwd',properties.get('dbpwd'))
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 {
//let's register an output folder on the main SourceSet:
//it is now a part of the 'main' classpath and will be a part of the jar
output.dir(generatedResources, builtBy: 'generateMyResources')
java {
srcDirs=['src/main/java'
,'gensrc'
,'jtsext/src/main/java'
]
}
}
test {
java {
srcDirs=[ 'src/test/java'
,'jtsext/src/test/java'
]
}
}
}
task generateMyResources {
def versionPropsFile = new File(generatedResources,"ch/interlis/iox_j/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 validateOnlyAsciiChars(File file) {
byte[] contents = file.bytes
for(byte b:contents){
if(b==9 || b==10 || b==13){
// tab, lf, cr
}else if(b>=32 && b<=126){
// printable character
}else{
//println 'special char '+b
return false
}
}
return true
}
task validateJavaSources{
boolean filesOk=true;
sourceSets.main.java.each { File file ->
if(!validateOnlyAsciiChars(file)){
logger.error(file.name+" contains non ascii characters")
filesOk=false
}
}
sourceSets.test.java.each { File file ->
if(!validateOnlyAsciiChars(file)){
logger.error(file.name+" contains non ascii characters")
filesOk=false
}
}
if(!filesOk){
throw new GradleException('some files in sourceSets are not valid')
}
}
task writePom {
doLast {
pom {
project {
}
}.writeTo("$buildDir/poms/iox-ili.xml")
}
}
test {
// when Gradle forks a new Java process, it does not automatically pass the
// environment variable values along to the new environment. One has to
// explicitly pass these variables
systemProperty 'dburl', dburl
systemProperty 'dbusr', dbusr
systemProperty 'dbpwd', dbpwd
testLogging.exceptionFormat = 'full'
}
uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
repository(url: 'ftp://ftp.interlis.ch'){
authentication(userName: repos_usr, password: repos_pwd)
}
}
}
}