Skip to content

Commit

Permalink
adding gradle script to build and upload
Browse files Browse the repository at this point in the history
adding a gradle script that calls through to the Makefile
  • Loading branch information
lbergelson committed Feb 24, 2017
1 parent dfd1a9b commit d221bbc
Show file tree
Hide file tree
Showing 9 changed files with 430 additions and 25 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.gradle
.idea
build
src/main/c/bwa
src/main/c/*.o
src/main/c/*.dylib
src/main/c/*.so
*.swp
47 changes: 23 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,34 @@ JNI code for bwa mem.
This project builds dynamic libraries with a JNI API.
It allows Java code to call Heng Li's bwa mem aligner.

The makefile in src/main/c will build an appropriate library for Mac OSX or x86_64 Linux.
Pre-compiled dynamic libraries for these OS's exist in src/main/resources.
To build you'll need gmake, git, gcc, and Java 8.

To deploy into maven central:
Find a Mac.
Clone this repository.
Go into ```src/main/c```.
Type ```make``` (you'll need gmake, git, and gcc).
Copy ```libbwa.Darwin.dylib``` to ```src/main/resources```.
Type ```make clean```.
Go back up to the repo root, and type ```gradle test``` to run the Java unit tests.
Find a Linux machine.
Clone this repository.
Go into ```src/main/c```.
Type ```make``` (you'll need gmake, git, and gcc).
Copy ```libbwa.Linux.so``` to ```src/main/resources```.
Type ```make clean```.
Go back up to the repo root, and type ```gradle test``` to run the Java unit tests.
Copy ```src/main/resources/libbwa.Linux.so``` to ```src/main/resources``` ON THE MAC.
(Yes, you have to copy it to the other machine.)
Go back to the Mac.
Type ```gradle deploy``` (you'll need gradle).
To build and install a snapshot locally:

```
./gradlew install
```

To use this JNI binding on some architecture for which we don't provide a binary:
Clone the repo.
This will work for testing but will only include a native library for your system.

To upload a snapshot from a Broad Institute OSX machine with both OSX and Linux binaries:
```
commit your changes and push your branch to github
scripts/build_both_dylib_and_so.sh
./gradlew uploadArchives printVersion
```

To upload to maven central
```
commit your changes and push your branch to github
git tag -a -s <version>
scripts/build_both_dylib_and_so.sh
./gradlew uploadArchive -Drelease=true
```

To use this JNI binding on another architecture for which we don't provide a binary:
Go into ```src/main/c```.
Modify the Makefile to produce a library name appropriate to your system.
Type ```make``` (you'll need gmake, git, and gcc).
Move the library you built somewhere permanent on your machine.
Use ```-DLIBBWA_PATH=<that permanent location>``` when you run GATK (or other Java program).

151 changes: 150 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
apply plugin: 'java'
buildscript {
repositories {
jcenter()
}
}

plugins {
id 'java'
id 'maven'
id 'signing'
id 'com.palantir.git-version' version '0.5.1' //version helper
}

repositories {
mavenCentral()
Expand All @@ -8,6 +19,144 @@ dependencies {
testCompile 'org.testng:testng:6.9.6'
}

final isRelease = Boolean.getBoolean("release")
version = (isRelease ? gitVersion() : gitVersion() + "-SNAPSHOT").replaceAll(".dirty", "")
group = "org.broadinstitute"
String cpath = "src/main/c"
String libname = "libbwa"

task buildBwaLib(type: Exec){
workingDir "$cpath"
outputs.files "$cpath/libbwa*"
outputs.dir "$cpath/bwa"
commandLine "make"
String home = System.properties."java.home"
//strip the trailing jre
String corrected = home.endsWith("jre") ? home.substring(0, home.length() - 4) : home
environment JAVA_HOME : corrected
doFirst { println "using $home -> $corrected as JAVA_HOME" }
}
clean {
delete "$cpath/bwa"
delete "$cpath/$libname*"
delete fileTree("$cpath") {include "$libname*", "*.o"}
}
processResources {
dependsOn buildBwaLib
from cpath
include "$libname*"
}
test {
useTestNG()
testLogging {
testLogging {
events "skipped", "failed"
exceptionFormat = "full"
}
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
println "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
}
}
}
}
javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
/**
*This specifies what artifacts will be built and uploaded when performing a maven upload.
*/
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
/**
* Sign non-snapshot releases with our secret key. This should never need to be invoked directly.
*/
signing {
required { isRelease && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
def assertLibExists(lib){
if ( ! file(lib).exists()){
throw new GradleException("Could not perform a maven release because $lib is missing. You must include both OSX and Linux binaries to release. " +
"You can run scripts/build_both_dylib_and_so.sh to build both if you are on a Broad Institute connected mac.")
}
}
/**
* Upload a release to sonatype. You must be an authorized uploader and have your sonatype
* username and password information in your gradle properties file. See the readme for more info.
*
* For releasing to your local maven repo, use gradle install
*/
uploadArchives {
doFirst {
println "Attempting to upload version:$version"
if (isRelease){
assertLibExists("$cpath/${libname}.Linux.so")
assertLibExists("$cpath/${libname}.Darwin.dylib")
}
}
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: project.findProperty("sonatypeUsername"), password: project.findProperty("sonatypePassword"))
}

snapshotRepository(url: "https://artifactory.broadinstitute.org/artifactory/libs-snapshot-local/") {
authentication(userName: System.env.ARTIFACTORY_USERNAME, password: System.env.ARTIFACTORY_PASSWORD)
}

pom.project {
name 'gatk-bwamem-jni'
packaging 'jar'
description 'java bindings for the bwa-mem assembler'
url 'http://github.com/broadinstitute/gatk-bwamem-jni'

scm {
url 'scm:[email protected]:broadinstitute/gatk-bwamem-jni.git'
connection 'scm:[email protected]:broadinstitute/gatk-bwamem-jni.git'
developerConnection 'scm:[email protected]:broadinstitute/gatk-bwamem-jni.git'
}

developers {
developer {
id = "gatkdev"
name = "GATK Development Team"
email = "[email protected]"
}
}

licenses {
license {
name 'BSD 3-Clause'
url 'https://github.com/broadinstitute/gatk-bwamem-jni/blob/master/LICENSE.TXT'
distribution 'repo'
}
}
}
}
}
}

Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Thu Feb 16 17:46:58 EST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip
Loading

0 comments on commit d221bbc

Please sign in to comment.