build.gradle 8.34 KB
Newer Older
anttil's avatar
anttil committed
1
apply from: '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
        include 'native/jhdf5/amd64-Linux/**/*'
49
        include 'native/jhdf5/arm-Linux/**/*'
anttil's avatar
anttil committed
50
51
    }
    
52
53
54
    from('targets/dist') {
        include 'BUILD*INFO'
    }    
anttil's avatar
anttil committed
55
56
}

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

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

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

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

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

    from (configurations.runtime.collect {zipTree(it)}) {
        exclude 'native/**/*'
105
        exclude 'BUILD-*.INFO'
106
    }
107
108
109
110

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

118

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

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

brinn's avatar
brinn committed
144
145
146
147
148
149
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/**"
brinn's avatar
brinn committed
150
151
	include "ch/ethz/sis/hdf5/**"
	include "hdf/hdf5lib/exceptions/**"
brinn's avatar
brinn committed
152
	exclude "ch/systemsx/cisd/hdf5/hdf5lib/**"
brinn's avatar
brinn committed
153
	exclude "ch/ethz/sis/hdf5/hdf5lib/**"
brinn's avatar
brinn committed
154
155
156
157
158
159
160
161
162
	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) {
163
    archiveName "${project.group}-jhdf5-javadoc.zip"
anttil's avatar
anttil committed
164
    from javadoc.destinationDir
165
166
}

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

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

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

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

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

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

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

	// 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()
        }
    }

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
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 {}
                    }
284
285
                }
            }
286
287
288
289
        }
    }
}

290
build.dependsOn distributionZip
291