-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
264 lines (228 loc) · 8.55 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
import java.security.cert.Extension;
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'signing'
group = 'org.opensextant'
version = '2.0.2-SNAPSHOT'
ext.isReleaseVersion = !version.endsWith('-SNAPSHOT')
sourceCompatibility = 1.7
ext.publish = [user: null, password: null]
// Publishing locations and associated variables
if (project.hasProperty('ospubLocaldest')) {
ext.oss_snapshot = ospubLocaldest
ext.publish.user = mavenUser
ext.publish.password = mavenPassword
} else {
ext.oss_snapshot = "https://oss.sonatype.org/content/repositories/snapshots"
ext.publish.user = project.hasProperty('ospubUsername') ? ospubUsername : null
ext.publish.password = project.hasProperty('ospubPassword') ? ospubPassword : null
}
def oss_staging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
repositories {
[ mavenCentral(), maven { url oss_snapshot } ]
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'commons-io:commons-io:1.4'
}
}
configurations {
provided
compile { compile.extendsFrom provided
description = 'These modules are needed at compile time and runtime' }
runtime { extendsFrom compile
description = 'These modules are only needed at runtime' }
test { extendsFrom runtime
description = 'Include these in addition when testing' }
jni { extendsFrom compile
description = 'Output of compilation used for creating jni headers' }
}
sourceSets {
main { compileClasspath += configurations.provided }
}
dependencies {
def slf4j_version = '1.7.2'
compile group: 'org.opensextant', name: 'geodesy', version: '[2.0.0,2.1)'
compile group: 'commons-lang', name: 'commons-lang', version: '2.5'
compile group: 'commons-io', name: 'commons-io', version: '1.4'
// compile group: 'stax', name: 'stax-api-osgi', version: '1.0.1'
compile group: 'org.slf4j', name: 'slf4j-api', version: slf4j_version
testRuntime group: 'org.slf4j', name: 'slf4j-simple', version: slf4j_version
provided group: 'log4j', name: 'log4j', version: '[1.2.0,1.3)'
testCompile group: 'findbugs', name: 'annotations', version: "1.0.0"
testCompile 'org.mortbay.jetty:jetty:6.1.26'
testCompile 'junit:junit:4.11'
jni files(dir: "build/libs", include: 'giscore-' + version + '.jar')
}
eclipse {
project {
name = 'giscore'
natures 'org.springsource.ide.eclipse.gradle.core.nature',
'org.eclipse.jdt.groovy.core.groovyNature'
}
classpath {
plusConfigurations += configurations.test
}
}
test {
exclude 'org/opensextant/giscore/test/TestTransfusionFields*'
exclude 'org/opensextant/giscore/test/TestSorterOutputStream*'
exclude 'org/opensextant/giscore/test/filegdb/**'
exclude 'org/**/*GDB*'
exclude 'org/**/*Gdb*'
}
ext.IOUtils = Class.forName("org.apache.commons.io.IOUtils")
def packageLibrary(name, libname, packagen, osn, extn, pre = "") {
def libdir = new java.io.File(sourceSets.main.output.classesDir, packagen)
libdir = new java.io.File(libdir, osn)
def lib = "$libname"
def inputFile = new File(projectDir, lib)
task "$name" {
description = "Packages the native code for $osn"
// Inputs and outputs
inputs.file inputFile
outputs.dir libdir
doLast {
// Make output directory
if (! libdir.exists()) libdir.mkdirs()
// Create and write property file
def propfile = new java.io.File(libdir, "filegdb.properties")
def taskname = "$name"
def packageName = "$packagen"
def os = "$osn"
def extension = "$extn"
def prefix = "$pre"
def props = new java.util.Properties()
def writer = new java.io.FileWriter(propfile)
def libfile = prefix + "filegdb." + extension
def formatter = new java.text.SimpleDateFormat("yyyy/MM/dd")
props.setProperty("modified", formatter.format(new java.util.Date()))
props.setProperty("filename", libfile)
props.store(writer, "Automatically generated file, do not edit")
IOUtils.closeQuietly(writer)
// Copy library into place
def fromis = new java.io.FileInputStream(inputFile)
def toos = new java.io.FileOutputStream(new java.io.File(libdir, libfile))
IOUtils.copy(fromis, toos)
IOUtils.closeQuietly(fromis)
IOUtils.closeQuietly(toos)
}
}
}
packageLibrary("packageWin64", "filegdb/win64/filegdb/x64/Release/filegdb.dll",
"org/opensextant/giscore/filegdb", "win64", "dll")
packageLibrary("packageLinux", "filegdb/linux/filegdb/dist/Release/GNU-Linux-x86/libfilegdb.so",
"org/opensextant/giscore/filegdb", "linux64", "so", "lib")
packageLibrary("packageMacOS", "filegdb/osx/filegdb/x64/Release/libfilegdb.dylib",
"org/opensextant/giscore/filegdb", "mac64", "dylib", "lib")
test.dependsOn packageWin64, packageLinux, packageMacOS
jar.dependsOn packageWin64, packageLinux, packageMacOS
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
/* This task is not yet working */
task createJni(dependsOn: jar) << {
ant.javah(destdir: "build/jni", classpath: configurations.jni.asPath) {
ant.class(name: 'org.opensextant.giscore.filegdb.Geodatabase')
ant.class(name: 'org.opensextant.giscore.filegdb.Table')
ant.class(name: 'org.opensextant.giscore.filegdb.Row')
ant.class(name: 'org.opensextant.giscore.filegdb.EnumRows')
}
}
/*
This needs to be converted to Gradle
<target name="api-compatibility" depends="jar" description="Compare the latest build to the previous version to detect API changes.">
<ivy:cachepath pathid="clirr.path" organisation="net.sf.clirr" module="clirr-core" revision="0.6-mitre" conf="default" inline="true"/>
<taskdef resource="clirrtask.properties" classpathref="clirr.path" />
<fail unless="previous.revision" message="The previous.revision property was not set, could not load the last release for API comparison."/>
<ivy:retrieve inline="true" conf="default" organisation="org.opensextant" module="giscore" revision="${previous.revision}" sync="true" pattern="${build.previous}/[organization].[artifact]-[revision].[ext]" />
<property name="previous.jar" value="org.opensextant.giscore-${previous.revision}.jar"/>
<fail message="Could not find previous revision at ${build.previous}/${previous.jar}">
<condition>
<not>
<available file="${build.previous}/${previous.jar}"/>
</not>
</condition>
</fail>
<delete file="${build}/clirr.xml"/>
<clirr failOnBinError="false" failOnSrcError="false">
<origclasspath>
<fileset dir="${build.previous}">
<exclude name="${previous.jar}"/>
</fileset>
</origclasspath>
<newclasspath refid="project.classpath"/>
<origFiles dir="${build.previous}" includes="${previous.jar}"/>
<newFiles dir="${rel}/jars/" includes="giscore.jar"/>
<formatter type="xml" outfile="${build}/clirr.xml"/>
</clirr>
</target>
*/
jar {
baseName = "giscore"
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
signing {
required isReleaseVersion
sign configurations.archives
}
uploadArchives.doFirst {
// Check presets
if (publish.user == null || publish.password == null) {
throw new Exception('When uploading you must defined an appropriate user/password pair check the gradle file to see which pair (changes for snapshot)')
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: oss_staging) {
authentication(userName: publish.user, password: publish.password)
}
snapshotRepository(url: oss_snapshot) {
authentication(userName: publish.user, password: publish.password)
}
pom.project {
name 'giscore'
packaging 'jar'
description 'GIScore is a streaming IO library for geographic information system data formats'
url 'https://github.com/OpenSextant/giscore'
scm {
url 'scm:git://github.com/OpenSextant/giscore.git'
connection 'scm:[email protected]:OpenSextant/giscore.git'
developerConnection 'scm:[email protected]:OpenSextant/giscore.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'drand'
name 'Doug Rand'
}
developer {
id 'docjason'
name 'Jason Mathews'
}
}
}
}
}
}