build.gradle 8.44 KB
Newer Older
felmer's avatar
felmer committed
1
apply from: '../gradle/javaproject.gradle'
2

3
group='sis'
brinn's avatar
brinn committed
4
5
sourceCompatibility='1.8'
targetCompatibility='1.8'
6
7
8
9
10
11
12
13
14
15

dependencies {
    compile 'cisd:cisd-args4j:+',
            'cisd:cisd-base:+',
            'rinn:restrictions:+'
    
    testCompile 'testng:testng:+',
                'jmock:jmock:+'
}

16
tasks.withType(Test) {
17
    systemProperty "java.library.path", "libs/native/jhdf5/amd64-Linux:libs/native/jhdf5/amd64-Linux:libs/native/jhdf5/x86_64-Mac OS X:libs/native/jhdf5/x86_64-Mac OS X"
18
}
anttil's avatar
anttil committed
19

anttil's avatar
anttil committed
20
21
22
23
24
25
26
27
28
// Eclipse Gradle plugin always uses the default JRE, so we need to explicitly set it to 1.7.
// (https://issues.gradle.org/browse/GRADLE-3100)
eclipse {
    classpath {
         containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
         containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7'
    }
}

29
jar {
30
    baseName "${project.group}-jhdf5-core"
31
32
33
    from (sourceSets.main.output.classesDir) { 
        exclude('ch/systemsx/cisd/hdf5/h5ar') 
        exclude('ch/systemsx/cisd/hdf5/io')
anttil's avatar
anttil committed
34
    }
35
36
37
    from('targets/dist') {
        include 'BUILD*INFO'
    }    
38
39
40
    manifest {
        attributes 'Main-Class': 'ch.systemsx.cisd.hdf5.BuildAndEnvironmentInfo'
        attributes 'Class-Path': configurations.runtime.collect { it.getName() }.join(' ')
anttil's avatar
anttil committed
41
    }
42
    
anttil's avatar
anttil committed
43
44
}

45
task nativeJarLinuxIntel(type: Jar) {
anttil's avatar
anttil committed
46
    archiveName 'hdf5-linux-intel.jar'
47
    from ("libs") {
anttil's avatar
anttil committed
48
49
        include 'native/jhdf5/amd64-Linux/**/*'
        include 'native/jhdf5/i386-Linux/**/*'
50
        include 'native/jhdf5/arm-Linux/**/*'
anttil's avatar
anttil committed
51
52
    }
    
53
54
55
    from('targets/dist') {
        include 'BUILD*INFO'
    }    
anttil's avatar
anttil committed
56
57
}

58
task nativeJarMacIntel(type: Jar) {
anttil's avatar
anttil committed
59
    archiveName 'hdf5-macosx-intel.jar'
60
    from ("libs") {
anttil's avatar
anttil committed
61
62
63
64
        include 'native/jhdf5/i386-Mac OS X/**/*'
        include 'native/jhdf5/x86_64-Mac OS X/**/*'
    }
    
65
66
67
    from('targets/dist') {
        include 'BUILD*INFO'
    }    
anttil's avatar
anttil committed
68
69
70
71
}

task nativeJarWindowsIntel(type: Jar) {
    archiveName 'hdf5-windows-intel.jar'
72
    from ("libs") {
anttil's avatar
anttil committed
73
74
75
76
        include 'native/jhdf5/amd64-Windows/**/*'
        include 'native/jhdf5/x86-Windows/**/*'
    }
    
77
78
79
    from('targets/dist') {
        include 'BUILD*INFO'
    }    
80
81
82
}

task toolsJar(type: Jar, dependsOn: [compileJava]) {
83
    baseName "${project.group}-jhdf5-tools"
84
85
86
87
    from (sourceSets.main.output.classesDir) {
        include('ch/systemsx/cisd/hdf5/h5ar/**/*') 
        include('ch/systemsx/cisd/hdf5/io/**/*') 
    }
88
89
90
91
    
    from('targets/dist') {
        include 'BUILD*INFO'
    }    
92
93
94
    
    manifest {
        attributes 'Main-Class': 'ch.systemsx.cisd.hdf5.h5ar.HDF5ArchiverMain'
95
        attributes 'Class-Path': configurations.runtime.collect { it.getName() }.join(' ') + " ${project.group}-jhdf5-core.jar " + [nativeJarLinuxIntel, nativeJarMacIntel, nativeJarWindowsIntel].collect {it.archiveName}.join(' ')
96
97
98
99
    }
}

task allJar(type: Jar, dependsOn: [compileJava]) {
100
    baseName "${project.group}-jhdf5"
101
102
103
104
105
106
107

    from (sourceSets.main.output.classesDir) {
        include '**/*'
    }

    from (configurations.runtime.collect {zipTree(it)}) {
        exclude 'native/**/*'
108
        exclude 'BUILD-*.INFO'
109
    }
110
111
112
113

    from('targets/dist') {
        include 'BUILD*INFO'
    }    
114
115
116
    
    manifest {
        attributes 'Main-Class': 'ch.systemsx.cisd.hdf5.h5ar.HDF5ArchiverMain'
117
        attributes 'Class-Path': [nativeJarLinuxIntel, nativeJarMacIntel, nativeJarWindowsIntel].collect {it.archiveName}.join(' ')
118
    }
anttil's avatar
anttil committed
119
120
}

121

122
task batteriesIncluded(type: Jar, dependsOn: [allJar, nativeJarLinuxIntel, nativeJarMacIntel, nativeJarWindowsIntel]) {
123
    archiveName "${project.group}-jhdf5-batteries_included.jar"
anttil's avatar
anttil committed
124
125
126
127
    from (zipTree(allJar.archivePath)) {
        include '**/*'
    }
    
128
129
130
131
    from (configurations.runtime.collect {zipTree(it)}) {
        include 'native/**/*'
    }

132
    from (zipTree(nativeJarLinuxIntel.archivePath)) {
anttil's avatar
anttil committed
133
134
        include 'native/**/*'
    }
135
    from (zipTree(nativeJarMacIntel.archivePath)) {
anttil's avatar
anttil committed
136
137
138
139
140
141
        include 'native/**/*'
    }
    from (zipTree(nativeJarWindowsIntel.archivePath)) {
        include 'native/**/*'
    }
    
142
143
144
    manifest {
        attributes 'Main-Class': 'ch.systemsx.cisd.hdf5.h5ar.HDF5ArchiverMain'
    }
anttil's avatar
anttil committed
145
146
}

brinn's avatar
brinn committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
task myJavadoc(type: Javadoc) {
	source = [ sourceSets.main.allJava, "base-src" ]
	classpath = configurations.compile
	options.memberLevel = JavadocMemberLevel.PUBLIC
	options.overview = "overview.html"
	include "ch/systemsx/cisd/hdf5/**"
	include "ncsa/hdf/hdf5lib/exceptions/**"
	exclude "ch/systemsx/cisd/hdf5/hdf5lib/**"
	exclude "ch/systemsx/cisd/hdf5/cleanup/**"
	exclude "ch/systemsx/cisd/hdf5/BitSetConversionUtils.java"
	exclude "ch/systemsx/cisd/hdf5/MatrixUtils.java"
	exclude "ch/systemsx/cisd/hdf5/StringUtils.java"
	exclude "ch/systemsx/cisd/hdf5/PaddingUtils.java"
	exclude "ch/systemsx/cisd/hdf5/ReflectionUtils.java"
}

task javadocZip(type: Zip, dependsOn: myJavadoc) {
164
    archiveName "${project.group}-jhdf5-javadoc.zip"
anttil's avatar
anttil committed
165
    from javadoc.destinationDir
166
167
}

anttil's avatar
anttil committed
168
task exampleZip(type: Jar) {
169
    archiveName "${project.group}-jhdf5-examples-src.zip"
anttil's avatar
anttil committed
170
171
172
173
174
175
176
177
178
179

    from ("sourceExamples/java") {
        include '**/*'
    }
    
    from ("targets/dist") {
        include "BUILD-jhdf5.INFO"
    }
}

180
task distributionZip(type: Zip, dependsOn: [jar, toolsJar, allJar, nativeJarLinuxIntel, nativeJarMacIntel, nativeJarWindowsIntel, batteriesIncluded, javadocZip, sourcesJar, exampleZip]) {
181
    baseName "${project.group}-jhdf5"
anttil's avatar
anttil committed
182

183
    from (jar.archivePath) {
184
185
        into "${project.group}-jhdf5/lib"
        rename '(.*)', "${project.group}-jhdf5-core.jar"
186
187
188
    }
    
    from (toolsJar.archivePath) {
189
190
        into "${project.group}-jhdf5/lib"
        rename '(.*)', "${project.group}-jhdf5-tools.jar"
191
192
193
    }

    from (allJar.archivePath) {
194
195
        into "${project.group}-jhdf5/lib"
        rename '(.*)', "${project.group}-jhdf5.jar"
196
197
198
    }
    
    from (configurations.runtime) {
199
200
        exclude '*restriction*'
        exclude '*bcel*'
201
        into "${project.group}-jhdf5/lib"
202
    }
anttil's avatar
anttil committed
203
    
204
    from (zipTree(batteriesIncluded.archivePath)) {
205
        into "${project.group}-jhdf5/lib/native"
206
        include 'native/**'
anttil's avatar
anttil committed
207
208
    }
    
209
    from (nativeJarLinuxIntel.archivePath) {
210
        into "${project.group}-jhdf5/lib/nativejar"
anttil's avatar
anttil committed
211
212
    }
    
213
    from (nativeJarMacIntel.archivePath) {
214
        into "${project.group}-jhdf5/lib/nativejar"
anttil's avatar
anttil committed
215
216
217
    }
    
    from (nativeJarWindowsIntel.archivePath) {
218
        into "${project.group}-jhdf5/lib/nativejar"
anttil's avatar
anttil committed
219
220
    }

221
    from (batteriesIncluded.archivePath) {
222
        into "${project.group}-jhdf5/lib/batteries_included"
anttil's avatar
anttil committed
223
224
225
    }

    from ("dist") {
226
        into "${project.group}-jhdf5"
anttil's avatar
anttil committed
227
228
229
    }
    
    from (javadocZip.archivePath) {
230
        into "${project.group}-jhdf5/doc"
anttil's avatar
anttil committed
231
232
233
    }
    
    from (exampleZip.archivePath) {
234
        into "${project.group}-jhdf5/doc"
anttil's avatar
anttil committed
235
236
237
    }    
    
    from (sourcesJar.archivePath) {
238
239
        into "${project.group}-jhdf5/src"
        rename '(.*)', "${project.group}-jhdf5-src.zip"
anttil's avatar
anttil committed
240
    }
241
242
243
244
245
246
247
248
249
250
251

	// BR 2014-06-09:
	// This is a workaround for an issue in Gradle: if one of entries from a jar file gets extraced read-only, 
	// overwriting it in a subsequent run will fail. It should be fixed in a future version of Gradle.
	// See http://forums.gradle.org/gradle/topics/ziptree_unable_to_overwrite_temporary_read_only_files 
    doLast {
        exec {
            commandLine = "chmod -R u+w $buildDir/tmp/expandedArchives".tokenize()
        }
    }

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
if (project == project.rootProject)
{
    publishing {
        publications {
            artifacts(IvyPublication) {
                module "${project.group}-jhdf5"
                revision project.revisionForPublication
                from components.java
                artifact(toolsJar) {
                    name = "${project.group}-jhdf5-tools"
                    conf = "runtime"
                }
                artifact(nativeJarLinuxIntel) {
                    name = "hdf5-linux-intel"
                    conf = "runtime"
                }
                artifact(nativeJarMacIntel) {
                    name = "hdf5-macosx-intel"
                    conf = "runtime"
                }
                artifact(nativeJarWindowsIntel) {
                    name = "hdf5-windows-intel"
                    conf = "runtime"
                }
                artifact(sourcesJar) {
                    type = "source"
                }
                descriptor {
                    withXml {
                        asNode().dependencies.dependency.find { it.@org == 'rinn' }.replaceNode {}
                    }
285
286
                }
            }
287
288
289
290
        }
    }
}

291
build.dependsOn distributionZip
292