apply from: '../gradle/javaproject.gradle' group='sis' dependencies { compile 'cisd:cisd-args4j:+', 'cisd:cisd-base:+', 'rinn:restrictions:+' testCompile 'testng:testng:+', 'jmock:jmock:+' } tasks.withType(Test) { 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" } // 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' } } jar { baseName "${project.group}-jhdf5-core" from (sourceSets.main.output.classesDir) { exclude('ch/systemsx/cisd/hdf5/h5ar') exclude('ch/systemsx/cisd/hdf5/io') } from('targets/dist') { include 'BUILD*INFO' } manifest { attributes 'Main-Class': 'ch.systemsx.cisd.hdf5.BuildAndEnvironmentInfo' attributes 'Class-Path': configurations.runtime.collect { it.getName() }.join(' ') } } task nativeJarLinuxIntel(type: Jar) { archiveName 'hdf5-linux-intel.jar' from ("libs") { include 'native/jhdf5/amd64-Linux/**/*' include 'native/jhdf5/i386-Linux/**/*' include 'native/jhdf5/arm-Linux/**/*' } from('targets/dist') { include 'BUILD*INFO' } } task nativeJarMacIntel(type: Jar) { archiveName 'hdf5-macosx-intel.jar' from ("libs") { include 'native/jhdf5/i386-Mac OS X/**/*' include 'native/jhdf5/x86_64-Mac OS X/**/*' } from('targets/dist') { include 'BUILD*INFO' } } task nativeJarWindowsIntel(type: Jar) { archiveName 'hdf5-windows-intel.jar' from ("libs") { include 'native/jhdf5/amd64-Windows/**/*' include 'native/jhdf5/x86-Windows/**/*' } from('targets/dist') { include 'BUILD*INFO' } } task toolsJar(type: Jar, dependsOn: [compileJava]) { baseName "${project.group}-jhdf5-tools" from (sourceSets.main.output.classesDir) { include('ch/systemsx/cisd/hdf5/h5ar/**/*') include('ch/systemsx/cisd/hdf5/io/**/*') } from('targets/dist') { include 'BUILD*INFO' } manifest { attributes 'Main-Class': 'ch.systemsx.cisd.hdf5.h5ar.HDF5ArchiverMain' attributes 'Class-Path': configurations.runtime.collect { it.getName() }.join(' ') + " ${project.group}-jhdf5-core.jar " + [nativeJarLinuxIntel, nativeJarMacIntel, nativeJarWindowsIntel].collect {it.archiveName}.join(' ') } } task allJar(type: Jar, dependsOn: [compileJava]) { baseName "${project.group}-jhdf5" from (sourceSets.main.output.classesDir) { include '**/*' } from (configurations.runtime.collect {zipTree(it)}) { exclude 'native/**/*' exclude 'BUILD-*.INFO' } from('targets/dist') { include 'BUILD*INFO' } manifest { attributes 'Main-Class': 'ch.systemsx.cisd.hdf5.h5ar.HDF5ArchiverMain' attributes 'Class-Path': [nativeJarLinuxIntel, nativeJarMacIntel, nativeJarWindowsIntel].collect {it.archiveName}.join(' ') } } task batteriesIncluded(type: Jar, dependsOn: [allJar, nativeJarLinuxIntel, nativeJarMacIntel, nativeJarWindowsIntel]) { archiveName "${project.group}-jhdf5-batteries_included.jar" from (zipTree(allJar.archivePath)) { include '**/*' } from (configurations.runtime.collect {zipTree(it)}) { include 'native/**/*' } from (zipTree(nativeJarLinuxIntel.archivePath)) { include 'native/**/*' } from (zipTree(nativeJarMacIntel.archivePath)) { include 'native/**/*' } from (zipTree(nativeJarWindowsIntel.archivePath)) { include 'native/**/*' } manifest { attributes 'Main-Class': 'ch.systemsx.cisd.hdf5.h5ar.HDF5ArchiverMain' } } 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) { archiveName "${project.group}-jhdf5-javadoc.zip" from javadoc.destinationDir } task exampleZip(type: Jar) { archiveName "${project.group}-jhdf5-examples-src.zip" from ("sourceExamples/java") { include '**/*' } from ("targets/dist") { include "BUILD-jhdf5.INFO" } } task distributionZip(type: Zip, dependsOn: [jar, toolsJar, allJar, nativeJarLinuxIntel, nativeJarMacIntel, nativeJarWindowsIntel, batteriesIncluded, javadocZip, sourcesJar, exampleZip]) { baseName "${project.group}-jhdf5" from (jar.archivePath) { into "${project.group}-jhdf5/lib" rename '(.*)', "${project.group}-jhdf5-core.jar" } from (toolsJar.archivePath) { into "${project.group}-jhdf5/lib" rename '(.*)', "${project.group}-jhdf5-tools.jar" } from (allJar.archivePath) { into "${project.group}-jhdf5/lib" rename '(.*)', "${project.group}-jhdf5.jar" } from (configurations.runtime) { exclude '*restriction*' exclude '*bcel*' into "${project.group}-jhdf5/lib" } from (zipTree(batteriesIncluded.archivePath)) { into "${project.group}-jhdf5/lib/native" include 'native/**' } from (nativeJarLinuxIntel.archivePath) { into "${project.group}-jhdf5/lib/nativejar" } from (nativeJarMacIntel.archivePath) { into "${project.group}-jhdf5/lib/nativejar" } from (nativeJarWindowsIntel.archivePath) { into "${project.group}-jhdf5/lib/nativejar" } from (batteriesIncluded.archivePath) { into "${project.group}-jhdf5/lib/batteries_included" } from ("dist") { into "${project.group}-jhdf5" } from (javadocZip.archivePath) { into "${project.group}-jhdf5/doc" } from (exampleZip.archivePath) { into "${project.group}-jhdf5/doc" } from (sourcesJar.archivePath) { into "${project.group}-jhdf5/src" rename '(.*)', "${project.group}-jhdf5-src.zip" } // 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() } } } 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 {} } } } } } } build.dependsOn distributionZip